/* Looked Up: same hand as sbaiii.com (Archivo + Plex Mono, graph paper, one accent for data), dark first. */

@font-face {
    font-family: 'Archivo';
    font-style: normal;
    font-weight: 400 800;
    font-display: swap;
    src: url('assets/fonts/archivo.woff2') format('woff2');
}

@font-face {
    font-family: 'Archivo Fallback';
    src: local('Helvetica Neue'), local('Helvetica'), local('Arial');
    size-adjust: 111.31%;
    ascent-override: 78.88%;
    descent-override: 18.87%;
    line-gap-override: 0%;
}

@font-face {
    font-family: 'IBM Plex Mono';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('assets/fonts/plex-mono-500.woff2') format('woff2');
}

:root {
    /* Dark is the default here (the portfolio is light-first). */
    --paper: #08090b;
    --paper-2: #101217;
    --paper-3: #171a21;
    --ink: #edeff2;
    --muted: #a3abb6;
    --faint: #8a929d;
    --rule: #1e2127;
    --accent: #6b93ff;
    --accent-on: #08090b;
    --accent-soft: rgba(107, 147, 255, 0.16);
    --land: #1a1e26;
    --land-lang: #252b36;
    --ramp-0: #26345c;
    --ramp-1: #6b93ff;
    --ramp-2: #d6e1ff;
    --planetary: #ffcf5c;
    --shadow: rgba(0, 0, 0, 0.6);

    --display: 'Archivo', 'Archivo Fallback', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --sans: 'Archivo', 'Archivo Fallback', 'Helvetica Neue', Helvetica, Arial, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

    --t-display: clamp(2.6rem, 6.4vw, 5rem);
    --t-h2: clamp(1.8rem, 3.6vw, 2.8rem);
    --t-h3: clamp(1.1rem, 1.6vw, 1.35rem);
    --t-lead: clamp(1.05rem, 1.4vw, 1.3rem);
    --t-body: clamp(0.95rem, 0.4vw + 0.85rem, 1.0625rem);
    --t-meta: 0.75rem;

    --gutter: clamp(1rem, 4vw, 3rem);
    --section-y: clamp(3.5rem, 9vh, 7rem);
    --max: 1440px;
    --fast: 0.18s cubic-bezier(0.32, 0.72, 0, 1);
}

[data-theme='light'] {
    --paper: #ffffff;
    --paper-2: #f5f6f8;
    --paper-3: #eceef2;
    --ink: #0a0b0d;
    --muted: #4f5560;
    --faint: #5f6672;
    --rule: #e4e6ea;
    --accent: #1b4dff;
    --accent-on: #ffffff;
    --accent-soft: rgba(27, 77, 255, 0.10);
    --land: #e9ecf1;
    --land-lang: #d9dee7;
    --ramp-0: #c7d4ff;
    --ramp-1: #4f74ff;
    --ramp-2: #0b2a99;
    --planetary: #a86a00;
    --shadow: rgba(10, 11, 13, 0.10);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 4.5rem; }

body {
    background: var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: var(--t-body);
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}

/* Graph-paper motif, as on sbaiii.com */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(to right, var(--rule) 1px, transparent 1px),
        linear-gradient(to bottom, var(--rule) 1px, transparent 1px);
    background-size: 5rem 5rem;
    opacity: 0.45;
    mask-image: radial-gradient(ellipse 120% 70% at 30% 0%, #000 15%, transparent 70%);
}

body > * { position: relative; z-index: 1; }
[hidden] { display: none !important; }

a { color: inherit; text-underline-offset: 0.18em; }
button, select, input { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 2px; }
::selection { background: var(--accent); color: var(--accent-on); }

.visually-hidden {
    position: absolute !important; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.visually-hidden-focusable:not(:focus) {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%);
}
.skip:focus {
    position: fixed; top: 0.5rem; left: 0.5rem; z-index: 200; padding: 0.5rem 0.8rem;
    background: var(--accent); color: var(--accent-on);
}

