/* Cele mai vechi mănăstiri din România
   Palette taken from the painted churches: the ultramarine of Voroneț, the ochre and
   gold of the interiors, the limestone of the ruins. Both themes are defined here in
   full; nothing below re-declares a colour outside a token block. */

:root {
  --paper:        #f2ede2;
  --surface:      #fbf8f1;
  --surface-deep: #e9e2d3;
  --rule:         #cec4ae;
  --rule-strong:  #a99c80;

  --text:         #1a1814;
  --text-soft:    #474036;
  --text-muted:   #4d4539;

  --blue:         #1c4a78;
  --blue-soft:    #2d6396;
  --gold:         #663f04;
  --gold-bright:  #b8801f;
  --rust:         #792e1b;
  --slate:        #3a4a59;
  --moss:         #4b6244;

  --live:         #a8690f;
  --stand:        #7d7362;
  --gone:         #5b6c7e;
  --lost:         #8a4a5e;

  /* Label text sits on a 22% wash of its own colour, so it carries its own
     value to clear 7:1 at pill size. */
  --ink-live:     #5d3900;
  --ink-again:    #30422b;
  --ink-listed:   #474036;
  --ink-lost:     #61303f;
  --ink-gone:     #344251;

  --map-land:     #e5dcc9;
  --map-line:     #c3b79c;
  --map-sea:      #ecebe4;

  --shadow:       0 1px 2px rgba(26, 24, 20, .07), 0 8px 28px rgba(26, 24, 20, .07);
  --focus:        #1c4a78;

  --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:        #111318;
    --surface:      #1a1d24;
    --surface-deep: #23262f;
    --rule:         #343945;
    --rule-strong:  #4d5463;

    --text:         #f1ede4;
    --text-soft:    #cdc6b8;
    --text-muted:   #bbb4a4;

    --blue:         #86b7e2;
    --blue-soft:    #9cc6ea;
    --gold:         #e0ae4e;
    --gold-bright:  #f0c470;
    --rust:         #e8a189;
    --slate:        #9fb4c8;
    --moss:         #9dbd90;

    --live:         #eab24f;
    --stand:        #a49a86;
    --gone:         #7d93a9;
    --lost:         #c68ba0;

    --ink-live:     #f0d399;
    --ink-again:    #c5dabc;
    --ink-listed:   #d0c9bc;
    --ink-lost:     #e2c1cd;
    --ink-gone:     #bbcada;

    --map-land:     #1f242d;
    --map-line:     #394252;
    --map-sea:      #15181e;

    --shadow:       0 1px 2px rgba(0, 0, 0, .4), 0 10px 34px rgba(0, 0, 0, .34);
    --focus:        #9cc6ea;
  }
}

:root[data-theme="dark"] {
  --paper:        #111318;
  --surface:      #1a1d24;
  --surface-deep: #23262f;
  --rule:         #343945;
  --rule-strong:  #4d5463;

  --text:         #f1ede4;
  --text-soft:    #cdc6b8;
  --text-muted:   #bbb4a4;

  --blue:         #86b7e2;
  --blue-soft:    #9cc6ea;
  --gold:         #e0ae4e;
  --gold-bright:  #f0c470;
  --rust:         #e8a189;
  --slate:        #9fb4c8;
  --moss:         #9dbd90;

  --live:         #eab24f;
  --stand:        #a49a86;
  --gone:         #7d93a9;
  --lost:         #c68ba0;

  --ink-live:     #f0d399;
  --ink-again:    #c5dabc;
  --ink-listed:   #d0c9bc;
  --ink-lost:     #e2c1cd;
  --ink-gone:     #bbcada;

  --map-land:     #1f242d;
  --map-line:     #394252;
  --map-sea:      #15181e;

  --shadow:       0 1px 2px rgba(0, 0, 0, .4), 0 10px 34px rgba(0, 0, 0, .34);
  --focus:        #9cc6ea;
}

* { 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;
}

