/* ═══════════════════════════════════════════════════════
   TIGLA DE LA APULUM — Clay, stamp, legion
   ═══════════════════════════════════════════════════════ */

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

/* ── Tokens: light ──────────────────────────────────── */
:root {
  --paper:    #f4eee3;
  --surface:  #e9dfcc;
  --surface-2:#dccfb6;
  --stone:    #c9b99c;

  --ink:      #221610;
  --ink-2:    #46372b;
  --ink-3:    #6a5a4c;
  --ink-4:    #8a7a68;

  --accent:   #93340f;
  --accent-bg:#f3ddc9;

  --kept:     #1b5e3e;
  --kept-bg:  #d8e8de;
  --returned: #2a5b7c;
  --returned-bg:#d6e6f0;
  --rebuilt:  #5f3d8c;
  --rebuilt-bg:#e6dcf5;
  --lost:     #8b1a1a;
  --lost-bg:  #f0d4d4;

  --clay:     #93340f;
  --clay-bg:  #f3ddc9;

  --focus:    #2a5b7c;
  --border:   rgba(34,22,16,.13);

  --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:    #14100c;
  --surface:  #1f1712;
  --surface-2:#2a1f17;
  --stone:    #453729;

  --ink:      #f0e7d7;
  --ink-2:    #d3c8b4;
  --ink-3:    #b3a690;
  --ink-4:    #938670;

  --accent:   #e0955a;
  --accent-bg:#2d1c0e;

  --kept:     #7cc8a0;
  --kept-bg:  #162a20;
  --returned: #7fb3d9;
  --returned-bg:#14242f;
  --rebuilt:  #c0a8e8;
  --rebuilt-bg:#211a33;
  --lost:     #e89090;
  --lost-bg:  #2a1616;

  --clay:     #e0955a;
  --clay-bg:  #2d1c0e;

  --focus:    #7fb3d9;
  --border:   rgba(240,231,215,.11);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:    #14100c;
    --surface:  #1f1712;
    --surface-2:#2a1f17;
    --stone:    #453729;
    --ink:      #f0e7d7;
    --ink-2:    #d3c8b4;
    --ink-3:    #b3a690;
    --ink-4:    #938670;
    --accent:   #e0955a;
    --accent-bg:#2d1c0e;
    --kept:     #7cc8a0;
    --kept-bg:  #162a20;
    --returned: #7fb3d9;
    --returned-bg:#14242f;
    --rebuilt:  #c0a8e8;
    --rebuilt-bg:#211a33;
    --lost:     #e89090;
    --lost-bg:  #2a1616;
    --clay:     #e0955a;
    --clay-bg:  #2d1c0e;
    --focus:    #7fb3d9;
    --border:   rgba(240,231,215,.11);
  }
}

/* ── 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.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.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; }

/* ── 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; }

/* ── Stamp ──────────────────────────────────────────── */
.slab {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin: 0 auto;
  max-width: 56rem;
}
.stamp-box {
  position: relative;
  padding: clamp(1.5rem, 4vw, 3rem) clamp(1rem, 3vw, 2rem);
  text-align: center;
}
.stamp-svg { max-width: 34rem; margin: 0 auto; width: 100%; height: auto; display: block; }
.stamp-svg .cartouche {
  fill: var(--surface-2);
  stroke: var(--ink-3);
  stroke-width: 3;
}
.stamp-svg .cartouche-inner {
  fill: none;
  stroke: var(--ink-3);
  stroke-width: 1.2;
  opacity: .7;
}
.stamp-svg text {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .08em;
}
.stamp-svg .w { cursor: pointer; }
.stamp-svg .w .hit { fill: transparent; }
.stamp-svg .w .glyph { fill: var(--ink-2); transition: fill .15s; }
.stamp-svg .w:hover .glyph, .stamp-svg .w.active .glyph { fill: var(--accent); }
.stamp-svg .w.v-kept:hover .glyph, .stamp-svg .w.v-kept.active .glyph { fill: var(--kept); }
.stamp-svg .w.v-returned:hover .glyph, .stamp-svg .w.v-returned.active .glyph { fill: var(--returned); }
.stamp-svg .w.v-rebuilt:hover .glyph, .stamp-svg .w.v-rebuilt.active .glyph { fill: var(--rebuilt); }
.stamp-svg .sep { fill: var(--ink-4); }
.slab-cap {
  padding: 1rem clamp(1rem, 3vw, 2rem);
  font-size: .88rem;
  color: var(--ink-3);
  border-top: 1px solid var(--border);
}
.expansion {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1.5rem;
  justify-content: center;
  margin-top: 1rem;
  padding: 1rem;
  border-top: 1px solid var(--border);
}
.expansion .pair { text-align: center; min-width: 5rem; }
.expansion .lat {
  display: block;
  font-family: var(--font-display);
  font-size: .95rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 600;
}
.expansion .ro { display: block; font-size: .95rem; color: var(--ink); font-style: italic; }

