/* /atlas — the same night palette and points of light as the home page map
   (site.css .shop-map), plus the province colours, chart and ranking. */

.atlas-head { padding-bottom: var(--s-4); }
.atlas-head h1 { max-width: 22ch; }
.atlas-head .lede { max-width: 46rem; }
.atlas-head .eyebrow time { font-family: var(--font-data); }

/* --- dataset switch ------------------------------------------------------- */
.atlas-modes {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; margin: 0 0 var(--s-6);
  background: var(--paper-2); border: var(--hair-strong); border-radius: var(--radius-pill);
}
.atlas-modes[hidden] { display: none; }
.atlas-modes button {
  background: transparent; border: 0; border-radius: var(--radius-pill); color: var(--ink-2);
  font-size: var(--t-sm); padding: var(--s-2) var(--s-4); min-height: 40px; cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.atlas-modes button:hover { color: var(--ink); }
.atlas-modes button[aria-pressed="true"] { background: var(--orange); color: var(--on-orange); font-weight: 600; }

/* --- the board: facts · map · side ---------------------------------------- */
/* three cards of one height, tops and bottoms in line */
.atlas-board {
  display: grid; gap: var(--s-6); align-items: stretch;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
}
.atlas-facts, .atlas-side, .atlas-map {
  display: flex; flex-direction: column; min-width: 0; margin: 0;
  background: var(--paper-2); border: var(--hair); border-radius: var(--radius); padding: var(--s-6);
}
.atlas-side > div:not([hidden]) { display: flex; flex-direction: column; flex: 1; }
.atlas-source { margin: 0; font-size: var(--t-xs); color: var(--ink-3); letter-spacing: .02em; }
.atlas-date { margin: var(--s-1) 0 0; font-family: var(--font-data); color: var(--ink-2); font-size: var(--t-sm); }
.atlas-total { margin: var(--s-1) 0 0; display: flex; align-items: baseline; gap: var(--s-2); }
.atlas-total strong {
  font-size: clamp(3rem, 6vw, 4.5rem); line-height: 1; color: var(--orange); font-weight: 500;
  text-shadow: 0 0 28px rgba(247, 147, 26, .25);
}
.atlas-total span { color: var(--ink-2); }
.atlas-delta { margin: var(--s-2) 0 0; font-size: var(--t-sm); color: var(--ink-2); }
.atlas-compare { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s-3); margin: var(--s-4) 0 0; }
.atlas-compare div { border-top: var(--hair); padding-top: var(--s-2); min-width: 0; }
.atlas-compare dt { font-size: var(--t-xs); color: var(--ink-3); }
.atlas-compare dd { margin: 0; font-size: var(--t-md); color: var(--ink); overflow-wrap: anywhere; }

.atlas-chart { margin: auto 0 0; padding-top: var(--s-6); }      /* sits at the bottom of the card */
.atlas-chart figcaption { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--s-2); }
.atlas-chart figcaption b { font-size: var(--t-sm); font-weight: 600; }
.atlas-chart figcaption span { font-size: var(--t-xs); color: var(--ink-3); }
.atlas-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.atlas-chart .cg { stroke: var(--rule); stroke-width: 1; }
.atlas-chart .ct { stroke: var(--rule-strong); stroke-width: 1; }
.atlas-chart .cl { fill: var(--ink-3); font: 10px var(--font-data); }
.atlas-chart .carea { fill: rgba(247, 147, 26, .14); }
.atlas-chart .cline { fill: none; stroke: var(--orange); stroke-width: 2; stroke-linejoin: round; }
.atlas-chart .cline-ghost { fill: none; stroke: var(--rule-strong); stroke-width: 1.5; stroke-dasharray: 2 3; }
.atlas-chart .cnow { stroke: var(--orange-ink); stroke-width: 1; stroke-dasharray: 2 2; opacity: .6; }
.atlas-chart .chead { fill: var(--orange); stroke: var(--paper-2); stroke-width: 2;
  filter: drop-shadow(0 0 4px rgba(247, 147, 26, .8)); }
.atlas-chart .cmark { fill: var(--closed); }
.atlas-caveat { margin: var(--s-3) 0 0; font-size: var(--t-xs); color: var(--ink-3); }
.atlas-note {
  margin: var(--s-3) 0 0; padding: var(--s-2) var(--s-3); border-left: 3px solid var(--closed);
  background: rgba(224, 138, 118, .08); font-size: var(--t-xs); color: var(--ink-2);
}

