/* Themes. A theme is a set of values for the variables the screens read (the
   "tokens"), and optionally a list of decor ornaments switched on with
   data-decor. Every rule below that isn't a theme's token block reads only
   tokens, so an Operator's own theme (a validated set of the same tokens, served
   as /themes/<id>.css) restyles every surface without writing any CSS
   (docs/DESIGN.md §5.6). Loaded after app.css, so it wins at equal specificity. */

@font-face { font-family: "Lilita One"; font-weight: 400; font-display: swap; src: url("/static/fonts/lilita-one.woff2") format("woff2"); }
@font-face { font-family: "Nunito"; font-weight: 600 900; font-display: swap; src: url("/static/fonts/nunito.woff2") format("woff2"); }
@font-face { font-family: "Dela Gothic One"; font-weight: 400; font-display: swap; src: url("/static/fonts/dela-gothic-one.woff2") format("woff2"); }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 500; font-display: swap; src: url("/static/fonts/zen-maru-gothic-500.woff2") format("woff2"); }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 700; font-display: swap; src: url("/static/fonts/zen-maru-gothic-700.woff2") format("woff2"); }
@font-face { font-family: "Zen Maru Gothic"; font-weight: 900; font-display: swap; src: url("/static/fonts/zen-maru-gothic-900.woff2") format("woff2"); }
@font-face { font-family: "Michroma"; font-weight: 400; font-display: swap; src: url("/static/fonts/michroma.woff2") format("woff2"); }
@font-face { font-family: "Jura"; font-weight: 300 700; font-display: swap; src: url("/static/fonts/jura.woff2") format("woff2"); }

/* ── Pop Over: navy and teal, yellow and pink, chunky borders, hard shadows ── */
:root, [data-theme="popover"] {
  --bg: #0a0a2e; --surface: #14144a; --surface2: #1a1a5e;
  --text: #ffffff; --muted: #a9baf2; --line: #00c4b4; --border: #2b2b8a;
  --accent: #ff3d7f; --accent-text: #ffffff;
  --a1: #ffe600; --a2: #00c4b4; --a3: #ff3d7f;
  --danger: #ff7a98; --ok: #3ce08a;
  --input-bg: #ffffff; --input-text: #0a0a2e;
  --bubble-bg: #fffde7; --bubble-text: #0a0a2e; --bubble-border: #000000;
  --bw: 3px; --radius: 12px; --r: 12px; --r-btn: 40px;
  --shadow: 4px 4px 0 rgba(0, 196, 180, .35);
  --btn-shadow: 3px 3px 0 rgba(0, 0, 0, .35);
  --text-shadow: 2px 2px 0 rgba(0, 0, 0, .4);
  --bubble-shadow: .35vw .35vw 0 rgba(0, 0, 0, .4);
  --font-display: "Lilita One", "Fredoka One", system-ui, sans-serif;
  --font-body: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display-weight: 400; --body-weight: 700;
  color-scheme: dark;
}
/* what follows from the tokens, unless a theme says otherwise */
:root, [data-theme] {
  --hero: linear-gradient(135deg, var(--surface), var(--surface2) 50%, var(--surface));
  --scan: 0;
}

/* ── Midnight Neon: dark violet, cyan and magenta, thin lines, no shadows ── */
[data-theme="neon"] {
  --bg: #0e0a1a; --surface: #181230; --surface2: #221a42;
  --text: #f1ecff; --muted: #a99fd0; --line: #34295e; --border: #34295e;
  --accent: #ff3ea5; --accent-text: #ffffff;
  --a1: #ffd84a; --a2: #27e1ff; --a3: #ff3ea5;
  --danger: #ff5c6c; --ok: #46e08f;
  --input-bg: #0b0718; --input-text: #f1ecff;
  --bubble-bg: #1c1536; --bubble-text: #f1ecff; --bubble-border: #5a4a9a;
  --bw: 1px; --radius: 10px; --r: 10px; --r-btn: 10px;
  --shadow: none; --btn-shadow: none; --text-shadow: none; --bubble-shadow: none;
  --font-display: system-ui, -apple-system, "Segoe UI", sans-serif; --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --display-weight: 800; --body-weight: 600;
  color-scheme: dark;
}

/* ── Daylight: warm paper, navy ink, serif headings ── */
[data-theme="daylight"] {
  --bg: #f6f1e7; --surface: #ffffff; --surface2: #efe6d3;
  --text: #1b2433; --muted: #5c6678; --line: #1f3a5f; --border: #d9cdb4;
  --accent: #b23a0c; --accent-text: #ffffff;
  --a1: #8f5700; --a2: #1f6f8b; --a3: #b23a0c;
  --danger: #b91c1c; --ok: #15803d;
  --input-bg: #ffffff; --input-text: #1b2433;
  --bubble-bg: #fffdf6; --bubble-text: #1b2433; --bubble-border: #1f3a5f;
  --bw: 2px; --radius: 8px; --r: 8px; --r-btn: 8px;
  --shadow: 3px 3px 0 rgba(31, 58, 95, .2); --btn-shadow: 2px 2px 0 rgba(31, 58, 95, .25); --text-shadow: none;
  --bubble-shadow: .3vw .3vw 0 rgba(31, 58, 95, .3);
  --font-display: Georgia, "Times New Roman", serif; --font-body: system-ui, -apple-system, "Segoe UI", sans-serif;
  --display-weight: 700; --body-weight: 600;
  color-scheme: light;
}

