/* =============================================================================
 * onboarding-story.css — Story-onboarding foundation (scene layer + motion).
 *
 * Pairs with js/onboarding-story.js. Design source of truth:
 * ../../story-onboarding-storyboard.html (repo root).
 *
 * Everything here is inert unless the flow runs with the story flag on
 * (?story=1) — js/onboarding-story.js only mounts .story-frame then.
 * ========================================================================== */

:root {
  --story-ease: cubic-bezier(.22, 1, .36, 1);
  --story-exit-ms: 180ms;
  --story-enter-ms: 320ms;
  --story-scene-ms: 600ms;
}

/* --- Frame plumbing ---------------------------------------------------------
 * The scene layer persists across step swaps, so paint() renders into
 * .story-ui-host instead of wiping the whole frame. The host mirrors the
 * .frame flex column so the existing .ui/.ui-body/.ui-cta layout is unchanged.
 */
.frame.story-frame { position: relative; overflow: hidden; }
.story-ui-host {
  position: relative; z-index: 1;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column;
}
.story-ui-host .ui { flex: 1; min-height: 0; }

/* --- Step transition ---------------------------------------------------------
 * Exit: current screen fades up and out. Enter: next screen fades up and in,
 * slightly later. The classes are driven by js — CSS owns only the curves.
 */
.story-ui-host .ui.story-exit {
  opacity: 0; transform: translateY(-10px);
  transition: opacity var(--story-exit-ms) var(--story-ease),
              transform var(--story-exit-ms) var(--story-ease);
  pointer-events: none;
}
.story-ui-host .ui.story-enter { opacity: 0; transform: translateY(16px); }
.story-ui-host .ui.story-entering {
  opacity: 1; transform: none;
  transition: opacity var(--story-enter-ms) var(--story-ease),
              transform var(--story-enter-ms) var(--story-ease);
}

/* --- Scene layer -------------------------------------------------------------
 * A persistent world behind the cards. Nodes/edges are keyed by id and morph
 * between steps (position/opacity transitions). Dimmed during transactional
 * steps, full-strength during story beats.
 */
