@font-face {
  font-family: "Literata";
  src: url("font/literata-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0100-024F, U+0300-036F, U+1E00-1EFF, U+2000-206F, U+2122, U+2190-21FF, U+221A, U+25CC;
}
@font-face {
  font-family: "Literata";
  src: url("font/literata-greek.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0370-03FF, U+1F00-1FFF;
}
@font-face {
  font-family: "Noto Serif Devanagari";
  src: url("font/noto-serif-devanagari.woff2") format("woff2");
  font-weight: 400 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0900-097F, U+200C-200D;
}

:root {
  color-scheme: light;
  --bg: #faf6ee;
  --bg-surface: #f2eadc;
  --bg-inset: #ede3d2;
  --text-primary: #221f1a;
  --text-secondary: #423c33;
  --text-muted: #4f483d;
  --accent: #703b12;
  --mark: #832c09;
  --rule: #d8cbb3;
  --rule-strong: #b9a986;
  --focus: #703b12;
  --shadow: 0 1px 2px rgba(34, 31, 26, .06), 0 8px 24px rgba(34, 31, 26, .05);

  --serif: "Literata", "Iowan Old Style", Palatino, "Palatino Linotype", Georgia, serif;
  --deva: "Noto Serif Devanagari", "Noto Sans Devanagari", "Kohinoor Devanagari", "Devanagari MT", serif;
  --measure: 34rem;
  --wide: 58rem;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #15171c;
    --bg-surface: #1d2027;
    --bg-inset: #23272f;
    --text-primary: #f2ede3;
    --text-secondary: #c6beb0;
    --text-muted: #b9b1a5;
    --accent: #e9ae6b;
    --mark: #f5a177;
    --rule: #343943;
    --rule-strong: #4c525e;
    --focus: #e9ae6b;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #15171c;
  --bg-surface: #1d2027;
  --bg-inset: #23272f;
  --text-primary: #f2ede3;
  --text-secondary: #c6beb0;
  --text-muted: #b9b1a5;
  --accent: #e9ae6b;
  --mark: #f5a177;
  --rule: #343943;
  --rule-strong: #4c525e;
  --focus: #e9ae6b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 24px rgba(0, 0, 0, .3);
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--serif);
  font-size: clamp(1.0625rem, 0.98rem + 0.42vw, 1.1875rem);
  line-height: 1.66;
  font-optical-sizing: auto;
  text-rendering: optimizeLegibility;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
  border-radius: 2px;
}

a { color: var(--accent); text-underline-offset: .18em; text-decoration-thickness: from-font; }
a:hover { text-decoration-thickness: .11em; }

.skip {
  position: absolute; left: -9999px; top: 0;
  background: var(--bg-surface); color: var(--text-primary);
  padding: .7rem 1rem; z-index: 60; border: 1px solid var(--rule-strong); border-radius: 0 0 6px 0;
}
.skip:focus { left: 0; }

/* ---------- layout ---------- */

.shell { width: 100%; max-width: var(--wide); margin: 0 auto; padding: 0 1.25rem; }
.col { max-width: var(--measure); margin-inline: auto; }
.col--wide { max-width: 46rem; margin-inline: auto; }

/* ---------- masthead ---------- */

.masthead {
  display: flex; flex-wrap: wrap; gap: .75rem 1rem;
  align-items: center; justify-content: space-between;
  padding-top: 1rem; padding-bottom: .9rem;
  border-bottom: 1px solid var(--rule);
}
.masthead__home {
  font-size: .82rem; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted); text-decoration: none; font-weight: 600;
}
.masthead__home:hover { color: var(--accent); }
.masthead__tools { display: flex; gap: .5rem; align-items: center; }

