/* Samachar World News. Two typefaces: Newsreader for headlines, Schibsted Grotesk for everything else. */
@font-face { font-family: "Newsreader"; src: url("fonts/newsreader-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Schibsted Grotesk"; src: url("fonts/schibsted-grotesk-latin-wght-normal.woff2") format("woff2"); font-weight: 400 900; font-display: swap; }

:root {
  --panel: #f6f7f9;
  --ink: #12161c;
  --muted: #5a6472;
  --rule: #d6dbe2;
  --focus: #1f6feb;
  --ok: #1b7f4b;
  --late: #a86200;
  --stale: #b3261e;
  --serif: "Newsreader", "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans: "Schibsted Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --ledger-w: clamp(340px, 31vw, 430px);
}
@media (prefers-color-scheme: dark) {
  :root { --panel: #14181e; --ink: #e8ebef; --muted: #9ba5b2; --rule: #2b323b; --focus: #6ea1ff; --ok: #4cc08a; --late: #e0a03a; --stale: #ff7b72; }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--panel); color: var(--ink); font: 14px/1.4 var(--sans); -webkit-text-size-adjust: 100%; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.noscript { padding: 16px; }

.app { display: grid; grid-template-columns: var(--ledger-w) minmax(0, 1fr); height: 100vh; height: 100dvh; }

/* ---- Ledger (left column) ---- */
.ledger { display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow-x: hidden; border-right: 1px solid var(--rule); background: var(--panel); }
.masthead { padding: 18px 18px 6px; }
.masthead h1 { margin: 0; font: 600 32px/1 var(--serif); letter-spacing: -0.015em; }
.tagline { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.freshness { padding: 8px 18px 12px; border-bottom: 1px solid var(--rule); }
.age { margin: 0; font-weight: 650; font-size: 14px; }
.age-sub { margin: 1px 0 0; color: var(--muted); font-size: 12.5px; min-height: 1.4em; }
.ruler { position: relative; height: 5px; margin-top: 8px; background: var(--rule); border-radius: 3px; overflow: hidden; }
.ruler-fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--muted); border-radius: 3px; transition: width .4s ease; }
.freshness[data-level="ok"] .ruler-fill { background: var(--ok); }
.freshness[data-level="late"] .ruler-fill { background: var(--late); }
.freshness[data-level="stale"] .ruler-fill { background: var(--stale); }
.freshness[data-level="stale"] .age { color: var(--stale); }
.freshness[data-level="late"] .age { color: var(--late); }
.age-note { margin: 8px 0 0; font-size: 12.5px; }
.freshness[data-level="stale"] .age-note { color: var(--stale); }

.link-button { background: none; border: 0; padding: 4px 0; font: inherit; font-size: 13px; font-weight: 600; color: var(--focus); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

.filters { padding: 12px 18px 10px; border-bottom: 1px solid var(--rule); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { --c: var(--muted); display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 8px; font: 500 12.5px/1.3 var(--sans); color: var(--ink);
  background: transparent; border: 1px solid var(--rule); border-radius: 999px; cursor: pointer; }
.chip .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; }
.chip .dot.ring { background: transparent; border: 2px solid var(--ink); }
.chip .n { color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 16%, transparent); border-color: var(--c); }
.chip[aria-pressed="true"] .n { color: var(--ink); }
.chip:disabled { opacity: .45; cursor: default; }
.country-row { display: flex; align-items: center; gap: 10px; margin-top: 10px; }
.country-row label { color: var(--muted); font-size: 12.5px; }
.country-row select { flex: 1; min-width: 0; padding: 5px 8px; font: 13px var(--sans); color: var(--ink); background: transparent; border: 1px solid var(--rule); border-radius: 6px; }

.results { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.results-status { margin: 0; padding: 10px 18px 6px; color: var(--muted); font-size: 12.5px; }
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; overscroll-behavior: contain; }
.item { --c: var(--muted); display: block; width: 100%; text-align: left; padding: 11px 16px 12px 14px; font: inherit; color: inherit; background: none;
  border: 0; border-bottom: 1px solid var(--rule); border-left: 4px solid var(--c); cursor: pointer; }
.item:hover { background: color-mix(in srgb, var(--c) 7%, transparent); }
.item[aria-current="true"] { background: color-mix(in srgb, var(--c) 13%, transparent); }
.item .h { display: block; font: 500 17px/1.28 var(--serif); letter-spacing: -0.003em; overflow-wrap: anywhere; }
.item .m { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 5px; font-size: 12px; color: var(--muted); }
.item .where { color: var(--ink); font-weight: 600; }
.list-end { padding: 12px 18px 18px; color: var(--muted); font-size: 12.5px; }

.colophon { padding: 10px 18px 14px; border-top: 1px solid var(--rule); font-size: 12.5px; color: var(--muted); }
.colophon summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.colophon p { margin: 8px 0 0; }
.colophon .credit { margin-top: 8px; }
.colophon a { color: inherit; text-underline-offset: 2px; }

/* ---- Map ---- */
.stage { position: relative; min-width: 0; min-height: 0; }
#map { position: absolute; inset: 0; }
.map-notice { position: absolute; left: 12px; bottom: 28px; margin: 0; max-width: min(360px, calc(100% - 24px)); padding: 7px 10px; font-size: 12.5px;
  color: var(--ink); background: var(--panel); border: 1px solid var(--rule); border-radius: 6px; z-index: 2; }

.cluster { --cl-bg: #1b2430; --cl-fg: #fff; --cl-edge: #fff; display: grid; place-items: center; padding: 0; font: 650 13px/1 var(--sans); color: var(--cl-fg); background: var(--cl-bg);
  border: 2px solid var(--cl-edge); border-radius: 50%; cursor: pointer; box-shadow: 0 0 0 1px rgba(18, 22, 28, .35); }
.cluster:hover { filter: brightness(1.25); }
@media (prefers-color-scheme: dark) { .cluster { --cl-bg: #e8ebef; --cl-fg: #12161c; --cl-edge: #12161c; box-shadow: 0 0 0 1px rgba(232, 235, 239, .5); } }

.maplibregl-popup { max-width: min(340px, 86vw) !important; }
.maplibregl-popup-content { padding: 0; border-radius: 8px; background: var(--panel); color: var(--ink); font-family: var(--sans); max-height: 55vh; overflow-y: auto; }
.maplibregl-popup-tip { display: none; }
.maplibregl-popup-close-button { font-size: 20px; padding: 2px 9px; color: var(--muted); }
.story { --c: var(--muted); padding: 12px 34px 12px 14px; border-left: 4px solid var(--c); }
.story + .story { border-top: 1px solid var(--rule); }
.story .topic { margin: 0; font-size: 12px; color: var(--muted); }
.story h3 { margin: 3px 0 0; font: 500 17px/1.28 var(--serif); overflow-wrap: anywhere; }
.story .m { margin: 6px 0 0; font-size: 12.5px; color: var(--muted); }
.story .m b { color: var(--ink); font-weight: 600; }
.story a { display: inline-block; margin-top: 8px; font-size: 13px; font-weight: 600; color: var(--focus); text-underline-offset: 2px; }
.more-stories { margin: 0; padding: 10px 14px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--rule); }

.maplibregl-ctrl-attrib { font-size: 11px; }

/* ---- Narrow screens: map on top, ledger below ---- */
@media (max-width: 820px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: 46dvh minmax(0, 1fr); }
  .stage { order: -1; }
  .ledger { border-right: 0; border-top: 1px solid var(--rule); }
  .masthead { padding: 10px 16px 2px; display: flex; align-items: baseline; gap: 10px; }
  .masthead h1 { font-size: 24px; }
  .tagline { margin: 0; }
  .freshness, .filters { padding-left: 16px; padding-right: 16px; }
  .chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
  .chip { flex: none; }
  .results-status { padding-left: 16px; }
  .map-notice { bottom: 24px; }
}
@media (prefers-reduced-motion: reduce) { .ruler-fill { transition: none; } }