.story-scene {
  position: absolute; inset: 0; z-index: 0;
  overflow: hidden; pointer-events: none;
  opacity: 1;
  transition: opacity 400ms var(--story-ease);
  background: linear-gradient(180deg, #F2F7FF 0%, rgba(255, 255, 255, 0) 62%);
}
.story-scene.dimmed { opacity: .15; }
.story-scene.hidden { opacity: 0; }

/* Node: avatar circle. left/top are set in % by js and animate on morph. */
.sc-node {
  position: absolute; width: 34px; height: 34px; z-index: 2;
  border-radius: 50%; background: var(--tint, #E0EAF9);
  border: 2px solid var(--brand, #0250CB);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: var(--brand-d, #023A94);
  font-family: inherit;
  opacity: 1; transform: translate(-50%, -50%) scale(1);
  transition: left var(--story-scene-ms) var(--story-ease),
              top var(--story-scene-ms) var(--story-ease),
              opacity 350ms var(--story-ease),
              transform 350ms var(--story-ease),
              border-color 350ms var(--story-ease),
              background 350ms var(--story-ease);
}
.sc-node.big { width: 46px; height: 46px; font-size: 14px; }
.sc-node.dim { opacity: .38; border-style: dashed; }
.sc-node.lit { background: #E3F4EA; border-color: #1E7A46; color: #1E7A46; }
.sc-node.sc-in { opacity: 0; transform: translate(-50%, -50%) scale(.55); }
.sc-node.sc-out { opacity: 0 !important; transform: translate(-50%, -50%) scale(.55); }

/* Landing-page node language: gradient initials bubbles + the Hooz pill. */
.sc-node.sc-avatar {
  border: 2px solid #fff; color: #fff; font-size: 12px;
  box-shadow: 0 6px 14px -6px rgba(15, 23, 42, .35);
}
.sc-node.sc-avatar.big { font-size: 14px; }
.sc-node.sc-avatar.lit { box-shadow: 0 0 0 4px rgba(34, 163, 91, .3), 0 6px 14px -6px rgba(15, 23, 42, .35); border-color: #fff; color: #fff; }
.sc-node.sc-hooz {
  width: auto; height: 36px; border-radius: 999px; padding: 0 18px;
  background: linear-gradient(135deg, #0250CB, #0288D1);
  border: 2px solid #fff; color: #fff; font-size: 14px; font-weight: 800;
  box-shadow: 0 8px 18px -8px rgba(2, 80, 203, .55);
}

/* Pulse: a signal dot traveling an edge (geometry animated via WAAPI). */
.sc-pulse {
  position: absolute; width: 8px; height: 8px; z-index: 1;
  margin: -4px 0 0 -4px; border-radius: 50%;
  background: #22A35B; box-shadow: 0 0 6px rgba(34, 163, 91, .5);
  opacity: 0; pointer-events: none;
}

/* Cycle: a looping "pop in → edge draws → solidify → reset". Used for the
 * Hooz-AI beat, where the extended connections reveal themselves on repeat. */
.sc-node.sc-cycle { animation: scNodeCycle 4s ease-in-out infinite; }
.sc-edge.sc-cycle { animation: scEdgeCycle 4s ease-in-out infinite; }
@keyframes scNodeCycle {
  0%   { opacity: 0;  transform: translate(-50%, -50%) scale(.4); }
  14%  { opacity: .55; transform: translate(-50%, -50%) scale(1.06); }
  26%  { opacity: .6; transform: translate(-50%, -50%) scale(1); }
  42%  { opacity: 1;  transform: translate(-50%, -50%) scale(1); }
  86%  { opacity: 1;  transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0;  transform: translate(-50%, -50%) scale(.4); }
}
@keyframes scEdgeCycle {
  0%, 14% { opacity: 0; }
  30%     { opacity: .6; }
  86%     { opacity: .6; }
  100%    { opacity: 0; }
}

/* Edge: a rotated hairline between two nodes; js computes px geometry. */
.sc-edge {
  position: absolute; height: 0; z-index: 0;
  border-top: 2px solid #D9E4F5;
  transform-origin: 0 50%;
  opacity: .9;
  transition: opacity 350ms var(--story-ease),
              width var(--story-scene-ms) var(--story-ease),
              transform var(--story-scene-ms) var(--story-ease);
}
.sc-edge.strong { border-top-color: var(--brand, #0250CB); opacity: .55; }
.sc-edge.dashed { border-top-style: dashed; border-top-color: var(--muted2, #718096); opacity: .55; }
.sc-edge.sc-in, .sc-edge.sc-out { opacity: 0; }

/* Ripple: expanding ring, used for network pulses. */
.sc-ripple {
  position: absolute; width: 60px; height: 60px; margin: -30px 0 0 -30px;
  border: 2px solid var(--accent, #0288D1); border-radius: 50%;
  animation: scRipple 3.2s var(--story-ease) infinite;
}
@keyframes scRipple {
  0%   { transform: scale(.35); opacity: .7; }
  70%  { transform: scale(1.9); opacity: 0; }
  100% { transform: scale(1.9); opacity: 0; }
}

/* Badge: a labelled pill that pops onto the scene (reaction payoff). */
.sc-badge {
  position: absolute; transform: translate(-50%, -50%) scale(1);
  background: #E3F4EA; color: #1E7A46;
  font-size: 11px; font-weight: 750; letter-spacing: .02em;
  border-radius: 999px; padding: 4px 12px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(30, 122, 70, .18);
  transition: opacity 350ms var(--story-ease), transform 350ms var(--story-ease);
}
.sc-badge.sc-in, .sc-badge.sc-out { opacity: 0; transform: translate(-50%, -50%) scale(.6); }

/* --- Story beat chrome --------------------------------------------------------
 * Skip link under story-beat CTAs (FTUE only), and the beat counter eyebrow.
 */
.story-skip {
  text-align: center; color: var(--muted2, #718096);
  font-size: 13px; font-weight: 600; padding: 10px 0 0; cursor: pointer;
}
.story-skip:hover { color: var(--muted, #4A5568); }
.story-beat-count {
  text-align: center; font-size: 11px; font-weight: 750;
  letter-spacing: .09em; color: var(--brand, #0250CB); margin-bottom: 6px;
}

/* --- Auto-typing thread --------------------------------------------------------
 * Bubbles reuse the .demo/.bub visual language from onboarding.css but are
 * appended live by Story.typeThread (no looping keyframes).
 */
.story-thread .bub { animation: none; opacity: 1; transform: none; }
.story-thread .bub.story-bub-in { opacity: 0; transform: translateY(9px) scale(.97); }
.story-thread .bub { transition: opacity 260ms var(--story-ease), transform 260ms var(--story-ease); }
.sc-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.sc-typing i {
  width: 6px; height: 6px; border-radius: 50%; background: #9A9AA0;
  animation: scTypeDot 1.2s infinite;
}
.sc-typing i:nth-child(2) { animation-delay: .18s; }
.sc-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes scTypeDot { 0%, 60%, 100% { opacity: .35; } 30% { opacity: 1; } }

/* --- Reduced motion ------------------------------------------------------------
 * Crossfades only: no travel, no ripples, scenes render as stills.
 */
@media (prefers-reduced-motion: reduce) {
  .story-ui-host .ui.story-exit,
  .story-ui-host .ui.story-entering { transform: none; transition-duration: 1ms; }
  .story-ui-host .ui.story-enter { transform: none; }
  .sc-node, .sc-edge, .sc-badge, .story-thread .bub { transition-duration: 1ms; }
  .sc-ripple, .sc-typing i { animation: none; }
  .sc-node.sc-cycle { animation: none; opacity: 1; transform: translate(-50%, -50%) scale(1); }
  .sc-edge.sc-cycle { animation: none; opacity: .6; }
}

/* =============================================================================
 * Slice 2 — Manager story content
 * ========================================================================== */

/* --- Team-type picker: two cards side by side, detail reveals in place -------
 * Fixes the "whole screen goes white" re-render: clicking a card toggles
 * selection and swaps the detail panel below without repainting the screen.
 */
.story-modes { display: flex; gap: 12px; margin: 4px 0 0; }
.story-mode {
  flex: 1; text-align: center; cursor: pointer; user-select: none;
  background: #fff; border: 2px solid var(--line, #E2E8F0); border-radius: 16px;
  padding: 18px 12px 16px;
  transition: border-color .18s var(--story-ease), background .18s var(--story-ease),
              transform .12s var(--story-ease), box-shadow .18s var(--story-ease);
}
.story-mode:hover { border-color: #C7D6EE; }
.story-mode.sel {
  border-color: var(--brand, #0250CB); background: var(--tint, #E0EAF9);
  box-shadow: 0 6px 18px rgba(2, 80, 203, .13);
}
.story-mode .emoji { font-size: 30px; line-height: 1; }
.story-mode .name { font-weight: 750; font-size: 15px; margin-top: 8px; color: var(--ink, #1A202C); }
.story-mode-detail { overflow: hidden; }
.story-mode-detail.reveal { animation: modeReveal .34s var(--story-ease); }
@keyframes modeReveal {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.story-mode-desc {
  font-size: 13.5px; color: var(--muted, #4A5568); line-height: 1.5;
  margin: 16px auto 4px; max-width: 300px; text-align: center;
}

/* --- Invite: roster circles fill green one-by-one (people joining) -----------
 */
.roster-fill { display: flex; flex-direction: column; align-items: center; gap: 16px; margin: 6px 0 2px; }
.roster-ring {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px 14px;
  max-width: 280px; margin: 0 auto;
}
.rf-seat {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; font-family: inherit;
  border: 2px dashed #C7D0DB; color: transparent; background: #fff;
  opacity: .55;
}
.rf-seat.filled {
  border: 2px solid #1E7A46; border-style: solid;
  background: #E3F4EA; color: #1E7A46; opacity: 1;
  animation: seatPop .42s var(--story-ease) both;
}
@keyframes seatPop {
  0%   { transform: scale(.5); opacity: 0; }
  55%  { transform: scale(1.14); }
  100% { transform: scale(1); opacity: 1; }
}
.rf-counter {
  font-size: 13px; font-weight: 750; color: var(--brand-d, #023A94);
  background: var(--tint, #E0EAF9); border-radius: 999px; padding: 5px 15px;
  font-variant-numeric: tabular-nums;
}

/* --- Connect-your-teams: 5 · YOU · 5 network with recommended subs -----------
 */
.connect-viz { width: 100%; max-width: 320px; margin: 2px auto 0; }
.connect-viz svg { width: 100%; height: auto; display: block; overflow: visible; }
.cv-edge { stroke: var(--brand, #0250CB); stroke-width: 2; opacity: 0; }
.cv-edge.on { animation: cvEdgeDraw .5s var(--story-ease) forwards; }
@keyframes cvEdgeDraw { from { opacity: 0; } to { opacity: .8; } }
.cv-node { transition: fill .35s var(--story-ease), stroke .35s var(--story-ease); }
.cv-rec { opacity: 0; transform-box: fill-box; transform-origin: center; }
.cv-rec.on { animation: cvRecPop .4s var(--story-ease) forwards; }
@keyframes cvRecPop { 0% { opacity: 0; transform: scale(.4); } 60% { transform: scale(1.15); } 100% { opacity: 1; transform: scale(1); } }
.connect-cap {
  display: inline-block; margin: 12px auto 0;
  font-size: 12px; font-weight: 750; letter-spacing: .02em;
  color: #1E7A46; background: #E3F4EA; border-radius: 999px; padding: 5px 14px;
  opacity: 0;
}
.connect-cap.on { animation: modeReveal .4s var(--story-ease) forwards; }

@media (prefers-reduced-motion: reduce) {
  .story-mode-detail.reveal,
  .rf-seat.filled, .cv-edge.on, .cv-rec.on, .connect-cap.on { animation-duration: 1ms; }
}

/* --- Story chrome tweaks (Slice 2 feedback) ---------------------------------
 * Hide the "X of 6" step counter in story mode — the story shouldn't feel like
 * a numbered form.
 */
.story-frame .ui-top .step { display: none; }

/* Roster fill sits a touch lower so the block reads as vertically centered. */
.roster-fill { margin-top: 26px; }

/* --- Reward network (growthSub): games flow to YOU through your network ------
 */
.reward-net { width: 100%; max-width: 320px; margin: 2px auto 0; }
.reward-net svg { width: 100%; height: auto; display: block; overflow: visible; }
.rn-node { animation: rnFloat 5.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.rn-node:nth-child(3n)   { animation-duration: 6.2s; animation-delay: .7s; }
.rn-node:nth-child(3n+1) { animation-duration: 5.7s; animation-delay: 1.5s; }
.rn-node:nth-child(4n)   { animation-delay: 2.3s; }
@keyframes rnFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
.rn-found { filter: drop-shadow(0 0 0 rgba(30,122,70,.35)); }
.rn-chip {
  fill: #1E7A46; font-size: 10px; font-weight: 800;
  opacity: 0; animation: rnChip 3.6s ease-in-out infinite;
}
.reward-cap {
  display: inline-block; margin: 12px auto 0;
  font-size: 12.5px; font-weight: 750; color: #1E7A46;
  background: #E3F4EA; border-radius: 999px; padding: 6px 15px;
}
@keyframes rnChip { 0%,20% { opacity: 0; transform: translateY(4px); } 35%,72% { opacity: 1; transform: none; } 90%,100% { opacity: 0; } }

/* --- Done screen: big primary + two square buttons (Slice 2 feedback) --------
 */
.story-dl { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.story-dl .dl-sub { font-size: 12px; font-weight: 600; color: rgba(255,255,255,.85); }
.story-done-row { display: flex; gap: 12px; margin-top: 12px; }
.story-sq {
  flex: 1; min-height: 82px; border-radius: 16px;
  border: 1.5px solid var(--line, #E2E8F0); background: #fff; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-family: inherit; font-weight: 700; font-size: 13.5px; color: var(--ink, #1A202C);
  padding: 12px 8px; text-align: center; line-height: 1.25;
  transition: border-color .15s var(--story-ease), background .15s var(--story-ease), transform .1s var(--story-ease);
}
.story-sq:hover { border-color: #C7D6EE; background: #FAFCFF; }
.story-sq:active { transform: scale(.98); }
.story-sq .sq-ic { font-size: 21px; line-height: 1; }

/* Done hero: the landing-page Hooz wordmark on a transparent ground. */
.done-logo {
  height: 60px; width: auto; display: block; margin: 8px auto 0;
}

/* Download block: label + the store badges stacked vertically. Flows under
 * the hero in the centered body, so it needs a little separation on top. */
.story-dl-block { display: flex; flex-direction: column; align-items: center; gap: 9px; margin: 12px 0 4px; }
.story-dl-block .dl-label { font-size: 14.5px; font-weight: 750; color: var(--ink, #1A202C); text-align: center; max-width: 300px; }
.story-dl-block .store-row { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.story-dl-block .store-row img { height: 44px; width: auto; display: block; }

/* Long www.hooz.app button at the very bottom. */
.story-url-btn { width: 100%; margin-top: 12px; letter-spacing: .01em; }

/* --- Story player landing: wordmark → "Your new assistant" → three typed
 * texts → the welcome line. Clean, crisp, main-landing feel. -------------- */
.lw-logo {
  height: 46px; width: auto; display: block; margin: 26px auto 0;
  animation: gsRise .5s var(--story-ease) both;
}
.lw-head {
  font-size: 28px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15;
  text-align: center; color: var(--ink, #1A202C); margin: 14px 0 0;
  animation: gsRise .55s var(--story-ease) .15s both;
}
.lw-demo { margin-top: 22px; animation: gsRise .55s var(--story-ease) .3s both; }
.lw-welcome {
  text-align: center; font-size: 17px; font-weight: 750;
  color: var(--brand, #0250CB); margin-top: 18px; opacity: 0;
}
.lw-welcome.show { animation: gsRise .5s var(--story-ease) both; }

@media (prefers-reduced-motion: reduce) {
  .lw-logo, .lw-head, .lw-demo, .lw-welcome.show { animation-duration: 1ms; animation-delay: 0ms; }
  .lw-welcome.show { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .rn-node, .rn-chip { animation: none; }
}

/* =============================================================================
 * Slice 3 — continuous story flow (interstitials, staged team name, spacers)
 * ========================================================================== */

/* Scene spacer: reserves the top of the card for the persistent scene so the
 * bubbles NEVER collide with copy (the round-1 lesson). */
.scene-spacer { height: 200px; flex: 0 0 auto; }
.scene-spacer.tall { height: 290px; }
.scene-spacer.short { height: 150px; }

/* --- Interstitial beats ("Let's get started!", "Let's build the network") ---
 * Landing-page feel: wordmark pans in, headline rises with the hero type.
 */
.story-interstitial {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center;
  gap: 18px; cursor: pointer;
}
.story-interstitial .gs-logo {
  height: 40px; width: auto;
  animation: gsPan .7s var(--story-ease) both;
}
.story-interstitial h2 {
  font-size: 30px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15;
  color: var(--ink, #1A202C); margin: 0; max-width: 300px;
  animation: gsRise .6s var(--story-ease) .25s both;
}
.story-interstitial .gs-sub {
  font-size: 14.5px; color: var(--muted, #4A5568); margin: 0; max-width: 280px;
  animation: gsRise .6s var(--story-ease) .45s both;
}
@keyframes gsPan  { from { opacity: 0; transform: translateX(-46px); } to { opacity: 1; transform: none; } }
@keyframes gsRise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* --- Staged team-name reveal --------------------------------------------------
 * Phase 1: just the name input. Phase 2: the typed name lifts to the top as a
 * title, "What do you need to play?" appears in brand blue, then the
 * requirements card rises in.
 */
.tn-title {
  font-size: 27px; font-weight: 800; letter-spacing: -.015em; text-align: center;
  color: var(--ink, #1A202C); margin: 0;
  animation: tnLift .55s var(--story-ease) both;
}
@keyframes tnLift {
  from { opacity: .4; transform: translateY(150px) scale(1.06); }
  to   { opacity: 1; transform: none; }
}
.tn-q {
  text-align: center; font-size: 15px; font-weight: 750;
  color: var(--brand, #0250CB); margin: 14px 0 0;
  animation: gsRise .5s var(--story-ease) .45s both;
}
.tn-panel { animation: gsRise .55s var(--story-ease) .95s both; }

@media (prefers-reduced-motion: reduce) {
  .story-interstitial .gs-logo, .story-interstitial h2, .story-interstitial .gs-sub,
  .tn-title, .tn-q, .tn-panel { animation-duration: 1ms; animation-delay: 0ms; }
}