h1, h2, h3, .kicker, .ui { font-family: var(--sans); }

a { color: var(--blue); text-underline-offset: .18em; text-decoration-thickness: .06em; }
a:hover { color: var(--rust); }

:where(a, button, [tabindex], summary, input):focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
  border-radius: 3px;
}

/* ---------- shell ---------- */

.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); }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: .75rem;
  padding: .5rem var(--gutter);
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--rule);
  font-family: var(--sans); font-size: .8125rem;
}
.topbar .home { font-weight: 600; letter-spacing: .01em; text-decoration: none; color: var(--text-soft); }
.topbar .spacer { flex: 1; }
.chip {
  display: inline-flex; align-items: center; gap: .35rem;
  padding: .3rem .6rem; border: 1px solid var(--rule-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-soft);
  font: inherit; cursor: pointer; text-decoration: none;
}
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip[aria-current="true"] { background: var(--text); color: var(--paper); border-color: var(--text); }

/* On a narrow screen the theme control keeps its icon and its accessible name,
   and gives up the visible label so the bar fits on one line. */
@media (max-width: 27rem) {
  .topbar { gap: .4rem; padding-inline: .75rem; }
  #themelabel { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  #theme { padding: .3rem .5rem; }
}

/* ---------- opening ---------- */

.hero { padding: clamp(2.5rem, 7vw, 5rem) 0 1.5rem; }
.kicker {
  font-size: .75rem; letter-spacing: .14em; text-transform: uppercase;
  color: var(--rust); font-weight: 600; margin: 0 0 1.1rem;
}
h1 {
  font-family: var(--serif);
  font-size: clamp(2.1rem, 6.4vw, 3.65rem);
  line-height: 1.06; letter-spacing: -.018em;
  margin: 0 0 1.15rem; font-weight: 600; text-wrap: balance;
}
.deck {
  font-size: clamp(1.1rem, 2.4vw, 1.3rem);
  line-height: 1.5; color: var(--text-soft); margin: 0 0 1.6rem; text-wrap: pretty;
}
.byline {
  font-family: var(--sans); font-size: .8125rem; color: var(--text-muted);
  border-top: 1px solid var(--rule); padding-top: .9rem;
}

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

section { padding: clamp(2rem, 5vw, 3.25rem) 0; }
h2 {
  font-size: clamp(1.45rem, 3.4vw, 2rem); line-height: 1.16; letter-spacing: -.012em;
  margin: 0 0 .35rem; font-weight: 650; font-family: var(--serif); text-wrap: balance;
}
h3 { font-size: 1.075rem; margin: 2rem 0 .4rem; font-weight: 650; letter-spacing: .005em; }

/* Every section carries an id so it can be linked to; the fragment clears the
   sticky bar. No mark is printed beside the heading. */
[id] { scroll-margin-top: 4.5rem; }

/* Reading rail: where the page is, and a way to jump. It needs room beside the text
   column, so it appears only once there is some. */
.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 {
  display: flex; flex-direction: row-reverse; align-items: center; gap: .55rem;
  text-decoration: none; padding: .15rem 0;
}
.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(--rust); transform: scale(1.45); }
.rail-label {
  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; max-width: 14rem;
  overflow: hidden; text-overflow: ellipsis; 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; } }
.standfirst { color: var(--text-muted); font-family: var(--sans); font-size: .9rem; margin: 0 0 1.5rem; }
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(--rust); font-weight: 600;
}
strong { font-weight: 650; }
.num { font-variant-numeric: tabular-nums; }

blockquote {
  margin: 1.8rem 0; padding: .2rem 0 .2rem 1.15rem;
  border-left: 3px solid var(--gold); color: var(--text-soft); font-style: italic;
}

.note {
  background: var(--surface); border: 1px solid var(--rule); border-left: 3px solid var(--slate);
  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: .78rem; letter-spacing: .1em; text-transform: uppercase; color: var(--slate); }
.note p:last-child { margin-bottom: 0; }

