/* Biserica de lemn este o clădire de deal — mariuscomper.uk/biserici-de-lemn/ */

:root {
  color-scheme: light;
  --bg: #f3eee2;
  --bg-surface: #fbf8f0;
  --bg-sunken: #e7dfcd;
  --text-primary: #191510;
  --text-secondary: #443c30;
  --text-muted: #4d4436;
  --line: #cfc3aa;
  --line-strong: #807252;
  --oak: #7a3f10;
  --oak-soft: #b98a55;
  --fir: #1f5540;
  --rain: #1d4f6d;
  --dot: #7a3f10;
  --dot-alt: #1d4f6d;
  --focus: #7a3f10;
  --field-lo: #efe7d5;
  --field-hi: #6d6047;
  --shadow: 0 1px 2px rgba(25, 21, 16, .09), 0 6px 20px rgba(25, 21, 16, .07);
}

:root[data-theme="dark"],
:root:not([data-theme="light"]) {
  --focus-ring: 2px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #131109;
    --bg-surface: #1d1a12;
    --bg-sunken: #0d0b06;
    --text-primary: #f6f1e4;
    --text-secondary: #d3c8b2;
    --text-muted: #bcb098;
    --line: #3a3427;
    --line-strong: #7a7053;
    --oak: #e8a862;
    --oak-soft: #a97b45;
    --fir: #6dc79c;
    --rain: #79b6dc;
    --dot: #e8a862;
    --dot-alt: #79b6dc;
    --focus: #e8a862;
    --field-lo: #221e14;
    --field-hi: #c9b98f;
    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 26px rgba(0, 0, 0, .42);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131109;
  --bg-surface: #1d1a12;
  --bg-sunken: #0d0b06;
  --text-primary: #f6f1e4;
  --text-secondary: #d3c8b2;
  --text-muted: #bcb098;
  --line: #3a3427;
  --line-strong: #7a7053;
  --oak: #e8a862;
  --oak-soft: #a97b45;
  --fir: #6dc79c;
  --rain: #79b6dc;
  --dot: #e8a862;
  --dot-alt: #79b6dc;
  --focus: #e8a862;
  --field-lo: #221e14;
  --field-hi: #c9b98f;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 8px 26px rgba(0, 0, 0, .42);
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
  font-size: 1.0625rem;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
}

.ui, button, input, select, th, .label, figcaption, .note, .legend, .tag {
  font-family: ui-sans-serif, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.wrap { width: min(100% - 2.4rem, 62rem); margin-inline: auto; }
.narrow { width: min(100% - 2.4rem, 40rem); margin-inline: auto; }

a { color: inherit; text-decoration-color: var(--line-strong); text-underline-offset: .18em; }
a:hover { text-decoration-color: var(--oak); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 3px; }

/* ---------------------------------------------------------------- masthead */
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 1rem 0 .4rem;
  border-bottom: 1px solid var(--line);
}
.masthead .kicker {
  font-size: .74rem; letter-spacing: .13em; text-transform: uppercase;
  color: var(--text-muted); font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif;
}
.tools { display: flex; gap: .4rem; align-items: center; }

