/* Today in Space — shared dark theme for the homepage and archive. */

:root {
    --bg:        #04060d;
    --surface:   rgba(255, 255, 255, 0.045);
    --surface-2: rgba(255, 255, 255, 0.08);
    --ink:       #eef0fa;
    --ink-soft:  #aeb5cc;
    --ink-faint: #737b96;
    --line:      rgba(255, 255, 255, 0.09);
    --accent:    #8f98ff;
    --accent-2:  #ff8fd1;

    --calm:  #3ddc97;
    --watch: #f5b041;
    --info:  #6fa8ff;
    --alert: #ff6b5b;

    color-scheme: dark;
}

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

html { background: var(--bg); }

body {
    color: var(--ink);
    font-family: 'Manrope', system-ui, sans-serif;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    /* Faint nebula glow under the starfield */
    background:
        radial-gradient(ellipse 60% 45% at 12% 8%,  rgba(88, 101, 242, 0.16), transparent 70%),
        radial-gradient(ellipse 50% 40% at 92% 22%, rgba(255, 105, 180, 0.10), transparent 70%),
        radial-gradient(ellipse 70% 50% at 50% 105%, rgba(61, 220, 151, 0.07), transparent 70%),
        var(--bg);
    background-attachment: fixed;
}

#starfield {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
}

a { color: var(--accent); }

.wrap {
    position: relative;
    z-index: 1;
    max-width: 960px;
    margin: 0 auto;
    padding: 56px 24px 64px;
}

/* ---- Header ---- */
.topnav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.topnav a { text-decoration: none; font-weight: 600; font-size: 14px; }
.topnav a:hover { text-decoration: underline; }

