/* Catppuccin Mocha + Groundhog — Editorial Hard-Line Design System
   Font families (2): Space Grotesk + JetBrains Mono
   Type scales (3): --fs-display, --fs-heading, --fs-body (15px >= 13px minimum) */
:root {
  /* Public design tokens shared with demos.css and infographic.css */
  --bg: #11111b;
  --surface: #181825;
  --surface-2: #1e1e2e;
  --text: #cdd6f4;
  --muted: #a6adc8;
  --accent: #94e2d5;
  --peach: #fab387;
  --green: #a6e3a1;
  --border: rgba(166, 173, 200, 0.16);
  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, monospace;

  /* Internal Catppuccin Mocha aliases & hairline accents */
  --crust: var(--bg);
  --mantle: var(--surface);
  --base: var(--surface-2);
  --surface0: #313244;
  --surface1: #45475a;
  --subtext1: #bac2de;
  --subtext0: var(--muted);
  --teal: var(--accent);
  --hairline: var(--border);
  --hairline-strong: rgba(148, 226, 213, 0.42);

  /* Strict 3-level type scale (minimum body 15px >= 13px) */
  --fs-display: clamp(2.35rem, 4.5vw, 3.55rem);
  --fs-heading: clamp(1.35rem, 2.2vw, 1.65rem);
  --fs-body: 0.9375rem;
}

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

html {
  scroll-behavior: smooth;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-body);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

main, header, footer {
  position: relative;
  z-index: 1;
}

.container {
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

code {
  font-family: var(--font-mono);
  font-size: inherit;
  background: var(--surface-2);
  color: var(--accent);
  padding: 0.08em 0.36em;
  border-radius: 4px;
  border: 1px solid var(--border);
  overflow-wrap: anywhere;
  word-break: break-word;
}

a {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Header — borderless at y = 0, crisp surface separation on scroll */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  background: transparent;
  border-bottom: 1px solid transparent;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.site-header.scrolled {
  background: rgba(17, 17, 27, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom-color: var(--border);
}

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: var(--fs-body);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.brand-icon {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--hairline-strong);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.35rem;
}

.nav-links a {
  color: var(--subtext1);
  text-decoration: none;
  font-size: var(--fs-body);
  font-weight: 500;
  white-space: nowrap;
  transition: color 0.15s ease;
}

.nav-links a:hover {
  color: var(--accent);
}

/* Tactile Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.62rem 1.15rem;
  border-radius: 6px;
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: var(--fs-body);
  line-height: 1.2;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--accent);
  color: var(--bg);
}

.btn-primary:hover {
  background: var(--text);
  color: var(--bg);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}

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

.btn-ghost {
  background: transparent;
  color: var(--subtext1);
  border-color: var(--border);
}

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

.copy-btn {
  background: var(--surface0);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.34rem 0.78rem;
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

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

.copy-btn.copied {
  border-color: var(--green);
  color: var(--green);
  background: rgba(166, 227, 161, 0.08);
}

/* Edge-to-edge full-bleed Hero */
.hero {
  background:
    radial-gradient(ellipse 70% 55% at 80% 15%, rgba(148, 226, 213, 0.08), transparent 65%),
    linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
  padding: 6.5rem 0 3.75rem;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(240px, 0.65fr);
  gap: 3rem;
  align-items: center;
}

.hero-copy,
.hero-media {
  min-width: 0;
}

.hero-title {
  font-size: var(--fs-display);
  font-weight: 700;
  line-height: 1.07;
  letter-spacing: -0.03em;
  margin: 0 0 1.25rem;
}

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

.hero-sub {
  max-width: 62ch;
  margin: 0 0 1.85rem;
  color: var(--subtext1);
  font-size: var(--fs-body);
}

.hero-cta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.install-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  min-width: 0;
  max-width: 100%;
}

.install-bar code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  flex: 1;
  min-width: 0;
}

.prompt-chevron {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
}

.hero-media {
  margin: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  overflow: hidden;
}

.hero-logo {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
}

.hero-caption {
  padding: 0.75rem 0.9rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-body);
  font-family: var(--font-mono);
}

