/* theme.css — canonical design tokens for jdbb studio ("Terminal Folio").
 *
 * This file is the ONE source of truth for color/type tokens. Pages link it
 * ahead of their page CSS; the legacy :root blocks in style.css / admin.html /
 * landing.html were removed in favor of this file.
 *
 * System rules (see docs/DESIGN-SYSTEM.md):
 *  - cardless ledger: hairline rules + whitespace + aligned columns, no boxes
 *  - zero border-radius, zero shadows, zero gradients
 *  - one filled accent button per page; all other actions are underlined links
 *  - tags are plain bracketed mono text, never pills
 */

:root {
  /* Process palette — light */
  --bg: #F7F9FA;
  --surface: #FFFFFF;          /* modals + overlays only, not section cards */
  --border: #DCE3E8;
  --border-strong: #0E1116;    /* 1px strong section rules */
  --text: #0E1116;
  --text-secondary: #5D6B76;
  --text-muted: #8A97A1;

  --accent: #007699;           /* process cyan, contrast-safe as text on --bg */
  --accent-fill: #00A8E0;      /* the ONE filled button per page */
  --accent-fill-hover: #0090C4;
  --accent-fill-active: #007FAD;
  --fill-text: #0E1116;        /* text on --accent-fill */

  --green: #2F7D4F;
  --red: #B3261E;
  --yellow: #8A6A00;
  --orange: #A45A00;
  --blue: var(--accent);

  /* Legacy vars kept so existing page CSS keeps working; recalibrated. */
  --badge-green-bg: transparent;
  --badge-red-bg: transparent;
  --badge-yellow-bg: transparent;
  --badge-dim-bg: #EDF1F4;     /* progress tracks etc. */
  --progress-bg: #EDF1F4;
  --toggle-bg: #EDF1F4;
  --hover-tint: rgba(0, 150, 199, 0.05);
  --modal-backdrop: rgba(14, 17, 22, 0.35);
  --theme-bg: var(--bg);

  /* Decorative layers from the old design: retired. */
  --noise-opacity: 0;
  --grid-color: transparent;
  --gradient-wash: none;

  --radius: 0;

  /* Type. The header selector switches both aliases via html[data-font]. */
  --mono: "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  --body: "Inter", -apple-system, "Helvetica Neue", Arial, sans-serif;
  --font-size-adjust: none;
}

html.dark {
  --bg: #0C0E12;
  --surface: #12151B;
  --border: #232833;
  --border-strong: #3A404D;
  --text: #E8E6E1;
  --text-secondary: #8B909A;
  --text-muted: #6A707B;

  --accent: #3BC3F2;
  --accent-fill: #00A8E0;
  --accent-fill-hover: #26B7E8;
  --accent-fill-active: #0090C4;
  --fill-text: #0C0E12;

  --green: #6BBF73;
  --red: #E5484D;
  --yellow: #D5A021;
  --orange: #D07830;

  --badge-dim-bg: #1A1E26;
  --progress-bg: #1A1E26;
  --toggle-bg: #1A1E26;
  --hover-tint: rgba(59, 195, 242, 0.06);
  --modal-backdrop: rgba(0, 0, 0, 0.6);
  --theme-bg: var(--bg);
}

/* ---- Site font choices (the header selector switches these) ---- */
html[data-font="jetbrains"] { --mono: "JetBrains Mono", "SFMono-Regular", Menlo, monospace; --body: "JetBrains Mono", "SFMono-Regular", Menlo, monospace; }
html[data-font="martian"]   { --mono: "Martian Mono", "SFMono-Regular", Menlo, monospace;   --body: "Martian Mono", "SFMono-Regular", Menlo, monospace; --font-size-adjust: 0.52; }
html[data-font="plex"]      { --mono: "IBM Plex Sans", -apple-system, sans-serif;           --body: "IBM Plex Sans", -apple-system, sans-serif; }
html[data-font="geist"]     { --mono: "Geist", -apple-system, sans-serif;                   --body: "Geist", -apple-system, sans-serif; }
html[data-font="literata"]  { --mono: "Literata", Georgia, serif;                           --body: "Literata", Georgia, serif; }
html[data-font="ibm-serif"] { --mono: "IBM Plex Serif", Georgia, serif;                     --body: "IBM Plex Serif", Georgia, serif; }
html[data-font="source-serif"] { --mono: "Source Serif 4", Georgia, serif;                  --body: "Source Serif 4", Georgia, serif; }
html[data-font="newsreader"] { --mono: "Newsreader", Georgia, serif;                        --body: "Newsreader", Georgia, serif; }