/* ── Manga: red, navy ink and cream, hard ink shadows, sunburst and halftone ── */
[data-theme="manga"] {
  --bg: #f4ebd0; --surface: #fff8e1; --surface2: #f8e6be;
  --text: #1b2150; --muted: #4f5380; --line: #1b2150; --border: #9b9bb8;
  --accent: #c8281f; --accent-text: #ffffff;
  --a1: #c8281f; --a2: #1b2150; --a3: #d6322a;
  --danger: #b3201a; --ok: #1f7a4d;
  --input-bg: #ffffff; --input-text: #1b2150;
  --bubble-bg: #ffffff; --bubble-text: #1b2150; --bubble-border: #1b2150;
  --bw: 3px; --radius: 4px; --r: 4px; --r-btn: 4px;
  --shadow: 5px 5px 0 #1b2150; --btn-shadow: 3px 3px 0 #1b2150; --text-shadow: 2px 2px 0 rgba(27, 33, 80, .25);
  --bubble-shadow: .4vw .4vw 0 #1b2150;
  --font-display: "Dela Gothic One", "Zen Maru Gothic", sans-serif; --font-body: "Zen Maru Gothic", system-ui, sans-serif;
  --display-weight: 400; --body-weight: 700;
  color-scheme: light;
}

/* ── Republic: pink, off-white and pale blue with black, ruled lines, lowercase ── */
[data-theme="republic"] {
  --bg: #f1eee3; --surface: #ffffff; --surface2: #bfe3f2;
  --text: #1b1b26; --muted: #4a4a5e; --line: #1b1b26; --border: #8d99a3;
  --accent: #ff2e93; --accent-text: #1b1b26;
  --a1: #1b1b26; --a2: #0a5fa8; --a3: #d4146f;
  --danger: #d11c3a; --ok: #0e8a4f;
  --input-bg: #ffffff; --input-text: #1b1b26;
  --bubble-bg: #f1eee3; --bubble-text: #1b1b26; --bubble-border: #1b1b26;
  --bw: 3px; --radius: 18px; --r: 18px; --r-btn: 18px;
  --shadow: none; --btn-shadow: none; --text-shadow: none; --bubble-shadow: none;
  --font-display: "Michroma", "Jura", sans-serif; --font-body: "Jura", system-ui, sans-serif;
  --display-weight: 400; --body-weight: 700;
  color-scheme: light;
}

/* ── Everything below reads tokens only ── */
body { font-family: var(--font-body); font-weight: var(--body-weight); }
h1, h2, .brand, button, .button { font-family: var(--font-display); font-weight: var(--display-weight); letter-spacing: .03em; }
h1 { color: var(--a1); text-shadow: var(--text-shadow); }
h2 { color: var(--a2); }
a { color: var(--a2); }
.site-header { background: var(--hero); border-bottom: calc(var(--bw) + 1px) solid var(--a2); }
.brand { color: var(--a1); font-size: 1.4rem; text-shadow: var(--text-shadow); }
.card, fieldset {
  background: linear-gradient(135deg, var(--surface2), var(--surface));
  border: var(--bw) solid var(--line); border-radius: var(--r); box-shadow: var(--shadow);
}
input, select, textarea {
  border: var(--bw) solid var(--line); border-radius: var(--r-btn); padding: 9px 16px;
  background: var(--input-bg); color: var(--input-text); font-weight: 800;
}
input:focus { border-color: var(--a1); }
textarea { border-radius: var(--r); }
input[type=checkbox], input[type=radio] { accent-color: var(--accent); }
/* The template's stylesheet makes every input full width except checkboxes. */
input[type=radio] { display: inline; width: auto; margin: 0; padding: 0; }
button, .button { border: var(--bw) solid var(--accent); border-radius: var(--r-btn); box-shadow: var(--btn-shadow); }
button.secondary, .button.secondary { color: var(--a1); border-color: var(--line); box-shadow: none; }
button.link { box-shadow: none; border: 0; font-family: var(--font-body); font-weight: 800; color: var(--a2); }
button:hover, .button:hover { filter: brightness(1.08); }
.badge { border: 2px solid var(--a2); color: var(--a2); font-weight: 800; }
.flash, .notice { background: var(--surface2); border: var(--bw) solid var(--a1); }
.site-footer { color: var(--muted); }
.site-header .user-menu .menu { border: var(--bw) solid var(--line); box-shadow: var(--shadow); }
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9999;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, var(--scan)) 2px, rgba(0, 0, 0, var(--scan)) 4px);
}
a.button { color: var(--accent-text); text-decoration: none; }
a.button.secondary { color: var(--a1); }
.badge.live { border-color: var(--ok); color: var(--ok); }
.join-code { font-family: var(--font-display); color: var(--a1); text-shadow: var(--text-shadow); letter-spacing: .12em; }
.join-code.big { font-size: 3rem; margin: 0; line-height: 1; }
.brand-logo { display: block; max-height: 44px; max-width: 220px; width: auto; height: auto; }

