/* ♞ Chess Academy — stylesheet */

:root {
  --bg: #12141a;
  --surface: #1a1f29;
  --surface-2: #232a37;
  --surface-3: #2c3444;
  --border: #2e3646;
  --border-strong: #3d475c;
  --text: #eef1f6;
  --muted: #9aa4b5;
  --accent: #f0b429;
  --accent-soft: rgba(240, 180, 41, 0.14);
  --accent-2: #8f7fdb;
  --ok: #46c07d;
  --ok-soft: rgba(70, 192, 125, 0.14);
  --bad: #e35d5d;
  --bad-soft: rgba(227, 93, 93, 0.16);
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --font-board: 'Segoe UI Symbol', 'Noto Sans Symbols 2', 'DejaVu Sans', 'Apple Symbols', sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background:
    radial-gradient(1100px 500px at 85% -10%, rgba(143, 127, 219, 0.09), transparent 60%),
    radial-gradient(900px 500px at -10% 0%, rgba(240, 180, 41, 0.07), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 2rem; letter-spacing: -0.02em; margin: 0.2em 0 0.5em; }
h2 { font-size: 1.25rem; letter-spacing: -0.01em; margin: 1.4em 0 0.6em; }

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--muted); }
.ok { color: var(--ok); }
.bad { color: var(--bad); }

::selection { background: rgba(240, 180, 41, 0.35); }

/* Header -------------------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 1.4rem;
  padding: 0.65rem 1.4rem;
  background: rgba(18, 20, 26, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 800;
  font-size: 1.12rem;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand .brand-mark { color: var(--accent); }
.brand:hover { text-decoration: none; color: var(--accent); }

.site-nav { display: flex; gap: 0.35rem; flex: 1; flex-wrap: wrap; }
.site-nav a {
  color: var(--muted);
  font-weight: 550;
  font-size: 0.95rem;
  padding: 0.4rem 0.75rem;
  border-radius: 9px;
}
.site-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
body[data-view='courses'] #nav-courses,
body[data-view='puzzles'] #nav-puzzles,
body[data-view='trainer'] #nav-trainer,
body[data-view='dashboard'] #nav-dashboard {
  color: var(--accent);
  background: var(--accent-soft);
}

.header-auth { display: flex; align-items: center; gap: 0.6rem; }
.nav-user {
  color: var(--text);
  font-weight: 650;
  padding: 0.28rem 0.7rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px;
  font-size: 0.88rem;
}
a.nav-rating {
  font-weight: 800;
  padding: 0.28rem 0.7rem;
  background: var(--accent-soft);
  border: 1px solid rgba(240, 180, 41, 0.4);
  border-radius: 99px;
  font-size: 0.88rem;
}
a.nav-rating:hover { text-decoration: none; filter: brightness(1.1); }

/* Buttons, forms -------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.15rem;
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.15s, background 0.15s, transform 0.06s;
}
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent-2);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #221a05;
}
.btn-primary:hover { filter: brightness(1.07); }
.btn-small { padding: 0.32rem 0.8rem; font-size: 0.85rem; }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }

label {
  display: block;
  margin: 0.8rem 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 550;
}
input, select {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  color: var(--text);
  font-size: 0.98rem;
}
.filters label { display: inline-block; margin: 0 1rem 0.4rem 0; }
.filters select { display: inline-block; width: auto; }

.form-error { color: var(--bad); min-height: 1.2em; font-size: 0.9rem; }

/* Layout ---------------------------------------------------------------- */

.site-main { max-width: 1100px; margin: 0 auto; padding: 1.6rem 1.5rem 3.5rem; }

.site-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 1.6rem;
  border-top: 1px solid var(--border);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* Home ------------------------------------------------------------------ */

.hero { text-align: center; padding: 3.6rem 1rem 2.4rem; }
.hero h1 {
  font-size: clamp(2rem, 5vw, 3rem);
  margin-bottom: 0.45rem;
}
.hero h1 .accent { color: var(--accent); }
.hero p { color: var(--muted); max-width: 36rem; margin: 0 auto 1.7rem; font-size: 1.05rem; }
.hero-actions { display: flex; gap: 0.8rem; justify-content: center; flex-wrap: wrap; }

.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}
.feature-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  color: var(--text);
  transition: transform 0.15s, border-color 0.15s;
}
.feature-card:hover {
  border-color: var(--accent);
  text-decoration: none;
  transform: translateY(-3px);
}
.feature-icon {
  display: inline-flex;
  width: 2.7rem; height: 2.7rem;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.7rem;
}
.feature-card h3 { margin: 0.2rem 0 0.35rem; font-size: 1.05rem; }
.feature-card p { color: var(--muted); font-size: 0.92rem; margin: 0; line-height: 1.5; }

