/* Cinci sate și cinci cimitire, pe același deal
   Palette taken from a cut through soil: chalk and pale clay above, ochre and burnt
   earth in the middle, charcoal at the bottom. Both themes are declared here in full;
   no colour is written outside a token block. */

:root {
  --paper:        #f4efe6;
  --surface:      #fcf9f3;
  --surface-deep: #eae3d5;
  --rule:         #d2c7b3;
  --rule-strong:  #ab9d84;

  --text:         #1b1712;
  --text-soft:    #463e33;
  --text-muted:   #4e4638;

  --ochre:        #9a4a16;   /* settlements — validated, light mode */
  --ochre-deep:   #7d3c11;
  --deep:         #1d5f92;   /* burials — validated, light mode */
  --deep-soft:    #2a6ea4;
  --charcoal:     #3b4048;
  --moss:         #4a6140;
  --chalk:        #7c705c;

  --ink-ochre:    #6d340f;
  --ink-deep:     #174a72;

  --map-land:     #e7dfcd;
  --map-line:     #c4b89d;
  --map-sea:      #eeece5;
  --ghost:        #b3a68c;

  --shadow:       0 1px 2px rgba(27, 23, 18, .07), 0 8px 28px rgba(27, 23, 18, .08);
  --focus:        #1d5f92;

  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

  --measure: 34rem;
  --gutter: clamp(1.15rem, 4vw, 2.5rem);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper:        #12140f;
    --surface:      #1c1f19;
    --surface-deep: #262a22;
    --rule:         #383d33;
    --rule-strong:  #545a4c;

    --text:         #f2eee3;
    --text-soft:    #cfc8b7;
    --text-muted:   #bdb5a2;

    --ochre:        #c9793c;
    --ochre-deep:   #e09a5f;
    --deep:         #4f9bd0;
    --deep-soft:    #75b3de;
    --charcoal:     #9aa3ae;
    --moss:         #9cbb8f;
    --chalk:        #a89c85;

    --ink-ochre:    #f0c395;
    --ink-deep:     #b4d6ee;

    --map-land:     #21261d;
    --map-line:     #3d4536;
    --map-sea:      #14170f;
    --ghost:        #5a6150;

    --shadow:       0 1px 2px rgba(0, 0, 0, .44), 0 10px 34px rgba(0, 0, 0, .36);
    --focus:        #75b3de;
  }
}

:root[data-theme="dark"] {
  --paper:        #12140f;
  --surface:      #1c1f19;
  --surface-deep: #262a22;
  --rule:         #383d33;
  --rule-strong:  #545a4c;

  --text:         #f2eee3;
  --text-soft:    #cfc8b7;
  --text-muted:   #bdb5a2;

  --ochre:        #c9793c;
  --ochre-deep:   #e09a5f;
  --deep:         #4f9bd0;
  --deep-soft:    #75b3de;
  --charcoal:     #9aa3ae;
  --moss:         #9cbb8f;
  --chalk:        #a89c85;

  --ink-ochre:    #f0c395;
  --ink-deep:     #b4d6ee;

  --map-land:     #21261d;
  --map-line:     #3d4536;
  --map-sea:      #14170f;
  --ghost:        #5a6150;

  --shadow:       0 1px 2px rgba(0, 0, 0, .44), 0 10px 34px rgba(0, 0, 0, .36);
  --focus:        #75b3de;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0; background: var(--paper); color: var(--text);
  font-family: var(--serif); font-size: 1.0625rem; line-height: 1.62;
  text-rendering: optimizeLegibility;
}
@media (min-width: 46rem) { body { font-size: 1.125rem; line-height: 1.66; } }

