/* Alucard — Design Language compliant styles
   Base unit: 8px. Palette A (Cool neutral). Blue/Orange accents.
   Dark/light mode equal citizens. */

:root {
  --base: 8px;
  --surface: #F5F5F5;
  --on-surface: #1A1A1A;
  --subtle: #6B6B6B;
  --accent-primary: #2563EB;
  --accent-secondary: #EA580C;
  --positive: #2563EB;
  --negative: #EA580C;
  --surface-raised: #FFFFFF;
  --surface-sunken: #E8E8E8;
  --border: #D4D4D4;
  --card-bg: #FFFFFF;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --surface: #121212;
    --on-surface: #E8E8E8;
    --subtle: #6B6B6B;
    --accent-primary: #3B82F6;
    --accent-secondary: #F97316;
    --positive: #3B82F6;
    --negative: #F97316;
    --surface-raised: #1E1E1E;
    --surface-sunken: #0A0A0A;
    --border: #2E2E2E;
    --card-bg: #1E1E1E;
  }
}

[data-theme="dark"] {
  --surface: #121212;
  --on-surface: #E8E8E8;
  --subtle: #6B6B6B;
  --accent-primary: #3B82F6;
  --accent-secondary: #F97316;
  --positive: #3B82F6;
  --negative: #F97316;
  --surface-raised: #1E1E1E;
  --surface-sunken: #0A0A0A;
  --border: #2E2E2E;
  --card-bg: #1E1E1E;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  line-height: 1.5;
}

body {
  font-family: -apple-system, 'Segoe UI', system-ui, sans-serif;
  background: var(--surface);
  color: var(--on-surface);
  min-height: 100vh;
}

/* --- Layout --- */

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: calc(var(--base) * 3) calc(var(--base) * 2);
}

/* --- Header --- */

header {
  border-bottom: 1px solid var(--border);
  padding: calc(var(--base) * 2) 0;
  margin-bottom: calc(var(--base) * 4);
}

header .header-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 calc(var(--base) * 2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

header h1 a {
  color: var(--on-surface);
  text-decoration: none;
}

header nav {
  display: flex;
  gap: calc(var(--base) * 2);
  align-items: center;
}

header nav a {
  color: var(--subtle);
  text-decoration: none;
  font-size: 0.875rem;
  transition: color 150ms ease-out;
}

header nav a:hover,
header nav a:focus-visible {
  color: var(--accent-primary);
}

/* --- Theme toggle --- */

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--subtle);
  cursor: pointer;
  padding: calc(var(--base) * 0.5) calc(var(--base) * 1);
  border-radius: 4px;
  font-size: 0.875rem;
  transition: color 150ms ease-out, border-color 150ms ease-out;
}

.theme-toggle:hover {
  color: var(--on-surface);
  border-color: var(--subtle);
}

/* --- Main language selector --- */

.main-lang-selector {
  display: flex;
  align-items: center;
  gap: calc(var(--base) * 1.5);
  margin-bottom: calc(var(--base) * 3);
}

.main-lang-selector label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--subtle);
}

.main-lang-selector select {
  font-family: inherit;
  font-size: 0.875rem;
  padding: calc(var(--base) * 0.75) calc(var(--base) * 1.5);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--on-surface);
  cursor: pointer;
  transition: border-color 150ms ease-out;
}

.main-lang-selector select:hover,
.main-lang-selector select:focus-visible {
  border-color: var(--accent-primary);
  outline: none;
}

.main-lang-selector select:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- Language grid --- */

.lang-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: calc(var(--base) * 2);
  margin-bottom: calc(var(--base) * 4);
}

.lang-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: calc(var(--base) * 3);
  text-decoration: none;
  color: var(--on-surface);
  transition: border-color 150ms ease-out;
}

.lang-card:hover,
.lang-card:focus-visible {
  border-color: var(--accent-primary);
}

.lang-card h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: calc(var(--base) * 1);
}

.lang-card .meta {
  font-size: 0.8125rem;
  color: var(--subtle);
}

/* --- Language tiles --- */

.lang-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--base) * 1);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: calc(var(--base) * 4) calc(var(--base) * 3);
  text-decoration: none;
  color: var(--on-surface);
  transition: border-color 150ms ease-out;
}

.lang-tile:hover,
.lang-tile:focus-visible {
  border-color: var(--accent-primary);
}

.lang-tile-flag {
  font-size: 2.5rem;
  line-height: 1;
}

.lang-tile-name {
  font-size: 1.125rem;
  font-weight: 600;
}

.lang-tile-meta {
  font-size: 0.8125rem;
  color: var(--subtle);
}

/* --- Category list --- */

.category-header {
  margin-bottom: calc(var(--base) * 3);
}

.category-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
}

.category-header .breadcrumb {
  font-size: 0.8125rem;
  color: var(--subtle);
  margin-bottom: calc(var(--base) * 1);
}

.category-header .breadcrumb a {
  color: var(--accent-primary);
  text-decoration: none;
}

.cat-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: calc(var(--base) * 1);
}

.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--base) * 1.5) calc(var(--base) * 2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  text-decoration: none;
  color: var(--on-surface);
  transition: border-color 150ms ease-out;
}

.cat-item:hover,
.cat-item:focus-visible {
  border-color: var(--accent-primary);
}

.cat-item .name {
  font-weight: 500;
}

.cat-item .count {
  font-size: 0.8125rem;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
}

.cat-item .progress-indicator {
  display: flex;
  align-items: center;
  gap: calc(var(--base) * 1);
}

