﻿/* css/kids.css */
/* Modern Dark Theme - Polish Pass */

:root {
  /* --- Design Tokens --- */

  /* Palette */
  --bg-app: #1e1e1e;
  /* Main App Background */
  --bg-panel: #252525;
  /* Sidebars */
  --bg-card: #2e2e2e;
  /* Cards/Inputs */
  --bg-hover: rgba(255, 255, 255, 0.08);

  /* Accents */
  --accent-primary: #3692e7;
  /* Blue (Method, Active) */
  --accent-success: #629924;
  /* Green (Coach, Hints) */
  --accent-error: #e74c3c;
  /* Red (Mistakes) */
  --accent-warning: #f1c40f;
  /* Yellow */

  /* Text */
  --text-main: #f0f0f0;
  --text-muted: #a0a0a0;
  --text-dim: #666666;

  /* Borders & Shadows */
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(255, 255, 255, 0.15);
  --shadow-soft: 0 4px 12px rgba(0, 0, 0, 0.15);
  --shadow-card: 0 2px 8px rgba(0, 0, 0, 0.2);

  /* Dimensions */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --gap-sm: 8px;
  --gap-md: 16px;

  /* Board Preference (Pink/White) */
  --board-white: #f0f0f0;
  --board-black: #ec94a4;
  --highlight-white: rgba(246, 172, 137, 0.9);
  --highlight-black: rgba(235, 115, 95, 0.9);
  --highlight-check: rgba(250, 74, 74, 0.9);
}

/* --- Global Reset & Typography --- */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  background: var(--bg-app);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout Structure --- */
.app-layout {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* --- Left Sidebar --- */
.sidebar-left {
  width: 250px;
  background: var(--bg-panel);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 10;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-header h1 {
  font-size: 16px;
  font-weight: 700;
  margin: 0;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

/* Sidebar Nav */
.sidebar-menu {
  flex: 1;
  padding: 10px 0;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* Navigation Categories */
.nav-category {
  margin-bottom: 4px;
}

.nav-header {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  cursor: pointer;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 14px;
  transition: color 0.2s, background 0.2s;
  user-select: none;
}

.nav-header:hover {
  color: var(--text-main);
  background: var(--bg-hover);
}

.nav-header .icon {
  margin-right: 12px;
  width: 20px;
  text-align: center;
  opacity: 0.7;
}

.nav-header .arrow {
  margin-left: auto;
  font-size: 10px;
  opacity: 0.5;
  transition: transform 0.25s ease;
}

.nav-category.expanded .arrow {
  transform: rotate(90deg);
  /* 90deg for > to v if using > initially */
}

/* If using ▼/▶ icons directly, JS handles text swap, or rotate logic applies to a chevron */

.nav-items {
  display: block;
  padding-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  padding: 8px 20px 8px 52px;
  /* Indented */
  text-decoration: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
  border-right: 3px solid transparent;
  /* Right border for active state? Or pill? */
}

/* User requested "soft pill highlight" style */
.nav-item {
  margin: 2px 12px 2px 0;
  /* Gap on right */
  border-radius: 0 20px 20px 0;
  /* Pill shape on right end */
  border-right: none;
  padding-right: 12px;
}

.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text-muted);
}

.nav-item.active {
  background: rgba(54, 146, 231, 0.15);
  color: var(--accent-primary);
  font-weight: 600;
}

.nav-item.disabled {
  opacity: 0.3;
  pointer-events: none;
}

/* Sidebar Icons */
.nav-icon {
  width: 22px;
  height: 22px;
  vertical-align: middle;
  margin-right: 8px;
  /* Ensure visibility on dark theme */
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.nav-piece {
  width: 16px;
  height: 16px;
  vertical-align: middle;
  margin: 0 1px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.3));
}

.nav-label {
  vertical-align: middle;
}

/* Footer Profile */
.user-profile {
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.user-profile:hover {
  background: var(--bg-hover);
}

.avatar {
  background: var(--bg-card);
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  box-shadow: var(--shadow-card);
}

.username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-main);
}

.rating {
  font-size: 12px;
  color: var(--text-dim);
}


/* --- Main Content (Board) --- */
.main-content {
  flex: 1;
  background: var(--bg-app);
  /* Match global bg */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 24px;
}

.game-header {
  position: absolute;
  top: 24px;
  text-align: center;
}

#posTitle {
  font-size: 20px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: -0.01em;
}