.pill {
  font: inherit; font-size: .82rem; font-weight: 600;
  padding: .38rem .8rem; border-radius: 999px;
  border: 1px solid var(--rule-strong); background: var(--bg-surface);
  color: var(--text-secondary); cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.pill:hover { background: var(--bg-inset); color: var(--text-primary); border-color: var(--accent); }

/* ---------- opening ---------- */

.opening { padding: 3.5rem 0 2rem; }
.kicker {
  font-size: .8rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700; margin: 0 0 1.1rem;
}
h1 {
  font-size: clamp(2.1rem, 1.5rem + 3vw, 3.5rem);
  line-height: 1.08; letter-spacing: -.018em; font-weight: 700;
  margin: 0 0 1.1rem; text-wrap: balance;
}
.deck {
  font-size: clamp(1.15rem, 1.05rem + 0.5vw, 1.35rem);
  line-height: 1.55; color: var(--text-secondary); margin: 0 0 1.6rem;
  text-wrap: pretty;
}
.byline {
  font-size: .85rem; color: var(--text-muted);
  border-top: 1px solid var(--rule); padding-top: .9rem;
  display: flex; flex-wrap: wrap; gap: .4rem 1rem;
}

/* ---------- sections ---------- */

section { padding: 2.4rem 0; }
section + section { border-top: 1px solid var(--rule); }

h2 {
  font-size: clamp(1.5rem, 1.25rem + 1.1vw, 2rem);
  line-height: 1.16; letter-spacing: -.012em; font-weight: 700;
  margin: 0 0 .35rem; text-wrap: balance;
}
.h2num {
  display: block; font-size: .78rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 700; margin-bottom: .5rem;
}
h3 {
  font-size: 1.16rem; font-weight: 700; line-height: 1.3;
  margin: 2rem 0 .5rem; letter-spacing: -.005em;
}
p { margin: 0 0 1.15rem; text-wrap: pretty; }
.lede { font-size: 1.08em; color: var(--text-secondary); }

blockquote {
  margin: 1.6rem 0; padding: .2rem 0 .2rem 1.2rem;
  border-left: 3px solid var(--rule-strong);
  font-size: 1.05em; color: var(--text-secondary);
}
blockquote p:last-child { margin-bottom: 0; }
blockquote cite {
  display: block; margin-top: .6rem; font-size: .82rem; font-style: normal;
  color: var(--text-muted); letter-spacing: .01em;
}

/* ---------- language forms ---------- */

.deva { font-family: var(--deva); line-height: 1.9; font-size: 1.06em; }
.rom { font-style: italic; }
.gk { font-style: normal; }
.gloss { color: var(--text-muted); font-size: .92em; }

.caveat {
  background: var(--bg-inset);
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.15rem;
  margin: 1.6rem 0;
  font-size: .95rem;
  color: var(--text-secondary);
}
.caveat p { margin: 0; }
.caveat p + p { margin-top: .7rem; }
.caveat__label {
  display: block; font-size: .74rem; letter-spacing: .13em; text-transform: uppercase;
  font-weight: 700; color: var(--text-muted); margin-bottom: .45rem;
}

/* ---------- interaction A: expressions ---------- */

.expr-set { margin: 1.8rem 0 0; display: grid; gap: 1rem; }
.expr {
  background: var(--bg-surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 1.15rem 1.2rem;
}
.expr__line {
  font-size: clamp(1.2rem, 1.05rem + .8vw, 1.6rem);
  line-height: 1.5; margin: 0 0 .55rem; letter-spacing: -.005em;
}
.expr__head { font-weight: 700; }
.q {
  color: var(--mark);
  border-bottom: 2px solid color-mix(in srgb, var(--mark) 40%, transparent);
  transition: opacity .28s ease;
}
.expr.is-stripped .q { opacity: .32; text-decoration: line-through; text-decoration-thickness: 1px; }
.expr__trans { margin: 0 0 .5rem; color: var(--text-secondary); font-size: .98rem; }
.expr__gloss { margin: 0 0 .7rem; font-size: .86rem; color: var(--text-muted); }
.expr__verdict {
  margin: 0; font-size: .95rem; padding-top: .7rem;
  border-top: 1px dashed var(--rule-strong);
}
.expr__verdict b { color: var(--text-primary); }
.expr__cite { font-size: .8rem; color: var(--text-muted); }

.controls {
  display: flex; flex-wrap: wrap; gap: .7rem; align-items: center;
  margin: 1.6rem 0 0;
}
.btn {
  font: inherit; font-size: .93rem; font-weight: 600;
  padding: .58rem 1.05rem; border-radius: 8px;
  border: 1px solid var(--accent); background: var(--bg-surface); color: var(--accent);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--accent); color: var(--bg); }
.btn[aria-pressed="true"] { background: var(--accent); color: var(--bg); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.status { font-size: .88rem; color: var(--text-muted); }

/* ---------- interaction B: paradigm ---------- */

.tablenote { margin: 1.6rem 0 .6rem; font-size: .85rem; color: var(--text-muted); }
.tablewrap { overflow-x: auto; margin: 0; -webkit-overflow-scrolling: touch; }
table.paradigm {
  border-collapse: collapse; width: 100%; min-width: 30rem;
  background: var(--bg-surface); font-size: .95rem;
}
.paradigm th, .paradigm td {
  border: 1px solid var(--rule-strong); padding: .5rem .6rem; text-align: left;
  vertical-align: middle;
}
.paradigm thead th, .paradigm tbody th { font-weight: 700; color: var(--text-primary); background: var(--bg-inset); }
.paradigm tbody th { white-space: nowrap; font-size: .88rem; }
.cell { display: flex; flex-direction: column; gap: .1rem; }
.cell .deva { font-size: 1.12rem; line-height: 1.6; }
.cell .rom { font-size: .88rem; color: var(--text-secondary); }
.cell__hidden { color: var(--text-muted); font-size: .88rem; }
td.is-hidden { padding: 0; }
td.is-hidden .reveal {
  font: inherit; font-size: .86rem; width: 100%; height: 100%;
  min-height: 3.1rem; padding: .5rem .6rem;
  background: none; border: 0; color: var(--text-muted); cursor: pointer; text-align: left;
}
td.is-hidden .reveal:hover { background: var(--bg-inset); color: var(--accent); }
.count {
  margin: 1rem 0 0; font-size: .95rem; color: var(--text-secondary);
}

/* ---------- interaction C: one word ---------- */

.steps { margin: 1.8rem 0 0; }
.step {
  background: var(--bg-surface); border: 1px solid var(--rule);
  border-radius: 10px; padding: 1.2rem 1.25rem;
}
.step + .step { margin-top: 1rem; }
.step__where {
  font-size: .76rem; letter-spacing: .12em; text-transform: uppercase;
  font-weight: 700; color: var(--text-muted); margin: 0 0 .6rem;
}
.step__form { font-size: 1.35rem; margin: 0 0 .3rem; }
.step__form .rom { font-size: .8em; color: var(--text-secondary); }
.step__sense { margin: 0; color: var(--text-secondary); font-size: .98rem; }
.step__sense em { color: var(--text-primary); font-style: italic; }

.js-on .steps--paged .step { display: none; }
.js-on .steps--paged .step.is-current { display: block; }

/* ---------- note cards ---------- */

.notes { display: grid; gap: 1rem; margin: 1.8rem 0 0; align-items: start; }
@media (min-width: 46rem) { .notes { grid-template-columns: 1fr 1fr; } }
.note {
  background: var(--bg-surface); border: 1px solid var(--rule);
  border-radius: 10px; padding: 1.15rem 1.2rem;
}
.note h3 { margin: 0 0 .6rem; font-size: 1.02rem; }
.note p { margin: 0 0 .7rem; font-size: .95rem; color: var(--text-secondary); }
.note p:last-child { margin-bottom: 0; }
.note dl { margin: 0; font-size: .95rem; }
.note dt { font-family: var(--deva); font-size: 1.1rem; line-height: 1.8; color: var(--text-primary); }
.note dd { margin: 0 0 .55rem; color: var(--text-secondary); font-size: .92rem; }
.note dd .rom { color: var(--text-muted); }

/* ---------- figures ---------- */

figure { margin: 2.2rem 0; }
figure img {
  display: block; width: 100%; height: auto; border-radius: 8px;
  border: 1px solid var(--rule-strong); background: var(--bg-inset);
}
figcaption {
  margin-top: .7rem; font-size: .85rem; line-height: 1.55; color: var(--text-muted);
}
figcaption b { color: var(--text-secondary); font-weight: 600; }
figcaption a { color: var(--accent); }

/* ---------- facts list ---------- */

.facts { margin: 1.4rem 0 0; padding: 0; list-style: none; }
.facts li {
  display: grid; gap: .1rem .9rem; padding: .75rem 0;
  border-top: 1px solid var(--rule);
}
@media (min-width: 34rem) { .facts li { grid-template-columns: 9rem 1fr; } }
.facts b { font-weight: 700; font-size: .88rem; color: var(--text-muted); }
.facts span { color: var(--text-secondary); }

/* ---------- sources ---------- */

.sources { font-size: .93rem; }
.sources ul { margin: 0; padding-left: 1.1rem; }
.sources li { margin-bottom: .7rem; color: var(--text-secondary); }

/* ---------- footer ---------- */

footer {
  border-top: 1px solid var(--rule);
  padding-top: 2rem; padding-bottom: 3.5rem; font-size: .88rem; color: var(--text-muted);
}
footer p { margin: 0 0 .6rem; }
footer a { color: var(--accent); }

.totop {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 40;
  background: var(--bg-surface); border: 1px solid var(--rule-strong);
  color: var(--text-secondary); border-radius: 999px;
  padding: .55rem .95rem; font: inherit; font-size: .82rem; font-weight: 600;
  text-decoration: none; box-shadow: var(--shadow);
}
.totop:hover { color: var(--accent); border-color: var(--accent); }
.js-on .totop { opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.js-on .totop.is-shown { opacity: 1; pointer-events: auto; }

.vh {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* controls that only mean something once the page is interactive */
.js-only { display: none; }
.js-on .js-only { display: inline-flex; }
