/* Atlas — a cartographic plate over a quiet basemap. Serif for names and figures, a precise sans for everything else. */
:root {
  --paper: #f6f5f1;
  --paper-2: #ecebe5;
  --ink: #16212a;
  --ink-2: #3a4650;
  --muted: #5d6871;
  --hair: rgba(22, 33, 42, .14);
  --serif: 'Newsreader', 'Iowan Old Style', Georgia, serif;
  --sans: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --plate-w: 372px;
  --gap: 16px;
  --ds-bottom: 14px; --ds-right: 14px;
}
body { font: 400 15px/1.5 var(--sans); color: var(--ink); background: #e8e9e6; overflow: hidden; }
.map { background: #dfe3e2; }

/* ---------- shared bits */
.k { display: inline-block; width: 10px; height: 10px; border-radius: 2px; flex: none; }
.k-open { background: var(--c-open); } .k-cond { background: var(--c-cond); }
.k-barrier { background: var(--c-barrier); } .k-water { background: var(--c-water); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 18px;
  border: 0; border-radius: 3px; background: var(--paper-2); color: var(--ink); font-weight: 600; font-size: 14px;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ink); color: var(--paper); }
@media (hover: hover) and (pointer: fine) { .btn:hover { background: #dedcd4; } .btn-primary:hover { background: #253442; } }
.link { padding: 0; border: 0; background: none; color: var(--ink-2); font-size: 13px; text-decoration: underline; text-decoration-color: var(--hair); text-underline-offset: 3px; transition: text-decoration-color 160ms ease, color 160ms ease; }
@media (hover: hover) and (pointer: fine) { .link:hover { color: var(--ink); text-decoration-color: currentColor; } }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- country picker */
.cp { position: relative; }
.cp-input {
  width: 100%; height: 48px; padding: 0 40px 0 14px; border: 0; border-radius: 3px; background: #fff;
  font: 500 22px/1 var(--serif); color: var(--ink); box-shadow: inset 0 0 0 1px var(--hair);
  transition: box-shadow 160ms ease;
}
.cp::after { content: ''; position: absolute; right: 16px; top: 20px; width: 7px; height: 7px; border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg); transition: transform 200ms var(--ease-out); pointer-events: none; }
.cp.is-open::after { transform: translateY(4px) rotate(225deg); }
.cp-input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
.cp-input::placeholder { color: #66717a; }
.cp-menu {
  position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 6px); max-height: min(340px, 50vh); overflow: auto; margin: 0; padding: 4px;
  list-style: none; background: #fff; border-radius: 4px; box-shadow: 0 18px 44px rgba(18, 28, 36, .2), 0 0 0 1px var(--hair);
  overscroll-behavior: contain; transform-origin: top center;
  opacity: 0; transform: translateY(-4px) scale(.98); visibility: hidden; pointer-events: none;
  transition: opacity 160ms var(--ease-out), transform 180ms var(--ease-out), visibility 0s linear 180ms;
}
.cp.is-open .cp-menu { opacity: 1; transform: none; visibility: visible; pointer-events: auto; transition: opacity 160ms var(--ease-out), transform 180ms var(--ease-out), visibility 0s; }
.cp-option { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 9px 10px; border-radius: 3px; cursor: pointer; font-size: 15px; }
.cp-option[aria-selected='true'] { background: var(--paper-2); }
@media (hover: hover) and (pointer: fine) { .cp-option:hover { background: var(--paper); } }
.cp-meta { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cp-empty { padding: 12px 10px; color: var(--muted); font-size: 14px; }

/* ---------- title plate (first screen) */
.title {
  position: fixed; inset: 0; z-index: 40; display: grid; align-items: center; padding: 24px clamp(24px, 6vw, 96px);
  background: linear-gradient(90deg, rgba(246, 245, 241, .97) 0, rgba(246, 245, 241, .9) 38%, rgba(246, 245, 241, 0) 72%);
  transition: opacity 360ms var(--ease-out), visibility 0s linear 360ms;
}
.title[aria-hidden='true'] { opacity: 0; visibility: hidden; pointer-events: none; }
.title-plate { max-width: 560px; }
.title h1 { margin: 0; font: 400 clamp(56px, 7.4vw, 112px)/.92 var(--serif); letter-spacing: -.035em; }
.title-lede { margin: 24px 0 0; max-width: 30em; font-size: 19px; line-height: 1.5; color: var(--ink-2); }
.title-key { display: flex; flex-wrap: wrap; gap: 8px 20px; margin: 26px 0 0; font-size: 14px; color: var(--ink-2); }
.title-key span { display: inline-flex; align-items: center; gap: 8px; }
.title-form { margin-top: 36px; }
.title-label { display: block; margin-bottom: 8px; font-size: 14px; font-weight: 600; }
.title-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; max-width: 520px; }
.title-row .btn { min-height: 48px; }
.title-small { margin: 18px 0 0; max-width: 32em; font-size: 13px; color: var(--muted); }
.title-plate > * { animation: rise 640ms var(--ease-out) both; }
.title-plate > :nth-child(2) { animation-delay: 60ms; } .title-plate > :nth-child(3) { animation-delay: 120ms; }
.title-plate > :nth-child(4) { animation-delay: 180ms; } .title-plate > :nth-child(5) { animation-delay: 240ms; }
.title-plate > :nth-child(6) { animation-delay: 300ms; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* ---------- the plate */
.plate {
  position: fixed; z-index: 20; top: var(--gap); left: var(--gap); bottom: var(--gap); width: var(--plate-w);
  display: flex; flex-direction: column; background: var(--paper); border-radius: 4px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, .6) inset, 0 12px 40px rgba(18, 28, 36, .16), 0 0 0 1px rgba(22, 33, 42, .06);
  transition: transform 420ms var(--ease-out), opacity 280ms var(--ease-out);
}
body.is-title .plate { transform: translateX(calc(-100% - 2 * var(--gap))); opacity: 0; }
.plate-grip { display: none; }
.plate-scroll { flex: 1; overflow: auto; overscroll-behavior: contain; padding: 22px 24px 20px; scrollbar-width: thin; }
.plate-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 18px; }
.wordmark { font: 500 25px/1.1 var(--serif); letter-spacing: -.02em; color: var(--ink); text-decoration: none; }

.block { padding: 20px 0; }
.block + .block { box-shadow: 0 -1px 0 var(--hair); }
.block-country { padding-top: 0; }
.block h2, .block-title h2 { margin: 0; font: 500 22px/1.15 var(--serif); letter-spacing: -.01em; }
.block-title { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 10px; }
.figure { display: grid; gap: 2px; margin: 18px 0 12px; }
.figure-num { font: 400 76px/.9 var(--serif); letter-spacing: -.035em; font-variant-numeric: lining-nums tabular-nums; }
.figure-sm { margin-top: 4px; }
.figure-sm .figure-num { font-size: 48px; }
.figure-cap { margin: 6px 0 0; font-size: 15px; color: var(--ink-2); }
.bar { height: 8px; border-radius: 1px; background: var(--paper-2); }
.bar-lg { height: 12px; }
.split { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 14px 0 0; }
.split div { min-width: 0; }
.split dt { display: flex; align-items: flex-start; gap: 6px; font-size: 13px; line-height: 1.25; color: var(--muted); }
.split dt .k { margin-top: 2px; }
.split dd { margin: 4px 0 0; font: 500 18px/1 var(--serif); font-variant-numeric: tabular-nums; }
.dist { margin: 18px 0 0; }
.dist-chart { height: 48px; }
.dist-chart svg { width: 100%; height: 100%; }
.dist-chart rect { fill: #cfcdc5; cursor: pointer; transition: fill 140ms ease; }
@media (hover: hover) and (pointer: fine) { .dist-chart rect:hover { fill: var(--ink-2); } }
.dist-chart rect.is-current { fill: var(--ink); }
.dist figcaption { margin-top: 6px; font-size: 13px; color: var(--muted); }
.dist figcaption b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.note { margin: 12px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }
.live { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 7px; }
.live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--c-open); transition: background-color 200ms ease; }
[data-measuring] .live::before, [data-moving] .live::before { background: var(--c-cond); animation: blink 900ms ease-in-out infinite alternate; }
@keyframes blink { to { opacity: .3; } }
[data-moving] .block-view .figure-num, [data-measuring] .block-view .figure-num { opacity: .45; transition: opacity 200ms ease; }

