/*
  frontend/css/main.css
  ------------------------
  Global stylesheet: design tokens, reset, typography, layout primitives,
  nav/footer, buttons, and every landing-page (index.html) component.
  Loaded on every page. Page-specific styles (the pricing comparison
  table, the app dashboard) live in pricing.css / dashboard.css instead.

  Design language, in short: this is a compiler product for developers —
  the visual voice is precise and engineered, not soft consumer SaaS.
  Sharp-ish corners over pills, hairline rules over drop shadows, a dark
  "terminal" panel as the one bold gesture, red reserved for the brand
  mark and calls to action.

  *** Fix log: nav breaking once the user is signed in ***
    .user-email / .auth-user sit inside a flex row (.nav-actions ->
    .auth-slot -> .auth-user -> .user-email). A flex item's default
    min-width is `auto` (sized to its content), which silently overrides
    `overflow: hidden` + `text-overflow: ellipsis` on .user-email — so the
    moment a real (often long) email renders post-login, that item refuses
    to shrink and pushes nav-links / the sign-out button out of the row
    instead of truncating, which is what "breaks" visually. `min-width: 0`
    is added down the whole chain below. .site-nav .container also moves
    from a fixed `height` to `min-height` + `flex-wrap` as a second safety
    net, so if the signed-in content is ever still wider than the row, it
    wraps onto a second line instead of clipping/overflowing.
*/

/* =====================================================
   Fonts
   ===================================================== */

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@500;600;700&family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* =====================================================
   Design Tokens
   ===================================================== */

:root {
  /* Theme: dark is the default (see [data-theme="light"] override below).
     Only these four surfaces change between themes; every other rule in
     this file reads through the legacy --color-ink / --color-paper /
     --color-slate / --color-line names, so it repaints automatically. */
  --color-bg: #0b0d0e;
  --color-bg-elevated: #14171a;
  --color-text: #f2f1ee;
  --color-text-muted: #9aa1a8;
  --color-hairline: #262a2e;
  color-scheme: dark;

  /* Color */
  --color-ink: var(--color-text);
  --color-paper: var(--color-bg);
  --color-brand: #e8392c;
  --color-brand-dark: #b7281d;
  --color-brand-tint: rgba(232, 57, 44, 0.14);
  --color-slate: var(--color-text-muted);
  --color-line: var(--color-hairline);
  --color-code-bg: #0b0d0e;
  --color-code-text: #f2f1ee;
  --color-code-muted: #8b9198;
  --color-code-accent: #7ce3b0;
  --color-surface: var(--color-bg-elevated);

  /* Elevation (dark mode leans on hairlines, not shadows) */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);

  /* Type */
  --font-display: "Space Grotesk", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;

  --text-xs: 0.8125rem; /* 13px */
  --text-sm: 0.9375rem; /* 15px */
  --text-base: 1.0625rem; /* 17px */
  --text-lg: 1.25rem; /* 20px */
  --text-xl: 1.75rem; /* 28px */
  --text-2xl: 2.5rem; /* 40px */
  --text-3xl: 3.375rem; /* 54px */

  /* Spacing scale (8px base) */
  --space-1: 0.5rem;
  --space-2: 0.75rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 4.5rem;
  --space-8: 6.5rem;

  /* Layout */
  --container-width: 1120px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --border-width: 1px;
}

/* --- Light theme override ---------------------------------------------
   Applied via [data-theme="light"] on <html> (set by js/theme.js, which
   reads the saved choice from localStorage before first paint). Dark
   values above stay the default whenever the attribute is absent. */
[data-theme="light"] {
  --color-bg: #fcfbfa;
  --color-bg-elevated: #ffffff;
  --color-text: #14171a;
  --color-text-muted: #5b6169;
  --color-hairline: #e4e1dc;
  --color-brand: #d6291e;
  --color-brand-dark: #a81e15;
  --color-brand-tint: #fbeae8;
  --shadow-sm: 0 1px 2px rgba(20, 23, 26, 0.06);
  --shadow-md: 0 8px 24px rgba(20, 23, 26, 0.08);
  color-scheme: light;
}

/* =====================================================
   Reset
   ===================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* Theme-switch transition — scoped to color-bearing properties on the
   handful of surfaces that read the tokens directly, so toggling never
   causes layout jank. */