#levelLabel {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
  font-weight: 500;
}

.board-container {
  display: flex;
  flex-direction: column;
  gap: var(--gap-md);
  /* Add subtle frame container? Or just apply to board itself */
}

/* Board styling improvements */
#board {
  width: 600px;
  max-width: 75vh;
  max-height: 75vh;
  border-radius: 4px;
  /* Chessboard.js limitation usually, but wrapper has logic */
  box-shadow: var(--shadow-soft);
  /* Border? */
  border: 4px solid var(--bg-card);
  /* Fake border frame */
}

/* Override Chessboard transitions for snappy feel */
#board img,
body>img.piece-417db {
  transition: none !important;
  will-change: transform, top, left;
}

/* Player Info */
.player-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: var(--text-muted);
  width: 100%;
  padding: 4px 0;
}


/* --- Right Sidebar (Tools) --- */
.sidebar-right {
  width: 320px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  display: flex !important;
  flex-direction: column !important;
  height: 100vh;
  padding: 24px;
}

.right-top {
  flex: 0 0 auto;
  width: 100%;
  margin-bottom: 20px;
}

.right-middle {
  flex: 1;
  overflow-y: auto;
  padding-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
}

.right-bottom {
  flex: 0 0 auto;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- UI Components: Cards --- */
/* Unified Card Style */
.card-glass {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s;
}

/* Coach Panel (The main card) */
.coach-panel {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  /* Increased padding */
  box-shadow: var(--shadow-card);
  transition: transform 0.2s, box-shadow 0.2s;

  background: linear-gradient(180deg, rgba(46, 46, 46, 1) 0%, rgba(40, 40, 40, 1) 100%);
  min-height: 240px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.coach-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  font-weight: 700;
  margin-bottom: 12px;
}

.coach-verdict {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 10px;
}

.coach-explain {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted);
  flex: 1;
}

.coach-actions {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}



/* Mistake Mode Inside Coach */
.mistake-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  animation: fadeIn 0.3s ease;
}

.mistake-title {
  color: var(--accent-error);
  font-weight: 700;
  margin-bottom: 4px;
}

.mistake-text {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin-bottom: 12px;
}

.mistake-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: auto;
}

/* Why button spans full width if needed, grid handles it via ID or specific class */
#mistakeWhyBtn {
  grid-column: span 2;
}


/* Method / Plan Box */
.method-box {
  background: rgba(54, 146, 231, 0.05);
  border: 1px solid rgba(54, 146, 231, 0.15);
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 14px;
}

.method-step {
  position: relative;
  padding-left: 20px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.method-step::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--accent-primary);
  font-weight: bold;
}

/* --- Buttons --- */
/* Base Button */
button {
  font-family: inherit;
  border: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  font-weight: 600;
  font-size: 14px;
  height: 42px;
  /* Consistent height */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

button:active {
  transform: scale(0.98);
}

/* Ghost Button (Navigation, Plan, Hints) */
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-focus);
  color: var(--text-muted);
}

.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--text-muted);
  color: var(--text-main);
}

/* Inline Hint Button (Smaller) */
.btn-hint-inline {
  height: 28px;
  padding: 0 12px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  border-radius: 14px;
}

.btn-hint-inline:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

/* Primary / Action Buttons */
.btn-mistake-primary {
  background: var(--accent-error);
  color: white;
}

.btn-mistake-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

.btn-mistake-secondary {
  background: var(--bg-hover);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.btn-mistake-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
}

.btn-giveup {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-dim);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 1px;
}

.btn-giveup:hover {
  background: var(--bg-hover);
  color: var(--accent-error);
  border-color: rgba(231, 76, 60, 0.3);
}


/* --- Toggles & Controls --- */
.controls-bar button {
  height: 36px;
  /* Slightly smaller for board controls */
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
}

.controls-bar button:hover {
  background: var(--bg-hover);
  color: var(--text-main);
}

/* Toggle Switch */
.toggle-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  position: relative;
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Sidebar Controls Cluster (Bottom Left) */
.sidebar-controls {
  margin: 0 16px 20px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
}

/* Level Nav (Now in Right Panel) */
.level-nav-sidebar {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 16px 0;
  /* Vertical spacing in right panel */
  width: 100%;
}

