/* ecosphere homepage hero: dark atlas band (pairs with hero-map.js).
   The section carries data-mode="dark", so tokens.css supplies dark neutrals
   inside it while the rest of the page stays light. */

.atlas-hero {
  --sea: color-mix(in oklab, var(--bg) 88%, black);
  --r0: color-mix(in oklab, var(--seq-max) 10%, var(--surface-2));
  --r1: color-mix(in oklab, var(--seq-max) 32%, var(--surface-2));
  --r2: color-mix(in oklab, var(--seq-max) 54%, var(--surface-2));
  --r3: color-mix(in oklab, var(--seq-max) 77%, var(--surface-2));
  --r4: color-mix(in oklab, var(--seq-max) 92%, white);
  --no-value-bg: var(--surface-2);
  --no-value-line: var(--border-strong);
  position: relative; overflow: hidden; background: var(--sea); color: var(--ink); border-bottom: 1px solid var(--border);
}
.atlas-hero::before { /* faint chart-paper dots */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: radial-gradient(circle at 1px 1px, rgb(233 240 239 / 0.05) 1px, transparent 0);
  background-size: 22px 22px;
}
.atlas-hero-inner {
  position: relative; width: min(1440px, 100% - 3rem); margin-inline: auto; padding-block: clamp(2.5rem, 5vw, 4rem);
  /* Left edge lines up with the 1200px .wrap used by the header; map and side cards use the extra width. */
  padding-left: clamp(0px, 50% - 624px, 120px);
  display: grid; grid-template-columns: minmax(340px, 420px) minmax(0, 1fr) 236px; grid-template-areas: "copy map side";
  gap: 2rem 2.25rem; align-items: start;
}
.atlas-copy { grid-area: copy; display: grid; gap: 1.5rem; align-content: start; }
.atlas-map { grid-area: map; position: relative; align-self: center; }
.atlas-side { grid-area: side; display: grid; gap: .75rem; align-content: start; }

.atlas-hero h1 {
  font-family: var(--font-display); font-weight: 500; font-variation-settings: "opsz" 144;
  font-size: clamp(2.2rem, 3.6vw, 3.3rem); line-height: 1.06; letter-spacing: -0.012em; margin-top: 1rem; text-wrap: balance;
}
.atlas-hero h1 em { font-style: italic; font-weight: 400; color: var(--accent-text); }
.atlas-hero .lede { margin-top: 1.25rem; font-size: clamp(1rem, 1.2vw, 1.0625rem); }
.atlas-hero .button-row { margin-top: 1.75rem; }

/* ---------- Lens panel: layers + year ---------- */
.lens { border: 1px solid var(--border); border-radius: var(--r-lg); background: color-mix(in oklab, var(--surface) 82%, transparent); padding: 1rem; }
.lens-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; margin-bottom: .75rem; }
.lens-head h2 { font-family: var(--font-ui); font-size: .8125rem; font-weight: 600; letter-spacing: .02em; color: var(--ink-2); }
.lens-layers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.lens-layer {
  display: flex; align-items: center; gap: 10px; text-align: left; padding: 7px 10px; min-height: 44px;
  border: 1px solid var(--border); border-radius: var(--r-md); background: transparent; color: var(--ink-2);
  font: 500 .875rem/1.25 var(--font-ui); cursor: pointer;
}
.lens-layer:hover { border-color: var(--border-strong); color: var(--ink); }
.lens-layer[aria-checked="true"] { border-color: var(--accent-text); color: var(--ink); background: color-mix(in oklab, var(--accent) 18%, transparent); }
.lens-ring { flex: none; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--muted); display: grid; place-items: center; }
.lens-layer[aria-checked="true"] .lens-ring { border-color: var(--accent-text); }
.lens-layer[aria-checked="true"] .lens-ring::after { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent-text); }
.lens-layer small { display: block; font-family: var(--font-data); font-size: .6875rem; color: var(--muted); font-weight: 400; margin-top: 1px; }

