/* Miskolci Múzsa díj: a black stage, gold lettering, nothing else. The trophy and the opening curtain are drawn by scene.js.
   The page has three phases (data-phase on .stage): "title" (the shut curtain, nothing else), "intro" (the curtain is half open,
   the lettering comes up and the lamp flickers on behind it) and "lit" (the trophy turns, the status line appears). */

@font-face {
  font-family: "Antonio";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("antonio-300.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* the same face for the rest of the Latin letters: Hungarian ő and ű are not in the first file, and the weather names have them
   (the browser only loads this file when such a letter is on the page) */
@font-face {
  font-family: "Antonio";
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url("antonio-latin-ext-300.woff2") format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  color-scheme: dark;
  --stage: #000;
  --gold: #c9a35b;
  --gold-quiet: #9a7b42;
  --gold-faint: rgb(201 163 91 / 0.14);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --edge: clamp(1.25rem, 5vh, 3rem);
  --slow: 3.2s;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--stage);
}

body {
  color: var(--gold);
  font-family: "Antonio", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  font-weight: 300;
  overscroll-behavior: none;
}

::selection {
  background: var(--gold);
  color: var(--stage);
}

.stage {
  position: relative;
  height: 100%;
  min-height: 22rem;
  overflow: hidden;
}

#scene {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  outline: none;
}

#scene:active {
  cursor: grabbing;
}

#scene:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: -0.5rem;
}

/* the lettering of the original animation: thin, condensed, very widely spaced */
.title {
  position: absolute;
  top: var(--edge);
  left: 0;
  right: 0;
  margin: 0;
  padding-inline: 1rem;
  box-sizing: border-box;
  --tracking: 0.8em;
  font-size: clamp(0.85rem, 0.5rem + 1.6vw, 1.6rem);
  font-weight: 300;
  line-height: 1.3;
  letter-spacing: var(--tracking);
  text-indent: var(--tracking);
  text-align: center;
  text-transform: uppercase;
  text-wrap: balance;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  /* the title waits for the curtain: it comes up when the curtain is half open and the lamp starts (data-phase "intro", set
     by scene.js). The late animation is only for a page whose script never ran. */
  animation: title-in-late var(--slow) var(--ease-out) 12s forwards;
}

.stage[data-phase="intro"] .title,
.stage[data-phase="lit"] .title,
.stage[data-phase="game"] .title {
  animation: title-in var(--slow) var(--ease-out) forwards;
}

.sound:focus-visible,
.mixer-toggle:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 0.35rem;
}

.caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(0.75rem, 3vh, 1.75rem);
  padding-inline: 1rem;
  display: grid;
  gap: 0.6rem;
  justify-items: center;
  text-align: center;
  z-index: 1;
  pointer-events: none;
}

.status,
.hint {
  margin: 0;
  text-transform: uppercase;
  text-wrap: balance;
  opacity: 0;
  transition: opacity 2.6s var(--ease-out);
}

.status {
  font-size: clamp(0.95rem, 0.85rem + 0.4vw, 1.15rem);
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--gold-quiet);
}

.hint {
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  color: var(--gold-quiet);
}

.stage[data-phase="lit"] .status {
  opacity: 1;
}

.stage[data-phase="lit"] .hint {
  opacity: 1;
  transition-delay: 3.2s;
}

.hint[data-gone] {
  opacity: 0 !important;
  transition: opacity 0.6s var(--ease-out);
  transition-delay: 0s;
}

/* the speaker button (one switch for everything) and the volume button next to it */
.sound,
.mixer-toggle {
  position: absolute;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 3;
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--gold-quiet);
  cursor: pointer;
  opacity: 0;
  transition: color 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

/* the buttons are there from the start: without autoplay the speaker is how the sound is switched on */
.sound,
.mixer-toggle {
  animation: lettering-in 2s var(--ease-out) 4s forwards;
}

.sound:hover,
.mixer-toggle:hover,
.mixer-toggle[aria-expanded="true"] {
  color: var(--gold);
  border-color: var(--gold-quiet);
}

.mixer-toggle {
  right: calc(max(1rem, env(safe-area-inset-right, 0px)) + 3.25rem);
}

/* the four sliders: a thin gold line that fills up to the thumb, on the black of the stage */
.mixer {
  --panel-gap: 0.75rem;
  position: absolute;
  right: max(1rem, env(safe-area-inset-right, 0px));
  bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 2.75rem + var(--panel-gap));
  z-index: 3;
  display: grid;
  gap: 0.35rem;
  width: min(16rem, calc(100vw - 2rem));
  padding: 1rem 1.1rem 0.75rem;
  background: rgb(0 0 0 / 0.94);
  border: 1px solid var(--gold-faint);
  border-radius: 0.5rem;
  box-shadow: 0 0.75rem 2rem rgb(0 0 0 / 0.6);
  animation: mixer-in 0.35s var(--ease-out);
}

.mix {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  column-gap: 1rem;
}

.mix-name {
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-quiet);
}