/* ---------- figures ---------- */

figure { margin: 2rem 0; }
figure img {
  display: block; width: auto; max-width: 100%; height: auto; max-height: 78vh;
  margin-inline: auto; border-radius: 4px;
  background: var(--surface-deep); box-shadow: var(--shadow);
}
figcaption {
  font-family: var(--sans); font-size: .8125rem; line-height: 1.5;
  color: var(--text-muted); margin-top: .6rem;
}
figcaption b { color: var(--text-soft); font-weight: 600; }
figcaption .credit { display: block; margin-top: .25rem; font-size: .75rem; }
figcaption a { color: var(--text-muted); }

/* ---------- the three on the Mureș ---------- */

.triad { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; margin: 2rem 0; }
@media (min-width: 46rem) { .triad { grid-template-columns: repeat(3, 1fr); } }
.triad article { background: var(--surface); padding: 1.15rem 1.1rem; }
.triad .yr { font-family: var(--sans); font-size: 1.9rem; font-weight: 650; line-height: 1; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.triad .nm { font-weight: 650; margin: .45rem 0 .1rem; }
.triad .pl { font-family: var(--sans); font-size: .78rem; color: var(--text-muted); }
.triad .fate { margin: .7rem 0 0; font-size: .9375rem; color: var(--text-soft); }
.triad .tag {
  display: inline-block; margin-top: .7rem; padding: .16rem .5rem; border-radius: 999px;
  font-family: var(--sans); font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 650;
}
.tag-live { background: color-mix(in srgb, var(--live) 22%, transparent); color: var(--ink-live); }
.tag-gone { background: color-mix(in srgb, var(--gone) 22%, transparent); color: var(--ink-gone); }

/* ---------- map ---------- */

.atlas { background: var(--surface); border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule); padding: clamp(1.75rem, 4vw, 3rem) 0; }
.atlas-head { max-width: var(--measure); margin: 0 0 1.4rem; }

.stage { position: relative; }
.mapbox {
  position: relative; background: var(--map-sea);
  border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
}
.mapbox svg { display: block; width: 100%; height: auto; }
/* On a wide screen the country would grow taller than the window and push the
   controls out of sight; cap it and let the outline letterbox inside. */
@media (min-width: 46rem) { .mapbox svg { max-height: 66vh; } }
.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: .55; opacity: .75; }

.dot { transition: opacity .45s ease, r .45s ease; cursor: pointer; }
.dot:focus-visible { outline: none; }
.dot-live   { fill: var(--live); }
.dot-listed { fill: var(--stand); }
.dot-lost   { fill: var(--lost); }
.dot-gone   { fill: var(--gone); }
.dot-again  { fill: var(--moss); }
.dot-hollow { fill: none; stroke-width: 1.6; }
.dot-hollow.dot-live   { stroke: var(--live); }
.dot-hollow.dot-listed { stroke: var(--stand); }
.dot-hollow.dot-lost   { stroke: var(--lost); }
.dot-hollow.dot-gone   { stroke: var(--gone); }
.dot-hollow.dot-again  { stroke: var(--moss); }
.halo { fill: none; stroke: var(--gold-bright); stroke-width: 2; opacity: 0; }
.label { font-family: var(--sans); font-size: 13px; fill: var(--text); paint-order: stroke; stroke: var(--map-sea); stroke-width: 4px; stroke-linejoin: round; font-weight: 600; }
.leader { stroke: var(--rule-strong); stroke-width: 1; fill: none; }

.yearplate {
  position: absolute; left: 1rem; top: .85rem; pointer-events: none;
  font-family: var(--sans); font-variant-numeric: tabular-nums;
}
.yearplate .y { font-size: clamp(2rem, 5.5vw, 3.1rem); font-weight: 700; line-height: 1; letter-spacing: -.03em; color: var(--text); }
.yearplate .c { font-size: .8125rem; color: var(--text-muted); margin-top: .2rem; }

