/* demo-builder — Catppuccin Mocha Editorial Hard-Line Design System
   Sibling to groundhog and groundhog-agency: shared crust/mantle/base surfaces,
   Space Grotesk + JetBrains Mono (2 fonts), strict 3-level type scale,
   Catppuccin Mauve primary + Groundhog Teal secondary + subtle Peach highlights. */

:root {
  --bg: #11111b;
  --surface: #181825;
  --surface-2: #1e1e2e;
  --text: #cdd6f4;
  --muted: #a6adc8;
  --accent: #cba6f7;        /* Primary: Catppuccin Mauve */
  --teal: #94e2d5;          /* Secondary: Groundhog Teal */
  --peach: #fab387;         /* Subtle editorial highlights */
  --green: #a6e3a1;
  --border: rgba(166, 173, 200, 0.16);
  --hairline-strong: rgba(203, 166, 247, 0.45);
  --surface0: #313244;

  --font-sans: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Strict 3-level type scale (minimum body 15px >= 13px) */
  --fs-display: clamp(2.2rem, 4.3vw, 3.4rem);
  --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;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  color: var(--teal);
  padding: 0.08em 0.36em;
  border-radius: 4px;
  border: 1px solid var(--border);
}

pre code {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.84rem;
}

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

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

/* ── Header ─────────────────────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 30;
  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;
  gap: 1.25rem;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  text-decoration: none;
  color: var(--text);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

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

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  flex-wrap: nowrap;
}

.nav-links a {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  white-space: nowrap;
  transition: color 0.15s ease;
}

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

.nav-cta {
  padding: 0.4rem 0.85rem !important;
  color: var(--text) !important;
}

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.68rem 1.2rem;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.92rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-primary {
  background: var(--accent);
  color: #11111b;
}

.btn-primary:hover {
  background: #d8bcf9;
  color: #11111b;
}

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

.btn-secondary:hover {
  border-color: var(--hairline-strong);
  color: var(--text);
}

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

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--hairline-strong);
}

/* ── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  padding: 7.25rem 0 3.5rem;
  border-bottom: 1px solid var(--border);
  background:
    radial-gradient(ellipse 68% 54% at 78% 14%, rgba(203, 166, 247, 0.11), transparent 70%),
    radial-gradient(ellipse 52% 44% at 14% 26%, rgba(148, 226, 213, 0.07), transparent 70%),
    radial-gradient(ellipse 40% 35% at 52% 0%, rgba(250, 179, 135, 0.05), transparent 72%);
}

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

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

.hero-title {
  margin: 0 0 1.15rem;
  font-size: var(--fs-display);
  line-height: 1.08;
  letter-spacing: -0.03em;
  color: var(--text);
}

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

.hero-sub {
  margin: 0 0 1.55rem;
  color: var(--muted);
  max-width: 60ch;
}

.hero-sub strong {
  color: var(--text);
}

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

/* ── Runtime Switcher & Install Bar ─────────────────────────────────────── */
.runtime-switcher {
  max-width: 660px;
}

.runtime-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}

.runtime-tab {
  padding: 0.36rem 0.72rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.runtime-tab:hover {
  color: var(--text);
  border-color: var(--hairline-strong);
}

.runtime-tab[aria-selected='true'] {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent);
}

.install-bar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  overflow: hidden;
  padding: 0.68rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
}

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

.install-bar code {
  flex: 1 1 auto;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 0.83rem;
  white-space: nowrap;
  overflow-x: auto;
  scrollbar-width: thin;
}

.runtime-hint {
  margin: 0.45rem 0 0;
  font-size: 0.84rem;
  color: var(--muted);
}

.copy-btn {
  flex: 0 0 auto;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
}

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

.copy-btn.copied {
  border-color: var(--green);
  color: var(--green);
}

.hero-media {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.hero-logo {
  width: 100%;
  max-width: 340px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.hero-caption {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
}

.hero-caption code {
  white-space: nowrap;
}

.hero-ledger {
  margin: 3rem 0 0;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1.25rem;
}

.ledger-item dt {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 0.25rem;
}

.ledger-item dd {
  margin: 0;
  color: var(--text);
  font-size: 0.92rem;
}

.ledger-item strong {
  color: var(--teal);
}

/* ── Sections ───────────────────────────────────────────────────────────── */
.section {
  padding: 4.5rem 0;
  border-bottom: 1px solid var(--border);
}

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

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

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

.mono-index {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  color: var(--peach);
}

/* ── Demo Showcase ──────────────────────────────────────────────────────── */
.demo-tabs,
.ref-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.demo-tab {
  padding: 0.55rem 1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.84rem;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

.demo-tab:hover {
  color: var(--text);
  border-color: var(--hairline-strong);
}

.demo-tab[aria-selected='true'] {
  background: var(--surface-2);
  color: var(--accent);
  border-color: var(--accent);
}

.demo-panel {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
}

.demo-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--bg);
  overflow: hidden;
}

.demo-stage video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: var(--bg);
}

