/*
 * NEO homepage: one screen, in the first-run guide's flat red/bone print style
 * (apps/web/src/styles.css, "first-run print stage"). No external requests.
 */
:root {
  --charcoal: #1C1C1C;
  --deep: #141414;
  --red: #E5504A;
  --bone: #E9E4D0;
  --muted: #B5B4AE;
  --hairline: #62625E;
  --portrait-bg: #CDE9FD;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', sans-serif;
  --mono: ui-monospace, 'SF Mono', 'JetBrains Mono', 'Cascadia Code', Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  overflow: hidden;
  background: var(--charcoal);
  color: var(--bone);
  font: 400 1rem/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
:is(a, button):focus-visible { outline: 2px solid var(--bone); outline-offset: 3px; }

.home {
  position: relative;
  isolation: isolate;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  --window-right: max(3.5rem, env(safe-area-inset-right, 0px));
  --window-bottom: max(2rem, env(safe-area-inset-bottom, 0px));
  --figure-bottom: max(1.5rem, 2dvh);
  --figure-height: min(94dvh, calc(100dvh - max(2.5rem, 3dvh) - var(--figure-bottom)));
  /* Half the painted width of each figure, in the 984px-tall frame of its art. */
  --art-half: 225;
  --figure-center: max(32vw, calc(var(--figure-height) * var(--art-half) / 984 + 0.75rem));
  --card-width: clamp(20rem, 30vw, 27rem);
}
.home[data-kind='boy'] { --art-half: 171; }
.home[data-kind='girl'] { --art-half: 158; }
.home[data-kind='cat'] { --art-half: 295; }
.home[data-kind='dog'] { --art-half: 307; }

/* ── Stage ─────────────────────────────────────────────────────────────── */
.stage, .backdrop, .orbit { position: absolute; inset: 0; pointer-events: none; }
.backdrop { overflow: hidden; }
.hazard { position: absolute; left: 1.5%; top: 37%; width: 1.25rem; height: 7rem; background: repeating-linear-gradient(135deg, var(--red) 0 5px, transparent 5px 10px); }
.tabs { position: absolute; height: 1.3rem; }
.tabs > span { position: absolute; width: calc(100% - 8px); height: 0.5rem; background: var(--red); }
.tabs > span:nth-child(1) { top: 0; left: 0; }
.tabs > span:nth-child(2) { top: 4px; left: 4px; }
.tabs > span:nth-child(3) { top: 8px; left: 8px; }
.stage-tabs { top: 14%; left: 6%; width: 12%; }

/* The SVG viewBox hugs the glyphs, so 50% centres cap height, not font leading. */
.wordmark {
  position: absolute;
  top: 50%;
  left: 1%;
  z-index: 1;
  width: 98%;
  height: clamp(5rem, min(56vw, 94dvh), 80rem);
  translate: 0 -50%;
  font-family: Impact, Haettenschweiler, 'Arial Narrow Bold', 'Arial Narrow', 'Roboto Condensed', sans-serif;
  font-weight: 900;
}
.wordmark svg { display: block; width: 100%; height: 100%; overflow: visible; }
.wordmark :is(text, use) { fill: none; stroke: var(--bone); stroke-width: 1.5px; vector-effect: non-scaling-stroke; }
.wordmark .wordmark-registration { stroke: var(--red); opacity: 0; }
.home[data-motion='on'] .wordmark-registration { animation: misregistration 8s steps(1, end) infinite; }

.figure-frame {
  position: absolute;
  left: var(--figure-center);
  bottom: var(--figure-bottom);
  z-index: 2;
  width: calc(var(--figure-height) * 32 / 41);
  height: var(--figure-height);
  translate: -50% 0;
  pointer-events: auto;
}
.figure { position: relative; display: block; width: 100%; height: 100%; }
.figure > img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: center; user-select: none; -webkit-user-drag: none; }
.figure > .figure-ink { opacity: 0; pointer-events: none; }
.figure[data-glitch] { animation: figure-shake 480ms steps(1, end); }
.figure[data-glitch] > .figure-ink { animation: figure-slices 480ms steps(1, end); }
.figure[data-glitch]::after {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  background: var(--red);
  -webkit-mask: var(--ink) center / cover no-repeat;
  mask: var(--ink) center / cover no-repeat;
  animation: figure-register 480ms steps(1, end);
}

