/* ═══════════════════════════════════════════════════════════════
   Slovora Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
  /* ── Palette ──────────────────────────────────────────────── */
  --bg-primary: #0f1118;
  --bg-secondary: #181b25;
  --bg-card: #1e2230;
  --bg-card-hover: #262b3d;
  --bg-answer-zone: #14171f;
  --bg-glass: rgba(30, 34, 48, 0.7);

  --accent: #6c5ce7;
  --accent-light: #a29bfe;
  --accent-glow: rgba(108, 92, 231, 0.25);

  --success: #00cec9;
  --success-glow: rgba(0, 206, 201, 0.25);
  --error: #ff6b6b;
  --error-glow: rgba(255, 107, 107, 0.25);
  --warning: #feca57;

  --text-primary: #eef0f6;
  --text-secondary: #8b90a0;
  --text-dim: #5a5f72;

  --border: rgba(255, 255, 255, 0.06);
  --border-accent: rgba(108, 92, 231, 0.3);

  /* ── Typography ───────────────────────────────────────────── */
  --font-ui: 'Inter', system-ui, -apple-system, sans-serif;
  --font-content: 'Noto Sans', 'Inter', sans-serif;

  /* ── Spacing & Shapes ─────────────────────────────────────── */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-xl: 24px;

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-bounce: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Reset & Base ─────────────────────────────────────────────── */

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

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Header ───────────────────────────────────────────────────── */

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  margin-bottom: 8px;
}

.header-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.header-logo {
  font-size: 1.4rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-actions {
  display: flex;
  gap: 8px;
}

/* ── Buttons ──────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #7c6cf0);
  color: white;
  box-shadow: var(--shadow-glow);
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 30px var(--accent-glow);
}
.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.btn-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-size: 1.1rem;
}
.btn-icon:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.btn-back {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1.2rem;
  padding: 8px;
  cursor: pointer;
  transition: color var(--transition);
}
.btn-back:hover {
  color: var(--accent-light);
}

/* ── Menu Cards ───────────────────────────────────────────────── */

.menu-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.menu-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 16px;
}
.menu-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.menu-card-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-glow), rgba(162, 155, 254, 0.1));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.menu-card-text h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 2px;
}

.menu-card-text p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-family: var(--font-content);
}

/* ── Exercise Screen ──────────────────────────────────────────── */

.exercise-instruction {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.exercise-prompt {
  font-size: 1.2rem;
  font-weight: 600;
  font-family: var(--font-content);
  color: var(--accent-light);
  margin-bottom: 24px;
  padding: 14px 18px;
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

/* ── Card Zones ───────────────────────────────────────────────── */

.card-zone {
  min-height: 64px;
  padding: 12px;
  border-radius: var(--radius-md);
  margin-bottom: 20px;
}

.card-zone-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
}

.card-pool {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
}

.answer-zone {
  background: var(--bg-answer-zone);
  border: 2px dashed rgba(108, 92, 231, 0.2);
  min-height: 72px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.answer-zone.empty::after {
  content: attr(data-placeholder);
  color: var(--text-dim);
  font-size: 0.85rem;
  width: 100%;
  text-align: center;
}

/* ── Word Cards ───────────────────────────────────────────────── */

.cards-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.word-card {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-content);
  font-size: 1.05rem;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition-bounce);
  -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
.word-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--accent);
  transform: scale(1.04);
}
.word-card:active {
  transform: scale(0.97);
}

.word-card.placed {
  opacity: 0.3;
  pointer-events: none;
  transform: scale(0.95);
}

.word-card.in-answer {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(108, 92, 231, 0.05));
  border-color: var(--accent);
}

/* ── Card states: correct / incorrect ──────────────────────── */

.word-card.correct {
  border-color: var(--success);
  box-shadow: 0 0 12px var(--success-glow);
  background: rgba(0, 206, 201, 0.08);
}

