/* ══════════════════════════════════════════════════════════════
   SPANISH VOCAB APP — STYLES
   Color system:
     --gray   = #94a3b8  (never practiced)
     --red    = #ef4444  (last attempt incorrect)
     --green  = #22c55e  (correct once)
     --blue   = #3b82f6  (correct twice+)
══════════════════════════════════════════════════════════════ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f172a;
  --bg-card:      #1e293b;
  --bg-card-2:    #273549;
  --border:       #334155;
  --text:         #f1f5f9;
  --text-muted:   #94a3b8;
  --accent:       #6366f1;

  --col-gray:     #475569;
  --col-red:      #ef4444;
  --col-green:    #22c55e;
  --col-blue:     #3b82f6;

  --radius:       10px;
  --radius-lg:    18px;
  --shadow:       0 4px 24px rgba(0,0,0,0.4);
  --transition:   0.18s ease;
}

html { font-size: 16px; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Utility ── */
.hidden { display: none !important; }

/* ══════════════════════════════════════════════════════════════
   TOP BAR
══════════════════════════════════════════════════════════════ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  height: 56px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.logo {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.btn-progress-overview {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.4rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: background var(--transition), border-color var(--transition);
}
.btn-progress-overview:hover {
  background: var(--accent);
  border-color: var(--accent);
}

/* ══════════════════════════════════════════════════════════════
   MAIN CONTENT
══════════════════════════════════════════════════════════════ */
.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

.page-header {
  margin-bottom: 2rem;
}
.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}
.subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* ══════════════════════════════════════════════════════════════
   UNIT CARDS (Homepage)
══════════════════════════════════════════════════════════════ */
.unit-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  transition: border-color var(--transition);
}
.unit-card:hover { border-color: #4b5563; }

/* Colored left-border accent per unit */
.unit-card-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  cursor: pointer;
  user-select: none;
}
.unit-accent-bar {
  width: 5px;
  height: 36px;
  border-radius: 4px;
  flex-shrink: 0;
}
.unit-title-block h2 {
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.2;
}
.unit-title-block .unit-meta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 1px;
}
.unit-card-header:hover .unit-title-block h2 {
  text-decoration: underline;
  text-decoration-color: var(--text-muted);
}

/* Unit-level progress bar */
.unit-progress-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.progress-bar-track {
  flex: 1;
  height: 8px;
  background: var(--bg-card-2);
  border-radius: 99px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--col-green);
  transition: width 0.4s ease;
  min-width: 0;
}
.progress-pct {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--col-green);
  min-width: 36px;
  text-align: right;
}

/* ── Sections inside a unit card ── */
.section-block {
  margin-bottom: 1.25rem;
}
.section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  user-select: none;
}
.section-header-name {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color var(--transition);
}
.section-header:hover .section-header-name { color: var(--text); }

/* Section progress bar (slimmer) */
.section-progress-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.section-progress-row .progress-bar-track { height: 5px; }
.section-progress-row .progress-pct {
  font-size: 0.72rem;
  min-width: 30px;
  color: var(--text-muted);
}

/* ══════════════════════════════════════════════════════════════
   WORD BOX GRID
══════════════════════════════════════════════════════════════ */
.word-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

/* Small compact boxes on homepage */
.word-box {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform var(--transition), opacity var(--transition);
  position: relative;
  flex-shrink: 0;
}
.word-box:hover { transform: scale(1.25); z-index: 10; }

/* Large boxes in unit view */
.word-grid-large .word-box {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.6rem;
  font-weight: 700;
  color: rgba(255,255,255,0.6);
  text-align: center;
  overflow: hidden;
  padding: 2px;
  line-height: 1.1;
}

/* Box status colors */
.status-0 { background: var(--col-gray);  }   /* never practiced */
.status-1 { background: var(--col-red);   }   /* last incorrect  */
.status-2 { background: var(--col-green); }   /* correct once    */
.status-3 { background: var(--col-blue);  }   /* correct 2x+     */

/* Flash animations for feedback */
@keyframes flashCorrect {
  0%   { filter: brightness(1); }
  40%  { filter: brightness(1.7); }
  100% { filter: brightness(1); }
}
@keyframes flashWrong {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-4px); }
  40%      { transform: translateX(4px); }
  60%      { transform: translateX(-3px); }
  80%      { transform: translateX(3px); }
}
.flash-correct { animation: flashCorrect 0.5s ease; }
.flash-wrong   { animation: flashWrong 0.4s ease; }

