/* style.css — all styling */
:root {
  --bg: #0e1318;
  --bg-2: #141b22;
  --surface: #1a222b;
  --surface-2: #222c37;
  --border: #2c3744;
  --text: #e9e6e1;
  --text-dim: #9aa3ad;
  --text-mute: #6b7480;
  --accent: #d9a441;
  --accent-soft: rgba(217,164,65,0.14);
  --accent-2: #6fae8e;
  --danger: #d97757;
  --success: #7fb069;
  --radius: 14px;
  --shadow: 0 8px 30px rgba(0,0,0,0.35);
  --shadow-soft: 0 2px 10px rgba(0,0,0,0.25);
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #f6f2ea;
  --bg-2: #efe9dd;
  --surface: #ffffff;
  --surface-2: #f3ede2;
  --border: #e2d9c7;
  --text: #2a2a2a;
  --text-dim: #5c5c5c;
  --text-mute: #8a8a8a;
  --accent: #b8860b;
  --accent-soft: rgba(184,134,11,0.12);
  --accent-2: #4a8a6a;
  --danger: #c25a3a;
  --success: #5a8f4a;
  --shadow: 0 8px 28px rgba(80,60,30,0.12);
  --shadow-soft: 0 2px 8px rgba(80,60,30,0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    --bg: #f6f2ea; --bg-2: #efe9dd; --surface: #ffffff; --surface-2: #f3ede2;
    --border: #e2d9c7; --text: #2a2a2a; --text-dim: #5c5c5c; --text-mute: #8a8a8a;
    --accent: #b8860b; --accent-soft: rgba(184,134,11,0.12); --accent-2: #4a8a6a;
    --danger: #c25a3a; --success: #5a8f4a; --shadow: 0 8px 28px rgba(80,60,30,0.12);
    --shadow-soft: 0 2px 8px rgba(80,60,30,0.08); 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, "Noto Sans Hebrew", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  cursor: pointer;
  transition: background .18s, transform .12s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(0.95); }
.brand { display: flex; align-items: center; gap: 9px; }
.brand-mark {
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  background: var(--accent);
  color: #1a1208;
  font-weight: 800;
  font-size: 18px;
}
.brand-name { font-weight: 700; letter-spacing: 0.5px; font-size: 18px; }
.spacer { flex: 1; }

/* Layout shells */
main {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 22px 18px 40px;
}
main.home { max-width: 980px; margin: 0 auto; width: 100%; }

/* Hero */
.hero { margin-bottom: 28px; }
.hero-title {
  font-size: clamp(24px, 5vw, 36px);
  line-height: 1.15;
  margin: 0 0 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.hero-sub {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.55;
  margin: 0 0 18px;
  max-width: 60ch;
}
.stat-row { display: flex; gap: 10px; flex-wrap: wrap; }
.stat {
  flex: 1 1 110px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex; flex-direction: column;
  gap: 2px;
}
.stat-num { font-size: 24px; font-weight: 800; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-dim); }

/* Decks */
.section-head { margin: 6px 0 14px; }
.section-head h2 { font-size: 16px; margin: 0; color: var(--text-dim); font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.deck-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.deck-card {
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  color: var(--text);
  font: inherit;
  transition: transform .16s, border-color .16s, background .16s, box-shadow .16s;
  display: flex; flex-direction: column;
  gap: 8px;
}
.deck-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  background: var(--surface-2);
}
.deck-card:active { transform: translateY(-1px); }
.deck-top { display: flex; justify-content: space-between; align-items: center; }
.deck-icon { font-size: 22px; }
.deck-count {
  font-size: 12px; color: var(--text-dim);
  background: var(--bg-2); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 20px;
}
.deck-name { margin: 0; font-size: 17px; font-weight: 700; }
.deck-desc { margin: 0; font-size: 13px; color: var(--text-dim); line-height: 1.4; min-height: 36px; }
.deck-progress { margin-top: 4px; }

.bar {
  height: 6px;
  background: var(--bg-2);
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  border-radius: 20px;
  transition: width .4s ease;
}
.bar-label { display: block; margin-top: 6px; font-size: 11px; color: var(--text-mute); }

.foot {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-mute);
  text-align: center;
}
kbd {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 6px; font-size: 11px;
  font-family: inherit; color: var(--text-dim);
}