.lens-year { margin-top: .9rem; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: .75rem; }
.lens-year label { font-size: .8125rem; color: var(--ink-2); font-weight: 500; }
.lens-year output { font-family: var(--font-data); font-size: 1.125rem; color: var(--ink); min-width: 3.2em; text-align: right; font-weight: 500; }
.lens-play { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border-strong); background: transparent; color: var(--ink); cursor: pointer; display: grid; place-items: center; }
.lens-play:hover { border-color: var(--accent-text); }
.lens-play:disabled { opacity: .45; cursor: not-allowed; }
.lens-play svg { width: 14px; height: 14px; }
.lens-track { grid-column: 1 / -1; }
.lens-track input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; cursor: pointer; margin: 0; }
.lens-track input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(90deg, var(--accent-text) var(--progress, 100%), var(--border-strong) var(--progress, 100%)); }
.lens-track input[type="range"]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--border-strong); }
.lens-track input[type="range"]::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent-text); }
.lens-track input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent-text); }
.lens-track input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--bg); border: 2px solid var(--accent-text); }
.lens-track input[type="range"]:disabled { cursor: not-allowed; opacity: .45; }
.lens-ticks { display: flex; justify-content: space-between; font-family: var(--font-data); font-size: .6875rem; color: var(--muted); margin-top: -6px; padding: 0 2px; }
.lens-note { margin-top: .75rem; font-size: .8125rem; color: var(--muted); line-height: 1.5; }
.lens-note strong { color: var(--ink-2); font-weight: 500; }

