:root {
  --night: #05080f;
  --ink: #ece6d8;
  --dim: #a9a79f;
  --lamp: #ff9a3d;
  --line: rgb(236 230 216 / 0.18);
  --target: 24px;
  --pad: clamp(1.25rem, 4vw, 3.5rem);
  color-scheme: dark;
}

@media (pointer: coarse) {
  :root { --target: 44px; }
}

html {
  background: var(--night);
  overscroll-behavior: none;
}

body {
  margin: 0;
  min-block-size: 100dvh;
  color: var(--ink);
  font: 400 1rem/1.5 "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
  overflow-wrap: break-word;
  -webkit-font-smoothing: antialiased;
}

h1 { text-wrap: balance; }

/* ---------- the 3D canvas and the layers above it ---------- */

#scene,
#poster,
#shade,
#veil {
  position: fixed;
  inset: 0;
  inline-size: 100%;
  block-size: 100%;
}

#scene {
  display: block;
  touch-action: none;
  outline: none;
}
/* The old-game look draws few pixels and shows each one as a crisp square. */
#scene.pixels { image-rendering: pixelated; }

/* The photo, shown until the 3D version of it has loaded. Its size and position are set from
   script so it lines up with the 3D framing. */
#poster {
  background: var(--night) url("../static/poster.jpg") no-repeat 50% 100% / auto 100%;
  transition: opacity 1.4s ease;
}
#poster.gone { opacity: 0; }

/* Darkens the edges on the opening screen so the text stays readable. */
#shade {
  pointer-events: none;
  background:
    linear-gradient(to right, var(--night) 0%, transparent 16%, transparent 84%, var(--night) 100%),
    radial-gradient(120% 90% at 50% 55%, transparent 50%, rgb(3 5 10 / 0.55) 100%),
    linear-gradient(to bottom, rgb(3 5 10 / 0.35) 0%, transparent 28%, transparent 66%, rgb(3 5 10 / 0.6) 100%);
  transition: opacity 1s ease;
}
#shade.gone { opacity: 0; }

/* Full-screen fade used between the opening shot and the forest. */
#veil {
  pointer-events: none;
  background: #02040a;
  opacity: 0;
  transition: opacity 0.7s ease;
}
#veil.on { opacity: 1; }

/* ---------- buttons ---------- */

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  min-block-size: var(--target);
  min-inline-size: var(--target);
}

button:focus-visible {
  outline: 2px solid var(--lamp);
  outline-offset: 3px;
}

#enter,
#resume,
#actions button,
#jump {
  padding: 0.8em 2.2em;
  border: 1px solid rgb(236 230 216 / 0.55);
  border-radius: 999px;
  background: rgb(5 8 15 / 0.35);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 0.8rem;
  backdrop-filter: blur(6px);
  transition: border-color 0.25s ease, box-shadow 0.25s ease, color 0.25s ease;
}

:is(#enter, #resume, #act, #smoke, #swing, #drop, #jump):hover {
  border-color: var(--lamp);
  color: #fff3e2;
  box-shadow: 0 0 32px rgb(255 154 61 / 0.3);
}

/* ---------- opening screen ---------- */

#title {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: 1fr auto;
  justify-items: center;
  padding:
    max(var(--pad), env(safe-area-inset-top, 0px))
    max(var(--pad), env(safe-area-inset-right, 0px))
    max(var(--pad), env(safe-area-inset-bottom, 0px))
    max(var(--pad), env(safe-area-inset-left, 0px));
  text-align: center;
  transition: opacity 0.6s ease;
}
#title.gone {
  opacity: 0;
  pointer-events: none;
}

#title header {
  align-self: start;
  padding-block-start: clamp(1rem, 7vh, 5rem);
}

#band-name {
  margin: 0;
  font-weight: 200;
  font-size: clamp(3.2rem, 13vw, 9rem);
  line-height: 1;
  letter-spacing: 0.32em;
  margin-inline-end: -0.32em; /* the last letter's tracking would push the word off centre */
  text-shadow: 0 0 60px rgb(5 8 15 / 0.8);
}