/* ── Word cards ─────────────────────────────────────── */
.cards { list-style: none; padding: 0; display: grid; gap: 1rem; }
.card {
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--paper);
  cursor: pointer;
}
.card.match { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.lede.gap-top { margin-top: var(--gap); }
.card .from {
  font-family: var(--font-display);
  font-size: 1.3rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  font-weight: 600;
}
.card .arrow { color: var(--ink-4); margin: 0 .5rem; }
.card .to { font-size: 1.15rem; font-style: italic; }
.card .verdict {
  display: flex; align-items: center; gap: .4rem;
  margin: .5rem 0; font-size: .88rem; font-weight: 600;
}
.card .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex-shrink: 0; }
.card.v-kept .dot { background: var(--kept); }
.card.v-kept .verdict { color: var(--kept); }
.card.v-kept .from { color: var(--kept); }
.card.v-returned .dot { background: var(--returned); }
.card.v-returned .verdict { color: var(--returned); }
.card.v-returned .from { color: var(--returned); }
.card.v-rebuilt .dot { background: var(--rebuilt); }
.card.v-rebuilt .verdict { color: var(--rebuilt); }
.card.v-rebuilt .from { color: var(--rebuilt); }
.card.v-lost .dot { background: var(--lost); }
.card.v-lost .verdict { color: var(--lost); }
.card.v-lost .from { color: var(--lost); }
.card .why { font-size: .92rem; color: var(--ink-2); line-height: 1.55; }
.card .why i { font-style: italic; }

.legend {
  list-style: none; padding: 0;
  display: flex; flex-wrap: wrap; gap: .5rem 1.5rem;
  font-size: .85rem; color: var(--ink-3); margin: 1rem 0;
}
.legend li { display: flex; align-items: center; gap: .35rem; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend .v-kept .dot { background: var(--kept); }
.legend .v-returned .dot { background: var(--returned); }
.legend .v-rebuilt .dot { background: var(--rebuilt); }
.legend .v-lost .dot { background: var(--lost); }
.tally { font-size: .9rem; color: var(--ink-3); margin-bottom: .5rem; }

/* ── Split layout ───────────────────────────────────── */
.split { display: grid; grid-template-columns: 1fr; gap: var(--gap); }
@media (min-width: 50rem) { .split { grid-template-columns: 1fr 1fr; } }
.split .side { display: flex; flex-direction: column; gap: 1.5rem; }

/* ── Figures ────────────────────────────────────────── */
.fig { margin: 1.5rem 0 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); }

/* ── 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); }

/* ── Timeline ───────────────────────────────────────── */
.timeline { list-style: none; padding: 0; border-left: 2px solid var(--border); margin-left: .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;
}
.timeline .clay-event::before { background: var(--clay); }
.timeline .clay-event .year { color: var(--clay); }

/* ── 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; }

/* ── 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;
  }
  .rail a {
    display: flex; align-items: center; gap: .5rem;
    color: var(--ink-4); text-decoration: none;
    font-size: .8rem; font-family: var(--font-display);
    flex-direction: row-reverse;
  }
  .rail a i {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--stone); display: block; flex-shrink: 0;
  }
  .rail a[aria-current="true"] { color: var(--ink); }
  .rail a[aria-current="true"] i { background: var(--accent); }
}

/* ── Not found ──────────────────────────────────────── */
.notfound { padding-top: 4rem; text-align: center; }
.notfound p { margin-top: .5rem; }

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