/* ---------- Map ---------- */
.atlas-map svg { width: 100%; height: auto; aspect-ratio: 860 / 760; overflow: visible; }
.atlas-graticule line { stroke: var(--grid-line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.atlas-graticule line.is-equator { stroke: rgb(233 240 239 / 0.2); stroke-dasharray: 4 4; }
.atlas-graticule text { font-family: var(--font-data); font-size: 11px; fill: var(--muted); }
.atlas-place { stroke: var(--sea); stroke-width: .8; vector-effect: non-scaling-stroke; transition: fill var(--dur-slow) var(--ease-out); cursor: crosshair; }
.atlas-place.is-island { stroke: var(--ink-2); stroke-width: 1; }
.atlas-place.is-highlighted, .atlas-place:hover { stroke: var(--ink); stroke-width: 1.8; }
.atlas-place.is-no-value { fill: url(#atlas-no-value); }
.atlas-no-value-bg { fill: var(--no-value-bg); }
.atlas-no-value-line { stroke: var(--no-value-line); stroke-width: 2; }
.atlas-hero .b0 { fill: var(--r0); } .atlas-hero .b1 { fill: var(--r1); } .atlas-hero .b2 { fill: var(--r2); } .atlas-hero .b3 { fill: var(--r3); } .atlas-hero .b4 { fill: var(--r4); }
@media (prefers-reduced-motion: reduce) { .atlas-place { transition: none; } }
.atlas-fallback { display: grid; place-items: center; min-height: 320px; text-align: center; color: var(--muted); padding: 2.5rem; font-size: .9375rem; border: 1px dashed var(--border-strong); border-radius: var(--r-lg); }

/* ---------- Side cards: highest five, legend, look-up ---------- */
.atlas-card { background: color-mix(in oklab, var(--surface) 92%, transparent); border: 1px solid var(--border); border-radius: var(--r-lg); padding: .85rem 1rem; box-shadow: var(--shadow-2); }
.atlas-card-title { font-family: var(--font-ui); font-size: .75rem; font-weight: 600; color: var(--ink-2); letter-spacing: .02em; }
.atlas-card-sub { font-family: var(--font-data); font-size: .6875rem; color: var(--muted); margin-top: 2px; }
.atlas-top5 { margin: .6rem 0 .5rem; counter-reset: rank; }
.atlas-top5 li { counter-increment: rank; }
.atlas-top5 button {
  width: 100%; display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; text-align: left;
  background: none; border: 0; border-bottom: 1px solid var(--border); color: var(--ink); padding: 7px 0; font: 400 .8125rem/1.3 var(--font-ui); cursor: pointer;
}
.atlas-top5 li:last-child button { border-bottom: 0; }
.atlas-top5 button::before { content: counter(rank); font-family: var(--font-data); font-size: .6875rem; color: var(--muted); }
.atlas-top5 button:hover .atlas-top5-name, .atlas-top5 button:focus-visible .atlas-top5-name { color: var(--accent-text); text-decoration: underline; text-underline-offset: 3px; }
.atlas-top5-value { font-family: var(--font-data); color: var(--ink-2); }
.atlas-legend-bands { margin-top: .6rem; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; }
.atlas-legend-bands li { font-family: var(--font-data); font-size: .6875rem; color: var(--ink-2); text-align: center; line-height: 1.3; }
.atlas-swatch { display: block; height: 12px; border-radius: 2px; margin-bottom: 5px; border: 1px solid rgb(233 240 239 / 0.12); }
.atlas-swatch.b0 { background: var(--r0); } .atlas-swatch.b1 { background: var(--r1); } .atlas-swatch.b2 { background: var(--r2); } .atlas-swatch.b3 { background: var(--r3); } .atlas-swatch.b4 { background: var(--r4); }
.atlas-swatch.is-no-value { background: repeating-linear-gradient(45deg, var(--no-value-bg) 0 3px, var(--no-value-line) 3px 5px); }
.atlas-legend-ends { display: flex; justify-content: space-between; font-size: .6875rem; color: var(--muted); margin-top: 4px; }
.atlas-legend-note { display: flex; align-items: center; gap: .5rem; font-size: .72rem; color: var(--muted); margin-top: .45rem; line-height: 1.35; }
.atlas-legend-note .atlas-swatch { width: 14px; height: 10px; margin: 0; flex: none; }
.atlas-swatch-dot { flex: none; width: 10px; height: 10px; margin: 0 2px; border-radius: 50%; background: var(--r2); box-shadow: 0 0 0 1px var(--ink-2); }
.atlas-lookup label { display: block; font-size: .75rem; font-weight: 600; color: var(--ink-2); margin-bottom: .4rem; }
.atlas-lookup select {
  width: 100%; min-height: 40px; padding: .4rem .6rem; border-radius: var(--r-md);
  background: var(--surface-2); color: var(--ink); border: 1px solid var(--border-strong); font-size: .875rem;
}

/* ---------- Tooltip ---------- */
.atlas-tip {
  position: absolute; z-index: var(--z-tooltip); pointer-events: none; min-width: 190px; max-width: 250px;
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-md); box-shadow: var(--shadow-3);
  padding: 10px 12px; opacity: 0; transform: translateY(4px); transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-out);
}
.atlas-tip.is-on { opacity: 1; transform: none; }
.atlas-tip-name { font-family: var(--font-display); font-size: 1.0625rem; font-weight: 500; line-height: 1.25; }
.atlas-tip-value { font-family: var(--font-data); font-size: 1.375rem; margin-top: 4px; }
.atlas-tip-value small { font-size: .75rem; color: var(--muted); margin-left: 4px; }
.atlas-tip-band { font-size: .75rem; color: var(--ink-2); margin: 2px 0 8px; display: flex; align-items: center; gap: 6px; }
.atlas-tip-band .atlas-swatch { width: 12px; height: 12px; margin: 0; flex: none; }
@media (prefers-reduced-motion: reduce) { .atlas-tip { transition: none; } }

/* ---------- Responsive ---------- */
@media (max-width: 1240px) {
  .atlas-hero-inner { grid-template-columns: minmax(0, 1fr) 236px; grid-template-areas: "copy copy" "map side"; width: min(1200px, 100% - 3rem); padding-left: 0; }
  .atlas-copy { grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 2rem; align-items: start; }
}
@media (max-width: 860px) {
  .atlas-hero-inner { grid-template-columns: minmax(0, 1fr); grid-template-areas: "copy" "map" "side"; width: calc(100% - 2.25rem); }
  .atlas-copy { grid-template-columns: minmax(0, 1fr); }
  .atlas-side { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .atlas-card { box-shadow: none; }
}
@media (max-width: 560px) {
  .atlas-side { grid-template-columns: minmax(0, 1fr); }
  .lens-layers { grid-template-columns: minmax(0, 1fr); }
  .atlas-hero .btn { flex: 1 1 auto; }
}
