/* EclipseVision — SwarmSoft theme (swarmsoft.com): deep-space navy,
   neon cyan/violet accents, glass panels. WCAG 2.1 AA contrast. */

:root {
    --bg: #0d1330;
    --bg-2: #111a3f;
    --panel: rgba(255, 255, 255, 0.045);
    --panel-border: rgba(120, 160, 255, 0.22);
    --text: #eef2ff;          /* 15.9:1 on --bg  (AAA) */
    --text-dim: #b9c3e8;      /* 7.6:1 on --bg   (AA)  */
    --accent: #33e0ff;        /* neon cyan — 9.9:1 on --bg */
    --accent-2: #9b7bff;      /* violet   — 5.4:1 on --bg */
    --danger-strong: #ffd08a; /* 10.4:1 on --bg */
    --radius: 14px;
    --grad: linear-gradient(120deg, var(--accent), var(--accent-2));
}

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

html { scroll-behavior: smooth; }

body {
    background:
        radial-gradient(1200px 600px at 80% -10%, rgba(155, 123, 255, 0.18), transparent 60%),
        radial-gradient(900px 500px at -10% 30%, rgba(51, 224, 255, 0.10), transparent 55%),
        var(--bg);
    color: var(--text);
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
    line-height: 1.55;
    min-height: 100vh;
}

/* Dynamic font scaling: everything is rem-based, so OS/browser text-size
   settings scale the whole UI. */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--accent);
    color: #041022;
    padding: 0.5rem 1rem;
    z-index: 100;
    font-weight: 700;
}
.skip-link:focus { left: 0.5rem; top: 0.5rem; }

