/* The public Coming soon page (specs 047, 048). Same-origin files only: the CSP in _headers allows no inline styles,
 * outside fonts or requests (047 design §6). Tokens copied from frontend/src/index.css :root (047 TD-236).
 * Every element's base style is its finished place; keyframes only say where it starts (048 design §6). */

@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 200 1000;
  font-display: swap;
  src: url('fonts/nunito-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* The app's handwritten script, for "dreams" and "why not?" (048 FR-004, FR-014). */
@font-face {
  font-family: 'Caveat';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url('fonts/caveat-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329,
    U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  --page: #f5f8fe;
  --surface: #ffffff;
  --surface-soft: #eaf0fc;
  --border: #dce4f2;
  --heading: #14213d;
  --text: #334155;
  --muted: #5b6b82;
  --accent: #2f5bea;
  --logo-mint: #7ee2a8;
  --logo-peach: #fdba74;

  /* Decorative blends of the tokens above, for the illustration only. */
  --accent-line: rgba(47, 91, 234, 0.2);
  --accent-faint: rgba(47, 91, 234, 0.1);
  --ink-shadow: rgba(20, 33, 61, 0.14);

  /* Entrances blur in on desktops; phones skip it (048 FR-008). */
  --enter-filter: blur(8px);

  color-scheme: light;
}

.lite {
  --enter-filter: none;
}

[hidden] {
  display: none !important;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: clip;
  background: radial-gradient(ellipse 60% 70% at 78% 45%, var(--surface-soft), transparent 70%), var(--page);
  color: var(--text);
  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Layout (048 FR-015): words, then the illustration; side by side on wide screens ── */

.page {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100vh;
  min-height: 100svh;
  max-width: 1600px;
  margin: 0 auto;
  padding: 40px 22px 88px;
  /* The orbits and sparks may reach past the illustration's box; never past the screen (NFR-004). */
  overflow-x: clip;
}

.words {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 760px;
}

.logo-mark {
  width: clamp(48px, 5vw, 76px);
  height: auto;
  margin-bottom: clamp(14px, 2vw, 24px);
}

.heart { fill: var(--accent); }
.mint { fill: var(--logo-mint); }
.peach { fill: var(--logo-peach); }

.name {
  margin: 0;
  color: var(--heading);
  font-size: clamp(52px, 15vw, 96px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 0.95;
}

.name-line {
  display: block;
  white-space: nowrap;
}

.ch {
  display: inline-block;
  transform-origin: 50% 80%;
}

.un {
  color: var(--accent);
}

.line {
  position: relative;
  margin: clamp(22px, 3vw, 34px) 0 0;
  color: var(--text);
  font-size: clamp(19px, 2.1vw, 30px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.35;
}

.dreams {
  color: var(--accent);
  font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1;
}

.underline {
  position: absolute;
  left: 0;
  bottom: -14px;
  width: min(315px, 88%);
  height: 13px;
  overflow: visible;
}

.underline path,
.scribble path {
  fill: none;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
}

.underline path {
  stroke: var(--logo-peach);
  stroke-width: 4;
}

.soon {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  margin: clamp(34px, 5vw, 64px) 0 0;
  color: var(--muted);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.soon::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-faint);
}

/* ── The illustration (048 FR-013): three depths, finished in place ── */

.stage {
  position: relative;
  align-self: center;
  width: min(100%, 480px);
  aspect-ratio: 1 / 1;
  translate: var(--mx, 0px) var(--my, 0px);
}

.pointer .stage {
  transition: translate 0.3s ease-out;
}

/* Pause freezes the lean where it is (landing.js pins the current value first). */
.motion-paused .stage {
  transition: none;
}

.stage-inner {
  position: absolute;
  inset: 0;
}

.orbit {
  position: absolute;
  border-radius: 50%;
}

.orbit-outer {
  inset: 3%;
  border: 1.5px dashed var(--accent-line);
  transform: rotate(-17deg) scaleY(0.78);
}

.orbit-mid {
  inset: 12%;
  border: 1px solid var(--accent-line);
}

.orbit-inner {
  inset: 21%;
  border: 2px dashed var(--accent-faint);
  transform: rotate(19deg) scaleY(0.82);
}

.orbit-dot {
  position: absolute;
  border-radius: 50%;
}

.dot-a { width: 9px; height: 9px; top: 6%; left: 24%; background: var(--accent); }
.dot-b { width: 8px; height: 8px; top: 10%; left: 15%; background: var(--accent); }
.dot-c { width: 13px; height: 13px; bottom: 13%; right: 14%; background: var(--logo-peach); }

.grid-paper {
  position: absolute;
  top: 6%;
  left: 7%;
  width: 86%;
  height: 86%;
  transform: rotate(-14deg);
  background:
    linear-gradient(90deg, var(--accent-line) 1px, transparent 1px),
    linear-gradient(0deg, var(--accent-line) 1px, transparent 1px);
  background-size: 8.5% 8.5%;
  -webkit-mask-image: radial-gradient(ellipse, #000 35%, transparent 72%);
  mask-image: radial-gradient(ellipse, #000 35%, transparent 72%);
}

.blob {
  position: absolute;
  top: 17%;
  left: 20%;
  width: 62%;
  height: 62%;
  border-radius: 48% 52% 55% 45% / 46% 42% 58% 54%;
  rotate: -6deg;
  background:
    radial-gradient(circle at 27% 29%, #ffffff, transparent 40%),
    radial-gradient(circle at 77% 77%, #9db4f5, transparent 42%),
    linear-gradient(148deg, #dbe5fd, #bccdf9 60%, #d6e1fd);
  box-shadow: inset 12px 18px 50px rgba(255, 255, 255, 0.6), 0 28px 80px rgba(47, 91, 234, 0.14);
  /* Its own layer, drawn once: its arrival otherwise repaints a large gradient each frame (NFR-002). */
  will-change: opacity, translate, scale;
}

.blob-ring {
  position: absolute;
  inset: 27%;
  border: 1px dashed rgba(255, 255, 255, 0.85);
  border-radius: 50%;
}

.blob-centre {
  position: absolute;
  inset: 41%;
  border: 8px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  background: var(--logo-mint);
  box-shadow: 0 0 0 1px var(--accent-line), 0 10px 30px rgba(47, 91, 234, 0.18);
}

.card {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(20, 33, 61, 0.1);
  box-shadow: 0 22px 48px var(--ink-shadow);
  will-change: opacity, translate, scale;
}

.card-ideas {
  z-index: 3;
  top: 16%;
  left: 6%;
  width: 33%;
  height: 22%;
  border-radius: 22px;
  background: var(--surface);
  rotate: -13deg;
}

.card-ideas span {
  color: var(--heading);
  font-size: clamp(18px, 5vw, 38px);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1.02;
  rotate: -6deg;
}

.asterisk {
  position: absolute;
  right: 12%;
  bottom: 8%;
  color: var(--logo-peach);
  font-family: 'Caveat', cursive;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 700;
}

.card-star {
  z-index: 4;
  top: 27%;
  right: 1%;
  width: 26%;
  height: 26%;
  border-radius: 50% 50% 45% 55%;
  background: var(--logo-mint);
  box-shadow: 0 18px 35px var(--ink-shadow);
}

.card-star svg {
  width: 73%;
  height: 73%;
  overflow: visible;
}

.star-shape { fill: var(--accent); }
.star-centre { fill: var(--logo-peach); }

.card-why {
  z-index: 4;
  right: 11%;
  bottom: 12%;
  width: 38%;
  height: 21%;
  border-radius: 20px;
  background: var(--logo-peach);
  rotate: 9deg;
}

.card-why span {
  color: var(--heading);
  font-family: 'Caveat', 'Segoe Print', 'Bradley Hand', cursive;
  font-size: clamp(30px, 8vw, 62px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1;
}

.why-spark {
  position: absolute;
  top: -32%;
  right: -12%;
  width: 24%;
  fill: var(--accent);
}

/* Tilted labels, not buttons: no border, no hover, no pointer (048 FR-014). */
.chip {
  position: absolute;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 11px 15px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 8px 20px rgba(20, 33, 61, 0.06);
  color: var(--heading);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.chip svg {
  width: 12px;
  height: 12px;
}

.chip-curiosity { top: 5%; right: 19%; rotate: 8deg; }
.chip-curiosity svg { fill: var(--accent); }
.chip-imagination { bottom: 5%; left: 8%; rotate: -8deg; }
.chip-imagination svg { fill: none; stroke: var(--accent); stroke-width: 2.5; }

.spark {
  position: absolute;
}

.spark-a { bottom: 28%; left: 0; width: 7%; fill: var(--accent); }
.spark-b { top: 13%; right: 3%; width: 5%; fill: var(--logo-peach); }

.scribble {
  position: absolute;
  z-index: 2;
  bottom: 10%;
  left: 25%;
  width: 22%;
  rotate: 14deg;
  overflow: visible;
}

.scribble path {
  stroke: var(--accent);
  stroke-width: 4.5;
}

/* Wide screens: words left, illustration right. */
@media (min-width: 900px) {
  .page {
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.95fr);
    align-items: center;
    gap: 24px;
    padding: 56px clamp(32px, 6vw, 112px) 96px;
  }

  .name {
    font-size: clamp(64px, 7.2vw, 128px);
  }

  .stage {
    justify-self: center;
    width: min(100%, 680px);
  }

  .card-ideas span { font-size: clamp(18px, 2.4vw, 38px); }
  .card-why span { font-size: clamp(28px, 3.8vw, 62px); }
}

/* Landscape phones: side by side, sized to the height. */
@media (max-height: 500px) and (orientation: landscape) {
  .page {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 20px;
    padding: 16px max(24px, env(safe-area-inset-right)) 16px max(24px, env(safe-area-inset-left));
  }

  .logo-mark { width: 40px; margin-bottom: 10px; }
  .name { font-size: clamp(36px, 11vh, 64px); }
  .line { margin-top: 16px; font-size: 17px; }
  .soon { margin-top: 22px; }
  .stage { width: min(100%, 86vh); width: min(100%, 86svh); }
  .card-ideas span { font-size: 18px; }
  .card-why span { font-size: 28px; }
}

/* ── Motion (048 FR-002–FR-006, FR-012): only while landing.js sets .motion-on ── */

/* The name: every letter is legible from the first frame, just out of line, and springs into place (FR-012). */
.motion-on .ch { animation: settle-a 0.95s cubic-bezier(0.17, 0.89, 0.23, 1.25) both; }
.motion-on .ch:nth-child(3n + 2) { animation-name: settle-b; }
.motion-on .ch:nth-child(3n) { animation-name: settle-c; }

.k0 { animation-delay: 0.2s !important; }
.k1 { animation-delay: 0.25s !important; }
.k2 { animation-delay: 0.3s !important; }
.k3 { animation-delay: 0.35s !important; }
.k4 { animation-delay: 0.4s !important; }
.k5 { animation-delay: 0.45s !important; }
.k6 { animation-delay: 0.5s !important; }
.k7 { animation-delay: 0.55s !important; }
.k8 { animation-delay: 0.6s !important; }
.k9 { animation-delay: 0.65s !important; }
.k10 { animation-delay: 0.7s !important; }
.k11 { animation-delay: 0.75s !important; }
.k12 { animation-delay: 0.8s !important; }

/* Structure first: the grid and the orbits (FR-002); the orbits then turn slowly for good (FR-006). */
.motion-on .grid-paper { animation: fade-in 0.6s ease-out both; }
.motion-on .orbit-outer { animation: orbit-in 0.7s 0.05s ease-out both, spin-back 47s linear infinite; }
.motion-on .orbit-mid { animation: orbit-in 0.7s 0.12s ease-out both, spin 36s linear infinite; }
.motion-on .orbit-inner { animation: orbit-in 0.7s 0.2s ease-out both, spin 22s linear infinite; }

/* Breaking out (FR-003): elements of very different sizes arrive in turn, springy, then drift (FR-006). */
.motion-on .blob { animation: enter 1.3s 0.65s cubic-bezier(0.2, 0.8, 0.2, 1) both, morph 11s 1.95s ease-in-out infinite; }
.lite.motion-on .blob { animation-name: enter, morph-lite; }
.motion-on .blob-ring { animation: spin 20s linear infinite; }
.motion-on .blob-centre { animation: pop 0.9s 1.15s cubic-bezier(0.17, 0.89, 0.23, 1.25) both; }
.motion-on .card-ideas { animation: enter 1.05s 0.8s cubic-bezier(0.17, 0.89, 0.23, 1.2) both, drift 7s 1.85s ease-in-out infinite; }
.motion-on .card-star { animation: enter 1.05s 1s cubic-bezier(0.17, 0.89, 0.23, 1.2) both, drift 8.2s 2.05s ease-in-out infinite; }
.motion-on .card-star svg { animation: spin-back 24s linear infinite; }
.motion-on .card-why { animation: enter 1.05s 1.2s cubic-bezier(0.17, 0.89, 0.23, 1.2) both, drift 8.8s 2.25s ease-in-out infinite; }
.motion-on .why-spark { animation: spin 18s linear infinite; }
.motion-on .chip-curiosity { animation: enter 0.9s 1.3s cubic-bezier(0.17, 0.89, 0.23, 1.2) both, float 5s 2.2s ease-in-out infinite; }
.motion-on .chip-imagination { animation: enter 0.9s 1.5s cubic-bezier(0.17, 0.89, 0.23, 1.2) both, float 5.6s 2.4s ease-in-out infinite; }
.motion-on .spark-a { animation: pop 0.8s 1.6s cubic-bezier(0.17, 0.89, 0.23, 1.25) both, pulse 3s 2.4s ease-in-out infinite; }
.motion-on .spark-b { animation: pop 0.8s 1.75s cubic-bezier(0.17, 0.89, 0.23, 1.25) both, pulse 3.4s 2.55s ease-in-out infinite; }

/* Resolution (FR-004): the strokes draw themselves; about 2.9 s in all (FR-005). */
.motion-on .scribble path { animation: draw 1.2s 1.7s ease-out both; }
.motion-on .underline path { animation: draw 1s 1.9s ease-out both; }
.motion-on .soon::before { animation: breathe 2.8s ease-in-out infinite; }

/* Pause (FR-010) and a hidden tab (FR-011) stop every animation in place; Play resumes from there. */
.motion-paused *,
.motion-paused *::before,
.motion-held *,
.motion-held *::before {
  animation-play-state: paused !important;
}

/* Small enough that neighbours never collide, so the name reads at every moment (FR-012). */
@keyframes settle-a { from { translate: -0.01em 0.07em; rotate: -4deg; } }
@keyframes settle-b { from { translate: 0.01em -0.06em; rotate: 3deg; } }
@keyframes settle-c { from { translate: 0.01em 0.06em; rotate: 4deg; } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes orbit-in { from { opacity: 0; scale: 0.9; } }
@keyframes enter { from { opacity: 0; translate: 0 40px; scale: 0.7; filter: var(--enter-filter); } }
@keyframes pop { from { opacity: 0; scale: 0.25; rotate: -40deg; } }
@keyframes draw { from { stroke-dashoffset: 1; } }
@keyframes spin { from { rotate: 0deg; } to { rotate: 360deg; } }
@keyframes spin-back { from { rotate: 0deg; } to { rotate: -360deg; } }
@keyframes drift { 50% { translate: 0 -17px; } }
@keyframes float { 50% { translate: 0 -10px; } }
@keyframes pulse { 50% { opacity: 0.6; scale: 0.82; } }
@keyframes breathe { 50% { box-shadow: 0 0 0 9px var(--accent-faint); } }

@keyframes morph {
  0%,
  100% { border-radius: 48% 52% 55% 45% / 46% 42% 58% 54%; rotate: -6deg; }
  45% { border-radius: 56% 44% 45% 55% / 52% 56% 44% 48%; rotate: 7deg; }
  75% { border-radius: 44% 56% 59% 41% / 55% 40% 60% 45%; rotate: -2deg; }
}

/* Phones: the same turn without reshaping, which is expensive to draw (FR-008). */
@keyframes morph-lite {
  0%,
  100% { rotate: -6deg; }
  45% { rotate: 7deg; }
  75% { rotate: -2deg; }
}

/* Fallback if the script and the setting ever disagree: no movement, the finished picture (FR-009). */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before {
    animation: none !important;
    transition: none !important;
  }
}

/* ── The bottom edge (spec 049 design §5): Pause on the left; the chat line beside Intercom's launcher, which
   Intercom draws 48px square, 20px from the bottom-right corner (measured 2026-10-21). ── */

.dock {
  position: fixed;
  z-index: 20;
  left: max(1rem, env(safe-area-inset-left));
  right: calc(max(20px, env(safe-area-inset-right)) + 48px + 12px);
  bottom: max(20px, env(safe-area-inset-bottom));
  display: flex;
  align-items: flex-end;
  gap: 12px;
  pointer-events: none;
}

.dock > * {
  pointer-events: auto;
}

.chat-note {
  max-width: 22rem;
  margin: 0 0 0 auto;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
}

/* Narrow screens: Pause above the line, which takes the width up to the launcher (FR-005). */
@media (max-width: 599px) {
  .dock {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .chat-note {
    max-width: none;
    margin: 0;
  }
}

/* Room at the end of the scroll, only while the line shows, so the dock never hides the page (FR-005, FR-008). */
.page:has(.chat-note:not([hidden])) {
  padding-bottom: 116px;
}

@media (max-width: 599px) {
  .page:has(.chat-note:not([hidden])) {
    padding-bottom: 180px;
  }
}

/* ── Pause / Play (047 FR-006, 048 FR-010) ── */

.motion {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  min-width: 44px;
  min-height: 44px;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--heading);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  cursor: pointer;
}

.motion:hover {
  border-color: var(--accent);
}

.motion:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.motion-icon {
  width: 1rem;
  height: 1rem;
  fill: currentColor;
}

.icon-play,
.motion-paused .icon-pause {
  display: none;
}

.motion-paused .icon-play {
  display: inline;
}