.era {
  position: absolute; right: 1rem; top: .9rem; max-width: 15rem; text-align: right;
  font-family: var(--sans); font-size: .8125rem; line-height: 1.45; color: var(--text-soft);
  pointer-events: none; opacity: 0; transition: opacity .5s ease;
}
.era.on { opacity: 1; }
.era b { display: block; color: var(--rust); font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; }

/* controls */
.controls {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  margin-top: .9rem; font-family: var(--sans); font-size: .8125rem;
}
.play {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .55rem 1.05rem; border: 0; border-radius: 999px;
  background: var(--text); color: var(--paper); font: inherit; font-weight: 650; cursor: pointer;
}
.play:hover { background: var(--blue); }
.play svg { width: .9em; height: .9em; fill: currentColor; }
.scrub { flex: 1 1 14rem; min-width: 10rem; accent-color: var(--gold-bright); cursor: pointer; }
.controls .reading { color: var(--text-muted); font-variant-numeric: tabular-nums; }

.legend { display: flex; flex-wrap: wrap; gap: .3rem .95rem; margin-top: .9rem; font-family: var(--sans); font-size: .78rem; color: var(--text-soft); }
.legend button {
  display: inline-flex; align-items: center; gap: .4rem; padding: .2rem .1rem;
  background: none; border: 0; font: inherit; color: inherit; cursor: pointer; border-bottom: 1.5px solid transparent;
}
.legend button[aria-pressed="false"] { opacity: .42; }
.legend button:hover { border-bottom-color: currentColor; }
.legend i { width: .62rem; height: .62rem; border-radius: 50%; display: inline-block; }
.sw-live { background: var(--live); } .sw-listed { background: var(--stand); }
.sw-lost { background: var(--lost); } .sw-gone { background: var(--gone); }
.sw-again { background: var(--moss); }

/* card */
.card {
  position: absolute; z-index: 20; width: min(19rem, calc(100vw - 3rem));
  background: var(--surface); border: 1px solid var(--rule-strong); border-radius: 7px;
  box-shadow: var(--shadow); padding: .85rem .95rem; font-family: var(--sans); font-size: .8125rem;
  color: var(--text-soft); line-height: 1.5;
}
.card[hidden] { display: none !important; }
.card h4 { margin: 0 0 .1rem; font-size: .95rem; color: var(--text); font-weight: 650; line-height: 1.25; }
.card .where { color: var(--text-muted); font-size: .78rem; }
.card dl { display: grid; grid-template-columns: auto 1fr; gap: .18rem .6rem; margin: .65rem 0 0; }
.card dt { color: var(--text-muted); font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.card dd { margin: 0; font-variant-numeric: tabular-nums; }
.card .caveat { margin: .6rem 0 0; padding-top: .55rem; border-top: 1px solid var(--rule); font-size: .76rem; color: var(--text-muted); }
.card .close { position: absolute; top: .45rem; right: .5rem; background: none; border: 0; color: var(--text-muted); font-size: 1.1rem; line-height: 1; cursor: pointer; padding: .15rem .3rem; }

.status-msg { padding: 2.5rem 1rem; text-align: center; color: var(--text-muted); font-family: var(--sans); font-size: .875rem; }

/* A phone gives the map the full width of the screen, and marks large enough to
   tell apart and to hit with a thumb. */
@media (max-width: 46rem) {
  .atlas .wide { padding-inline: 0; }
  .atlas-head { padding-inline: var(--gutter); }
  .mapbox { border-radius: 0; border-inline: 0; }
  .controls, .legend { padding-inline: var(--gutter); }
  .dot { r: 6px; }
  .dot[r="6"] { r: 9px; }
  .dot-hollow { stroke-width: 2.2; }
  .scrub { height: 26px; }
  .yearplate { left: .7rem; }
}

/* ---------- table ---------- */

.tablewrap { overflow-x: auto; overscroll-behavior-x: contain; max-width: 100%; margin: 1.5rem 0; border: 1px solid var(--rule); border-radius: 6px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; min-width: 34rem; font-family: var(--sans); font-size: .8125rem; }
caption { text-align: left; padding: .85rem 1rem; color: var(--text-muted); font-size: .8125rem; border-bottom: 1px solid var(--rule); }
th, td { padding: .5rem .75rem; text-align: left; border-bottom: 1px solid var(--rule); vertical-align: top; }
thead th { position: sticky; top: 0; background: var(--surface-deep); color: var(--text-soft); font-size: .72rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 650; }
tbody tr:last-child td { border-bottom: 0; }
td.yr { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--text); font-weight: 600; }
td.fate { white-space: nowrap; }
.dim { color: var(--text-muted); }
.pill { display: inline-block; padding: .1rem .45rem; border-radius: 999px; font-size: .7rem; font-weight: 650; letter-spacing: .03em; }
.pill-live   { background: color-mix(in srgb, var(--live) 22%, transparent); color: var(--ink-live); }
.pill-listed { background: color-mix(in srgb, var(--stand) 22%, transparent); color: var(--ink-listed); }
.pill-lost   { background: color-mix(in srgb, var(--lost) 22%, transparent); color: var(--ink-lost); }
.pill-gone   { background: color-mix(in srgb, var(--gone) 22%, transparent); color: var(--ink-gone); }
.pill-again  { background: color-mix(in srgb, var(--moss) 22%, transparent); color: var(--ink-again); }

