/* ============================================================
   The Robin Cam — foundation styles
   Design direction: plan §3 (warm living storybook).
   This is the FOUNDATION: tokens locked, structure + motion in place.
   The Phase 5 showpiece pass polishes on top of this — see PHASE5-PLAN.md.
   ============================================================ */

:root {
  /* Palette — derived from the robin (plan §3) */
  --robin-egg:     #7FD4C1;   /* hero color, the literal egg */
  --morning-cream: #FBF6EC;   /* background, dawn light */
  --robin-breast:  #E8743B;   /* terracotta accent, the joy color, CTAs */
  --nest-brown:    #3D2E26;   /* primary text (warm, never cold black) */
  --dawn-gold:     #F4C95D;   /* highlights, live pulse, egg glow */
  --soft-sky:      #BFE6DD;   /* subtle fills, card tints */

  /* Derived tints */
  --cream-deep:   #F3EAD7;
  --ink-soft:     #6B574B;
  --card-bg:      #FFFFFF;
  --hairline:     #ECE0CC;
  --terracotta-ink: #A8481C;  /* AA-safe terracotta for SMALL text on cream/white (≥5.4:1); --robin-breast stays for decorative/large */

  /* Type */
  --display: "Fraunces", Georgia, "Times New Roman", serif;
  --body: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", sans-serif;

  /* Rhythm */
  --maxw: 940px;
  --radius: 22px;
  --radius-lg: 34px;
  --shadow: 0 18px 50px -24px rgba(61, 46, 38, 0.35);
  --shadow-soft: 0 10px 30px -18px rgba(61, 46, 38, 0.28);
  --gap: clamp(1.25rem, 4vw, 2.5rem);

  --ease-spring: cubic-bezier(0.22, 1, 0.36, 1);

  --day: 0.5;   /* 0 = night, 1 = midday; set from the viewer's local clock (app.js) */
}

/* ---- reset-ish ---- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }   /* must win over component display rules */
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--nest-brown);
  background:
    radial-gradient(1200px 600px at 50% -10%, var(--soft-sky) 0%, transparent 60%),
    var(--morning-cream);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
button { font: inherit; cursor: pointer; }
h1, h2, p { margin: 0; }

/* ---- accessibility ---- */
.skip-link {
  position: absolute; left: 50%; top: -3rem; transform: translateX(-50%);
  background: var(--nest-brown); color: var(--morning-cream);
  padding: 0.6rem 1rem; border-radius: 0 0 12px 12px; z-index: 100;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }
:focus-visible {
  outline: 3px solid var(--robin-breast);
  outline-offset: 3px;
  border-radius: 6px;
}
.sr-only {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* Privacy-first: with JS on, keep the live page hidden until site.json confirms
   "live" — so content never flashes before the kill switch can apply, and a stale/
   unreachable control doc fails CLOSED to the veil. With JS off, .js is absent so the
   static page shows (see the <noscript> in the video frame). */
html.js body[data-site="pending"] .page,
html.js body[data-site="private"] .page { visibility: hidden; }

/* ---- layout ---- */
.page {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2rem) 4rem;
}

/* ---- masthead ---- */
.masthead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.5rem 0 1.5rem;
}
.wordmark {
  font-family: var(--display);
  font-weight: 600;
  font-size: clamp(1.4rem, 4.5vw, 2rem);
  color: var(--nest-brown);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.masthead__brand { display: flex; flex-direction: column; gap: 0.05rem; min-width: 0; }
.masthead__greeting {
  font-family: var(--display); font-style: italic; font-weight: 500;
  font-size: 0.82rem; color: var(--ink-soft); letter-spacing: 0.005em;
}
.masthead__right { display: flex; align-items: center; gap: 0.75rem; }

.live-pill {
  display: inline-flex; align-items: center; gap: 0.45rem;
  background: rgba(232, 116, 59, 0.12);
  color: var(--nest-brown);            /* AA on the pale fill; the breathing dot carries the terracotta */
  font-weight: 700; font-size: 0.82rem; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.4rem 0.7rem 0.4rem 0.6rem; border-radius: 999px;
}
.live-pill[data-live="false"] { background: rgba(107, 87, 75, 0.1); color: var(--ink-soft); }
.live-pill__dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--robin-breast);
  box-shadow: 0 0 0 0 rgba(232, 116, 59, 0.55);
  animation: breathe 2.4s ease-in-out infinite;
}
.live-pill[data-live="false"] .live-pill__dot { background: var(--ink-soft); animation: none; }
@keyframes breathe {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 116, 59, 0.5); }
  50% { box-shadow: 0 0 0 7px rgba(232, 116, 59, 0); }
}

