/* Cum se nasc românii — o mie de puncte pe axa vârstei.
   Pânza rămâne întunecată în ambele teme (contrast maxim pentru puncte); restul paginii urmează tema. */

:root {
  color-scheme: light;
  --bg: #faf7f2;
  --bg-raised: #ffffff;
  --bg-sunken: #f0ebe2;
  --fg: #201b16;
  --fg-soft: #55493d;
  --fg-faint: #4a4038;
  --line: rgba(32, 27, 22, 0.14);
  --line-strong: rgba(32, 27, 22, 0.34);
  --shadow: rgba(30, 20, 10, 0.16);

  --canvas: #16110d;
  --canvas-ink: #f5efe6;
  --canvas-soft: #b7a99a;
  --canvas-line: rgba(245, 239, 230, 0.16);

  /* progresie perceptuală pe vârsta mamei: tânără (cald, deschis) -> matură (rece, adânc) */
  --a-sub15: #ffd9a0;
  --a-15-19: #ffb15c;
  --a-20-24: #ff8a5c;
  --a-25-29: #f16a63;
  --a-30-34: #d9548a;
  --a-35-39: #a558a8;
  --a-40-44: #6f5bb0;
  --a-45-49: #4a5bab;
  --a-50p: #33499a;

  /* rang: patru culori distincte, nu o gradație */
  --r-1: #e8b74e;
  --r-2: #4fb0a5;
  --r-3: #9b7ae8;
  --r-4p: #e0596d;

  --urban: #c9822f;
  --rural: #5f9e5a;

  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, monospace;

  --container: 720px;
  --wide: 1180px;
  --radius: 12px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #171310;
    --bg-raised: #1e1a16;
    --bg-sunken: #100d0b;
    --fg: #f3ede4;
    --fg-soft: #c9bdb0;
    --fg-faint: #b3a89b;
    --line: rgba(243, 237, 228, 0.15);
    --line-strong: rgba(243, 237, 228, 0.32);
    --shadow: rgba(0, 0, 0, 0.55);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171310;
  --bg-raised: #1e1a16;
  --bg-sunken: #100d0b;
  --fg: #f3ede4;
  --fg-soft: #c9bdb0;
  --fg-faint: #b3a89b;
  --line: rgba(243, 237, 228, 0.15);
  --line-strong: rgba(243, 237, 228, 0.32);
  --shadow: rgba(0, 0, 0, 0.55);
}

* { 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(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 400; line-height: 1.12; letter-spacing: -0.012em; margin: 0 0 .5em; }
h1 { font-size: clamp(2.4rem, 7.6vw, 4.6rem); }
h2 { font-size: clamp(1.7rem, 4vw, 2.5rem); margin-top: 0; }
h3 { font-size: 1.22rem; letter-spacing: 0; margin-bottom: .35em; }
p { margin: 0 0 1.1em; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; text-decoration-color: var(--line-strong); }
a:hover { text-decoration-color: currentColor; }
b, strong { font-weight: 600; }
:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; border-radius: 4px; }