/* Study */
main.study { max-width: 760px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 16px; }
.study-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.ghost {
  background: none; border: none; color: var(--text-dim);
  font: inherit; font-size: 14px; cursor: pointer; padding: 6px 4px;
}
.ghost:hover { color: var(--text); }
.study-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.chip {
  font-size: 12px; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border);
  padding: 5px 10px; border-radius: 20px;
}
.chip-btn {
  font-size: 12px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text-dim); padding: 5px 10px; border-radius: 20px;
  transition: all .15s;
}
.chip-btn:hover { color: var(--text); }
.chip-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.progress-line { display: flex; flex-direction: column; gap: 2px; }

/* Flip card */
.card-stage { perspective: 1400px; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 320px; }
.flip-card {
  position: relative;
  width: 100%; max-width: 540px;
  aspect-ratio: 16 / 10;
  transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.4,.2,.2,1);
  cursor: pointer;
}
.flip-card.flipped { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow);
  display: grid;
  place-items: center;
  padding: 24px;
}
.flip-face.back { transform: rotateY(180deg); background: linear-gradient(160deg, var(--surface), var(--surface-2)); }
.face-inner { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.he-text { font-size: clamp(38px, 11vw, 64px); font-weight: 700; line-height: 1.1; color: var(--text); letter-spacing: 0.02em; }
.he-tr { font-style: italic; color: var(--accent); font-size: clamp(14px, 3.5vw, 18px); letter-spacing: 0.5px; }
.en-text { font-size: clamp(26px, 6vw, 40px); font-weight: 700; color: var(--text); }
.face-hint { font-size: 12px; color: var(--text-mute); margin-top: 8px; }
.speak-btn {
  margin-top: 6px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 24px; padding: 8px 16px;
  font: inherit; font-size: 13px; cursor: pointer;
  transition: transform .12s, background .15s;
}
.speak-btn:hover { background: var(--accent); color: #1a1208; }
.speak-btn:active { transform: scale(0.95); }

/* Controls */
.card-controls { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
.ctrl {
  font: inherit; font-size: 14px;
  padding: 12px 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, opacity .15s;
}
.ctrl:hover:not(:disabled) { background: var(--surface-2); border-color: var(--accent); }
.ctrl:active:not(:disabled) { transform: scale(0.97); }
.ctrl:disabled { opacity: 0.4; cursor: default; }
.ctrl.mark.known { background: var(--success); border-color: var(--success); color: #0e1318; font-weight: 600; }
.ctrl.primary { background: var(--accent); border-color: var(--accent); color: #1a1208; font-weight: 700; }
.ctrl.primary:hover { filter: brightness(1.08); }

@media (max-width: 560px) {
  .card-controls { grid-template-columns: 1fr 1fr; }
}

/* Quiz */
main.quiz { max-width: 640px; margin: 0 auto; width: 100%; display: flex; flex-direction: column; gap: 16px; }
.quiz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 26px 22px;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.quiz-prompt { margin: 0; }
.quiz-instr { color: var(--text-dim); font-size: 13px; }
.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 100%; }
@media (max-width: 480px) { .opts { grid-template-columns: 1fr; } }
.opt {
  font: inherit; font-size: 16px;
  text-align: center;
  padding: 16px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  transition: transform .12s, background .15s, border-color .15s, opacity .2s;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.opt:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-2); transform: translateY(-2px); }
.opt:active:not(:disabled) { transform: scale(0.98); }
.opt.correct { background: var(--success); border-color: var(--success); color: #0e1318; }
.opt.wrong { background: var(--danger); border-color: var(--danger); color: #fff; }
.opt.dim { opacity: 0.45; }
.opt-en { font-weight: 600; font-size: 16px; }
.opt-he { font-size: 22px; font-weight: 700; }
.opt-tr { font-size: 12px; color: var(--text-dim); font-style: italic; }
.opt.correct .opt-tr, .opt.wrong .opt-tr { color: rgba(255,255,255,0.85); }

/* Result */
main.result { display: grid; place-items: center; }
.result-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px;
  text-align: center;
  max-width: 420px; width: 100%;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.result-grade { font-size: 14px; color: var(--accent); letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; }
.result-score { font-size: 56px; font-weight: 800; line-height: 1; }
.result-score span { font-size: 28px; color: var(--text-dim); font-weight: 600; }
.result-pct { font-size: 16px; color: var(--text-dim); }
.result-bar { width: 100%; height: 8px; margin: 12px 0 6px; background: var(--bg-2); border-radius: 20px; overflow: hidden; border: 1px solid var(--border); }
.result-msg { color: var(--text-dim); font-size: 14px; line-height: 1.5; margin: 6px 0 12px; }
.result-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; width: 100%; }
.result-actions .ctrl { flex: 1 1 110px; }

/* Scrollbar */
main::-webkit-scrollbar { width: 8px; }
main::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
main::-webkit-scrollbar-track { background: transparent; }

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