/* sebbanyo.fr — waiting page.
   Yonah, a small mascot, repairs a steampunk machine; a current runs along a
   brass cable and lights the welcome sign (letter lamps, glyphs.css).
   Without JS or with reduced motion: machine on, sign lit, Yonah at rest.
   Font: Bricolage Grotesque (SIL OFL 1.1, see fonts/OFL.txt), self-hosted. */

@font-face {
  font-family: "Bricolage Grotesque";
  font-style: normal;
  font-weight: 200 800;
  font-stretch: 75% 100%;
  font-display: swap;
  src: url("fonts/bricolage-grotesque-latin.woff2") format("woff2");
}

:root {
  --night: #0b1020;
  --cream: #f3e6cf;
  --cream-soft: #c9bda9;      /* 9.9:1 on the night */
  --orange: #ff8a2a;
  --brass: #b8852f;
  /* Yonah's width; his height is 1.5 × (1024 × 1536 canvas). */
  --cw: min(max(110px, 15vw), 190px, 24dvh);
  color-scheme: dark;
}

*,
*::before,
*::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(120% 90% at 30% 20%, #151d38 0%, var(--night) 62%);
  color: var(--cream);
  font-family: "Bricolage Grotesque", system-ui, sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

p { margin: 0; }

::selection {
  background: var(--orange);
  color: var(--night);
}

:focus-visible {
  outline: 3px solid var(--orange);
  outline-offset: 4px;
}

/* ---- text ---------------------------------------------------------------- */
.masthead {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: clamp(1rem, 3vh, 2rem) clamp(1.25rem, 4vw, 3.5rem) 0;
  font-weight: 700;
}

.status {
  color: var(--orange);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scene {
  padding: clamp(1.5rem, 6vh, 4rem) clamp(1.25rem, 4vw, 3.5rem) 0;
}

.intro {
  position: relative;
  z-index: 2;
  max-width: min(62rem, 100%);
}

/* The sign: letter lamps from the glyph atlas. The real text stays in the
   page, transparent, for selection and copy; the heading is named by its
   aria-label for screen readers. Lit by default. */
.sign {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em 0.32em;
  margin: 0 0 clamp(1.25rem, 3vh, 2rem);
  padding-top: 0.3em;                       /* room for the accents */
  font-size: clamp(1.7rem, 4.4vw, 4.6rem);
  line-height: 1;
}

.word {
  display: inline-flex;
  gap: 0.02em;
  white-space: nowrap;
}

.g {
  position: relative;
  display: inline-block;
  height: 1em;
  color: transparent;
  font-size: 1em;
  line-height: 1;
  text-align: center;
  vertical-align: top;
}

.g::before,
.g::after {
  content: "";
  position: absolute;
  inset: 0;
  background-repeat: no-repeat;
  background-position: var(--gx) 0;
  pointer-events: none;
}

/* Front: the letter. Behind: the same letter with an orange drop-shadow,
   i.e. a glow from behind that follows its outline. Lit per letter by
   main.js (.is-lit, the spark hops from letter to letter); lit by default
   without JS (.is-lit-all). */
.g::before {
  z-index: 1;
  background-image: url("assets/letters-off.webp");
  transition: filter 220ms ease-out;
}

.g::after {
  z-index: 0;
  background-image: url("assets/letters-off.webp");
  filter: drop-shadow(0 0 0.06em rgb(255 170 80 / 0.95)) drop-shadow(0 0 0.22em rgb(255 110 20 / 0.7));
  opacity: 0;
  transition: opacity 260ms ease-out;
}

.sign.is-lit-all .g::before,
.g.is-lit::before,
.g.is-lit > .acc::before {
  background-image: url("assets/letters-on.webp");
  filter: brightness(1.08);
}

.sign.is-lit-all .g::after,
.g.is-lit::after,
.g.is-lit > .acc::after { opacity: 1; }

/* Accents sit on top of their letter. */
.acc {
  position: absolute;
  left: 50%;
  bottom: 94%;
  translate: -50% 0;
}

/* Wear: a lamp stutters. */
.g.is-flicker::before,
.g.is-flicker::after { animation: stutter 520ms steps(1, end) both; }

@keyframes stutter {
  0% { opacity: 1; }
  15% { opacity: 0.35; }
  30% { opacity: 1; }
  48% { opacity: 0.2; }
  62% { opacity: 0.9; }
  80% { opacity: 0.45; }
  100% { opacity: 1; }
}

.who {
  font-size: clamp(1.05rem, 0.9rem + 0.6vw, 1.45rem);
  font-weight: 700;
}

.what {
  margin-top: 0.2em;
  color: var(--cream-soft);
  font-size: clamp(1rem, 0.88rem + 0.5vw, 1.3rem);
}

.hint {
  margin-top: 1rem;
  color: var(--orange);
  font-size: 0.95rem;
}

/* ---- stage: the whole viewport ------------------------------------------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.cable {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.stage:not(.is-scripted) .cable { display: none; }   /* drawn by main.js */

/* Steampunk wiring: a thin cloth-covered wire with a copper braid, run along
   the walls and held by brass saddles. */
.cable path { fill: none; stroke-linecap: round; stroke-linejoin: round; }
.cable-base { stroke: #20150d; stroke-width: 3.6; }
.cable-braid { stroke: #b4703a; stroke-width: 1.6; stroke-dasharray: 2.4 3.2; stroke-linecap: butt; }
.cable-trail {
  stroke: #ffd79a;
  stroke-width: 2.6;
  opacity: 0;
  filter: drop-shadow(0 0 3px #ff8a2a) drop-shadow(0 0 6px rgb(255 110 20 / 0.6));
}
.cable-saddle { fill: #c9973f; stroke: #4e3412; stroke-width: 1; }
.cable-end { fill: #d8a957; stroke: #4e3412; stroke-width: 1.2; }

/* The machine: a real button, so the keyboard can repair it too. */
.machine {
  position: absolute;
  right: max(24px, 6vw);
  bottom: max(24px, 4vh);
  width: calc(0.93 * var(--cw) * 339 / 360);
  aspect-ratio: 339 / 360;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  -webkit-tap-highlight-color: transparent;
}

.machine img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transition: opacity 260ms ease-out;
}

.machine-on { opacity: 0; }
.machine.is-on .machine-on { opacity: 1; }
.machine:hover { filter: brightness(1.08); }
.machine.is-on { filter: drop-shadow(0 0 10px rgb(255 120 30 / 0.35)); }
.machine.is-shuddering { animation: shudder var(--shudder-time, 420ms) linear; }
.machine.is-on.wear-3,
.machine.is-on.wear-4 { filter: drop-shadow(0 0 6px rgb(255 120 30 / 0.22)) brightness(0.94); }
.machine.is-on.wear-5 { animation: falter 900ms steps(1, end) infinite; }

@keyframes shudder {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  20% { translate: calc(var(--amp, 1px) * -1) 0; rotate: calc(var(--rot, 0.3deg) * -1); }
  40% { translate: var(--amp, 1px) calc(var(--amp, 1px) * -0.5); rotate: 0deg; }
  60% { translate: calc(var(--amp, 1px) * -0.7) 0; rotate: var(--rot, 0.3deg); }
  80% { translate: calc(var(--amp, 1px) * 0.5) 0; rotate: 0deg; }
}

@keyframes falter {
  0%, 100% { filter: drop-shadow(0 0 6px rgb(255 120 30 / 0.2)) brightness(0.92); }
  40% { filter: brightness(0.7); }
  55% { filter: drop-shadow(0 0 8px rgb(255 120 30 / 0.3)) brightness(1); }
}

/* Yonah: positioned by his feet, tilts around them while running. Without
   JS he stands at the machine. */
.character {
  position: absolute;
  left: calc(100vw - max(24px, 6vw) - 1.622 * var(--cw));
  bottom: max(24px, 4vh);
  margin: 0;
  width: var(--cw);
  aspect-ratio: 1024 / 1536;
  transform-origin: 50% 100%;
  user-select: none;
}

.stage.is-scripted .character,
.stage.is-scripted .machine {
  left: 0;
  top: 0;
  right: auto;
  bottom: auto;
}

.character::after {             /* ground shadow */
  content: "";
  position: absolute;
  left: 18%;
  right: 16%;
  bottom: -1.5%;
  height: 4%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgb(0 0 0 / 0.55), transparent);
  z-index: -1;
}

.facing,
.rig,
.frames {
  position: absolute;
  inset: 0;
}

.facing.is-left { transform: scaleX(-1); }

.frames {
  width: 100%;
  height: 100%;
}

.body-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

/* Head files: 1254 × 1254 at 0.691, set on the neck, over the collar. */
.head {
  position: absolute;
  z-index: 1;
  left: 6.63%;
  top: -1.73%;
  width: 84.6%;
  aspect-ratio: 1;
  transform-origin: 51% 77%;
}

.face,
.eyes {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.face { visibility: hidden; }
.head[data-face="neutral"] .face-neutral,
.head[data-face="grin"] .face-grin,
.head[data-face="surprised"] .face-surprised,
.head[data-face="sad"] .face-sad { visibility: visible; }
.head.is-blinking .face-blink { visibility: visible; }
.head.is-blinking .eyes { visibility: hidden; }

.iris { fill: #5a3418; }
.pupil-core { fill: #160b06; }
.glint { fill: #fff8ec; }

/* Smoke that stays: one more curl at each wear stage, thick after the fuse
   blows, a thin wisp while the machine is broken. Positioned on the
   machine's lamp by main.js; only transform and opacity are animated. */
.smoke {
  position: absolute;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
}

.puff {
  position: absolute;
  left: calc(var(--s, 60px) * -0.5);
  top: calc(var(--s, 60px) * -0.8);
  width: var(--s, 60px);
  height: var(--s, 60px);
  background: url("assets/explosion.webp") no-repeat 100% 0 / 400% 100%;   /* the wisp */
  opacity: 0;
  display: none;
  animation: smoke-rise 3.4s linear infinite;
}

.puff:nth-child(1) { animation-delay: -1s; }   /* already rising when it appears */
.puff:nth-child(2) { --drift: -18px; animation-delay: -0.7s; background-position: 66.666% 0; }  /* a cloud */
.puff:nth-child(3) { --drift: 14px; animation-delay: -1.4s; }
.puff:nth-child(4) { --drift: -8px; animation-delay: -2.1s; background-position: 66.666% 0; }
.puff:nth-child(5) { --drift: 22px; animation-delay: -2.8s; }

.smoke[data-level="1"] .puff:nth-child(-n+1),
.smoke[data-level="2"] .puff:nth-child(-n+2),
.smoke[data-level="3"] .puff:nth-child(-n+3),
.smoke[data-level="4"] .puff:nth-child(-n+4),
.smoke[data-level="5"] .puff { display: block; }

.smoke[data-level="4"],
.smoke[data-level="5"] { --s: 80px; }

@keyframes smoke-rise {
  0% { transform: translate(0, 0) scale(0.45); opacity: 0; }
  12% { opacity: 0.75; }
  70% { opacity: 0.35; }
  100% { transform: translate(var(--drift, 10px), -130px) scale(1.5); opacity: 0; }
}

/* Sprite effects (4 frames each), moved and stepped by main.js. */
.fx {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  background-repeat: no-repeat;
  background-size: 400% 100%;
}

.fx-spark { width: 70px; height: 70px; background-image: url("assets/sparks.webp"); }
.fx-boom { width: 120px; height: 120px; background-image: url("assets/explosion.webp"); }

@media (prefers-reduced-motion: reduce) {
  .g::before, .g::after, .machine img { transition: none; }
  .g.is-flicker::before, .g.is-flicker::after, .machine { animation: none !important; }
  .smoke { display: none; }
}

@media print {
  .stage { display: none; }
}
