/* ————————————————————————————————————————————————————————————
   Listening Loop — "Friday night gym under the lights"
   Engine styles. All tenant color/copy arrives from /api/config;
   the two brand custom properties below are only fallbacks.
   ———————————————————————————————————————————————————————————— */

@font-face {
  font-family: 'Fraunces';
  src: url('/fonts/fraunces-var.woff2') format('woff2-variations');
  font-weight: 100 900;
  font-display: swap;
  font-style: normal;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-400.woff2') format('woff2');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}

:root {
  /* brand — overwritten at runtime from the business config */
  --brand: #1B1E53;
  --accent: #D92027;

  /* the gym at night */
  --navy-deep: #0B0D24;
  --navy-low: #12142F;
  --navy-mid: #1B1E53;
  --navy-lift: #262B6E;

  --ink: #FAF7F5;          /* warm off-white, never pure white */
  --ink-soft: #DCDAE8;
  --ink-mute: #A9ADCC;
  --ink-faint: rgba(250, 247, 245, .38);

  --accent-hot: #FF4B45;
  --line: rgba(250, 247, 245, .14);
  --court-stroke: rgba(250, 247, 245, .028);

  --fz-hero: clamp(1.95rem, 4.4vw + 1.15rem, 3.1rem);
  --fz-line: clamp(1.5rem, 3.4vw + .95rem, 2.35rem);
  --fz-body: clamp(1.02rem, .4vw + .95rem, 1.15rem);
  --fz-small: .875rem;

  --ease-spring: cubic-bezier(.34, 1.45, .5, 1);
  --ease-out: cubic-bezier(.22, 1, .36, 1);

  --pad: clamp(20px, 5vw, 32px);
}

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

html { height: 100%; }

body {
  min-height: 100dvh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: var(--fz-body);
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(130% 80% at 50% -12%, var(--navy-lift) 0%, transparent 58%),
    radial-gradient(120% 70% at 50% 118%, #07081C 0%, transparent 52%),
    linear-gradient(180deg, var(--navy-mid) 0%, var(--navy-low) 46%, var(--navy-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* film grain — a whisper, not a texture pack */
.grain {
  position: fixed; inset: -50%;
  pointer-events: none;
  z-index: 3;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='180' height='180' filter='url(%23n)' opacity='0.6'/></svg>");
  opacity: .045;
  mix-blend-mode: overlay;
  animation: grain-drift 9s steps(6) infinite;
}
@keyframes grain-drift {
  0%,100% { transform: translate(0,0); }
  20% { transform: translate(-2%,1%); }
  40% { transform: translate(1%,-2%); }
  60% { transform: translate(-1%,2%); }
  80% { transform: translate(2%,1%); }
}

/* faint court geometry */
.court {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
}
.court circle, .court path {
  stroke: var(--court-stroke);
  stroke-width: 2;
}

/* ————— stage & screens ————— */

#stage { position: relative; z-index: 2; min-height: 100dvh; }

.screen {
  position: absolute; inset: 0;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  padding: calc(64px + env(safe-area-inset-top)) var(--pad) max(28px, env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  right: 0; left: 0;
}
.screen.center { justify-content: center; }

.screen-enter { opacity: 0; transform: translateY(26px) scale(.988); }
.screen-in {
  opacity: 1; transform: none;
  transition: opacity .46s var(--ease-out), transform .52s var(--ease-spring);
}
.screen-exit {
  opacity: 0; transform: translateY(-18px);
  transition: opacity .22s ease-in, transform .22s ease-in;
}

/* staggered child reveal */
.rise { opacity: 0; transform: translateY(18px); }
.screen-in .rise {
  opacity: 1; transform: none;
  transition: opacity .5s var(--ease-out), transform .55s var(--ease-spring);
}
.screen-in .rise.d1 { transition-delay: .07s; }
.screen-in .rise.d2 { transition-delay: .16s; }
.screen-in .rise.d3 { transition-delay: .26s; }
.screen-in .rise.d4 { transition-delay: .38s; }

/* ————— type ————— */

.eyebrow {
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 14px;
}
.eyebrow::before {
  content: '';
  display: inline-block;
  width: 22px; height: 2px;
  background: var(--accent);
  vertical-align: middle;
  margin-right: 10px;
  border-radius: 2px;
}

h1.q {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 560;
  font-variation-settings: 'SOFT' 68, 'WONK' 0, 'opsz' 40;
  font-size: var(--fz-hero);
  line-height: 1.12;
  letter-spacing: -.012em;
  text-wrap: balance;
  margin-bottom: 14px;
}

.hint { color: var(--ink-mute); font-size: var(--fz-small); }
.hint.lock::before { content: '🔒\00a0'; font-size: .8em; }

.body-copy { color: var(--ink-soft); max-width: 44ch; }

/* ————— back button ————— */

.back-btn {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  left: 14px;
  z-index: 5;
  width: 44px; height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(250, 247, 245, .05);
  color: var(--ink-mute);
  font: 500 1.6rem/1 'Fraunces', Georgia, serif;
  display: grid; place-items: center;
  padding: 0 0 4px;
  cursor: pointer;
  transition: background .2s, color .2s, transform .16s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.back-btn:hover { background: rgba(250, 247, 245, .1); color: var(--ink); }
.back-btn:active { transform: scale(.92); }

/* ————— progress dots ————— */

.dots {
  position: fixed;
  top: calc(20px + env(safe-area-inset-top));
  left: 50%; transform: translateX(-50%);
  display: flex; gap: 9px;
  z-index: 4;
  opacity: 0;
  transition: opacity .4s ease;
}
.dots.on { opacity: 1; }
.dots i {
  width: 6px; height: 6px; border-radius: 50%;
  background: rgba(250, 247, 245, .22);
  transition: background .3s, box-shadow .3s, transform .3s var(--ease-spring);
}
.dots i.done { background: rgba(250, 247, 245, .5); }
.dots i.now {
  background: var(--accent-hot);
  box-shadow: 0 0 10px rgba(217, 32, 39, .8);
  transform: scale(1.35);
}

/* ————— controls ————— */

.cta-zone { margin-top: auto; padding-top: 26px; display: grid; gap: 12px; }

.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 600 1.06rem/1 'Inter', system-ui, sans-serif;
  color: var(--ink);
  min-height: 58px;
  padding: 17px 26px;
  border-radius: 18px;
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .16s var(--ease-spring), box-shadow .25s, background .25s, color .25s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.965); }

.btn-primary {
  background: linear-gradient(180deg, #D92027, #C81B22);
  box-shadow: 0 12px 34px rgba(217, 32, 39, .34), inset 0 1px 0 rgba(255, 255, 255, .18);
  color: #FFF8F6;
}
.btn-primary:hover { box-shadow: 0 14px 40px rgba(217, 32, 39, .45); }

.btn-ghost {
  background: rgba(250, 247, 245, .05);
  border: 1px solid var(--line);
  color: var(--ink-soft);
}
.btn-ghost:hover { background: rgba(250, 247, 245, .09); }

.btn-quiet {
  background: none; color: var(--ink-mute);
  min-height: 44px; font-weight: 500; font-size: .95rem;
}
.btn-quiet:hover { color: var(--ink); }

.btn.copied {
  background: var(--ink);
  color: var(--navy-mid);
  box-shadow: 0 10px 30px rgba(250, 247, 245, .15);
}

:where(button, a, textarea, input):focus-visible {
  outline: 3px solid rgba(255, 106, 98, .75);
  outline-offset: 3px;
  border-radius: 6px;
}

/* headings receive programmatic focus for screen readers — never a ring */
h1:focus, h1:focus-visible { outline: none; }

.chip-all {
  border-color: rgba(255, 75, 69, .45);
  color: #FFD9D6;
  font-weight: 600;
}

/* ————— stars ————— */

.stars {
  display: flex; justify-content: center; gap: 6px;
  margin: 30px 0 10px;
}
.star {
  appearance: none; background: none; border: 0; cursor: pointer;
  width: 60px; height: 64px;
  display: grid; place-items: center;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.star svg { width: 46px; height: 46px; overflow: visible; }
.star svg path {
  fill: transparent;
  stroke: rgba(250, 247, 245, .42);
  stroke-width: 1.6;
  stroke-linejoin: round;
  transition: fill .2s, stroke .2s, filter .3s;
}
.star.lit svg path {
  fill: var(--accent);
  stroke: var(--accent-hot);
  filter: drop-shadow(0 0 12px rgba(217, 32, 39, .55));
}
.star.pop svg { animation: star-pop .42s var(--ease-spring); }
@keyframes star-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.32) rotate(-4deg); }
  100% { transform: scale(1); }
}

.star-label {
  text-align: center;
  min-height: 1.6em;
  color: var(--ink-soft);
  font-weight: 500;
  font-size: 1.05rem;
}

/* burst particles on 4–5 stars */
.burst { position: absolute; inset: 0; pointer-events: none; }
.burst i {
  position: absolute; left: 50%; top: 50%;
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent-hot);
  animation: burst-fly .62s ease-out forwards;
}
.burst i:nth-child(3n) { background: var(--ink); width: 4px; height: 4px; }
@keyframes burst-fly {
  0% { transform: rotate(var(--a)) translateY(0) scale(1); opacity: 1; }
  100% { transform: rotate(var(--a)) translateY(-48px) scale(.15); opacity: 0; }
}

/* ————— chips ————— */

.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 22px 0 6px; }
.chip {
  appearance: none; cursor: pointer;
  font: 500 .98rem/1.2 'Inter', system-ui, sans-serif;
  color: var(--ink-soft);
  background: rgba(250, 247, 245, .045);
  border: 1px solid rgba(250, 247, 245, .2);
  border-radius: 999px;
  padding: 12px 17px;
  min-height: 46px;
  transition: all .22s var(--ease-spring);
  -webkit-tap-highlight-color: transparent;
}
.chip[aria-pressed="true"] {
  color: #FFF8F6;
  background: rgba(217, 32, 39, .2);
  border-color: var(--accent-hot);
  box-shadow: 0 4px 18px rgba(217, 32, 39, .25);
}
.chip.pounce { animation: chip-pounce .38s var(--ease-spring); }
@keyframes chip-pounce {
  0% { transform: scale(1); }
  40% { transform: scale(1.09); }
  70% { transform: scale(.97); }
  100% { transform: scale(1); }
}

/* ————— text input ————— */

textarea {
  width: 100%;
  min-height: 130px;
  resize: none;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: rgba(7, 8, 26, .5);
  color: var(--ink);
  font: 400 1.05rem/1.6 'Inter', system-ui, sans-serif;
  padding: 18px;
  margin-top: 20px;
  transition: border-color .25s, box-shadow .25s;
}
textarea::placeholder { color: var(--ink-faint); }
textarea:focus {
  outline: none;
  border-color: rgba(255, 75, 69, .65);
  box-shadow: 0 0 0 4px rgba(217, 32, 39, .14);
}

/* ————— the feel-heard moment (screen 7) ————— */

.heard-lines { margin: 8px 0 26px; display: grid; gap: 18px; }
.heard-line {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 500;
  font-variation-settings: 'SOFT' 82, 'WONK' 1, 'opsz' 28;
  font-size: var(--fz-line);
  line-height: 1.18;
  letter-spacing: -.01em;
  text-wrap: balance;
  position: relative;
  padding-left: 22px;
  opacity: 0; transform: translateY(24px);
}
.heard-line::before {
  content: '“';
  position: absolute; left: -4px; top: -6px;
  color: var(--accent-hot);
  opacity: .8;
  font-size: 1.3em;
}
.heard-line.in {
  opacity: 1; transform: none;
  transition: opacity .6s var(--ease-out), transform .66s var(--ease-spring);
}
.thanks {
  color: var(--ink-soft);
  border-top: 1px solid var(--line);
  padding-top: 20px;
  max-width: 46ch;
}
.signature {
  font-family: 'Fraunces', Georgia, serif;
  font-variation-settings: 'SOFT' 90, 'WONK' 1;
  font-style: italic;
  font-size: 1.5rem;
  color: var(--accent-hot);
  margin-top: 10px;
}

/* ————— share screen ————— */

.recap {
  margin-top: 18px;
  background: rgba(250, 247, 245, .035);
  border: 1px solid rgba(250, 247, 245, .1);
  border-radius: 18px;
  padding: 16px 16px 12px;
}
.recap-label {
  font-size: .72rem; font-weight: 600;
  letter-spacing: .13em; text-transform: uppercase;
  color: var(--ink-mute);
  margin-bottom: 10px;
}
.recap-facts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; }
.sub-stars { color: var(--accent-hot); letter-spacing: 2px; font-size: .95rem; }
.sub-stars .off { color: rgba(250, 247, 245, .25); }
.pill {
  display: inline-block;
  background: rgba(250, 247, 245, .07);
  border: 1px solid rgba(250, 247, 245, .14);
  border-radius: 999px;
  padding: 4px 11px;
  font-size: .8rem;
  color: var(--ink-soft);
}
.quote-line {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 10px;
  padding: 10px 12px 10px 14px;
  background: none;
  border: 0;
  border-left: 2px solid rgba(255, 75, 69, .55);
  border-radius: 0 12px 12px 0;
  color: var(--ink);
  font: 400 .98rem/1.5 'Inter', system-ui, sans-serif;
  cursor: pointer;
  transition: background .2s, border-color .2s, opacity .2s;
  -webkit-tap-highlight-color: transparent;
}
.quote-line::after {
  content: '  +';
  color: var(--accent-hot);
  font-weight: 600;
}
.quote-line:hover { background: rgba(250, 247, 245, .05); }
.quote-line.used { opacity: .45; }
.quote-line.used::after { content: '  ✓'; color: var(--ink-mute); }
.add-hint { color: var(--ink-faint); font-size: .78rem; margin-top: 10px; }

.draft-wrap { position: relative; margin-top: 20px; }
.draft-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: -8px;
}
.draft-head b {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600; font-size: 1.25rem;
}
.draft-head span { color: var(--ink-mute); font-size: var(--fz-small); }
textarea.draft { min-height: 130px; }

