/* Hallmark · v2-E "the journey" · client: pharaoh · Phase 1 (the opening)
 * Macrostructure: immersive single-stage story (one fixed particle canvas behind everything),
 * then a conventional sales page (Phase 3). Phases 1–2 are centre-aligned, the swarm sits low,
 * the words sit high. Nav: none during the gate; a fixed countdown bar after the burst. */

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: var(--color-paper); }
body {
  margin: 0; background: var(--color-paper); color: var(--color-ink);
  font-family: var(--font-body); font-size: var(--text-md); line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--color-focus); outline-offset: 3px; }

:root { --bar-h: 3.5rem; }
html.is-gated, html.is-gated body { overflow: hidden; overscroll-behavior: none; }

/* ---- the swarm: one canvas behind the whole story ---- */
.swarm {
  position: fixed; inset: 0; width: 100%; height: 100%;
  z-index: 0; pointer-events: none; color: var(--color-accent);
}
main { position: relative; z-index: 1; }

/* ---- PHASE 1 · the opening ---- */
.opening {
  min-height: 100svh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center; text-align: center;
  padding: calc(var(--bar-h) + clamp(1.25rem, 6vh, 4rem)) var(--gutter) max(1.25rem, env(safe-area-inset-bottom));
}
html.is-gated .opening { touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab; }
html.is-gated.is-drawing .opening { cursor: grabbing; }

.opening__lines { display: grid; }
/* the lines share one slot: each one fades out as the next arrives */
.line {
  grid-area: 1 / 1;
  font-family: var(--font-display); font-style: italic; font-weight: 300;
  font-size: clamp(2.1rem, 1.3rem + 3.4vw, 4.4rem); line-height: 1.3; letter-spacing: -0.005em;
  color: var(--color-ink);
}
.js .line { transition: opacity 1.1s var(--ease-out), transform 1.1s var(--ease-out), filter 1.1s var(--ease-out); }
.js .line--1 { opacity: 0; }
.is-begun .line--1 { animation: rise 1.6s var(--ease-out) 0.6s forwards; }
.js .line--2 { opacity: 0; transform: translateY(0.4rem); }
.beat-2 .line--1 { animation: none; opacity: 0; transform: translateY(-0.4rem); filter: blur(6px); }
.beat-2 .line--2 { opacity: 1; transform: none; transition-delay: 0.6s; }
.beat-3 .line--2 { opacity: 0; transform: translateY(-0.4rem); filter: blur(6px); transition-delay: 0s; }
/* reduced motion: no story, so both lines sit together above DIE. */
.is-still .line { grid-area: auto; }
.is-still .line--1, .is-still .line--2 { opacity: 1; transform: none; filter: none; animation: none; }

/* the square the flower lives in (the canvas reads its centre and size) */
.opening__anchor {
  position: relative; align-self: center;
  height: 100%; max-height: min(64vh, 88vw); aspect-ratio: 1; max-width: 100%;
  display: grid; place-items: center;
}
.die {
  font-family: var(--font-display); font-weight: 500; text-transform: uppercase;
  font-size: clamp(5rem, 24vw, 13.5rem); line-height: 1; letter-spacing: 0.04em;
  color: var(--color-ink);
}
.js .die { opacity: 0; transform: scale(1.12); filter: blur(10px); }
.is-burst .die { opacity: 1; transform: none; filter: none; transition: opacity 0.9s var(--ease-out) 0.15s, transform 1.4s var(--ease-out) 0.15s, filter 1s var(--ease-out) 0.15s; }

.opening__foot { display: grid; justify-items: center; gap: var(--space-sm); min-height: 4.5rem; align-content: end; }
.opening__foot .hint { grid-area: 1 / 1; }
.opening__foot .skip { grid-area: 2 / 1; }
.hint--scroll.is-on { animation: bob 2.4s var(--ease-in-out) infinite; }
.hint {
  font-size: clamp(0.875rem, 0.8rem + 0.3vw, 1rem); font-weight: 500; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--color-ink); opacity: 0; transition: opacity 0.6s var(--ease-out);
}
.hint.is-on { opacity: 1; }
.hint--begin { letter-spacing: 0.26em; }
.hint--begin.is-on { opacity: 0.85; animation: breathe 3.2s var(--ease-in-out) infinite; }
.is-waiting .skip { opacity: 0; pointer-events: none; }
.skip {
  font: inherit; font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-muted); background: none; border: 0;
  padding: var(--space-sm) var(--space-md); min-height: 2.75rem; cursor: pointer;
  text-decoration: underline; text-decoration-color: var(--color-rule); text-underline-offset: 0.3em;
  transition: color var(--dur-micro) var(--ease-out);
}
.skip:hover { color: var(--color-ink); }
.replay, .is-burst .skip:not(.replay) { display: none; }
.is-burst .replay { display: inline-block; }
html:not(.js) .skip { display: none; }