/* ── Avatar orbit: portraits revolve around the figure on a dashed ellipse ─ */
.orbit { --portrait-size: 60px; --portrait-target: 64px; color: var(--bone); }
.orbit-area { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: auto; }
.orbit-path { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; fill: none; color: var(--bone); }
.orbit-path path { stroke: currentColor; stroke-width: 1; stroke-dasharray: 4 7; vector-effect: non-scaling-stroke; }
.orbit-path--back { z-index: 1; opacity: .6; }
.orbit-path--front { z-index: 3; }
.orbit-node {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--portrait-target);
  height: var(--portrait-target);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--bone);
  cursor: pointer;
  pointer-events: auto;
  will-change: transform, opacity;
}
.orbit-node:focus-visible { outline: 2px solid var(--bone); outline-offset: 4px; }
.orbit-visual { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; pointer-events: none; }
.orbit-visual img { position: relative; z-index: 1; width: var(--portrait-size); height: var(--portrait-size); border: 1.5px solid var(--red); border-radius: 50%; background: var(--portrait-bg); object-fit: cover; }
.orbit-node[aria-checked='true'] .orbit-visual img { border-width: 3px; }
.orbit-node[aria-checked='true'] > .orbit-visual::before { content: ''; position: absolute; right: 0; bottom: 0; width: 40%; height: 40%; background: var(--red); }
.home[data-motion='on'] .orbit-visual { animation: badge-in 240ms var(--ease) both; animation-delay: var(--stagger, 0ms); }

/* ── HUD and navigation ────────────────────────────────────────────────── */
.hud { position: absolute; z-index: 3; inset: max(1rem, env(safe-area-inset-top, 0px)) 1rem max(1rem, env(safe-area-inset-bottom, 0px)); pointer-events: none; font-family: var(--mono); line-height: 1; text-transform: uppercase; }
.hud-corner { position: absolute; width: 1rem; height: 1rem; border-color: var(--hairline); border-style: solid; }
.hud-corner--tl { top: 0; left: 0; border-width: 1px 0 0 1px; }
.hud-corner--tr { top: 0; right: 0; border-width: 1px 1px 0 0; }
.hud-corner--bl { bottom: 0; left: 0; border-width: 0 0 1px 1px; }
.hud-corner--br { bottom: 0; right: 0; border-width: 0 1px 1px 0; }
.hud-brand, .hud-status, .hud-avatar { position: absolute; left: 2.5rem; letter-spacing: 0.12em; }
.hud-brand { top: 0; color: var(--bone); font-size: 0.75rem; }
.hud-status { top: 0.875rem; color: var(--muted); font-size: 0.625rem; }
.hud-avatar { bottom: 0; color: var(--red); font-size: 0.625rem; }

.topnav { position: absolute; z-index: 5; top: max(1rem, env(safe-area-inset-top, 0px)); right: 3.5rem; display: flex; align-items: center; gap: 1.5rem; translate: 0 -0.375rem; font: 0.75rem/1 var(--mono); letter-spacing: 0.12em; text-transform: uppercase; }
.topnav a { padding: 0.375rem 0; color: var(--bone); text-decoration: none; }
.topnav a:hover { color: var(--red); }
.lang { min-height: 1.75rem; padding: 0.25rem 0.625rem; border: 1px solid var(--hairline); border-radius: 3px; background: transparent; color: var(--bone); font: inherit; letter-spacing: 0.08em; cursor: pointer; }
.lang:hover { border-color: var(--bone); }