body,
.site-nav,
.site-footer,
.btn,
.manifest,
.manifest-row,
.framework-badge,
.pricing-teaser-card,
.pricing-table,
.pricing-column,
.terminal,
.mobile-drawer,
.mobile-backdrop {
  transition: background-color 200ms ease, border-color 200ms ease,
    color 200ms ease;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

button {
  font-family: inherit;
}

/* Visible keyboard focus everywhere — never suppressed. */
:focus-visible {
  outline: 2px solid var(--color-brand);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* =====================================================
   Typography
   ===================================================== */

h1,
h2,
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 var(--space-3);
  letter-spacing: -0.01em;
}

h1 {
  font-size: var(--text-3xl);
}

h2 {
  font-size: var(--text-2xl);
}

h3 {
  font-size: var(--text-lg);
}

p {
  margin: 0 0 var(--space-3);
  color: var(--color-slate);
  max-width: 62ch;
}

.lede {
  font-size: var(--text-lg);
  color: var(--color-slate);
}

code,
.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
}

/* =====================================================
   Layout primitives
   ===================================================== */

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.section {
  padding: var(--space-7) 0;
}

.section-header {
  max-width: 640px;
  margin-bottom: var(--space-6);
}

.section-header h2 {
  margin-bottom: var(--space-2);
}

.divider {
  border: none;
  border-top: var(--border-width) solid var(--color-line);
  margin: 0;
}

/* =====================================================
   Buttons
   ===================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: 0.75rem 1.375rem;
  font-family: var(--font-display);
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: var(--border-width) solid transparent;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease,
    color 120ms ease;
}

.btn-primary {
  background: var(--color-brand);
  color: var(--color-paper);
}

.btn-primary:hover {
  background: var(--color-brand-dark);
}

.btn-secondary {
  background: transparent;
  border-color: var(--color-ink);
  color: var(--color-ink);
}

.btn-secondary:hover {
  background: var(--color-ink);
  color: var(--color-paper);
}

.btn-block {
  width: 100%;
}

/* =====================================================
   Nav
   ===================================================== */

.site-nav {
  border-bottom: var(--border-width) solid var(--color-line);
  background: var(--color-paper);
  position: sticky;
  top: 0;
  z-index: 10;
}

/* min-height (not height) + flex-wrap: a fixed height clips or overflows
   the moment the signed-in auth-slot content (avatar + email + actions)
   needs more room than the signed-out state did. Wrapping onto a second
   row is a visible-but-intact fallback; clipping/overflowing is the
   "broken nav" this replaces. */
.site-nav .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.5rem;
  flex-wrap: wrap;
  row-gap: var(--space-1);
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.brand img {
  height: 1.75rem;
  width: auto;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-5);
}

.nav-links a:not(.btn) {
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink);
}

.nav-links a:not(.btn):hover {
  color: var(--color-brand);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  /* Lets the row wrap instead of forcing an overflow/clip once the
     signed-in auth-slot (below) is in the DOM. */
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* --- Theme toggle --- */

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
  transition: border-color 120ms ease, color 120ms ease,
    background-color 120ms ease;
}

.theme-toggle:hover {
  border-color: var(--color-ink);
}

.theme-toggle svg {
  width: 1.1rem;
  height: 1.1rem;
}

.theme-toggle .icon-moon {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-sun {
  display: none;
}

[data-theme="light"] .theme-toggle .icon-moon {
  display: inline-flex;
}

/* --- Mobile hamburger toggle --- */

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-ink);
  cursor: pointer;
}

.nav-toggle svg {
  width: 1.15rem;
  height: 1.15rem;
}

@media (max-width: 760px) {
  .nav-links {
    display: none;
  }

  .nav-toggle {
    display: inline-flex;
  }
}

/* --- Mobile drawer (nav links, revealed by .nav-toggle) --- */

.mobile-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  pointer-events: none;
  z-index: 20;
}

.mobile-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 84vw);
  background: var(--color-paper);
  border-left: var(--border-width) solid var(--color-line);
  padding: var(--space-4);
  transform: translateX(100%);
  z-index: 21;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mobile-drawer.is-open {
  transform: translateX(0);
}

