/* ---- fonts (all local) ------------------------------------------------ */
@font-face { font-family: "Vazirmatn"; src: url("../vendor/fonts/Vazirmatn-wght.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "NotoGreek"; src: url("../vendor/fonts/noto-sans-greek-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "NotoGreek"; src: url("../vendor/fonts/noto-sans-greek-ext-400-normal.woff2") format("woff2"); unicode-range: U+1F00-1FFF; font-display: swap; }
@font-face { font-family: "NotoLatinExt"; src: url("../vendor/fonts/noto-sans-latin-ext-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "NotoHebrew"; src: url("../vendor/fonts/noto-sans-hebrew-hebrew-400-normal.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "NotoSyriac"; src: url("../vendor/fonts/noto-sans-syriac-syriac-400-normal.woff2") format("woff2"); font-display: swap; }

/* ---- tokens ----------------------------------------------------------- */
:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #f0e9da;
  --ink: #1f2430;
  --muted: #5b6270;
  --line: #e2d9c6;
  --accent: #a8481f;        /* terracotta */
  --accent-ink: #ffffff;
  --accent-soft: #f6e3d8;
  --royal: #3b377a;         /* imperial purple-blue */
  --royal-soft: #e6e4f6;
  --good: #2c7a57;
  --good-soft: #dff1e7;
  --warn: #9a6412;
  --warn-soft: #f8ecd4;
  --bad: #b3261e;
  --shadow: 0 1px 2px rgba(31, 36, 48, .06), 0 4px 16px rgba(31, 36, 48, .06);
  --radius: 14px;
  --font: "Vazirmatn", "NotoLatinExt", "NotoGreek", "NotoHebrew", "NotoSyriac", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161b; --surface: #1d2027; --surface-2: #252932; --ink: #ece7dc; --muted: #a2a8b4;
    --line: #2f343e; --accent: #e08a5f; --accent-ink: #1a1208; --accent-soft: #3a2a22;
    --royal: #aaa5f2; --royal-soft: #2a2946; --good: #6cc59a; --good-soft: #1d3329;
    --warn: #e2b766; --warn-soft: #362d1b; --bad: #f08a82;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #14161b; --surface: #1d2027; --surface-2: #252932; --ink: #ece7dc; --muted: #a2a8b4;
  --line: #2f343e; --accent: #e08a5f; --accent-ink: #1a1208; --accent-soft: #3a2a22;
  --royal: #aaa5f2; --royal-soft: #2a2946; --good: #6cc59a; --good-soft: #1d3329;
  --warn: #e2b766; --warn-soft: #362d1b; --bad: #f08a82;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25);
  color-scheme: dark;
}

/* ---- base ------------------------------------------------------------- */
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 17px; line-height: 1.9;
}
a { color: var(--royal); }
h1, h2, h3 { line-height: 1.5; margin: 1.2em 0 .5em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.3rem; font-weight: 750; }
h3 { font-size: 1.1rem; font-weight: 700; }
p, li { unicode-bidi: plaintext; }
.ltr { direction: ltr; unicode-bidi: isolate; display: inline-block; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 64px; }
.hidden { display: none !important; }