.display { font-family: var(--display); font-weight: 800; letter-spacing: -0.03em; line-height: 1; }
.meta {
    font-family: var(--mono); font-size: var(--t-meta); font-weight: 500;
    letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted);
}
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.h3 { font-size: var(--t-h3); font-weight: 700; letter-spacing: -0.01em; margin: 1.2rem 0 0.6rem; }
.help { color: var(--faint); font-size: 0.875rem; max-width: 60ch; }

/* Header */
.header {
    position: sticky; top: 0; z-index: 100;
    background: color-mix(in srgb, var(--paper) 86%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--rule);
}
.header__inner {
    max-width: var(--max); margin-inline: auto; padding: 0.7rem var(--gutter);
    display: flex; align-items: center; gap: 1rem;
}
.brand { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; font-weight: 800; letter-spacing: -0.02em; }
.brand__mark {
    width: 1.1rem; height: 1.1rem; border-radius: 50%;
    border: 2px solid var(--accent); box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 10px var(--accent);
}
.nav { display: none; gap: 1.2rem; margin-left: 1.5rem; }
.nav a { text-decoration: none; color: var(--muted); font-size: 0.9rem; }
.nav a:hover { color: var(--ink); }
.controls { margin-left: auto; display: flex; align-items: center; gap: 0.6rem; }
.langswitch { display: flex; border: 1px solid var(--rule); border-radius: 999px; padding: 2px; }
.langswitch button {
    font-family: var(--mono); font-size: 0.75rem; font-weight: 500; padding: 0.35rem 0.6rem;
    border-radius: 999px; color: var(--muted); min-width: 2.5rem; min-height: 2rem;
}
.langswitch button[aria-pressed='true'] { background: var(--accent); color: var(--accent-on); }
.theme { width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 1px solid var(--rule); display: grid; place-items: center; }
.theme__icon {
    width: 1rem; height: 1rem; border-radius: 50%;
    background: linear-gradient(90deg, var(--ink) 50%, transparent 50%); border: 1.5px solid var(--ink);
}

@media (min-width: 900px) { .nav { display: flex; } }

/* "Right now" strip (Phase 5): reserved height, so arriving data never shifts the page */
.livestrip { border-bottom: 1px solid var(--rule); background: color-mix(in srgb, var(--paper-2) 70%, transparent); }
.livestrip__inner { max-width: var(--max); margin-inline: auto; padding: 0.6rem var(--gutter) 0.5rem; height: 8.6rem; overflow: hidden; }
.livestrip__head { display: flex; align-items: center; gap: 0.55rem; height: 1.2rem; }
.pulse { flex: none; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: #ff5c5c; box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.6); animation: pulse 2s infinite; }
.livestrip.is-resting .pulse { background: var(--faint); animation: none; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0.55); } 70% { box-shadow: 0 0 0 0.6rem rgba(255, 92, 92, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 92, 92, 0); } }
/* fixed height: one scrollable row of items, one-line texts, so arriving data never moves the page (CLS) */
.livestrip__list { list-style: none; display: flex; flex-wrap: nowrap; gap: 1.4rem; overflow-x: auto; overflow-y: hidden;
    height: 3.5rem; margin: 0.35rem 0 0.15rem; scrollbar-width: thin; }
.livestrip__list li { flex: none; display: grid; align-content: start; width: min(17rem, 78vw); }
.livestrip__list strong, .livestrip__list span, .livestrip__state, .livestrip__note {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.livestrip__list strong { font-weight: 700; line-height: 1.3; }
.livestrip__list span { color: var(--muted); font-size: 0.8rem; line-height: 1.3; }
.livestrip__state { height: 1.1rem; font-size: 0.82rem; }
.livestrip__note { font-size: 0.76rem; height: 1rem; }
@media (max-width: 640px) { .livestrip__note { white-space: normal; height: 4rem; line-height: 1.3; } .livestrip__inner { height: 11.6rem; } }
.next { margin-top: 1.1rem; }
.next__title { margin-bottom: 0.4rem; }
.next__list { list-style: none; display: grid; gap: 0.25rem; margin-bottom: 0.3rem; }
.next__list span { color: var(--muted); }

/* Layout: content and a sticky map on wide screens; stacked on phones */
.layout {
    max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter);
    display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 clamp(1.5rem, 3vw, 3rem);
}
.layout__viz { padding-bottom: 1rem; }
@media (min-width: 1000px) {
    .layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); grid-template-rows: auto 1fr; }
    .hero, .layout__content { grid-column: 1; }
    .layout__viz { grid-column: 2; grid-row: 1 / 3; padding-top: clamp(1.5rem, 6vh, 5rem); }
    .layout__viz .viz { position: sticky; top: 4.5rem; }   /* beats the base .viz rule below */
}