.mobile-drawer a {
  padding: var(--space-3) var(--space-1);
  font-size: var(--text-base);
  font-weight: 500;
  border-bottom: var(--border-width) solid var(--color-line);
}

.mobile-drawer .btn {
  margin-top: var(--space-3);
}

body.no-scroll {
  overflow: hidden;
}

@media (min-width: 761px) {
  .mobile-drawer,
  .mobile-backdrop {
    display: none;
  }
}

/* =====================================================
   Hero
   ===================================================== */

.hero {
  padding: var(--space-8) 0 var(--space-7);
}

.hero .container {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: var(--space-7);
  align-items: center;
}

.hero-copy h1 {
  margin-bottom: var(--space-4);
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.hero-actions .btn {
  padding: 0.875rem 1.75rem;
}

.hero-note {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--color-slate);
}

/* --- Terminal / compile panel --- */

.terminal {
  background: var(--color-code-bg);
  color: var(--color-code-text);
  border: var(--border-width) solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.terminal-titlebar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border-bottom: var(--border-width) solid rgba(255, 255, 255, 0.08);
}

.terminal-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
}

.terminal-body {
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.terminal-line {
  opacity: 0;
  transform: translateY(4px);
  animation: terminal-line-in 420ms ease forwards;
  white-space: pre-wrap;
}

.terminal-line--muted {
  color: var(--color-code-muted);
}

.terminal-line--accent {
  color: var(--color-code-accent);
}

.terminal-rule {
  border-color: rgba(255, 255, 255, 0.12);
  margin: var(--space-1) 0;
}

@keyframes terminal-line-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Staggered one-time reveal — the page's single orchestrated motion moment. */
.terminal-line:nth-child(1) {
  animation-delay: 80ms;
}
.terminal-line:nth-child(2) {
  animation-delay: 260ms;
}
.terminal-line:nth-child(3) {
  animation-delay: 440ms;
}
.terminal-line:nth-child(4) {
  animation-delay: 620ms;
}
.terminal-line:nth-child(5) {
  animation-delay: 800ms;
}
.terminal-line:nth-child(6) {
  animation-delay: 980ms;
}
.terminal-line:nth-child(7) {
  animation-delay: 1160ms;
}
.terminal-line:nth-child(8) {
  animation-delay: 1340ms;
}

@media (max-width: 900px) {
  .hero .container {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Steps ("Upload → Compile → Ship" — a real sequence)
   ===================================================== */

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
}

.step {
  border-top: 2px solid var(--color-ink);
  padding-top: var(--space-3);
}

.step-index {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-brand);
  display: block;
  margin-bottom: var(--space-2);
}

.step h3 {
  margin-bottom: var(--space-2);
}

.step p {
  margin-bottom: 0;
}

@media (max-width: 760px) {
  .steps {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Output manifest ("what you get back")
   ===================================================== */

.manifest {
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.manifest-row {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-4);
  padding: var(--space-4);
}

.manifest-row + .manifest-row {
  border-top: var(--border-width) solid var(--color-line);
}

.manifest-filename {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-ink);
}

.manifest-desc {
  margin: 0;
  color: var(--color-slate);
}

@media (max-width: 640px) {
  .manifest-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }
}

/* =====================================================
   Framework badges
   ===================================================== */

.framework-badges {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.framework-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-3);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-slate);
}

/* =====================================================
   Pricing teaser strip (on index.html; full table lives in pricing.css)
   ===================================================== */

.pricing-teaser {
  background: var(--color-brand-tint);
}

.pricing-teaser-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.pricing-teaser-card {
  background: var(--color-paper);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-md);
  padding: var(--space-4);
}