.word-card.incorrect {
  border-color: var(--error);
  box-shadow: 0 0 12px var(--error-glow);
  background: rgba(255, 107, 107, 0.08);
  animation: shake 0.4s ease-in-out;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

@keyframes pulse-success {
  0% { box-shadow: 0 0 0 0 var(--success-glow); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.word-card.correct {
  animation: pulse-success 0.6s ease-out;
}

/* ── Feedback Bar ─────────────────────────────────────────────── */

.feedback {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 16px;
  transition: all var(--transition);
}

.feedback.success {
  background: rgba(0, 206, 201, 0.1);
  border: 1px solid rgba(0, 206, 201, 0.3);
  color: var(--success);
}

.feedback.error {
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  color: var(--error);
}

/* ── Action Bar ───────────────────────────────────────────────── */

.action-bar {
  display: flex;
  gap: 12px;
  margin-top: 8px;
  margin-bottom: 16px;
}

.action-bar .btn {
  flex: 1;
}

/* ── Difficulty Toggle ────────────────────────────────────────── */

.difficulty-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: auto;
  padding: 12px 0;
}

.difficulty-toggle label {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.toggle-group {
  display: flex;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.toggle-group button {
  padding: 6px 16px;
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.toggle-group button.active {
  background: var(--accent);
  color: white;
}

/* ── Settings Screen ──────────────────────────────────────────── */

.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 0.8rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
}

.settings-row span {
  font-size: 0.9rem;
}

/* ── Stats Screen ─────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-light);
}

.stat-card .stat-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ── Help Modal ───────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  animation: fadeIn 0.2s ease;
  padding: 16px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  max-width: 500px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: slideUp 0.25s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all var(--transition);
}
.modal-close:hover {
  background: var(--error);
  color: white;
  border-color: var(--error);
}

/* ── Grammar Table ────────────────────────────────────────────── */

.grammar-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--font-content);
  font-size: 0.95rem;
}

.grammar-table th {
  text-align: left;
  padding: 8px 12px;
  color: var(--text-dim);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
}

.grammar-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}

.grammar-table tr:last-child td {
  border-bottom: none;
}

.grammar-table tr:hover td {
  background: rgba(108, 92, 231, 0.05);
}

/* ── README Viewer ────────────────────────────────────────────── */

.readme-shell {
  margin-top: 16px;
}

.readme-content {
  font-family: var(--font-content);
  color: var(--text-primary);
  line-height: 1.65;
  padding-bottom: 32px;
}

.readme-content h2 {
  font-family: var(--font-ui);
  font-size: 1.35rem;
  margin: 18px 0 10px;
}

.readme-content h3 {
  font-family: var(--font-ui);
  font-size: 1.05rem;
  margin: 18px 0 8px;
}

.readme-content h4 {
  font-family: var(--font-ui);
  font-size: 0.95rem;
  margin: 14px 0 6px;
  color: var(--text-secondary);
}

.readme-content p,
.readme-content ul {
  margin-bottom: 12px;
}

.readme-content ul {
  padding-left: 22px;
}

.readme-content li {
  margin-bottom: 6px;
}

.readme-content code {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.9em;
}

.readme-content pre {
  overflow-x: auto;
  background: var(--bg-answer-zone);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 12px 0;
}

.readme-content pre code {
  background: transparent;
  border: 0;
  padding: 0;
}

.readme-content a {
  color: var(--accent-light);
}

/* ── Tab selector for help tables ─────────────────────────────── */

.tab-selector {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.tab-selector button {
  padding: 6px 12px;
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
}

.tab-selector button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

/* ── Screen transition ────────────────────────────────────────── */

.screen-enter {
  animation: fadeIn 0.2s ease;
}

/* ── Responsive ───────────────────────────────────────────────── */

@media (max-width: 480px) {
  #app { padding: 12px; }
  .word-card { padding: 8px 12px; font-size: 0.95rem; }
  .exercise-prompt { font-size: 1.05rem; padding: 12px 14px; }
  .modal-content { padding: 18px; border-radius: var(--radius-lg); }
}
