/* ==========================================================================
   Self-hosted fonts — no requests to third-party font services
   ========================================================================== */
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-400.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-500.woff2') format('woff2'); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-700.woff2') format('woff2'); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Satoshi'; src: url('../assets/fonts/satoshi-900.woff2') format('woff2'); font-weight: 900; font-style: normal; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../assets/fonts/jetbrainsmono-latin.woff2') format('woff2'); font-weight: 100 800; font-style: normal; font-display: swap; }

/* ==========================================================================
   base.css — design tokens and fundamentals
   Palette: instrument panel (graphite, muted teal as the only accent)
   ========================================================================== */

:root {
  /* Typography */
  --font-sans: 'Satoshi', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', monospace;

  --text-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.35vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.0625rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --text-xl: clamp(1.5rem, 1.2rem + 1.1vw, 2.125rem);

  /* Spacing (4px system) */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px oklch(0% 0 0 / 0.28);
  --shadow: 0 8px 24px oklch(0% 0 0 / 0.32);
  --shadow-lg: 0 24px 60px oklch(0% 0 0 / 0.42);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---------- Dark (default: cockpit) ---------- */
:root,
[data-theme='dark'] {
  --bg: oklch(19% 0.008 250);
  --surface: oklch(23% 0.009 250);
  --surface-2: oklch(27% 0.01 250);
  --surface-3: oklch(32% 0.011 250);
  --border: oklch(36% 0.012 250);
  --border-soft: oklch(30% 0.01 250);
  --text: oklch(93% 0.006 250);
  --text-muted: oklch(72% 0.008 250);
  --text-faint: oklch(58% 0.008 250);
  --accent: oklch(78% 0.11 178);
  --accent-strong: oklch(84% 0.12 178);
  --accent-ink: oklch(20% 0.03 178);
  --warn: oklch(80% 0.12 78);
  --danger: oklch(70% 0.15 25);
  --good: oklch(78% 0.13 155);
}

/* ---------- Light ---------- */
[data-theme='light'] {
  --bg: oklch(96.5% 0.004 250);
  --surface: oklch(99% 0.002 250);
  --surface-2: oklch(94% 0.005 250);
  --surface-3: oklch(90% 0.006 250);
  --border: oklch(86% 0.008 250);
  --border-soft: oklch(91% 0.006 250);
  --text: oklch(24% 0.01 250);
  --text-muted: oklch(45% 0.012 250);
  --text-faint: oklch(58% 0.01 250);
  --accent: oklch(58% 0.1 178);
  --accent-strong: oklch(50% 0.11 178);
  --accent-ink: oklch(99% 0.005 178);
  --warn: oklch(60% 0.13 65);
  --danger: oklch(55% 0.18 25);
  --good: oklch(55% 0.13 155);
}

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

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior: none;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.015em;
  font-weight: 700;
}

h1 {
  font-size: var(--text-xl);
}
h2 {
  font-size: var(--text-lg);
}
h3 {
  font-size: var(--text-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  font-weight: 700;
}

p {
  margin: 0 0 var(--space-3);
}

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

button {
  font: inherit;
  color: inherit;
}

canvas {
  display: block;
  touch-action: none;
}

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

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px
  ;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--surface-2);
  --btn-border: var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  min-height: 38px;
  border: 1px solid var(--btn-border);
  border-radius: var(--radius);
  background: var(--btn-bg);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s var(--ease), border-color 0.18s var(--ease), transform 0.12s var(--ease);
  user-select: none;
  -webkit-user-select: none;
}

.btn:hover {
  /* Brightness instead of a fixed color so primary buttons keep their accent */
  filter: brightness(1.14);
  border-color: var(--border);
}

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

.btn-primary {
  --btn-bg: var(--accent);
  --btn-border: transparent;
  color: var(--accent-ink);
  font-weight: 700;
}

.btn-primary:hover {
  --btn-bg: var(--accent-strong);
  border-color: transparent;
}

.btn-ghost {
  --btn-bg: transparent;
}

.btn-ghost:hover {
  background: var(--surface-2);
}

.btn-block {
  width: 100%;
}

.btn-mini {
  padding: var(--space-1) var(--space-3);
  min-height: 30px;
  font-size: var(--text-xs);
}

.btn[aria-pressed='true'],
.btn.is-active {
  border-color: var(--accent);
  color: var(--accent);
}

/* ---------- Forms ---------- */
.switch {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--text-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--space-1) 0;
}

.switch input {
  appearance: none;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  margin: 2px 0 0;
  border-radius: 999px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  position: relative;
  cursor: pointer;
  transition: background 0.18s var(--ease);
}

.switch input::after {
  content: '';
  position: absolute;
  inset: 2px auto 2px 2px;
  width: 14px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: transform 0.18s var(--ease), background 0.18s var(--ease);
}

.switch input:checked {
  background: color-mix(in oklch, var(--accent) 35%, var(--surface-3));
  border-color: var(--accent);
}

.switch input:checked::after {
  transform: translateX(16px);
  background: var(--accent);
}

/* ---------- Tables ---------- */
.spec-table,
.compare-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.spec-table td,
.compare-table td,
.compare-table th {
  padding: var(--space-2) var(--space-3);
  border-bottom: 1px solid var(--border-soft);
  text-align: left;
}

.spec-table td:last-child,
.compare-table td:not(:first-child) {
  font-family: var(--font-mono);
  font-size: 0.9em;
  color: var(--text);
  text-align: right;
}

.spec-table td:first-child,
.compare-table th {
  color: var(--text-muted);
}

.compare-table th {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hint {
  font-size: var(--text-xs);
  color: var(--text-faint);
  line-height: 1.5;
}


/* ==========================================================================
   Scrollbars — deliberately visible so scrollable areas are recognizable.
   ::-webkit-scrollbar forces a classic (always visible) bar in Chromium
   instead of the overlay variant. Important: scrollbar-width /
   scrollbar-color must NOT be set for this, otherwise they win and the
   pseudo-element rules are ignored. Firefox gets the standard
   properties via the @supports block below.
   ========================================================================== */
:root {
  --scroll-thumb: oklch(52% 0.012 250);
  --scroll-thumb-hover: oklch(64% 0.014 250);
  --scroll-track: oklch(19% 0.008 250);
}

[data-theme='light'] {
  --scroll-thumb: oklch(76% 0.008 250);
  --scroll-thumb-hover: oklch(66% 0.01 250);
  --scroll-track: oklch(95% 0.004 250);
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--scroll-track);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: var(--scroll-thumb);
  border: 3px solid transparent;
  background-clip: content-box;
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--scroll-thumb-hover);
  background-clip: content-box;
}

::-webkit-scrollbar-corner {
  background: var(--scroll-track);
}

/* Firefox does not know the ::-webkit pseudo-elements */
@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll-thumb) var(--scroll-track);
  }
}

/* Respect the operating-system setting for reduced motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
