/* bb-board-theme.css: board colors for every board on the site (opening trainer, endgame
   trainer, micro-course and drill pages, report "What would you play?" card). Loaded by
   base.html so all of them look the same. Pages lay out their own board; they must NOT
   redefine the color variables below on their own containers, or this file stops working
   for them.

   Theme: html[data-board-theme] = (none) green | brand | brown | slate | bw, set before paint by
   base.html from localStorage "bb_board_theme". Each theme is a solid light square, a
   mid-tone dark square (so black pieces stay readable), and a light/dark last-move tint. */

:root {
  --board-light: #E8ECDF;
  --board-dark: #6F9669;
  --board-lm-light: #F3E98C;
  --board-lm-dark: #C2C35C;
  --board-sel-ring: rgba(20, 83, 45, 0.85);
  --board-border: transparent;
  /* Older names some pages still read. */
  --board-last-move: #F3E98C;
  --board-selected: #F3E98C;
  --board-selected-border: rgba(20, 83, 45, 0.85);
}
/* The original Blackbox board: translucent green on near-black, grid lines, white rims on
   black pieces. Kept as its own theme ("Board: Blackbox"). */
html[data-board-theme="brand"] {
  --board-light: rgba(34, 197, 94, 0.55);
  --board-dark: rgba(12, 28, 18, 0.95);
  --board-lm-light: rgba(234, 179, 8, 0.62);
  --board-lm-dark: rgba(161, 128, 10, 0.75);
  --board-sel-ring: rgba(34, 197, 94, 0.95);
  --board-border: rgba(34, 197, 94, 0.25);
  --board-last-move: rgba(234, 179, 8, 0.62);
  --board-selected: rgba(34, 197, 94, 0.4);
  --board-selected-border: rgba(34, 197, 94, 0.95);
}
html[data-board-theme="brand"] .board-grid .sq.light .coord { color: rgba(0, 0, 0, 0.55); }
html[data-board-theme="brand"] .board-grid .sq.dark .coord { color: rgba(255, 255, 255, 0.70); }
html[data-board-theme="brown"] {
  --board-light: #F0D9B5;
  --board-dark: #B58863;
  --board-lm-light: #F6EB72;
  --board-lm-dark: #DCC34B;
  --board-sel-ring: rgba(92, 54, 24, 0.85);
  --board-last-move: #F6EB72;
  --board-selected: #F6EB72;
  --board-selected-border: rgba(92, 54, 24, 0.85);
}
html[data-board-theme="slate"] {
  --board-light: #DEE3E6;
  --board-dark: #8CA2AD;
  --board-lm-light: #EEE78F;
  --board-lm-dark: #B9BE7A;
  --board-sel-ring: rgba(30, 58, 80, 0.85);
  --board-last-move: #EEE78F;
  --board-selected: #EEE78F;
  --board-selected-border: rgba(30, 58, 80, 0.85);
}
html[data-board-theme="bw"] {
  --board-light: #E9E9E9;
  --board-dark: #333333;
  --board-lm-light: #F2E58A;
  --board-lm-dark: #8C8440;
  --board-sel-ring: rgba(34, 197, 94, 0.95);
  --board-last-move: #F2E58A;
  --board-selected: #F2E58A;
  --board-selected-border: rgba(34, 197, 94, 0.95);
}

/* Square colors, last move and selection. html + .board-grid outranks each page's own
   ".sq.light" / ".sq.last-move" rules, including their !important ones. */
html .board-grid .sq.light { background: var(--board-light); }
html .board-grid .sq.dark { background: var(--board-dark); }
html .board-grid .sq { border-color: var(--board-border); }
html .board-grid .sq.light.last-move { background: var(--board-lm-light) !important; }
html .board-grid .sq.dark.last-move { background: var(--board-lm-dark) !important; }
html .board-grid .sq.light.selected { background: var(--board-lm-light) !important; }
html .board-grid .sq.dark.selected { background: var(--board-lm-dark) !important; }
html .board-grid .sq.selected {
  border-color: transparent !important;
  box-shadow: inset 0 0 0 3px var(--board-sel-ring);
}
html .board-wrap { border-color: transparent; }

