/*
 * Theme palettes — colours and structural tokens only; layout lives in style.css.
 * A new theme is one block here plus one entry in THEME_FX (src/config.ts).
 * Loaded AFTER style.css so these values win.
 *
 * --up / --down stay green/red in every theme, tinted to the palette: an amber
 * theme must not turn "up" amber.
 */

/* ── matrix — green phosphor, the default ───────────────────────────────── */
:root,
html[data-theme="matrix"] {
  --bg: #04070a;
  --bg-2: #060b0e;
  --bg-3: #03060a;
  --bg-rgb: 4, 7, 10;
  --panel: rgba(8, 15, 13, 0.82);
  --panel-solid: #070e0c;
  --scrim: rgba(2, 5, 7, 0.74);
  --tip-bg: rgba(5, 11, 9, 0.97);

  --accent-rgb: 61, 255, 158;
  --green: rgb(var(--accent-rgb));
  --green-deep: #00c46e;
  --green-deep-rgb: 0, 196, 110;

  --ink: #b9ffd8;
  --dim: #4e8a70;
  --dimmer: #2c5644;
  --line: rgba(var(--accent-rgb), 0.18);
  --line-hot: rgba(var(--accent-rgb), 0.55);

  --amber: #ffb454;
  --amber-rgb: 255, 180, 84;
  --red: #ff5566;
  --red-rgb: 255, 85, 102;

  --up: #3ef58c;
  --up-rgb: 62, 245, 140;
  --down: #ff5468;
  --down-rgb: 255, 84, 104;
  --magenta: #ff4d9d;
  --magenta-rgb: 255, 77, 157;
  --cyan: #56e8ff;

  --glow: 0 0 8px rgba(var(--accent-rgb), 0.35);
  --scheme: dark;

  /* structure: a screen, not paper */
  --radius: 0px;
  --line-w: 1px;
  --card-shadow: none;
  --crt-opacity: 1;
  --well: rgba(0, 0, 0, 0.45);
  --well-soft: rgba(0, 0, 0, 0.28);
  --track-bg: rgba(0, 0, 0, 0.35);
}

/* ── amber — warm CRT, the monitor in the corner of a dark room ─────────── */
html[data-theme="amber"] {
  --bg: #0b0703;
  --bg-2: #120c05;
  --bg-3: #080502;
  --bg-rgb: 11, 7, 3;
  --panel: rgba(21, 14, 6, 0.82);
  --panel-solid: #120c07;
  --scrim: rgba(9, 5, 2, 0.78);
  --tip-bg: rgba(24, 15, 7, 0.97);

  --accent-rgb: 255, 176, 64;
  --green: rgb(var(--accent-rgb));
  --green-deep: #ff8c1a;
  --green-deep-rgb: 255, 140, 26;

  --ink: #ffe3b8;
  --dim: #9a7440;
  --dimmer: #5b4325;
  --line: rgba(var(--accent-rgb), 0.2);
  --line-hot: rgba(var(--accent-rgb), 0.6);

  --amber: #ffd479;
  --amber-rgb: 255, 212, 121;
  --red: #ff5f5f;
  --red-rgb: 255, 95, 95;

  --up: #7fd06a;
  --up-rgb: 127, 208, 106;
  --down: #ff6b52;
  --down-rgb: 255, 107, 82;
  --magenta: #ff7ab8;
  --magenta-rgb: 255, 122, 184;
  --cyan: #7fd9d0;

  --glow: 0 0 8px rgba(var(--accent-rgb), 0.35);
  --scheme: dark;

  --radius: 2px;
  --line-w: 1px;
  --card-shadow: none;
  --crt-opacity: 1;
  --well: rgba(0, 0, 0, 0.45);
  --well-soft: rgba(0, 0, 0, 0.28);
  --track-bg: rgba(0, 0, 0, 0.35);
}