.pricing-teaser-card .plan-name {
  font-family: var(--font-display);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.pricing-teaser-card .plan-price {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  color: var(--color-brand);
  margin-bottom: var(--space-2);
}

.pricing-teaser-card p {
  font-size: var(--text-sm);
  margin-bottom: 0;
}

@media (max-width: 900px) {
  .pricing-teaser-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .pricing-teaser-grid {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Pricing comparison table (pricing.html)
   -----------------------------------------------------
   NOTE: the roadmap's file tree gives pricing.html its own
   frontend/css/pricing.css (File 49b). That file does not exist yet at
   the time of writing, so its rules live here temporarily. If/when
   pricing.css is created, move everything in this block there verbatim
   and drop it from main.css.
   ===================================================== */

.pricing-page-header {
  padding: var(--space-7) 0 var(--space-5);
}

.billing-toggle-note {
  font-size: var(--text-sm);
  color: var(--color-slate);
}

.pricing-table {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: var(--border-width) solid var(--color-line);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.pricing-column {
  padding: var(--space-5) var(--space-4);
  border-left: var(--border-width) solid var(--color-line);
  display: flex;
  flex-direction: column;
}

.pricing-column:first-child {
  border-left: none;
}

.pricing-column--recommended {
  background: var(--color-brand-tint);
}

.pricing-column-name {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-bottom: var(--space-1);
}

.pricing-column-caption {
  font-size: var(--text-xs);
  color: var(--color-brand);
  font-family: var(--font-mono);
  margin-bottom: var(--space-3);
  min-height: 1.2em;
}

.pricing-column-price {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  margin-bottom: var(--space-4);
}

.pricing-column-price span {
  font-size: var(--text-xs);
  color: var(--color-slate);
}

.pricing-feature-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.pricing-feature-list li {
  font-size: var(--text-sm);
  color: var(--color-slate);
  padding-left: var(--space-3);
  position: relative;
}

.pricing-feature-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 6px;
  height: 6px;
  background: var(--color-ink);
}

.pricing-column--recommended .pricing-feature-list li::before {
  background: var(--color-brand);
}

@media (max-width: 900px) {
  .pricing-table {
    grid-template-columns: 1fr;
  }

  .pricing-column {
    border-left: none;
    border-top: var(--border-width) solid var(--color-line);
  }

  .pricing-column:first-child {
    border-top: none;
  }
}

.pricing-faq {
  margin-top: var(--space-7);
  max-width: 720px;
}

.pricing-faq-item + .pricing-faq-item {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: var(--border-width) solid var(--color-line);
}

.pricing-faq-item h3 {
  font-size: var(--text-base);
  margin-bottom: var(--space-1);
}

.pricing-faq-item p {
  margin-bottom: 0;
}

/* =====================================================
   Footer
   ===================================================== */

.site-footer {
  border-top: var(--border-width) solid var(--color-line);
  padding: var(--space-7) 0 var(--space-5);
}

.footer-top {
  display: grid;
  grid-template-columns: 1.3fr 1fr 1fr 1fr 1fr;
  gap: var(--space-5);
  padding-bottom: var(--space-6);
}

.footer-brand-col .brand {
  margin-bottom: var(--space-3);
}

.footer-brand-col .brand img {
  height: 1.5rem;
}

.footer-tagline {
  font-size: var(--text-sm);
  max-width: 32ch;
  margin-bottom: 0;
}

.footer-col-title {
  font-family: var(--font-display);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-ink);
  margin-bottom: var(--space-3);
}

.footer-col ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.footer-col a {
  font-size: var(--text-sm);
  color: var(--color-slate);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

.footer-col a:hover {
  color: var(--color-brand);
}

.footer-col a svg {
  width: 1rem;
  height: 1rem;
  flex: none;
}

.footer-bottom {
  border-top: var(--border-width) solid var(--color-line);
  padding-top: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.footer-copy {
  font-size: var(--text-xs);
  color: var(--color-slate);
  margin: 0;
}

.footer-bottom-links {
  display: flex;
  gap: var(--space-4);
}

.footer-bottom-links a {
  font-size: var(--text-xs);
  color: var(--color-slate);
}

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

@media (max-width: 900px) {
  .footer-top {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-5) var(--space-4);
  }

  .footer-brand-col {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .footer-top {
    grid-template-columns: 1fr;
  }
}

/* =====================================================
   Live UI layer (motion, status, dropzone, auth nav, feedback)
   Appended to main.css. Everything below reads the existing tokens,
   so both themes work without extra overrides.
   ===================================================== */

:root {
  --ok: #2ecc8f;
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --glow: 0 0 0 1px var(--color-brand-tint), 0 10px 34px -10px rgba(232, 57, 44, 0.5);
}
[data-theme="light"] {
  --ok: #12915f;
  --glow: 0 0 0 1px var(--color-brand-tint), 0 10px 30px -12px rgba(214, 41, 30, 0.4);
}

/* --- Theme switch: JS adds .theme-anim to <html> for ~350ms so every
       surface cross-fades without a permanent transition cost. --- */
.theme-anim,
.theme-anim *,
.theme-anim *::before,
.theme-anim *::after {
  transition: background-color 320ms ease, border-color 320ms ease,
    color 320ms ease, fill 320ms ease, box-shadow 320ms ease !important;
}
.theme-toggle svg { transition: transform 400ms var(--ease-out); }
.theme-toggle:hover svg { transform: rotate(28deg); }

/* --- Glass nav --- */
.site-nav {
  background: color-mix(in srgb, var(--color-paper) 78%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(14px);
  backdrop-filter: saturate(140%) blur(14px);
}
.nav-links a:not(.btn) { position: relative; }
.nav-links a:not(.btn)::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -6px; height: 1px;
  background: var(--color-brand); transform: scaleX(0); transform-origin: left;
  transition: transform 240ms var(--ease-out);
}
.nav-links a:not(.btn):hover::after { transform: scaleX(1); }

/* --- Live status pill --- */
.status-pill {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.4rem 0.7rem; border: var(--border-width) solid var(--color-line);
  border-radius: 999px; font: 500 var(--text-xs) / 1 var(--font-mono);
  color: var(--color-slate); white-space: nowrap;
}
.status-dot { position: relative; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--color-slate); }
.status-pill[data-state="online"] .status-dot,
.status-pill[data-state="online"] .status-dot::after { background: var(--ok); }
.status-pill[data-state="offline"] .status-dot { background: var(--color-brand); }
.status-pill[data-state="online"] .status-dot::after {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  animation: ping 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
.status-pill[data-state="checking"] .status-dot { animation: blink 1s steps(1) infinite; }
@keyframes ping { 75%, 100% { transform: scale(3.2); opacity: 0; } }
@keyframes blink { 50% { opacity: 0.25; } }
@media (max-width: 1000px) { .status-label { display: none; } .status-pill { padding: 0.55rem; } }

/* --- Buttons: lift, glow, pulse, loading --- */
.btn { position: relative; }
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary:hover { box-shadow: var(--glow); }
.btn-pulse { animation: pulse 2.6s ease-out infinite; }
.btn-pulse:hover { animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 var(--color-brand-tint), 0 0 0 0 rgba(232, 57, 44, 0.35); }
  70%, 100% { box-shadow: 0 0 0 0 transparent, 0 0 0 12px rgba(232, 57, 44, 0); }
}
.btn.is-loading { color: transparent !important; pointer-events: none; }
.btn.is-loading::after {
  content: ""; position: absolute; width: 1.05rem; height: 1.05rem;
  border: 2px solid var(--color-paper); border-right-color: transparent;
  border-radius: 50%; animation: spin 0.7s linear infinite;
}
.btn-secondary.is-loading::after { border-color: var(--color-ink); border-right-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Cards: glass border, lift, cursor-follow glow (JS sets --mx / --my) --- */
.glass {
  background: color-mix(in srgb, var(--color-surface) 72%, transparent);
  border: var(--border-width) solid color-mix(in srgb, var(--color-brand) 16%, var(--color-line));
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
[data-glow] { position: relative; overflow: hidden; transition: transform 260ms var(--ease-out), box-shadow 260ms var(--ease-out), border-color 200ms ease; }
[data-glow]::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(240px circle at var(--mx, 50%) var(--my, 50%), var(--color-brand-tint), transparent 70%);
  transition: opacity 240ms ease;
}
[data-glow]:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--color-brand); }
[data-glow]:hover::before { opacity: 1; }
.manifest-row:hover { background: var(--color-brand-tint); }
.framework-badge:hover { color: var(--color-ink); border-color: var(--color-brand); transform: translateY(-2px); }
.framework-badge { transition: transform 200ms var(--ease-out), border-color 200ms ease, color 200ms ease; }

/* --- Hero backdrop + terminal --- */
.hero { position: relative; isolation: isolate; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: -10% 0 auto; height: 70%; z-index: -1; pointer-events: none;
  background: radial-gradient(60% 60% at 75% 30%, var(--color-brand-tint), transparent 70%);
}

/* Professional "network" backdrop: a graph-paper grid with a small node
   dot at every intersection (circuit-board / network-diagram read, not a
   generic decorative pattern), faded out toward the edges with a mask so
   it reads as a backdrop rather than competing with the hero copy or the
   terminal panel. Sits behind .hero::before's red glow (z-index: -2). */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background-image:
    radial-gradient(circle, color-mix(in srgb, var(--color-brand) 55%, var(--color-ink)) 1.4px, transparent 1.6px),
    linear-gradient(var(--color-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--color-line) 1px, transparent 1px);
  background-size: 48px 48px, 48px 48px, 48px 48px;
  background-position: -1px -1px, -1px -1px, -1px -1px;
  opacity: 0.55;
  mask-image: radial-gradient(ellipse 75% 65% at 55% 15%, black 35%, transparent 100%);
  -webkit-mask-image: radial-gradient(ellipse 75% 65% at 55% 15%, black 35%, transparent 100%);
  animation: hero-grid-drift 50s linear infinite;
}
[data-theme="light"] .hero::after {
  opacity: 0.4;
}
@keyframes hero-grid-drift {
  to {
    background-position: 47px 47px, 47px 47px, 47px 47px;
  }
}

.terminal { box-shadow: var(--shadow-md), 0 0 70px -24px rgba(232, 57, 44, 0.45); }
.terminal-title { margin-left: auto; color: var(--color-code-muted); font-size: 0.75rem; }
.terminal-body { min-height: 21rem; }
.terminal.is-live .terminal-line { opacity: 1; transform: none; animation: none; }
.caret { display: inline-block; width: 0.6ch; height: 1.05em; margin-left: 1px; vertical-align: -0.18em; background: var(--color-code-accent); animation: blink 1s steps(1) infinite; }
.tk-k { color: #ff7b72; } .tk-t { color: #79c0ff; } .tk-s { color: #a5d6ff; }
.tk-n { color: #ffa657; } .tk-c { color: var(--color-code-muted); } .tk-ok { color: var(--color-code-accent); }

/* --- Model dropzone --- */
.dropzone {
  position: relative; padding: var(--space-6) var(--space-4); text-align: center; cursor: pointer;
  background: var(--color-surface); border: 1.5px dashed var(--color-line); border-radius: var(--radius-md);
  transition: border-color 200ms ease, background-color 200ms ease, transform 300ms var(--ease-out), box-shadow 300ms ease;
}
.dropzone:hover, .dropzone:focus-visible { border-color: var(--color-brand); }
.dropzone.is-over { border-color: var(--color-brand); background: var(--color-brand-tint); transform: scale(1.015); box-shadow: var(--glow); }
.dz-icon { width: 2.75rem; height: 2.75rem; margin: 0 auto var(--space-2); color: var(--color-brand); transition: transform 300ms var(--ease-out); }
.dropzone.is-over .dz-icon { transform: translateY(-6px) scale(1.12); }
.dz-title { font: 600 var(--text-base) var(--font-display); color: var(--color-ink); margin: 0 0 4px; }
.dz-sub { margin: 0 auto; font-size: var(--text-xs); }
.dropzone[data-state="idle"] .dz-file, .dropzone:not([data-state="idle"]) .dz-idle { display: none; }
.dz-file { display: flex; align-items: center; gap: var(--space-3); text-align: left; }
.dz-badge { flex: none; width: 2.75rem; height: 2.75rem; display: grid; place-items: center; border-radius: var(--radius-sm); background: var(--color-brand-tint); color: var(--color-brand); font: 600 var(--text-xs) var(--font-mono); }
.dz-meta { flex: 1; min-width: 0; }
.dz-name { font: 500 var(--text-sm) var(--font-mono); color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dz-status { font-size: var(--text-xs); color: var(--color-slate); margin: 2px 0 var(--space-1); max-width: none; }
.dz-progress { height: 4px; border-radius: 4px; overflow: hidden; background: var(--color-line); }
.dz-progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--color-brand), #ff8a7a); transition: width 160ms linear; }
.dz-check { flex: none; width: 1.75rem; height: 1.75rem; display: none; color: var(--ok); }
.dz-check path { stroke-dasharray: 26; stroke-dashoffset: 26; }
.dropzone[data-state="done"] { border-style: solid; border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--color-surface)); animation: pop 420ms var(--ease-out); }
.dropzone[data-state="done"] .dz-check { display: block; }
.dropzone[data-state="done"] .dz-check path { animation: draw 500ms 120ms ease forwards; }
.dropzone[data-state="done"] .dz-progress span { background: var(--ok); }
.dropzone[data-state="error"] { border-style: solid; border-color: var(--color-brand); animation: shake 380ms ease; }
.dz-actions { display: none; margin-top: var(--space-3); gap: var(--space-2); justify-content: center; }
.dropzone[data-state="done"] ~ .dz-actions, .dropzone[data-state="error"] ~ .dz-actions { display: flex; }
@keyframes draw { to { stroke-dashoffset: 0; } }
@keyframes pop { 40% { transform: scale(1.02); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px); } 40%, 80% { transform: translateX(6px); } }