/* ---- Base ---- */
html { background: var(--bg); font-size-adjust: var(--font-size-adjust); }

/* Old decorative layers, neutralized wherever pages still carry the markup. */
.grid-lines { display: none !important; }
body::before, body::after { display: none !important; }

/* ---- Shared masthead (header bar used on every surface) ---- */
.jdbb-masthead {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 18px 0 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--mono);
}
.jdbb-wordmark {
  font-family: var(--mono); font-size: 15px; font-weight: 700;
  letter-spacing: 0.02em; color: var(--text); text-decoration: none;
  white-space: nowrap;
}
.jdbb-wordmark .bracket { color: var(--accent); font-weight: 700; }
.jdbb-wordmark .kj { letter-spacing: -0.08em; }
html[data-font="literata"] .jdbb-wordmark .kj,
html[data-font="ibm-serif"] .jdbb-wordmark .kj,
html[data-font="source-serif"] .jdbb-wordmark .kj,
html[data-font="newsreader"] .jdbb-wordmark .kj { letter-spacing: 0; }
.jdbb-wordmark .studio { color: var(--text-secondary); font-weight: 400; margin-left: 0.45em; }
.jdbb-masthead nav { display: flex; align-items: center; gap: 1.4rem; }
.jdbb-masthead nav a {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-secondary); text-decoration: none;
}
.jdbb-masthead nav a:hover { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }

/* Status strip under the masthead */
.jdbb-statusline {
  display: flex; justify-content: space-between; gap: 1rem;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--text-muted);
}
.jdbb-statusline .ok { color: var(--green); }

