/* ═══════════════════════════════════════════════════════
   BASARABI-MURFATLAR — Chalk, incision, fading ink
   ═══════════════════════════════════════════════════════ */

/* ── Fonts ──────────────────────────────────────────── */
@font-face {
  font-family: 'Cormorant';
  src: url('/basarabi-murfatlar/assets/fonts/Cormorant.woff2') format('woff2');
  font-weight: 300 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: 'Cormorant';
  src: url('/basarabi-murfatlar/assets/fonts/Cormorant-Italic.woff2') format('woff2');
  font-weight: 300 700;
  font-style: italic;
  font-display: swap;
}

/* ── Tokens: light ──────────────────────────────────── */
:root {
  --paper:    #f2eee3;
  --surface:  #e6dfcd;
  --surface-2:#d9cfb6;
  --stone:    #c4b89e;

  --ink:      #211c14;
  --ink-2:    #453d30;
  --ink-3:    #6b6252;
  --ink-4:    #8d8471;

  --accent:   #7a4a16;
  --accent-bg:#f0e2c8;

  --read:     #1b5e3e;
  --read-bg:  #d8e8de;
  --unread:   #8b1a1a;
  --unread-bg:#f0d4d4;
  --part:     #4a3b8c;
  --part-bg:  #e4dff5;

  --chalk:    #faf7ef;
  --chalk-line:#b9ae94;

  --focus:    #2a6b8c;
  --border:   rgba(33,28,20,.14);

  --bar-h:    2.75rem;
  --measure:  38rem;
  --gap:      clamp(1.5rem, 3vw, 3rem);

  --font-display: 'Cormorant', 'Georgia', 'Times New Roman', serif;
  --font-body:    'Georgia', 'Times New Roman', serif;
  --font-mono:    'SFMono-Regular', 'Consolas', monospace;
}

/* ── Tokens: dark ───────────────────────────────────── */
[data-theme="dark"] {
  --paper:    #14110c;
  --surface:  #1f1a13;
  --surface-2:#2b2419;
  --stone:    #453c2c;

  --ink:      #ece4d2;
  --ink-2:    #cfc6b0;
  --ink-3:    #ada48d;
  --ink-4:    #8a8270;

  --accent:   #d9a45f;
  --accent-bg:#2b2011;

  --read:     #7cc8a0;
  --read-bg:  #162a20;
  --unread:   #e89090;
  --unread-bg:#2a1616;
  --part:     #b8a8e8;
  --part-bg:  #1e1a30;

  --chalk:    #221d15;
  --chalk-line:#6e6450;

  --focus:    #6aadcc;
  --border:   rgba(236,228,210,.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:    #14110c;
    --surface:  #1f1a13;
    --surface-2:#2b2419;
    --stone:    #453c2c;
    --ink:      #ece4d2;
    --ink-2:    #cfc6b0;
    --ink-3:    #ada48d;
    --ink-4:    #8a8270;
    --accent:   #d9a45f;
    --accent-bg:#2b2011;
    --read:     #7cc8a0;
    --read-bg:  #162a20;
    --unread:   #e89090;
    --unread-bg:#2a1616;
    --part:     #b8a8e8;
    --part-bg:  #1e1a30;
    --chalk:    #221d15;
    --chalk-line:#6e6450;
    --focus:    #6aadcc;
    --border:   rgba(236,228,210,.12);
  }
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  font-size: clamp(1.05rem, 1rem + .22vw, 1.17rem);
  line-height: 1.65;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: .15em; }
a:hover { text-decoration-thickness: 2px; }
img { max-width: 100%; height: auto; display: block; }

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

