/* ============================================================
   Wish You Were Then — the real game, shown large.
   Light, quiet chrome; the game's own colours live inside the
   frames. Granny's watch flips the strand between 1995 and 1923.
   Rides on shared/tokens.css + shared/base.css.
   ============================================================ */

@font-face {
  font-family: "WYWT Hand";
  src: url("assets/fonts/wywt-hand.ttf") format("truetype");
  font-display: swap;
}

/* ---- the quiet base (v2 "Gallery Light" tokens) ---- */

body {
  background: var(--bg);
  color: var(--ink);
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---- type roles ---- */

h1, h2 {
  font-family: var(--serif);
  font-weight: 400;
  letter-spacing: -0.01em;
  line-height: 1.02;
  text-wrap: balance;
}
h1 em, h2 em { font-style: italic; }

h1 { font-size: var(--size-case-title); }
h2 { font-size: var(--size-case-state); }

.one-line {
  max-width: 34rem;
  margin-top: 1rem;
  font-size: var(--size-body);
  line-height: var(--leading-body);
  color: var(--muted);
}

.plaque {
  font-family: var(--sans);
  font-size: var(--size-caption);
  font-weight: 500;
  letter-spacing: var(--tracking-caption);
  color: var(--muted);
}

/* ---- frames: where the game's colour lives ---- */

.film video, .frame video, .frame img { display: block; width: 100%; }

.frame {
  margin: 0;
}
.frame video, .frame .era-img {
  border-radius: var(--r-md);
  overflow: hidden;
  box-shadow: var(--shadow-rest);
}
.frame figcaption { margin-top: 0.9rem; }

/* era-twinned imagery crossfades under the watch */
.era-img { display: grid; }
.era-img img {
  grid-area: 1 / 1;
  width: 100%;
  transition: opacity 450ms var(--ease-out);
}
[data-era="now"] .e-then { opacity: 0; }
[data-era="then"] .e-now { opacity: 0; }

.duo { display: grid; }
.duo > * { grid-area: 1 / 1; }
.t-then { visibility: hidden; }
[data-era="then"] .t-now { visibility: hidden; }
[data-era="then"] .t-then { visibility: visible; }

/* ============================================================
   1 · Hero — the game, edge to edge
   ============================================================ */

.hero { padding: 0; }

.hero-film {
  position: relative;
  min-height: 92svh;
  overflow: hidden;
  background: var(--well);
}

#hero-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* the poster stands in until the engine's first frame (and under calm preferences) */
  background: url("assets/film/hero-poster.png") center / cover no-repeat;
}

.hero-scrim {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, rgba(10, 8, 16, 0.78) 0%, rgba(10, 8, 16, 0.28) 34%, rgba(10, 8, 16, 0) 60%),
    linear-gradient(to bottom, rgba(10, 8, 16, 0.35) 0%, rgba(10, 8, 16, 0) 22%);
}

.hero-words {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  padding: 0 var(--gutter) clamp(2rem, 6vh, 4rem);
  max-width: min(var(--wide), 100%);
  margin: 0 auto;
  color: #faf6ea;
}