/* Coordinates take the other square's color, the usual board convention. */
html .board-grid .sq.light .coord { color: var(--board-dark); opacity: 1; }
html .board-grid .sq.dark .coord { color: var(--board-light); opacity: 1; }

/* Black pieces got a white rim for the old near-black squares. On the mid-tone squares
   they read without it; the Blackbox and B&W boards keep it for their dark squares. */
html:not([data-board-theme="bw"]):not([data-board-theme="brand"]) .board-grid .bb-piece.black {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.35));
}
html:not([data-board-theme="bw"]):not([data-board-theme="brand"]) .board-grid .bb-piece.white {
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}

/* Coordinates off (setting "coordinates"). */
html[data-board-coords="off"] .board-grid .coord { display: none; }

/* ── Settings panel (static/js/bb-settings.js) ─────────────────────────── */
.bbs-overlay {
  position: fixed; inset: 0; z-index: 10000; background: rgba(0, 0, 0, 0.6);
  display: flex; align-items: flex-end; justify-content: center;
}
@media (min-width: 640px) { .bbs-overlay { align-items: center; } }
.bbs-panel {
  width: min(520px, 100%); max-height: 88vh; overflow-y: auto; box-sizing: border-box;
  background: #111814; color: #E7ECE8; border: 1px solid #22302A; border-radius: 16px 16px 0 0;
  padding: 18px 18px 24px; font-family: var(--font-body, Inter, system-ui, sans-serif);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
@media (min-width: 640px) { .bbs-panel { border-radius: 16px; padding: 22px 24px 24px; } }
.bbs-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.bbs-head h2 { margin: 0; font-family: var(--font-display, Georgia, serif); font-size: 22px; font-weight: 700; }
.bbs-close {
  width: 44px; height: 44px; border: 0; border-radius: 10px; background: transparent; color: #C9D1CC;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.bbs-close:hover { background: rgba(255, 255, 255, 0.06); }
.bbs-row { padding: 12px 0; border-top: 1px solid #1C2621; }
.bbs-row:first-child { border-top: 0; }
.bbs-label { font-size: 13px; font-weight: 600; color: #9AA59F; margin-bottom: 8px; }
.bbs-opts { display: flex; flex-wrap: wrap; gap: 6px; }
.bbs-opt {
  min-height: 40px; padding: 0 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid #2A3730; background: #18211C; color: #E7ECE8;
  font: 600 14px var(--font-body, Inter, system-ui, sans-serif);
  display: inline-flex; align-items: center; gap: 8px;
}
.bbs-opt:hover { border-color: #3A4A41; }
.bbs-opt.is-on { background: rgba(34, 197, 94, 0.16); border-color: #22C55E; color: #86EFAC; }
.bbs-opt:focus-visible, .bbs-close:focus-visible { outline: 2px solid #4ADE80; outline-offset: 2px; }
.bbs-pieces { display: inline-flex; gap: 1px; padding: 1px 2px; border-radius: 4px; background: #E8ECDF; }
.bbs-pieces img { width: 22px; height: 22px; display: block; }
.bbs-swatch { width: 16px; height: 16px; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.35); }
.bbs-note { margin: 14px 0 0; font-size: 14px; color: #9AA59F; }
.bbs-note a, .bbs-all { color: #4ADE80; font-weight: 600; }
.bbs-all { display: inline-block; margin-top: 14px; font-size: 14px; }

/* Gear button that opens the panel (sits in the trainers' control rows). */
.bb-settings-btn { display: inline-flex; align-items: center; gap: 6px; }
.bb-settings-btn svg { width: 15px; height: 15px; }
