/* ============================================================================
   Kavron Data Portal — "Frontier deck" theme.
   A single, deliberate dark world: deep navy ground, teal->cyan signature
   gradient reserved for the brand mark / hero accents / top hairline, and a
   solid brand-teal for primary CTAs. Built for a licensed data-download product
   that should read as expensive and considered.

   Constraints honoured:
   - No external fonts / CDN (CSP style-src 'self', no font-src): refined system
     stack with a designed type treatment (scale contrast + tracking + tab nums).
   - No external images: all depth from CSS gradients / radial glows.
   - AA contrast, visible :focus-visible, respects prefers-reduced-motion.
   - Responsive 375 -> 1440, no horizontal body scroll; wide tables self-scroll.
   ============================================================================ */

:root {
  color-scheme: dark;

  /* --- Ground & elevated surfaces (deep navy, layered) --- */
  --bg:          oklch(16% 0.028 250);
  --bg-deep:     oklch(12% 0.026 252);
  --surface:     oklch(21% 0.030 250);
  --surface-2:   oklch(25% 0.032 250);
  --surface-3:   oklch(29% 0.034 250);

  /* --- Hairlines --- */
  --line:        oklch(34% 0.028 248);
  --line-soft:   oklch(28% 0.026 250);
  --line-strong: oklch(44% 0.030 246);

  /* --- Ink --- */
  --ink:         oklch(95% 0.008 240);
  --ink-soft:    oklch(76% 0.018 240);
  --ink-faint:   oklch(66% 0.020 242);

  /* --- Brand accent (teal -> cyan) --- */
  --teal:        oklch(74% 0.128 192);
  --teal-bright: oklch(82% 0.120 195);
  --cyan:        oklch(80% 0.115 205);
  --teal-ink:    oklch(19% 0.045 240);   /* dark text that sits on solid teal   */
  --teal-tint:   oklch(74% 0.128 192 / 0.14);
  --teal-tint-2: oklch(74% 0.128 192 / 0.24);
  --glow-teal:   oklch(70% 0.13 195 / 0.55);

  /* --- Semantic chip hues --- */
  --green:       oklch(80% 0.135 158);
  --green-tint:  oklch(80% 0.135 158 / 0.14);
  --gold:        oklch(83% 0.115 88);
  --gold-tint:   oklch(83% 0.115 88 / 0.14);
  --violet:      oklch(78% 0.115 300);
  --violet-tint: oklch(78% 0.115 300 / 0.15);
  --danger:      oklch(74% 0.150 25);
  --danger-tint: oklch(60% 0.16 25 / 0.16);

  /* --- Type --- */
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", "SFMono-Regular", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  --text-xs:   0.74rem;
  --text-sm:   0.84rem;
  --text-base: clamp(0.95rem, 0.9rem + 0.2vw, 1.03rem);
  --text-lg:   clamp(1.1rem, 1rem + 0.4vw, 1.28rem);
  --text-h2:   clamp(1.25rem, 1rem + 1vw, 1.6rem);
  --text-display: clamp(2rem, 1.2rem + 3.4vw, 3.4rem);

  /* --- Rhythm & shape --- */
  --space-1: 0.4rem;
  --space-2: 0.75rem;
  --space-3: 1.25rem;
  --space-4: 2rem;
  --space-5: 3rem;
  --space-section: clamp(2.5rem, 1.6rem + 4vw, 4.75rem);
  --radius:    14px;
  --radius-sm: 9px;
  --radius-pill: 999px;

  --shadow-card:
    0 1px 0 oklch(100% 0 0 / 0.03) inset,
    0 2px 6px oklch(0% 0 0 / 0.4),
    0 24px 60px -32px oklch(0% 0 0 / 0.75);
  --shadow-pop:
    0 1px 0 oklch(100% 0 0 / 0.05) inset,
    0 10px 40px -12px oklch(0% 0 0 / 0.7);

  --grad-brand: linear-gradient(115deg, var(--teal) 0%, var(--cyan) 55%, oklch(84% 0.10 214) 100%);

  --duration-fast: 140ms;
  --duration:      240ms;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* Atmospheric backdrop (base.html hook: <div class="app-aura">).
   Painted above the body ground but behind all content. */
.app-aura {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(70% 55% at 82% -8%, oklch(60% 0.12 200 / 0.32), transparent 60%),
    radial-gradient(60% 48% at 8% 4%, oklch(52% 0.10 235 / 0.30), transparent 62%),
    radial-gradient(120% 90% at 50% 120%, oklch(45% 0.06 250 / 0.35), transparent 70%),
    var(--bg);
}

.wrap { width: min(1120px, 92vw); margin-inline: auto; }

a { color: var(--cyan); text-decoration: none; }
a:hover { color: var(--teal-bright); text-decoration: underline; text-underline-offset: 0.18em; }

:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 3px;
}

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--cyan);
  background: oklch(100% 0 0 / 0.05);
  border: 1px solid var(--line-soft);
  padding: 0.05em 0.4em;
  border-radius: 6px;
}
time { font-variant-numeric: tabular-nums; }

