/* Mămăliga din porumbul american — harvest-warm identity on semantic tokens.
   Fraunces + Source Serif 4 (SIL OFL 1.1), served locally. No inline colours
   in HTML; every surface below uses a variable. */

@font-face {
  font-family: "Fraunces";
  src: url("../fonts/fraunces-normal-latin-ext.woff2") format("woff2");
  font-weight: 400 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-normal-latin-ext.woff2") format("woff2");
  font-weight: 400 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "Source Serif 4";
  src: url("../fonts/source-serif-4-italic-latin-ext.woff2") format("woff2");
  font-weight: 400; font-style: italic; font-display: swap;
}

:root {
  --bg: #faf4e6;
  --bg-surface: #fffdf4;
  --bg-soft: #f3e8cf;
  --text-primary: #2c2010;
  --text-secondary: #5d4c34;
  --line: #d9c69c;
  --accent: #8a5a00;
  --accent-ink: #6e4700;
  --field: #3d6b35;
  --hearth: #a03d12;
  --card-shadow: 0 1px 0 rgba(44, 32, 16, 0.12), 0 8px 24px rgba(44, 32, 16, 0.10);
  --topbar-h: 3rem;
  --radius: 0.9rem;
  --focus: #1a5fb4;
}
[data-theme="dark"] {
  --bg: #1c1409;
  --bg-surface: #26200f;
  --bg-soft: #2e2513;
  --text-primary: #f6ecd4;
  --text-secondary: #d3c39c;
  --line: #57482c;
  --accent: #f0b429;
  --accent-ink: #ffd97a;
  --field: #8fce7e;
  --hearth: #ff9c6b;
  --card-shadow: 0 1px 0 rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  --focus: #9cc4ff;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text-primary);
  font-family: "Source Serif 4", Georgia, serif;
  font-size: 1.075rem;
  line-height: 1.65;
}
main { display: block; }
.wrap { max-width: 44rem; margin: 0 auto; padding: 0 1.1rem; }
.wrap-wide { max-width: 64rem; margin: 0 auto; padding: 0 1.1rem; }

/* Sticky bar: one line, house pattern. */
.topbar {
  position: sticky; top: 0; z-index: 20;
  min-height: var(--topbar-h);
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0 0.9rem;
  padding-top: env(safe-area-inset-top);
  background: var(--bg-surface);
  border-bottom: 2px solid var(--line);
}
.topbar .home {
  font-family: "Fraunces", Georgia, serif; font-weight: 700;
  color: var(--text-primary); text-decoration: none; white-space: nowrap;
}
.topnav { display: flex; gap: 0.9rem; overflow-x: auto; scrollbar-width: none; white-space: nowrap; }
.topnav::-webkit-scrollbar { display: none; }
.topnav a { color: var(--text-secondary); text-decoration: none; padding: 0.35rem 0; }
.topnav a[aria-current="true"] { color: var(--text-primary); text-decoration: underline; text-underline-offset: 4px; }
.spacer { flex: 1 1 auto; }
.chip {
  border: 1px solid var(--line); border-radius: 999px;
  padding: 0.28rem 0.8rem; color: var(--text-primary); text-decoration: none;
  white-space: nowrap; background: var(--bg-soft);
}
.icon-btn {
  width: 2.4rem; height: 2.4rem; border-radius: 50%;
  border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--text-primary); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn svg { display: block; }
.icon-btn svg[hidden] { display: none; }

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

section { scroll-margin-top: calc(var(--topbar-h) + 0.75rem + env(safe-area-inset-top)); }

.hero { padding: 2.2rem 0 1.2rem; }
.kicker {
  display: inline-block; font-size: 0.95rem; color: var(--text-secondary);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.2rem 0.8rem;
  margin-bottom: 1rem; background: var(--bg-surface);
}
h1, h2, h3 { font-family: "Fraunces", Georgia, serif; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(2rem, 5.5vw, 3.1rem); margin: 0 0 0.8rem; }
.deck { font-size: 1.25rem; color: var(--text-secondary); margin: 0 0 1.4rem; }
.hero-grid { display: grid; gap: 1.4rem; }
@media (min-width: 52rem) {
  .hero-grid { grid-template-columns: 1.15fr 0.85fr; align-items: start; }
}

figure { margin: 0; }
.frame {
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--card-shadow);
  padding: 0.6rem;
}
.frame img { display: block; width: 100%; height: auto; border-radius: 0.55rem; }
figcaption { font-size: 0.92rem; color: var(--text-secondary); padding: 0.55rem 0.3rem 0.2rem; }
figcaption .lic { display: block; }

