/* ── Reset & custom properties ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* ── Warm theme (legacy — Brain, FAQ sections only) ─────────── */
  --warm-bg: #fdf6ec;
  --warm-accent: #e8875a;
  --warm-text: #2d2d2d;
  --warm-muted: #8a7060;

  /* ── Dark theme — primary palette ───────────────────────────── */
  --dark-bg:            #1a181c;
  --dark-surface:       #24212a;
  --dark-surface-raised:#2d2a36;
  --dark-border:        #3d3844;
  --dark-border-subtle: rgba(255, 255, 255, 0.04);
  --dark-bg-glow-overlay: rgba(26, 24, 28, 0.04);
  --dark-text:          #e2ddd8;
  --dark-muted:         #968e96;
  --dark-code-bg:       #24212a;

  /* ── Copper accent ──────────────────────────────────────────── */
  --dark-accent:        #c48b6e;
  --dark-accent-hover:  #d49e82;
  --dark-accent-muted:  #9a6d52;
  --dark-glow:          rgba(196, 139, 110, 0.08);

  /* ── Supporting accents ─────────────────────────────────────── */
  --slate:              #6e8ec4;
  --slate-muted:        #4d6a9a;
  --sage:               #8eaa7e;
  --sage-muted:         #6a8060;

  /* ── Dynamic mood accent ────────────────────────────────────── */
  --spark-accent:       var(--dark-accent);
  --spark-glow:         var(--dark-glow);
  --chat-bubble-color:  var(--dark-accent);

  /* ── Type scale (custom editorial) ──────────────────────────── */
  --text-display:   clamp(2.5rem, 6vw, 3.5rem);
  --text-title:     1.75rem;
  --text-subtitle:  1.25rem;
  --text-body:      1rem;
  --text-small:     0.875rem;
  --text-xs:        0.75rem;

  /* ── Layout ─────────────────────────────────────────────────── */
  --nav-height:   56px;
  --radius-sm:     8px;
  --radius:       12px;
  --radius-lg:    20px;
  --transition:   0.2s ease;
}

html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 300;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
  background: var(--dark-bg);
  color: var(--dark-text);
}

/* ── Nav ── */
#main-nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--nav-height);
  background: var(--dark-bg);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1.5rem;
  z-index: 100;
  border-bottom: 1px solid var(--dark-border);
}

#main-nav .logo {
  font-family: 'Courier Prime', 'Courier New', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--dark-text);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  display: inline-block;
  background: #ef4444; /* red — initial state */
  transition: background var(--transition);
}
#status-dot.green { background: var(--dark-accent, #c48b6e); }
#status-dot.amber { background: #f59e0b; }
#status-dot.red   { background: #ef4444; }

#main-nav .links {
  display: flex;
  gap: 1rem;
  margin-left: auto;
  list-style: none;
}

#main-nav .links a {
  color: var(--dark-muted);
  text-decoration: none;
  font-size: var(--text-small);
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--transition);
}
#main-nav .links a:hover,
#main-nav .links a.active { color: var(--dark-text); }

#main-nav .nav-github { opacity: 0.6; }
#main-nav .nav-github:hover { opacity: 1; color: var(--dark-text); }

/* ── Hamburger button (hidden on desktop) ── */
.nav-burger {
  display: none;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  margin-left: auto;
}
.nav-burger span {
  display: block;
  height: 2px;
  width: 100%;
  background: var(--dark-muted);
  border-radius: 2px;
  transition: background var(--transition);
}
.nav-burger:hover span { background: var(--dark-text); }

/* ── Mobile nav ── */
@media (max-width: 700px) {
  .nav-burger { display: flex; }

  #main-nav .links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--dark-bg);
    flex-direction: column;
    gap: 0;
    margin: 0;
    padding: 0.5rem 0 1rem;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    z-index: 99;
  }
  #main-nav .links li a {
    display: block;
    padding: 0.65rem 1.5rem;
    font-size: 1rem;
  }
  #main-nav.nav-open .links {
    display: flex;
  }
  #main-nav.nav-open .nav-burger span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
  #main-nav.nav-open .nav-burger span:nth-child(2) { opacity: 0; }
  #main-nav.nav-open .nav-burger span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }
  .nav-burger span { transition: transform 0.2s ease, opacity 0.2s ease, background var(--transition); }
}