/* --- map: the home page's points of light, with province outlines --------- */
.atlas-map-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--s-3); }
.atlas-map-head b { font-size: var(--t-sm); font-weight: 600; }
.atlas-map-head span { font-size: var(--t-xs); color: var(--ink-3); }
.atlas-map-box { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.atlas-svg { display: block; width: 100%; height: auto; max-height: 34rem; margin: 0 auto; }
.atlas-svg .prov {
  fill: rgba(237, 230, 214, .035); stroke: rgba(237, 230, 214, .16); stroke-width: 1.6;
  stroke-linejoin: round; fill-rule: evenodd; transition: fill .45s var(--ease), stroke .2s;
}
.atlas-svg .prov:hover { stroke: rgba(237, 230, 214, .45); }
.atlas[data-mode="province"] .atlas-svg .prov { cursor: pointer; }
.atlas-svg .prov.zero { fill: rgba(237, 230, 214, .02); }
.atlas-svg .prov.sel { stroke: var(--ink); stroke-width: 5; }
.atlas-svg .dot {
  fill: var(--orange); fill-opacity: .6; opacity: 0; pointer-events: none;
  transform-box: fill-box; transform-origin: center; transition: opacity .35s ease;
}
.atlas-svg .dot.on { opacity: 1; }
.atlas-svg .labels { pointer-events: none; }
.atlas-svg .lbl { paint-order: stroke; stroke: var(--paper-2); stroke-width: 8px; stroke-linejoin: round; }
.atlas[data-mode="province"] .atlas-svg .lbl .num { fill: var(--ink); }
.atlas-legend { margin: var(--s-3) 0 0; font-size: var(--t-xs); color: var(--ink-3); text-align: center; }
.atlas-legend .num { color: var(--orange-ink); }
.atlas-tip {
  position: absolute; left: 0; top: 0; pointer-events: none; z-index: 2; white-space: nowrap;
  padding: var(--s-1) var(--s-3); border-radius: var(--radius-sm); background: var(--paper-3);
  border: var(--hair-strong); font-size: var(--t-xs); color: var(--ink);
}

/* --- side: years (country) and the ranking (provinces) -------------------- */
.atlas-side-h { font-size: var(--t-md); margin: 0 0 var(--s-3); display: flex; flex-direction: column; gap: 2px; }
.atlas-side-h span { font: 400 var(--t-xs) var(--font-body); color: var(--ink-3); }
.atlas-years { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.atlas-years li {
  display: grid; grid-template-columns: 3.5rem minmax(0, 1fr) auto; align-items: baseline; gap: var(--s-2);
  padding: var(--s-2) 0; border-bottom: var(--hair); transition: opacity .3s;
}
.atlas-years .y { color: var(--ink); font-size: var(--t-sm); }
.atlas-years .d { color: var(--ink-3); font-size: var(--t-xs); }
.atlas-years b { color: var(--orange-ink); font-size: var(--t-md); font-weight: 500; }
.atlas-years li.future { opacity: .3; }
.atlas-side-note { margin: var(--s-3) 0 0; font-size: var(--t-xs); color: var(--ink-3); }
.atlas-switch { margin-top: auto; padding-top: var(--s-4); border-top: var(--hair); }
#a-side-national .atlas-side-note { margin-bottom: var(--s-6); }
.atlas-switch[hidden] { display: none; }
.atlas-switch p { font-size: var(--t-sm); color: var(--ink-2); margin: 0 0 var(--s-3); }
.atlas-switch p b { display: block; color: var(--ink); }

.atlas-filters { display: grid; gap: var(--s-2); margin-bottom: var(--s-4); }
.atlas-filters select { font-size: var(--t-sm); min-height: 40px; }
.atlas-rank { position: relative; overflow: hidden; }
.rk {
  position: absolute; left: 0; right: 0; top: 0; height: 42px; padding: 4px 6px; margin: 0;
  display: grid; grid-template-columns: 1.4rem minmax(0, 1fr) auto 2.6rem; grid-template-rows: auto 6px;
  column-gap: var(--s-2); align-items: center; text-align: left; cursor: pointer;
  background: transparent; border: 1px solid transparent; border-radius: var(--radius-sm); color: var(--ink);
}
.atlas-rank.ready .rk { transition: transform .45s cubic-bezier(.2, .7, .3, 1), opacity .3s, visibility 0s; }
.rk.off { opacity: 0; visibility: hidden; }
.atlas-rank.ready .rk.off { transition: transform .45s, opacity .3s, visibility 0s .3s; }
.rk:hover { background: var(--paper-3); }
.rk.sel { border-color: var(--ink-2); background: var(--paper-3); }
.rk-n { color: var(--ink-3); font-size: var(--t-xs); }
.rk-name { font-size: var(--t-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rk-v { font-size: var(--t-sm); color: var(--orange-ink); }
.rk-d { font-size: var(--t-xs); color: var(--ink-3); text-align: right; }
.rk-d.up { color: var(--open); }
.rk-d.down { color: var(--closed); }
.rk-bar { grid-column: 2 / 5; position: relative; height: 5px; }
.rk-bar i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; }
.rk-base { border: 1px solid var(--rule-strong); }
.rk-now { background: var(--orange); opacity: .85; }
.atlas-rank.ready .rk-now, .atlas-rank.ready .rk-base { transition: width .45s cubic-bezier(.2, .7, .3, 1); }

/* --- playback ------------------------------------------------------------- */
.atlas-play {
  display: flex; align-items: center; gap: var(--s-4); margin: var(--s-6) 0 0; padding: var(--s-4);
  background: var(--paper-2); border: var(--hair); border-radius: var(--radius);
}
.atlas-play[hidden] { display: none; }
.atlas-playbtn { flex: none; min-width: 10.5rem; }
.atlas:not(.is-playing) .atlas-playbtn { animation: atlas-invite 2.6s ease-in-out 1.2s 2; }
@keyframes atlas-invite {
  0%, 100% { box-shadow: 0 0 0 0 rgba(247, 147, 26, 0); }
  50% { box-shadow: 0 0 0 8px rgba(247, 147, 26, .18); }
}
.atlas-time { flex: 1; min-width: 0; }
.atlas-time input[type="range"] { width: 100%; accent-color: var(--orange); margin: 0; cursor: pointer; }
.atlas-time-labels { display: flex; justify-content: space-between; gap: var(--s-3); font-size: var(--t-xs); color: var(--ink-3); }
.atlas-time-labels #a-frame { text-align: center; }
.atlas-time-labels #a-start, .atlas-time-labels #a-end { font-family: var(--font-data); white-space: nowrap; }
.atlas-foot { margin: var(--s-3) 0 0; font-size: var(--t-xs); color: var(--ink-3); text-align: center; }

/* --- the text below the board --------------------------------------------- */
.atlas-text { max-width: var(--measure); }
.atlas-text .block { margin-top: var(--s-12); }
.atlas-text h2 { font-size: var(--t-xl); margin-bottom: var(--s-3); }
.atlas-text h3 { font-size: var(--t-md); margin: var(--s-6) 0 var(--s-2); }
.atlas-table-wrap { overflow-x: auto; margin: var(--s-4) 0 0; border: var(--hair); border-radius: var(--radius-sm); }
.atlas-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.atlas-table th, .atlas-table td { padding: var(--s-2) var(--s-3); border-bottom: var(--hair); text-align: left; white-space: nowrap; }
.atlas-table thead th { background: var(--paper-3); font-weight: 600; font-size: var(--t-xs); color: var(--ink-2); }
.atlas-table tbody th { font-weight: 500; }
.atlas-table .n { text-align: right; }
.atlas-table tfoot th, .atlas-table tfoot td { font-weight: 600; border-bottom: 0; }
.atlas-table a { color: var(--ink); text-decoration-color: var(--rule-strong); }
.atlas-table a:hover { color: var(--orange-ink); }
.atlas-small { font-size: var(--t-xs); color: var(--ink-3); margin-top: var(--s-2); }
.atlas-details { margin-top: var(--s-4); border: var(--hair); border-radius: var(--radius); padding: 0 var(--s-4); }
.atlas-details > summary { cursor: pointer; padding: var(--s-3) 0; font-weight: 600; color: var(--orange-ink); }
.atlas-details[open] > summary { border-bottom: var(--hair); }
.atlas-details .atlas-table-wrap { border: 0; margin-top: 0; }
.atlas-details .atlas-small { padding-bottom: var(--s-3); }
.atlas-notes, .atlas-downloads, .atlas-sources { padding-left: 1.1rem; }
.atlas-notes li, .atlas-sources li { margin-bottom: var(--s-2); font-size: var(--t-sm); color: var(--ink-2); }
.atlas-downloads { list-style: none; padding: 0; display: grid; gap: var(--s-2); }
.atlas-downloads a { font-weight: 600; color: var(--orange-ink); }
.atlas-downloads span { color: var(--ink-3); font-size: var(--t-sm); }

/* --- narrower screens ----------------------------------------------------- */
@media (max-width: 64rem) {
  .atlas-board { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .atlas-map { grid-column: 2; grid-row: 1 / span 2; }
  .atlas-facts, .atlas-side { grid-column: 1; }
}
@media (max-width: 44rem) {
  .atlas-board { grid-template-columns: minmax(0, 1fr); gap: var(--s-4); }
  .atlas-map, .atlas-facts, .atlas-side { grid-column: auto; grid-row: auto; }
  .atlas-facts, .atlas-side, .atlas-map { padding: var(--s-4); }
  .atlas-chart { margin-top: 0; }
  .atlas-switch { margin-top: var(--s-4); }
  .atlas-svg { max-height: 32rem; }
  .atlas-modes { display: flex; border-radius: var(--radius); }
  .atlas-modes button { flex: 1 1 auto; }
  .atlas-play { flex-direction: column; align-items: stretch; gap: var(--s-3); }
  .atlas-playbtn { width: 100%; }
  .atlas-time-labels #a-frame { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .atlas-svg .prov, .atlas-svg .dot, .atlas-years li { transition: none; }
  .atlas-rank.ready .rk, .atlas-rank.ready .rk-now, .atlas-rank.ready .rk-base { transition: none; }
  .atlas:not(.is-playing) .atlas-playbtn { animation: none; }
}
@media print {
  .atlas-modes, .atlas-play, .atlas-side { display: none; }
}
