/* ==========================================================================
   Scene three — the time machine.
   The room, floor mechanism, clock and timeline rail are drawn on a WebGL
   canvas. The six year cards are DOM: each carries real text that has to stay
   crisp and reachable, and they are positioned by JS from the same fitted
   geometry the canvas draws with, so the layers cannot drift apart.
   ========================================================================== */

@font-face {
  font-family: 'Bodoni Moda';
  src: url('../../public/fonts/bodonimoda-400.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}

.chrono {
  --amber: #ffa03c;
  --ember: #ff3c14;
  --cream: #f4e9dc;

  position: relative;
  height: 240svh;              /* travel for the intro to breathe into */
  background: #060505;
}

.chrono__pin {
  position: sticky;
  top: 0;
  height: 100svh;
  overflow: hidden;
}

#chronoStage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* The figure's own canvas, stacked OVER the card deck: he stands in front of
   the timeline with the cards passing behind his shoulders. Transparent, and
   inert to the pointer so the cards underneath stay hoverable and clickable. */
#chronoFront {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 6;
}

/* --------------------------------------------------------------------------
   Editorial furniture
   -------------------------------------------------------------------------- */

.chrono__title,
.chrono__rail,
.chrono__hint,
.chrono__note {
  position: absolute;
  margin: 0;
  pointer-events: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1.1s var(--ease-out), transform 1.2s var(--ease-out);
}
.chrono.is-live .chrono__rail,
.chrono.is-live .chrono__hint,
.chrono.is-live .chrono__note { opacity: 1; transform: none; }
.chrono.is-live .chrono__title span {
  display: block;
  clip-path: inset(0 0 100% 0);
  opacity: 0;
  filter: blur(8px);
  letter-spacing: .7em;
  transform: translate3d(0, .6em, 0);
}
.chrono.is-title .chrono__title span {
  clip-path: inset(0 0 -20% 0);
  opacity: 1;
  filter: blur(0);
  letter-spacing: .30em;
  transform: none;
  transition:
    clip-path 1s var(--ease-expo) calc(var(--w, 0) * .28s),
    opacity .6s ease calc(var(--w, 0) * .28s),
    filter .9s var(--ease-out) calc(var(--w, 0) * .28s),
    letter-spacing 1.6s var(--ease-expo) calc(var(--w, 0) * .28s),
    transform 1.1s var(--ease-expo) calc(var(--w, 0) * .28s);
}
.chrono__title span:nth-child(2) { --w: 1; }
.chrono__title span:nth-child(3) { --w: 2; }
.chrono__title span:nth-child(4) { --w: 3; }
/* the brand-red hairline under it draws once the words are in */
.chrono__title::after {
  content: '';
  display: block;
  width: 2.4em;
  height: 2px;
  margin-top: .5em;
  background: var(--brand-red, #fb141a);
  transform: scaleX(0);
  transform-origin: left;
}
.chrono.is-title .chrono__title::after {
  transform: none;
  transition: transform 1.1s var(--ease-expo) 1.25s;
}

/* beside the rail's end dot beyond 2026: a second dot, what comes next */
.yr-next {
  position: absolute;
  width: 9px;
  height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: #fff1e0;
  box-shadow: 0 0 10px 2px rgba(255, 150, 60, .75), 0 0 26px 6px rgba(255, 90, 30, .35);
  /* just before the end dot, on the rail */
  transform: translateX(-26px);
  opacity: var(--in, 0);
  pointer-events: none;
  animation: nextBeat 1.6s ease-in-out infinite;
}
@keyframes nextBeat { 50% { transform: translateX(-26px) scale(.6); opacity: calc(var(--in, 0) * .5); } }
.chrono.is-portrait .yr-next { transform: translateY(-26px); animation: none; }

.chrono__rail { transition-delay: .15s; }
.chrono.is-live .chrono__hint { transition-delay: .25s; }
.chrono.is-live .chrono__note { transition-delay: .3s; }

/* the title is the scene's first beat: each word rises out of its own
   mask, defocused and widely tracked, and settles - one after another */
.chrono__title {
  opacity: 1;
  transform: none;
  left: clamp(18px, 3vw, 54px);
  top: clamp(26px, 5.5vh, 62px);
  display: grid;
  gap: .18em;
  font-family: 'Bodoni Moda', 'Times New Roman', serif;
  font-weight: 400;
  font-size: clamp(15px, 1.75vw, 27px);
  line-height: 1;
  letter-spacing: .30em;
  text-transform: uppercase;
  color: var(--cream);
}

.chrono__rail {
  left: clamp(18px, 3vw, 54px);
  top: clamp(150px, 24vh, 240px);
  display: grid;
  gap: .95em;
  font-family: var(--ui);
  font-size: clamp(7.5px, .62vw, 9.5px);
  font-weight: 400;
  letter-spacing: .38em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, .62);
  line-height: 1;
}
.chrono__rail i,
.chrono__hint i,
.chrono__note i {
  display: block;
  width: 26px;
  height: 1px;
  background: var(--brand-red, #fb141a);   /* the logo's red */
  margin: .5em 0;
}

.chrono__hint {
  right: clamp(18px, 3vw, 54px);
  top: clamp(26px, 5.5vh, 62px);
  text-align: right;
  font-family: var(--ui);
  font-size: clamp(7.5px, .62vw, 9.5px);
  letter-spacing: .34em;
  text-transform: uppercase;
  color: var(--cream);                      /* the logo's ink */
  line-height: 2;
}
.chrono__hint i { margin-left: auto; }

.chrono__note {
  font-family: var(--ui);
  font-size: clamp(7.5px, .6vw, 9.5px);
  letter-spacing: .34em;
  text-transform: uppercase;
  color: rgba(243, 239, 230, .78);
  line-height: 2.1;
}
.chrono__note--bl { left: clamp(18px, 3vw, 54px); bottom: clamp(20px, 5vh, 56px); }
.chrono__note--br {
  right: clamp(18px, 3vw, 54px);
  bottom: clamp(20px, 5vh, 56px);
  text-align: right;
}
.chrono__note--br i { margin-left: auto; }

/* --------------------------------------------------------------------------
   The deck of years
   -------------------------------------------------------------------------- */

.chrono__deck {
  position: absolute;
  inset: 0;
  perspective: 1400px;
  pointer-events: none;
}

/* The big year numeral on the rail. Styled as the reference sets them: bold
   condensed warm-cream figures with a CONTROLLED glow — generous blur radii
   read as a white pill from a distance, which is exactly what must not
   happen. No background, no box; it is lettering standing in the room. */
.yr-tag {
  position: absolute;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  cursor: default;
  transform: translate(-16%, -128%) scale(calc(.88 + .12 * var(--near, 0)));
  transform-origin: 0 100%;
  font-family: var(--ui);
  font-weight: 600;
  letter-spacing: .035em;
  line-height: 1;
  color: color-mix(in srgb, #eccfa4 calc(58% + 42% * var(--near, 0)), #c99055);
  opacity: calc(var(--in, 0) * (.72 + .28 * var(--near, 0)));
  text-shadow:
    0 0 5px rgba(255, 150, 60, calc(.22 + .18 * var(--near, 0))),
    0 0 16px rgba(255, 70, 20, calc(.12 + .26 * var(--near, 0)));
  transition: color .5s ease, text-shadow .5s ease;
  will-change: transform, opacity;
}
.yr-tag.is-active {
  color: #fff4e4;
  text-shadow:
    0 0 5px rgba(255, 170, 90, .45),
    0 0 18px rgba(255, 70, 20, .5),
    0 0 42px rgba(255, 40, 10, .3);
}

.yr {
  position: absolute;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  pointer-events: auto;
  color: inherit;
  font: inherit;

  /* The card is the supplied artwork, drawn centred on its measured box. It
     rises into place as the scene arrives and lifts toward the viewer as it
     becomes the active year. One transform, so it stays on the compositor. */
  transform:
    translate(-50%, -50%)
    translateY(calc((1 - var(--in, 0)) * 26px - var(--near, 0) * 8px))
    scale(calc(.97 + .05 * var(--near, 0)));
  opacity: var(--in, 0);
  filter:
    brightness(calc(.86 + .2 * var(--near, 0)))
    drop-shadow(0 0 calc(var(--near, 0) * 22px) rgba(255, 120, 40, calc(var(--near, 0) * .55)));
  will-change: transform, opacity;
  z-index: calc(1 + var(--near, 0) * 10);
}
.yr__card {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  pointer-events: none;
}
.yr:focus-visible { outline: none; }
.yr:focus-visible .yr__card { filter: drop-shadow(0 0 0 2px var(--amber)); }

/* --------------------------------------------------------------------------
   Portrait — the timeline becomes a vertical descent rather than a squeezed arc
   -------------------------------------------------------------------------- */

/* On a phone the deck holds ONE card at a time: six stacked cards in a tall
   frame would be a pile, so the vertical year rail becomes the control and the
   active card holds the stage beside it. */
.chrono.is-portrait .chrono__deck { perspective: none; }
.chrono.is-portrait .yr {
  transform:
    translate(-50%, -50%)
    translateY(calc((1 - var(--near, 0)) * 22px))
    scale(calc(.94 + .06 * var(--near, 0)));
  /* only the active card is visible and hittable */
  opacity: calc(var(--in, 0) * max(0, var(--near, 0) * 3 - 2));
  pointer-events: none;
  transition: opacity .45s ease, transform .55s var(--ease-out);
}
.chrono.is-portrait .yr.is-active { pointer-events: auto; }

/* the year numerals become the tap targets */
.chrono.is-portrait .yr-tag {
  /* set to the LEFT of its node, right-aligned, so the rail never runs
     through the numerals and nothing is cut at the screen edge */
  transform: translate(calc(-100% - 12px), -50%) scale(calc(.9 + .18 * var(--near, 0)));
  transform-origin: 100% 50%;
  text-align: right;
  padding: 10px 14px;
  margin: -10px -14px;
  pointer-events: auto;
  cursor: pointer;
  opacity: calc(var(--in, 0) * (.42 + .58 * var(--near, 0)));
}
/* on a phone the bottom-right corner belongs to "Still designing what's
   next"; the top-right caption would land on it, so it steps aside */
.chrono.is-portrait .chrono__hint { display: none; }

@media (max-width: 760px) {
  .chrono { height: 200svh; }
  .chrono__rail { display: none; }
  .chrono__note--bl { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .chrono__title span, .chrono__title::after, .chrono__rail, .chrono__hint, .chrono__note,
  .yr { transition-duration: .01ms !important; transition-delay: 0s !important; }
  .yr-next { animation: none; }
}