/* ── The poster card ───────────────────────────────────────────────────── */
.card {
  position: absolute;
  right: var(--window-right);
  bottom: var(--window-bottom);
  z-index: 4;
  display: flex;
  flex-direction: column;
  width: var(--card-width);
  max-height: calc(100dvh - 6.5rem - var(--window-bottom));
  min-height: 0;
  border: 1px solid var(--bone);
  border-radius: 3px;
  background: var(--charcoal);
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 1.25rem 1.75rem 0.75rem; }
.card-label { color: var(--bone); font: 600 0.75rem/1.2 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; }
.card-count { color: var(--muted); font: 0.6875rem/1 var(--mono); font-variant-numeric: tabular-nums; }
.terminal { flex: 0 0 auto; margin: 0 1.75rem; padding: 0.75rem 0; border-top: 1px solid var(--hairline); color: var(--red); font: 0.8125rem/1.4 var(--mono); letter-spacing: 0.04em; }
.terminal-cursor { display: inline-block; width: 0.6em; height: 1em; margin-left: 0.2em; vertical-align: -0.15em; background: var(--bone); color: transparent; }
.home[data-motion='on'] .terminal-cursor { animation: cursor-blink 1s steps(1, end) infinite; }
.card-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 0.75rem 1.75rem 1.25rem; }
.card h1 { margin: 0; color: var(--bone); font-size: clamp(1.5rem, 2.1vw, 2rem); font-weight: 700; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
.pillars { display: grid; gap: 0.875rem; margin: 1.25rem 0 0; padding: 0; list-style: none; }
.pillars li { display: grid; grid-template-columns: 2rem minmax(0, 1fr); padding-top: 0.875rem; border-top: 1px solid var(--hairline); }
.pillar-index { grid-row: span 2; padding-top: 0.2rem; color: var(--red); font: 0.75rem/1 var(--mono); letter-spacing: 0.08em; }
.pillars h2 { margin: 0; color: var(--bone); font-size: 0.9375rem; font-weight: 600; line-height: 1.3; }
.pillars p { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.8125rem; line-height: 1.5; }
.card-footer { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 1rem 1.75rem; border-top: 1px solid var(--hairline); background: var(--deep); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.625rem; min-height: 2.75rem; padding: 0.5rem 1.125rem; border: 1px solid transparent; border-radius: 3px; font: 700 0.8125rem/1.2 var(--mono); letter-spacing: 0.04em; text-decoration: none; }
.btn--primary { flex: 1 1 auto; border-color: var(--red); background: var(--red); color: var(--charcoal); }
.btn--primary::after { content: '>>'; flex-shrink: 0; }
.btn--secondary { border-color: var(--bone); background: transparent; color: var(--bone); font-weight: 500; }
.btn:hover { border-color: var(--bone); background: var(--bone); color: var(--charcoal); }

/* ── Phones and narrow windows: the stage on top, the card as a sheet ─── */
@media (max-width: 899px) {
  .home { display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .stage { position: relative; grid-area: 1 / 1; inset: auto; min-height: 0; overflow: hidden; }
  .hud { inset-inline: 0.75rem; }
  .hud-brand, .hud-status, .hud-avatar { left: 1.5rem; }
  .hud-brand { font-size: 0.625rem; }
  .hud-status { top: 1.1rem; font-size: 0.5rem; }
  .hud-avatar { display: none; }
  .topnav { right: 2.25rem; gap: 1rem; font-size: 0.625rem; }
  .wordmark { height: clamp(4rem, min(50vw, 40dvh), 28rem); max-height: 96%; }
  .figure-frame { left: 50%; bottom: 0.5rem; width: auto; max-width: calc(100% - 1rem); height: calc(100% - max(3.5rem, env(safe-area-inset-top, 0px)) - 0.5rem); aspect-ratio: 32 / 41; }
  .orbit { --portrait-size: 44px; --portrait-target: 56px; }
  .hazard { top: 55%; width: 0.75rem; height: 4rem; }
  .stage-tabs { display: none; }
  .card {
    position: relative;
    grid-area: 2 / 1;
    inset: auto;
    width: auto;
    max-height: calc(64dvh - max(1rem, env(safe-area-inset-bottom, 0px)));
    margin: 0 max(1rem, env(safe-area-inset-right, 0px)) max(1rem, env(safe-area-inset-bottom, 0px)) max(1rem, env(safe-area-inset-left, 0px));
  }
  .card-top { padding: 1rem 1rem 0.5rem; }
  .terminal { margin-inline: 1rem; padding-block: 0.5rem; }
  .card-body { padding: 0.5rem 1rem 0.875rem; }
  .card h1 { font-size: 1.375rem; }
  .pillars { gap: 0.5rem; margin-top: 0.875rem; }
  .pillars li { padding-top: 0.5rem; }
  .card-footer { padding: 0.75rem 1rem; }
}
@media (max-width: 479px) {
  .hud-brand-long { display: none; }
}
/* Short phones keep the three promises as headlines. */
@media (max-width: 899px) and (max-height: 859px) {
  .pillars p { display: none; }
  .pillar-index { grid-row: auto; padding-top: 0.15rem; }
}
/* Landscape phones give the avatar controls the full stage height. */
@media (min-width: 560px) and (max-width: 899px) and (max-height: 500px) and (orientation: landscape) {
  .home { grid-template-columns: minmax(0, 1fr) minmax(20rem, 1fr); grid-template-rows: minmax(0, 1fr); }
  .card { grid-area: 1 / 2; max-height: calc(100dvh - 5rem); margin-top: max(4rem, env(safe-area-inset-top, 0px)); }
}
@media (max-height: 740px) and (min-width: 900px) {
  .card-top { padding-top: 0.875rem; padding-bottom: 0.5rem; }
  .terminal { padding-block: 0.5rem; }
  .card-body { padding-top: 0.5rem; padding-bottom: 0.875rem; }
  .card h1 { font-size: clamp(1.375rem, 1.9vw, 1.75rem); }
  .pillars { gap: 0.5rem; margin-top: 0.75rem; }
  .pillars li { padding-top: 0.5rem; }
  .card-footer { padding-block: 0.75rem; }
}

/* ── Motion ────────────────────────────────────────────────────────────── */
.home[data-motion='off'] *, .home[data-motion='off'] *::before, .home[data-motion='off'] *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) {
  .home *, .home *::before, .home *::after { animation: none !important; transition: none !important; }
  .orbit-node { will-change: auto; }
}
@keyframes misregistration {
  0%, 96%, 96.21%, 100% { opacity: 0; transform: none; }
  96.01% { opacity: 1; transform: translate(3px, 2px); }
}
@keyframes cursor-blink { 0%, 50% { opacity: 1; } 50.01%, 100% { opacity: 0; } }
@keyframes badge-in { from { opacity: 0; scale: .75; } to { opacity: 1; scale: 1; } }
@keyframes figure-shake {
  0%, 92%, 100% { transform: none; }
  8%, 42% { transform: translate(-3px, 1px); }
  18%, 66% { transform: translate(3px, -2px); }
  30%, 78% { transform: translate(-2px, -1px); }
  54%, 86% { transform: translate(2px, 2px); }
}
@keyframes figure-slices {
  0%, 92%, 100% { opacity: 0; transform: none; clip-path: inset(0); }
  8%, 54% { opacity: 1; transform: translateX(3px); clip-path: polygon(0 12%, 100% 12%, 100% 22%, 0 22%, 0 44%, 100% 44%, 100% 54%, 0 54%, 0 74%, 100% 74%, 100% 83%, 0 83%); }
  18%, 78% { opacity: 1; transform: translateX(-4px); clip-path: polygon(0 6%, 100% 6%, 100% 14%, 0 14%, 0 32%, 100% 32%, 100% 42%, 0 42%, 0 60%, 100% 60%, 100% 67%, 0 67%, 0 88%, 100% 88%, 100% 94%, 0 94%); }
  30%, 86% { opacity: 1; transform: translateX(2px); clip-path: polygon(0 24%, 100% 24%, 100% 36%, 0 36%, 0 64%, 100% 64%, 100% 76%, 0 76%); }
  42%, 66% { opacity: 1; transform: none; clip-path: inset(0); }
}
@keyframes figure-register {
  0%, 18%, 42%, 66%, 86%, 100% { opacity: 0; transform: none; }
  8%, 54% { opacity: .7; transform: translate(3px, 2px); }
  30%, 78% { opacity: .6; transform: translate(-3px, -2px); }
}
