/* styles.css — shared design tokens + components for both tabs, extracted
   verbatim (colors, fonts, spacing scale) from the confirmed prototypes:
   wayfinder/prototypes/0002-teacher-tab-layout.html and 0003-projector-tab-layout.html.
   Do not redesign from scratch — this file exists so the real app looks like
   the prototypes the requester already signed off on. */

:root {
  /* theme-invariant: the board and the wooden control desk don't flip with
     dark mode — a real chessboard and a real podium don't repaint themselves
     for your OS setting. */
  --board-light-sq: #e9dfc8;
  --board-dark-sq: #7d5a3c;
  --board-border: #4a3220;
  --wood-panel: #241a10;
  --wood-panel-fg: #efe6d4;
  --wood-panel-muted: #b7a68c;
  --wood-panel-border: #3c2c1c;
  --felt: #2f5d46;
  --felt-bright: #4f9d74;
  --felt-fg: #f1fff6;
  --flag-red: #a13d2c;
  --flag-red-bright: #c9573f;
  --piece-white: #f6f1e4;
  --piece-black: #201408;
  --piece-white-stroke: #4a3220;
  --last-move: #d9b45c;
  --arrow: #c94a3a;

  /* theme-variant: page chrome around the desk */
  --page-bg: #ece2cc;
  --panel-bg: #faf6ec;
  --panel-bg-2: #f1e9d6;
  --border: #d9cbaa;
  --text: #241a10;
  --text-muted: #6b5b45;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-bg: #15100a;
    --panel-bg: #1e1610;
    --panel-bg-2: #251b13;
    --border: #3a2c1d;
    --text: #ede4d3;
    --text-muted: #a5937a;
  }
}
:root[data-theme="dark"] {
  --page-bg: #15100a;
  --panel-bg: #1e1610;
  --panel-bg-2: #251b13;
  --border: #3a2c1d;
  --text: #ede4d3;
  --text-muted: #a5937a;
}

* { box-sizing: border-box; }

body {
  background: var(--page-bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  margin: 0;
}

.serif {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
}
.mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
}

/* ---- wooden control desk (topbar), teacher tab only ---- */
.desk {
  background: var(--wood-panel);
  color: var(--wood-panel-fg);
  border: 1px solid var(--wood-panel-border);
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.5rem;
}
.wordmark {
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.35rem;
  letter-spacing: 0.01em;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  white-space: nowrap;
}
.wordmark small {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--wood-panel-muted);
  letter-spacing: 0.02em;
}
.desk-group { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.desk-group label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--wood-panel-muted);
}
.desk select, .btn, .icon-btn {
  font: inherit;
  font-size: 0.85rem;
  border-radius: 6px;
  border: 1px solid var(--wood-panel-border);
  background: #322414;
  color: var(--wood-panel-fg);
  padding: 0.4rem 0.65rem;
  cursor: pointer;
}
.desk select { max-width: 15rem; }
.btn:hover, .icon-btn:hover { background: #3d2c19; }
.btn:disabled, .icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--felt); border-color: var(--felt); color: var(--felt-fg); }
.btn.primary:hover { background: var(--felt-bright); }
.btn.danger { background: var(--flag-red); border-color: var(--flag-red); color: #fff; }
.btn.danger:hover { background: var(--flag-red-bright); }
.icon-btn { padding: 0.35rem 0.55rem; }
.spacer { flex: 1 1 auto; }

/* ---- signature control: the sync plunger ---- */
.sync-plunger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  background: #322414;
  border: 1px solid var(--wood-panel-border);
  border-radius: 999px;
  padding: 0.3rem 0.9rem 0.3rem 0.4rem;
  cursor: pointer;
  font-size: 0.85rem;
}
.sync-plunger .knob {
  width: 2.1rem;
  height: 1.15rem;
  border-radius: 999px;
  background: var(--flag-red);
  position: relative;
  transition: background 0.15s ease;
  flex: none;
}
.sync-plunger .knob::after {
  content: "";
  position: absolute;
  top: 2px; left: 2px;
  width: 0.85rem; height: 0.85rem;
  border-radius: 50%;
  background: #fff;
  transition: transform 0.15s ease;
}
.sync-plunger.on .knob { background: var(--felt-bright); }
.sync-plunger.on .knob::after { transform: translateX(0.95rem); }
.sync-plunger .state { font-weight: 600; min-width: 9.5ch; }
.sync-plunger.on .state { color: var(--felt-bright); }
.sync-plunger:not(.on) .state { color: var(--flag-red-bright); }

