/* ==========================================================================
   Find Your Flow — the instrument panel, Wrapped grammar
   One beat per screen. Everything enters, reacts, exits.
   "Transitions are the thesis." All timing rides the Section 8 easing tokens.
   ========================================================================== */

* { margin: 0; padding: 0; box-sizing: border-box; }

/* landing.css carries this reset; ffy.css did not, so every anchor-based CTA on
   this page rendered underlined — including the $29 button. */
a { color: inherit; text-decoration: none; }

/* The journey owns the viewport — one beat per screen, no document scroll.
   The RESULT is a reading surface and must scroll like one. */
html, body { height: 100%; overflow: hidden; }

body {
  font-size: 16px;
  line-height: 1.6;
  background-image:
    linear-gradient(var(--nh-text-09) 1px, transparent 1px),
    linear-gradient(90deg, var(--nh-text-09) 1px, transparent 1px);
  background-size: 72px 72px;
  background-attachment: fixed;
}
/* Both html AND body must be released. Flipping only body left the document
   element locked at height:100%/overflow:hidden, which turns body into a nested
   scroll container — the thing that kills momentum scrolling on iOS Safari and
   reads as sticky, janky scroll. The class is set on both elements. */
html.is-result, body.is-result {
  height: auto;
  overflow: visible;
  overscroll-behavior-y: auto;
}

/* Ambient glow — drifts toward the emerging signal. */
.ffy-glow {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.55;
  background: radial-gradient(62% 48% at 50% 12%, var(--nh-glow, transparent), transparent 72%);
  transition: background 2400ms var(--nh-ease-signal);
}
.ffy-glow[data-mode="boost"]   { --nh-glow: rgba(239, 158, 51, 0.22); }
.ffy-glow[data-mode="control"] { --nh-glow: rgba(50, 201, 228, 0.22); }
.ffy-glow[data-mode="restore"] { --nh-glow: rgba(126, 88, 227, 0.24); }

/* Mode-color flood — the transition between beats. Sweeps, never fades. */
.ffy-flood {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  background: var(--nh-flood, transparent);
  transform: scaleY(0); transform-origin: bottom;
  opacity: 0;
}
.ffy-flood.is-sweeping {
  animation: nh-flood 620ms var(--nh-ease-signal) forwards;
}
@keyframes nh-flood {
  0%   { transform: scaleY(0); transform-origin: bottom; opacity: 0.9; }
  45%  { transform: scaleY(1); transform-origin: bottom; opacity: 0.9; }
  46%  { transform: scaleY(1); transform-origin: top; opacity: 0.9; }
  100% { transform: scaleY(0); transform-origin: top; opacity: 0.9; }
}

/* --- Instrument: fixed, always present ------------------------------------ */
.ffy-instrument {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  max-width: 900px; margin: 0 auto;
  display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: end;
  padding: 20px 24px 14px;
  transition: opacity 520ms var(--nh-ease-signal);
}
body.is-blackout .ffy-instrument { opacity: 0.12; }