/* ---- the countdown bar ---- */
.clockbar {
  position: fixed; inset: 0 0 auto 0; z-index: var(--z-sticky); height: var(--bar-h);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: var(--space-md);
  padding: 0 var(--gutter); padding-top: env(safe-area-inset-top);
  background: var(--color-scrim-94); border-bottom: var(--rule-hair) solid var(--color-rule-soft);
  transform: translateY(-101%); transition: transform 0.9s var(--ease-out);
}
.clockbar.is-on, html:not(.js) .clockbar { transform: none; }
.clockbar__brand { font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-ink-2); }
.clockbar__clock { display: flex; align-items: baseline; gap: var(--space-md); }
.clockbar__label { font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.14em; text-transform: uppercase; color: var(--color-accent); }
.clockbar__units { display: flex; gap: var(--space-sm); font-variant-numeric: tabular-nums; }
.cu b { font-weight: 500; font-size: var(--text-lg); color: var(--color-ink); letter-spacing: 0.01em; }
.cu i { font-style: normal; font-size: var(--text-2xs); color: var(--color-muted); margin-left: 0.12em; }
.is-closed .clockbar__units { display: none; }
.clockbar__apply {
  justify-self: end; display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0 var(--space-lg);
  border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink);
  font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.16em; text-transform: uppercase; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-micro) var(--ease-out);
}
.clockbar__apply:hover { background: var(--color-accent-2); }
.clockbar__apply[aria-disabled="true"] { background: var(--color-paper-3); color: var(--color-muted); cursor: default; }

@media (max-width: 43.99rem) {
  :root { --bar-h: 3.75rem; }
  .clockbar { grid-template-columns: 1fr auto; gap: var(--space-sm); padding: 0 var(--space-md); }
  .clockbar__brand { display: none; }
  .clockbar__clock { flex-direction: column; align-items: flex-start; gap: 0; }
  .clockbar__label { font-size: var(--text-2xs); }
  .clockbar__units { gap: 0.4rem; }
  .cu b { font-size: var(--text-md); }
  .clockbar__apply { min-height: 2.75rem; }
}

/* the sound toggle: always reachable, bottom right */
.sound {
  position: fixed; right: max(var(--space-md), env(safe-area-inset-right)); bottom: max(var(--space-md), env(safe-area-inset-bottom)); z-index: var(--z-raised);
  font: inherit; font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--color-muted); background: none; border: 0; padding: var(--space-sm); min-height: 2.75rem; cursor: pointer;
  transition: color var(--dur-micro) var(--ease-out);
}
.sound:hover { color: var(--color-ink); }
.sound[aria-pressed="true"] { color: var(--color-ink-2); }
.sound.is-waiting { color: var(--color-accent); animation: bob 2.4s var(--ease-in-out) infinite; }
html:not(.js) .sound { display: none; }
.sound { transition: color var(--dur-micro) var(--ease-out), opacity 0.6s var(--ease-out); }
.is-quiet .sound { opacity: 0; pointer-events: none; }

/* ---- PHASE 2 · the story: a sticky stage, one viewport of scroll per beat ---- */
.story { position: relative; height: 750svh; }
.story__stage {
  position: sticky; top: 0; height: 100svh;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  justify-items: center; text-align: center;
  padding: calc(var(--bar-h) + clamp(1.25rem, 6vh, 4rem)) var(--gutter) max(1.25rem, env(safe-area-inset-bottom));
}
/* all the beats share one slot, so the stage never shifts as the words change */
.story__text { display: grid; align-items: start; max-width: 40rem; }
.beat {
  grid-area: 1 / 1; margin: 0;
  font-family: var(--font-display); font-weight: 400; font-style: normal;
  font-size: clamp(1.75rem, 1.05rem + 2.5vw, 3.3rem); line-height: 1.4; letter-spacing: -0.005em;
  text-wrap: balance; color: var(--color-ink);
  opacity: 0; transform: translateY(0.6rem); filter: blur(4px);
  transition: opacity 0.9s var(--ease-out), transform 0.9s var(--ease-out), filter 0.9s var(--ease-out);
}
.beat.is-on { opacity: 1; transform: none; filter: none; transition-delay: 0.15s; }
.beat--close { font-weight: 300; font-size: clamp(2.1rem, 1.1rem + 2.8vw, 4.2rem); line-height: 1.06; letter-spacing: -0.015em; }
.beat--close em { font-style: italic; color: var(--color-accent); }
html:not(.js) .beat { opacity: 1; transform: none; filter: none; position: static; }