#tagline {
  margin: 1.2rem 0 0;
  color: var(--dim);
  font-size: 0.82rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

.start {
  display: grid;
  justify-items: center;
  align-content: end;
  gap: 1rem;
  min-block-size: 7rem;
}

#load-text,
#keys {
  margin: 0;
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  text-wrap: balance; /* on a narrow phone the line splits evenly instead of leaving one word alone */
}

/* ---------- while walking ---------- */

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* The tiny aiming dot sits on the physical sticker selected by the centre of the view. */
#hud.aimed-at-link::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  translate: -50% -50%;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 2px 1px #241c18;
}

#hint {
  position: absolute;
  inset-inline: 0;
  inset-block-end: max(1.4rem, env(safe-area-inset-bottom, 0px));
  margin: 0;
  padding-inline: 1rem;
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-align: center;
  text-transform: uppercase;
  text-shadow: 0 1px 12px #000;
  transition: opacity 1.2s ease;
}
#hint.gone { opacity: 0; }

#cabin-status, #cabin-caption {
  position: absolute;
  inset-inline: 1rem;
  inset-block-end: max(4.5rem, calc(env(safe-area-inset-bottom) + 4rem));
  margin: 0 auto;
  max-inline-size: min(38rem, calc(100% - 2rem));
  inline-size: fit-content;
  padding: .35rem .8rem;
  color: #fff6e3;
  background: rgb(19 13 11 / .88);
  font-size: clamp(.87rem, 1.7vw, 1.05rem);
  line-height: 1.45;
  text-align: center;
  text-wrap: balance;
}
#cabin-status:empty, #cabin-caption:empty { display: none; }
#hud #captions {
  inset-inline: max(1rem, env(safe-area-inset-left)) auto;
  color: var(--ink);
}
#captions[aria-pressed="true"] { text-decoration: underline; }
@media (pointer: coarse) {
  #captions span { display: none; }
}

/* What can be done with the thing in front of the visitor: sit, pick up, smash. */
#actions {
  position: absolute;
  inset-block-end: max(4.2rem, calc(env(safe-area-inset-bottom, 0px) + 3rem));
  inset-inline: 0;
  display: flex;
  flex-wrap: wrap; /* a narrow window puts them on two lines */
  justify-content: center;
  gap: 0.6rem;
  white-space: nowrap;
}
#actions button { pointer-events: auto; }
#tools { display: contents; } /* on a computer: in the same row */
#smoke:disabled { opacity: 0.55; }
#jump { display: none; }
@media (pointer: coarse) {
  #jump {
    display: block;
    position: absolute;
    inset-inline-end: max(1rem, env(safe-area-inset-right));
    inset-block-end: max(1rem, env(safe-area-inset-bottom));
    padding-inline: 1.1rem;
    pointer-events: auto;
    touch-action: manipulation;
  }
  #actions {
    inset-block-end: max(4.75rem, calc(env(safe-area-inset-bottom) + 4rem));
    flex-wrap: nowrap;
    align-items: end;
    min-block-size: 3rem; /* keeps Swing and Drop in place while the prompt beside them comes and goes */
  }
  #actions button { padding-inline: 1.25rem; touch-action: manipulation; }
  #tools {
    position: absolute;
    inset-inline-end: max(1rem, env(safe-area-inset-right));
    inset-block-end: calc(100% + 0.8rem);
    display: grid;
    justify-items: end;
    gap: 0.8rem;
  }
  #drop { order: -1; } /* Swing, used the most, is the nearer of the two */
  #hint { padding-inline: 5rem; }
}

/* Forest audio and the optional jury captions. */
#captions,
#sound {
  position: absolute;
  inset-block-start: max(1rem, env(safe-area-inset-top, 0px));
  inset-inline-end: max(1rem, env(safe-area-inset-right, 0px));
  padding: 0.5em 1em;
  border: 0;
  background: none;
  color: var(--dim);
  font-size: 0.68rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-shadow: 0 1px 12px #000;
  pointer-events: auto;
}
#sound:hover { color: var(--ink); }