.mix output {
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.mix input {
  grid-column: 1 / -1;
  --fill: 50%;
  width: 100%;
  height: 1.75rem;
  margin: 0;
  background: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.mix input::-webkit-slider-runnable-track {
  height: 2px;
  background: linear-gradient(to right, var(--gold) var(--fill), var(--gold-faint) var(--fill));
}

.mix input::-moz-range-track {
  height: 2px;
  background: var(--gold-faint);
}

.mix input::-moz-range-progress {
  height: 2px;
  background: var(--gold);
}

.mix input::-webkit-slider-thumb {
  width: 0.9rem;
  height: 0.9rem;
  margin-top: calc((2px - 0.9rem) / 2);
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  appearance: none;
  -webkit-appearance: none;
  transition: transform 0.2s var(--ease-out);
}

.mix input::-moz-range-thumb {
  width: 0.9rem;
  height: 0.9rem;
  border: 0;
  border-radius: 50%;
  background: var(--gold);
  transition: transform 0.2s var(--ease-out);
}

.mix input:hover::-webkit-slider-thumb,
.mix input:active::-webkit-slider-thumb {
  transform: scale(1.25);
}

.mix input:hover::-moz-range-thumb,
.mix input:active::-moz-range-thumb {
  transform: scale(1.25);
}

.mix input:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 0.1rem;
  border-radius: 0.25rem;
}

@keyframes mixer-in {
  from {
    opacity: 0;
    transform: translateY(0.4rem);
  }
}

@media (pointer: coarse) {
  .mix input {
    height: 2.75rem;
  }
}

.sound[data-muted="false"] .sound-off,
.sound[data-muted="true"] .sound-on {
  display: none;
}

/* the number of all visits, small, in the top right corner above the line of the title */
.visitors {
  position: absolute;
  top: max(0.75rem, env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  z-index: 3;
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--gold-quiet);
  opacity: 0;
  pointer-events: none;
  user-select: none;
  transition: opacity 2.6s var(--ease-out);
}

.visitors-number {
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

.stage[data-phase="lit"] .visitors {
  opacity: 1;
  transition-delay: 3.6s;
}

.stage[data-phase="game"] .visitors {
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
  transition-delay: 0s;
}

/* the weather of Miskolc at the bottom left, mirroring the sound buttons: a round button (the drawing of the weather, struck
   through when the effects on the stage are off) and three lines of text */
.weather {
  position: absolute;
  left: max(1rem, env(safe-area-inset-left, 0px));
  bottom: max(1rem, env(safe-area-inset-bottom, 0px));
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 2.6s var(--ease-out);
}

.stage[data-phase="lit"] .weather {
  opacity: 1;
  pointer-events: auto;
  transition-delay: 3.6s;
}

.weather-toggle {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: none;
  color: var(--gold-quiet);
  cursor: pointer;
  transition: color 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

.weather-toggle:hover {
  color: var(--gold);
  border-color: var(--gold-quiet);
}

.weather-toggle:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 0.35rem;
}

/* one drawing at a time, chosen by scene.js (data-glyph on .weather); the slash shows when the effects are off */
.glyph,
.weather-slash {
  display: none;
}

.weather[data-glyph="sun"] .glyph-sun,
.weather[data-glyph="moon"] .glyph-moon,
.weather[data-glyph="cloud"] .glyph-cloud,
.weather[data-glyph="fog"] .glyph-fog,
.weather[data-glyph="rain"] .glyph-rain,
.weather[data-glyph="snow"] .glyph-snow,
.weather[data-glyph="storm"] .glyph-storm,
.weather[data-glyph="hail"] .glyph-hail {
  display: inline;
}

.weather-toggle[aria-pressed="false"] .weather-slash {
  display: inline;
}

.weather-text {
  display: grid;
  gap: 0.15rem;
  min-width: 0;
  /* never as wide as the caption in the middle: a long name wraps instead */
  max-width: max(10rem, calc(50vw - 20rem));
}

.weather-text p {
  margin: 0;
  text-transform: uppercase;
}

.weather-now {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  color: var(--gold);
}

.weather[data-state="unavailable"] .weather-reading {
  display: none;
}

.weather-temp {
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.weather-unit {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: var(--gold-quiet);
}

.weather-label {
  font-size: 0.8rem;
  letter-spacing: 0.22em;
}

.weather-place,
.weather-credit {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--gold-quiet);
}

.weather-credit a {
  color: inherit;
  text-decoration: underline;
  text-decoration-color: var(--gold-faint);
  text-underline-offset: 0.25em;
  transition: color 0.3s var(--ease-out), text-decoration-color 0.3s var(--ease-out);
}

.weather-credit a:hover {
  color: var(--gold);
  text-decoration-color: var(--gold-quiet);
}

.weather-credit a:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 0.2rem;
}

.stage[data-phase="game"] .weather {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s var(--ease-out);
  transition-delay: 0s;
}

/* a narrow screen: the caption moves up out of the bottom row, which is for the weather and the sound buttons, and a long name
   of the weather wraps instead of running under the buttons */
@media (max-width: 40rem) {
  .caption {
    bottom: calc(max(1rem, env(safe-area-inset-bottom, 0px)) + 5.25rem);
  }

  .weather-text {
    max-width: calc(100vw - 12rem);
  }

  .weather-now {
    flex-wrap: wrap;
    column-gap: 0.75rem;
    row-gap: 0;
  }

  .weather-text p {
    white-space: normal;
  }
}

.fallback {
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 100%;
  height: auto;
}

/* the title comes up with its letters drawing slowly apart */
@keyframes title-in {
  from {
    opacity: 0;
    letter-spacing: calc(var(--tracking) * 0.8);
    text-indent: calc(var(--tracking) * 0.8);
  }
  to {
    opacity: 1;
  }
}

@keyframes title-in-late {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes lettering-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@media (max-width: 30rem) {
  .title {
    --tracking: 0.55em;
  }

  .status {
    letter-spacing: 0.2em;
    text-indent: 0.2em;
  }

}

/* without JavaScript there is no gate and no sound: the lettering and the picture are all there is */
@media (scripting: none) {
  .sound,
  .mixer-toggle,
  .weather,
  .visitors {
    display: none;
  }

  .title {
    animation: none;
    opacity: 1;
  }

  .status {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .title,
  .stage[data-phase] .title {
    animation: none;
    opacity: 1;
  }

  .status,
  .hint,
  .weather,
  .visitors {
    transition: none !important;
  }

  .sound,
  .mixer-toggle {
    animation: none;
    opacity: 1;
  }

  .mixer {
    animation: none;
  }
}

/* ---- the hidden game: the well is drawn on the canvas, the numbers and the buttons are here ---- */

[hidden] {
  display: none !important;
}

.stage[data-phase="game"] .caption {
  opacity: 0;
  transition: opacity 0.6s var(--ease-out);
}

.game {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  animation: lettering-in 1.2s var(--ease-out) both;
}

.game button {
  pointer-events: auto;
  border: 1px solid transparent;
  background: none;
  color: var(--gold-quiet);
  font: inherit;
  cursor: pointer;
  transition: color 0.3s var(--ease-out), border-color 0.3s var(--ease-out);
}

.game button:hover {
  color: var(--gold);
  border-color: var(--gold-quiet);
}

.game button:focus-visible {
  outline: 1px solid var(--gold);
  outline-offset: 0.35rem;
}

.game-close {
  position: absolute;
  top: max(var(--edge), env(safe-area-inset-top, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border-radius: 50%;
}

.game-stats {
  position: absolute;
  top: calc(var(--edge) + 3rem);
  left: max(1rem, env(safe-area-inset-left, 0px));
  display: grid;
  gap: 0.9rem;
  margin: 0;
}

.game-stats dt {
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-quiet);
}

.game-stats dd {
  margin: 0.1rem 0 0;
  font-size: 1.6rem;
  letter-spacing: 0.08em;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
}

/* scene.js moves this label to the spot above the preview of the next piece */
.game-next {
  position: absolute;
  margin: 0;
  transform: translate(-50%, -50%);
  font-size: 0.8rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gold-quiet);
  white-space: nowrap;
}

.game-help {
  position: absolute;
  left: 0;
  right: 0;
  bottom: clamp(0.75rem, 3vh, 1.75rem);
  margin: 0;
  padding-inline: 4.5rem;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-wrap: balance;
  color: var(--gold-quiet);
}

.game-note,
.game-over {
  position: absolute;
  top: 50%;
  left: 50%;
  margin: 0;
  transform: translate(-50%, -50%);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.4em;
  text-indent: 0.4em;
  color: var(--gold);
}

.game-note {
  font-size: 1.4rem;
}

.game-over {
  display: grid;
  gap: 1.25rem;
  justify-items: center;
  padding: 1.5rem 2rem;
  background: rgb(0 0 0 / 0.72);
}

.game-over p {
  margin: 0;
  font-size: 1.4rem;
}

.game-over button {
  padding: 0.6rem 1.6rem;
  border-color: var(--gold-quiet);
  font-size: 1rem;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-transform: uppercase;
}

/* the touch pad is only for devices without a keyboard */
.game-pad {
  display: none;
}

@media (pointer: coarse) {
  .game-help {
    display: none;
  }

  .game-pad {
    position: absolute;
    left: 0;
    right: 0;
    bottom: max(1rem, env(safe-area-inset-bottom, 0px));
    display: flex;
    justify-content: center;
    gap: 0.75rem;
  }

  .game-pad button {
    display: grid;
    place-items: center;
    width: 3.5rem;
    height: 3.5rem;
    padding: 0;
    border-color: var(--gold-faint);
    border-radius: 50%;
    touch-action: manipulation;
  }
}

@media (max-width: 30rem) {
  .game-stats {
    top: calc(var(--edge) + 2.75rem);
    gap: 0.5rem;
  }

  .game-stats dd {
    font-size: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game {
    animation: none;
  }
}