.share-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border: 1.5px solid var(--hairline); background: var(--card-bg);
  color: var(--nest-brown); border-radius: 999px;
  padding: 0.45rem 1.05rem; font-weight: 600; font-size: 0.92rem;
  transition: transform 0.2s var(--ease-spring), border-color 0.2s ease, background 0.2s ease;
}
.share-btn:hover { border-color: var(--robin-breast); transform: translateY(-1px); }

/* ---- hero ---- */
.hero { text-align: center; padding: clamp(0.5rem, 2vw, 1.5rem) 0 0; }
.hero__eyebrow {
  font-family: var(--body); font-weight: 700;
  font-size: 0.74rem; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--terracotta-ink);
  margin: 0 0 clamp(0.5rem, 1.6vw, 0.85rem);
}
.hero__narration {
  font-family: var(--display);
  font-weight: 460;                 /* variable Fraunces: lighter cut reads more elegant at display size */
  font-optical-sizing: auto;        /* let Fraunces use its display optical master at large sizes */
  font-size: clamp(1.5rem, 8vw, 3.5rem);   /* ramps smoothly 320px→desktop, no binary step */
  line-height: 1.06;
  letter-spacing: -0.022em;
  color: var(--nest-brown);
  max-width: 15ch;                  /* a deliberately narrow measure — reads like a line of verse */
  margin: 0 auto clamp(1.25rem, 3vw, 2rem);
  padding-inline: 0.5rem;
  text-wrap: balance;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);   /* faint lift off the cream */
  transition: opacity 0.3s ease, transform 0.45s var(--ease-spring), filter 0.3s ease;
}
.hero__narration.is-swapping { opacity: 0; transform: translateY(8px); filter: blur(2px); }
/* the fresh sentence "sets" like ink — a brief terracotta bloom that resolves */
@keyframes inkSettle {
  from { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 7px rgba(168, 72, 28, 0.28); }
  to   { text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 0 rgba(168, 72, 28, 0); }
}
@media (prefers-reduced-motion: no-preference) {
  .hero__narration.is-fresh { animation: inkSettle 0.6s ease; }
}