/* ---- teacher tab layout ---- */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(16rem, 0.85fr);
  gap: 1rem;
  align-items: start;
}
@media (max-width: 46rem) {
  .workspace { grid-template-columns: 1fr; }
}

.board-col { display: flex; flex-direction: column; gap: 0.75rem; }
.board-row { display: flex; gap: 0.6rem; align-items: stretch; }

.side-col { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }

.tool-rail {
  background: var(--wood-panel);
  border: 1px solid var(--wood-panel-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.4rem;
}
.tool-rail button {
  width: 2.3rem;
  height: 2.3rem;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--wood-panel-fg);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.tool-rail button.active { background: var(--felt); border-color: var(--felt); }
.tool-rail button:hover:not(.active) { background: #3c2c1c; }

.board-container {
  --sq: min(5.6vw, 3.6rem);
  width: calc(var(--sq) * 8);
  height: calc(var(--sq) * 8);
  border: 4px solid var(--board-border);
  border-radius: 4px;
  overflow: hidden;
  flex: none;
}
.board-container.mini {
  --sq: 1.35rem;
  border-width: 2px;
  border-radius: 3px;
}

/* cm-chessboard ships fixed theme colors via SVG `fill`; override them here
   so the board matches this app's wood/felt palette instead of its own
   default beige theme. */
.cm-chessboard.default .board .square.white,
.cm-chessboard.default-contrast .board .square.white { fill: var(--board-light-sq); }
.cm-chessboard.default .board .square.black,
.cm-chessboard.default-contrast .board .square.black { fill: var(--board-dark-sq); }
.cm-chessboard .markers .marker.marker-last-move {
  fill: var(--last-move);
  opacity: 0.55;
}

.move-badge { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; }
.move-badge .current {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  font-size: 1rem;
  background: var(--panel-bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.2rem 0.55rem;
  /* Fixed width (ch is exact for a monospace font) so the game title next
     to it doesn't shift sideways every time a shorter/longer move label
     replaces the previous one - e.g. "1.e4" vs "12...Qxd8+". 8ch was too
     narrow to actually cover that example (10 chars); 13ch covers the
     realistic worst case - a black move, 3-digit move number, longest SAN
     (piece capture + promotion + check, e.g. "100...exd8=Q+"). */
  display: inline-block;
  min-width: 13ch;
  text-align: center;
}
.move-badge .caveat { font-size: 0.75rem; color: var(--text-muted); }

/* Lives in the dark wood .desk bar now (next to the Sync toggle), not the
   light move-badge row it started in - colors match .desk-group label's
   wood-panel palette instead of the light-card --text-muted it used there. */
.lock-pgn-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--wood-panel-muted);
  cursor: pointer;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.9rem 1rem;
}
/* Every card is now a <details>/<summary> (see .collapsible-card below) -
   there are no more plain .card > h2 headers left to style. */
.tag {
  font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
}
.notes-body {
  font-size: 0.92rem;
  line-height: 1.55;
  margin: 0;
  white-space: pre-wrap;
  padding: 0 1rem 0.9rem;
  max-height: 6rem;
  overflow-y: auto;
}
.notes-body:empty::before { content: attr(data-empty-label); color: var(--text-muted); font-style: italic; }

.projector-preview { display: flex; align-items: center; gap: 0.8rem; padding-top: 0.8rem; }
.projector-preview .caption { font-size: 0.82rem; color: var(--text-muted); }
.projector-preview .caption strong { color: var(--text); }

/* Collapsed by default (see index.html) - styled as a <details>/<summary>
   so it needs no JS: a native, keyboard-accessible disclosure widget. Shared
   by every collapsible card (.projector-preview-card, .projector-overlays-card,
   and any future one) so a new one can't silently fall back to the browser's
   default summary styling by forgetting to duplicate these rules. */
.collapsible-card { padding: 0; }
.collapsible-card summary {
  cursor: pointer;
  padding: 0.9rem 1rem;
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 0.95rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}
.collapsible-card summary .tag { margin-left: auto; }
.collapsible-card summary::-webkit-details-marker { display: none; }
.collapsible-card summary::before {
  content: "▸";
  display: inline-block;
  width: 1em;
  margin-right: 0.3rem;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.collapsible-card[open] summary::before { transform: rotate(90deg); }

/* Each collapsible card's own inner-content padding (they hold different
   content, so this isn't shared like the summary styling above). */
.projector-preview-card .projector-preview { padding: 0 1rem 0.9rem; }
.projector-overlays-card .desk-group { padding: 0 1rem 0.9rem; }
.library-card .desk-group { padding: 0 1rem 0.9rem; }

/* ---- variations panel ---- */
.variations > .var-tree { padding: 0 1rem 0.9rem; }
.variations > .free-hint { margin: 0 1rem 0.9rem; }
.var-tree { font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace; font-size: 0.88rem; }
.var-line {
  display: inline-block;
  text-align: left;
  background: transparent;
  border: none;
  color: var(--text);
  padding: 0.15rem 0.1rem;
  cursor: pointer;
  border-radius: 4px;
}
.var-line:hover { background: var(--panel-bg-2); }
.var-line .num { color: var(--text-muted); margin-right: 0.15rem; }
/* No font-weight change here on purpose: this is a monospace stack with a
   generic "monospace" fallback at the end, and not every font a browser
   picks from that fallback keeps bold at the exact same advance width as
   regular (Windows' Consolas is a known case that doesn't). A wider bold
   word reflows every word after it on the same line, so the highlighted
   move visibly "jumps" sideways as you step through moves. Background
   contrast alone is a strong enough active-state signal without it. */
.var-line.active { background: var(--felt); color: var(--felt-fg); }
.var-line.active .num { color: var(--felt-fg); }
.var-row { margin: 0.1rem 0; }
.var-sideline { margin-left: 1.1rem; color: var(--text-muted); font-size: 0.85rem; display: block; }
.var-sideline .var-line { color: inherit; }
.var-expand {
  font-size: 0.78rem;
  color: var(--felt-bright);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.1rem 0.3rem;
  text-decoration: underline;
}

.free-hint {
  font-size: 0.78rem;
  color: var(--flag-red-bright);
  background: color-mix(in srgb, var(--flag-red) 12%, var(--panel-bg));
  border: 1px solid color-mix(in srgb, var(--flag-red) 35%, var(--border));
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
}
.free-hint[hidden] { display: none; }

/* ---- library-full / confirm banners ---- */
.banner {
  background: var(--panel-bg-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.banner.warn {
  color: var(--flag-red-bright);
  border-color: color-mix(in srgb, var(--flag-red) 35%, var(--border));
}

/* ---- box 2: persistent "games in this file" list (see CLAUDE.md — this
   replaced ticket 0006's one-time upload-picker modal, which used to have
   its own .modal-backdrop/.modal/.picker-list rules here) ---- */
.game-list-card[hidden] { display: none; }
.game-list {
  list-style: none;
  margin: 0;
  padding: 0 1rem 0.9rem;
  max-height: 9rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.game-list-entry {
  width: 100%; text-align: left;
  font: inherit; font-size: 0.85rem;
  padding: 0.45rem 0.7rem;
  border-radius: 6px; border: 1px solid var(--border);
  background: var(--panel-bg-2); color: var(--text); cursor: pointer;
}
.game-list-entry:hover { background: var(--felt); color: var(--felt-fg); border-color: var(--felt); }
.game-list-entry.active { background: var(--felt); color: var(--felt-fg); border-color: var(--felt); font-weight: 600; }

/* ---- projector tab: fullscreen wood stage ---- */
body.projector {
  min-height: 100vh;
  background: var(--wood-panel);
  color: var(--wood-panel-fg);
  display: flex;
  flex-direction: column;
}
.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 2rem;
}
.stage .board-wrap { position: relative; }
.stage .board-container {
  --sq: min(9vw, 9vh, 5.2rem);
  border-width: 6px;
}
.arrow-layer { position: absolute; inset: 0; pointer-events: none; }

.overlay {
  position: absolute;
  background: color-mix(in srgb, var(--wood-panel) 88%, black 0%);
  border: 1px solid var(--wood-panel-border);
  border-radius: 8px;
  padding: 0.5rem 0.9rem;
  font-size: 1.15rem;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.overlay[hidden] { display: none; }
.overlay.move-number {
  top: 1.2rem; left: 1.2rem;
  font-family: ui-monospace, "SF Mono", "Cascadia Code", "Roboto Mono", monospace;
  font-weight: 600;
}
.overlay.game-title {
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  max-width: 70vw;
  font-family: ui-serif, Georgia, "Iowan Old Style", "Times New Roman", serif;
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.no-game-hint {
  color: var(--wood-panel-muted);
  font-size: 1rem;
  text-align: center;
  max-width: 30rem;
}

.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.credit {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}
