/* Population atlas (/analysis-population) — look validated 2026-11-02 (docs/prototypes/population-atlas/atlas-site-style.html).
   Site colours from styles.css; map classes in blue ending on --primary. */
.atlas {
    --atlas-ink: var(--dark, #212529);
    --atlas-ink-2: var(--body-text, #495057);
    --atlas-ink-3: #6c757d;
    --atlas-line: var(--border, #e0e0e0);
    --atlas-accent-soft: #e7eef5;
    --atlas-land: #e9ecef;
    --atlas-sea: #f1f4f7;
    --atlas-nodata: #c9ced3;
    --atlas-hl: var(--secondary, #D4AF37);
    --atlas-c0: #dce8f4;
    --atlas-c1: #a3c2e0;
    --atlas-c2: #5f91c4;
    --atlas-c3: #2d679f;
    --atlas-c4: var(--primary, #12436D);
    --atlas-bubble: #2d679f;
    padding: 1.5rem 0 2.5rem;
    color: var(--atlas-ink);
    font-size: 15px;
    line-height: 1.55;
}

.atlas-sr {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* National total */
.atlas-total {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    margin-bottom: 14px;
}
.atlas-total-num {
    font-size: clamp(28px, 4.4vw, 40px);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1;
    color: var(--primary);
    font-variant-numeric: tabular-nums;
}
.atlas-total-lab {
    font-size: 14px;
    color: var(--atlas-ink-2);
}

/* Controls */
.atlas-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 22px;
    align-items: center;
    padding: 14px 0;
    border-top: 1px solid var(--atlas-line);
    border-bottom: 1px solid var(--atlas-line);
}
.atlas-group {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.atlas-group > span {
    font-size: 12px;
    font-weight: 600;
    color: var(--atlas-ink-3);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.atlas-seg {
    display: inline-flex;
    background: var(--white);
    border: 1px solid var(--atlas-line);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.atlas-seg button {
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    border: 0;
    background: transparent;
    color: var(--atlas-ink-2);
    min-height: 40px;
    padding: 6px 14px;
    border-radius: 999px;
    cursor: pointer;
}
.atlas-seg button[aria-pressed="true"] {
    background: var(--primary);
    color: var(--white);
}
.atlas-seg button:focus-visible,
.atlas-play:focus-visible,
.atlas-more:focus-visible,
.atlas input[type=range]:focus-visible {
    outline: 2px solid var(--atlas-hl);
    outline-offset: 2px;
}
.atlas-year {
    flex: 1 1 280px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.atlas-play {
    flex: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1px solid var(--atlas-line);
    background: var(--white);
    color: var(--primary);
    cursor: pointer;
    display: grid;
    place-items: center;
}
.atlas-play svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}
.atlas input[type=range] {
    flex: 1;
    min-width: 0;
    accent-color: var(--primary);
}
.atlas-year-val {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-size: 17px;
    min-width: 3.2ch;
}

/* Map + ranked list */
.atlas-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 20px;
    margin-top: 20px;
}
.atlas-mapcard {
    background: var(--white);
    border: 1px solid var(--atlas-line);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    min-width: 0;
}
#atlas-map {
    display: block;
    width: 100%;
    height: auto;
    background: var(--atlas-sea);
    touch-action: manipulation;
}
#atlas-map .shape { stroke: var(--white); stroke-width: 0.8; transition: fill 0.35s ease; }
#atlas-map .shape.hover { stroke: var(--atlas-hl); stroke-width: 2.2; }
#atlas-map .base { fill: var(--atlas-land); stroke: var(--white); stroke-width: 0.6; }
#atlas-map .bubble { fill: var(--atlas-bubble); fill-opacity: 0.82; stroke: var(--white); stroke-width: 1; transition: r 0.35s ease; }
#atlas-map .bubble.hover { stroke: var(--atlas-hl); stroke-width: 2.5; fill-opacity: 1; }
#atlas-map .isl { font-size: 13px; font-style: italic; fill: var(--atlas-ink-3); pointer-events: none; }
#atlas-map .bigyear { font-size: 64px; font-weight: 800; fill: var(--atlas-ink); opacity: 0.08; font-variant-numeric: tabular-nums; pointer-events: none; }

.atlas-legend {
    position: absolute;
    right: 16px;
    top: 104px;
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--atlas-line);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 12px;
    color: var(--atlas-ink-2);
    max-width: calc(100% - 32px);
}
.atlas-legend b { display: block; font-size: 12px; color: var(--atlas-ink); margin-bottom: 6px; font-weight: 600; }
.atlas-legend-row { display: flex; gap: 3px 8px; flex-wrap: wrap; }
.atlas-legend-row div { display: flex; flex-direction: column; gap: 3px; min-width: 54px; }
.atlas-legend-row i { display: block; height: 10px; border-radius: 2px; }
.atlas-legend-row span { font-variant-numeric: tabular-nums; white-space: nowrap; }
.atlas-bubbles { display: flex; align-items: flex-end; gap: 14px; }
.atlas-bubbles div { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.atlas-bubbles i { display: block; border-radius: 50%; background: var(--atlas-bubble); opacity: 0.82; }

.atlas-tip {
    position: absolute;
    pointer-events: none;
    background: var(--atlas-ink);
    color: var(--white);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.4;
    min-width: 190px;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
    opacity: 0;
    transition: opacity 0.12s;
}
.atlas-tip .t { font-weight: 700; font-size: 14px; }
.atlas-tip .p { opacity: 0.75; font-size: 12px; margin-bottom: 6px; }
.atlas-tip dl { display: grid; grid-template-columns: auto auto; gap: 2px 14px; margin: 0; }
.atlas-tip dt { opacity: 0.75; }
.atlas-tip dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

.atlas-error {
    margin: 0;
    padding: 24px;
    color: var(--atlas-ink-2);
}

.atlas-rank {
    background: var(--white);
    border: 1px solid var(--atlas-line);
    border-radius: 12px;
    padding: 18px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.atlas-rank h2 { font-size: 16px; margin: 0; font-weight: 700; color: var(--primary); text-align: left; }
.atlas-rank-sub { font-size: 13px; color: var(--atlas-ink-2); margin: -8px 0 0; }
.atlas-rank ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; max-height: 520px; overflow: auto; }
.atlas-rank li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 4px 8px; align-items: center; padding: 6px; border-radius: 6px; }
.atlas-rank li.hover { background: var(--atlas-accent-soft); }
.atlas-rank .r { font-size: 12px; color: var(--atlas-ink-3); font-variant-numeric: tabular-nums; }
.atlas-rank .n { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.atlas-rank .v { font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.atlas-rank .bar { grid-column: 2 / 4; height: 4px; border-radius: 2px; background: var(--atlas-line); overflow: hidden; }
.atlas-rank .bar i { display: block; height: 100%; background: var(--primary); border-radius: 2px; transition: width 0.35s ease; }
.atlas-more {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    background: none;
    border: 0;
    min-height: 40px;
    padding: 4px 0;
    cursor: pointer;
    text-align: left;
}

/* Notes and sources */
.atlas-notes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.atlas-note {
    background: var(--white);
    border: 1px solid var(--atlas-line);
    border-radius: 12px;
    padding: 16px 18px;
    font-size: 14px;
    color: var(--atlas-ink-2);
}
.atlas-note h3 { font-size: 14px; margin: 0 0 6px; color: var(--atlas-ink); font-weight: 700; }
.atlas-note p { margin: 0; }
.atlas-sources {
    margin: 20px 0 0;
    font-size: 12.5px;
    color: var(--atlas-ink-3);
    line-height: 1.6;
}
.atlas-sources a { color: var(--primary); }

@media (max-width: 860px) {
    .atlas-main { grid-template-columns: 1fr; }
    .atlas-rank ol { max-height: none; }
}
@media (max-width: 520px) {
    #atlas-map .bigyear { font-size: 44px; }
    .atlas-legend { position: static; margin: 10px; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
    .atlas * { transition: none !important; }
}