/* Hero */
.hero { padding-block: clamp(1.5rem, 6vh, 5rem) clamp(2rem, 6vh, 4rem); display: flex; flex-direction: column; }
/* Phones: the hero reserves the first screen, so text arriving with the data never pushes the map (CLS). */
@media (max-width: 999px) {
    .hero { min-height: calc(100svh - 7.5rem); }
    .hero__actions { margin-top: auto; padding-top: 1.2rem; }
}
.hero__title { font-size: var(--t-display); margin: 0.8rem 0 1.2rem; max-width: 14ch; text-wrap: balance; }
.hero__label {
    font-family: var(--display); font-weight: 800; font-size: clamp(1.8rem, 5vw, 3.4rem);
    line-height: 1.05; letter-spacing: -0.03em; color: var(--accent); min-height: 1.1em;
}
.hero__label a { text-decoration: none; }
.hero__label a:hover { text-decoration: underline; }
.hero__desc { color: var(--muted); font-size: var(--t-lead); margin-top: 0.3rem; min-height: 0; }
.hero__brief { margin-top: 1rem; max-width: 52ch; color: var(--ink); line-height: 1.5; border-left: 2px solid var(--accent); padding-left: 0.9rem; }
.hero__brief:empty, .hero__desc:empty, .day-brief:empty, .briefing__about:empty { display: none; }
.hero__counter { font-size: clamp(1.2rem, 2.6vw, 1.8rem); font-weight: 700; margin-top: 0.6rem; min-height: 1.3em; }
.hero__sub { color: var(--muted); margin-top: 0.3rem; min-height: 1.5em; }
.hero__actions { margin-top: 1.2rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }
.updated { margin-top: 1.5rem; }
.skeleton { background: linear-gradient(90deg, var(--paper-2), var(--paper-3), var(--paper-2)); border-radius: 4px; max-width: 18ch; }

.btn {
    display: inline-flex; align-items: center; gap: 0.4rem; min-height: 2.6rem; padding: 0.5rem 1rem;
    border: 1px solid var(--rule); border-radius: 999px; background: var(--paper-2); font-size: 0.9rem;
}
.btn:hover { border-color: var(--accent); }
.btn--icon { width: 2.6rem; justify-content: center; padding: 0; flex: none; }
.btn--wide { margin-top: 1rem; width: 100%; justify-content: center; }
.btn--small { min-height: 2.2rem; padding: 0.3rem 0.8rem; font-size: 0.8rem; }

/* Sections */
.fig { padding-block: var(--section-y); border-top: 1px solid var(--rule); }
.fig__head { margin-bottom: clamp(1.5rem, 4vw, 2.5rem); }
.fig__title { font-size: var(--t-h2); font-weight: 800; letter-spacing: -0.035em; line-height: 1.02; margin: 0.6rem 0; }
.fig__standfirst { color: var(--muted); font-size: var(--t-lead); max-width: 46ch; line-height: 1.4; }

/* Scrubber */
.scrubber__bars { width: 100%; height: 56px; display: block; }
.scrubber__bars rect { fill: var(--ramp-0); }
.scrubber__bars rect.is-on { fill: var(--accent); }
.scrubber__row { display: flex; align-items: center; gap: 0.6rem; margin-top: 0.4rem; }
.scrubber__row input[type='range'] { flex: 1; accent-color: var(--accent); min-height: 2.6rem; }
.scrubber__head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0.3rem 1rem; }
.day-brief { margin-top: 0.8rem; max-width: 60ch; font-size: 1.02rem; }
.linkbtn { color: var(--accent); font-size: 0.85rem; text-decoration: underline; text-underline-offset: 0.18em; padding: 0.4rem 0; min-height: 2.4rem; }
.scrubber__out { margin-top: 0.4rem; font-family: var(--mono); font-size: 0.85rem; color: var(--muted); }
.scrubber__out output { color: var(--ink); }

