/* ============================================================
   Chess Drills — Card Grid + Search/Filter + Training
   ============================================================ */

/* Page header */
.drills-header {
  text-align: center;
  padding: 2rem 1rem 0.5rem;
  max-width: 900px;
  margin: 0 auto;
}
.drills-title {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.5rem;
}
.drills-subtitle {
  font-size: 1.05rem;
  color: rgba(255,255,255,.6);
  max-width: 600px;
  margin: 0 auto;
}

/* Container */
.drills-container {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

/* Training CTA Card */
.training-cta-card {
  background: linear-gradient(135deg, rgba(59,130,246,.15), rgba(124,77,255,.15));
  border: 1px solid rgba(59,130,246,.25);
  border-radius: 14px;
  padding: 1.25rem 1.5rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
  margin-bottom: 1.5rem;
}
.training-cta-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(59,130,246,.15);
}
.cta-card-top {
  display: flex;
  align-items: center;
  gap: 1rem;
}
.cta-card-icon {
  font-size: 2rem;
}
.cta-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.cta-card-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}
.cta-card-desc {
  font-size: 0.9rem;
  color: rgba(255,255,255,.6);
}
.cta-card-arrow {
  font-size: 1.5rem;
  color: rgba(255,255,255,.4);
}
.overall-progress {
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin-bottom: 0.75rem;
}
.overall-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  margin-bottom: 0.5rem;
}
.overall-progress-track {
  height: 8px;
  background: rgba(255,255,255,.1);
  border-radius: 4px;
  overflow: hidden;
}
.overall-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #3b82f6);
  border-radius: 4px;
  transition: width 0.6s;
}

/* Search + Filters Bar */
.drills-toolbar {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  align-items: center;
}
.drills-search {
  flex: 1;
  min-width: 200px;
  padding: 0.6rem 1rem 0.6rem 2.5rem;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 8px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  transition: border-color .2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.4)' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 10-1.397 1.398h-.001l3.85 3.85a1 1 0 001.415-1.414l-3.85-3.85zm-5.242.156a5 5 0 110-10 5 5 0 010 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 0.75rem center;
}
.drills-search:focus {
  border-color: rgba(59,130,246,.5);
}
.drills-search::placeholder {
  color: rgba(255,255,255,.35);
}
.drills-filters {
  display: flex;
  gap: 0.4rem;
}
.drills-filter-btn {
  padding: 0.5rem 1rem;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.7);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.drills-filter-btn:hover {
  background: rgba(255,255,255,.08);
}
.drills-filter-btn.active {
  background: rgba(59,130,246,.2);
  border-color: rgba(59,130,246,.4);
  color: #60a5fa;
}

/* Tag pills */
.drills-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}
.drills-tag-pill {
  padding: 0.3rem 0.7rem;
  border-radius: 20px;
  border: 1px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.55);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  white-space: nowrap;
}
.drills-tag-pill:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.8);
}
.drills-tag-pill.active {
  background: rgba(124,77,255,.2);
  border-color: rgba(124,77,255,.4);
  color: #b794f6;
}

/* Drill count */
.drills-count {
  font-size: 0.85rem;
  color: rgba(255,255,255,.4);
  margin-bottom: 0.75rem;
}

/* Card Grid */
.drills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 0.75rem;
}

/* Drill Card */
.drill-card {
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 10px;
  padding: 1rem 1.15rem;
  cursor: pointer;
  transition: transform .15s, border-color .2s, box-shadow .2s;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.drill-card:hover {
  transform: translateY(-2px);
  border-color: rgba(59,130,246,.3);
  box-shadow: 0 4px 16px rgba(0,0,0,.2);
}
.drill-card.item-completed {
  border-color: rgba(34,197,94,.25);
}
.drill-card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.drill-card-name {
  font-weight: 700;
  font-size: 0.95rem;
  color: #fff;
  flex: 1;
  line-height: 1.3;
}
.drill-card-check {
  display: none;
  width: 20px;
  height: 20px;
  background: #22c55e;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #fff;
  flex-shrink: 0;
}
.drill-card.item-completed {
  border-color: rgba(34, 197, 94, .25);
}
.drill-card.item-completed .drill-card-check {
  display: flex;
}

/* Favorite heart button */
.drill-fav-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  color: rgba(255,255,255,.3);
  flex-shrink: 0;
  padding: 2px 4px;
  line-height: 1;
  transition: color .2s, transform .2s;
}
.drill-fav-btn:hover {
  color: #f87171;
  transform: scale(1.2);
}
.drill-fav-btn.active {
  color: #ef4444;
}
.drill-fav-btn.active:hover {
  color: #dc2626;
}
.drill-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}
.drill-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.drill-badge.white {
  background: rgba(255,255,255,.12);
  color: rgba(255,255,255,.85);
}
.drill-badge.black {
  background: rgba(0,0,0,.35);
  color: rgba(255,255,255,.75);
  border: 1px solid rgba(255,255,255,.1);
}
.drill-card-moves {
  color: rgba(255,255,255,.4);
  font-size: 0.8rem;
}
.drill-card-desc {
  font-size: 0.82rem;
  color: rgba(255,255,255,.45);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* No results */
.drills-no-results {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(255,255,255,.4);
  font-size: 1rem;
  display: none;
}

/* ============================================================
   Training Section (reused from openings/traps pattern)
   ============================================================ */
.training-section {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}
.training-container {
  max-width: 900px;
  margin: 0 auto;
}

/* Header */
.training-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.training-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.training-header-progress {
  flex: 0 1 220px;
  min-width: 100px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-right: auto;
}
.training-header-progress-text {
  font-size: 0.85rem;
  color: rgba(255,255,255,.5);
  white-space: nowrap;
}
.training-header-progress-track {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,.08);
  border-radius: 3px;
  overflow: hidden;
}
.training-header-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #7c4dff, #448aff);
  border-radius: 3px;
  transition: width 0.6s;
  width: 0%;
}
.training-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.5);
  font-size: 2.4rem;
  cursor: pointer;
  padding: 0 0.2rem;
  line-height: 1;
  flex-shrink: 0;
}
.training-close-btn:hover {
  color: #fff;
}