/* Touch: a thumb stick appears under the left thumb. */
#stick {
  position: absolute;
  inline-size: 104px;
  block-size: 104px;
  margin: -52px 0 0 -52px;
  border: 1px solid rgb(236 230 216 / 0.3);
  border-radius: 50%;
  opacity: 0;
  transition: opacity 0.2s ease;
}
#stick.on { opacity: 1; }
#stick-knob {
  position: absolute;
  inset: 50% auto auto 50%;
  inline-size: 44px;
  block-size: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: rgb(236 230 216 / 0.35);
}

#pause {
  position: fixed;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 1rem;
  background: rgb(3 5 10 / 0.55);
  backdrop-filter: blur(3px);
}
#pause p {
  margin: 0;
  color: var(--dim);
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  text-transform: uppercase;
}

[hidden] { display: none !important; }

.noscript {
  position: fixed;
  inset: auto 0 2rem;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  #poster,
  #shade,
  #veil,
  #title,
  #hint { transition-duration: 0.2s; }
}

/* ---------- the drum room ---------- */

/* Everything below shows only while the visitor sits at the drum kit. drum-play.js makes these
   inside #hud the first time someone sits down, and hides them again when they stand up. */

/* While the mouse is captured there is no pointer to aim with. This dot marks the middle of the
   screen: a click plays whatever it is on, and it turns amber over anything that can be played. */
#drum-aim {
  position: absolute;
  inset: 50% auto auto 50%;
  inline-size: 6px;
  block-size: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 0 0 0 1px rgb(5 8 15 / 0.45); /* a dark rim, so it still shows on a pale drum head */
  opacity: 0.38;
  transition: opacity 0.15s ease, background-color 0.15s ease;
}
#drum-aim.on {
  background: var(--lamp);
  opacity: 0.95;
}

/* Computers: which key plays what, laid out like the kit seen from the stool. It hangs at the top
   in the middle, below the line the sound switch is on: from the stool that strip is the rafters
   and the back wall, while the bottom corners hold the hi-hat and the crash. Every size inside is
   in ems, so the whole panel shrinks with the window. */
#drum-legend {
  position: absolute;
  inset-block: 3.2rem auto;
  inset-inline: 0;
  margin-inline: auto;
  inline-size: fit-content;
  padding: 0.9em 1.1em;
  background: rgb(19 13 11 / 0.72);
  color: var(--dim);
  font-size: clamp(0.58rem, min(1.3vh, 0.95vw), 0.72rem);
  letter-spacing: 0.16em;
  line-height: 1.3;
  text-transform: uppercase;
  white-space: nowrap;
  -webkit-user-select: none;
  user-select: none;
}
.drum-map {
  display: grid;
  grid-template-areas:
    "crash   tom1  tom2 ride"
    "hat     snare .    floor"
    "hatOpen kick  kick .";
  grid-template-columns: repeat(4, minmax(6.6em, auto));
  gap: 0.7em 1em;
}
.drum-piece {
  display: grid;
  align-content: start;
  justify-items: start;
  gap: 0.3em;
}
.drum-keys,
.drum-note {
  display: flex;
  align-items: center;
  gap: 0.4em;
}
/* Under the map: B for the band, E to stand up, Shift for a soft hit, a click on a drum. */
.drum-notes {
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: start;
  gap: 0.5em 1.4em;
  margin-block-start: 0.9em;
  padding-block-start: 0.8em;
  border-block-start: 1px solid var(--line);
}
#drum-legend kbd {
  box-sizing: border-box;
  min-inline-size: 2.1em;
  padding: 0.2em 0.45em;
  border: 1px solid var(--line);
  border-radius: 0.4em;
  color: var(--ink);
  font: inherit;
  font-size: 1.08em;
  letter-spacing: 0.02em;
  text-align: center;
}

/* Phones and tablets: a pad for every piece, in a cluster under each thumb. The hi-hat is in the
   bottom left corner, snare and kick in the bottom right. The middle row only has pads at the two
   edges, and the middle column only the Band button at the very bottom: on a narrow phone
   anything else there would lie on the page's own "Stand up" button, which sits in the middle
   between the bottom and the top row. */