a { color: inherit; text-underline-offset: .18em; text-decoration-thickness: from-font; }
a:hover { text-decoration-color: var(--ochre); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

.wrap { max-width: calc(var(--measure) + 2 * var(--gutter)); margin: 0 auto; padding: 0 var(--gutter); }
.wide { max-width: 78rem; margin: 0 auto; padding: 0 var(--gutter); }
.skip {
  position: absolute; left: -9999px; top: 0; background: var(--surface); color: var(--text);
  padding: .6rem .9rem; border: 1px solid var(--rule-strong); border-radius: 5px; z-index: 60;
}
.skip:focus { left: .8rem; top: .8rem; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 40; display: flex; align-items: center; gap: .55rem;
  padding: .3rem var(--gutter); background: color-mix(in srgb, var(--paper) 97%, transparent);
  backdrop-filter: saturate(1.2) blur(8px); border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: .75rem; min-height: 2.5rem;
}
.topbar .home { font-weight: 600; text-decoration: none; color: var(--text-soft); flex: none; }
.topbar .spacer { flex: 1; }

/* Jumps to the places a reader goes straight to. Scrolls sideways rather than wrapping,
   so the bar stays one line tall at every width. */
.topnav {
  display: flex; gap: .1rem; overflow-x: auto; scrollbar-width: none;
  -ms-overflow-style: none; margin-left: .25rem; min-width: 0;
}
.topnav::-webkit-scrollbar { display: none; }
.topnav a {
  padding: .2rem .5rem; border-radius: 999px; text-decoration: none;
  color: var(--text-muted); white-space: nowrap;
}
.topnav a:hover { color: var(--ochre); background: var(--surface-deep); }
.topnav a[aria-current="true"] { color: var(--text); background: var(--surface-deep); font-weight: 600; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 1.85rem; height: 1.85rem; padding: 0; border-radius: 999px; cursor: pointer;
  color: var(--text-muted); background: var(--surface); border: 1px solid var(--rule-strong);
}
.icon-btn:hover { color: var(--ochre); border-color: var(--ochre); }
.icon-btn svg { display: block; }
/* `hidden` has to beat the rule above, or both icons show at once. */
.icon-btn svg[hidden] { display: none; }

.chip {
  display: inline-flex; align-items: center; gap: .3rem; padding: .2rem .55rem;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); text-decoration: none; font: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--ochre); color: var(--ochre); }
.chip[aria-current="true"] { background: var(--text); color: var(--paper); border-color: var(--text); }
@media (max-width: 34rem) {
  .topbar .home { max-width: 6.4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar { gap: .35rem; }
  .topnav a { padding: .2rem .4rem; }
}

/* ---------- hero ---------- */
.hero { padding: clamp(2.4rem, 7vw, 4.6rem) 0 1.2rem; }
.kicker {
  font-family: var(--sans); font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--ochre); margin: 0 0 .85rem; font-weight: 650;
}
h1 {
  font-size: clamp(2.05rem, 6.4vw, 3.3rem); line-height: 1.07; letter-spacing: -.022em;
  font-weight: 650; margin: 0 0 1rem; text-wrap: balance;
}
.deck { font-size: 1.1rem; color: var(--text-soft); margin: 0 0 1.3rem; }
@media (min-width: 46rem) { .deck { font-size: 1.24rem; } }
.byline { font-family: var(--sans); font-size: .78rem; color: var(--text-muted); margin: 0; }

h2 {
  font-size: clamp(1.4rem, 3.6vw, 1.85rem); line-height: 1.16; letter-spacing: -.015em;
  font-weight: 650; margin: 2.8rem 0 .9rem; text-wrap: balance;
}
h3 { font-size: 1.09rem; font-weight: 650; margin: 1.9rem 0 .55rem; }
section { scroll-margin-top: 3.4rem; }
p { margin: 0 0 1.15rem; }
.lede::first-letter {
  float: left; font-size: 3.3em; line-height: .84; padding: .06em .09em 0 0;
  color: var(--ochre); font-weight: 650;
}
strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }
.standfirst { color: var(--text-muted); font-family: var(--sans); font-size: .88rem; margin: 0 0 1.4rem; }

.note {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--chalk);
  border-radius: 0 6px 6px 0; padding: 1rem 1.15rem; margin: 1.7rem 0;
  font-size: .9375rem; color: var(--text-soft);
}
.note h3 { margin: 0 0 .4rem; font-size: .76rem; letter-spacing: .1em; text-transform: uppercase; color: var(--chalk); }
.note p:last-child { margin-bottom: 0; }

/* ---------- reading rail ---------- */
.rail {
  display: none; position: fixed; top: 50%; right: 1.4rem; transform: translateY(-50%);
  flex-direction: column; align-items: flex-end; gap: .5rem; z-index: 30;
}
@media (min-width: 76rem) { .rail { display: flex; } }
.rail-dot {
  position: relative; display: flex; align-items: center; justify-content: flex-end;
  text-decoration: none; padding: .15rem 0; width: 14px;
}
.rail-dot .dot {
  display: block; width: 6px; height: 6px; border-radius: 50%; flex: none;
  background: var(--rule-strong); transition: background-color .15s ease, transform .15s ease;
}
.rail-dot:hover .dot, .rail-dot:focus-visible .dot { background: var(--text-soft); }
.rail-dot.active .dot { background: var(--ochre); transform: scale(1.45); }
.rail-label {
  /* Out of flow: in flow, an invisible label still takes width and every dot lands at a
     different x, which reads as a scattered column rather than a rail. */
  position: absolute; right: 100%; top: 50%; margin-top: -.85rem; margin-right: .5rem;
  font-family: var(--sans); font-size: .75rem; line-height: 1.2; color: var(--text-soft);
  background: var(--surface); border: 1px solid var(--rule); border-radius: 4px;
  padding: .25rem .55rem; white-space: nowrap; box-shadow: var(--shadow);
  opacity: 0; transform: translateX(6px); pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}