/* ---- THE CLUTCH — a CSS nest cup cradling the eggs (the showpiece) ---- */
.clutch {
  width: min(86%, 340px);
  margin: clamp(0.25rem, 1.5vw, 0.75rem) auto clamp(1.25rem, 3vw, 2rem);
}
.clutch__cup {
  position: relative;
  aspect-ratio: 5 / 2.15;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: clamp(8px, 2.4vw, 16px);
  border-radius: 46% 46% 48% 48% / 24% 24% 78% 78%;
  background:
    radial-gradient(110% 70% at 50% 0%, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0) 55%),
    /* woven layers: concentric rings curving around a centre below the bowl */
    repeating-radial-gradient(58% 82% at 50% 130%,
      rgba(43, 32, 24, 0) 0 7px, rgba(43, 32, 24, 0.30) 7px 9px, rgba(134, 98, 67, 0.10) 9px 15px),
    radial-gradient(120% 135% at 50% -12%, #7a5c43 0%, #573f2e 48%, #38291f 100%);
  box-shadow:
    inset 0 16px 24px -12px rgba(0, 0, 0, 0.6),
    inset 0 -10px 16px -10px rgba(255, 232, 190, 0.16),
    0 16px 26px -16px rgba(61, 46, 38, 0.55);
  overflow: hidden;
  isolation: isolate;
}
/* warm light pooling under the eggs — strength driven by --glow (time-aware later) */
.clutch__glow {
  position: absolute; left: 50%; bottom: -8%;
  width: 72%; height: 78%;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--dawn-gold), rgba(244, 201, 93, 0) 62%);
  /* warm at night, faded at noon — solves the "empty nest = dead page" problem */
  opacity: calc(0.5 * (1 - var(--day)) + 0.06);
  z-index: 0; pointer-events: none;
  transition: opacity 1.2s ease;
}
.clutch__eggs {
  position: relative; z-index: 1;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: clamp(2px, 1vw, 6px);
}
.clutch__slot { display: block; line-height: 0; }
.clutch__slot + .clutch__slot { margin-left: clamp(-10px, -1.8vw, -4px); }   /* nestle / overlap */
.clutch__slot:nth-child(1) { transform: rotate(-9deg) translateY(1px); }
.clutch__slot:nth-child(2) { transform: rotate(4deg)  translateY(3px); }
.clutch__slot:nth-child(3) { transform: rotate(-3deg) translateY(3px); }
.clutch__slot:nth-child(4) { transform: rotate(8deg)  translateY(1px); }
.clutch__slot:nth-child(5) { transform: rotate(-6deg) translateY(0); }
.clutch__egg {
  width: clamp(30px, 8.5vw, 46px); height: auto; display: block;
  filter: drop-shadow(0 3px 3px rgba(43, 32, 24, 0.4));
}
/* the signature beat: a fresh egg drops in, the cup glows once and takes a deeper breath */
@keyframes eggSettle {
  0%   { transform: translateY(-46px) scale(0.86); opacity: 0; }
  55%  { transform: translateY(4px)  scale(1.05); opacity: 1; }
  78%  { transform: translateY(-2px) scale(0.99); }
  100% { transform: translateY(0)    scale(1); }
}
.clutch__egg.settle { animation: eggSettle 0.62s var(--ease-spring) both; }
@keyframes cupBreath { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.035); } }
@keyframes glowPulse {
  0%, 100% { opacity: calc(0.5 * (1 - var(--day)) + 0.06); }
  35%      { opacity: calc(0.5 * (1 - var(--day)) + 0.56); }
}
@keyframes cupIdleBreath { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.012); } }
@media (prefers-reduced-motion: no-preference) {
  .clutch__cup { animation: cupIdleBreath 6s ease-in-out infinite; }
  .clutch__cup.is-arriving { animation: cupBreath 0.7s var(--ease-spring); }   /* arrival overrides idle */
  .clutch__cup.is-arriving .clutch__glow { animation: glowPulse 0.7s ease; }
}

/* ---- the organic video frame ---- */
.stage-frame {
  position: relative; margin: 0 auto; max-width: 820px;
  border-radius: var(--radius-lg);
  padding: clamp(8px, 1.5vw, 14px);
  background: linear-gradient(160deg, #fff 0%, var(--cream-deep) 100%);
  box-shadow: var(--shadow);
}
.stage-frame::before {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit; padding: 1.5px;
  background: linear-gradient(160deg, var(--robin-egg), var(--dawn-gold));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor; mask-composite: exclude;
  opacity: 0.5; pointer-events: none;
}
.stage-frame__media {
  position: relative; aspect-ratio: 16 / 9;
  border-radius: calc(var(--radius-lg) - 10px);
  overflow: hidden; background: #2a2018;
}
.stage-frame__media iframe { width: 100%; height: 100%; border: 0; display: block; }
/* transparent cover over the iframe so YouTube's chrome can't be hovered back into view */
.stage-frame__cover { position: absolute; inset: 0; z-index: 1; background: transparent; }
.stage-frame__poster {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 0.5rem;
  color: var(--cream-deep); text-align: center;
  background: radial-gradient(circle at 50% 40%, #4a3b30, #2a2018);
}
.stage-frame__poster-bird { font-size: clamp(2.5rem, 8vw, 4rem); }
.stage-frame__live {
  position: absolute; top: clamp(14px, 2.5vw, 22px); right: clamp(14px, 2.5vw, 22px);
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: rgba(20, 14, 10, 0.6); color: #fff; backdrop-filter: blur(6px);
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  padding: 0.35rem 0.6rem; border-radius: 999px;
}
.stage-frame__live-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--robin-breast);
  animation: breathe 2.4s ease-in-out infinite;
}