.hero-words .plaque { color: #cfc6b2; margin-bottom: 0.9rem; }
.hero-words .one-line { color: #e9e2d2; max-width: 30rem; }

.cta-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.cta-note {
  font-family: var(--sans);
  font-size: var(--size-caption);
  letter-spacing: var(--tracking-caption);
  color: #cfc9c0;
}

/* CTA pill: surface + ink, no brand colour — interactive states stay ink (v2 §1) */
.btn-cta {
  display: inline-block;
  padding: 0.75rem 1.5rem;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  font-size: 1rem;
  border-radius: 999px;
  box-shadow: var(--shadow-rest);
  transition: transform var(--dur-quick) var(--ease-out);
}
.btn-cta:hover, .btn-cta:focus-visible { transform: translateY(-2px); }

/* ============================================================
   Beats — varied compositions on a calm page
   ============================================================ */

.beat { padding: calc(var(--beat) * 0.9) 0; }

.beat-head {
  max-width: min(var(--wide), 100%);
  margin: 0 auto var(--space-4);
  padding: 0 var(--gutter);
}
.beat-head.center { text-align: center; }
.beat-head.center .one-line { margin-inline: auto; }

/* 2 · the years: frame bleeds to the right edge */
.beat-years { padding-top: var(--beat); }
.frame-right {
  margin-left: max(var(--gutter), calc((100vw - var(--wide)) / 2));
  margin-right: 0;
}
.frame-right video, .frame-right .era-img { border-radius: clamp(6px, 1vw, 14px) 0 0 clamp(6px, 1vw, 14px); }
.frame-right figcaption { text-align: left; }

/* 3 · after dark: frame bleeds to the left edge, words sit beside */
.beat-dark {
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 4fr);
  gap: var(--space-4);
  align-items: end;
  background: transparent;
}
.frame-left { margin-right: 0; }
.frame-left video { border-radius: 0 clamp(6px, 1vw, 14px) clamp(6px, 1vw, 14px) 0; }
.frame-left figcaption { padding-left: var(--gutter); }
.beat-dark .beat-aside { padding-right: max(var(--gutter), calc((100vw - var(--wide)) / 2)); padding-bottom: var(--space-4); }

@media (max-width: 1020px) {
  .beat-dark { grid-template-columns: 1fr; align-items: start; }
  .beat-dark .beat-aside { order: -1; padding: 0 var(--gutter); }
}

/* 4 · the overworld: tall frame, centred */
.frame-tall {
  max-width: min(44rem, calc(100vw - 2 * var(--gutter)));
  margin: 0 auto;
}
.frame-tall figcaption { text-align: center; }

/* 5 · the craft strip */
.beat-craft .beat-head { margin-bottom: var(--space-3); }
.states {
  max-width: min(var(--wide), 100%);
  margin: 0 auto;
  padding: var(--space-4) var(--gutter);
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: var(--space-3) var(--space-4);
  border-top: 1px solid var(--hairline);
  border-bottom: 1px solid var(--hairline);
}
.states figure { display: grid; justify-items: center; gap: 0.6rem; margin: 0; }
.states figcaption {
  font-family: var(--sans);
  font-size: var(--size-caption);
  letter-spacing: var(--tracking-caption);
  color: var(--muted);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  list-style: none;
  margin: 0 0 0 auto;
  padding: 0 0 1.6rem;
  align-self: end;
}
.chips li { width: 16px; height: 16px; background: var(--c); border-radius: 3px; }

@media (max-width: 820px) {
  .chips { margin-left: 0; padding-bottom: 0; }
}

/* 6 · Claude */
.beat-claude .beat-head { margin-bottom: var(--space-3); }
.credits {
  max-width: min(var(--wide), 100%);
  margin: 0 auto;
  padding: var(--space-3) var(--gutter) 0;
  border-top: 1px solid var(--hairline);
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: var(--space-3) var(--space-4);
}
.credits dt {
  font-family: var(--sans);
  font-size: var(--size-caption);
  font-weight: 500;
  letter-spacing: var(--tracking-caption);
  color: var(--muted);
  margin-bottom: 0.3rem;
}
.credits dd { margin: 0; font-size: var(--size-body); }

/* 7 · play: one rich ink panel, the game's night inside it */
.beat-play { padding-bottom: var(--beat); }
.play-panel {
  position: relative;
  display: grid;
  place-items: center;
  min-height: min(72vh, 34rem);
  margin: 0 auto;
  max-width: min(72rem, calc(100vw - 2 * var(--gutter)));
  border-radius: clamp(8px, 1.2vw, 16px);
  overflow: hidden;
  background: var(--well);
  box-shadow: 0 30px 80px -30px rgba(18, 12, 28, 0.55);
}
.play-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.85;
}
.play-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(10, 8, 16, 0.55) 0%, rgba(10, 8, 16, 0.25) 55%, rgba(10, 8, 16, 0.65) 100%);
}
.play-words {
  position: relative;
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  text-align: center;
  padding: var(--space-4) var(--gutter);
  color: #faf6ea;
}
.play-words .hand {
  font-family: "WYWT Hand", "Segoe Script", cursive;
  font-size: clamp(1.1rem, 2.4vw, 1.5rem);
  color: #e8d9ae;
  transform: rotate(-1.6deg);
}
.play-words strong {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.2rem, 5.4vw, 4rem);
  line-height: 1;
}
.play-note {
  font-family: var(--sans);
  font-size: var(--size-caption);
  letter-spacing: var(--tracking-caption);
  color: #cfc9c0;
}
.play-panel:hover .btn-cta, .play-panel:focus-visible .btn-cta { transform: translateY(-2px); }