.wrap { width: min(100% - 2.4rem, var(--container)); margin-inline: auto; }
.wrap-wide { width: min(100% - 2.4rem, var(--wide)); margin-inline: auto; }
.kicker { font-family: var(--sans); font-size: .76rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; color: var(--fg-faint); margin-bottom: .8em; }
.num { font-variant-numeric: tabular-nums; }
.small { font-size: .92rem; color: var(--fg-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

/* ---------- bara de sus ---------- */
.topbar { position: relative; z-index: 5; display: flex; align-items: center; gap: 1rem; padding: 1rem 0; }
.topbar .brand { font-family: var(--serif); font-size: 1rem; text-decoration: none; color: var(--canvas-soft); }
.topbar .spacer { flex: 1; }
.lang { display: flex; gap: .35rem; }
.lang a, .theme-toggle {
  font: 600 .74rem/1 var(--sans); letter-spacing: .08em;
  padding: .48rem .62rem; border-radius: 999px;
  border: 1px solid var(--canvas-line); color: var(--canvas-soft);
  background: transparent; text-decoration: none; cursor: pointer;
}
.lang a[aria-current="page"] { background: rgba(245,239,230,.12); color: var(--canvas-ink); }
.lang a:hover, .theme-toggle:hover { color: var(--canvas-ink); border-color: var(--canvas-soft); }

/* ---------- eroul ---------- */
.hero { position: relative; background: var(--canvas); color: var(--canvas-ink); padding-bottom: 3.5rem; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0; z-index: 1; pointer-events: none;
  background: radial-gradient(130% 95% at 6% 42%, rgba(22,17,13,.95) 0%, rgba(22,17,13,.86) 34%, rgba(22,17,13,.4) 72%, rgba(22,17,13,0) 100%);
}
.hero::after {
  content: ""; position: absolute; z-index: 1; inset: auto 0 0 0; height: 120px;
  background: linear-gradient(to bottom, transparent, var(--canvas)); pointer-events: none;
}
#hero-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.hero .inner { position: relative; z-index: 2; padding: 1.5rem 0 0; }
.hero h1 { color: var(--canvas-ink); margin-bottom: .28em; text-wrap: balance; }
.hero .kicker { color: var(--a-25-29); }
.hero .deck {
  font-size: clamp(1.06rem, 2.3vw, 1.3rem); line-height: 1.5;
  color: var(--canvas-ink); max-width: 34em; margin-bottom: 1.6rem;
  text-shadow: 0 1px 24px rgba(22,17,13,.9);
}
.hero .deck b { color: #fff; }
.hero .byline { font-size: .82rem; color: var(--canvas-soft); margin: 0; }
.hero .scroll-hint { margin-top: 2.6rem; font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; color: var(--canvas-soft); }

/* ---------- scrollytelling ---------- */
.scrolly { position: relative; background: var(--canvas); color: var(--canvas-ink); }
.scrolly .stage { position: sticky; top: 0; height: 100svh; display: flex; flex-direction: column; }
.stage-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .5rem 1.2rem; padding: 1rem 0 .3rem; min-height: 3.4rem; }
.stage-title { font-family: var(--serif); font-size: 1.15rem; margin: 0; color: var(--canvas-ink); }
.stage-sub { font-size: .82rem; color: var(--canvas-soft); margin: 0; }
#stage-canvas { flex: 1; width: 100%; min-height: 0; display: block; touch-action: pan-y; }

.steps { position: relative; z-index: 2; pointer-events: none; }
.step { min-height: 92svh; display: flex; align-items: center; padding: 3rem 0; }
.step > div {
  pointer-events: auto; background: rgba(16, 13, 10, .9); border: 1px solid var(--canvas-line);
  border-radius: var(--radius); padding: 1.3rem 1.4rem; max-width: 30rem;
  backdrop-filter: blur(8px); box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
.step p:last-child { margin-bottom: 0; }
.step .lead { font-family: var(--serif); font-size: 1.3rem; line-height: 1.35; }
.step b { color: #fff; }
.step .tag { font: 600 .7rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--canvas-soft); display: block; margin-bottom: .7rem; }
@media (min-width: 900px) {
  .step { justify-content: flex-start; }
  .steps { width: min(100% - 3rem, var(--wide)); margin-inline: auto; }
}
@media (min-width: 1000px) {
  .stage-head { padding-left: 504px; }
}

/* consola de an (reglaj Act II) */
.year-console { pointer-events: auto; display: flex; align-items: center; gap: .7rem; padding: .2rem 0 1rem; flex-wrap: wrap; }
.year-console input[type="range"] { flex: 1; accent-color: var(--a-25-29); min-width: 8rem; }
.year-console output { font: 600 .84rem var(--mono); color: var(--canvas-ink); min-width: 3.4rem; text-align: right; }
.year-console button {
  border: 1px solid var(--canvas-line); background: none; color: var(--canvas-ink);
  width: 2.1rem; height: 2.1rem; border-radius: 999px; cursor: pointer; flex: none; font-size: .8rem;
}
.year-console button:hover { border-color: var(--canvas-soft); }
.year-console .badge { font: 600 .68rem/1 var(--sans); letter-spacing: .07em; text-transform: uppercase; color: var(--canvas-soft); border: 1px solid var(--canvas-line); border-radius: 999px; padding: .3rem .55rem; }
.year-console .badge.provisional { color: var(--a-20-24); border-color: var(--a-20-24); }
/* inset-ul de 504px se aplică doar consolei din interiorul pânzei (Act II), nu și celei
   independente de la Act VI (județ), care își setează propriul padding-left:0 inline */
@media (min-width: 1000px) {
  .scrolly .year-console { padding-left: 504px; }
}

/* comutatoarele ascunse până când IntersectionObserver activează pasul lor;
   !important e deliberat — clasa utilitară trebuie să câștige indiferent de ordinea
   celorlalte reguli cu o singură clasă (ex. .seg { display: inline-flex } e definită mai jos) */
.is-hidden { display: none !important; }

/* ---------- proza ---------- */
.prose { padding: 4.5rem 0; }
.prose h2 + .lede { font-size: 1.18rem; color: var(--fg-soft); }
.prose .figure-note { font-size: .88rem; color: var(--fg-faint); border-left: 2px solid var(--line); padding-left: .9rem; }

/* ---------- casete ---------- */
.callout { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem 1.3rem; margin: 2rem 0; }
.callout h3 { margin-top: 0; }
.callout p:last-child { margin-bottom: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 1rem; margin: 2rem 0; }
.stat { border-top: 3px solid var(--sw, var(--line-strong)); padding-top: .6rem; }
.stat b { display: block; white-space: nowrap; font-family: var(--serif); font-size: 1.9rem; line-height: 1; font-variant-numeric: tabular-nums; }
.stat span { font-size: .84rem; color: var(--fg-soft); display: block; margin-top: .3rem; }

table { width: 100%; border-collapse: collapse; font-size: .9rem; margin: 1.4rem 0; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); }
th { font-size: .76rem; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-faint); font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
.table-scroll { overflow-x: auto; }

.method { background: var(--bg-sunken); }
.sources ol { padding-left: 1.2rem; font-size: .92rem; color: var(--fg-soft); }
.sources li { margin-bottom: .55rem; }

footer.wrap { padding: 2.5rem 0 3.5rem; border-top: 1px solid var(--line); font-size: .9rem; color: var(--fg-soft); }
footer .back-home { display: inline-block; margin-bottom: .5rem; text-decoration: none; }

/* tooltip pânză */
.tip {
  position: fixed; z-index: 40; pointer-events: none; opacity: 0; transform: translate(-50%, -118%);
  background: #1c1712; color: #f5efe6; border: 1px solid rgba(245,239,230,.2);
  border-radius: 9px; padding: .5rem .65rem; font-size: .8rem; line-height: 1.35;
  max-width: 15rem; box-shadow: 0 12px 34px rgba(0,0,0,.5); transition: opacity .12s;
}
.tip.on { opacity: 1; }
.tip b { display: flex; align-items: center; gap: .4rem; font-size: .86rem; color: #f5efe6; }
.tip b .sw { width: 9px; height: 9px; border-radius: 3px; flex: none; }
.tip .m { font-variant-numeric: tabular-nums; color: #b7a99a; }

.noscript { background: var(--bg-raised); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.5rem auto; width: min(100% - 2.4rem, var(--container)); }

@media (prefers-reduced-motion: reduce) { * { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
@media (max-width: 899px) {
  .scrolly .stage { height: 58svh; }
  .step { min-height: 100svh; align-items: flex-end; padding: 1rem 0 1.6rem; }
  .step > div { padding: 1rem 1.1rem; font-size: .95rem; line-height: 1.55; }
  .step .lead { font-size: 1.14rem; }
  .step .tag { margin-bottom: .5rem; }
  .legend { font-size: .73rem; gap: .25rem .7rem; padding: .4rem 0 .7rem; }
}
@media (max-width: 700px) {
  body { font-size: 16px; }
  .step > div { max-width: none; }
  .stage-head { padding-top: .7rem; }
}

/* comutator de unitate (rang / vârstă etc.) */
.seg { display: inline-flex; gap: .25rem; border: 1px solid var(--line); border-radius: 999px; padding: .2rem; margin-bottom: .3rem; flex-wrap: wrap; }
.seg button { font: 500 .85rem/1 var(--sans); color: var(--fg-soft); background: none; border: 0; border-radius: 999px; padding: .45rem .8rem; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--fg); color: var(--bg); font-weight: 600; }

/* ---------- rata de fertilitate (Act IV) ---------- */
.fert-chart { margin: 1.6rem 0; }
.fert-chart svg { width: 100%; height: auto; display: block; }
.fert-key { display: flex; flex-wrap: wrap; gap: .3rem 1.2rem; font-size: .82rem; color: var(--fg-soft); align-items: center; margin-top: .4rem; }
.fert-key span { display: inline-flex; align-items: center; gap: .35rem; }
.fert-key i { width: 11px; height: 11px; border-radius: 50%; }

/* ---------- urban/rural (Act V) ---------- */
.ur-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr)); gap: 1rem; margin: 1.6rem 0; }
.ur-card { border: 1px solid var(--line); border-top: 3px solid var(--sw, var(--line-strong)); border-radius: var(--radius); padding: 1rem 1.1rem; background: var(--bg-raised); }
.ur-card .lbl { font: 600 .74rem/1 var(--sans); letter-spacing: .1em; text-transform: uppercase; margin-bottom: .5rem; display: block; color: var(--fg); }
.ur-card.urban { --sw: var(--urban); }
.ur-card.rural { --sw: var(--rural); }
.ur-card .v { font-family: var(--serif); font-size: 1.8rem; }
.ur-card .v2 { font-size: .88rem; color: var(--fg-soft); margin-top: .2rem; }

/* ---------- selector de județ (Act VI) ---------- */
.county-picker { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; margin: 1.2rem 0 1.6rem; }
.county-picker select {
  font: 500 .95rem/1.2 var(--sans); padding: .55rem .8rem; border-radius: 10px;
  border: 1px solid var(--line-strong); background: var(--bg-raised); color: var(--fg); min-width: 12rem;
}
.county-picker .reset { font: 500 .85rem var(--sans); color: var(--fg-soft); background: none; border: 1px solid var(--line); border-radius: 999px; padding: .4rem .8rem; cursor: pointer; }
.county-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(8rem, 1fr)); gap: .9rem; margin: 1.2rem 0; }
.county-stats .cs { border-top: 3px solid var(--line-strong); padding-top: .5rem; }
.county-stats .cs b { display: block; font-family: var(--serif); font-size: 1.5rem; }
.county-stats .cs span { font-size: .8rem; color: var(--fg-soft); }
.share-link { font: 500 .84rem var(--sans); color: var(--fg-soft); background: none; border: 1px solid var(--line); border-radius: 999px; padding: .4rem .85rem; cursor: pointer; }
.share-link:hover { border-color: var(--line-strong); color: var(--fg); }

/* ---------- matricea tată × mamă (Act VII) ---------- */
.matrix-wrap { overflow-x: auto; margin: 1.6rem 0; }
.matrix { border-collapse: collapse; font-size: .78rem; }
.matrix caption { caption-side: top; text-align: left; font-size: .82rem; color: var(--fg-faint); margin-bottom: .5rem; }
.matrix th, .matrix td { padding: .35rem .5rem; text-align: center; white-space: nowrap; }
.matrix thead th { font: 600 .68rem/1 var(--sans); letter-spacing: .04em; color: var(--fg-faint); border-bottom: 1px solid var(--line); }
.matrix tbody th { text-align: right; font: 600 .7rem/1 var(--sans); color: var(--fg-faint); padding-right: .7rem; }
.matrix td { font-variant-numeric: tabular-nums; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.matrix td.faint { color: var(--fg); text-shadow: none; }
.matrix td.unknown { color: var(--fg-faint); text-shadow: none; background: var(--bg-sunken) !important; }
