/* ============================================================
   Encyclopedia Afghanica — css/style.css

   The ONLY stylesheet. All presentation lives here; HTML pages
   must never carry inline styles, <style> blocks, or scripts.

   Design language: classic scholarly — serif text on warm paper,
   a single reading column, hairline rules, quiet oxblood accents.
   Dark mode follows the OS automatically. RTL is pre-wired for
   the future ps/ and fa/ mirrors.

   Selectors are limited to elements/classes permitted by the
   canonical template in AGENTS.md §4.
   ============================================================ */

:root {
  --paper:  #f6f1e7;
  --card:   #fdfaf3;
  --ink:    #26211a;
  --muted:  #6d6150;
  --accent: #8a3324;
  --accent-deep: #5f2117;
  --rule:   #d8ccb4;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:  #191512;
    --card:   #211c17;
    --ink:    #e9e0cf;
    --muted:  #a29580;
    --accent: #cf8757;
    --accent-deep: #b06a3f;
    --rule:   #3c342a;
  }
}

* { box-sizing: border-box; }

/* ---------- page frame ---------- */

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Georgia, "Iowan Old Style", "Palatino Linotype",
               "Book Antiqua", "Source Serif 4", serif;
  font-size: 1.0625rem;
  line-height: 1.68;
}

main {
  max-width: 68ch;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 2.75rem;
}

footer {
  max-width: 68ch;
  margin: 0 auto;
  padding: 1rem 1.25rem 2.5rem;
  border-top: 1px solid var(--rule);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
}

footer p { margin: 0; }

/* ---------- breadcrumbs ---------- */

nav.crumbs {
  max-width: 68ch;
  margin: 0 auto;
  padding: 0.95rem 1.25rem 0;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.85rem;
  color: var(--muted);
}

/* ---------- headings ---------- */

h1, h2, h3 {
  line-height: 1.22;
  font-weight: 600;
  color: var(--ink);
}

h1 { font-size: 2.05rem; margin: 0.35rem 0 1.1rem; }
h2 {
  font-size: 1.32rem;
  margin: 2.1rem 0 0.7rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}
h3 { font-size: 1.08rem; margin: 1.6rem 0 0.55rem; }

/* ---------- prose ---------- */

p { margin: 0.85rem 0; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent);
  text-underline-offset: 0.16em;
}
a:hover { color: var(--accent-deep); text-decoration-thickness: 2px; }

em, strong, q, cite { font-style: inherit; }
em { font-style: italic; }
strong { font-weight: 700; }

blockquote {
  margin: 1.3rem 0;
  padding: 0.15rem 0 0.15rem 1.1rem;
  border-left: 3px solid var(--rule);
  color: var(--muted);
}

hr {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: 2.2rem auto;
  width: 42%;
}

ul, ol { margin: 0.85rem 0; padding-left: 1.5rem; }
li { margin: 0.32rem 0; }

time { color: inherit; }

sup { font-size: 0.72em; line-height: 0; }
sup a {
  text-decoration: none;
  font-weight: 600;
}

/* ---------- figures & tables ---------- */

figure { margin: 1.6rem 0; }

img {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  border: 1px solid var(--rule);
}

figcaption {
  margin-top: 0.55rem;
  text-align: center;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.83rem;
  color: var(--muted);
}

table {
  border-collapse: collapse;
  width: 100%;
  margin: 1.4rem 0;
  font-size: 0.95rem;
}
th, td {
  text-align: left;
  padding: 0.5rem 0.7rem;
  border-bottom: 1px solid var(--rule);
}
th {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

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

section#sources {
  margin-top: 2.6rem;
  padding-top: 0.4rem;
  border-top: 2px solid var(--rule);
  font-size: 0.92rem;
}

section#sources h2 {
  font-size: 1.12rem;
  border-bottom: none;
  margin-bottom: 0.4rem;
}

section#sources ol { padding-left: 1.4rem; }
section#sources li { margin: 0.4rem 0; }

/* ---------- right-to-left mirrors (ps/, fa/) ----------
   Pages generated with lang="ps"/"fa" and dir="rtl" get proper
   Arabic-script typography and mirrored chrome for free.       */

[lang="ps"], [lang="fa"] {
  font-family: "Noto Naskh Arabic", "Amiri", "Scheherazade New",
               "Iranian Sans", serif;
  line-height: 1.95;
}

[dir="rtl"] blockquote {
  border-left: 0;
  border-right: 3px solid var(--rule);
  padding: 0.15rem 1.1rem 0.15rem 0;
}

[dir="rtl"] ul,
[dir="rtl"] ol,
[dir="rtl"] section#sources ol { padding-left: 0; padding-right: 1.5rem; }

[dir="rtl"] th, [dir="rtl"] td { text-align: right; }

/* ---------- print ---------- */

@media print {
  body { background: #fff; color: #000; }
  nav.crumbs, footer { display: none; }
  main { max-width: none; padding: 0; }
  a { color: inherit; text-decoration: none; }
}