/* ── ice — cool blueprint, cyan on deep navy ────────────────────────────── */
html[data-theme="ice"] {
  --bg: #03070d;
  --bg-2: #061019;
  --bg-3: #020509;
  --bg-rgb: 3, 7, 13;
  --panel: rgba(9, 19, 30, 0.82);
  --panel-solid: #071320;
  --scrim: rgba(2, 6, 10, 0.76);
  --tip-bg: rgba(6, 16, 26, 0.97);

  --accent-rgb: 88, 196, 255;
  --green: rgb(var(--accent-rgb));
  --green-deep: #2aa8ff;
  --green-deep-rgb: 42, 168, 255;

  --ink: #cfe9ff;
  --dim: #4b7fa3;
  --dimmer: #2b4b63;
  --line: rgba(var(--accent-rgb), 0.2);
  --line-hot: rgba(var(--accent-rgb), 0.6);

  --amber: #ffc46b;
  --amber-rgb: 255, 196, 107;
  --red: #ff6b7a;
  --red-rgb: 255, 107, 122;

  --up: #4fdcb0;
  --up-rgb: 79, 220, 176;
  --down: #ff7b8f;
  --down-rgb: 255, 123, 143;
  --magenta: #c08bff;
  --magenta-rgb: 192, 139, 255;
  --cyan: #7ff0ff;

  --glow: 0 0 10px rgba(var(--accent-rgb), 0.42);
  --scheme: dark;

  /* soft glass: rounded corners, no CRT overlay */
  --radius: 9px;
  --vt-gap: 5px;   /* rounded chips need air */
  --line-w: 1px;
  --card-shadow: 0 14px 34px -22px rgba(0, 0, 0, 0.9);
  --crt-opacity: 0;
  --well: rgba(118, 200, 255, 0.06);
  --well-soft: rgba(118, 200, 255, 0.05);
  --track-bg: rgba(118, 200, 255, 0.07);
}

/* ice drifts: two slow radial glows behind the grid, pure CSS */
html[data-theme="ice"] body::before {
  content: "";
  position: fixed;
  inset: -20%;
  /* 0, not -1: body paints its own background, so a negative layer is invisible */
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(38% 34% at 18% 22%, rgba(var(--accent-rgb), 0.16), transparent 70%),
    radial-gradient(34% 30% at 82% 72%, rgba(var(--magenta-rgb), 0.12), transparent 72%);
  animation: drift 34s ease-in-out infinite alternate;
}
@keyframes drift {
  from { transform: translate3d(-2%, -1%, 0) scale(1); }
  to   { transform: translate3d(3%, 2%, 0) scale(1.08); }
}
@media (prefers-reduced-motion: reduce) {
  html[data-theme="ice"] body::before { animation: none; }
}

/* ── paper — printed sheet: square corners, 2px rules, hard shadow, no CRT ── */
html[data-theme="paper"] {
  --bg: #efe9da;
  --bg-2: #f7f2e7;
  --bg-3: #e6dfcf;
  --bg-rgb: 239, 233, 218;
  --panel: #fffdf6;
  --panel-solid: #fffdf6;
  --scrim: rgba(30, 26, 20, 0.45);
  /* tooltips are paper too: dark-on-dark was unreadable */
  --tip-bg: #fffdf6;
  --tip-ink: #17150f;

  --accent-rgb: 24, 22, 18;
  --green: rgb(var(--accent-rgb));
  --green-deep: #6b6250;
  --green-deep-rgb: 107, 98, 80;

  --ink: #17150f;
  --dim: #6a6353;
  --dimmer: #857d6a;
  --line: rgba(23, 21, 15, 0.3);
  --line-hot: rgba(23, 21, 15, 0.75);

  --amber: #a35c00;
  --amber-rgb: 163, 92, 0;
  --red: #b3261e;
  --red-rgb: 179, 38, 30;

  --up: #2f6b3a;
  --up-rgb: 47, 107, 58;
  --down: #a8322a;
  --down-rgb: 168, 50, 42;
  --magenta: #7d2b62;
  --magenta-rgb: 125, 43, 98;
  --cyan: #0b6473;

  --glow: none;
  --scheme: light;
  --radius: 0px;
  --line-w: 2px;
  --card-shadow: 5px 5px 0 rgba(23, 21, 15, 0.85);
  --crt-opacity: 0;
  --well: #ffffff;
  --well-soft: #faf6ec;
  --track-bg: rgba(23, 21, 15, 0.09);
}

/* flat sheet with a faint printed grid instead of a glowing field */
html[data-theme="paper"] body {
  background:
    repeating-linear-gradient(0deg, rgba(23, 21, 15, 0.035) 0 1px, transparent 1px 26px),
    repeating-linear-gradient(90deg, rgba(23, 21, 15, 0.035) 0 1px, transparent 1px 26px),
    var(--bg);
}

/* cards sit on the sheet: no blur, hard edge, no glow */
html[data-theme="paper"] .card,
html[data-theme="paper"] .panel,
html[data-theme="paper"] .readout,
html[data-theme="paper"] .nodeform {
  backdrop-filter: none;
  border-color: var(--line-hot);
}
html[data-theme="paper"] .card:hover { transform: translate(-1px, -1px); }

