/* =====================================================================
   Chess Trainer Pro — Dark Teal Theme
   ===================================================================== */

:root {
  --bg:            #05141A;
  --surface:       rgba(255,255,255,.04);
  --surface-solid: #0B242D;
  --ink:           #DFF9FB;
  --ink-soft:      #6F98A0;
  --accent:        #2DD4BF;
  --accent-bright: #7CF2E4;
  --accent-deep:   #0E7490;
  --glow:          rgba(45,212,191,.5);
  --border:        rgba(124,242,228,.15);
  --danger:        #f87171;
  --radius-lg:     20px;
  --radius-md:     13px;
  --radius-sm:     9px;
  --ease:          cubic-bezier(.22,1,.36,1);
  --mono:          'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(ellipse 900px 500px at 78% 0%,   rgba(45,212,191,.10), transparent 60%),
    radial-gradient(ellipse 650px 550px at  8% 100%, rgba(14,116,144,.10), transparent 55%),
    var(--bg);
  color: var(--ink);
  font-family: 'Inter', -apple-system, Segoe UI, Arial, sans-serif;
  min-height: 100vh;
  line-height: 1.5;
}

/* ---- Chess symbol font ---- */
.glyphfont {
  font-family: 'Noto Sans Symbols 2', 'Segoe UI Symbol', 'Apple Symbols', 'DejaVu Sans', sans-serif;
}

h1, h2 { font-family: 'Sora', 'Inter', sans-serif; font-weight: 600; margin: 0; }

:focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---- Top bar ---- */

#topBar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: rgba(5,20,26,.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-left { display: flex; align-items: center; gap: 28px; }

#topBar h1 {
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 0;
  color: var(--ink);
  line-height: 1;
}

/* nightchess topbar lockup (SVG mark + wordmark) */
.topbar-lockup {
  flex-shrink: 0;
  display: block;
  /* width is derived from height + viewBox aspect ratio automatically */
  filter: drop-shadow(0 0 10px rgba(45,212,191,.25));
}

.main-nav { display: flex; gap: 2px; }
.main-nav a {
  text-decoration: none;
  color: var(--ink-soft);
  font-weight: 600;
  font-size: 13.5px;
  padding: 8px 15px;
  border-radius: 999px;
  transition: color .15s, background .15s;
}
.main-nav a:hover { color: var(--ink); background: rgba(255,255,255,.06); }
.main-nav a.active { color: #fff; background: rgba(45,212,191,.14); box-shadow: 0 0 0 1px var(--border); }

#authWidget {
  font-size: 13px;
  color: var(--ink-soft);
  display: flex;
  align-items: center;
  gap: 10px;
}
#authWidget button { padding: 6px 14px; font-size: 13px; }

/* ---- Page layout ---- */

.page-layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 20px;
  max-width: 1200px;
  margin: 24px auto;
  padding: 0 24px 60px;
}

/* ---- Sidebar ---- */

#sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px;
  height: fit-content;
  position: sticky;
  top: 80px;
}

#sidebar h2 {
  font-size: 14px;
  color: var(--accent-bright);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* openings list chips */
.opening-category { margin-bottom: 14px; }
.opening-category h3 {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin: 0 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.opening-row {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 3px;
  cursor: pointer;
  transition: background .15s;
}
.opening-row:hover { background: rgba(45,212,191,.08); }

.opening-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  display: block;
  margin-bottom: 5px;
}

.opening-row button {
  font-size: 11.5px;
  padding: 4px 10px;
  width: 100%;
  text-align: left;
  margin-bottom: 3px;
}

.opening-row button.tiny-danger {
  background: none;
  color: var(--danger);
  font-weight: 400;
  padding: 2px 4px;
  width: auto;
  font-size: 11px;
}
.opening-row button.tiny-danger:hover { background: rgba(248,113,113,.1); }

/* ---- Main content ---- */

main { min-width: 0; }

.layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 20px;
  align-items: start;
}

/* ---- Board wrap ---- */

#boardWrap {
  background: var(--surface-solid);
  padding: 14px;
  padding-bottom: 42px;  /* space for dock pill */
  border-radius: 22px;
  border: 1px solid var(--border);
  box-shadow: 0 0 60px -20px rgba(45,212,191,.3);
  position: relative;
}