/* ---- header / nav ----------------------------------------------------- */
.top {
  position: sticky; top: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.top .bar { max-width: 760px; margin: 0 auto; padding: 8px 16px; display: flex; align-items: center; gap: 12px; }
.brand { font-weight: 800; color: var(--ink); text-decoration: none; white-space: nowrap; font-size: .98rem; }
.nav { display: flex; gap: 4px; margin-inline-start: auto; overflow-x: auto; }
.nav a, .nav button {
  font: inherit; font-size: .9rem; color: var(--muted); text-decoration: none; border: 0; background: none;
  padding: 6px 10px; border-radius: 999px; cursor: pointer; white-space: nowrap;
}
.nav a[aria-current="page"] { background: var(--surface-2); color: var(--ink); font-weight: 650; }
.nav a:hover, .nav button:hover { color: var(--ink); }

/* ---- components ------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stack > * + * { margin-top: 14px; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .num { font-size: 2rem; font-weight: 800; line-height: 1.2; }
.tile .lbl { color: var(--muted); font-size: .9rem; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 10px 18px; cursor: pointer;
  background: var(--accent); color: var(--accent-ink); text-decoration: none; min-height: 44px;
}
.btn.secondary { background: var(--surface-2); color: var(--ink); }
.btn:disabled { opacity: .5; cursor: default; }
.pill { display: inline-block; padding: 1px 10px; border-radius: 999px; font-size: .82rem; background: var(--surface-2); color: var(--muted); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.royal { background: var(--royal-soft); color: var(--royal); }
.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: .92rem; color: var(--muted); margin-bottom: 4px; }
.field input {
  width: 100%; font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); direction: ltr; text-align: left;
}
.error { color: var(--bad); min-height: 1.5em; }
details > summary { cursor: pointer; font-weight: 650; }

/* ---- session page ------------------------------------------------------ */
.eyebrow { color: var(--accent); font-weight: 700; font-size: .9rem; margin-top: 24px; }
.puzzle { border-inline-start: 4px solid var(--accent); }
.object { border-inline-start: 4px solid var(--royal); }
.reader { font-size: 1.05rem; }
.reader blockquote {
  margin: 1em 0; padding: 12px 16px; background: var(--surface-2); border-radius: 10px;
  border-inline-start: 4px solid var(--royal);
}
.reader h2 { border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.reader table { border-collapse: collapse; width: 100%; font-size: .95rem; }
.reader td, .reader th { border: 1px solid var(--line); padding: 6px 8px; }
.myth { border-inline-start: 4px solid var(--bad); }
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { display: grid; grid-template-columns: 90px 1fr; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.timeline .yr { font-weight: 750; color: var(--royal); }

/* ---- word card --------------------------------------------------------- */
.word { position: relative; }
.word .head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 14px; }
.word .orig { font-size: 2rem; font-weight: 500; direction: ltr; unicode-bidi: isolate; }
.word .tr { direction: ltr; unicode-bidi: isolate; font-style: italic; color: var(--muted); }
.word .fa { font-weight: 750; font-size: 1.2rem; }
.word dl { margin: 12px 0 0; }
.word dt { font-weight: 750; color: var(--royal); margin-top: 10px; font-size: .95rem; }
.word dd { margin: 2px 0 0; }
.journey { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; direction: rtl; margin: 4px 0; }
.journey .step { background: var(--surface-2); border-radius: 10px; padding: 2px 10px; unicode-bidi: isolate; }
.journey .step b { font-weight: 650; }
.journey .step .l { color: var(--muted); font-size: .78rem; margin-inline-end: 6px; }
.journey .arrow { color: var(--muted); }
.careful { background: var(--warn-soft); border-radius: 10px; padding: 10px 12px; margin-top: 12px; }
.careful strong { color: var(--warn); }
.word .rank { position: absolute; top: 14px; inset-inline-end: 14px; }

/* ---- review ------------------------------------------------------------ */
.flash { min-height: 260px; display: flex; flex-direction: column; justify-content: center; text-align: center; font-size: 1.25rem; }
.flash .front, .flash .back { unicode-bidi: plaintext; }
.flash .back { border-top: 1px solid var(--line); margin-top: 18px; padding-top: 18px; font-size: 1.1rem; }
.ratings { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.ratings button { display: flex; flex-direction: column; line-height: 1.4; padding: 8px 4px; }
.ratings .again { background: #c0392b; color: #fff; }
.ratings .hard { background: var(--warn); color: #fff; }
.ratings .good { background: var(--good); color: #fff; }
.ratings .easy { background: var(--royal); color: #fff; }
:root[data-theme="dark"] .ratings button, .ratings button { font-weight: 700; }
.ratings small { font-weight: 400; opacity: .9; font-size: .78rem; }
.progress { height: 6px; background: var(--surface-2); border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .3s; }

/* ---- chart ------------------------------------------------------------- */
.chart svg { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); }
.chart .bar.zero { fill: var(--line); }
.chart text { fill: var(--muted); font-family: var(--font); font-size: 10px; }

/* ---- login ------------------------------------------------------------- */
.login { max-width: 400px; margin: 10vh auto 0; }
.login h1 { text-align: center; }

@media print {
  .top, .no-print { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
}
