/* ═══════════════════════════════════════════════════════
   IUGARUL — Field, yoke, furrow
   ═══════════════════════════════════════════════════════ */

/* ── Fonts ──────────────────────────────────────────── */
@font-face {
  font-family: 'Spectral';
  src: url('/iugarul/assets/fonts/Spectral-500.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Spectral';
  src: url('/iugarul/assets/fonts/Spectral-500-latext.woff2') format('woff2');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Spectral';
  src: url('/iugarul/assets/fonts/Spectral-600.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Spectral';
  src: url('/iugarul/assets/fonts/Spectral-600-latext.woff2') format('woff2');
  font-weight: 600;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Spectral';
  src: url('/iugarul/assets/fonts/Spectral-500i.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Spectral';
  src: url('/iugarul/assets/fonts/Spectral-500i-latext.woff2') format('woff2');
  font-weight: 500;
  font-style: italic;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+2020, U+20A0-20AB, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ── Tokens: light ──────────────────────────────────── */
:root {
  --paper:    #f4efe3;
  --surface:  #e9e1cd;
  --surface-2:#ddd2b6;
  --stone:    #c9bb99;

  --ink:      #241c12;
  --ink-2:    #463b2a;
  --ink-3:    #66593f;
  --ink-4:    #8a7d63;

  --accent:   #7a4d12;
  --accent-bg:#f0dfc0;

  --field:    #3f6b2a;
  --field-bg: #dde8cf;
  --furrow:   #8b5e2e;
  --furrow-bg:#f3e4cb;

  --focus:    #2f6b8f;
  --border:   rgba(36,28,18,.14);

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

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

/* ── Tokens: dark ───────────────────────────────────── */
[data-theme="dark"] {
  --paper:    #14100a;
  --surface:  #1f1912;
  --surface-2:#2b2318;
  --stone:    #453a28;

  --ink:      #efe7d4;
  --ink-2:    #d3c9ae;
  --ink-3:    #b3a888;
  --ink-4:    #8f866e;

  --accent:   #d9a75f;
  --accent-bg:#2b2114;

  --field:    #93c47d;
  --field-bg: #1a2a16;
  --furrow:   #d29a5b;
  --furrow-bg:#2b2114;

  --focus:    #6aadcc;
  --border:   rgba(239,231,212,.12);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:    #14100a;
    --surface:  #1f1912;
    --surface-2:#2b2318;
    --stone:    #453a28;
    --ink:      #efe7d4;
    --ink-2:    #d3c9ae;
    --ink-3:    #b3a888;
    --ink-4:    #8f866e;
    --accent:   #d9a75f;
    --accent-bg:#2b2114;
    --field:    #93c47d;
    --field-bg: #1a2a16;
    --furrow:   #d29a5b;
    --furrow-bg:#2b2114;
    --focus:    #6aadcc;
    --border:   rgba(239,231,212,.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 { 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.1rem, 1.35rem + 3.3vw, 3.9rem);
  line-height: 1.08;
  font-weight: 600;
  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: 600;
  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.08rem, 1rem + .35vw, 1.28rem);
  line-height: 1.55;
  color: var(--ink-2);
  max-width: 34rem;
}
.lede {
  font-size: 1.08rem;
  color: var(--ink-2);
  margin-bottom: 1.5rem;
}
.prose { max-width: var(--measure); }
.prose p + p { margin-top: 1em; }
.prose figure, .wrap > figure { margin-top: 1.75rem; }

/* ── Hero ───────────────────────────────────────────── */
.hero {
  padding: clamp(3rem, 8vw, 7rem) 0 clamp(2rem, 5vw, 4rem);
  text-align: center;
}
.hero-text { margin-bottom: clamp(2rem, 4vw, 3.5rem); }
.hero h1 { margin-bottom: 1rem; }
.hero .deck { margin: 0 auto; }

/* ── Figures ────────────────────────────────────────── */
.fig { margin: 0; }
.fig img { border-radius: 6px; }
.fig figcaption {
  font-size: .85rem;
  color: var(--ink-3);
  margin-top: .5rem;
  line-height: 1.45;
}
.fig .cr { font-size: .78rem; display: block; margin-top: .25rem; }
.fig .cr a { color: var(--ink-4); }
.fig.side-float { max-width: 30rem; }
@media (min-width: 50rem) {
  .fig.side-float { max-width: 24rem; }
}

/* ── Etymology chain ────────────────────────────────── */
.etym {
  list-style: none;
  padding: 0;
  display: grid;
  gap: .75rem;
  margin: 1.5rem 0;
}
.etym li {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem;
  padding: .9rem 1.25rem;
  border: 1px solid var(--border);
  border-left: 4px solid var(--field);
  border-radius: 6px;
  background: var(--surface);
}
.etym .from {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--field);
}
.etym .arrow { color: var(--ink-4); }
.etym .to {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 600;
}
.etym .gloss { flex-basis: 100%; font-size: .9rem; color: var(--ink-3); }

/* ── Ancient quote ──────────────────────────────────── */
.quote {
  margin: 1.5rem 0;
  padding: 1.25rem 1.5rem;
  border-radius: 6px;
  background: var(--field-bg);
  border: 1px solid var(--border);
}
.quote p { font-family: var(--font-display); font-size: 1.1rem; line-height: 1.5; }
.quote cite {
  display: block;
  margin-top: .5rem;
  font-family: var(--font-body);
  font-style: normal;
  font-size: .85rem;
  color: var(--ink-3);
}

/* ── Facts DL ───────────────────────────────────────── */
.facts {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}
.facts dt {
  font-family: var(--font-display);
  font-size: .85rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-top: .75rem;
}
.facts dt:first-child { margin-top: 0; }
.facts dd { margin-left: 0; color: var(--ink-2); }

/* ── Measure interactive ────────────────────────────── */
.measure {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}
.measure fieldset { border: none; padding: 1.25rem 1.25rem 0; }
.measure legend {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  padding: 0;
}
.regions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem;
  margin-top: .75rem;
}
@media (max-width: 26rem) {
  .regions { grid-template-columns: 1fr; }
}
.regions label {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  cursor: pointer;
  font-family: var(--font-display);
  font-size: .95rem;
  min-height: 44px;
}
.regions label:hover { border-color: var(--accent); }
.regions label.picked { border-color: var(--field); background: var(--field-bg); }
.regions input {
  appearance: none;
  width: 1.1rem; height: 1.1rem;
  border: 2px solid var(--ink-4);
  border-radius: 50%;
  flex-shrink: 0;
  margin: 0;
  cursor: pointer;
  position: relative;
}
.regions label.picked input { border-color: var(--field); }
.regions label.picked input::after {
  content: '';
  position: absolute; inset: 2px;
  border-radius: 50%;
  background: var(--field);
}
.regions .sub { display: block; font-size: .78rem; color: var(--ink-3); font-family: var(--font-body); }
.result {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
  padding: 1.25rem;
}
@media (min-width: 50rem) {
  .result { grid-template-columns: 1fr 1fr; align-items: center; }
}
.bignum {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 2rem + 2.5vw, 3.4rem);
  font-weight: 600;
  line-height: 1.1;
  color: var(--field);
}
.result .unit { font-size: 1.1rem; color: var(--ink-3); font-weight: 500; }
.statline {
  list-style: none;
  padding: 0;
  margin-top: .75rem;
  font-size: .95rem;
  color: var(--ink-2);
}
.statline li { padding: .3rem 0; border-top: 1px dashed var(--border); }
.statline li:first-child { border-top: none; }
.statline strong { color: var(--ink); }
.fieldfig { margin: 0; }
.fieldfig svg {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 6px;
  background: var(--paper);
  border: 1px solid var(--border);
}
.fieldfig figcaption { font-size: .82rem; color: var(--ink-3); margin-top: .5rem; line-height: 1.45; }
.vh {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}
.fallback-table { width: 100%; border-collapse: collapse; margin-top: 1.5rem; font-size: .92rem; }
.fallback-table caption { text-align: left; font-family: var(--font-display); font-weight: 600; padding-bottom: .5rem; }
.fallback-table th, .fallback-table td {
  text-align: left;
  padding: .5rem .6rem;
  border-top: 1px solid var(--border);
}
.fallback-table th { color: var(--ink-3); font-weight: 600; }
.js .fallback-table { display: none; }

/* ── Timeline ───────────────────────────────────────── */
.timeline {
  list-style: none;
  padding: 0;
  border-left: 2px solid var(--border);
  margin: 1.5rem 0 0 .5rem;
}
.timeline li {
  padding: .75rem 0 .75rem 1.5rem;
  position: relative;
  font-size: .95rem;
  color: var(--ink-2);
}
.timeline li::before {
  content: '';
  position: absolute;
  left: -6px; top: 1rem;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--stone);
  border: 2px solid var(--paper);
}
.timeline .year {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--ink);
  display: block;
  font-size: 1rem;
}