.status-strip {
  font-size: 12.5px;
  color: var(--ink-soft);
  margin-bottom: 10px;
  min-height: 18px;
}
.status-strip b { color: var(--ink); }

/* ---- Eval bar ---- */

.board-with-eval {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

#evalBarWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 18px;
  flex-shrink: 0;
  gap: 4px;
}

#evalBar {
  flex: 1;
  width: 12px;
  border-radius: 4px;
  background: #0A2028;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(124,242,228,.10);
  min-height: 80px;
}

#evalFill {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, #c8c8c8, #e8e8e8);
  height: 50%;
  transition: height .5s cubic-bezier(.4,0,.2,1);
}

#evalScore {
  font-size: 9px;
  color: var(--ink-soft);
  font-family: 'JetBrains Mono', monospace;
  text-align: center;
  line-height: 1;
  letter-spacing: -.02em;
}

/* board container so arrowLayer is always on top of board */
.board-container { position: relative; width: 460px; }
#board { width: 460px; border-radius: 6px; overflow: hidden; }
#arrowLayer { position: absolute; top: 0; left: 0; pointer-events: none; }

/* Override chessboard.js square colors */
.white-1e1d7 { background-color: #1A4A5C !important; }
.black-3c85d { background-color: #0F2B38 !important; }

/* ---- Floating dock ---- */

.dock {
  position: absolute;
  left: 50%;
  bottom: -24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px;
  border-radius: 999px;
  background: rgba(11,36,45,.88);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  box-shadow: 0 14px 34px -10px rgba(0,0,0,.55), 0 0 0 1px rgba(124,242,228,.06);
  white-space: nowrap;
  z-index: 10;
}

.dock .btn {
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  font-size: 12.5px;
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: all .2s var(--ease);
  white-space: nowrap;
}

.dock .btn.primary {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff;
  box-shadow: 0 4px 14px -4px var(--glow);
}
.dock .btn.primary:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 18px -4px var(--glow); }
.dock .btn.primary:active:not(:disabled) { transform: translateY(0); }

.dock .btn.secondary {
  background: transparent;
  color: var(--ink-soft);
}
.dock .btn.secondary:hover:not(:disabled) { color: var(--ink); background: rgba(255,255,255,.07); }

.dock .btn:disabled {
  opacity: .4;
  cursor: default;
  transform: none !important;
}

/* Gear button */
.dock .gear {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--ink-soft);
  font-size: 15px;
  transition: all .2s;
  position: relative;
  background: none;
  border: none;
}
.dock .gear:hover { color: var(--accent-bright); background: rgba(255,255,255,.06); }

/* Gear settings popup */
.settings-pop {
  position: absolute;
  bottom: 46px;
  right: 0;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  display: none;
  flex-direction: column;
  gap: 10px;
  width: 148px;
  box-shadow: 0 12px 28px -8px rgba(0,0,0,.55);
}
.settings-pop.show { display: flex; }

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: var(--ink-soft);
  font-weight: 500;
}
.toggle-row input[type=checkbox] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: rgba(255,255,255,.1);
  border-radius: 999px;
  position: relative;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: background .2s, border-color .2s;
  flex-shrink: 0;
}
.toggle-row input[type=checkbox]::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--ink-soft);
  border-radius: 50%;
  top: 1px;
  left: 1px;
  transition: left .2s, background .2s;
}
.toggle-row input[type=checkbox]:checked {
  background: rgba(45,212,191,.25);
  border-color: var(--accent);
}
.toggle-row input[type=checkbox]:checked::after {
  left: 15px;
  background: var(--accent-bright);
}

/* ---- Eval label ---- */

.eval-label {
  margin-top: 38px;
  text-align: center;
  font-size: 12px;
  color: var(--ink-soft);
  font-family: var(--mono);
  min-height: 16px;
}
.eval-label b { color: var(--accent-bright); }

/* ---- Side panels ---- */

.side { display: flex; flex-direction: column; gap: 12px; }

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
}

/* status + hint */
#status {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  min-height: 20px;
}

#hint {
  font-size: 13px;
  color: var(--danger);
  min-height: 16px;
  line-height: 1.4;
}

/* explain panel */
.explain-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 15px 16px;
}

.explain-title {
  font-weight: 700;
  font-size: 11.5px;
  color: var(--accent-bright);
  text-transform: uppercase;
  letter-spacing: .07em;
  margin-bottom: 7px;
}