.share {
  margin: 1.4rem 0 0; padding: 0.9rem 1rem;
  border: 1px dashed var(--line); border-radius: var(--radius);
  background: var(--bg-surface); scroll-margin-top: calc(var(--topbar-h) + 4.75rem);
}
.share p { margin: 0 0 0.6rem; font-size: 1rem; }
.share-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.share-row a, .share-row button {
  min-height: 3rem; display: inline-flex; align-items: center;
  padding: 0.4rem 0.9rem; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-soft);
  color: var(--text-primary); text-decoration: none; font-size: 1rem; cursor: pointer;
  font-family: inherit;
}
.share-feed[hidden] { display: none; }
input.share-feed {
  display: block; width: 100%; margin-top: 0.6rem;
  font: inherit; color: var(--text-primary);
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 0.6rem; padding: 0.6rem 0.8rem;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.share-row button[hidden] { display: none; }
.js-only[hidden] { display: none; }

.prose h2 { font-size: clamp(1.5rem, 3.6vw, 2rem); margin: 2.6rem 0 0.7rem; }
.prose h2 a { color: inherit; text-decoration: none; }
.prose h2 a:hover { text-decoration: underline; }
.prose p { margin: 0 0 1rem; }
.stat-grid { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr)); margin: 1.2rem 0; }
.stat {
  background: var(--bg-surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 0.9rem 1rem; box-shadow: var(--card-shadow);
}
.stat b { display: block; font-family: "Fraunces", Georgia, serif; font-size: 1.7rem; color: var(--accent-ink); }
.stat span { font-size: 0.95rem; color: var(--text-secondary); }

/* Regional tracks */
.tracks { list-style: none; margin: 1.2rem 0; padding: 0; display: grid; gap: 0.9rem; }
.tracks li { background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 0.8rem 1rem; }
.tracks h3 { margin: 0 0 0.4rem; font-size: 1.1rem; }
.rail { position: relative; height: 0.7rem; background: var(--bg-soft); border-radius: 999px; margin: 0.5rem 0; }
.rail i { position: absolute; top: 0; bottom: 0; border-radius: 999px; background: var(--field); }
.rail i.span-early { left: 20%; width: 35%; }
.rail i.span-late { left: 35%; width: 40%; }
.rail.uncertain i { background: repeating-linear-gradient(45deg, var(--field), var(--field) 6px, transparent 6px, transparent 12px); }
.tracks p { margin: 0.2rem 0 0; font-size: 0.98rem; color: var(--text-secondary); }

/* Bench */
.bench {
  background: var(--bg-surface); border: 2px solid var(--line);
  border-radius: 1.1rem; box-shadow: var(--card-shadow);
  padding: 1.2rem; margin: 1.4rem 0;
}
.bench fieldset { border: 0; margin: 0 0 1rem; padding: 0; }
.bench legend { font-family: "Fraunces", Georgia, serif; font-weight: 700; padding: 0; margin-bottom: 0.5rem; }
.seg { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.seg label {
  border: 1px solid var(--line); border-radius: 999px; padding: 0.45rem 1rem;
  background: var(--bg-soft); cursor: pointer; min-height: 3rem;
  display: inline-flex; align-items: center;
}
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label:has(input:checked) { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }
.seg label:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
[data-theme="dark"] .seg label:has(input:checked) { color: #1c1409; }
.bars { margin: 1rem 0; display: grid; gap: 0.7rem; }
.bar-row { display: block; font-size: 0.98rem; }
.bar-head { display: flex; justify-content: space-between; gap: 0.8rem; margin-bottom: 0.25rem; }
.bar-head span:last-child { text-align: right; color: var(--text-secondary); }
.bar-track { height: 1.1rem; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 999px; }
.bar-fill.maize { background: var(--accent); }
.bar-fill.millet { background: var(--field); }
.bench-note { font-size: 0.95rem; color: var(--text-secondary); }
.mill-steps { list-style: none; padding: 0; margin: 0.6rem 0; display: grid; gap: 0.4rem; }
.mill-steps li { padding: 0.5rem 0.8rem; border: 1px solid var(--line); border-radius: 0.6rem; background: var(--bg); }
.mill-steps li.done { border-color: var(--field); }
.stir-panel { display: grid; gap: 0.7rem; margin-top: 0.8rem; }
.big-btn {
  min-height: 3.2rem; border-radius: 0.8rem; border: 2px solid var(--accent-ink);
  background: var(--accent-ink); color: #fff; font-size: 1.05rem; font-family: inherit;
  cursor: pointer; padding: 0.6rem 1rem; touch-action: manipulation;
}
.big-btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.big-btn.ghost { background: transparent; color: var(--text-primary); }
[data-theme="dark"] .big-btn { color: #1c1409; }
[data-theme="dark"] .big-btn.ghost { color: var(--text-primary); }
.meter { height: 0.9rem; background: var(--bg-soft); border-radius: 999px; overflow: hidden; }
.meter i { display: block; height: 100%; width: 0; background: var(--hearth); }
.result { border-top: 1px solid var(--line); padding-top: 0.8rem; font-size: 1rem; }
.reset-link { background: none; border: 0; padding: 0.6rem 0; color: var(--accent-ink); text-decoration: underline; cursor: pointer; font-size: 1rem; font-family: inherit; min-height: 3rem; }

/* Method, sources, footer */
.method { background: var(--bg-surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin: 2rem 0; }
.method h2 { margin-top: 0; }
.sourcelist { margin: 0.6rem 0; padding-left: 1.2rem; }
.sourcelist li { margin-bottom: 0.45rem; }
footer { border-top: 2px solid var(--line); margin-top: 2.5rem; padding: 1.2rem 0 3rem; color: var(--text-secondary); font-size: 0.95rem; }
footer a { color: var(--accent-ink); }
.totop { display: inline-block; margin-top: 0.8rem; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 0.5rem; top: 0.5rem; background: var(--bg-surface); padding: 0.5rem 1rem; z-index: 50; }