/* ============================================================
   The watch
   ============================================================ */

.watch-dock {
  position: fixed;
  right: clamp(0.75rem, 2.2vw, 1.75rem);
  bottom: clamp(0.75rem, 2.2vw, 1.5rem);
  z-index: 40;
  width: clamp(58px, 6.5vw, 80px);
}

.watch {
  all: unset;
  cursor: pointer;
  display: grid;
  justify-items: center;
  gap: 0.2rem;
  width: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.watch-face {
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 200 / 250;
  filter: drop-shadow(0 5px 12px rgba(30, 20, 8, 0.35));
  transition: transform var(--dur-quick) var(--ease-out);
}
.watch-face svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.watch:hover .watch-face { transform: translateY(-3px); }
.watch:active .watch-face { transform: translateY(0) scale(0.97); }
.watch:focus-visible { outline: 2px solid var(--ink); outline-offset: 6px; border-radius: 50%; }

.w-hand { transform-box: border-box; transform-origin: 50% 60%; }
.w-min { animation: w-turn 60s linear infinite; }
.w-hour { animation: w-turn 720s linear infinite; animation-delay: -220s; }
@keyframes w-turn { to { transform: rotate(360deg); } }

.year {
  display: block;
  height: 1.05em;
  overflow: hidden;
  font-family: var(--sans);
  font-size: var(--size-caption);
  font-weight: 500;
  letter-spacing: 0.1em;
  color: #9a7318; /* the watch's own brass, an in-world accent — not page chrome */
  font-variant-numeric: tabular-nums;
}
.y-roll { display: block; transition: transform 450ms var(--ease-out); }
.y-roll b { display: block; height: 1.05em; line-height: 1.05; font-weight: 500; }
[data-era="then"] .y-roll { transform: translateY(-1.05em); }

#era-flash {
  position: fixed;
  z-index: 35;
  width: 12px; height: 12px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}
#era-flash.go { animation: flash-ring 600ms var(--ease-out); }
/* the ring is the watch's brass washing over the page — in-world, not chrome */
@keyframes flash-ring {
  0%   { opacity: 0.8; transform: scale(1);   box-shadow: 0 0 0 4px #c89232, 0 0 24px 10px rgba(200, 146, 50, 0.28); }
  100% { opacity: 0;   transform: scale(260); box-shadow: 0 0 0 1px #c89232; }
}

/* keep the footer's words clear of the watch */
.site-footer .inner { padding-right: clamp(72px, 9vw, 110px); }

@media (max-width: 640px) {
  .beat { padding-block: calc(var(--beat) * 0.55); }
  .beat-years { padding-top: calc(var(--beat) * 0.7); }
  .beat-play { padding-bottom: calc(var(--beat) * 0.7); }
  .hero-scrim {
    background:
      linear-gradient(to top, rgba(10, 8, 16, 0.82) 0%, rgba(10, 8, 16, 0.4) 46%, rgba(10, 8, 16, 0) 68%),
      linear-gradient(to bottom, rgba(10, 8, 16, 0.35) 0%, rgba(10, 8, 16, 0) 22%);
  }
}

/* the shared nav runs tight at phone width */
@media (max-width: 430px) {
  .site-nav .wordmark { font-size: 0.9rem; gap: 0.45rem; }
  .site-nav ul { font-size: 0.7rem; gap: 0.7rem; }
}

/* ============================================================
   Calm preferences
   ============================================================ */

@media (prefers-reduced-motion: reduce), (update: slow) {
  .w-min, .w-hour { animation: none; }
  .w-min { transform: rotate(48deg); }
  .w-hour { transform: rotate(-55deg); }
  #era-flash { display: none; }
  .era-img img, .y-roll { transition: none; }
}

/* ============================================================
   Calm preferences: each film gets an explicit play control
   (shown only when html.reduced — set by wywt.js, or ?reduced)
   ============================================================ */

.frame { position: relative; }

.film-play {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: none;
  padding: 0.7rem 1.5rem;
  border: 0;
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--sans);
  font-weight: 500;
  font-size: var(--size-caption);
  letter-spacing: var(--tracking-caption);
  box-shadow: var(--shadow-rest);
  cursor: pointer;
}
html.reduced .film-play { display: inline-block; }
.film-play:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