.home-cta {
  margin-top: 2.4rem;
  padding: 1.6rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}
.home-cta p { margin: 0; color: var(--muted); }
.home-cta strong { color: var(--text); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  margin: 1rem 0 2rem;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.05rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
}
.stat-value { font-size: 1.65rem; font-weight: 800; letter-spacing: -0.02em; }
.stat-label { color: var(--muted); font-size: 0.84rem; }

/* Courses ---------------------------------------------------------------- */

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(270px, 1fr));
  gap: 1rem;
}
.course-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  color: var(--text);
  display: flex;
  flex-direction: column;
  transition: transform 0.15s, border-color 0.15s;
}
.course-card:hover { border-color: var(--accent); text-decoration: none; transform: translateY(-3px); }
.course-level {
  align-self: flex-start;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent-2);
  border: 1px solid rgba(143, 127, 219, 0.5);
  border-radius: 99px;
  padding: 0.14rem 0.65rem;
  margin-bottom: 0.7rem;
}
.course-card h3 { margin: 0.2rem 0 0.4rem; }
.course-card p { color: var(--muted); flex: 1; margin: 0 0 0.8rem; line-height: 1.5; }
.course-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
  font-size: 0.85rem;
  margin-bottom: 0.45rem;
}
.course-meta .done { color: var(--ok); font-weight: 650; }

.bar {
  height: 6px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
}
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #f6d276); }

.lesson-list { list-style: none; padding: 0; margin: 1.1rem 0; }
.lesson-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin-bottom: 0.6rem;
  transition: border-color 0.15s;
}
.lesson-item:hover { border-color: var(--border-strong); }
.lesson-item.done { border-color: rgba(70, 192, 125, 0.55); }
.lesson-item a {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0.9rem 1.1rem;
  color: var(--text);
  font-weight: 550;
}
.lesson-item a:hover { text-decoration: none; background: var(--surface-2); border-radius: 12px; }
.lesson-num {
  flex-shrink: 0;
  width: 1.75rem; height: 1.75rem;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  color: var(--muted);
}
.lesson-check { margin-left: auto; color: var(--ok); font-weight: 700; }

.lesson-body {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.4rem 1.7rem;
  line-height: 1.7;
  max-width: 48rem;
}
.lesson-body ul { padding-left: 1.25rem; }
.lesson-body li { margin: 0.3rem 0; }
.lesson-body .demo { margin: 1.3rem auto; max-width: 440px; }
.fen-label {
  text-align: center;
  color: var(--muted);
  font-size: 0.75rem;
  font-family: ui-monospace, monospace;
  margin-top: 0.4rem;
}
.lesson-nav { display: flex; justify-content: space-between; margin-top: 1.5rem; gap: 1rem; flex-wrap: wrap; }
.lesson-complete-row { margin-top: 1.3rem; }

/* Chess board -------------------------------------------------------------- */

.board {
  --sq: min(72px, 11.5vw);
  position: relative;
  display: grid;
  grid-template-columns: repeat(8, var(--sq));
  grid-template-rows: repeat(8, var(--sq));
  width: max-content;
  margin: 0 auto;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid #0c0e12;
  outline: 4px solid #3a3126;
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.45), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  touch-action: manipulation;
  user-select: none;
}