.progress-bar-mini {
  width: 48px;
  height: 4px;
  background: var(--surface-sunken);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-mini .fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 2px;
  transition: width 200ms ease-out;
}

/* --- Practice view --- */

.practice-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: calc(var(--base) * 4);
}

.practice-header .info {
  font-size: 0.8125rem;
  color: var(--subtle);
}

.practice-header .info a {
  color: var(--accent-primary);
  text-decoration: none;
}

.practice-stats {
  display: flex;
  gap: calc(var(--base) * 3);
  font-size: 0.8125rem;
  color: var(--subtle);
  font-variant-numeric: tabular-nums;
  margin-bottom: calc(var(--base) * 3);
}

.practice-stats .stat-correct {
  color: var(--positive);
}

.practice-stats .stat-wrong {
  color: var(--negative);
}

.flashcard-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: calc(var(--base) * 3);
}

.flashcard {
  width: 100%;
  min-width: 100%;
  min-height: 200px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--base) * 4);
  cursor: pointer;
  user-select: none;
  transition: border-color 150ms ease-out;
  position: relative;
}

.flashcard:hover {
  border-color: var(--subtle);
}

.flashcard .card-label {
  position: absolute;
  top: calc(var(--base) * 1.5);
  left: calc(var(--base) * 2);
  font-size: 0.6875rem;
  color: var(--subtle);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flashcard .card-text {
  font-size: 1.5rem;
  font-weight: 600;
  text-align: center;
  line-height: 1.3;
}

.flashcard .card-hint {
  position: absolute;
  bottom: calc(var(--base) * 1.5);
  font-size: 0.75rem;
  color: var(--subtle);
}

.flashcard.revealed {
  border-color: var(--accent-primary);
}

.answer-buttons {
  display: flex;
  gap: calc(var(--base) * 2);
  width: 100%;
}

.btn-wrong,
.btn-correct {
  width: 50%;
}

.btn {
  padding: calc(var(--base) * 1) calc(var(--base) * 3);
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--surface-raised);
  color: var(--on-surface);
  font-size: 0.875rem;
  cursor: pointer;
  transition: border-color 150ms ease-out, background 150ms ease-out;
}

.btn:hover,
.btn:focus-visible {
  border-color: var(--subtle);
}

.btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.btn-correct {
  border-color: var(--positive);
  color: var(--positive);
}

.btn-correct:hover {
  background: var(--positive);
  color: var(--surface);
}

.btn-wrong {
  border-color: var(--negative);
  color: var(--negative);
}

.btn-wrong:hover {
  background: var(--negative);
  color: var(--surface);
}

.btn-primary {
  background: var(--accent-primary);
  color: #fff;
  border-color: var(--accent-primary);
}

.btn-primary:hover {
  opacity: 0.9;
}

.btn-danger {
  border-color: var(--negative);
  color: var(--negative);
}

.btn-danger:hover {
  background: var(--negative);
  color: var(--surface);
}

#reveal-prompt {
  width: 100%;
}

.btn-reveal {
  width: 100%;
}

/* --- Progress bar --- */

.progress-section {
  margin-top: calc(var(--base) * 3);
  width: 100%;
  max-width: 480px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--surface-sunken);
  border-radius: 3px;
  overflow: hidden;
}

.progress-bar .fill {
  height: 100%;
  background: var(--accent-primary);
  border-radius: 3px;
  transition: width 200ms ease-out;
}

.progress-label {
  font-size: 0.75rem;
  color: var(--subtle);
  margin-top: calc(var(--base) * 0.5);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* --- Settings page --- */

.settings-section {
  margin-bottom: calc(var(--base) * 4);
}

.settings-section h2 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: calc(var(--base) * 2);
}

.settings-section h3 {
  font-size: 0.9375rem;
  font-weight: 500;
  margin-bottom: calc(var(--base) * 1);
  margin-top: calc(var(--base) * 2);
}

.reset-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: calc(var(--base) * 1);
}

.reset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--base) * 1) calc(var(--base) * 2);
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
}

.reset-item .label {
  font-size: 0.875rem;
}

.reset-all-section {
  padding: calc(var(--base) * 3);
  border: 1px solid var(--negative);
  border-radius: 4px;
  margin-top: calc(var(--base) * 3);
}

.reset-all-section p {
  font-size: 0.875rem;
  color: var(--subtle);
  margin-bottom: calc(var(--base) * 2);
}

/* --- Keyboard hints --- */

.kbd-hint {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .kbd-hint {
    display: inline;
    font-size: 0.6875rem;
    color: var(--subtle);
    margin-left: calc(var(--base) * 0.5);
  }

  kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 0.6875rem;
    font-family: inherit;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface-sunken);
  }
}

/* --- Responsive --- */

@media (max-width: 480px) {
  .container {
    padding: calc(var(--base) * 2) calc(var(--base) * 1.5);
  }

  .flashcard .card-text {
    font-size: 1.25rem;
  }

  .lang-grid {
    grid-template-columns: 1fr;
  }
}

/* --- Focus visible --- */

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

/* --- Reduced motion --- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
  }
}

/* --- Skip link --- */

.skip-link {
  position: absolute;
  top: -100%;
  left: calc(var(--base) * 2);
  background: var(--accent-primary);
  color: #fff;
  padding: calc(var(--base) * 1) calc(var(--base) * 2);
  border-radius: 4px;
  z-index: 1000;
  font-size: 0.875rem;
}

.skip-link:focus {
  top: calc(var(--base) * 1);
}