.filters { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 1.2rem 0; }
.filters button {
    font-size: 0.82rem; padding: 0.4rem 0.8rem; min-height: 2.4rem; border-radius: 999px;
    border: 1px solid var(--rule); color: var(--muted);
}
.filters button[aria-checked='true'] { border-color: var(--accent); color: var(--ink); background: var(--accent-soft); }

/* Event cards */
.cards { list-style: none; display: grid; gap: 0.7rem; }
.card {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0.3rem 1rem;
    padding: 0.9rem 1rem; border: 1px solid var(--rule); border-radius: 10px; background: var(--paper-2);
}
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.card__title { font-size: 1.1rem; font-weight: 700; letter-spacing: -0.01em; line-height: 1.25; }
.card__title button { text-align: left; font-weight: inherit; }
.card__title button:hover { color: var(--accent); }
.card__desc { grid-column: 1 / -1; color: var(--muted); font-size: 0.9rem; margin-top: -0.2rem; }
.card__meta { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; color: var(--muted); font-size: 0.85rem; }
.card__links { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; font-size: 0.85rem; }
.card__links a { color: var(--accent); }
.spark { width: 120px; height: 36px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.spark line { stroke: var(--faint); stroke-dasharray: 2 2; vector-effect: non-scaling-stroke; }

.badge {
    display: inline-block; font-family: var(--mono); font-size: 0.68rem; font-weight: 500; letter-spacing: 0.1em;
    text-transform: uppercase; padding: 0.15rem 0.45rem; border-radius: 4px; border: 1px solid currentColor;
}
.badge--noticed { color: var(--muted); }
.badge--international { color: var(--accent); }
.badge--planetary { color: var(--planetary); }
.badge--archive { color: var(--muted); margin-left: 0.3rem; vertical-align: 0.1em; }
.badge--archive[hidden] { display: none; }
.badge--spreading { color: var(--accent-on); background: var(--accent); border-color: var(--accent); }
.card__forecast { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.3rem 0.9rem; font-size: 0.85rem; color: var(--ink); }
.card__forecast .fade { color: var(--muted); }
.forecast-note { margin-top: 0.8rem; }

/* FIG. 05 forecast */
.stats { display: grid; gap: 1rem 2rem; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); margin-bottom: 1.5rem; }
.stats div { border-top: 2px solid var(--accent); padding-top: 0.6rem; }
.stats dt { font-family: var(--display); font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.6rem); letter-spacing: -0.03em; line-height: 1; }
.stats dd { color: var(--muted); font-size: 0.88rem; margin-top: 0.4rem; }
.calib { max-width: 26rem; margin: 0 0 1.2rem; }
.calib__svg { width: 100%; height: auto; display: block; }
.calib__svg .axis { stroke: var(--rule); }
.calib__svg .diag { stroke: var(--faint); stroke-dasharray: 3 3; }
.calib__svg .pt { fill: var(--accent); fill-opacity: 0.85; }
.calib__svg .line { fill: none; stroke: var(--accent); stroke-width: 1.5; }
.calib__svg text { fill: var(--faint); font-family: var(--mono); font-size: 9px; }
.forecast-summary { max-width: 62ch; line-height: 1.55; }

/* Languages panel */
.field { display: grid; gap: 0.3rem; max-width: 22rem; }
select {
    min-height: 2.6rem; padding: 0.4rem 0.7rem; border-radius: 8px; border: 1px solid var(--rule);
    background: var(--paper-2);
}
.langpanel { display: grid; gap: 1rem 2rem; }
@media (min-width: 640px) { .langpanel { grid-template-columns: 1fr 1fr; } }
.mini { list-style: none; display: grid; gap: 0.45rem; counter-reset: mini; }
.mini li { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr); gap: 0.2rem 0.5rem; counter-increment: mini; }
.mini li::before { content: counter(mini); font-family: var(--mono); color: var(--faint); font-size: 0.8rem; padding-top: 0.15rem; }
.mini small { grid-column: 2; color: var(--muted); font-size: 0.8rem; }
.mini a { text-decoration: none; }
.mini a:hover { color: var(--accent); text-decoration: underline; }
.empty { color: var(--faint); }