/* ══════════════════════════════════════════════════════════════
   TOOLTIP
══════════════════════════════════════════════════════════════ */
.word-tooltip {
  position: fixed;
  background: #1e293b;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.82rem;
  pointer-events: none;
  z-index: 999;
  max-width: 220px;
  box-shadow: var(--shadow);
  line-height: 1.6;
}
.word-tooltip .tip-es { font-weight: 700; color: var(--text); }
.word-tooltip .tip-en { color: var(--text-muted); }

/* ══════════════════════════════════════════════════════════════
   UNIT VIEW (Focused)
══════════════════════════════════════════════════════════════ */
.btn-back {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  margin-bottom: 1.5rem;
  transition: color var(--transition), border-color var(--transition);
}
.btn-back:hover { color: var(--text); border-color: var(--text-muted); }

#unitViewHeader {
  margin-bottom: 2rem;
}
#unitViewHeader h1 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}
#unitViewHeader .unit-meta {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Section blocks in unit view */
.uv-section-block {
  margin-bottom: 2.5rem;
}
.uv-section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color var(--transition);
}
.uv-section-title:hover { color: var(--text); }
.uv-section-title .filter-badge {
  font-size: 0.65rem;
  background: var(--accent);
  color: white;
  padding: 1px 7px;
  border-radius: 99px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
}

/* ══════════════════════════════════════════════════════════════
   PRACTICE BAR (Fixed bottom)
══════════════════════════════════════════════════════════════ */
.practice-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  padding: 0.75rem 1rem;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

.practice-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.5rem;
  display: grid;
  grid-template-columns: 1fr 2fr auto;
  align-items: center;
  gap: 1.5rem;
  min-height: 90px;
}

.practice-prompt {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.practice-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.practice-word {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: var(--text);
  min-height: 1.8rem;
}

.practice-input-area {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.practice-input-wrapper {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.practice-input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.05rem;
  padding: 0.6rem 0.9rem;
  outline: none;
  transition: border-color var(--transition);
}
.practice-input:focus { border-color: var(--accent); }

/* Input border feedback */
.practice-input.input-correct { border-color: var(--col-green) !important; }
.practice-input.input-wrong   { border-color: var(--col-red)   !important; }

/* Inline feedback below input */
.practice-feedback {
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.3rem;
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}
.practice-feedback.feedback-correct {
  color: var(--col-green);
  background: rgba(34,197,94,0.12);
}
.practice-feedback.feedback-wrong {
  color: var(--col-red);
  background: rgba(239,68,68,0.12);
}

/* Practice again button */
.btn-practice-again {
  background: var(--accent);
  border: none;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 700;
  transition: opacity var(--transition);
  white-space: nowrap;
}
.btn-practice-again:hover { opacity: 0.85; }

/* Cycle info (right column) */
.practice-cycle-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.85rem;
}
.practice-cycle-info span:first-child {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text);
}
.cycle-label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Spacer so fixed bar doesn't cover content */
.practice-bar-spacer { height: 130px; }

/* ══════════════════════════════════════════════════════════════
   PROGRESS OVERVIEW MODAL
══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.modal-header h2 { font-size: 1.4rem; font-weight: 800; }
.modal-close {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  transition: color var(--transition), border-color var(--transition);
}
.modal-close:hover { color: var(--text); border-color: var(--text-muted); }

/* Stacked progress bar */
.overview-bar-wrapper {
  margin-bottom: 0.75rem;
}
.overview-bar {
  display: flex;
  height: 40px;
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
}
.overview-bar-seg {
  height: 100%;
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: rgba(255,255,255,0.9);
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}

/* Legend */
.overview-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.legend-item { display: flex; align-items: center; gap: 0.4rem; }
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  flex-shrink: 0;
}
.dot-gray  { background: var(--col-gray);  }
.dot-red   { background: var(--col-red);   }
.dot-green { background: var(--col-green); }
.dot-blue  { background: var(--col-blue);  }

/* Stats table */
.overview-stats {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
  line-height: 2;
}
.overview-stats p { display: flex; justify-content: space-between; }
.overview-stats .stat-label { color: var(--text-muted); }
.overview-stats .stat-value { font-weight: 700; }

.btn-secondary {
  background: var(--bg-card-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 1.25rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background var(--transition);
}
.btn-secondary:hover { background: var(--border); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
══════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .practice-bar-inner {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .practice-cycle-info {
    grid-column: 2;
    grid-row: 1;
    align-items: flex-end;
  }
  .practice-input-area {
    grid-column: 1 / -1;
  }
  .practice-word { font-size: 1.1rem; }
  .word-grid-large .word-box { width: 36px; height: 36px; }
}