.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.footnote { color: var(--ink-mute); font-size: .82rem; text-align: center; max-width: 40ch; margin: 2px auto 0; }

/* ————— closing ————— */

.close-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-variation-settings: 'SOFT' 75, 'WONK' 0, 'opsz' 60;
  font-size: clamp(2.2rem, 5.6vw + 1.2rem, 3.6rem);
  line-height: 1.08;
  letter-spacing: -.015em;
  text-wrap: balance;
  margin-bottom: 18px;
}
.tagline {
  margin-top: 34px;
  font-size: .8rem; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--accent-hot);
}
.logo-badge {
  width: 74px; height: 74px;
  border-radius: 50%;
  object-fit: contain;
  margin-bottom: 22px;
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, .45));
}

/* welcome logo, smaller */
.logo-badge.sm { width: 58px; height: 58px; margin-bottom: 18px; }

/* ————— toast ————— */

.toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink);
  color: var(--navy-mid);
  font-weight: 600; font-size: .92rem;
  padding: 12px 20px;
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .5);
  z-index: 9;
  transition: transform .45s var(--ease-spring);
  pointer-events: none;
  max-width: calc(100vw - 48px);
  text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* ————— error card ————— */
.dead-link {
  min-height: 100dvh; display: grid; place-items: center;
  text-align: center; padding: 40px; color: var(--ink-soft);
}

/* ————— reduced motion ————— */

@media (prefers-reduced-motion: reduce) {
  html:not(.motion-ok) *, html:not(.motion-ok) *::before, html:not(.motion-ok) *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
    transition-delay: 0ms !important;
  }
  html:not(.motion-ok) .grain { animation: none; }
}
html.rm *, html.rm *::before, html.rm *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
  transition-delay: 0ms !important;
}
html.rm .grain { animation: none; }

@media (min-width: 640px) {
  .screen { padding-top: 96px; }
}