.demo-stage:not(.video-ready) video {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  pointer-events: none;
}

.demo-fallback {
  position: absolute;
  inset: 0;
  z-index: 1;
  margin: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  background: var(--bg);
}

.demo-stage.video-ready .demo-fallback {
  display: none;
}

.demo-fallback img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.demo-fallback-bar {
  position: relative;
  z-index: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.35rem;
  background: linear-gradient(180deg, rgba(17, 17, 27, 0.25) 0%, rgba(17, 17, 27, 0.92) 45%);
  border-top: 1px solid var(--border);
}

.demo-fallback-bar p {
  margin: 0.25rem 0 0;
  font-size: 0.86rem;
  color: var(--text);
  max-width: 62ch;
}

.demo-fallback-bar code,
.demo-meta > code {
  overflow-wrap: anywhere;
  max-width: 100%;
}

.demo-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.1rem 1.35rem;
  border-top: 1px solid var(--border);
}

.demo-meta h3 {
  margin: 0 0 0.3rem;
  font-size: 1rem;
}

.demo-meta p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  max-width: 68ch;
}

.storyboard-pre {
  margin: 0;
  padding: 1.25rem 1.35rem;
  overflow-x: auto;
  line-height: 1.6;
  background: var(--surface);
}

/* ── Three Recording Modes ──────────────────────────────────────────────── */
.modes-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1.25rem;
}

.mode-cell {
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

.mode-cell h3 {
  margin: 0.45rem 0 0.65rem;
  font-size: 1.05rem;
}

.mode-cell p {
  margin: 0 0 1.1rem;
  color: var(--muted);
  flex: 1 1 auto;
}

.cell-foot {
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

/* ── 2-Pass Creative Pipeline ───────────────────────────────────────────── */
.pipeline-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.pipeline-step {
  padding: 1.4rem;
  background: var(--surface);
  display: flex;
  flex-direction: column;
}

.pipeline-step h3 {
  margin: 0.45rem 0 0.55rem;
  font-size: 1.02rem;
}

.pipeline-step p {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Reference Tables ───────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

th,
td {
  padding: 0.95rem 1.1rem;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}

thead th {
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
}

tbody th {
  color: var(--accent);
  font-weight: 600;
  white-space: nowrap;
}

tbody td {
  color: var(--muted);
}

tbody td:nth-child(2) code {
  display: inline-block;
  margin-block: 0.12rem;
  white-space: nowrap;
}

tbody tr:last-child th,
tbody tr:last-child td {
  border-bottom: none;
}

/* ── Install Code Blocks ────────────────────────────────────────────────── */
.install-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1.25rem;
}

.code-block {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
  min-width: 0;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.code-block pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  line-height: 1.65;
}

.callout {
  margin-top: 1.35rem;
  padding: 1rem 1.25rem;
  border-left: 3px solid var(--peach);
  border-radius: 0 8px 8px 0;
  background: var(--surface);
  color: var(--muted);
  font-size: 0.9rem;
}

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

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

.site-footer p {
  margin: 0;
}

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

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

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

/* ── Scroll Reveal ──────────────────────────────────────────────────────── */
.reveal {
  transition: opacity 0.4s ease, transform 0.4s ease;
}

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

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

/* ── Reduced Motion ─────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }

  .reveal.reveal-pending {
    opacity: 1;
    transform: none;
  }
}

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

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

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

  .nav-links a:not(.nav-cta):nth-child(-n+5) {
    display: none;
  }
}

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

  .section {
    padding: 3.25rem 0;
  }

  .pipeline-grid,
  .hero-ledger {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 0.65rem;
  }

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

  .demo-stage {
    aspect-ratio: auto;
    min-height: 0;
  }

  .demo-stage.video-ready {
    aspect-ratio: 16 / 9;
  }

  .demo-fallback {
    position: relative;
    min-height: 0;
  }

  .demo-fallback img {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }

  .demo-fallback-bar {
    background: var(--surface-2);
  }
}