/* ---- Theme bar (font selector + dark toggle), plain text controls ---- */
.theme-bar {
  position: relative;
  display: flex; align-items: center; gap: 0.65rem;
  font-family: var(--mono); font-size: 12px; color: var(--text-secondary);
  background: none; border: none; border-radius: 0; box-shadow: none; padding: 0;
}
.theme-bar .font-name {
  width: 146px; min-width: 146px;
  border: none; background: none; border-radius: 0; box-shadow: none;
  padding: 0; color: var(--text-secondary); cursor: pointer;
  font-family: var(--mono); font-size: 12px; text-align: left; white-space: nowrap;
}
.theme-bar .font-name:hover { color: var(--text); }
.theme-bar .font-name::before { content: "Aa "; color: var(--text-muted); }
.theme-bar .font-name::after { content: " \25BE"; color: var(--text-muted); }
.theme-bar .font-options {
  display: none;
  position: absolute; top: calc(100% + 9px); right: 18px; z-index: 80;
  box-sizing: border-box;
  width: 330px; padding: 14px 16px;
  background: var(--surface);
  border-top: 1px solid var(--border-strong);
  border-bottom: 1px solid var(--border-strong);
}
.theme-bar.expanded .font-options { display: block; }
.theme-bar.expanded .font-name::after { content: " \25B4"; }
.theme-opt-group + .theme-opt-group {
  margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border);
}
.theme-opt-label {
  padding: 0 0 8px;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
}
.theme-opt {
  --opt-name-size: 16px;
  --opt-sample-size: 17px;
  display: block; width: 100%;
  border: none; background: none; padding: 7px 0; border-radius: 0; box-shadow: none;
  color: var(--text-secondary); cursor: pointer; text-align: left;
}
.theme-opt-main {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-family: var(--mono); font-size: var(--opt-name-size); white-space: nowrap;
}
.theme-current { color: var(--accent); font-size: 12px; }
.theme-sample {
  display: block; margin-top: 2px;
  font-size: var(--opt-sample-size); line-height: 1.22; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.theme-opt[data-font="jetbrains"] { --opt-name-size: 14px; --opt-sample-size: 14px; }
.theme-opt[data-font="martian"] { --opt-name-size: 13px; --opt-sample-size: 13px; }
.theme-opt[data-font="plex"] { --opt-name-size: 16px; --opt-sample-size: 17px; }
.theme-opt[data-font="geist"] { --opt-name-size: 16px; --opt-sample-size: 17px; }
.theme-opt[data-font="literata"] { --opt-name-size: 16px; --opt-sample-size: 17px; }
.theme-opt[data-font="ibm-serif"] { --opt-name-size: 16px; --opt-sample-size: 17px; }
.theme-opt[data-font="source-serif"] { --opt-name-size: 16.5px; --opt-sample-size: 17.5px; }
.theme-opt[data-font="newsreader"] { --opt-name-size: 17px; --opt-sample-size: 18px; }
.theme-opt[data-font="jetbrains"] .theme-sample { font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace; }
.theme-opt[data-font="martian"] .theme-sample { font-family: "Martian Mono", "SFMono-Regular", Menlo, monospace; }
.theme-opt[data-font="plex"] .theme-sample { font-family: "IBM Plex Sans", -apple-system, sans-serif; }
.theme-opt[data-font="geist"] .theme-sample { font-family: "Geist", -apple-system, sans-serif; }
.theme-opt[data-font="literata"] .theme-sample { font-family: "Literata", Georgia, serif; }
.theme-opt[data-font="ibm-serif"] .theme-sample { font-family: "IBM Plex Serif", Georgia, serif; }
.theme-opt[data-font="source-serif"] .theme-sample { font-family: "Source Serif 4", Georgia, serif; }
.theme-opt[data-font="newsreader"] .theme-sample { font-family: "Newsreader", Georgia, serif; }
.theme-opt[data-font="jetbrains"] .theme-opt-name { font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace; }
.theme-opt[data-font="martian"] .theme-opt-name { font-family: "Martian Mono", "SFMono-Regular", Menlo, monospace; }
.theme-opt[data-font="plex"] .theme-opt-name { font-family: "IBM Plex Sans", -apple-system, sans-serif; }
.theme-opt[data-font="geist"] .theme-opt-name { font-family: "Geist", -apple-system, sans-serif; }
.theme-opt[data-font="literata"] .theme-opt-name { font-family: "Literata", Georgia, serif; }
.theme-opt[data-font="ibm-serif"] .theme-opt-name { font-family: "IBM Plex Serif", Georgia, serif; }
.theme-opt[data-font="source-serif"] .theme-opt-name { font-family: "Source Serif 4", Georgia, serif; }
.theme-opt[data-font="newsreader"] .theme-opt-name { font-family: "Newsreader", Georgia, serif; }
.theme-opt:hover .theme-opt-name { color: var(--text); text-decoration: underline; text-underline-offset: 3px; }
.theme-opt.active { color: var(--accent); }
.theme-opt.active .theme-sample { color: var(--text-secondary); }
.theme-sep { width: 1px; height: 14px; background: var(--border); }
.dark-btn {
  border: none; background: none; padding: 0; border-radius: 0;
  font-size: 14px; color: var(--text-secondary); cursor: pointer;
}
.dark-btn:hover { color: var(--text); }

/* ---- Ledger primitives ---- */
.kicker {
  font-family: var(--mono); font-size: 11px; font-weight: 600;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent);
}
.kicker::before { content: "// "; }
.tag {
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em;
  color: var(--text-secondary); white-space: nowrap;
  background: none; border: none; border-radius: 0; padding: 0;
}
.tag.ok { color: var(--green); }
.tag.warn { color: var(--accent); }
.tag.err { color: var(--red); }

hr.rule { border: none; border-top: 1px solid var(--border); margin: 0; }
hr.rule-strong { border: none; border-top: 1px solid var(--border-strong); margin: 0; }

/* The one filled button per page */
.btn-fill {
  font-family: var(--mono); font-size: 12px; font-weight: 600;
  letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--accent-fill); color: var(--fill-text);
  border: none; border-radius: 0; padding: 12px 24px; cursor: pointer;
  white-space: nowrap;
}
.btn-fill:hover { background: var(--accent-fill-hover); }
.btn-fill:active { background: var(--accent-fill-active); }

/* Text-link action (everything that is not the one filled button) */
.link-action {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.04em;
  color: var(--text); background: none; border: none; border-radius: 0;
  padding: 0; cursor: pointer; text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--text-muted);
}
.link-action:hover { text-decoration-color: var(--text); }
.link-action.accent { color: var(--accent); }
.link-action.danger { color: var(--red); }

/* Bare inputs: bottom rule only */
.input-bare {
  font-family: var(--mono); font-size: 14px; color: var(--text);
  background: none; border: none; border-bottom: 1px solid var(--border-strong);
  border-radius: 0; padding: 8px 2px; outline: none; width: 100%;
}
.input-bare::placeholder { color: var(--text-muted); }
.input-bare:focus { border-bottom-color: var(--accent); }

/* Bare progress line */
.progress-line { position: relative; height: 2px; background: var(--border); }
.progress-line > span { position: absolute; inset: 0 auto 0 0; background: var(--accent-fill); }
