/* style.css — all styling */
:root {
  --bg: #0e1116;
  --bg-2: #161b22;
  --surface: #1b212b;
  --surface-2: #232a36;
  --border: #2c3441;
  --text: #e8ecf2;
  --text-dim: #9aa6b6;
  --text-faint: #6b7686;
  --accent: #e8a14b;
  --accent-2: #f0b868;
  --accent-soft: rgba(232,161,75,0.14);
  --hebrew: #f5cf8a;
  --ok: #4ec27a;
  --bad: #f0656a;
  --shadow: 0 10px 30px rgba(0,0,0,0.4);
  --radius: 18px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f4ee;
  --bg-2: #ffffff;
  --surface: #ffffff;
  --surface-2: #f1eee6;
  --border: #e3ddcf;
  --text: #2a2620;
  --text-dim: #6b6457;
  --text-faint: #a39a86;
  --accent: #c47e1f;
  --accent-2: #d99436;
  --accent-soft: rgba(196,126,31,0.12);
  --hebrew: #a86c1a;
  --ok: #2e9d56;
  --bad: #d6444a;
  --shadow: 0 10px 30px rgba(80,60,30,0.12);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme]) {
    --bg: #f6f4ee; --bg-2: #ffffff; --surface: #ffffff; --surface-2: #f1eee6;
    --border: #e3ddcf; --text: #2a2620; --text-dim: #6b6457; --text-faint: #a39a86;
    --accent: #c47e1f; --accent-2: #d99436; --accent-soft: rgba(196,126,31,0.12);
    --hebrew: #a86c1a; --ok: #2e9d56; --bad: #d6444a;
    --shadow: 0 10px 30px rgba(80,60,30,0.12);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  overflow: hidden;
  touch-action: manipulation;
}

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

/* ---- Top bar ---- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 4px 14px;
  flex-shrink: 0;
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo {
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #1a1207;
  font-size: 24px; font-weight: 800;
  box-shadow: var(--shadow);
}
.brand-text h1 {
  margin: 0; font-size: 17px; font-weight: 700; letter-spacing: 0.2px;
}
.brand-text p {
  margin: 1px 0 0; font-size: 12px; color: var(--text-dim);
}

.mode-switch {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.mode-btn {
  border: none; background: transparent;
  color: var(--text-dim);
  font-size: 13px; font-weight: 600;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
}
.mode-btn.active {
  background: var(--accent);
  color: #1a1207;
  box-shadow: 0 2px 8px var(--accent-soft);
}
.mode-btn:not(.active):hover { color: var(--text); }

/* ---- Category bar ---- */
.cat-bar {
  display: flex; gap: 8px;
  overflow-x: auto;
  padding: 2px 4px 14px;
  flex-shrink: 0;
  scrollbar-width: none;
}
.cat-bar::-webkit-scrollbar { display: none; }
.cat-chip {
  white-space: nowrap;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  font-size: 12.5px; font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.cat-chip:hover { color: var(--text); border-color: var(--text-faint); }
.cat-chip.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-2);
}

/* ---- Stage ---- */
.stage {
  flex: 1;
  min-height: 0;
  position: relative;
}
.view {
  display: none;
  flex-direction: column;
  height: 100%;
}
.view.active { display: flex; }

/* ---- Progress ---- */
.progress-row {
  display: flex; align-items: center; gap: 12px;
  padding: 4px 2px 16px;
}
.progress-track {
  flex: 1;
  height: 6px;
  background: var(--surface);
  border-radius: 999px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(.4,.2,.2,1);
  width: 0;
}
.progress-fill.alt { background: linear-gradient(90deg, #6aa3e0, #8f7be0); }
.count {
  font-size: 12.5px; font-weight: 600;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
  min-width: 64px; text-align: right;
}

/* ---- Flashcard ---- */
.card-wrap {
  flex: 1;
  display: flex; align-items: center; justify-content: center;
  perspective: 1600px;
  min-height: 0;
  padding: 4px 0 8px;
}
.flip-card {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 5 / 4;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  perspective: 1600px;
}
.flip-inner {
  position: relative;
  width: 100%; height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.4,.2,.2,1);
}
.flip-inner.flipped { transform: rotateY(180deg); }

.card-face {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 10px;
  padding: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  box-shadow: var(--shadow);
}
.card-front {
  background: linear-gradient(160deg, var(--surface) 0%, var(--surface-2) 100%);
}
.card-back {
  background: linear-gradient(160deg, var(--accent-soft) 0%, var(--surface-2) 100%);
  border-color: var(--accent);
  transform: rotateY(180deg);
}
.card-cat {
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--accent-2);
  background: var(--accent-soft);
  padding: 5px 11px;
  border-radius: 999px;
}
.card-heb {
  font-size: clamp(48px, 13vw, 84px);
  font-weight: 700;
  color: var(--hebrew);
  direction: rtl;
  line-height: 1.15;
  letter-spacing: 0.01em;
  font-family: "Segoe UI", "Times New Roman", serif;
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.card-translit {
  font-size: 17px;
  color: var(--text-dim);
  font-style: italic;
  letter-spacing: 0.02em;
}
.flip-hint {
  margin-top: auto;
  font-size: 11.5px;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}
.card-meaning {
  font-size: clamp(26px, 6vw, 38px);
  font-weight: 700;
  color: var(--text);
  text-align: center;
  line-height: 1.2;
}
.card-heb-sm {
  font-size: 26px;
  color: var(--hebrew);
  direction: rtl;
  font-family: "Segoe UI", "Times New Roman", serif;
}

/* ---- Controls ---- */
.controls {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px;
  padding: 8px 2px 10px;
  flex-shrink: 0;
}
.ctrl {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px; font-weight: 600;
  padding: 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
  min-height: 44px;
}
.ctrl:hover { background: var(--surface-2); border-color: var(--text-faint); transform: translateY(-1px); }
.ctrl:active { transform: translateY(0); }
.ctrl.prev, .ctrl.next {
  padding: 11px 14px;
}
.ctrl.known { flex: 1; max-width: 240px; }
.ctrl.known.is-known {
  background: rgba(78,194,122,0.12);
  border-color: var(--ok);
  color: var(--ok);
}
.known-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--text-faint);
  transition: all 0.2s ease;
}
.known-dot.on {
  background: var(--ok);
  box-shadow: 0 0 0 4px rgba(78,194,122,0.2);
}

