/* Chess Drills — shared design system (Phase 0 prototype) */
/* Dark "chess gym" aesthetic. Mobile-first. No external fonts (system stack). */

:root {
  --bg: #12141a;
  --bg-raised: #1a1e27;
  --bg-card: #20242f;
  --border: #2e3442;
  --text: #e8eaf0;
  --text-dim: #9aa2b5;
  --accent: #4ade80;        /* green — progress/success */
  --accent-dim: #22c55e;
  --accent-contrast: #0b1f12;
  --danger: #f87171;
  --warn: #fbbf24;
  --sq-light: #e9edcc;      /* board squares */
  --sq-dark: #779556;
  --sq-select: #f6f66940;   /* selection overlay */
  --sq-last: #baca4466;     /* last-move overlay */
  --piece-white: #ffffff;
  --piece-white-stroke: #1f2937;
  --piece-black: #1f2430;
  --piece-black-stroke: #cbd5e1;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,.35);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.55;
}

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; letter-spacing: -0.02em; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3.5vw, 2rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.dim { color: var(--text-dim); }
.small { font-size: .85rem; }

.container { max-width: 960px; margin: 0 auto; padding: 0 20px; }
.narrow { max-width: 640px; }

/* Header / nav */
.site-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; max-width: 960px; margin: 0 auto;
}
.brand { font-weight: 800; font-size: 1.15rem; color: var(--text); letter-spacing: -0.01em; }
.brand .knight { color: var(--accent); margin-right: 6px; }
.nav a { margin-left: 18px; color: var(--text-dim); font-weight: 600; font-size: .95rem; }
.nav a:hover { color: var(--text); text-decoration: none; }

/* Buttons */
.btn {
  display: inline-block; border: 0; cursor: pointer;
  font-family: var(--font); font-weight: 700; font-size: 1rem;
  padding: 13px 22px; border-radius: var(--radius-sm);
  background: var(--bg-card); color: var(--text);
  border: 1px solid var(--border);
  transition: transform .06s ease, background .15s ease;
}
.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-contrast); }
.btn-primary:hover { background: var(--accent-dim); }
.btn-block { display: block; width: 100%; text-align: center; }
.btn:disabled { opacity: .5; cursor: default; }

/* Cards & sections */
.section { padding: 56px 0; }
.section-tight { padding: 32px 0; }
.card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px;
}
.grid { display: grid; gap: 16px; }
@media (min-width: 720px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.badge {
  display: inline-block; font-size: .72rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 9px; border-radius: 999px;
  background: var(--bg-raised); border: 1px solid var(--border); color: var(--text-dim);
}
.badge-live { color: var(--accent); border-color: var(--accent-dim); }
.badge-soon { color: var(--warn); }

/* Forms */
.input {
  width: 100%; padding: 13px 14px; font-size: 1rem; font-family: var(--font);
  background: var(--bg-raised); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.input:focus { outline: 2px solid var(--accent-dim); border-color: transparent; }
.form-row { display: flex; gap: 10px; flex-wrap: wrap; }
.form-row .input { flex: 1 1 220px; }

/* Chess board */
.board-wrap { max-width: min(92vw, 520px); margin: 0 auto; }
.board {
  display: grid; grid-template-columns: repeat(8, 1fr);
  width: 100%; aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm); overflow: hidden;
  box-shadow: var(--shadow);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.sq { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.sq-light { background: var(--sq-light); }
.sq-dark { background: var(--sq-dark); }
.sq.selected::after, .sq.lastmove::after, .sq.hint::after {
  content: ""; position: absolute; inset: 0;
}
.sq.selected::after { background: var(--sq-select); }
.sq.lastmove::after { background: var(--sq-last); }
.sq .piece {
  font-size: clamp(26px, 9vw, 52px);
  line-height: 1; z-index: 1; pointer-events: none;
}
.piece-w { color: var(--piece-white); text-shadow: 0 0 2px var(--piece-white-stroke), 0 1px 2px rgba(0,0,0,.5); }
.piece-b { color: var(--piece-black); text-shadow: 0 0 2px var(--piece-black-stroke); }
.sq.flash-good { animation: flashGood .45s ease; }
.sq.flash-bad { animation: flashBad .45s ease; }
@keyframes flashGood { 0% { box-shadow: inset 0 0 0 999px rgba(74,222,128,.55);} 100% { box-shadow: inset 0 0 0 999px transparent;} }
@keyframes flashBad  { 0% { box-shadow: inset 0 0 0 999px rgba(248,113,113,.55);} 100% { box-shadow: inset 0 0 0 999px transparent;} }

/* App chrome */
.hud {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 0; flex-wrap: wrap;
}
.hud .stat { font-weight: 700; }
.streak { color: var(--warn); font-weight: 800; }
.progress-dots { display: flex; gap: 6px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bg-card); border: 1px solid var(--border); }
.dot.done { background: var(--accent); border-color: var(--accent); }
.dot.miss { background: var(--danger); border-color: var(--danger); }
.dot.current { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74,222,128,.3); }

.status-line { min-height: 1.6em; font-weight: 700; text-align: center; margin: 10px 0; }
.status-good { color: var(--accent); }
.status-bad { color: var(--danger); }

/* Recap */
.recap-score { font-size: 3rem; font-weight: 900; letter-spacing: -0.03em; }
table.theme-table { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.theme-table td, table.theme-table th { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; }
table.theme-table td:last-child, table.theme-table th:last-child { text-align: right; }

/* Footer */
.site-footer { border-top: 1px solid var(--border); margin-top: 48px; padding: 28px 0 40px; color: var(--text-dim); font-size: .85rem; }

/* Utility */
.center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 28px; } .mt-4 { margin-top: 44px; }
.hidden { display: none !important; }