.rail-dot:hover .rail-label, .rail-dot:focus-visible .rail-label { opacity: 1; transform: none; }
.rail-dot.active .rail-label { color: var(--text); border-color: var(--rule-strong); }
@media (prefers-reduced-motion: reduce) { .rail-dot .dot, .rail-label { transition: none; } }
@media print { .rail { display: none; } }

/* ---------- figures ---------- */
figure { margin: 2rem 0; }
figure img {
  display: block; width: 100%; height: auto; border-radius: 6px;
  border: 1px solid var(--rule); background: var(--surface-deep);
}
figcaption { font-family: var(--sans); font-size: .8125rem; line-height: 1.5; color: var(--text-muted); margin-top: .55rem; }
figcaption b { color: var(--text-soft); font-weight: 650; }
figcaption .credit { display: block; margin-top: .25rem; font-size: .75rem; }

/* ---------- the stratigraphic column ---------- */
.strata { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 1.15rem 1.1rem 1rem; margin: 2rem 0; }
.strata svg { display: block; width: 100%; height: auto; }
.strata .st-band { fill: var(--surface-deep); }
.strata .st-band.alt { fill: color-mix(in srgb, var(--chalk) 12%, var(--surface)); }
.strata .st-rule { stroke: var(--rule); stroke-width: 1; }
.strata .st-set { fill: var(--ochre); }
.strata .st-nec { fill: var(--deep); }
.strata text { font-family: var(--sans); fill: var(--text-soft); }
.strata .st-era { font-size: 13px; font-weight: 650; fill: var(--text); }
.strata .st-date { font-size: 11.5px; fill: var(--text-muted); }
.strata .st-key { font-size: 12px; fill: var(--text-soft); }

.keyrow { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; font-family: var(--sans); font-size: .8125rem; color: var(--text-soft); margin: .85rem 0 0; }
.keyrow span { display: inline-flex; align-items: center; gap: .4rem; }
.keyrow i { width: 11px; height: 11px; border-radius: 2px; display: block; }
.k-set { background: var(--ochre); }
.k-nec { background: var(--deep); }
.k-now { background: var(--ochre); }
.k-old { background: var(--ghost); }

/* ---------- the running map ---------- */
.atlas { background: var(--surface); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: clamp(1.7rem, 4vw, 2.9rem) 0; margin: 2.6rem 0; }
.atlas-head { max-width: var(--measure); margin: 0 0 1.3rem; }
.atlas-head h2 { margin-top: 0; }
.mapbox { position: relative; border: 1px solid var(--rule); border-radius: 8px; background: var(--map-sea); overflow: hidden; }
.mapbox svg { display: block; width: 100%; height: auto; touch-action: none; }
.mapbox svg:focus-visible { outline: 2px solid var(--focus); outline-offset: -2px; }
.mapbox svg.zoomed { cursor: grab; }
.mapbox svg.zoomed:active { cursor: grabbing; }
@media (min-width: 46rem) { .mapbox svg { max-height: 62vh; } }
.land { fill: var(--map-land); stroke: var(--map-line); stroke-width: 1.1; stroke-linejoin: round; }
.county { fill: none; stroke: var(--map-line); stroke-width: .5; opacity: .7; }
.county.on { stroke: var(--ochre); stroke-width: 1.4; opacity: 1; }
.county.off { opacity: .3; }
.pt { transition: opacity .35s ease, r .35s ease; }
.pt-old { fill: var(--ghost); opacity: .5; }
.pt-now { fill: var(--ochre); }
.pt-hollow { fill: none; stroke: var(--ochre); stroke-width: 1.3; }
.pt-hit { fill: transparent; cursor: pointer; }
.pt-hit:focus-visible { outline: none; }
.pt-sel { fill: none; stroke: var(--text); stroke-width: 2; }
@media (prefers-reduced-motion: reduce) { .pt { transition: none; } }

.controls { display: flex; flex-wrap: wrap; align-items: center; gap: .6rem; margin: 0 0 .5rem; font-family: var(--sans); font-size: .85rem; }
.controls button { font: inherit; }
.btn {
  display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .85rem;
  border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--surface);
  color: var(--text); cursor: pointer;
}
.btn:hover { border-color: var(--ochre); color: var(--ochre); }
.btn-main { background: var(--text); color: var(--paper); border-color: var(--text); }
.btn-sq { min-width: 2.1rem; justify-content: center; padding: .4rem .55rem; font-size: 1rem; line-height: 1; }
.btn-sq[disabled] { opacity: .45; cursor: default; }
.btn-sq[disabled]:hover { border-color: var(--rule-strong); color: var(--text); }
.select {
  padding: .38rem 1.7rem .38rem .7rem; max-width: 12rem;
  appearance: none; -webkit-appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, currentColor 50%),
                    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 14px) 52%, calc(100% - 9px) 52%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.btn-main:hover { background: var(--ochre-deep); border-color: var(--ochre-deep); color: var(--paper); }