/* ---------- counts ---------- */

.counts { display: grid; gap: 1px; background: var(--rule); border: 1px solid var(--rule); border-radius: 6px; overflow: hidden; margin: 1.8rem 0; }
@media (min-width: 40rem) { .counts { grid-template-columns: repeat(3, 1fr); } }
.counts div { background: var(--surface); padding: 1rem 1.1rem; }
.counts .n { font-family: var(--sans); font-size: 2rem; font-weight: 700; line-height: 1; letter-spacing: -.025em; font-variant-numeric: tabular-nums; color: var(--text); }
.counts .k { font-family: var(--sans); font-size: .82rem; color: var(--text-muted); margin-top: .35rem; line-height: 1.4; }

/* ---------- footer ---------- */

footer { border-top: 1px solid var(--rule); padding: 2.25rem 0 3rem; font-family: var(--sans); font-size: .8125rem; color: var(--text-muted); }
footer h3 { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; color: var(--text-soft); margin: 0 0 .6rem; }
footer ul { margin: 0 0 1.4rem; padding-left: 1.1rem; }
footer li { margin-bottom: .4rem; line-height: 1.5; }
footer .foot-nav { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; padding-top: 1.2rem; border-top: 1px solid var(--rule); }
.totop {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-width: 44px; min-height: 44px; padding: 0 .85rem;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-soft); text-decoration: none;
}
.totop::before { content: "\2191"; }
.totop:hover { border-color: var(--blue); color: var(--blue); }
/* The progressive control appears once the reader is well past the opening and sits
   clear of the home indicator on a phone. */
.totop.is-float {
  position: fixed; z-index: 60;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-width: 44px; min-height: 44px; padding: 0 .9rem;
  border: 1px solid var(--rule-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-soft); text-decoration: none;
  font-family: var(--sans); font-size: .8125rem; box-shadow: var(--shadow);
  --lift: 0px;
  opacity: 0; transform: translateY(.4rem);
  transition: opacity .18s ease, transform .18s ease;
}
.totop.is-float.on { opacity: 1; transform: translateY(calc(-1 * var(--lift))); }
.totop.is-float::before { content: "\2191"; }
.totop.is-float:hover { border-color: var(--blue); color: var(--blue); }
@media (prefers-reduced-motion: reduce) { .totop.is-float { transition: none; } }
@media print { .totop, .topbar, .controls, .legend { display: none !important; } }

@media (prefers-reduced-motion: reduce) {
  .dot, .era, * { transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