/* ── Layout ─────────────────────────────────────────── */
.wrap { max-width: var(--measure); margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); }
.wide { max-width: 56rem; margin: 0 auto; padding: 0 clamp(1rem, 3vw, 2rem); }

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  display: flex; align-items: center; gap: .5rem;
  height: var(--bar-h);
  padding: 0 clamp(.75rem, 2vw, 1.25rem);
  background: var(--paper);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-display);
  font-size: .85rem;
  letter-spacing: .02em;
}
.topbar .home { color: var(--ink-3); text-decoration: none; white-space: nowrap; }
.topbar .home:hover { color: var(--ink); }
.topnav { display: flex; gap: .15rem; overflow-x: auto; scrollbar-width: none; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  color: var(--ink-3); text-decoration: none; white-space: nowrap;
  padding: .25rem .5rem; border-radius: 4px;
}
.topnav a:hover { color: var(--ink); background: var(--surface); }
.topnav a[aria-current="true"] { color: var(--ink); font-weight: 600; }
.spacer { flex: 1; }
.chip {
  color: var(--ink-3); text-decoration: none; white-space: nowrap;
  padding: .2rem .6rem; border-radius: 4px;
  font-size: .8rem;
}
.chip:hover { color: var(--ink); background: var(--surface); }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2rem; height: 2rem; border-radius: 50%;
  border: none; background: none; color: var(--ink-3);
  cursor: pointer; padding: 0;
}
.icon-btn:hover { color: var(--ink); background: var(--surface); }
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

/* ── Sections ───────────────────────────────────────── */
section, header.hero { scroll-margin-top: calc(var(--bar-h) + 1rem); }
.block { padding: var(--gap) 0; }
.block + .block { border-top: 1px solid var(--border); }

/* ── Typography ─────────────────────────────────────── */
h1 {
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 1.4rem + 3.5vw, 4.2rem);
  line-height: 1.06;
  font-weight: 400;
  letter-spacing: -.01em;
  color: var(--ink);
}
h2 {
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 1.2rem + 1.5vw, 2.2rem);
  line-height: 1.15;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 1rem;
}
h2 .anchor { color: inherit; text-decoration: none; }
h2 .anchor:hover { text-decoration: underline; text-decoration-thickness: 1px; }
.kicker {
  font-family: var(--font-display);
  font-size: .95rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .5rem;
}
.deck {
  font-size: clamp(1.1rem, 1.02rem + .35vw, 1.3rem);
  line-height: 1.6;
  color: var(--ink-2);
  margin-top: 1rem;
}
.lede {
  font-size: 1.12em;
  line-height: 1.6;
  color: var(--ink-2);
  margin-bottom: 1.25rem;
}
.prose p + p { margin-top: 1rem; }
.byline {
  font-size: .92rem;
  color: var(--ink-3);
  margin-top: 1.25rem;
}

/* ── Hero ───────────────────────────────────────────── */
.hero { padding: clamp(2rem, 4vw, 4rem) 0 var(--gap); }
.hero-text { margin-bottom: 2rem; }

/* ── Figures ────────────────────────────────────────── */
figure.fig { margin: 2rem 0 0; }
figure.fig img {
  border-radius: 6px;
  border: 1px solid var(--border);
  width: 100%;
}
figcaption {
  font-size: .92rem;
  line-height: 1.55;
  color: var(--ink-3);
  margin-top: .6rem;
}
figcaption .cr { display: block; margin-top: .25rem; font-size: .85rem; color: var(--ink-4); }
figcaption .cr a { color: var(--ink-3); }

/* ── Facts ──────────────────────────────────────────── */
dl.facts {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .4rem 1rem;
  margin-top: 1.5rem;
  padding: 1.1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .98rem;
}
dl.facts dt { color: var(--ink-3); white-space: nowrap; }
dl.facts dd { color: var(--ink-2); }

/* ── The wall (interaction) ─────────────────────────── */
.wall-stage {
  background: var(--chalk);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: clamp(1rem, 3vw, 1.75rem);
  margin: 1.5rem 0;
}
.wall-svg { width: 100%; height: auto; display: block; }
.wall-svg .zone { fill: none; stroke: var(--chalk-line); stroke-width: 1.5; opacity: .55; }
.wall-svg .zone-glyph { stroke: var(--ink-3); stroke-width: 2; fill: none; stroke-linecap: round; opacity: .7; }
.wall-svg g.z { cursor: default; }
.wall-svg g.z.active .zone { stroke: var(--accent); stroke-width: 3; opacity: 1; }
.wall-svg g.z.active .zone-glyph { stroke: var(--accent); opacity: 1; }
.wall-cap { font-size: .88rem; color: var(--ink-4); margin-top: .75rem; }
.chips { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1.25rem 0 0; list-style: none; padding: 0; }
.chips button {
  font-family: var(--font-body);
  font-size: .95rem;
  color: var(--ink-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .45rem 1rem;
  min-height: 2.75rem;
  cursor: pointer;
}
.chips button:hover { border-color: var(--ink-3); }
.chips button[aria-pressed="true"] {
  background: var(--accent-bg);
  border-color: var(--accent);
  color: var(--ink);
  font-weight: 700;
}
.chips .dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; margin-right: .45em; }