.readout { font-variant-numeric: tabular-nums; color: var(--text-soft); }
.readout b { color: var(--text); font-weight: 650; }

.scrub { width: 100%; margin: .3rem 0 0; accent-color: var(--ochre); }
.ticks { display: flex; justify-content: space-between; font-family: var(--sans); font-size: .68rem; color: var(--text-muted); margin-top: .1rem; }

.epochbar {
  display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 .7rem;
  font-family: var(--sans); font-size: .78rem;
}
.epochbar button {
  border: 1px solid var(--rule); border-radius: 999px; background: var(--surface);
  color: var(--text-soft); cursor: pointer; padding: .22rem .62rem; font: inherit;
  white-space: nowrap; overflow: hidden;
}
.epochbar button:hover { border-color: var(--ochre); color: var(--ochre); }
.epochbar button[aria-pressed="true"] {
  background: var(--ochre); border-color: var(--ochre-deep); color: var(--paper); font-weight: 600;
}
@media (max-width: 30rem) { .epochbar { font-size: .72rem; gap: 3px; } }

.card {
  position: absolute; right: .7rem; bottom: .7rem; width: min(22rem, calc(100% - 1.4rem));
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 8px;
  box-shadow: var(--shadow); padding: .85rem .95rem; font-family: var(--sans); font-size: .82rem;
  color: var(--text-soft); max-height: 62%; overflow: auto;
}
.card h3 { margin: 0 .5rem .15rem 0; font-size: .95rem; color: var(--text); font-family: var(--serif); }
.card .where { color: var(--text-muted); font-size: .76rem; margin: 0 0 .55rem; }
.card ol { margin: 0; padding: 0; list-style: none; }
.card li { display: flex; gap: .5rem; padding: .3rem 0; border-top: 1px solid var(--rule); }
.card li .ep { flex: none; width: 8.6rem; color: var(--text); font-weight: 600; }
.card li .ds { color: var(--text-muted); font-size: .76rem; }
.card .close { position: absolute; top: .45rem; right: .5rem; border: 0; background: none; cursor: pointer; color: var(--text-muted); font-size: 1.05rem; line-height: 1; padding: .2rem; }
.card .close:hover { color: var(--ochre); }

.maphint { margin: .6rem 0 0; }
.state { padding: 2rem 1rem; text-align: center; font-family: var(--sans); font-size: .9rem; color: var(--text-muted); }

/* ---------- bar charts (one series, geometry in SVG so no inline style is needed) ---------- */
.bars { margin: 1.6rem 0; }
.barchart { display: block; width: 100%; height: auto; font-family: var(--sans); }
.barchart .bl { font-size: 13px; fill: var(--text-soft); }
.barchart .bv { font-size: 13px; fill: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.barchart .btrack { fill: var(--surface-deep); }
.barchart .bar { fill: var(--ochre); }
.barchart .bar.dim { fill: var(--chalk); }

/* ---------- tables ---------- */
.tablewrap {
  overflow-x: auto; margin: 1.7rem 0; border: 1px solid var(--rule); border-radius: 8px;
  background: var(--surface);
}
/* Tables carry more columns than the reading measure allows, so they break out of it
   rather than wrapping every cell onto four lines. */
@media (min-width: 52rem) {
  .wrap .tablewrap {
    width: min(70rem, calc(100vw - 2 * var(--gutter)));
    margin-left: 50%; transform: translateX(-50%);
  }
}
table { border-collapse: collapse; width: 100%; font-family: var(--sans); font-size: .84rem; }
caption { text-align: left; padding: .8rem .9rem .1rem; color: var(--text-muted); font-size: .8rem; }
th, td { text-align: left; padding: .48rem .9rem; border-top: 1px solid var(--rule); vertical-align: top; }
td:first-child { font-weight: 600; color: var(--text); }
@media (min-width: 52rem) { td:first-child, th:first-child { white-space: nowrap; } }
thead th { border-top: 0; color: var(--text-muted); font-weight: 600; font-size: .75rem; letter-spacing: .04em; text-transform: uppercase; white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--surface-deep); }

/* ---------- footer ---------- */
footer { border-top: 1px solid var(--rule); margin-top: 3.2rem; padding: 1.8rem 0 3rem; font-family: var(--sans); font-size: .84rem; color: var(--text-muted); }
footer a { color: var(--text-soft); }
footer ul { margin: .5rem 0 0; padding-left: 1.1rem; }
footer li { margin: .2rem 0; }
.totop { display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; color: var(--text-soft); }

@media print {
  .topbar, .controls, .epochbar, .scrub { display: none; }
  body { background: #fff; color: #000; }
}