/* Sidebar Settings Reset */
.sidebar-settings {
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* Shrink toggles in sidebar settings to fit longer text */
.sidebar-settings .slider {
  width: 36px;
  height: 20px;
}

.sidebar-settings .slider::before {
  height: 16px;
  width: 16px;
  left: 2px;
  bottom: 2px;
}

.sidebar-settings input:checked+.slider::before {
  transform: translateX(16px);
}

.sidebar-settings .toggle-label {
  font-size: 14px;
}

.setting-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0;
}

.btn-sidebar-nav {
  padding: 0 16px;
  background: var(--bg-hover);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: auto;
  min-width: 80px;
}

.btn-sidebar-nav:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* Method Container (Below Coach) */
.method-container {
  margin-top: 12px;
  width: 100%;
}

/* Method Button - Subtle, Full Width */
.btn-ghost {
  width: 100%;
  padding: 10px;
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
}

.btn-ghost:hover {
  background: var(--bg-hover);
  color: var(--text-main);
  border-color: var(--border-focus);
}

/* Color Coding for Kids (Subtle) */
#nextBtn {
  border-color: rgba(98, 153, 36, 0.3);
  background: rgba(98, 153, 36, 0.08);
  /* Green */
  color: #9ccc65;
}

#nextBtn:hover {
  background: rgba(98, 153, 36, 0.15);
  color: #fff;
  border-color: rgba(98, 153, 36, 0.5);
}

/* Hint -> Blue */
.btn-hint-inline {
  border-color: rgba(54, 146, 231, 0.3);
  background: rgba(54, 146, 231, 0.08);
  color: #6bcafb;
}

.btn-hint-inline:hover {
  background: rgba(54, 146, 231, 0.15);
  color: #fff;
}

/* Mistake Retry -> Amber */
.btn-mistake-retry {
  border-color: rgba(241, 196, 15, 0.3);
  background: rgba(241, 196, 15, 0.1);
  color: #fdd835;
}

.btn-mistake-retry:hover {
  background: rgba(241, 196, 15, 0.2);
  color: #fff;
}

/* Mistake Keep Playing -> Green */
.btn-mistake-keep {
  border-color: rgba(98, 153, 36, 0.3);
  background: rgba(98, 153, 36, 0.1);
  color: #9ccc65;
}

.btn-mistake-keep:hover {
  background: rgba(98, 153, 36, 0.2);
  color: #fff;
}

/* Mistake Why -> Blue */
.btn-mistake-why {
  border-color: rgba(54, 146, 231, 0.3);
  background: rgba(54, 146, 231, 0.1);
  color: #6bcafb;
}

.btn-mistake-why:hover {
  background: rgba(54, 146, 231, 0.2);
  color: #fff;
}

.slider {
  width: 44px;
  height: 24px;
  background-color: #444;
  border-radius: 24px;
  position: relative;
  transition: 0.3s;
}

.slider::before {
  content: "";
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  border-radius: 50%;
  transition: 0.3s;
}

input:checked+.slider {
  background-color: var(--accent-success);
}

input:checked+.slider::before {
  transform: translateX(20px);
}

/* --- Fail/Messages --- */
.fail-container {
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.fail-icon {
  font-size: 48px;
  margin-bottom: 16px;
  color: var(--accent-error);
  opacity: 0.8;
}

.fail-text {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
}

.fail-actions {
  display: flex;
  gap: 8px;
  width: 100%;
}

/* Animation Utils */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Chessboard overrides for colors */
.white-1e1d7 {
  background-color: var(--board-white) !important;
  color: var(--board-black) !important;
}

.black-3c85d {
  background-color: var(--board-black) !important;
  color: var(--board-white) !important;
}

/* Remove default yellow highlighting from Chessboard.js */
.highlight1-32417,
.highlight2-9c5d2 {
  box-shadow: none !important;
  opacity: 1 !important;
}

/* Highlights */
.highlight-selected.white-1e1d7,
.highlight-last.white-1e1d7 {
  background-color: var(--highlight-white) !important;
  box-shadow: none !important;
}

.highlight-selected.black-3c85d,
.highlight-last.black-3c85d {
  background-color: var(--highlight-black) !important;
  box-shadow: none !important;
}

.highlight-check.white-1e1d7,
.highlight-check.black-3c85d {
  background-color: var(--highlight-check) !important;
}

/* Hint Dots - Restored to original size */
.legal-move-hint::after {
  content: '';
  position: absolute;
  width: 35%;
  height: 35%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}