.story__anchor {
  position: relative; align-self: center;
  height: 100%; max-height: min(64vh, 88vw); aspect-ratio: 1; max-width: 100%;
}
.story__foot { min-height: 4.5rem; }

/* the close: the monarch settles above the countdown and the apply button */
.close {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -46%); width: min(92vw, 42rem);
  display: grid; justify-items: center; gap: var(--space-md);
  opacity: 0; transition: opacity 0.9s var(--ease-out), transform 1.1s var(--ease-out);
}
.close.is-on { opacity: 1; transform: translate(-50%, -50%); transition-delay: 0.2s; }
.close__mark { width: clamp(6.5rem, 21vh, 11rem); aspect-ratio: 1; }
.close__clock { display: grid; justify-items: center; gap: var(--space-xs); }
.close__label { font-size: var(--text-2xs); font-weight: 500; letter-spacing: 0.18em; text-transform: uppercase; color: var(--color-accent); }
.close__units { display: flex; align-items: flex-start; gap: clamp(0.35rem, 1.2vw, 0.9rem); font-variant-numeric: lining-nums tabular-nums; }
.bu { display: grid; justify-items: center; }
.bu b { font-family: var(--font-display); font-weight: 300; font-size: var(--text-timer); line-height: 1; color: var(--color-ink); }
.bu i { font-style: normal; font-size: var(--text-2xs); letter-spacing: 0.16em; text-transform: uppercase; color: var(--color-muted); margin-top: 0.35rem; }
.bsep { font-family: var(--font-display); font-weight: 300; font-size: var(--text-timer); line-height: 1; color: var(--color-faint); }
.is-closed .close__units { display: none; }
.btn {
  display: inline-flex; align-items: center; gap: 0.5em; min-height: 3.25rem; padding: 0 var(--space-xl);
  border-radius: var(--radius-pill); background: var(--color-accent); color: var(--color-accent-ink);
  font-size: var(--text-md); font-weight: 500; text-decoration: none; white-space: nowrap;
  transition: background var(--dur-micro) var(--ease-out), transform var(--dur-micro) var(--ease-out);
}
.btn:hover { background: var(--color-accent-2); transform: translateY(-1px); }
.btn[aria-disabled="true"] { background: var(--color-paper-3); color: var(--color-muted); transform: none; cursor: default; }
.close__meta { font-size: var(--text-md); color: var(--color-muted); text-wrap: balance; }
.close .btn + .close__meta { margin-top: var(--space-2xs); }
.close__meta + .close__meta { margin-top: calc(var(--space-md) * -0.6); }
.close__more { margin-top: var(--space-sm); font-size: var(--text-sm); color: var(--color-muted); text-decoration: none; transition: color var(--dur-micro) var(--ease-out); }
.close__more:hover { color: var(--color-ink); }

/* ---- the hero: headline, the marigold under it, the countdown + apply ---- */
.hero {
  position: relative; min-height: 100svh; display: grid; justify-items: center; align-content: center; gap: var(--space-md);
  padding: calc(var(--bar-h) + var(--space-xl)) var(--gutter) var(--space-2xl); text-align: center;
}
.hero__t {
  margin: 0; max-width: 20ch; font-family: var(--font-display); font-weight: 300;
  font-size: clamp(2.3rem, 1.2rem + 3.4vw, 4.6rem); line-height: 1.05; letter-spacing: -0.015em;
  color: var(--color-ink); text-wrap: balance;
}
.hero__t em { font-style: italic; color: var(--color-accent); }
.hero__mark { width: min(clamp(15rem, 42vw, 27rem), 88vw); aspect-ratio: 2.4; margin: var(--space-sm) 0; }   /* the swarm gathers the loop here */
.hero .btn + .close__meta { margin-top: var(--space-2xs); }
/* the story's stage sits over the page's glow and rail */
.story { z-index: 2; }

@keyframes breathe { 0%, 100% { opacity: 0.6; } 50% { opacity: 1; } }
@keyframes bob { 0%, 100% { transform: none; } 50% { transform: translateY(0.3rem); } }
@keyframes rise { from { opacity: 0; transform: translateY(0.5rem); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
  .js .line--1, .js .line--2, .js .die { animation: none; opacity: 1; transform: none; filter: none; transition: opacity 0.15s linear; }
  .clockbar { transition: none; }
  .beat, .close { transition: opacity 0.15s linear; filter: none; }
  .hint--scroll.is-on, .hint--begin.is-on { animation: none; }
}
.nw { white-space: nowrap; }