/* --- Auth slot in nav ---
   min-width: 0 down the whole chain — .nav-actions is already flex above,
   .auth-slot/.auth-user are flex containers too, and a flex item's
   default min-width is `auto` (content-sized). Without overriding that,
   .user-email's own overflow/ellipsis rules below are silently ignored
   the moment a real email is long enough to matter, and the row overflows
   instead of truncating. See the fix-log at the top of this file. */
.auth-slot { display: flex; align-items: center; gap: var(--space-2); min-height: 2.25rem; min-width: 0; }
.auth-user { display: inline-flex; align-items: center; gap: var(--space-2); animation: fade-in 300ms ease; min-width: 0; }
.avatar { width: 2.25rem; height: 2.25rem; flex: none; border-radius: 50%; overflow: hidden; display: grid; place-items: center; background: var(--color-brand-tint); color: var(--color-brand); border: var(--border-width) solid var(--color-line); font: 600 0.9rem var(--font-display); }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.user-email { min-width: 0; max-width: 15ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--text-xs); color: var(--color-slate); }
.auth-skeleton { width: 9rem; height: 2.25rem; border-radius: var(--radius-md); background: linear-gradient(90deg, var(--color-line), var(--color-surface), var(--color-line)); background-size: 200% 100%; animation: shimmer 1.3s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes fade-in { from { opacity: 0; transform: translateY(-3px); } }
@media (max-width: 1100px) { .user-email { display: none; } }
@media (max-width: 760px) { .nav-actions .auth-slot { display: none; } }

/* --- API feedback: top loader + toasts (created by api_client.js) --- */
#qovox-loader { position: fixed; top: 0; left: 0; z-index: 100; width: 100%; height: 2px; background: var(--color-brand); transform-origin: left; transform: scaleX(0); opacity: 0; transition: opacity 200ms ease; }
#qovox-loader.is-active { opacity: 1; animation: loader 1.2s ease-in-out infinite; }
@keyframes loader { 0% { transform: scaleX(0.04); } 60% { transform: scaleX(0.8); } 100% { transform: scaleX(0.98); } }
.toast-stack { position: fixed; right: var(--space-3); bottom: var(--space-3); z-index: 100; display: flex; flex-direction: column; gap: var(--space-1); max-width: min(360px, calc(100vw - 2rem)); }
.toast { padding: var(--space-2) var(--space-3); border-left: 3px solid var(--color-brand); border-radius: var(--radius-sm); font-size: var(--text-sm); color: var(--color-ink); box-shadow: var(--shadow-md); animation: toast-in 320ms var(--ease-out); }
.toast[data-type="success"] { border-left-color: var(--ok); }
.toast.is-leaving { opacity: 0; transform: translateX(12px); transition: 240ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } }

.section-narrow { max-width: 760px; margin: 0 auto; }
.cta-band { text-align: center; }
.cta-band p { margin-left: auto; margin-right: auto; }
.cta-band .hero-actions { justify-content: center; }
/* current product in the footer */
.footer-col a[aria-current=true]{color:var(--color-ink,var(--text,#f2f2f5));font-weight:600}.footer-col a[aria-current=true]::after{content:" \00b7  you are here";color:var(--color-muted,var(--muted,#9b9ba8));font-weight:400;font-size:.85em}