/* ---------- header ---------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    backdrop-filter: blur(12px);
    background: rgba(13, 19, 48, 0.82);
    border-bottom: 1px solid var(--panel-border);
}
.header-inner {
    max-width: 72rem;
    margin: 0 auto;
    padding: 0.75rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 0.6rem; font-size: 1.25rem; font-weight: 800; letter-spacing: 0.02em; }
.brand-eclipse {
    width: 1.4rem; height: 1.4rem; border-radius: 50%;
    background: radial-gradient(circle at 50% 50%, #0d1330 52%, transparent 54%),
                conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent));
    box-shadow: 0 0 14px rgba(51, 224, 255, 0.55);
}
.brand-accent { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }

.nav-list { display: flex; align-items: center; gap: 1.1rem; list-style: none; flex-wrap: wrap; }
.nav-list a { color: var(--text-dim); text-decoration: none; font-size: 0.95rem; }
.nav-list a:hover, .nav-list a:focus-visible { color: var(--accent); }

/* ---------- hero ---------- */
.hero { max-width: 72rem; margin: 0 auto; padding: 3.5rem 1.25rem 2rem; text-align: center; }
.hero h1 {
    font-size: clamp(1.8rem, 4.5vw, 3rem);
    font-weight: 800;
    background: var(--grad);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { color: var(--text-dim); max-width: 44rem; margin: 0.9rem auto 1.4rem; }
.hero-countdown {
    display: inline-block;
    font-variant-numeric: tabular-nums;
    font-size: 1.1rem;
    padding: 0.6rem 1.2rem;
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    background: var(--panel);
}
.hero-countdown strong { color: var(--accent); }

/* ---------- panels ---------- */
main { max-width: 72rem; margin: 0 auto; padding: 0 1.25rem 3rem; display: grid; gap: 1.5rem; }
.panel {
    background: var(--panel);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1.4rem;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel h2 { font-size: 1.3rem; }
.hint { color: var(--text-dim); font-size: 0.9rem; margin-bottom: 0.6rem; }
.empty-note { color: var(--text-dim); }

/* ---------- buttons & chips ---------- */
.btn {
    display: inline-block;
    background: var(--grad);
    color: #041022;
    font-weight: 700;
    font-size: 0.95rem;
    border: none;
    border-radius: 999px;
    padding: 0.5rem 1.1rem;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { filter: brightness(1.1); }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--accent); }
.btn:focus-visible, .chip:focus-visible, a:focus-visible, button:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

.filters { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.chip {
    background: transparent;
    color: var(--text-dim);
    border: 1px solid var(--panel-border);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-size: 0.88rem;
    cursor: pointer;
}
.chip.is-active { background: var(--grad); color: #041022; font-weight: 700; border-color: transparent; }

/* ---------- eclipse list ---------- */
.eclipse-list, .saved-list { list-style: none; display: grid; gap: 0.8rem; }
.eclipse-card {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem 1.1rem;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    background: var(--bg-2);
    cursor: pointer;
    width: 100%;
    text-align: left;
    color: var(--text);
    font: inherit;
}
.eclipse-card:hover, .eclipse-card:focus-visible { border-color: var(--accent); }
.badge {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    color: #041022;
    background: var(--accent);
}
.badge-total { background: linear-gradient(120deg, #ffd76a, #ff9a3d); }
.badge-annular { background: linear-gradient(120deg, #33e0ff, #4d9dff); }
.badge-partial { background: linear-gradient(120deg, #9b7bff, #c79bff); }
.badge-lunar { background: linear-gradient(120deg, #ff7ba9, #9b7bff); }
.eclipse-meta { color: var(--text-dim); font-size: 0.9rem; }
.eclipse-name { font-weight: 700; }
.eclipse-date { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 700; white-space: nowrap; }

/* ---------- scrollable timeline (virtualized) ---------- */
.timeline-toolbar {
    display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
    margin-bottom: 0.75rem;
}
.year-jump { display: flex; align-items: center; gap: 0.4rem; color: var(--text-dim); font-size: 0.85rem; }
.year-jump input {
    width: 6.5rem; background: var(--bg); color: var(--text);
    border: 1px solid var(--panel-border); border-radius: 8px;
    padding: 0.35rem 0.5rem; font: inherit; font-variant-numeric: tabular-nums;
}
.timeline-count { color: var(--text-dim); font-size: 0.85rem; margin-left: auto; font-variant-numeric: tabular-nums; }

.timeline {
    position: relative;
    height: min(62vh, 40rem);
    overflow-y: auto;
    overflow-x: hidden;
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    background: var(--bg-2);
    overscroll-behavior: contain;
}
.timeline:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.timeline-canvas { position: relative; width: 100%; }
/* Continuous timeline spine; the per-row node dots sit on it. */
.timeline-canvas::before {
    content: "";
    position: absolute; top: 0; bottom: 0; left: 5.25rem;
    width: 2px; background: linear-gradient(var(--accent), var(--accent-2));
    opacity: 0.35;
}

.tl-row {
    position: absolute; left: 0; right: 0; height: 66px;
    display: grid; grid-template-columns: 5.25rem 1.75rem 1fr;
    align-items: center;
    padding-right: 1rem;
    background: transparent; border: none;
    border-bottom: 1px solid rgba(120, 160, 255, 0.10);
    color: var(--text); font: inherit; text-align: left; cursor: pointer;
}
.tl-row:hover, .tl-row:focus-visible { background: rgba(51, 224, 255, 0.07); }
.tl-row.is-past { opacity: 0.7; }
.tl-row.is-selected { background: rgba(155, 123, 255, 0.16); box-shadow: inset 3px 0 0 var(--accent); }

.tl-date { text-align: right; padding-right: 0.7rem; line-height: 1.15; }
.tl-day { display: block; font-weight: 700; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.tl-year { display: block; color: var(--text-dim); font-size: 0.75rem; font-variant-numeric: tabular-nums; }

.tl-node { position: relative; height: 100%; }
.tl-node::before {
    content: ""; position: absolute; left: 0; top: 50%;
    width: 0.8rem; height: 0.8rem; border-radius: 50%;
    background: var(--bg-2); border: 2px solid var(--accent);
    transform: translate(-50%, -50%);
}
.tl-row.is-future .tl-node::before { border-color: var(--accent); }
.tl-row.is-past .tl-node::before { border-color: var(--text-dim); }
.tl-row.is-selected .tl-node::before { background: var(--accent-2); border-color: #fff; }

.tl-main { min-width: 0; display: flex; flex-direction: column; gap: 0.15rem; padding-left: 0.4rem; }
.tl-headline { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.tl-headline .badge { font-size: 0.64rem; padding: 0.2rem 0.5rem; }
.tl-title { font-weight: 600; font-size: 0.94rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-region { color: var(--text-dim); font-size: 0.8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tl-today {
    position: absolute; left: 0; right: 0; height: 0;
    border-top: 2px dashed var(--accent); z-index: 3; pointer-events: none;
}
.tl-today-pill {
    position: absolute; left: 5.25rem; top: 0;
    transform: translate(0.4rem, -50%);
    background: var(--accent); color: #041022;
    font-size: 0.66rem; font-weight: 800; letter-spacing: 0.03em;
    padding: 0.16rem 0.55rem; border-radius: 999px; white-space: nowrap;
    box-shadow: 0 0 10px rgba(51, 224, 255, 0.5);
}

/* ---------- detail fact grid ---------- */
.fact-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.5rem 0.8rem; }
.fact {
    display: flex; flex-direction: column; padding: 0.4rem 0.6rem;
    background: var(--bg-2); border: 1px solid var(--panel-border); border-radius: 8px;
}
.fact dt { color: var(--text-dim); font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.05em; }
.fact dd { font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-when { color: var(--accent); font-weight: 700; margin-left: 0.5rem; }

/* ---------- detail ---------- */
#detail { border-color: var(--accent-2); }
#detail-body { display: grid; gap: 0.8rem; margin-bottom: 1rem; }
.phase-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.phase-table th, .phase-table td { text-align: left; padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--panel-border); }
.phase-table th { color: var(--text-dim); font-weight: 600; font-size: 0.85rem; text-transform: uppercase; letter-spacing: 0.05em; }
.detail-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- map ---------- */
#map {
    height: min(60vh, 30rem);
    border-radius: var(--radius);
    border: 1px solid var(--panel-border);
    background: #0a0f28;
}
.leaflet-container { background: #0a0f28; font: inherit; }
.map-popup { font-size: 0.9rem; line-height: 1.4; }
.map-popup strong { font-size: 1rem; }

/* ---------- lite mode ---------- */
body.lite #map { display: none; }
.lite-timeline { list-style: none; display: grid; gap: 0.4rem; font-variant-numeric: tabular-nums; }
.lite-timeline li { padding: 0.45rem 0.7rem; border-left: 3px solid var(--accent); background: var(--bg-2); border-radius: 0 8px 8px 0; }

/* ---------- safety ---------- */
.safety-panel { border-color: rgba(255, 179, 71, 0.45); }
.safety-warning {
    background: rgba(255, 179, 71, 0.12);
    border: 1px solid rgba(255, 179, 71, 0.55);
    color: var(--danger-strong);
    border-radius: 10px;
    padding: 0.8rem 1rem;
    margin-bottom: 0.9rem;
}
.safety-list { margin-left: 1.2rem; display: grid; gap: 0.45rem; color: var(--text-dim); }
.safety-list strong { color: var(--danger-strong); }

/* ---------- modal ---------- */
.modal {
    position: fixed; inset: 0;
    /* Must beat Leaflet's internal stacking (panes/controls go up to
       z-index 1000 inside #map), otherwise the map covers the dialog. */
    z-index: 2000;
    background: rgba(5, 8, 22, 0.7);
    display: flex; align-items: center; justify-content: center;
    padding: 1rem;
}
.modal[hidden] { display: none; }
.modal-card {
    background: var(--bg-2);
    border: 1px solid var(--panel-border);
    border-radius: var(--radius);
    padding: 1.4rem;
    max-width: 32rem;
    width: 100%;
    display: grid;
    gap: 0.9rem;
}
.modal-card textarea {
    width: 100%;
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--panel-border);
    border-radius: 10px;
    padding: 0.7rem;
    font: inherit;
    resize: vertical;
}
.modal-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* ---------- saved ---------- */
.saved-list li {
    display: flex; justify-content: space-between; align-items: center; gap: 1rem;
    padding: 0.7rem 1rem; background: var(--bg-2);
    border: 1px solid var(--panel-border); border-radius: 10px;
}
.saved-list button { background: none; border: none; color: var(--text-dim); cursor: pointer; font-size: 1rem; }
.saved-list button:hover { color: var(--danger-strong); }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--panel-border); padding: 1.4rem; text-align: center; color: var(--text-dim); font-size: 0.85rem; }

/* ---------- responsive ---------- */
@media (max-width: 40rem) {
    .eclipse-card { grid-template-columns: 1fr; gap: 0.4rem; }
    .panel { padding: 1rem; }
    .tl-row { grid-template-columns: 4.4rem 1.4rem 1fr; }
    .timeline-canvas::before, .tl-today-pill { left: 4.4rem; }
    .timeline-count { margin-left: 0; }
}

/* ---------- motion ---------- */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    * { transition: none !important; animation: none !important; }
}