button.chip, .langlink {
  background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--line-strong); border-radius: 999px;
  padding: .34rem .78rem; font-size: .8rem; cursor: pointer; line-height: 1.3;
  text-decoration: none; display: inline-block;
}
button.chip:hover, .langlink:hover { border-color: var(--oak); }
button.chip[aria-pressed="true"] { background: var(--oak); color: var(--bg-surface); border-color: var(--oak); }
:root[data-theme="dark"] button.chip[aria-pressed="true"],
:root:not([data-theme="light"]) button.chip[aria-pressed="true"] { color: #131109; }

/* ---------------------------------------------------------------- hero */
.hero { padding: 2.6rem 0 1.4rem; }
h1 {
  font-size: clamp(2.05rem, 5.6vw, 3.5rem);
  line-height: 1.08; margin: 0 0 1rem; font-weight: 600; letter-spacing: -.012em;
  max-width: 20ch;
}
.deck { font-size: clamp(1.1rem, 2.4vw, 1.33rem); line-height: 1.5; margin: 0 0 1.4rem; max-width: 46ch; color: var(--text-secondary); }
.byline { font-size: .82rem; color: var(--text-muted); margin: 0; }

.keyfigs { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin: 1.8rem 0; }
.keyfig { background: var(--bg-surface); padding: .95rem 1rem; }
.keyfig b { display: block; font-size: 1.85rem; line-height: 1.05; font-weight: 600; color: var(--oak); font-variant-numeric: tabular-nums; }
.keyfig span { display: block; font-size: .8rem; color: var(--text-secondary); margin-top: .3rem; font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif; line-height: 1.35; }

/* ---------------------------------------------------------------- sections */
section { padding: 2.4rem 0; border-top: 1px solid var(--line); }
section:first-of-type { border-top: 0; }
h2 { font-size: clamp(1.45rem, 3.2vw, 1.95rem); line-height: 1.18; margin: 0 0 .7rem; font-weight: 600; max-width: 26ch; }
h3 { font-size: 1.12rem; margin: 1.8rem 0 .5rem; font-weight: 600; }
p { margin: 0 0 1rem; max-width: 66ch; }
.lede { font-size: 1.1rem; color: var(--text-secondary); }
.note { font-size: .84rem; color: var(--text-muted); line-height: 1.5; max-width: 62ch; }

/* ---------------------------------------------------------------- map */
.mapcard { background: var(--bg-surface); border: 1px solid var(--line); box-shadow: var(--shadow); }
.maphead { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; padding: .8rem .9rem; border-bottom: 1px solid var(--line); }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.segmented button {
  background: var(--bg-surface); color: var(--text-secondary); border: 0;
  padding: .42rem .8rem; font-size: .82rem; cursor: pointer; border-right: 1px solid var(--line);
}
.segmented button:last-child { border-right: 0; }
.segmented button[aria-pressed="true"] { background: var(--bg-sunken); color: var(--text-primary); font-weight: 600; }
.mapstage { position: relative; }
canvas.map { display: block; width: 100%; height: auto; aspect-ratio: 1.392; touch-action: pan-y; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem 1.1rem; padding: .7rem .9rem; border-top: 1px solid var(--line); font-size: .78rem; color: var(--text-secondary); align-items: center; }
.swatch { display: inline-block; width: .72rem; height: .72rem; border-radius: 50%; margin-right: .34rem; vertical-align: -.06em; }
.ramp { display: inline-block; width: 5.5rem; height: .55rem; vertical-align: -.02em; margin: 0 .35rem; border: 1px solid var(--line-strong); }
.tip {
  position: absolute; pointer-events: none; z-index: 4; max-width: 17rem;
  background: var(--bg-surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow); padding: .55rem .68rem; font-size: .8rem; line-height: 1.42;
  font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif; color: var(--text-primary);
}
.tip b { display: block; font-size: .88rem; margin-bottom: .2rem; }
.tip .meta { color: var(--text-secondary); }
.tip[hidden] { display: none; }

/* ---------------------------------------------------------------- charts + tables */
figure { margin: 1.6rem 0; }
figure.chart { background: var(--bg-surface); border: 1px solid var(--line); padding: 1rem .9rem .7rem; }
svg.chart { display: block; width: 100%; height: auto; overflow: visible; }
svg text { font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif; fill: var(--text-secondary); }
figcaption { font-size: .82rem; color: var(--text-muted); margin-top: .7rem; line-height: 1.5; }

table { width: 100%; border-collapse: collapse; font-size: .87rem; font-variant-numeric: tabular-nums; }
.scroller { overflow-x: auto; margin: 1.2rem 0; border: 1px solid var(--line); background: var(--bg-surface); }
th, td { padding: .48rem .6rem; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead th { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-secondary); font-weight: 600; background: var(--bg-sunken); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
td.bar { width: 40%; padding-right: .9rem; }
.barline { display: block; height: .62rem; background: var(--oak); }
.barline.alt { background: var(--rain); }

/* ---------------------------------------------------------------- figures */
figure.photo { margin: 1.8rem 0; }
figure.photo img { display: block; width: 100%; height: auto; border: 1px solid var(--line); background: var(--bg-sunken); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pair figure { margin: 0; }
.credit { display: block; margin-top: .35rem; font-size: .74rem; color: var(--text-muted); }

/* ---------------------------------------------------------------- search */
.finder { background: var(--bg-surface); border: 1px solid var(--line); padding: 1.1rem; box-shadow: var(--shadow); }
.finder label { display: block; font-size: .82rem; color: var(--text-secondary); margin-bottom: .4rem; }
.finder input {
  width: 100%; padding: .62rem .7rem; font-size: 1rem; color: var(--text-primary);
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: 6px;
}
.suggest { list-style: none; margin: .4rem 0 0; padding: 0; max-height: 13rem; overflow-y: auto; border: 1px solid var(--line); }
.suggest:empty { border: 0; }
.suggest li { border-bottom: 1px solid var(--line); }
.suggest li:last-child { border-bottom: 0; }
.suggest button { width: 100%; text-align: left; background: var(--bg-surface); border: 0; padding: .5rem .65rem; font-size: .88rem; cursor: pointer; color: var(--text-primary); }
.suggest button:hover, .suggest button:focus-visible { background: var(--bg-sunken); }
.result { margin-top: 1rem; border-top: 1px solid var(--line); padding-top: .9rem; }
.result dl { display: grid; grid-template-columns: auto 1fr; gap: .3rem .9rem; margin: 0 0 .8rem; font-size: .9rem; }
.result dt { color: var(--text-muted); font-family: ui-sans-serif, -apple-system, "Segoe UI", sans-serif; font-size: .82rem; }
.result dd { margin: 0; font-variant-numeric: tabular-nums; }
.finder + .note { margin-top: .9rem; }

/* ---------------------------------------------------------------- misc */
.tag { display: inline-block; font-size: .72rem; padding: .12rem .45rem; border: 1px solid var(--line-strong); border-radius: 4px; color: var(--text-secondary); margin-right: .3rem; }
ul.plain { padding-left: 1.1rem; max-width: 66ch; }
ul.plain li { margin-bottom: .5rem; }
.sources { font-size: .88rem; }
.sources li { margin-bottom: .7rem; }
footer { border-top: 1px solid var(--line); padding: 1.8rem 0 3rem; font-size: .85rem; color: var(--text-muted); }
footer a { color: var(--text-secondary); }
.status { font-size: .84rem; color: var(--text-muted); padding: .8rem .9rem; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: .6rem; top: .6rem; z-index: 20; background: var(--bg-surface); padding: .5rem .8rem; border: 1px solid var(--oak); }

@media (max-width: 640px) {
  .pair { grid-template-columns: 1fr; }
  .keyfig b { font-size: 1.6rem; }
  body { font-size: 1.02rem; }
}

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