/* Mobile nav backdrop */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 90;
}
#main-nav.nav-open ~ .nav-backdrop { display: block; }

/* ── Sections ── */
section {
  padding: 4rem 2rem;
  overflow-x: hidden;
}
section:first-of-type { padding-top: calc(var(--nav-height) + 5rem); }
@media (max-width: 600px) {
  section { padding: 2.5rem 1rem; }
}
@media (max-width: 480px) {
  section { padding: 2.5rem 0.75rem; }
}

/* ── Accessibility ── */
/* Default: copper (dark bg). Warm sections override with warm-accent to ensure
   sufficient contrast on light backgrounds — some mood colors (#8a8a8a bored)
   fail WCAG 1.4.11 Non-text Contrast 3:1 minimum against white cards. */
:focus-visible { outline: 2px solid var(--spark-accent); outline-offset: 2px; }
[data-theme="warm"] :focus-visible { outline-color: var(--dark-accent-muted); } /* #9a6d52 — ~4.3:1 on cream, passes WCAG 1.4.11 */

/* ── Utility ── */

/* ── Containers ── */
.container-hero { max-width: 1100px; margin: 0 auto; padding: 0 1.25rem; }
.container      { max-width: 900px;  margin: 0 auto; padding: 0 1.25rem; overflow-x: hidden; }
.container-narrow { max-width: 680px; margin: 0 auto; padding: 0 1.25rem; }
.null-value::after { content: "—"; opacity: 0.4; }
.hidden { display: none; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Spacing helpers */
.mt-sm  { margin-top: 0.75rem; }
.mt-md  { margin-top: 1.5rem; }
.mt-lg  { margin-top: 3rem; }
.mb-md  { margin-bottom: 1.5rem; }
.mb-lg  { margin-bottom: 2.5rem; }

/* Text helpers */
.text-muted-warm { color: var(--warm-muted); }
.text-muted-dark { color: var(--dark-muted); }
.text-small      { font-size: 0.875rem; }
.text-xs         { font-size: 0.8rem; }
.text-italic     { font-style: italic; }
.text-right      { text-align: right; }
.text-mono       { font-family: monospace; }
.opacity-40      { opacity: 0.4; }
.text-lead       { font-size: 1.2rem; }

/* Flex helpers */
.flex            { display: flex; }
.flex-gap        { display: flex; gap: 1rem; }
.align-center    { align-items: center; }
.justify-between { justify-content: space-between; }

/* Voice samples */
.voice-samples { display: flex; flex-wrap: wrap; gap: 1.25rem; margin: 1rem 0 1.5rem; }
.voice-sample  { flex: 1 1 200px; min-width: 200px; }
.voice-sample audio { width: 100%; margin-top: 0.35rem; }

/* Live card inner layout */
.live-meta { display: flex; gap: 1rem; margin-top: 0.75rem; font-size: 0.8rem; opacity: 0.5; }
.live-label { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.5; margin-bottom: 0.5rem; }

/* Section transition — gradient divider between warm and dark */
.section-divider {
  height: 2px;
  background: linear-gradient(to right, transparent 5%, var(--dark-accent-muted, #9a6d52) 50%, transparent 95%);
  opacity: 0.6;
  margin: 0;
  position: relative;
}
.section-divider::after {
  content: '';
  position: absolute;
  top: -20px;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(to bottom, transparent, var(--dark-bg-glow-overlay));
  pointer-events: none;
}

/* ── Scroll entrance animations ── */
@media (prefers-reduced-motion: no-preference) {
  .animate-ready {
    opacity: 0;
    transform: translateY(16px);
  }
  .animate-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s cubic-bezier(0.25, 0.1, 0.25, 1),
                transform 0.4s cubic-bezier(0.25, 0.1, 0.25, 1);
  }
}

/* Accessibility: respect reduced-motion preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