.ffy-wave { width: 100%; height: 62px; display: block; }
.ffy-wave path {
  fill: none; stroke: url(#ffy-wave-gradient);
  stroke-width: 3; stroke-linecap: round; stroke-linejoin: round;
}

.ffy-meters { display: flex; gap: 11px; align-items: flex-end; height: 62px; }
.ffy-meter { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.ffy-meter__track {
  width: 11px; height: 54px; background: var(--nh-card-3);
  border-radius: 6px; display: flex; align-items: flex-end; overflow: hidden;
}
.ffy-meter__fill {
  width: 100%; border-radius: 6px; background: var(--nh-mode); height: 30%;
  transition: height 280ms var(--nh-ease-signal);   /* felt, under 300ms */
}
/* Surge: rise fast, settle. A rise-and-settle, never a bounce. */
.ffy-meter.is-surging .ffy-meter__fill {
  transition: height 240ms cubic-bezier(0.15, 0.85, 0.25, 1);
  box-shadow: 0 0 14px var(--nh-mode);
}
.ffy-meter.is-surging { animation: nh-surge 520ms var(--nh-ease-signal); }
@keyframes nh-surge { 0%,100% { filter: none; } 40% { filter: brightness(1.5); } }

/* Labels appear only at the naming moment. */
.ffy-meter__label {
  font-family: var(--nh-font-mono); font-size: 9px; letter-spacing: 0.12em;
  color: var(--nh-text-32); height: 12px; opacity: 0;
  transition: opacity 1100ms var(--nh-ease-signal);
}
body.is-naming .ffy-meter__label { opacity: 1; }
body.is-naming .ffy-meter__label::after { content: attr(data-label); }

/* --- One beat per screen -------------------------------------------------- */
.ffy-stage {
  position: relative; z-index: 5;
  min-height: 100vh; max-width: 900px; margin: 0 auto;
  padding: 132px 24px 48px;
  display: flex; flex-direction: column; justify-content: center;
}

.ffy-beat { display: grid; gap: 22px; }
.ffy-beat.is-leaving { animation: nh-beat-out 340ms var(--nh-ease-signal) forwards; }
@keyframes nh-beat-out {
  to { opacity: 0; transform: translateY(-18px); }
}

/* Anton stem builds in, line by line. */
.ffy-stem {
  font-family: var(--nh-font-display);
  text-transform: uppercase; font-weight: 400;
  font-size: clamp(28px, 5.2vw, 56px); line-height: 1.04;
  color: var(--nh-text-100); max-width: 16em;
}
.ffy-stem .ln { display: block; overflow: hidden; }
.ffy-stem .ln > span {
  display: block; transform: translateY(105%);
  animation: nh-rise 620ms var(--nh-ease-signal) forwards;
  animation-delay: calc(var(--i) * 90ms);
}
@keyframes nh-rise { to { transform: translateY(0); } }

.ffy-said {
  font-family: var(--nh-font-mono); font-size: 11px;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--nh-nico-pink);
  opacity: 0; animation: nh-fade 500ms var(--nh-ease-signal) 120ms forwards;
}
@keyframes nh-fade { to { opacity: 1; } }

/* Cards rise staggered. */
.ffy-cards { display: grid; gap: 11px; max-width: 640px; }
.ffy-card {
  text-align: left; font-family: var(--nh-font-body);
  font-size: 16px; line-height: 1.4; color: var(--nh-text-84);
  background: var(--nh-card-2); border: 1px solid var(--nh-text-09);
  border-left: 3px solid transparent; border-radius: 13px;
  padding: 17px 20px; cursor: pointer;
  opacity: 0; transform: translateY(22px);
  animation: nh-card-in 520ms var(--nh-ease-signal) forwards;
  animation-delay: calc(320ms + var(--i) * 85ms);
  transition: border-color 220ms var(--nh-ease-signal),
              background 220ms var(--nh-ease-signal),
              transform 220ms var(--nh-ease-signal);
}
@keyframes nh-card-in { to { opacity: 1; transform: translateY(0); } }
.ffy-card:hover, .ffy-card:focus-visible {
  background: var(--nh-card-3); border-left-color: var(--nh-nico-pink);
  transform: translateX(3px);
}
.ffy-card:focus-visible { outline: 2px solid var(--nh-control); outline-offset: 2px; }

/* Chosen card ignites; the others recede. */
.ffy-card.is-chosen {
  animation: none; opacity: 1;
  border-left-color: var(--nh-mode, var(--nh-nico-pink));
  background: var(--nh-card-3);
  box-shadow: 0 0 0 1px var(--nh-mode, var(--nh-nico-pink)),
              0 0 34px -6px var(--nh-mode, var(--nh-nico-pink));
  transform: translateX(0) scale(1.015);
  transition: box-shadow 380ms var(--nh-ease-signal), transform 380ms var(--nh-ease-signal);
}
.ffy-card.is-receding {
  animation: none;
  opacity: 0.22; transform: translateY(6px); pointer-events: none;
  transition: opacity 380ms var(--nh-ease-signal), transform 380ms var(--nh-ease-signal);
}

/* --- Interruption: a blackout moment -------------------------------------- */
body.is-blackout { background-color: #0B0B0A; }
.ffy-beat--interrupt { justify-items: start; max-width: 30em; }
.ffy-interrupt {
  font-family: var(--nh-font-body); font-size: clamp(18px, 2.6vw, 26px);
  line-height: 1.5; color: var(--nh-text-100);
  border-left: 3px solid var(--nh-nico-pink); padding-left: 20px;
  min-height: 3em;
}
.ffy-interrupt .caret {
  display: inline-block; width: 9px; height: 1.05em; margin-left: 3px;
  background: var(--nh-nico-pink); vertical-align: text-bottom;
  animation: nh-caret 900ms steps(1, end) infinite;
}
@keyframes nh-caret { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }
.ffy-whom {
  font-family: var(--nh-font-mono); font-size: 11px; letter-spacing: 0.14em;
  color: var(--nh-nico-pink); text-transform: none;
}

.ffy-continue {
  justify-self: start; background: none; border: 1px solid var(--nh-text-32);
  color: var(--nh-text-50); border-radius: 999px; padding: 9px 20px;
  font-family: var(--nh-font-mono); font-size: 11px; letter-spacing: 0.14em;
  text-transform: uppercase; cursor: pointer;
  opacity: 0; animation: nh-fade 460ms var(--nh-ease-signal) forwards;
}
.ffy-continue:hover { color: var(--nh-text-84); border-color: var(--nh-text-84); }

/* --- Result --------------------------------------------------------------- */
.ffy-result { max-width: 900px; margin: 0 auto; padding: 132px 24px 120px; display: grid; gap: 24px; }
.ffy-result[hidden] { display: none; }
.ffy-result .profile-card { max-width: 100%; }
.ffy-anton {
  font-family: var(--nh-font-display); text-transform: uppercase; font-weight: 400;
  font-size: clamp(28px, 4.8vw, 48px); line-height: 1.05; color: var(--nh-text-100);
}
.ffy-hook { color: var(--nh-text-50); max-width: 40em; }
.ffy-keep { background: var(--nh-card-1); border: 1px solid var(--nh-text-09); border-radius: 16px; padding: 24px; }
.ffy-keep h2 {
  font-family: var(--nh-font-display); text-transform: uppercase; font-weight: 400;
  font-size: 22px; color: var(--nh-text-100); margin-bottom: 8px;
}
.ffy-keep p { color: var(--nh-text-50); font-size: 15px; margin-bottom: 16px; }
.ffy-keep form { display: flex; gap: 10px; flex-wrap: wrap; }
.ffy-keep input {
  flex: 1 1 240px; background: var(--nh-card-3); border: 1px solid var(--nh-text-32);
  border-radius: 999px; padding: 12px 18px; color: var(--nh-text-100);
  font-family: var(--nh-font-body); font-size: 15px;
}
.ffy-keep input:focus-visible { outline: 2px solid var(--nh-control); outline-offset: 2px; }
.ffy-kept { color: var(--nh-text-84); font-size: 15px; }

.ffy-deepread {
  background: var(--nh-card-1); border: 1px solid var(--nh-text-09);
  border-radius: 16px; padding: 24px; display: grid; gap: 16px; justify-items: start;
}
.ffy-deepread .bubble { max-width: 100%; }
.ffy-testnote {
  font-family: var(--nh-font-mono); font-size: 11px; line-height: 1.9;
  letter-spacing: 0.06em; color: var(--nh-text-50);
}
.ffy-testnote .badge { margin-right: 10px; vertical-align: middle; }
.ffy-testnote code {
  color: var(--nh-text-84); background: var(--nh-card-3);
  padding: 2px 8px; border-radius: 5px; white-space: nowrap;
}

@media (max-width: 640px) {
  .ffy-instrument { grid-template-columns: 1fr; gap: 10px; padding-top: 14px; }
  .ffy-meters { justify-content: flex-start; height: 46px; }
  .ffy-stage { padding-top: 150px; }

  /* The result card owns the screen on mobile. The fixed instrument is stacked
     here so it is taller, and it was overlapping the card — but the card now
     carries its own waveform and bars, so on small viewports the header is
     redundant as well as in the way. Removed rather than pushed around. */
  body.is-result .ffy-instrument { display: none; }
  .ffy-result { padding-top: 28px; }

  /* Beats need room to breathe at 390px. */
  /* The stem is line-broken in JS, then CSS wraps those lines again if they do
     not fit — which orphans a word onto its own line ("YOUR" / "HEAD?"). Sized
     so a full JS line fits the 390px column, so each line stays one beat. */
  .ffy-stem { font-size: clamp(21px, 6.6vw, 29px); }
  .ffy-card { font-size: 15px; padding: 15px 16px; }
  .ffy-interrupt { font-size: 18px; padding-left: 16px; }
  .ffy-result { padding-left: 18px; padding-right: 18px; }
  .profile-card { padding: 22px 18px; }
  .ffy-keep, .ffy-deepread { padding: 20px 18px; }
  .ffy-anton { font-size: clamp(24px, 7.4vw, 34px); }
  .ffy-debug { display: none; }
}

/* --- Static fallback ------------------------------------------------------
   Reduced motion gets the same grammar with none of the movement: every beat
   arrives already in place, the flood never sweeps, nico's line is complete
   on arrival rather than typed. */
@media (prefers-reduced-motion: reduce) {
  .ffy-glow, .ffy-meter__fill, .ffy-card, .ffy-meter__label { transition: none; }
  .ffy-stem .ln > span,
  .ffy-card,
  .ffy-said,
  .ffy-continue { animation: none; opacity: 1; transform: none; }
  .ffy-flood.is-sweeping { animation: none; }
  .ffy-meter.is-surging { animation: none; }
  .ffy-interrupt .caret { display: none; }
  .ffy-beat.is-leaving { animation: none; }
}

/* --- Guaranteed entry ------------------------------------------------------
   Motion may never hold content hostage. When the watchdog fires, everything
   inside is forced visible regardless of what any animation was doing. */
.is-forced-in,
.is-forced-in * {
  opacity: 1 !important;
  transform: none !important;
  animation: none !important;
}

/* The stage retires at assembly — otherwise its 100vh pushes the result a full
   screen below the fold with nothing to scroll to. */
body.is-result .ffy-stage,
.ffy-stage[hidden] { display: none !important; }

/* --- Debug event log (preview only) ---------------------------------------- */
.ffy-debug {
  position: fixed; right: 12px; bottom: 12px; z-index: 90;
  width: min(420px, 44vw); max-height: 40vh;
  background: rgba(11, 11, 10, 0.94);
  border: 1px solid var(--nh-text-32); border-radius: 10px;
  padding: 10px 12px; color: var(--nh-text-84);
  font-family: var(--nh-font-mono); font-size: 10px; line-height: 1.7;
  display: flex; flex-direction: column; gap: 6px;
}
.ffy-debug b { color: var(--nh-nico-pink); letter-spacing: 0.12em; text-transform: uppercase; }
.ffy-debug ol { list-style: none; overflow-y: auto; margin: 0; padding: 0; }
.ffy-debug li { border-top: 1px solid var(--nh-text-09); padding: 3px 0; }
.ffy-debug li span { color: var(--nh-text-32); }
.ffy-debug li i { color: var(--nh-text-50); font-style: normal; }