/* ── Decor: ornaments an Operator can switch on; a theme lists the ones it uses ── */
[data-decor~="scanlines"] { --scan: .07; }
[data-decor~="sunburst"] { --hero: repeating-conic-gradient(from 0deg at 50% 50%, var(--bg) 0 7.5deg, var(--surface2) 7.5deg 15deg); }
[data-decor~="ruled"] {
  --hero: radial-gradient(circle at 5px 5px, var(--a2) 2.4px, transparent 3px) 0 100% / 10px 20px repeat-x,
          repeating-linear-gradient(0deg, var(--line) 0 1px, transparent 1px 4px) 0 0 / 100% 16px no-repeat, var(--bg);
}
[data-decor~="halftone"] .site-header, [data-decor~="halftone"] #card, [data-decor~="halftone"] body.info #stage {
  background-image: radial-gradient(circle, color-mix(in srgb, var(--line) 28%, transparent) 1.2px, transparent 1.7px), var(--hero);
  background-size: 7px 7px, auto;
}
[data-decor~="lowercase"] h1, [data-decor~="lowercase"] h2, [data-decor~="lowercase"] .brand,
[data-decor~="lowercase"] button, [data-decor~="lowercase"] .button, [data-decor~="lowercase"] .badge { text-transform: lowercase; }
[data-decor~="tilt"] .card:nth-of-type(odd) { transform: rotate(-.4deg); }
[data-decor~="tilt"] .card:nth-of-type(even) { transform: rotate(.3deg); }
@media (prefers-reduced-motion: reduce), (prefers-contrast: more) {
  [data-decor~="scanlines"] { --scan: 0; }
  [data-decor~="tilt"] .card { transform: none; }
}

/* Karaoketron screens */
.join-grid { display: flex; gap: 32px; align-items: center; flex-wrap: wrap; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.qr-box .qr { width: 220px; height: 220px; }

/* Session Control */
kt-control { display: block; }
.kt-playing .actions { margin-top: 12px; }
.kt-queue { list-style: decimal inside; margin: 0; padding: 0; }
.kt-queue li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 2px dashed var(--border); }
.kt-queue li:last-child { border-bottom: 0; }
.kt-entry { min-width: 0; overflow-wrap: anywhere; }
.kt-queue .actions { flex: none; flex-wrap: nowrap; }
.kt-queue .actions button { padding: 4px 10px; }
.kt-recent { margin: 0; padding-left: 20px; }
.kt-result { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 2px dashed var(--border); }
.kt-result img { width: 96px; height: 54px; object-fit: cover; border-radius: 6px; background: var(--border); }
@media (max-width: 560px) { .kt-result { grid-template-columns: 64px 1fr auto; } .kt-result img { width: 64px; height: 36px; } }
.kt-live { float: right; }
.kt-display { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 8px 0; border-bottom: 2px dashed var(--border); }
.kt-edit { padding: 12px; margin: 4px 0 8px; border: 2px dashed var(--border); border-radius: var(--radius); }
.kt-events { list-style: none; margin: 0; padding: 0; font-size: .95rem; }
.kt-events li { padding: 4px 0; border-bottom: 2px dashed var(--border); overflow-wrap: anywhere; }
.kt-events li:last-child { border-bottom: 0; }

/* The theme editor */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; align-items: start; }
@media (max-width: 860px) { .editor { grid-template-columns: 1fr; } }
.editor-preview { position: sticky; top: 12px; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; }
.swatch { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .9rem; }
.swatch input[type=color] { width: 44px; height: 32px; padding: 0; border: var(--bw) solid var(--line); border-radius: 6px; background: none; flex: none; }
.preview { background: var(--bg); color: var(--text); font-family: var(--font-body); font-weight: var(--body-weight); border: 2px dashed var(--border); border-radius: var(--r); overflow: hidden; }
.preview .site-header { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; gap: 10px; flex-wrap: wrap; }
.preview-body { padding: 14px; }
.preview-bubble { display: inline-block; padding: .5em .9em; border: var(--bw) solid var(--bubble-border); border-radius: calc(var(--r) * 1.4); background: var(--bubble-bg); color: var(--bubble-text); box-shadow: var(--bubble-shadow); }
.preview-bubble b { display: block; font-family: var(--font-display); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: var(--a3); }
.preview-bubble small { opacity: .65; }
.forget summary { cursor: pointer; margin: 8px 0; }

/* The join-code form on the home page. */
.join-form { margin: 20px auto; max-width: 420px; }
.join-form .row { display: flex; gap: 10px; align-items: stretch; }
.join-form input { flex: 1; min-width: 0; margin: 0; text-align: center; letter-spacing: .12em; font-size: 1.15em; }
.join-form button { flex: none; }
