/* base.css — tokens, reset, typography, shell (header/footer).
   The ONLY :root definition in the project (Trent's rule; principles.md #3).
   v0.4: warmer palette, better hierarchy, less corporate. */

:root {
  --bg: #fdfbf7;
  --surface: #ffffff;
  --border: #e8e2d5;
  --text: #1e2433;
  --muted: #6b6f7c;
  --indigo: #2a3a92;
  --sky: #2f9be8;
  --violet: #6a67ac;
  --pink: #d485b5;
  --orange: #f2945a;
  --warm: #c47a4a;
  --teal: #2f9e8f;
  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;

  /* TRA page theme (always dark, independent of site theme) */
  --tra-bg: #10141f;
  --tra-surface: #171e2d;
  --tra-border: #2a3448;
  --tra-text: #e8e6e0;
  --tra-muted: #93a0b4;

  --header-h: 64px;
}

/* ----- dark theme tokens ----- */
:root[data-theme="dark"] {
  --bg: #141720;
  --surface: #1e2130;
  --border: #2d3248;
  --text: #e2dfd8;
  --muted: #8a94a6;
  --warm: #d4946a;
  /* lighter indigo for text highlights — brand indigo is unreadable on dark */
  --indigo-soft: #9db1e8;
}

/* dark mode: indigo text highlights become indigo-soft so they read on dark */
:root[data-theme="dark"] a { color: var(--indigo-soft); }
:root[data-theme="dark"] .shell-footnav a { color: var(--muted); }
:root[data-theme="dark"] .ab-member-role,
:root[data-theme="dark"] .ab-goal h3,
:root[data-theme="dark"] .ab-audience strong,
:root[data-theme="dark"] .ab-split-card.lab .ab-split-badge { color: var(--indigo-soft); }
:root[data-theme="dark"] .intro-ring rect { stroke: var(--indigo-soft); }

/* light mode is the default — dark only when explicitly chosen */

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

html { font-size: 16px; }
body {
  background: var(--bg); color: var(--text);
  font-family: var(--font-body); line-height: 1.65;
}
a { color: var(--indigo); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; }

/* ---------- shell header ---------- */
.shell-header {
  position: fixed; inset: 0 0 auto 0; height: var(--header-h); z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px;
  background: var(--bg); border-bottom: 1px solid transparent;
  transition: border-color 400ms;
}
.shell-header:not(.intro) { border-bottom-color: var(--border); }
.shell-brand {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: var(--text);
  transition: margin 500ms;
}
.shell-header.intro .shell-brand { position: absolute; left: 50%; transform: translateX(-50%); margin: 0; }
.shell-brand img { height: 40px; width: 40px; object-fit: contain; }
.shell-brand .name { font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; }
.shell-brand .name span { color: var(--muted); font-weight: 400; }
.shell-tag { color: var(--muted); font-size: 0.85rem; opacity: 0; transition: opacity 400ms; }
.shell-header:not(.intro) .shell-tag { opacity: 1; }

/* ---------- theme toggle ---------- */
.theme-toggle {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  border: 1px solid var(--border); border-radius: 8px;
  background: transparent; color: var(--muted);
  cursor: pointer;
  transition: border-color 200ms, color 200ms;
  flex-shrink: 0;
}
.theme-toggle:hover { color: var(--text); border-color: var(--muted); }
.theme-icon { display: none; }
:root[data-theme="dark"] .theme-sun,
:root:not([data-theme="dark"]) .theme-moon { display: none; }
:root[data-theme="dark"] .theme-moon { display: block; }
:root:not([data-theme="dark"]) .theme-sun { display: block; }
/* light is the default; the moon only shows when dark is explicit */

/* ---------- shell footer ---------- */
.shell-footer {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 22px 20px; margin-top: 60px;
  border-top: 1px solid var(--border);
  color: var(--muted); font-size: 0.82rem;
}
.shell-footnav {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
  margin-bottom: 4px;
}
.shell-footnav a {
  color: var(--muted); text-decoration: none;
  font-family: var(--font-display); font-size: 0.82rem;
}
.shell-footnav a:hover { color: var(--warm); }
.page-home .shell-footer { display: none; }

/* env badge */
.env-badge {
  position: fixed; left: 14px; bottom: 12px; z-index: 1000;
  background: var(--orange); color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 0.72rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  padding: 5px 12px; border-radius: 999px;
  box-shadow: 0 4px 14px rgba(32, 38, 58, 0.25);
  pointer-events: none;
}

/* ---------- shared page patterns ---------- */

/* section titles — warm accent bar */
.section-head {
  font-family: var(--font-display); font-weight: 700;
  font-size: 1.6rem; margin-bottom: 8px; color: var(--text);
  padding-left: 14px; border-left: 3px solid var(--warm);
}

/* section descriptions */
.section-desc {
  color: var(--muted); font-size: 1rem; max-width: 60ch;
  margin-bottom: 24px; line-height: 1.6;
}

/* generic content pages */
.page-placeholder {
  max-width: 760px; margin: 0 auto;
  padding: calc(var(--header-h) + 60px) 24px 80px;
}
.page-placeholder h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); margin-bottom: 12px; }
.page-placeholder p { color: var(--muted); max-width: 56ch; }

@media (max-width: 768px) {
  .shell-tag { display: none; }
  .shell-footer { flex-direction: column; gap: 4px; text-align: center; }
  html, body { overflow-x: hidden; }
}

/* ---------- portal handoff: body bg animates from portal colour → page bg ---------- */
@keyframes body-from-portal {
  from { background-color: var(--portal-color, var(--bg)); }
  to   { background-color: var(--portal-target, var(--bg)); }
}
body.portal-in {
  animation: body-from-portal 0.7s ease forwards;
}

/* ---------- content fade-in (triggered after cover) ---------- */
/* content starts invisible while cover is up */
main { opacity: 0; }
/* home page has its own intro — always visible */
body.page-home main { opacity: 1; }
@keyframes content-rise {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
body.reveal main {
  animation: content-rise 0.6s ease-out both;
}
/* stagger children */
body.reveal main > * {
  opacity: 0;
  animation: content-rise 0.5s ease-out forwards;
}
body.reveal main > *:nth-child(1) { animation-delay: 0.06s; }
body.reveal main > *:nth-child(2) { animation-delay: 0.13s; }
body.reveal main > *:nth-child(3) { animation-delay: 0.20s; }
body.reveal main > *:nth-child(4) { animation-delay: 0.27s; }
body.reveal main > *:nth-child(5) { animation-delay: 0.34s; }
body.reveal main > *:nth-child(6) { animation-delay: 0.41s; }
/* home page has its own intro — skip */
body.page-home.reveal main,
body.page-home.reveal main > * { animation: none; opacity: 1; }
