/* Theme backgrounds + team brand kit (lib/themes.js, lib/team-brand.js, js/theme-layer.js).
   1. Session layer (projector + phones)  2. Projector dark stage  3. Editor picker (host)
   4. Team brand panel (host) — the admin section (js/admin/themes.js) injects its own styles
   The scrim strength (--qx-scrim) is computed on the server so every canvas text keeps 4.5:1. */

/* ── 1. Session layer ─────────────────────────────────────────────────────────────────── */
.qx-theme-layer { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden; background: #14161D; }
.qx-theme-layer img { display: block; width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .6s ease; }
.qx-theme-layer.is-loaded img { opacity: 1; }
.qx-theme-scrim { position: absolute; inset: 0; background: #14161D; opacity: var(--qx-scrim, .85); }
@media (prefers-reduced-motion: reduce) { .qx-theme-layer img { transition: none; } }
html.qx-themed { background: #14161D !important; }
html.qx-themed body,
html.qx-themed body.qx-canvas { background: transparent !important; background-image: none !important; }
/* phones: the full-screen states show the background (cards and tiles stay opaque) */
html.qx-themed .wait-screen,
html.qx-themed .q-screen,
html.qx-themed .result-screen,
html.qx-themed .final-screen { background: transparent; }
html.qx-themed .lb-preview { background: rgba(20, 22, 29, .72); }
.qx-theme-report {
  position: fixed; left: 50%; bottom: max(6px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 40;
  background: none; border: 0; padding: 8px 10px; min-height: 32px; font: 600 12px/1.2 var(--qx-font, system-ui, sans-serif);
  color: #C9CEDA; text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}
.qx-theme-report:disabled { text-decoration: none; cursor: default; }
.qx-theme-report:focus-visible { outline: 2px solid #C4A5FF; outline-offset: 2px; border-radius: 4px; }

/* brand slot on the projector: logo + name, QuizX mark only when the kit keeps it */
/* long school / organisation names: up to two balanced lines of whole words; screen-quiz.html
   (fitBrandName) shrinks the type until they fit, so nothing is cut mid-word */
.sq-brand-slot .qx-look-name {
  min-width: 0; max-width: min(64vw, 100%); white-space: normal; overflow-wrap: normal; word-break: normal; hyphens: manual;
  line-height: 1.12; text-wrap: balance; overflow: hidden;
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.sq-brand-slot img { flex-shrink: 0; }
.sq-brand-slot .qx-look-qx { display: inline-flex; align-items: center; margin-left: .6em; padding-left: .6em; border-left: 2px solid var(--qx-border); }
.sq-brand-slot .qx-look-qx .qx-logo__img { height: 1.1em; width: auto; }

/* ── 2. Projector dark stage (only while a theme is shown) ─────────────────────────────────
   The projector is light by default; the library art is drawn on dark grounds, so a themed
   session uses the dark ladder of quizx.css (same values, measured there) with the projector's
   type. Answer tiles are identical in both ladders. */
html[data-theme="projector"].qx-stage-dark {
  --qx-bg: #14161D; --qx-bg-2: #191C24; --qx-surface: #232732; --qx-surface-2: #313644; --qx-surface-3: #3E4454;
  --qx-text: #FFFFFF; --qx-muted: #C9CEDA; --qx-faint: #A2AAB9;
  --qx-border: #8791A5; --qx-border-2: #8791A5; --qx-keyline: #9AA3B4;
  --qx-success: #3FD68C; --qx-danger: #FF6B85; --qx-warning: #F5B301; --qx-info: #58BFFF;
  --qx-success-solid: #10693A; --qx-danger-solid: #B3122F;
  --qx-tile-dim: #3A3F4D; --qx-tile-dim-ink: #C9CEDA;
  --qx-state-ring: #FFFFFF; --qx-state-halo: rgba(255, 255, 255, .25);
  /* the projector uses --qx-accent-2 as TEXT (question label, timer, leaderboard): the light text accent here */
  --qx-accent: #6D3BF5; --qx-accent-2: #C4A5FF; --qx-accent-ink: #FFFFFF; --qx-accent-text: #C4A5FF; --qx-purple: #C4A5FF;
  --qx-green: var(--qx-success); --qx-blue: var(--qx-info); --qx-yellow: var(--qx-warning); --qx-red: var(--qx-danger);
  --qx-word-1: #46D39A; --qx-word-2: #A88BFF; --qx-word-3: #3EC2FF; --qx-word-4: #FFD700;
  --qx-word-5: #FF8FB0; --qx-word-6: #FFA94D; --qx-word-7: #C4A5FF; --qx-word-8: #5AE8F0;
  color-scheme: dark;
}
html.qx-stage-dark .sq-topbar { background: rgba(25, 28, 36, .92); }

/* ── 3. Editor picker (public/js/host/78-themes.js) ───────────────────────────────────────── */
.th-panel .eq-settings-body { gap: 8px; }
.th-current { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: rgba(255, 255, 255, .78); }
.th-current-thumb { width: 54px; height: 30px; border-radius: 6px; flex-shrink: 0; background: #14161D center/cover no-repeat; border: 1px solid rgba(255, 255, 255, .18); }
.th-open { width: 100%; justify-content: center; }
.th-current-thumb.is-none { background: #EDF0F3; }
.th-dialog { position: fixed; inset: 0; z-index: 3000; background: rgba(8, 9, 12, .72); display: flex; align-items: center; justify-content: center; padding: 16px; }
.th-sheet {
  background: #191C24; color: #fff; border: 1px solid #3E4454; border-radius: 16px; width: min(920px, 100%);
  max-height: min(88vh, 860px); display: flex; flex-direction: column; overflow: hidden; font-family: 'Plus Jakarta Sans', sans-serif;
}
.th-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px 10px; border-bottom: 1px solid #313644; }
.th-head h2 { font-size: 17px; font-weight: 900; margin: 0; flex: 1; }
.th-x { background: none; border: 0; color: #C9CEDA; font-size: 22px; line-height: 1; width: 44px; height: 44px; border-radius: 10px; cursor: pointer; }
.th-x:hover { background: #313644; color: #fff; }
.th-tools { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 16px; border-bottom: 1px solid #313644; }
.th-search { flex: 1 1 200px; min-width: 0; background: #232732; border: 1px solid #6B7488; color: #fff; border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 14px; }
.th-search:focus { outline: 2px solid #C4A5FF; outline-offset: 1px; }
.th-chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; flex: 1 1 100%; scrollbar-width: thin; }
.th-chip { flex-shrink: 0; background: #232732; border: 1px solid #6B7488; color: #E4E7EE; border-radius: 8px; padding: 7px 11px; min-height: 36px; font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.th-chip[aria-pressed="true"] { background: #F4F1EA; color: #14161D; border-color: #F4F1EA; }
.th-body { overflow-y: auto; padding: 12px 16px 16px; }
.th-group + .th-group { margin-top: 16px; }
.th-group h3 { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #A2AAB9; margin: 0 0 8px; }
.th-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.th-item { position: relative; width: 100%; display: flex; flex-direction: column; gap: 6px; background: none; border: 0; padding: 0; color: #E4E7EE; text-align: left; cursor: pointer; font: inherit; }
.th-thumb { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #0E1015; border: 2px solid #3E4454; }
.th-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.th-thumb .th-none { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800; color: #4A5163; background: #EDF0F3; }
.th-name { font-size: 13px; font-weight: 700; line-height: 1.25; }
.th-item:hover .th-thumb { border-color: #8791A5; }
.th-item:focus-visible { outline: none; }
.th-item:focus-visible .th-thumb { outline: 3px solid #C4A5FF; outline-offset: 2px; }
.th-item[aria-checked="true"] .th-thumb { border-color: #F4F1EA; box-shadow: 0 0 0 2px #F4F1EA; }
.th-item[aria-checked="true"] .th-name::before { content: "✓ "; }
.th-del { position: absolute; top: 6px; right: 6px; z-index: 1; width: 32px; height: 32px; border-radius: 8px; border: 0; background: rgba(20, 22, 29, .86); color: #FF8FA3; font-size: 15px; cursor: pointer; }
.th-del:focus-visible { outline: 2px solid #FF8FA3; }
.th-upload { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; width: 100%; aspect-ratio: 16 / 9; border-radius: 10px; border: 2px dashed #6B7488; background: #14161D; color: #E4E7EE; font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; padding: 8px; text-align: center; }
.th-upload small { font-weight: 600; color: #A2AAB9; font-size: 11px; }
.th-upload:disabled { cursor: progress; opacity: .7; }
.th-locked { border: 1px solid #3E4454; border-radius: 10px; padding: 12px; font-size: 13px; line-height: 1.45; color: #C9CEDA; background: #14161D; }
.th-locked a { color: #C4A5FF; font-weight: 800; }
.th-note { font-size: 12px; color: #A2AAB9; line-height: 1.4; margin: 6px 0 0; }
.th-empty { color: #A2AAB9; font-size: 13px; padding: 12px 0; }
@media (max-width: 600px) {
  .th-dialog { padding: 0; align-items: stretch; }
  .th-sheet { max-height: none; height: 100%; border-radius: 0; border: 0; }
  .th-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}

/* ── 4. Team brand panel (public/js/host/79-team-brand.js) ─────────────────────────────────── */
.tb-wrap { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 20px; align-items: start; max-width: 1080px; }
.tb-form { display: flex; flex-direction: column; gap: 16px; }
.tb-field label, .tb-label { display: block; font-size: 13px; font-weight: 800; color: #E4E7EE; margin-bottom: 6px; }
.tb-hint { font-size: 12px; color: #A2AAB9; margin-top: 5px; line-height: 1.4; }
.tb-input { width: 100%; background: #232732; border: 1px solid #6B7488; color: #fff; border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 15px; }
.tb-input:focus, .tb-color:focus-visible { outline: 2px solid #C4A5FF; outline-offset: 1px; }
.tb-input:disabled { opacity: .7; }
.tb-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tb-logo-box { width: 64px; height: 64px; border-radius: 12px; border: 1px solid #6B7488; background: #F4F1EA; display: flex; align-items: center; justify-content: center; overflow: hidden; flex-shrink: 0; color: #4A5163; font-size: 12px; font-weight: 800; }
.tb-logo-box img { max-width: 100%; max-height: 100%; object-fit: contain; }
.tb-color { width: 52px; height: 44px; padding: 2px; border: 1px solid #6B7488; border-radius: 10px; background: #232732; cursor: pointer; }
.tb-hex { width: 120px; font-family: ui-monospace, Menlo, monospace; }
.tb-swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.tb-swatch { width: 30px; height: 30px; border-radius: 8px; border: 2px solid #3E4454; cursor: pointer; }
.tb-swatch:focus-visible { outline: 2px solid #C4A5FF; outline-offset: 2px; }
.tb-contrast { font-size: 12px; color: #C9CEDA; line-height: 1.5; margin-top: 6px; }
.tb-contrast b { color: #fff; }
.tb-check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: #E4E7EE; line-height: 1.4; cursor: pointer; }
.tb-check input { width: 20px; height: 20px; margin-top: 1px; accent-color: #8B5CF6; flex-shrink: 0; }
.tb-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.tb-actions .btn { min-height: 44px; }
.tb-save { background: #F4F1EA; color: #14161D; }
.tb-reset { background: transparent; color: #FF8FA3; border: 1px solid #6B7488 !important; }
.tb-ghost { background: #313644; color: #fff; }
.tb-member { border: 1px solid #3E4454; background: #14161D; border-radius: 12px; padding: 12px 14px; font-size: 13px; color: #C9CEDA; line-height: 1.5; }
.tb-preview { display: flex; flex-direction: column; gap: 12px; }
.tb-wrap > [data-preview] { position: sticky; top: 12px; }
.tb-preview h3 { font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; color: #A2AAB9; margin: 0; }
.tb-prev-row { display: flex; gap: 12px; align-items: flex-end; }
/* projector mock: the real light projector ladder */
.tb-proj { flex: 1; min-width: 0; aspect-ratio: 16 / 9; border-radius: 10px; overflow: hidden; background: #EDF0F3; color: #14161D; border: 1px solid #3E4454; display: flex; flex-direction: column; font-family: 'Archivo', system-ui, sans-serif; }
.tb-proj-bar { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 5% 4% 3%; background: #E3E8ED; border-bottom: 1px solid #B8C1CC; font-weight: 900; font-size: clamp(9px, 1.6vw, 14px); }
.tb-proj-brand { display: flex; align-items: center; gap: 6px; min-width: 0; }
.tb-proj-brand img { height: 1.6em; width: auto; max-width: 5em; object-fit: contain; }
.tb-proj-brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-proj-q { margin: auto 6%; background: #fff; border-radius: 6px; padding: 5% 4%; text-align: center; font-weight: 800; font-size: clamp(9px, 1.5vw, 13px); }
.tb-proj-foot { display: flex; justify-content: space-between; align-items: center; padding: 3% 4%; font-size: clamp(8px, 1.2vw, 11px); font-weight: 800; }
.tb-proj-pill { background: var(--tb-fill, #5B2BD9); color: #fff; border-radius: 999px; padding: .3em .8em; }
.tb-proj-link { color: var(--tb-text-light, #5B2BD9); }
/* phone mock: the real dark phone ladder */
.tb-phone { width: 34%; max-width: 170px; aspect-ratio: 9 / 18; border-radius: 18px; border: 3px solid #3E4454; background: #14161D; color: #fff; display: flex; flex-direction: column; align-items: center; gap: 8%; padding: 10% 7%; overflow: hidden; font-size: clamp(8px, 1.3vw, 12px); }
.tb-phone-strip { display: flex; align-items: center; gap: 5px; background: rgba(255, 255, 255, .06); border-radius: 8px; padding: 4px 6px; max-width: 100%; font-weight: 900; }
.tb-phone-strip img { width: 18px; height: 18px; object-fit: contain; border-radius: 4px; }
.tb-phone-strip span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-phone-name { font-weight: 800; color: var(--tb-text-dark, #C4A5FF); }
.tb-phone-btn { width: 100%; text-align: center; background: var(--tb-fill, #6D3BF5); color: #fff; border-radius: 8px; padding: 7% 0; font-weight: 900; margin-top: auto; }
@media (max-width: 860px) {
  .tb-wrap { grid-template-columns: 1fr; }
  .tb-wrap > [data-preview] { position: static; }
  .tb-wrap > [data-preview] { order: -1; }
  .tb-preview { position: static; }
}