/* Briefing */
.briefing__text { font-size: clamp(1.15rem, 2vw, 1.5rem); line-height: 1.45; max-width: 40ch; margin: 0.6rem 0 1.2rem; }
.briefing__about { color: var(--muted); margin: -0.6rem 0 1.2rem; }
.facts { list-style: none; display: grid; gap: 0.5rem; margin-bottom: 1rem; }
.facts li { padding-left: 1rem; border-left: 2px solid var(--accent); color: var(--muted); }

/* About */
.about__lines { padding-left: 1.4rem; display: grid; gap: 0.35rem; max-width: 62ch; }
.about__lines li::marker { font-family: var(--mono); color: var(--faint); }
.about__limits { padding-left: 1.2rem; display: grid; gap: 0.35rem; max-width: 62ch; color: var(--muted); }
.about__links { margin: 1.2rem 0 0.6rem; }
.about__live { margin: 1rem 0 0; max-width: 62ch; color: var(--muted); }
.about__links a { color: var(--accent); }

/* Map / globe */
.viz { position: relative; margin: 0; }
.viz__stage {
    aspect-ratio: 2 / 1; width: 100%; border: 1px solid var(--rule); border-radius: 12px;
    background: radial-gradient(ellipse at 50% 40%, var(--paper-2), var(--paper)); overflow: hidden;
}
.viz__stage.is-globe { aspect-ratio: 1 / 1; width: min(100%, calc(100svh - 12rem)); margin-inline: auto; }
.viz__stage svg { width: 100%; height: 100%; display: block; }
.viz__stage canvas { display: block; }
.country { fill: var(--land); stroke: var(--paper); stroke-width: 0.4; transition: fill 0.5s ease; }
.is-reset .country { transition: none; }
.country.is-lang { fill: var(--land-lang); }
.arc { fill: none; stroke: var(--planetary); stroke-width: 1.4; stroke-linecap: round; opacity: 0.85; }
.anchor { fill: var(--planetary); }
.viz__caption { display: grid; gap: 0.35rem; margin-top: 0.6rem; font-size: 0.82rem; color: var(--muted); }
.viz__now { color: var(--ink); font-weight: 600; }
.legend { display: inline-flex; align-items: center; gap: 0.5rem; font-family: var(--mono); font-size: 0.72rem; }
.legend__scale { position: relative; display: inline-block; width: 9rem; padding-bottom: 0.95rem; }
.legend__ramp { display: block; width: 100%; height: 0.5rem; border-radius: 2px; background: linear-gradient(90deg, var(--ramp-0), var(--ramp-1), var(--ramp-2)); }
.legend__ticks { position: absolute; left: 0; right: 0; top: 0.65rem; height: 0.9rem; }
.legend__ticks span { position: absolute; transform: translateX(-50%); font-size: 0.66rem; color: var(--faint); }
.legend__ticks span:first-child { transform: none; }
.legend__ticks span:last-child { transform: translateX(-100%); }
.viz__mode { position: absolute; top: 0.6rem; right: 0.6rem; }

/* Phones: a compact bottom nav replaces the header links (hidden below 900px) */
.bottomnav {
    position: fixed; inset: auto 0 0 0; z-index: 90; display: grid; grid-template-columns: repeat(5, 1fr);
    background: color-mix(in srgb, var(--paper) 92%, transparent); backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
    display: grid; place-items: center; min-height: 3.2rem; font-size: 0.74rem; text-decoration: none; color: var(--muted);
    letter-spacing: 0.01em;
}
.bottomnav a:hover, .bottomnav a:focus-visible { color: var(--ink); }
body { padding-bottom: calc(3.3rem + env(safe-area-inset-bottom)); }
@media (min-width: 900px) { .bottomnav { display: none; } body { padding-bottom: 0; } }

.footer { max-width: var(--max); margin-inline: auto; padding: 2rem var(--gutter) 3rem; border-top: 1px solid var(--rule); }
.footer a { color: var(--muted); }
.noscript { padding: 1rem var(--gutter); }

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    .pulse { animation: none; }
    .country { transition: none; }
}