/* ============================ Header ==================================== */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: oklch(15% 0.026 250 / 0.72);
  backdrop-filter: blur(14px) saturate(1.2);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line-soft);
}
/* Signature gradient hairline across the very top */
.site-header::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--grad-brand);
  opacity: 0.9;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding-block: 0.85rem;
}

.brand {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; color: var(--ink); }
.brand-mark {
  align-self: center;
  font-size: 1.15rem;
  line-height: 1;
  background: var(--grad-brand);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 10px var(--glow-teal));
  transition: transform var(--duration) var(--ease);
}
.brand:hover .brand-mark { transform: rotate(90deg); }
.brand-name { font-size: 1.2rem; font-weight: 680; letter-spacing: -0.02em; }
.brand-sub {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
  font-weight: 600;
  padding-left: 0.65rem;
  border-left: 1px solid var(--line);
}

.header-nav { display: inline-flex; align-items: center; gap: 0.6rem; }
.who {
  font-size: var(--text-sm);
  color: var(--ink-faint);
  white-space: nowrap;
}
.who strong { color: var(--ink-soft); font-weight: 600; }

/* ======================= Main / typography ============================= */
main { flex: 1 0 auto; padding-block: var(--space-section); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--teal);
  margin: 0 0 0.7rem;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
}
.eyebrow::before {
  content: "";
  width: 1.6rem;
  height: 1px;
  background: linear-gradient(90deg, var(--teal), transparent);
}

h1 {
  font-size: var(--text-display);
  line-height: 1.02;
  letter-spacing: -0.035em;
  font-weight: 700;
  margin: 0 0 0.6rem;
  text-wrap: balance;
  background: linear-gradient(180deg, var(--ink) 30%, oklch(80% 0.02 240));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
h2 {
  font-size: var(--text-h2);
  letter-spacing: -0.02em;
  font-weight: 660;
  margin: var(--space-5) 0 var(--space-2);
  color: var(--ink);
}
.lede {
  color: var(--ink-soft);
  font-size: var(--text-lg);
  line-height: 1.5;
  max-width: 62ch;
  margin: 0 0 var(--space-4);
  text-wrap: pretty;
}
section > p { max-width: 74ch; }

/* ============================ Buttons ================================== */
.btn {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font: inherit;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.005em;
  padding: 0.72rem 1.15rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--btn-bd);
  background: var(--btn-bg);
  color: var(--btn-fg);
  cursor: pointer;
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease),
    background-color var(--duration-fast), border-color var(--duration-fast),
    box-shadow var(--duration-fast), color var(--duration-fast);
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.btn-sm { padding: 0.5rem 0.85rem; font-size: var(--text-sm); border-radius: 7px; }

.btn-primary {
  --btn-bg: var(--teal);
  --btn-fg: var(--teal-ink);
  --btn-bd: transparent;
  box-shadow: 0 0 0 1px oklch(80% 0.10 195 / 0.4) inset,
    0 10px 26px -12px var(--glow-teal);
}
.btn-primary:hover {
  --btn-bg: var(--teal-bright);
  box-shadow: 0 0 0 1px oklch(85% 0.10 195 / 0.55) inset,
    0 14px 34px -12px var(--glow-teal);
}

.btn-ghost {
  --btn-bg: transparent;
  --btn-fg: var(--ink-soft);
  --btn-bd: var(--line);
}
.btn-ghost:hover {
  --btn-bg: var(--surface-2);
  --btn-fg: var(--ink);
  --btn-bd: var(--line-strong);
}