.explain-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--ink-soft);
  white-space: pre-wrap;
}
.explain-text.loading { font-style: italic; color: var(--ink-soft); opacity: .7; }

.engine-line {
  margin-top: 10px;
  font-size: 12px;
  font-family: var(--mono);
  background: rgba(45,212,191,.08);
  color: var(--accent-bright);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  display: inline-block;
}

/* weak spots table */
#weakSpots { margin-top: 4px; }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 8px; }
td, th { padding: 5px 7px; border-bottom: 1px solid var(--border); text-align: left; }
th { color: var(--ink-soft); font-weight: 600; font-size: 11.5px; }
tr:hover td { background: rgba(45,212,191,.05); }

.muted { color: var(--ink-soft); font-size: 12px; }

/* tester status / practice status panels */
#testerStatusPanel, #practiceStatusPanel {
  background: rgba(45,212,191,.06);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 15px;
  margin-bottom: 16px;
  font-size: 13.5px;
  color: var(--ink-soft);
}

#testerProgress { margin-top: 5px; font-size: 13px; }

/* verdict panel */
#verdictPanel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 32px;
}
#verdictPanel h2 { font-size: 17px; color: var(--accent-bright); margin-bottom: 12px; }

/* ---- Forms & inputs ---- */

.form-row {
  display: block;
  margin-bottom: 13px;
  font-size: 13px;
  color: var(--ink-soft);
  font-weight: 600;
}
.form-row input, .form-row select, .form-row textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-weight: 400;
  color: var(--ink);
}
.form-row textarea { min-height: 64px; font-family: var(--mono); font-size: 12.5px; }

select, input[type=text], input[type=password], input[type=number], input[type=file] {
  padding: 8px 11px;
  font-size: 13.5px;
  font-family: inherit;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,212,191,.15);
}

textarea {
  width: 100%;
  min-height: 120px;
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 10px 12px;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--ink);
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(45,212,191,.12);
}

/* General buttons (outside dock) */
button {
  cursor: pointer;
  background: rgba(45,212,191,.18);
  color: var(--accent-bright);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 15px;
  font-size: 13.5px;
  font-family: inherit;
  font-weight: 600;
  transition: background .15s, color .15s, transform .1s;
}
button:hover:not(:disabled) { background: rgba(45,212,191,.3); color: #fff; }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: .35; cursor: default; }

button.secondary {
  background: rgba(255,255,255,.05);
  color: var(--ink-soft);
  border-color: var(--border);
}
button.secondary:hover:not(:disabled) { background: rgba(255,255,255,.1); color: var(--ink); }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-top: 10px; }

/* ---- PGN collapsible ---- */

.manual-pgn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  margin-bottom: 16px;
}
.manual-pgn summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink-soft);
  list-style: none;
  user-select: none;
}
.manual-pgn summary::-webkit-details-marker { display: none; }
.manual-pgn summary::before { content: '▸  '; color: var(--accent); }
.manual-pgn[open] summary::before { content: '▾  '; }
.manual-pgn[open] summary { margin-bottom: 12px; }

/* ---- Login screen ---- */