/* Hairline Ledger Strip (replaces decorative pill badges) */
.hero-ledger {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin: 3rem 0 0;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.ledger-item {
  background: var(--surface);
  padding: 0.95rem 1.15rem;
  min-width: 0;
}

.ledger-item dt {
  font-family: var(--font-mono);
  color: var(--muted);
  margin: 0 0 0.2rem;
}

.ledger-item dd {
  margin: 0;
  color: var(--subtext1);
}

.ledger-item dd strong {
  color: var(--accent);
  font-weight: 700;
}

/* Sections & Scroll Reveals */
.section {
  padding: 4.5rem 1.5rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 72px;
}

.reveal {
  opacity: 1;
  transform: none;
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.reveal.reveal-pending {
  opacity: 0;
  transform: translateY(14px);
}

.reveal.reveal-visible {
  opacity: 1;
  transform: translateY(0);
}

.section-head {
  max-width: 68ch;
  margin-bottom: 2.25rem;
}

.section-head h2 {
  font-size: var(--fs-heading);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin: 0 0 0.6rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.mono-index {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--peach);
  display: inline-block;
  margin-bottom: 0.25rem;
}

/* Layer Explorer */
.layers-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.layer-tabs {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.layer-tab {
  display: grid;
  grid-template-columns: 38px 1fr;
  gap: 0.65rem;
  align-items: start;
  text-align: left;
  padding: 1.35rem 1.4rem;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  transition: background-color 0.15s ease;
}

.layer-tab:last-child {
  border-bottom: none;
}

.layer-tab:hover {
  background: var(--surface-2);
}

.layer-tab.active {
  background: var(--surface-2);
  box-shadow: inset 3px 0 0 var(--accent);
}

.layer-sub {
  display: block;
  margin-top: 0.3rem;
  color: var(--muted);
  font-weight: 400;
}

.layer-inspector {
  background: var(--bg);
  padding: 1.5rem 1.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  min-width: 0;
}

.layer-inspector h3 {
  margin: 0;
  font-size: var(--fs-heading);
  line-height: 1.25;
}

.layer-desc {
  margin: 0;
  color: var(--subtext1);
}

.tree-block {
  margin: 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.layer-note {
  margin: 0;
  color: var(--accent);
  font-family: var(--font-mono);
}

/* Interactive Config Builder */
.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.builder-toggles {
  background: var(--surface);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.95rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.15s ease, opacity 0.15s ease;
}

.toggle-row:last-child {
  border-bottom: none;
}

.toggle-row:hover {
  background: var(--surface-2);
}

.toggle-subrow {
  padding-left: 2.1rem;
  background: rgba(17, 17, 27, 0.35);
}

.toggle-subrow.is-disabled {
  opacity: 0.52;
}

.toggle-row > span:first-child {
  min-width: 0;
  flex: 1;
}

.toggle-row strong {
  display: block;
  color: var(--text);
}

.toggle-desc {
  display: block;
  color: var(--muted);
  margin-top: 0.15rem;
}

.flag-toggle {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: var(--surface0);
  border: 1px solid var(--border);
  flex-shrink: 0;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text);
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.flag-toggle:checked + .switch {
  background: var(--accent);
  border-color: var(--accent);
}

.flag-toggle:checked + .switch::after {
  transform: translateX(20px);
  background: var(--bg);
}

.flag-toggle:focus-visible + .switch {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.builder-preview {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.15rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-weight: 600;
}

.builder-preview pre {
  margin: 0;
  padding: 1.15rem;
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  flex: 1;
}

.builder-preview pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
}

.preview-footer {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  padding: 0.85rem 1.15rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
}

/* Defence Matrix — Hairline Ruled Grid */
.matrix-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.matrix-cell {
  background: var(--surface);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  transition: background-color 0.15s ease;
}

.matrix-cell:hover {
  background: var(--surface-2);
}

.matrix-cell h3 {
  margin: 0;
  font-size: var(--fs-body);
  font-weight: 700;
  color: var(--text);
}

.matrix-cell p {
  margin: 0;
  color: var(--muted);
}

/* Bottom CTA Band */
.cta-band {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 3.5rem 0;
}

.cta-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
}

.cta-inner h2 {
  margin: 0 0 0.45rem;
  font-size: var(--fs-heading);
}

.cta-inner p {
  margin: 0;
  color: var(--subtext1);
}

.cta-inner .hero-cta {
  margin: 0;
}

/* Footer */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 2rem 1.5rem;
  color: var(--muted);
}

.site-footer p {
  margin: 0;
}

.footer-links {
  display: flex;
  gap: 1.2rem;
  flex-wrap: wrap;
}

.footer-links a {
  color: var(--subtext1);
  text-decoration: none;
}

.footer-links a:hover {
  color: var(--accent);
}

/* Responsive */
@media (max-width: 960px) {
  .hero-grid,
  .layers-grid,
  .builder-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .hero-ledger {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-media {
    max-width: 320px;
  }

  .matrix-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .nav-links a:not(.nav-cta) {
    display: none;
  }
}

@media (max-width: 640px) {
  .hero {
    padding: 5.5rem 0 3rem;
  }

  .hero-ledger {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 2rem;
  }

  .section {
    padding: 3rem 1.15rem;
  }

  .container {
    padding: 0 1.15rem;
  }

  .matrix-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .toggle-subrow {
    padding-left: 1.25rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .reveal,
  .btn {
    transition: none;
    transform: none;
  }
}

/* ── Narrated Video Showcase ────────────────────────────────────────────── */
.video-showcase {
  margin: 0 0 2.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.video-showcase video {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  background: var(--bg);
}

.video-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.875rem;
  color: var(--muted);
}

.video-caption strong {
  color: var(--text);
}

/* ── Sibling Companion Band (groundhog-agency) ──────────────────────────── */
.companion-band {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 2.5rem;
  align-items: center;
  padding: 2.25rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(250, 179, 135, 0.06), rgba(148, 226, 213, 0.04)), var(--surface);
}

.companion-copy h2 {
  margin: 0.45rem 0 0.85rem;
  font-size: var(--fs-heading);
  line-height: 1.2;
}

.companion-copy p {
  margin: 0 0 0.85rem;
  color: var(--muted);
}

.companion-note {
  font-size: 0.9rem;
}

.companion-points {
  display: flex;
  flex-direction: column;
  gap: 1.1rem;
  border-left: 1px solid var(--border);
  padding-left: 1.75rem;
}

.companion-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.companion-row strong {
  display: block;
  color: var(--text);
  margin-bottom: 0.2rem;
}

.companion-row p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

@media (max-width: 860px) {
  .companion-band {
    grid-template-columns: 1fr;
    padding: 1.5rem;
  }

  .companion-points {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 1.25rem;
  }
}
