/* ==========================================================================
   Atla — Lists page (lists.html)
   --------------------------------------------------------------------------
   Layered ON TOP of assets/css/styles.css (loaded FIRST), so all base design
   tokens (--bg, --ink, --ink-dim, --ink-mute, --on-color, --hair, --font-*,
   --step-*, --dur, --ease, --gutter, --container) and the self-hosted
   @font-face for "Fraunces" / "Inter" already exist there.

   The page renders ONLY published lists, in order:
     - "country-map": a visited-countries choropleth. Every country is a WARM
       WHITE (#f4efe6) with a thin earth-grey border, floating on a deep earth
       ocean/background so the white reads. Represented countries are then
       washed in their list colour (JS sets --fill on the country element via
       the CSSOM; custom properties inherit, so grouped countries' child
       .landxx paths pick it up). A legend grid sits below.
     - "generic": title + description + an items list.

   Strict-CSP safe: classes / CSS custom properties / SVG presentation
   attributes only. No inline styles, no <style> blocks, no external code.
   EARTH TONES ONLY: warm white #f4efe6, earth-grey borders, deep umber ocean.
   ========================================================================== */

/* ---- Page-scoped tokens (fallback-safe) ------------------------------- */
.page-lists {
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* Lists accent — dark ochre, an earth tone, for kickers / icons / focus. */
  --accent: #6f5a1d;

  /* Soft hairline variants on the near-black canvas. */
  --line: rgb(255 255 255 / 0.12);
  --line-soft: rgb(255 255 255 / 0.07);

  /* Choropleth palette (earth tones only). */
  --map-white: #f4efe6;     /* warm white — every country's resting fill   */
  --map-border: #7a6a55;    /* thin earth-grey country border               */
  --map-ocean: #2a2016;     /* deep umber ocean so white countries read     */
  --map-ocean-2: #1a130c;   /* darker umber for the radial wash             */

  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-ui);
}

/* ---- Secure inline-sprite + icon system (idempotent) ------------------- */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  inline-size: 1.2em;
  block-size: 1.2em;
  fill: none;
  stroke: currentColor;
  vertical-align: middle;
  flex: none;
}

/* ---- Film-grain overlay ------------------------------------------------ */
.grain {
  position: fixed;
  inset: 0;
  z-index: 80;
  pointer-events: none;
  opacity: 0.04;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---- Hero -------------------------------------------------------------- */
.lists-hero { background: var(--bg); color: var(--ink); }
.lists-hero__inner {
  min-block-size: auto;
  padding-block: clamp(8rem, 18vh, 12rem) clamp(2.5rem, 6vh, 4rem);
  gap: clamp(0.9rem, 0.4rem + 1.1vw, 1.6rem);
}
.lists-hero__cat {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.lists-hero__title {
  font-family: var(--font-display);
  font-weight: 300;
  font-optical-sizing: auto;
  font-size: clamp(3rem, 1.4rem + 9vw, 9rem);
  line-height: 0.94;
  letter-spacing: -0.02em;
  max-inline-size: 16ch;
  color: var(--ink);
}
.lists-hero__title em,
.lists-hero__title .is-accent {
  font-style: italic;
  font-weight: 400;
  color: color-mix(in oklab, var(--ink) 78%, var(--accent) 22%);
}
@supports not (color: color-mix(in oklab, #000 50%, #fff)) {
  .lists-hero__title em,
  .lists-hero__title .is-accent { color: var(--ink-dim); }
}
.lists-hero__desc {
  font-family: var(--font-ui);
  font-size: var(--step-1);
  max-inline-size: 46ch;
  color: var(--ink-dim);
}
.lists-hero__back { margin-block-start: clamp(0.5rem, 1.5vw, 1.2rem); }
.lists-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-dim);
  transition: color var(--dur) var(--ease);
}
.lists-back:hover,
.lists-back:focus-visible { color: var(--ink); }
.lists-back .icon { transition: transform var(--dur) var(--ease); }
.lists-back:hover .icon,
.lists-back:focus-visible .icon { transform: translateX(-0.3rem); }

/* ---- Lists section + stack -------------------------------------------- */
.lists { background: var(--bg); color: var(--ink); }
.lists__inner {
  min-block-size: auto;
  padding-block: clamp(1rem, 3vh, 2.5rem) clamp(5rem, 12vh, 9rem);
  justify-content: flex-start;
  gap: clamp(2rem, 4vw, 3.5rem);
}
.lists__stack {
  display: flex;
  flex-direction: column;
  gap: clamp(3rem, 7vw, 6rem);
}

/* Loading / empty status row. */
.lists__status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-dim);
}
.lists__status[hidden] { display: none; }
.lists__status .icon { color: var(--accent); }