.square {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.square.light { background: #eeeed2; }
.square.dark  { background: #77956a; }

/* Solid glyphs for both colors, colored + haloed for contrast */
.piece {
  font-family: var(--font-board);
  font-size: calc(var(--sq) * 0.8);
  cursor: grab;
  -webkit-user-select: none;
  user-select: none;
}
.piece.w { color: #fafafa; text-shadow: 0 0 2px #1c1c1c, 0 0 3px #1c1c1c, 0 1px 2px rgba(0,0,0,0.5); }
.piece.b { color: #23201c; text-shadow: 0 0 2px rgba(255,255,255,0.55), 0 1px 2px rgba(0,0,0,0.35); }

.square.last-move { box-shadow: inset 0 0 0 100px rgba(240, 180, 41, 0.4); }
.square.selected  { box-shadow: inset 0 0 0 3px var(--accent); }
.square.in-check  { box-shadow: inset 0 0 0 100px rgba(227, 93, 93, 0.5); }
.square.flash-wrong { animation: shake 0.35s; }

.square.target-move::after {
  content: '';
  position: absolute;
  width: 32%;
  height: 32%;
  border-radius: 50%;
  background: rgba(15, 18, 12, 0.28);
}
.square.target-capture::after {
  content: '';
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  border: 4px solid rgba(15, 18, 12, 0.35);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.coord {
  position: absolute;
  font-size: calc(var(--sq) * 0.17);
  font-weight: 700;
  pointer-events: none;
}
.square.light .coord { color: rgba(40, 45, 35, 0.7); }
.square.dark  .coord { color: rgba(240, 244, 235, 0.75); }
.coord-rank { top: 2px; left: 3px; }
.coord-file { bottom: 1px; right: 3px; }

.promo-overlay {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 21, 0.78);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  z-index: 5;
}
.promo-btn {
  font-family: var(--font-board);
  font-size: 2.5rem;
  line-height: 1;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 12px;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
  color: #fafafa;
  text-shadow: 0 0 2px #1c1c1c, 0 0 3px #1c1c1c;
}
.promo-btn:hover { border-color: var(--accent); }

/* Puzzles / solver ----------------------------------------------------------- */

.puzzle-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 1.4rem;
  align-items: start;
}
.puzzle-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 72vh;
  overflow-y: auto;
  padding: 2px;
}
.puzzle-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.62rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font-size: 0.94rem;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.puzzle-item:hover { border-color: var(--accent); }
.puzzle-item.active { border-color: var(--accent); background: var(--surface-2); }
.puzzle-item.solved { opacity: 0.62; }
.puzzle-theme { flex: 1; font-weight: 550; }
.puzzle-rating { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.puzzle-check { color: var(--ok); font-weight: 800; }

.puzzle-solver {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  box-shadow: var(--shadow);
}
.solver-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.solver-head h2 { margin: 0 0 0.25rem; }
.solver-head p { margin: 0; }
.solver-meta { display: flex; gap: 0.4rem; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }
.badge {
  font-size: 0.74rem;
  font-weight: 650;
  border: 1px solid var(--border-strong);
  border-radius: 99px;
  padding: 0.16rem 0.6rem;
  color: var(--muted);
}
.badge-ok { color: var(--ok); border-color: rgba(70, 192, 125, 0.55); background: var(--ok-soft); }

.solver-board { margin: 1.1rem auto; width: max-content; }
.solver-status { text-align: center; min-height: 1.6em; margin: 0.7rem 0 0.9rem; font-weight: 550; }
.solver-actions { display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }

/* Trainer --------------------------------------------------------------------- */

.trainer-layout {
  display: grid;
  grid-template-columns: 1fr 270px;
  gap: 1.4rem;
  align-items: start;
}
.trainer-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.5rem;
  box-shadow: var(--shadow);
}
.streak-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  padding: 1.3rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}
.streak-value { display: block; font-size: 2.6rem; font-weight: 800; color: var(--accent); line-height: 1.1; }
.streak-label { color: var(--muted); }
.trainer-best p { font-size: 0.9rem; line-height: 1.55; }
.trainer-actions { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }

/* Dashboard / auth --------------------------------------------------------------- */

.theme-row {
  display: grid;
  grid-template-columns: 170px 1fr 70px;
  gap: 0.9rem;
  align-items: center;
  margin-bottom: 0.7rem;
}
.theme-name { color: var(--muted); font-size: 0.93rem; }
.theme-count { text-align: right; color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }

.activity-list { padding-left: 1.3rem; }
.activity-list li { margin-bottom: 0.45rem; }

.auth-box {
  max-width: 390px;
  margin: 3rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.7rem;
  box-shadow: var(--shadow);
}
.auth-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.1rem; }
.auth-tab {
  flex: 1;
  padding: 0.5rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  cursor: pointer;
}
.auth-tab.active { color: var(--text); border-color: var(--accent); background: var(--accent-soft); }

.back-link { display: inline-block; margin-bottom: 0.6rem; }

/* Scrollbars -------------------------------------------------------------------- */

.puzzle-list::-webkit-scrollbar { width: 8px; }
.puzzle-list::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 99px; }

/* Responsive --------------------------------------------------------------------- */

@media (max-width: 860px) {
  .puzzle-layout { grid-template-columns: 1fr; }
  .puzzle-list { flex-direction: row; flex-wrap: wrap; max-height: none; }
  .puzzle-item { flex: 1 1 42%; }
  .trainer-layout { grid-template-columns: 1fr; }
  .site-header { flex-wrap: wrap; gap: 0.6rem 1rem; }
  .site-nav { order: 3; width: 100%; }
  .site-main { padding: 1.1rem 1rem 2.5rem; }
  .theme-row { grid-template-columns: 120px 1fr 60px; }
  .lesson-body { padding: 1.1rem 1.2rem; }
}