/* Mode Selection */
.training-mode-select {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.training-mode-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 1.5rem 1rem;
  border-radius: 12px;
  border: 2px solid transparent;
  background: rgba(255,255,255,.04);
  cursor: pointer;
  transition: all .2s;
  color: rgba(255,255,255,.6);
}
.training-mode-card:hover {
  background: rgba(255,255,255,.08);
}
.training-mode-card.active {
  background: rgba(59,130,246,.15);
  border-color: #3b82f6;
  color: #fff;
}
.mode-card-icon {
  font-size: 2rem;
}
.mode-card-label {
  font-weight: 700;
  font-size: 1rem;
}
.mode-card-desc {
  font-size: 0.8rem;
  opacity: 0.6;
}

/* Game Area */
.training-game {
  position: relative;
}
.training-board-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}
.training-board-wrap {
  position: relative;
}
.training-board {
  width: 100%;
  aspect-ratio: 1;
}

/* Side panel */
.training-side-panel {
  display: flex;
  flex-direction: column;
  justify-content: space-around;
  gap: 1rem;
  min-height: 280px;
}
.training-stats-row {
  display: flex;
  gap: 1.5rem;
}
.training-stat {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.training-stat-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.training-stat-val {
  font-size: 1.5rem;
  font-weight: 700;
  color: #fff;
}

/* Opening info */
.training-opening-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.training-opening-name {
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}
.training-opening-color {
  font-size: 0.8rem;
  padding: 0.15rem 0.6rem;
  border-radius: 4px;
  font-weight: 600;
}

/* Opening description */
.training-opening-desc {
  margin: -0.5rem 0 1rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,.55);
  line-height: 1.5;
}

/* Status */
.training-status {
  font-size: 1.1rem;
  font-weight: 600;
  color: rgba(255,255,255,.7);
  min-height: 1.5em;
}
.training-status.correct { color: #22c55e; }
.training-status.wrong { color: #ef4444; }
.training-status.info { color: rgba(255,255,255,.7); }
.training-status.success { color: #22c55e; }
.training-status.hint { color: #f59e0b; }

/* Progress bar */
.training-progress-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.training-progress-bar {
  flex: 1;
  height: 8px;
  background: rgba(255,255,255,.08);
  border-radius: 4px;
  overflow: hidden;
}
.training-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, #22c55e, #3b82f6);
  border-radius: 4px;
  transition: width 0.3s;
  width: 0%;
}
.training-move-count {
  font-size: 0.8rem;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
}

/* Buttons */
.training-buttons {
  display: flex;
  gap: 0.75rem;
}
.training-btn {
  padding: 0.65rem 1.25rem;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all .2s;
}
.hint-btn {
  background: rgba(59,130,246,.25);
  color: #93c5fd;
  border: 1px solid rgba(59,130,246,.4);
}
.hint-btn:hover { background: rgba(59,130,246,.4); color: #fff; }
.restart-btn {
  border-color: rgba(96,165,250,.25);
  background: rgba(96,165,250,.08);
  color: #93c5fd;
}
.restart-btn:hover { background: rgba(96,165,250,.15); }
.skip-btn {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.8);
}
.skip-btn:hover { background: rgba(255,255,255,.12); }

.training-btn.fav-btn {
  background: rgba(255,255,255,.06);
  color: rgba(255,255,255,.35);
  font-size: 1.1rem;
  padding: 0.65rem 1rem;
  transition: color .2s, transform .15s;
}
.training-btn.fav-btn:hover {
  color: #f87171;
  transform: scale(1.15);
  background: rgba(255,255,255,.1);
}
.training-btn.fav-btn.active {
  color: #ef4444;
}
.training-btn.fav-btn.active:hover {
  color: #dc2626;
}

/* Training tag badge */
.training-tag-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem 0.35rem 0.8rem;
  border-radius: 20px;
  background: rgba(245,158,11,.18);
  border: 1px solid rgba(245,158,11,.5);
  color: #fbbf24;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.25rem;
}
.training-tag-badge.shake {
  animation: badge-shake 0.5s ease-in-out;
}
@keyframes badge-shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-6px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}
.training-tag-close {
  background: none;
  border: none;
  color: rgba(251,191,36,.5);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color .2s;
}
.training-tag-close:hover {
  color: #fff;
}

/* Auto-advance */
.auto-advance-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: rgba(255,255,255,.5);
  cursor: pointer;
}
.auto-advance-toggle input[type="checkbox"] {
  accent-color: #3b82f6;
}