/* ---- A single list block (article) ------------------------------------ */
.list-block { display: flex; flex-direction: column; gap: clamp(1rem, 2.5vw, 1.8rem); }
.list-block__head { display: flex; flex-direction: column; gap: 0.6rem; max-inline-size: 60ch; }
.list-block__kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
}
.list-block__kicker .icon { color: var(--accent); }
.list-block__title {
  font-family: var(--font-display);
  font-size: var(--step-2);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.list-block__desc {
  font-family: var(--font-ui);
  font-size: var(--step-0);
  color: var(--ink-dim);
  max-inline-size: 60ch;
}

/* ==========================================================================
   country-map: the visited-countries choropleth
   ========================================================================== */

.cmap__figure { margin: 0; }

/* Viewport: a deep earth (umber) wash so the warm-white countries read. The
   radial lifts a slightly warmer umber out of the top-left and settles dark. */
.cmap__viewport {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(120% 140% at 18% 8%,
      color-mix(in oklab, var(--map-ocean) 78%, #000 22%) 0%,
      var(--map-ocean) 55%,
      var(--map-ocean-2) 100%);
  background-color: var(--map-ocean);   /* fallback for no color-mix() */
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.05);
}

/* The canvas that receives the inlined SVG. aspect-ratio reserves the box
   (zero layout shift) before the SVG arrives. */
.cmap__canvas {
  display: block;
  inline-size: 100%;
  aspect-ratio: 2754 / 1398;   /* world.svg's native viewBox ratio */
}
.cmap__canvas svg {
  display: block;
  inline-size: 100%;
  block-size: 100%;
}

/* ---- SVG map theming (world.svg ships with NO presentation attributes, so
   ALL theming lives here). Country primary elements carry data-code="ISO"
   (uppercase); multi-part countries are a <g> whose child .landxx paths
   inherit the lit fill via the inherited --fill custom property. ---------- */

/* Ocean: transparent so the viewport's earth wash reads as water. */
.cmap__canvas .oceanxx { fill: transparent; stroke: none; }

/* EVERY country resting: warm white with a thin earth-grey border. (.antxx =
   uninhabited territories incl. Antarctica; themed as land for context.) */
.cmap__canvas .landxx,
.cmap__canvas .antxx {
  fill: var(--map-white);
  stroke: var(--map-border);
  stroke-width: 0.6;
  fill-rule: evenodd;
  transition: fill var(--dur) var(--ease), filter var(--dur) var(--ease);
}

/* Decorative overlays the stripped source <style> kept hidden (small-country
   circles, sub-national markers, limited-recognition duplicate layers) —
   re-hide so they don't surface as blobs. */
.cmap__canvas .circlexx,
.cmap__canvas .subxx,
.cmap__canvas .noxx,
.cmap__canvas .unxx,
.cmap__canvas .limitxx { opacity: 0; }

/* Represented countries: filled from --fill (JS sets it on the country element
   via the CSSOM). Ordered AFTER the base so equal-specificity ties resolve
   here. The border warms slightly so the wash reads as deliberate. */
.cmap__canvas .is-visited,
.cmap__canvas .is-visited .landxx {
  fill: var(--fill, var(--accent));
  stroke: color-mix(in oklab, var(--fill, var(--accent)) 60%, #000 40%);
  stroke-width: 0.7;
}
@supports not (color: color-mix(in oklab, #000 50%, #fff)) {
  .cmap__canvas .is-visited,
  .cmap__canvas .is-visited .landxx { stroke: var(--map-border); }
}

/* Hover / keyboard-focus highlight (mirrored — never :hover alone). The filter
   brightens the whole country; the stroke is applied to self AND child paths so
   grouped countries get the full outline + a cream halo for keyboard users. */
.cmap__canvas .is-visited:hover,
.cmap__canvas .is-visited:focus-visible {
  filter: brightness(1.14) saturate(1.06);
  outline: none;
  cursor: default;
}
.cmap__canvas .is-visited:hover,
.cmap__canvas .is-visited:hover .landxx,
.cmap__canvas .is-visited:focus-visible,
.cmap__canvas .is-visited:focus-visible .landxx {
  stroke: var(--ink);
  stroke-width: 1.4;
}
.cmap__canvas .is-visited:focus-visible {
  filter: brightness(1.14) saturate(1.06) drop-shadow(0 0 2.5px var(--ink));
}

/* ---- Live readout (CSP-safe tooltip alternative) ---------------------- */
/* As well as each country's <title> child (native tooltip + SR text), JS writes
   the hovered/focused country's name + count here so it's announced + visible. */
.cmap__readout {
  margin-block-start: 0.9rem;
  min-block-size: 1.5em;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.02em;
  color: var(--ink-dim);
}
.cmap__readout .icon { color: var(--accent); flex: none; }
.cmap__readout .cmap__readout-empty { color: var(--ink-mute); }
.cmap__readout .cmap__readout-name { color: var(--ink); }
.cmap__readout .cmap__readout-count { opacity: 0.85; }

/* ---- Legend grid ------------------------------------------------------- */
.cmap__legend {
  margin-block-start: clamp(1.25rem, 3vw, 2rem);
}
.cmap__legend-heading {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ink-dim);
  margin-block-end: clamp(0.75rem, 1.5vw, 1.1rem);
}
.cmap__legend-grid {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(0.5rem, 1vw, 0.85rem);
}
@media (min-width: 40rem) { .cmap__legend-grid { grid-template-columns: 1fr 1fr; } }
@media (min-width: 64rem) { .cmap__legend-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 90rem) { .cmap__legend-grid { grid-template-columns: repeat(4, 1fr); } }

.cmap__legend-item {
  --swatch: var(--accent);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: clamp(0.6rem, 0.4rem + 0.6vw, 0.85rem) clamp(0.75rem, 0.5rem + 0.7vw, 1.05rem);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.03);
  border: 1px solid var(--line-soft);
  transition: background-color var(--dur) var(--ease),
              border-color var(--dur) var(--ease);
}
/* Hover/focus echo of the map: highlight the matching legend row + its swatch.
   .is-active is toggled by JS when the map country is hovered/focused. */
.cmap__legend-item:hover,
.cmap__legend-item.is-active {
  background: rgb(255 255 255 / 0.06);
  border-color: rgb(236 229 216 / 0.32);
}
.cmap__legend-swatch {
  flex: 0 0 auto;
  inline-size: 1.5rem;
  block-size: 1.5rem;
  border-radius: 6px;
  background: var(--swatch);
  background-image:
    radial-gradient(120% 120% at 25% 20%,
      color-mix(in oklab, var(--swatch) 65%, #fff 35%) 0%,
      var(--swatch) 70%);
  border: 1px solid rgb(255 255 255 / 0.2);
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 0.25);
}
@supports not (color: color-mix(in oklab, #000 50%, #fff)) {
  .cmap__legend-swatch { background-image: none; }
}
.cmap__legend-text {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  min-width: 0;
  flex: 1 1 auto;
}
.cmap__legend-name {
  font-family: var(--font-ui);
  font-size: var(--step-0);
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmap__legend-count {
  margin-inline-start: auto;
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-dim);
  white-space: nowrap;
}

/* ==========================================================================
   generic list: title/description handled above; items list here
   ========================================================================== */
.glist__items {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: clamp(0.5rem, 1vw, 0.85rem);
  max-inline-size: 60rem;
}
@media (min-width: 48rem) { .glist__items { grid-template-columns: 1fr 1fr; } }
.glist__item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: clamp(0.75rem, 0.5rem + 0.8vw, 1.1rem) clamp(0.9rem, 0.6rem + 0.9vw, 1.25rem);
  border-radius: 12px;
  background: rgb(255 255 255 / 0.03);
  border: 1px solid var(--line-soft);
}
.glist__label {
  font-family: var(--font-ui);
  font-size: var(--step-0);
  font-weight: 600;
  color: var(--ink);
}
.glist__note {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-dim);
}

/* ---- Empty state for a published-but-empty list ----------------------- */
.lists__empty,
.list-block__empty {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  color: var(--ink-dim);
  padding: 0.5rem 0;
}

/* ---- Reduced motion ---------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  .cmap__canvas .landxx,
  .cmap__canvas .antxx,
  .cmap__legend-item,
  .lists-back,
  .lists-back .icon { transition: none; }
}