/* ── Sources ────────────────────────────────────────── */
.srcs {
  padding: 0;
  list-style: none;
}
.srcs li {
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
  color: var(--ink-2);
}
.srcs li:last-child { border-bottom: none; }
.srcs a { word-break: break-all; }

/* ── Footer ─────────────────────────────────────────── */
.foot {
  padding: 2rem 0;
  text-align: center;
  font-size: .85rem;
  color: var(--ink-4);
  border-top: 1px solid var(--border);
}
.foot a { color: var(--ink-3); }
.foot p + p { margin-top: .25rem; }
.nf404 { padding-top: 4rem; text-align: center; }

/* ── Rail (desktop reading rail) ────────────────────── */
.rail {
  display: none;
}
@media (min-width: 90rem) {
  .rail {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    position: fixed;
    right: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 90;
    font-family: var(--font-display);
    font-size: .72rem;
    letter-spacing: .04em;
  }
  .rail a {
    display: flex; align-items: center; gap: .5rem;
    color: var(--ink-4); text-decoration: none;
    padding: .3rem .5rem;
    border-radius: 4px;
    flex-direction: row-reverse;
  }
  .rail a:hover { color: var(--ink-2); }
  .rail a[aria-current="true"] { color: var(--ink); }
  .rail a[aria-current="true"] i {
    background: var(--accent);
  }
  .rail i {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--stone);
    display: block;
    flex-shrink: 0;
  }
}

/* ── Reduced motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
  html { scroll-behavior: auto; }
}

/* ── Print ──────────────────────────────────────────── */
@media print {
  .topbar, .rail, .icon-btn { display: none; }
  body { font-size: 11pt; }
  section { break-inside: avoid; }
}