.btn-disabled {
  --btn-bg: oklch(24% 0.02 250);
  --btn-fg: var(--ink-faint);
  --btn-bd: var(--line-soft);
  cursor: not-allowed;
  box-shadow: none;
}
.btn-disabled:hover { transform: none; }

/* ===================== Auth card (login moment) ======================= */
.auth-card {
  position: relative;
  max-width: 27rem;
  margin: clamp(1.5rem, 6vh, 4.5rem) auto;
  padding: clamp(1.8rem, 1.2rem + 2.4vw, 2.8rem);
  background:
    radial-gradient(120% 60% at 50% -10%, var(--teal-tint), transparent 62%),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}
/* Gradient hairline across the top of the card */
.auth-card::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: var(--grad-brand);
}
/* Faint oversized diamond watermark */
.auth-card::after {
  content: "\25C6";
  position: absolute;
  top: -0.7rem;
  right: 0.4rem;
  font-size: 7rem;
  line-height: 1;
  color: oklch(74% 0.128 192 / 0.06);
  pointer-events: none;
  user-select: none;
}
.auth-card > * { position: relative; }
.auth-card h1 { font-size: clamp(1.9rem, 1.5rem + 1.6vw, 2.4rem); }

.auth-form { display: grid; gap: var(--space-3); margin-top: var(--space-4); }
.field { display: grid; gap: 0.45rem; }
.field-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 650;
  color: var(--ink-faint);
}
.field input {
  font: inherit;
  width: 100%;
  padding: 0.75rem 0.9rem;
  color: var(--ink);
  background: var(--bg-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast),
    background-color var(--duration-fast);
}
.field input::placeholder { color: var(--ink-faint); }
.field input:hover { border-color: var(--line-strong); }
.field input:focus {
  outline: none;
  border-color: var(--teal);
  background: oklch(18% 0.028 250);
  box-shadow: 0 0 0 3px var(--teal-tint-2);
}
.auth-form .btn { width: 100%; padding-block: 0.85rem; margin-top: 0.3rem; }

.form-error {
  margin: var(--space-3) 0 0;
  padding: 0.75rem 0.9rem;
  font-size: var(--text-sm);
  color: oklch(86% 0.09 25);
  background: var(--danger-tint);
  border: 1px solid oklch(58% 0.15 25 / 0.5);
  border-radius: var(--radius-sm);
}

/* ========================== Empty state =============================== */
.empty-state {
  padding: clamp(2rem, 5vw, 3.5rem);
  text-align: center;
  background:
    repeating-linear-gradient(135deg, transparent 0 13px, oklch(100% 0 0 / 0.014) 13px 14px),
    var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
}
.empty-title { font-size: var(--text-lg); font-weight: 660; color: var(--ink); margin: 0 0 0.5rem; }
.empty-body { color: var(--ink-soft); max-width: 42ch; margin: 0 auto 0.9rem; }
.empty-meta { font-size: var(--text-sm); color: var(--ink-faint); margin: 0.5rem 0; }
.empty-meta strong { color: var(--ink-soft); font-weight: 650; }

/* ===================== Data grid (catalog etc.) ======================= */
.table-scroll,
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  -webkit-overflow-scrolling: touch;
}
.table-wrap { margin-top: var(--space-2); }

.dataset-table,
.table-wrap table {
  width: 100%;
  border-collapse: collapse;
}
.dataset-table { min-width: 760px; }
.table-wrap table { min-width: 420px; }

.dataset-table thead th,
.table-wrap thead th {
  text-align: left;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-faint);
  font-weight: 700;
  padding: 0.95rem 1.05rem;
  background: linear-gradient(var(--surface-2), oklch(23% 0.030 250));
  border-bottom: 1px solid var(--line-strong);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

.dataset-table tbody td,
.dataset-table tbody th,
.table-wrap tbody td,
.table-wrap tbody th {
  padding: 0.9rem 1.05rem;
  border-bottom: 1px solid var(--line-soft);
  font-weight: 400;
  text-align: left;
  vertical-align: middle;
  color: var(--ink-soft);
}
.dataset-table tbody tr:last-child td,
.dataset-table tbody tr:last-child th,
.table-wrap tbody tr:last-child td,
.table-wrap tbody tr:last-child th { border-bottom: none; }