.key { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.key li { display: grid; grid-template-columns: 30px 1fr; gap: 12px; align-items: start; }
.key b { display: block; font-weight: 600; font-size: 14px; }
.key span { display: block; font-size: 13px; line-height: 1.35; color: var(--muted); }
.swatch { position: relative; display: block; width: 30px; height: 30px; border-radius: 3px; overflow: hidden; cursor: pointer; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08); transition: transform 140ms var(--ease-out); }
.swatch:active { transform: scale(.94); }
.swatch input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); padding: 0; border: 0; cursor: pointer; }
.swatch:focus-within { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatch-border { cursor: default; background: repeating-linear-gradient(90deg, var(--c-barrier) 0 7px, transparent 7px 11px) center/100% 2px no-repeat, #fff; }

.home { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
.home input { height: 44px; padding: 0 12px; border: 0; border-radius: 3px; background: #fff; box-shadow: inset 0 0 0 1px var(--hair); font-size: 15px; }
.home input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--ink); }
.home-clear { display: none; justify-self: start; }
.home[data-has-home] .home-clear { display: block; }
.home[aria-busy] .btn { opacity: .6; }
.status { min-height: 1.4em; margin: 8px 0 0; font-size: 13px; color: var(--c-barrier-deep); }
.plate-foot { padding-top: 16px; box-shadow: 0 -1px 0 var(--hair); font-size: 13px; color: var(--muted); }
.plate-foot p { margin: 0 0 8px; }

/* entrance of plate content after the title plate */
.plate.is-entering .block, .plate.is-entering .plate-head { animation: rise 520ms var(--ease-out) both; }
.plate.is-entering .block:nth-of-type(1) { animation-delay: 60ms; }
.plate.is-entering .block:nth-of-type(2) { animation-delay: 110ms; }
.plate.is-entering .block:nth-of-type(3) { animation-delay: 160ms; }
.plate.is-entering .block:nth-of-type(4) { animation-delay: 210ms; }

body.is-title .collar, body.is-title .tools, body.is-title .maplibregl-ctrl-top-right, body.is-title .maplibregl-ctrl-bottom-right .maplibregl-ctrl-scale { opacity: 0; pointer-events: none; }
.collar, .tools, .maplibregl-ctrl-top-right { transition: opacity 300ms var(--ease-out); }

/* ---------- map collar + tools */
.collar {
  position: fixed; z-index: 10; left: calc(var(--plate-w) + 2 * var(--gap)); bottom: var(--gap);
  display: flex; gap: 14px; padding: 7px 11px; border-radius: 3px; background: rgba(246, 245, 241, .92);
  font-size: 12px; color: var(--ink-2); font-variant-numeric: tabular-nums; pointer-events: none;
}
.collar b { font-weight: 600; }
.tools { position: fixed; z-index: 10; top: var(--gap); right: var(--gap); display: grid; gap: 6px; }
.tool {
  display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 3px; background: var(--paper); color: var(--ink);
  box-shadow: 0 4px 14px rgba(18, 28, 36, .14), 0 0 0 1px rgba(22, 33, 42, .06); transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.tool:active { transform: scale(.94); }
@media (hover: hover) and (pointer: fine) { .tool:hover { background: #fff; } }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.4; }
.maplibregl-ctrl-top-right { top: calc(var(--gap) + 146px); right: calc(var(--gap) - 10px); }
.maplibregl-ctrl-group { border-radius: 3px !important; box-shadow: 0 4px 14px rgba(18, 28, 36, .14), 0 0 0 1px rgba(22, 33, 42, .06) !important; background: var(--paper) !important; }
.maplibregl-ctrl-group button { width: 40px !important; height: 40px !important; }
.maplibregl-ctrl-bottom-right { right: calc(var(--gap) + 118px); bottom: calc(var(--gap) - 10px); }
.maplibregl-ctrl-attrib.maplibregl-compact { background: rgba(246, 245, 241, .92); }
.maplibregl-ctrl-scale { border-color: var(--ink-2); background: rgba(246, 245, 241, .85); color: var(--ink-2); font: 11px var(--sans); }

/* popups */
.wc-popup .maplibregl-popup-content { background: var(--paper); color: var(--ink); font: 13px/1.4 var(--sans); box-shadow: 0 12px 32px rgba(18, 28, 36, .2); border-radius: 3px; }
.wc-popup strong { font: 500 16px/1.2 var(--serif); }
.wc-popup span { color: var(--ink-2); }
.wc-popup .maplibregl-popup-tip { border-top-color: var(--paper) !important; border-bottom-color: var(--paper) !important; }
.maplibregl-popup { animation: pop 160ms var(--ease-out); }
@keyframes pop { from { opacity: 0; } }

/* ---------- about */
.about { width: min(620px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); padding: 32px 36px; border: 0; border-radius: 4px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 80px rgba(10, 18, 24, .3); }
.about::backdrop { background: rgba(22, 33, 42, .38); }
.about[open] { animation: dialog-in 220ms var(--ease-out); }
@keyframes dialog-in { from { opacity: 0; transform: scale(.97); } }
.about h2 { margin: 0 0 12px; font: 400 34px/1.05 var(--serif); letter-spacing: -.02em; }
.about h3 { margin: 22px 0 4px; font: 600 16px/1.25 var(--sans); }
.about p { margin: 0 0 10px; font-size: 15px; line-height: 1.55; color: var(--ink-2); }
.about-x { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; border: 0; border-radius: 3px; background: transparent; font-size: 24px; line-height: 1; }
@media (hover: hover) and (pointer: fine) { .about-x:hover { background: var(--paper-2); } }

/* ---------- phone */
@media (max-width: 860px) {
  :root { --ds-bottom: auto; --ds-top: 10px; --ds-right: 10px; --ds-panel-top: calc(100% + 8px); --ds-panel-bottom: auto; --ds-origin: top right; }
  .title { align-items: end; padding: 20px 20px calc(28px + env(safe-area-inset-bottom)); background: linear-gradient(0deg, rgba(246, 245, 241, .98) 0, rgba(246, 245, 241, .96) 62%, rgba(246, 245, 241, 0) 92%); }
  .title h1 { font-size: clamp(46px, 13.5vw, 64px); }
  .title-lede { margin-top: 16px; font-size: 17px; }
  .title-key { margin-top: 18px; gap: 6px 16px; }
  .title-form { margin-top: 22px; }
  .title-row { grid-template-columns: 1fr; }
  .title-small { margin-top: 12px; }
  .title .cp-menu { top: auto; bottom: calc(100% + 6px); max-height: 40vh; transform-origin: bottom center; }

  .plate {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; height: min(88dvh, 760px); border-radius: 14px 14px 0 0;
    box-shadow: 0 -10px 34px rgba(18, 28, 36, .2); transition: opacity 280ms var(--ease-out);
    will-change: transform;
  }
  body.is-title .plate { transform: translateY(100%) !important; }
  .plate-grip { display: block; padding: 8px 18px 12px; touch-action: none; cursor: grab; }
  .grip { display: block; width: 38px; height: 4px; margin: 0 auto 10px; border-radius: 2px; background: #c9c7bf; }
  .peek { display: grid; grid-template-columns: 1fr auto auto; gap: 18px; align-items: end; }
  .peek-country { min-width: 0; font: 500 21px/1.1 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .peek-fig { display: grid; justify-items: end; }
  .peek-fig b { font: 400 26px/1 var(--serif); font-variant-numeric: tabular-nums; }
  .peek-fig small { font-size: 12px; color: var(--muted); }
  .plate-scroll { padding: 4px 18px calc(24px + env(safe-area-inset-bottom)); }
  .plate[data-sheet='peek'] .plate-scroll { overflow: hidden; }
  .plate[data-sheet]:not([data-sheet='peek']) .peek { display: none; }
  .plate-head { display: none; }
  .figure-num { font-size: 60px; }
  .collar { display: none; }
  .tools { top: 10px; left: 10px; right: auto; grid-auto-flow: column; }
  .maplibregl-ctrl-top-right { display: none; }
  .maplibregl-ctrl-bottom-right { right: 0; bottom: calc(var(--peek, 108px) + 4px); }
  .about { padding: 26px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  .title-plate > *, .plate.is-entering .block, .plate.is-entering .plate-head { animation: none; }
  .plate, .title { transition: opacity 200ms ease; }
  .live::before { animation: none !important; }
}