/* ── Script cards ───────────────────────────────────── */
ol.cards { list-style: none; padding: 0; margin: 1.5rem 0 0; display: grid; gap: 1rem; }
.card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--stone);
  border-radius: 6px;
  padding: 1rem 1.25rem;
  background: var(--paper);
}
.card h3 { font-family: var(--font-display); font-size: 1.3rem; font-weight: 400; }
.card .count { font-size: .92rem; color: var(--ink-3); }
.card .verdict { display: flex; align-items: center; gap: .5em; font-size: .92rem; margin: .4rem 0 .5rem; }
.card .verdict .dot { width: .7em; height: .7em; border-radius: 50%; flex: none; }
.card p.why { font-size: .99rem; color: var(--ink-2); }
.card.v-read { border-left-color: var(--read); }
.card.v-read .verdict { color: var(--read); }
.card.v-read .verdict .dot, .chips .dot.d-read { background: var(--read); }
.card.v-unread { border-left-color: var(--unread); }
.card.v-unread .verdict { color: var(--unread); }
.card.v-unread .verdict .dot, .chips .dot.d-unread { background: var(--unread); }
.card.v-part { border-left-color: var(--part); }
.card.v-part .verdict { color: var(--part); }
.card.v-part .verdict .dot, .chips .dot.d-part { background: var(--part); }
.card.match { outline: 2px solid var(--accent); outline-offset: 2px; }
.tally { font-family: var(--font-display); font-size: 1.15rem; color: var(--ink-2); margin-top: 1rem; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.25rem; list-style: none; padding: 0; margin-top: 1rem; font-size: .92rem; color: var(--ink-3); }
.legend .dot { display: inline-block; width: .65em; height: .65em; border-radius: 50%; margin-right: .4em; }
.legend .v-read .dot { background: var(--read); }
.legend .v-unread .dot { background: var(--unread); }
.legend .v-part .dot { background: var(--part); }

/* ── Sources ────────────────────────────────────────── */
.sources { list-style: none; padding: 0; margin-top: 1rem; display: grid; gap: .6rem; font-size: .98rem; }
.sources li { padding-left: 1.1rem; position: relative; color: var(--ink-2); }
.sources li::before { content: "—"; position: absolute; left: 0; color: var(--ink-4); }
.verify-bar {
  margin-top: 1.5rem;
  padding: 1rem 1.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--read);
  border-radius: 6px;
  background: var(--read-bg);
  font-size: .95rem;
  color: var(--ink-2);
}

/* ── Rail ───────────────────────────────────────────── */
.rail {
  position: fixed; right: 1rem; top: 50%; transform: translateY(-50%);
  display: none; flex-direction: column; gap: .35rem; z-index: 50;
}
@media (min-width: 80rem) {
  .rail { display: flex; }
}
.rail a {
  display: flex; align-items: center; gap: .5rem; justify-content: flex-end;
  color: var(--ink-4); text-decoration: none; font-size: .8rem;
  font-family: var(--font-display);
}
.rail a i { display: block; width: .55rem; height: .55rem; border-radius: 50%; background: var(--stone); flex: none; }
.rail a[aria-current="true"] { color: var(--ink); }
.rail a[aria-current="true"] i { background: var(--accent); }

/* ── Footer ─────────────────────────────────────────── */
footer.site {
  border-top: 1px solid var(--border);
  padding: 2rem 0 3rem;
  font-size: .92rem;
  color: var(--ink-3);
}

/* ── Reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* ── Small screens ──────────────────────────────────── */
@media (max-width: 40rem) {
  dl.facts { grid-template-columns: 1fr; gap: .15rem; }
  dl.facts dt { margin-top: .5rem; }
  dl.facts dt:first-child { margin-top: 0; }
}
