/*
 * FlightLab shared theme tokens.
 *
 * flightlab-theme.js (loaded synchronously before this file) sets every token below as an inline
 * custom property on <html> for the active theme, so the :root block here is only a no-JS/first-paint
 * fallback (the default theme, Paper) and documents the vocabulary. Pages must reference tokens, never raw colors:
 *
 *   surfaces   --bg --surface --surface-raised
 *   text       --text --muted --on-accent
 *   sidebar    --nav-bg --nav-text
 *   lines      --border --border-strong
 *   semantics  --accent --accent-2 --success --warning --danger (+ --accent-dim)
 *   alpha mix  rgba(var(--ink-rgb), a)  rgba(var(--accent-rgb), a)  rgba(var(--success-rgb), a) ...
 *   modes      --mode-rocket --mode-airplane --mode-drone --mode-glider --mode-helicopter
 *              --mode-avian --mode-kite --mode-experimental --mode-waterrocket
 *   charts     read through FlightLabCharts / FlightLabTheme, not CSS
 */
:root {
  --bg: #f4efe4;
  --surface: #fbf8f1;
  --surface-raised: #ece5d6;
  --text: #2b241c;
  --muted: #6f6659;
  --border: rgba(60,40,10,0.10);
  --border-strong: rgba(60,40,10,0.2);
  --accent: #b3362a;
  --accent-2: #2f6f8f;
  --success: #4f7a3a;
  --warning: #a86a12;
  --danger: #b3362a;
  --on-accent: #fbf8f1;
  --nav-bg: #eae3d3;
  --nav-text: #675e4c;
  --mode-rocket: #b3362a;
  --mode-airplane: #2f6f8f;
  --mode-drone: #7b4f9e;
  --mode-glider: #3f6f6f;
  --mode-helicopter: #a86a12;
  --mode-avian: #a34a7a;
  --mode-kite: #4f7a3a;
  --mode-experimental: #6f6659;
  --mode-waterrocket: #3d5a80;

  --accent-rgb: 179,54,42;
  --accent-2-rgb: 47,111,143;
  --success-rgb: 79,122,58;
  --warning-rgb: 168,106,18;
  --danger-rgb: 179,54,42;
  --text-rgb: 43,36,28;
  --ink-rgb: 0,0,0;
  --accent-dim: rgba(179,54,42,0.1);
  --chart-grid: rgba(60,40,10,0.08);
  --chart-label: #6f6659;

  --display: 'Plus Jakarta Sans', -apple-system, sans-serif;
  --mono: 'Azeret Mono', 'SF Mono', monospace;

  /* Aliases for names that drifted across pages before the shared stylesheet existed. */
  --raised: var(--surface-raised);
  --purple: var(--mode-drone);
  --cyan: var(--accent-2);
  --warn: var(--warning);
  --panel: var(--surface);
  --panel2: var(--surface-raised);
  --line: var(--border-strong);
  --orange: var(--accent);
  --green: var(--success);
  --red: var(--danger);
  --amber: var(--warning);
  --sans: var(--display);
}

html { color-scheme: light; background: var(--bg); }
html[data-theme-base="dark"] { color-scheme: dark; }

/* Mode badges share one rule set; the color comes from the theme's mode tokens. */
.mode-badge.rocket { background: color-mix(in srgb, var(--mode-rocket) 12%, transparent); color: var(--mode-rocket); }
.mode-badge.airplane { background: color-mix(in srgb, var(--mode-airplane) 12%, transparent); color: var(--mode-airplane); }
.mode-badge.drone { background: color-mix(in srgb, var(--mode-drone) 12%, transparent); color: var(--mode-drone); }
.mode-badge.glider { background: color-mix(in srgb, var(--mode-glider) 12%, transparent); color: var(--mode-glider); }
.mode-badge.helicopter { background: color-mix(in srgb, var(--mode-helicopter) 12%, transparent); color: var(--mode-helicopter); }
.mode-badge.avian { background: color-mix(in srgb, var(--mode-avian) 12%, transparent); color: var(--mode-avian); }
.mode-badge.kite { background: color-mix(in srgb, var(--mode-kite) 12%, transparent); color: var(--mode-kite); }
.mode-badge.experimental { background: color-mix(in srgb, var(--mode-experimental) 12%, transparent); color: var(--mode-experimental); }
.mode-badge.waterrocket { background: color-mix(in srgb, var(--mode-waterrocket) 12%, transparent); color: var(--mode-waterrocket); }

/* Ink themes (no hue): pills become outlines so status still reads without color. */
html[data-theme-ink="1"] .mode-badge,
html[data-theme-ink="1"] .status-badge,
html[data-theme-ink="1"] .source-badge,
html[data-theme-ink="1"] .badge {
  background: transparent !important;
  box-shadow: inset 0 0 0 1px currentColor;
}
html[data-theme-ink="1"] .mode-badge img { filter: grayscale(1); }

/* Chart legends: line samples that carry dash pattern as well as color. */
.legend-sample { display: inline-block; vertical-align: middle; flex-shrink: 0; }
.legend-sample line { vector-effect: non-scaling-stroke; }

/* Theme picker tiles (Settings) and mini previews (editor, admin). */
.theme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.theme-tile {
  position: relative; display: flex; flex-direction: column; gap: 8px; padding: 10px; border-radius: 10px;
  border: 1px solid var(--border-strong); background: var(--surface-raised); cursor: pointer; text-align: left;
  font-family: var(--display); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
.theme-tile:hover { border-color: var(--accent); }
.theme-tile:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.theme-tile.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.35); }
.theme-tile .theme-tile-name { font-size: 0.8125rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.theme-tile .theme-tile-name .check { display: none; width: 14px; height: 14px; color: var(--accent); }
.theme-tile.selected .theme-tile-name .check { display: inline-block; }
.theme-tile .theme-tile-meta { font-size: 0.6875rem; color: var(--muted); line-height: 1.4; }
.theme-tile .theme-tile-actions { display: flex; gap: 6px; margin-top: 2px; }
.theme-tile .theme-tile-actions a,
.theme-tile .theme-tile-actions button {
  font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-decoration: none; background: none; border: none;
  padding: 2px 0; cursor: pointer; font-family: var(--display);
}
.theme-tile .theme-tile-actions a:hover,
.theme-tile .theme-tile-actions button:hover { color: var(--accent); }

.theme-swatch {
  display: flex; width: 100%; aspect-ratio: 16 / 9; border-radius: 6px; border: 1px solid; overflow: hidden;
}
.theme-swatch-nav { width: 28%; display: flex; flex-direction: column; gap: 4px; padding: 6px 5px; border-right: 1px solid; }
.theme-swatch-accent { display: block; height: 5px; width: 70%; border-radius: 2px; }
.theme-swatch-line { display: block; height: 3px; width: 85%; border-radius: 2px; opacity: 0.5; }
.theme-swatch-line.short { width: 55%; }
.theme-swatch-body { flex: 1; display: flex; flex-direction: column; gap: 4px; padding: 6px 7px; }
.theme-swatch-text { display: block; height: 4px; width: 60%; border-radius: 2px; }
.theme-swatch-text.short { width: 35%; opacity: 0.6; }
.theme-swatch-chart {
  flex: 1; display: flex; flex-direction: column; justify-content: space-evenly; align-items: stretch;
  border-radius: 4px; border: 1px solid; padding: 3px 5px; min-height: 22px;
}
.theme-swatch-chart .legend-sample { width: 100%; height: 6px; }

@media (max-width: 700px) {
  .theme-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