.dataset-table tbody tr,
.table-wrap tbody tr { transition: background-color var(--duration-fast); }
.dataset-table tbody tr:hover,
.table-wrap tbody tr:hover { background: var(--teal-tint); }

.task-cell {
  font-weight: 620;
  color: var(--ink);
  letter-spacing: -0.005em;
}
.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  font-size: 0.92em;
  color: var(--ink);
}
th.num { text-align: right; }
.actions { text-align: right; white-space: nowrap; }
.actions .btn + .btn { margin-left: 0.4rem; }

/* ============================== Tags ================================== */
.tag {
  display: inline-block;
  padding: 0.24rem 0.62rem;
  font-size: var(--text-sm);
  font-weight: 560;
  line-height: 1.3;
  border-radius: var(--radius-pill);
  background: var(--teal-tint);
  border: 1px solid oklch(74% 0.128 192 / 0.3);
  color: var(--teal-bright);
  white-space: nowrap;
}
.tag + .tag { margin-left: 0.3rem; }
.tag-muted {
  background: oklch(100% 0 0 / 0.04);
  border-color: var(--line);
  color: var(--ink-faint);
}
.tag-roadmap {
  display: inline-block;
  padding: 0.16rem 0.55rem;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 650;
  border-radius: var(--radius-pill);
  background: var(--violet-tint);
  border: 1px solid oklch(78% 0.115 300 / 0.32);
  color: var(--violet);
  white-space: nowrap;
}

/* Quality-tier cell copy (e.g. "A ±0.4") gets tabular treatment for scanning */
.dataset-table td { font-variant-numeric: tabular-nums; }

/* ============================== Footer ================================ */
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--line-soft);
  padding-block: var(--space-4);
  font-size: var(--text-sm);
  color: var(--ink-faint);
  background: oklch(14% 0.026 252 / 0.6);
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--cyan); }

/* Passport verification block: a .site-footer nested inside content.
   Restyle it as a boxed, monospace-flavoured note instead of a page footer. */
#main .site-footer {
  margin-top: var(--space-4);
  padding: var(--space-3);
  border: 1px solid var(--line);
  border-top: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(0deg, var(--teal-tint), transparent 70%),
    var(--surface);
  color: var(--ink-soft);
  box-shadow: var(--shadow-card);
}

/* ===================== Extraction matrix (/matrix) ==================== */
.matrix-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: var(--space-3);
  padding: 0.7rem 0.9rem;
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
}
.matrix-legend-note { color: var(--ink-faint); margin-left: auto; }

.chip {
  display: inline-block;
  padding: 0.24rem 0.62rem;
  font-size: var(--text-sm);
  font-weight: 560;
  font-variant-numeric: tabular-nums;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  white-space: nowrap;
}
.chip-native {
  background: var(--green-tint);
  border-color: oklch(80% 0.135 158 / 0.3);
  color: var(--green);
}
.chip-slam {
  background: var(--gold-tint);
  border-color: oklch(83% 0.115 88 / 0.32);
  color: var(--gold);
}
.chip-na {
  background: oklch(100% 0 0 / 0.03);
  border-color: var(--line-soft);
  color: var(--ink-faint);
}
.chip-empty { opacity: 0.5; font-style: italic; font-weight: 400; }

.matrix-table { min-width: 900px; }
.matrix-col { min-width: 9.5rem; vertical-align: bottom; }
.matrix-col-count {
  display: block;
  margin-top: 0.2rem;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
  color: var(--teal);
}
.matrix-family-row th {
  background: oklch(19% 0.028 250);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--teal);
  font-weight: 700;
  padding-block: 0.6rem;
  border-bottom: 1px solid var(--line);
}
.matrix-cell { white-space: nowrap; }
.matrix-signal { font-family: var(--font-mono); font-size: 0.9em; color: var(--ink); }
.matrix-signal .tag-roadmap { margin-left: 0.45rem; }
.matrix-slug { font-family: var(--font-mono); font-size: 0.86em; font-weight: 500; color: var(--cyan); }
.matrix-subhead { scroll-margin-top: 5rem; }
.matrix-meta { margin-top: var(--space-3); }

/* ============================ Responsive ============================== */
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .header-inner { flex-wrap: wrap; gap: var(--space-2); }
  .header-nav { gap: 0.45rem; flex-wrap: wrap; }
  .who { order: 3; width: 100%; }
  .matrix-legend-note { margin-left: 0; width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