/* Speed HUD */
.training-speed-hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  background: rgba(255,255,255,.04);
  border-radius: 10px;
}
.speed-timer {
  font-size: 2rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #fff;
}
.speed-timer.time-low { color: #ef4444; }
.speed-score-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.speed-score-label {
  font-size: 0.7rem;
  color: rgba(255,255,255,.4);
  text-transform: uppercase;
}
.speed-score-val {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}
.speed-lives-wrap {
  display: flex;
  gap: 0.25rem;
}
.speed-heart {
  font-size: 1.3rem;
  transition: opacity .3s;
}
.speed-heart.lost {
  opacity: 0.2;
}

/* Start Screen */
.training-start-screen {
  text-align: center;
  padding: 2rem 1rem;
}
.start-screen-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.training-start-screen h3 {
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 0.5rem;
}
.training-start-screen p {
  color: rgba(255,255,255,.5);
  margin-bottom: 1.5rem;
}
.speed-time-options {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}
.speed-time-btn {
  padding: 0.6rem 1.5rem;
  border-radius: 8px;
  border: 2px solid rgba(255,255,255,.1);
  background: rgba(255,255,255,.04);
  color: rgba(255,255,255,.7);
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.speed-time-btn.active {
  border-color: #3b82f6;
  background: rgba(59,130,246,.15);
  color: #60a5fa;
}
.training-start-btn {
  padding: 0.85rem 2.5rem;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #3b82f6, #7c4dff);
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  cursor: pointer;
  transition: transform .2s, box-shadow .2s;
}
.training-start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(59,130,246,.3);
}
.speed-best-display {
  margin-top: 1rem;
  font-size: 0.9rem;
  color: rgba(255,255,255,.4);
}

/* Game Over */
.training-gameover {
  text-align: center;
  padding: 2rem 1rem;
}
.gameover-close-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  font-size: 1.5rem;
  cursor: pointer;
}
.gameover-icon {
  font-size: 3rem;
  margin-bottom: 0.5rem;
}
.training-gameover h3 {
  font-size: 1.3rem;
  color: #fff;
  margin-bottom: 0.75rem;
}
.gameover-score {
  font-size: 3rem;
  font-weight: 800;
  color: #fff;
}
.gameover-label {
  font-size: 0.9rem;
  color: rgba(255,255,255,.5);
  margin-bottom: 0.75rem;
}
.gameover-best, .gameover-xp {
  font-size: 0.9rem;
  color: rgba(255,255,255,.4);
  margin-bottom: 0.25rem;
}
.gameover-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  margin-top: 1.5rem;
}

/* Completion flash / confetti */
.training-complete-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}
.confetti-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  animation: confetti-fall 1.4s ease-out forwards;
}
@keyframes confetti-fall {
  0% { opacity: 1; transform: translateY(0) rotate(0deg); }
  100% { opacity: 0; transform: translateY(400px) rotate(360deg); }
}

/* Board effects */
.flash-correct {
  animation: flash-correct 0.3s;
}
@keyframes flash-correct {
  0% { box-shadow: 0 0 30px rgba(34,197,94,.6); }
  100% { box-shadow: 0 0 0 rgba(34,197,94,0); }
}
.shake {
  animation: shake 0.4s;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* XP Toast (if not globally styled) */
.xp-toast {
  position: fixed;
  top: 80px;
  right: 20px;
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  z-index: 10000;
  opacity: 0;
  transform: translateX(100px);
  transition: opacity .4s, transform .4s;
  pointer-events: none;
}
.xp-toast.show {
  opacity: 1;
  transform: translateX(0);
}
.xp-toast-title {
  font-weight: 800;
  font-size: 1.1rem;
}
.xp-toast-sub {
  font-size: 0.8rem;
  opacity: 0.85;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 700px) {
  .drills-title { font-size: 1.5rem; }
  .drills-grid {
    grid-template-columns: 1fr;
  }
  .training-mode-select {
    flex-direction: column;
  }
  .training-board-layout {
    grid-template-columns: 1fr;
  }
  .training-board {
    max-width: 400px;
    margin: 0 auto;
  }
  .drills-toolbar {
    flex-direction: column;
  }
  .drills-search {
    min-width: 100%;
  }
}

@media (max-width: 480px) {
  .drills-grid {
    gap: 0.5rem;
  }
  .drill-card {
    padding: 0.85rem 1rem;
  }
}