.masthead {
    text-align: center;
    padding-bottom: 28px;
    border-bottom: 1px solid var(--line);
    animation: rise .6s ease both;
}
.eyebrow {
    font-size: 12px;
    letter-spacing: 0.32em;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 600;
    margin-bottom: 10px;
}
.masthead h1 {
    font-family: 'Sora', sans-serif;
    font-weight: 800;
    font-size: clamp(40px, 7vw, 68px);
    letter-spacing: -0.02em;
    line-height: 1.05;
    background: linear-gradient(120deg, #ffffff 25%, var(--accent) 65%, var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}
.masthead .date { margin-top: 12px; color: var(--ink-faint); font-size: 15px; font-weight: 500; }

/* ---- Section labels ---- */
.section-label {
    font-family: 'Sora', sans-serif;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--ink-soft);
    margin: 48px 0 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* ---- APOD with ambient glow ----
   A blurred copy of the picture sits behind the frame, so the glow takes on
   each day's colors without tinting the whole page. */
.apod { animation: rise .6s ease .1s both; }
.apod-stage { position: relative; isolation: isolate; }
.apod-ambient {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(48px) saturate(1.8) brightness(1.1);
    opacity: 0.7;
    transform: scale(1.1);
    z-index: -1;
    pointer-events: none;
    animation: breathe 9s ease-in-out infinite alternate;
}
.apod-frame {
    position: relative;
    border-radius: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at 30% 40%, #1d2a52, transparent 60%),
        radial-gradient(circle at 75% 65%, #3a1d47, transparent 55%),
        #060b1e;
    aspect-ratio: 16 / 9;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
}
.apod-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.apod-frame iframe,
.apod-frame video { width: 100%; height: 100%; border: 0; display: block; background: #000; }
.apod-frame .placeholder { color: #8fa3d4; font-size: 14px; letter-spacing: 0.04em; }
.apod h2 {
    font-family: 'Sora', sans-serif;
    font-weight: 700;
    font-size: 26px;
    letter-spacing: -0.01em;
    margin: 28px 0 10px;
}
.apod p.explain { color: var(--ink-soft); font-size: 16px; max-width: 70ch; }
.apod-note {
    margin: 16px 0 0;
    padding: 10px 14px;
    border-radius: 10px;
    font-size: 14px;
    color: var(--watch);
    background: color-mix(in srgb, var(--watch) 10%, transparent);
    border: 1px solid color-mix(in srgb, var(--watch) 35%, transparent);
}
.apod .credit { margin-top: 10px; font-size: 13px; color: var(--ink-faint); font-style: italic; }

/* ---- Space weather cards ---- */
.cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    animation: rise .6s ease .2s both;
}
.card {
    --c: var(--info);
    border-radius: 16px;
    padding: 24px 20px;
    text-align: center;
    color: var(--c);
    border: 1px solid color-mix(in srgb, var(--c) 40%, transparent);
    background: linear-gradient(180deg, color-mix(in srgb, var(--c) 14%, transparent), rgba(255, 255, 255, 0.02));
    box-shadow: 0 0 40px -18px var(--c);
    transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover { transform: translateY(-3px); box-shadow: 0 0 50px -12px var(--c); }
.card.calm  { --c: var(--calm); }
.card.watch { --c: var(--watch); }
.card.info  { --c: var(--info); }
.card.alert { --c: var(--alert); }
.card .label {
    font-family: 'Sora', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    margin-bottom: 10px;
    color: var(--ink-soft);
}
.card .value { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 46px; line-height: 1; }
.card .value.text { font-size: 26px; }
.card .sub { margin-top: 8px; font-size: 13px; font-style: italic; opacity: 0.85; }

/* ---- People in space ---- */
.people .card { max-width: 320px; animation: rise .6s ease .2s both; }
/* With the list of people: number on the left, station groups on the right. */
.people.has-list .card {
    max-width: none;
    display: grid;
    grid-template-columns: minmax(180px, 240px) 1fr;
    gap: 8px 28px;
    align-items: center;
}
.people.has-list .card:hover { transform: none; }
.people.has-list .source { grid-column: 1 / -1; }
.people-groups { text-align: left; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.people-station {
    font-family: 'Sora', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    margin-bottom: 8px;
}
.people-chips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; }
.person {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border-radius: 10px;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink);
    min-width: 0;
}
.person .flags { display: flex; gap: 4px; flex: none; }
.person .flag { display: block; border-radius: 2px; }
.person-text { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.person-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.person-agency { font-size: 11px; color: var(--ink-faint); }
@media (max-width: 640px) {
    .people.has-list .card { grid-template-columns: 1fr; padding: 20px 14px; }
}
.card .source { margin-top: 12px; font-size: 11px; color: var(--ink-faint); }
.card .source .stale { color: var(--watch); }

/* ---- Kp forecast bars ---- */
.forecast { margin-top: 30px; animation: rise .6s ease .3s both; }
.forecast .section-label { margin-top: 0; }
.forecast .bars {
    display: flex;
    justify-content: space-around;
    align-items: flex-end;
    gap: 28px;
    height: 130px;
    padding: 0 12px;
}
.bar { flex: 1; max-width: 80px; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; }
.bar .num { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 14px; }
.bar .track { flex: 1; width: 100%; display: flex; align-items: flex-end; }
.bar .fill {
    width: 100%;
    background: linear-gradient(180deg, var(--accent-2), var(--accent));
    border-radius: 6px 6px 0 0;
    min-height: 6px;
    box-shadow: 0 0 22px -4px rgba(143, 152, 255, 0.7);
}
.bar .day { font-size: 13px; color: var(--ink-soft); font-weight: 500; }

/* ---- Live Sky ---- */
.sky { animation: rise .6s ease .35s both; }
.sky-panel {
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 30px 80px -40px rgba(0, 0, 0, 0.9);
}
.sky-map { height: 440px; background: #0a0f1f; }
.sky-readout {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    align-items: center;
    padding: 16px 18px;
    border-top: 1px solid var(--line);
}
.stat .k { display: block; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.stat .v { font-family: 'Sora', sans-serif; font-weight: 700; font-size: 17px; font-variant-numeric: tabular-nums; }
.chip {
    font-family: 'Sora', sans-serif;
    font-weight: 600;
    font-size: 13px;
    padding: 9px 16px;
    border-radius: 999px;
    border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    color: var(--ink);
    cursor: pointer;
    white-space: nowrap;
}
.chip:hover { background: color-mix(in srgb, var(--accent) 26%, transparent); }
.chip[aria-pressed="true"] { background: var(--accent); color: #0b0e1c; }
.chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sky-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 20px;
    align-items: center;
    padding: 12px 18px 16px;
    font-size: 13px;
    color: var(--ink-soft);
}
.sky-legend .sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.sky-legend .line { display: inline-block; width: 18px; height: 0; border-top: 2px solid #b7c0ff; vertical-align: 3px; margin-right: 6px; }
.sky-legend .status { margin-left: auto; color: var(--watch); }
.sky-note { margin-top: 10px; font-size: 13px; color: var(--ink-faint); }

/* Satellite markers (map + globe) */
.map-sat, .globe-sat { --sat-color: #b7c0ff; position: relative; }
.map-sat--hubble, .globe-sat--hubble { --sat-color: #ffc46b; }
.map-sat--tiangong, .globe-sat--tiangong { --sat-color: #5fd3e6; }
.map-sat__dot, .globe-sat__dot {
    position: absolute; left: 7px; top: 7px;
    width: 10px; height: 10px; border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 10px 3px var(--sat-color);
}
.map-sat__pulse, .globe-sat__pulse {
    position: absolute; left: 0; top: 0; width: 24px; height: 24px;
    border-radius: 50%;
    border: 2px solid var(--sat-color);
    animation: pulse 2s ease-out infinite;
}
.map-sat__label, .globe-sat__label {
    position: absolute; left: 26px; top: 3px;
    font-family: 'Sora', sans-serif; font-weight: 700; font-size: 12px;
    color: var(--sat-color);
    text-shadow: 0 1px 4px #000, 0 0 2px #000;
    white-space: nowrap;
}
.map-sat:not(.is-selected) .map-sat__pulse,
.globe-sat:not(.is-selected) .globe-sat__pulse { display: none; }

/* Globe markers are real buttons: reset button styling and center on the point. */
.globe-sat {
    width: 24px; height: 24px;
    margin: -12px 0 0 -12px;
    padding: 0; border: 0; background: none;
    cursor: pointer;
    pointer-events: auto;
}
.globe-sat:focus-visible { outline: 2px solid var(--sat-color); outline-offset: 4px; border-radius: 50%; }

/* 3D globe */
.sky-globe {
    height: 520px;
    cursor: grab;
    background: radial-gradient(circle at 50% 50%, rgba(122, 162, 255, 0.08), transparent 60%);
}
.sky-globe:active { cursor: grabbing; }
/* Shown while sky-loader.js fetches globe.gl; sky-globe.js removes it. */
.sky-loading {
    height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: 14px;
    color: var(--ink-faint);
    cursor: default;
}
.sky-globe[hidden], .sky-map[hidden] { display: none; }

/* Globe / Map toggle and satellite picker */
.sky-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 48px 0 18px; }
.sky-head .section-label { margin: 0; flex: 1; }
.view-toggle { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); }
.view-toggle button {
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: 13px;
    padding: 6px 16px; border-radius: 999px; border: 0;
    background: transparent; color: var(--ink-soft); cursor: pointer;
}
.view-toggle button[aria-selected="true"] { background: var(--accent); color: #0b0e1c; }
.view-toggle button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sat-pick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.sat-pick .chip[data-sat="hubble"] { --accent: #ffc46b; }
.sat-pick .chip[data-sat="tiangong"] { --accent: #5fd3e6; }
.sky-readout .sat-title {
    grid-column: 1 / -1;
    display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
}
.sky-readout .sat-title strong { font-family: 'Sora', sans-serif; font-size: 15px; }
.sky-hint { font-size: 12px; color: var(--ink-faint); }

/* Leaflet, dark */
.leaflet-container { font-family: 'Manrope', system-ui, sans-serif; background: #0a0f1f; }
.leaflet-control-attribution { background: rgba(4, 6, 13, 0.7) !important; color: var(--ink-faint) !important; }
.leaflet-control-attribution a { color: var(--ink-soft) !important; }
.leaflet-bar a, .leaflet-control-layers {
    background: rgba(12, 16, 32, 0.9) !important;
    color: var(--ink) !important;
    border-color: var(--line) !important;
}
.leaflet-control-layers-expanded { color: var(--ink); }

/* ---- Archive page ---- */
.picker {
    display: flex; gap: 12px; align-items: center; justify-content: center; flex-wrap: wrap;
    margin: 28px 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 20px;
}
.picker label { font-family: 'Sora', sans-serif; font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.picker input[type=date] {
    font-family: 'Manrope', sans-serif;
    font-size: 15px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--ink);
}
.picker button {
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: 14px;
    padding: 10px 22px; border: none; border-radius: 8px;
    background: var(--accent); color: #0b0e1c; cursor: pointer;
}
.picker button:hover { filter: brightness(1.1); }
.notice {
    text-align: center;
    padding: 50px 24px;
    color: var(--ink-faint);
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 14px;
}
.notice strong { color: var(--ink-soft); font-family: 'Sora', sans-serif; }
/* Previous/next day links. space-between keeps "Previous" on the left even when "Next" is hidden. */
.day-nav {
    display: flex; justify-content: space-between; gap: 12px;
    margin: -12px 0 20px;
}
.day-nav a {
    font-family: 'Sora', sans-serif; font-weight: 600; font-size: 13px;
    padding: 9px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink-soft);
    text-decoration: none;
    white-space: nowrap;
}
.day-nav a:hover { color: var(--ink); border-color: color-mix(in srgb, var(--accent) 55%, transparent); }
.day-nav a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.digest-date { text-align: center; color: var(--ink-faint); font-size: 15px; margin-top: 8px; }

/* ---- Empty state + footer ---- */
.empty { text-align: center; padding: 60px 24px; color: var(--ink-faint); }
.foot {
    margin-top: 56px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
    text-align: center;
    color: var(--ink-faint);
    font-size: 13px;
}
.foot .archive-link { font-family: 'Sora', sans-serif; font-weight: 600; font-size: 14px; text-decoration: none; }
.foot .archive-link:hover { text-decoration: underline; }

/* ---- Motion ---- */
@keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes breathe {
    from { opacity: 0.55; transform: scale(1.06, 1.1); }
    to   { opacity: 0.85; transform: scale(1.12, 1.2); }
}
@keyframes pulse {
    from { transform: scale(0.6); opacity: 1; }
    to   { transform: scale(2.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---- Small screens ---- */
@media (max-width: 720px) {
    .wrap { padding: 36px 16px 48px; }
    .sky-globe { height: 380px; }
    .cards { grid-template-columns: 1fr; }
    .sky-map { height: 320px; }
    .sky-readout { grid-template-columns: 1fr 1fr; }
    .sky-legend .status { margin-left: 0; }
}