/* presence as a book-plate caption under the video (Fraunces italic, centred) */
.presence {
  display: inline-flex; align-items: center; gap: 0.45rem;
  margin: clamp(0.9rem, 2.5vw, 1.4rem) auto 0;
  font-family: var(--display); font-style: italic; font-weight: 500;
  font-size: clamp(0.95rem, 2.4vw, 1.1rem); color: var(--ink-soft);
}
.presence__icon { font-style: normal; transition: transform 0.4s var(--ease-spring); }
.presence[data-present="true"] .presence__icon { transform: translateY(-1px) rotate(-6deg); }

/* ---- cards / sections ---- */
section { margin-top: clamp(2rem, 6vw, 3.5rem); }
.card {
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: clamp(1.25rem, 3.5vw, 2rem);
  box-shadow: var(--shadow-soft);
}
.section-title {
  font-family: var(--body); font-weight: 700;
  font-size: 0.78rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--terracotta-ink); margin-bottom: 0.85rem;
}

/* ---- stage + journey ---- */
.stage__head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.stage__label {
  font-family: var(--display); font-size: clamp(1.25rem, 3.5vw, 1.7rem);
  font-weight: 500; color: var(--nest-brown);
}
.journey {
  list-style: none; margin: 1.25rem 0 0; padding: 0;
  display: flex; gap: 0.3rem;
}
.journey__step {
  flex: 1 1 0; min-width: 0;          /* all six share the width and shrink to fit — never scroll/clip */
  display: flex; flex-direction: column; align-items: center; gap: 0.4rem;
  text-align: center; color: var(--ink-soft);
  font-size: clamp(0.6rem, 2.3vw, 0.74rem); font-weight: 600;
  line-height: 1.15; overflow-wrap: break-word; hyphens: auto;
}
.journey__dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--cream-deep); border: 2px solid var(--hairline);
  position: relative;
}
.journey__step[data-done="true"] .journey__dot { background: var(--soft-sky); border-color: var(--robin-egg); }
.journey__step[data-current="true"] { color: var(--nest-brown); }
.journey__step[data-current="true"] .journey__dot {
  background: var(--robin-breast); border-color: var(--robin-breast);
  box-shadow: 0 0 0 5px rgba(232, 116, 59, 0.18);
}
/* connecting path between the steps; the completed stretch tints to robin-egg */
.journey__step { position: relative; }
.journey__dot { z-index: 1; }
.journey__step::after {
  content: ""; position: absolute; top: 7px; left: 50%; z-index: 0;
  width: calc(100% + 0.3rem); height: 2px; background: var(--hairline);
}
.journey__step:last-child::after { display: none; }
.journey__step[data-done="true"]::after { background: var(--robin-egg); }
@keyframes dotGlow {
  0%, 100% { box-shadow: 0 0 0 4px rgba(232, 116, 59, 0.18); }
  50%      { box-shadow: 0 0 0 8px rgba(232, 116, 59, 0.06); }
}
@media (prefers-reduced-motion: no-preference) {
  .journey__step[data-current="true"] .journey__dot { animation: dotGlow 2.6s ease-in-out infinite; }
}

/* ---- scoreboard ---- */
.scoreboard {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: clamp(0.6rem, 2vw, 1rem);
}
.tile {
  background: var(--card-bg); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: clamp(1rem, 2.5vw, 1.5rem) 0.75rem;
  text-align: center; box-shadow: var(--shadow-soft);
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
}
.tile__emoji { font-size: 1.5rem; }
.tile__value {
  font-family: var(--display); font-weight: 600; line-height: 1.05;
  font-size: clamp(1.5rem, 5vw, 2.4rem); color: var(--nest-brown);
  text-wrap: balance; overflow-wrap: break-word;
}
.tile__label { font-size: 0.76rem; font-weight: 600; color: var(--ink-soft); letter-spacing: 0.01em; }

/* ---- explainer ---- */
.explainer__body { font-size: clamp(1rem, 2.5vw, 1.15rem); color: var(--ink-soft); max-width: 60ch; }