.stats {
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 2px 0 14px;
  flex-shrink: 0;
}
.stats span { color: var(--text); font-weight: 600; }

/* ---- Quiz ---- */
.quiz-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 2px 4px;
}
.quiz-score { display: flex; flex-direction: column; gap: 2px; }
.score-label { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
.score-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; }
.quiz-streak {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 15px; font-weight: 700;
  color: var(--text-dim);
  transition: all 0.2s ease;
}
.quiz-streak.hot {
  color: var(--accent);
  border-color: var(--accent);
  background: var(--accent-soft);
}
.streak-flame { font-size: 16px; }

.quiz-question {
  flex: 1;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  padding: 18px;
  min-height: 0;
}
.qq-label { font-size: 12.5px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.1em; }
.qq-heb {
  font-size: clamp(46px, 12vw, 72px);
  font-weight: 700;
  color: var(--hebrew);
  direction: rtl;
  font-family: "Segoe UI", "Times New Roman", serif;
  text-shadow: 0 2px 12px rgba(0,0,0,0.25);
}
.qq-translit { font-size: 17px; color: var(--text-dim); font-style: italic; }

.quiz-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 4px 2px 12px;
  flex-shrink: 0;
}
@media (max-width: 460px) {
  .quiz-choices { grid-template-columns: 1fr; }
}
.choice {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px; font-weight: 600;
  padding: 14px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
  text-align: left;
  min-height: 52px;
}
.choice:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--accent);
  transform: translateY(-1px);
}
.choice:disabled { cursor: default; }
.choice-key {
  display: grid; place-items: center;
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.choice.correct {
  background: rgba(78,194,122,0.14);
  border-color: var(--ok);
  color: var(--ok);
}
.choice.correct .choice-key { background: var(--ok); color: #0e1116; }
.choice.wrong {
  background: rgba(240,101,106,0.12);
  border-color: var(--bad);
  color: var(--bad);
}
.choice.wrong .choice-key { background: var(--bad); color: #0e1116; }

.quiz-feedback {
  text-align: center;
  font-size: 14px; font-weight: 600;
  padding: 2px 0 14px;
  min-height: 20px;
  color: var(--text-dim);
  transition: color 0.2s ease;
}
.quiz-feedback.ok { color: var(--ok); }
.quiz-feedback.no { color: var(--bad); }

.quiz-end {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex: 1;
  text-align: center;
  padding: 24px;
}
.quiz-end.show { display: flex; }
.end-title { font-size: 22px; font-weight: 700; }
.end-score { font-size: 44px; font-weight: 800; color: var(--accent); }
.end-msg { font-size: 14.5px; color: var(--text-dim); max-width: 360px; }
.primary-btn {
  margin-top: 6px;
  background: var(--accent);
  color: #1a1207;
  border: none;
  font-size: 14.5px; font-weight: 700;
  padding: 12px 28px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.16s ease;
}
.primary-btn:hover { background: var(--accent-2); transform: translateY(-1px); }

/* ---- Hotkeys ---- */
.hotkeys {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 14px;
  padding: 10px 4px 16px;
  font-size: 11.5px;
  color: var(--text-faint);
  flex-shrink: 0;
}
.hotkeys span { display: inline-flex; align-items: center; gap: 5px; }
kbd {
  display: inline-block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  padding: 1px 6px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--text-dim);
  margin: 0 1px;
}

@media (max-width: 560px) {
  .brand-text p { display: none; }
  .brand-text h1 { font-size: 15px; }
  .mode-btn { padding: 7px 14px; font-size: 12.5px; }
  .hotkeys { gap: 10px; font-size: 10.5px; }
}