#drum-pads {
  --drum-pad: max(44px, clamp(3rem, 13vmin, 4.5rem)); /* 48 px on a phone, never under the 44 a finger needs */
  position: absolute;
  inset-inline: max(0.5rem, env(safe-area-inset-left, 0px)) max(0.5rem, env(safe-area-inset-right, 0px));
  inset-block-end: max(0.5rem, env(safe-area-inset-bottom, 0px));
  display: grid;
  grid-template-areas:
    "crash   tom1 .    tom2  ride"
    "hatOpen .    .    .     floor"
    "hat     .    band snare kick";
  grid-template-columns: var(--drum-pad) var(--drum-pad) minmax(0, 1fr) var(--drum-pad) var(--drum-pad);
  grid-template-rows: repeat(3, var(--drum-pad));
  gap: 0.9rem 0.5rem; /* 0.9 between the rows lifts the top row well clear of "Stand up" */
}
.drum-pad,
#drum-band {
  min-inline-size: 44px;
  min-block-size: 44px;
  pointer-events: auto; /* #hud lets touches through to the 3D view; these take them */
  touch-action: none; /* no scrolling, zooming or double-tap wait under a playing finger */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
.drum-pad {
  padding: 0 0 0 0.12em; /* the spacing after the last letter would push the word off centre */
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  background: rgb(19 13 11 / 0.6);
  color: var(--dim);
  font-size: 0.6rem;
  letter-spacing: 0.12em;
  line-height: 1.25;
  text-transform: uppercase;
}
#drum-band {
  grid-area: band;
  place-self: end center; /* at the bottom of its space, under "Stand up" */
  max-inline-size: 100%;
  padding: 0.4em 0.9em;
  border: 1px solid rgb(236 230 216 / 0.55);
  border-radius: 999px;
  background: rgb(5 8 15 / 0.35);
  font-size: 0.68rem;
  letter-spacing: 0.2em;
  line-height: 1.25;
  text-transform: uppercase;
}
#drum-band[aria-pressed="true"] {
  border-color: var(--lamp);
  color: #fff3e2;
}
/* Upright touch screens only (phones, tablets): the advice to turn the screen, under the sound switch at the top. */
.drum-turn {
  position: fixed;
  inset-block-start: max(3.2rem, calc(env(safe-area-inset-top, 0px) + 2.6rem));
  inset-inline: 1rem;
  margin: 0;
  color: var(--dim);
  font-size: 0.62rem;
  letter-spacing: 0.16em;
  line-height: 1.5;
  text-align: center;
  text-transform: uppercase;
}
@media (orientation: landscape) {
  .drum-turn { display: none; }
}
body.drumming #hint { visibility: hidden; }

/* A piece that was just played lights up for a moment: at once, then fading back. In the key
   panel that is its name and its keys, and the very key that was pressed lights brightest. */
.drum-name,
#drum-legend kbd,
.drum-pad {
  transition: color 0.3s ease, border-color 0.3s ease, background-color 0.3s ease, transform 0.12s ease;
}
.drum-piece.lit .drum-name { color: #fff3e2; }
#drum-legend .lit kbd { border-color: rgb(255 154 61 / 0.5); }
#drum-legend kbd.lit {
  border-color: var(--lamp);
  background: rgb(255 154 61 / 0.16);
  color: #fff3e2;
}
.drum-pad.lit {
  border-color: var(--lamp);
  background: rgb(84 46 18 / 0.72);
  color: #fff3e2;
}
.drum-piece.lit .drum-name,
#drum-legend .lit kbd,
#drum-legend kbd.lit,
.drum-pad.lit { transition-duration: 0s; }

@media (prefers-reduced-motion: no-preference) {
  .drum-pad.lit { transform: scale(0.96); } /* gives a little under the finger */
}
@media (prefers-reduced-motion: reduce) {
  #drum-aim,
  .drum-name,
  #drum-legend kbd,
  .drum-pad { transition: none; }
}