/* ---- sparkline ---- */
.sparkline { display: flex; align-items: flex-end; gap: 4px; height: 72px; }
.sparkline__bar {
  flex: 1; border-radius: 6px 6px 3px 3px;
  background: linear-gradient(var(--robin-egg), var(--dawn-gold));   /* sky → golden horizon */
  min-height: 4px; transition: height 0.6s var(--ease-spring);
}
.rhythm__axis {
  display: flex; justify-content: space-between;
  margin-top: 0.5rem; font-size: 0.68rem; font-weight: 600;
  letter-spacing: 0.04em; color: var(--ink-soft);
}

/* ---- timeline (a vertical rail of milestones) ---- */
.timeline { list-style: none; margin: 0; padding: 0; position: relative; display: grid; gap: 1.15rem; }
.timeline::before {
  content: ""; position: absolute; left: 15px; top: 12px; bottom: 12px;
  width: 2px; background: var(--hairline);
}
.timeline__item { position: relative; padding-left: 2.6rem; }
.timeline__icon {
  position: absolute; left: 0; top: -2px;
  width: 32px; height: 32px; display: grid; place-content: center;
  font-size: 1rem; line-height: 1;
  background: var(--card-bg); border: 1px solid var(--hairline); border-radius: 50%;
}
.timeline__date {
  display: block;
  font-variant-numeric: tabular-nums; font-weight: 700; color: var(--terracotta-ink);
  font-size: 0.78rem; letter-spacing: 0.02em;
}
.timeline__label { display: block; color: var(--nest-brown); margin-top: 0.05rem; }

/* ---- fact ---- */
.fact {
  text-align: center; background: linear-gradient(160deg, var(--soft-sky), var(--morning-cream));
  border-radius: var(--radius); padding: clamp(1.5rem, 4vw, 2.5rem);
  border: 1px solid var(--hairline);
}
.fact__title { color: var(--nest-brown); }
.fact__body { font-family: var(--display); font-size: clamp(1.1rem, 3vw, 1.5rem); font-weight: 500; max-width: 40ch; margin: 0 auto; }

/* ---- footer ---- */
.footer { margin-top: clamp(2.5rem, 7vw, 4rem); text-align: center; color: var(--ink-soft); }
.footer__line { font-family: var(--display); font-style: italic; font-size: 1.15rem; }
.footer__sub { font-size: 0.85rem; margin-top: 0.4rem; }
.footer__note { color: var(--terracotta-ink); font-weight: 600; }

/* ---- private veil (kill switch) ---- */
.private-veil { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center;
  background: var(--morning-cream); padding: 2rem; text-align: center; }
.private-veil__card { max-width: 30ch; }
.private-veil__bird { font-size: 3rem; display: block; margin-bottom: 1rem; }
.private-veil p { font-family: var(--display); font-size: clamp(1.2rem, 4vw, 1.6rem); }

/* ---- count-up helper ---- */
[data-countup] { font-variant-numeric: tabular-nums; }

/* ---- entrances ---- */
.reveal { opacity: 0; transform: translateY(18px); }
.reveal.is-in { opacity: 1; transform: none; transition: opacity 0.7s ease, transform 0.7s var(--ease-spring); }

/* ---- responsive ---- */
@media (max-width: 620px) {
  .scoreboard { grid-template-columns: repeat(2, 1fr); }
  .share-btn { padding: 0.4rem 0.85rem; }
}
@media (max-width: 400px) {
  /* keep the whole masthead row on one line at 320px */
  .masthead { gap: 0.5rem; }
  .wordmark { font-size: clamp(1.2rem, 5.4vw, 1.6rem); white-space: nowrap; }
  .masthead__greeting { font-size: 0.72rem; }
  .masthead__right { gap: 0.4rem; }
  .live-pill { padding: 0.35rem 0.5rem; font-size: 0.72rem; }
  .share-btn { padding: 0.4rem 0.7rem; font-size: 0.85rem; }
}
@media (pointer: coarse) {
  .share-btn { min-height: 44px; }   /* comfortable touch target on phones/tablets */
}

/* ---- reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
}