/* masthead: the ASCII art is a screen thing, paper gets type */
html[data-theme="paper"] .hero .logo { display: none; }
html[data-theme="paper"] .hero::before {
  content: attr(data-wordmark);
  display: block;
  font-size: clamp(38px, 7vw, 62px);
  line-height: 0.9;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 0 0 12px;
}
html[data-theme="paper"] .hero {
  border-bottom: var(--line-w) solid var(--ink);
  padding-bottom: 14px;
  margin-bottom: 22px;
}
html[data-theme="paper"] .prompt {
  background: var(--ink);
  color: var(--bg);
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px 9px;
}
html[data-theme="paper"] .prompt { color: var(--bg); }
html[data-theme="paper"] .prompt .typed { color: var(--bg); }
html[data-theme="paper"] .caret { color: var(--bg); }
html[data-theme="paper"] .prompt .user { color: #ffd0e2; }
html[data-theme="paper"] .prompt .path { color: #bfe9f2; }
html[data-theme="paper"] .prompt .dim { color: rgba(239, 233, 218, 0.6); }
html[data-theme="paper"] .tagline { color: var(--dim); margin-top: 10px; }

/* the view/toggle squares read as ink chips on paper */
html[data-theme="paper"] .tippy-box[data-theme~="bsp"] {
  /* no frame, and the offset lives in a drop-shadow so it follows the arrow
     silhouette instead of ending in a straight edge behind it */
  border-width: 0;
  --tip-nudge: 0px;
  box-shadow: none;
  /* soft, so nothing reads as a frame; drop-shadow follows the arrow */
  filter: drop-shadow(0 5px 10px rgba(23, 21, 15, 0.3));
}
/* the arrow is painted from `color`, so it has to become the tooltip surface */
html[data-theme="paper"] .tippy-box[data-theme~="bsp"] .tippy-arrow { color: var(--tip-bg); }
html[data-theme="paper"] .tippy-box[data-theme~="bsp"] .tip-dim { color: #6a6353; }
html[data-theme="paper"] .vt.active { color: var(--bg); background: var(--ink); border-color: var(--ink); box-shadow: none; }
html[data-theme="paper"] .meter-fill { box-shadow: none; }

/* ── christmas — evergreen night, gold light, falling snow ──────────────── */
html[data-theme="christmas"] {
  --bg: #06110d;
  --bg-2: #0a1a13;
  --bg-3: #040c08;
  --bg-rgb: 6, 17, 13;
  --panel: rgba(10, 28, 20, 0.84);
  --panel-solid: #081710;
  --scrim: rgba(3, 9, 6, 0.78);
  --tip-bg: #0d2419;
  --tip-ink: #eaf5ec;

  --accent-rgb: 255, 209, 102;          /* gold: tree lights */
  --green: rgb(var(--accent-rgb));
  --green-deep: #d4a537;
  --green-deep-rgb: 212, 165, 55;

  --ink: #eaf5ec;
  --dim: #8fbb9c;   /* lifted: evergreen eats contrast */
  --dimmer: #4a6f59;
  --line: rgba(var(--accent-rgb), 0.22);
  --line-hot: rgba(var(--accent-rgb), 0.6);

  --amber: #ff9f1c;
  --amber-rgb: 255, 159, 28;
  --red: #ff4d4d;                        /* berry red */
  --red-rgb: 255, 77, 77;

  --up: #63d98a;
  --up-rgb: 99, 217, 138;
  --down: #ff6b6b;
  --down-rgb: 255, 107, 107;
  --magenta: #ff7ab8;
  --magenta-rgb: 255, 122, 184;
  --cyan: #8fe3d0;

  --glow: 0 0 10px rgba(var(--accent-rgb), 0.35);
  --scheme: dark;

  --radius: 10px;
  --vt-gap: 5px;
  --line-w: 1px;
  --card-shadow: 0 16px 34px -24px rgba(0, 0, 0, 0.95);
  --crt-opacity: 0;
  --well: rgba(255, 209, 102, 0.05);
  --well-soft: rgba(255, 209, 102, 0.04);
  --track-bg: rgba(255, 209, 102, 0.07);
}

/* a low evergreen halo behind everything */
html[data-theme="christmas"] body::before {
  content: "";
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(42% 38% at 12% 8%, rgba(255, 209, 102, 0.09), transparent 70%),
    radial-gradient(40% 36% at 88% 88%, rgba(255, 77, 77, 0.07), transparent 72%);
}

/* snow needs a heavier hand than the rain's 0.3 */
html[data-theme="christmas"] #rain { opacity: 0.85; }

/* garland under the masthead: red / gold / evergreen, no content change */
html[data-theme="christmas"] .hero {
  border-bottom: 3px solid transparent;
  border-image: repeating-linear-gradient(
      90deg,
      #c20505 0 14px,
      #ffffff 14px 28px,
      #2f7d52 28px 42px
    )
    3;
  padding-bottom: 14px;
  margin-bottom: 20px;
}


/* ── plain-dark / plain-light — the no-costume pair ────────────────────────────────
 * Palette taken from Beszel's own themes (internal/site/src/index.css): its
 * neutral sheets, near-black ink, green(140)/red-600/orange-600 status family.
 * No glow, no tint, muted slate-blue accent.
 */

/* ── plain-dark — normal dark ──────────────────────────────────────────── */
html[data-theme="plain-dark"] {
  --bg: #161718;          /* beszel dark bg (hsl 220 5.5% 9%) */
  --bg-2: #191a1c;        /* beszel dark card (10.5%) */
  --bg-3: #131415;
  --bg-rgb: 22, 23, 24;
  --panel: #191a1c;
  --panel-solid: #191a1c;
  --scrim: rgba(10, 10, 11, 0.7);
  --tip-bg: #232527;
  --tip-ink: #f7f7f8;

  --accent-rgb: 149, 169, 198;
  --green: rgb(var(--accent-rgb));
  --green-deep: #7e96b8;
  --green-deep-rgb: 126, 150, 184;

  /* contrast on --bg: ink 16.8 · dim 7.7 · dimmer 4.7 · accent 7.5 · up 8.9 · down 6.5 */
  --ink: #f7f7f8;
  --dim: #a7aaae;
  --dimmer: #808389;
  --line: rgba(247, 247, 248, 0.14);
  --line-hot: rgba(247, 247, 248, 0.38);

  /* status: beszel green-400 / red-400 / orange-400 */
  --up: #67cb88;
  --up-rgb: 103, 203, 136;
  --down: #f87171;
  --down-rgb: 248, 113, 113;
  --amber: #fb923c;
  --amber-rgb: 251, 146, 60;
  --red: #f87171;
  --red-rgb: 248, 113, 113;
  --magenta: #c9a7f0;
  --magenta-rgb: 201, 167, 240;
  --cyan: #7fb8c9;

  --glow: none;
  --scheme: dark;

  --radius: 6px;
  --line-w: 1px;
  --vt-gap: 5px;          /* rounded chips need air */
  --card-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  --crt-opacity: 0;
  --well: #131415;
  --well-soft: #191b1d;
  --track-bg: rgba(247, 247, 248, 0.12);
}

/* ── plain-light — normal light ──────────────────────────────────────────── */
html[data-theme="plain-light"] {
  --bg: #fafaf9;          /* beszel light bg (hsl 30 8% 98%) */
  --bg-2: #ffffff;        /* beszel light card */
  --bg-3: #f2f1ef;
  --bg-rgb: 250, 250, 249;
  --panel: #ffffff;
  --panel-solid: #ffffff;
  --scrim: rgba(26, 26, 26, 0.35);
  --tip-bg: #ffffff;
  --tip-ink: #1a1a1a;

  --accent-rgb: 63, 98, 166;
  --green: rgb(var(--accent-rgb));
  --green-deep: #2f4d85;
  --green-deep-rgb: 47, 77, 133;

  /* contrast on --bg: ink 16.7 · dim 6.7 · dimmer 5.1 · accent 5.7 · up 5.7 · down 4.6 */
  --ink: #1a1a1a;
  --dim: #5c5957;
  --dimmer: #6f6b67;
  --line: rgba(26, 26, 26, 0.14);
  --line-hot: rgba(26, 26, 26, 0.42);

  /* status: beszel green-700 / red-600 / orange-600 */
  --up: #23713d;
  --up-rgb: 35, 113, 61;
  --down: #dc2626;
  --down-rgb: 220, 38, 38;
  --amber: #c2410c;
  --amber-rgb: 194, 65, 12;
  --red: #dc2626;
  --red-rgb: 220, 38, 38;
  --magenta: #7a3e9d;
  --magenta-rgb: 122, 62, 157;
  --cyan: #17707a;

  --glow: none;
  --scheme: light;

  --radius: 6px;
  --line-w: 1px;
  --vt-gap: 5px;          /* rounded chips need air */
  --card-shadow: 0 1px 2px rgba(26, 26, 26, 0.08);
  --crt-opacity: 0;
  --well: #ffffff;
  --well-soft: #f7f6f4;
  --track-bg: rgba(26, 26, 26, 0.09);
}

html[data-theme="plain-dark"] body { background: var(--bg); }
html[data-theme="plain-light"] body { background: var(--bg); }

/* masthead stays accent-coloured like the settings preview; only the glow goes */
[data-theme^="plain"] .hero .logo,
[data-theme^="plain"] .logo-preview { color: var(--green); }
[data-theme^="plain"] .hero .logo { text-shadow: none; }
[data-theme^="plain"] .vt.active {
  box-shadow: none;
}

html[data-theme="plain-light"] .card,
html[data-theme="plain-light"] .panel,
html[data-theme="plain-dark"] .card,
html[data-theme="plain-dark"] .panel {
  backdrop-filter: none;
}