.login-screen {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

/* Knight badge above login form */
.login-knight-badge {
  width: 88px;
  height: 88px;
  border-radius: 26px;
  background: radial-gradient(circle at 30% 20%, #123B47, #0B242D 55%, #04121A);
  border: 1px solid rgba(124,242,228,.28);
  box-shadow: 0 0 48px -10px rgba(45,212,191,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 22px;
  animation: lkbIdle 2.6s ease-in-out infinite;
  transition: opacity .35s var(--ease);
  flex-shrink: 0;
}
.lkb-glyph {
  font-size: 54px;
  line-height: 1;
  background: linear-gradient(180deg, #EAFFFB, #7CF2E4);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px rgba(124,242,228,.5));
  user-select: none;
}
@keyframes lkbIdle {
  0%, 100% { filter: drop-shadow(0 0  8px var(--glow)); }
  50%       { filter: drop-shadow(0 0 20px var(--glow)); }
}

.login-card {
  background: rgba(11,36,45,.78);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 32px;
  width: 340px;
  box-shadow: 0 20px 60px -15px rgba(0,0,0,.6), 0 0 0 1px rgba(124,242,228,.07);
}

.login-card h2 {
  margin: 0 0 20px;
  font-size: 20px;
  color: var(--ink);
}

.login-card button {
  width: 100%;
  margin-top: 6px;
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 14px;
  box-shadow: 0 4px 14px -4px var(--glow);
}
.login-card button:hover:not(:disabled) { filter: brightness(1.1); }

.login-card a { color: var(--accent); font-weight: 600; text-decoration: none; }
.login-card a:hover { text-decoration: underline; }

/* ---- Modal ---- */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.modal {
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  max-width: 620px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 24px;
  box-shadow: 0 24px 60px -12px rgba(0,0,0,.6);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-header h2 { font-size: 18px; color: var(--ink); }

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-soft);
  font-size: 20px;
  line-height: 1;
  padding: 4px 8px;
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: rgba(255,255,255,.06); }

/* ---- Punish stepper ---- */

#punishStepper .row { align-items: center; }
#punishStepLabel { min-width: 140px; text-align: center; font-size: 12.5px; }

/* ══════════════════════════════════════════════════════
   Intro animation overlay
   ══════════════════════════════════════════════════════ */

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  pointer-events: none;
  display: none;
  overflow: hidden;
  background: rgba(5,20,26,.6);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

/* Mini 3×3 board card */
.intro-board-card {
  position: absolute;
  padding: 10px;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  box-shadow: 0 0 40px -14px rgba(45,212,191,.45);
  opacity: 0;
}

.intro-board {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 44px);
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 0 0 1px var(--border);
}

.ic       { display: flex; align-items: center; justify-content: center; position: relative; transition: box-shadow .25s var(--ease); }
.ic.dark  { background: #123540; }
.ic.light { background: #0A2027; }
.ic.flash         { box-shadow: inset 0 0 0 2px rgba(124,242,228,.55), 0 0 18px -2px var(--glow); }
.ic.flash-capture { box-shadow: inset 0 0 0 2px rgba(124,242,228,.8),  0 0 26px  0  var(--glow); }
.ic.flash-check   { box-shadow: inset 0 0 0 2px rgba(255,107,107,.65), 0 0 26px  0  rgba(255,107,107,.55); }

.ig {
  font-size: 24px;
  line-height: 1;
  color: var(--ink);
  filter: drop-shadow(0 0 3px rgba(0,0,0,.5));
  user-select: none;
}

/* Queen capture pop */
.queen-captured { animation: queenPop .38s var(--ease) forwards; }
@keyframes queenPop {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(1.38); opacity: 1; }
  100% { transform: scale(.18);  opacity: 0; }
}

/* King piece (absolutely positioned, moves via translateY) */
.intro-king {
  position: absolute;
  font-size: 24px;
  color: var(--ink);
  filter: drop-shadow(0 0 4px rgba(0,0,0,.5));
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  margin: -12px 0 0 -10px;  /* rough centering for 24px glyph */
}

/* Flying knight (travels between positions) */
.intro-flying {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
}
.if-shell {
  position: absolute;
  inset: 0;
  border-radius: 13px;
  background: transparent;
  border: 1px solid transparent;
  box-shadow: none;
  transition: background .4s, border-color .4s, box-shadow .4s;
}
.if-glyph {
  position: relative;
  font-size: 36px;
  line-height: 1;
  color: #EAFFFB;
  filter: drop-shadow(0 0 10px var(--glow));
  transition: font-size .55s var(--ease);
  user-select: none;
}

/* Settled state (knight locked in as logo) */
.intro-flying.settled .if-shell {
  background: radial-gradient(circle at 30% 20%, #123B47, #0B242D 55%, #04121A);
  border-color: rgba(124,242,228,.4);
  box-shadow: 0 0 24px -5px rgba(45,212,191,.5);
}
.intro-flying.settled { animation: settledIdle 2.6s ease-in-out infinite; }
@keyframes settledIdle {
  0%, 100% { filter: drop-shadow(0 0  5px var(--glow)); }
  50%       { filter: drop-shadow(0 0 14px var(--glow)); }
}

/* ---- Responsive ---- */

@media (max-width: 900px) {
  .page-layout { grid-template-columns: 1fr; }
  #sidebar { position: static; }
  .layout { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  button, textarea, select, input { transition: none !important; }
}
