/* Last Night's Sky — editorial night-sky identity.
   Deliberately NOT the cme-tracker instrument panel: serif narration over real
   imagery, translucent glass over panel chrome, mono reserved for data values. */

:root {
  --bg: #08070d;
  --bg-2: #0d0b16;
  --ink: #e8e6f0;
  --muted: #8f8aa8;
  --faint: #565170;
  --line: rgba(232, 230, 240, 0.1);
  --glass: rgba(14, 12, 24, 0.78);
  --glass-heavy: rgba(11, 9, 19, 0.92);

  --accent: #7dd3fc;   /* supernova cyan */
  --accent-2: #a78bfa; /* violet */

  /* class semantics — the same color means the same thing everywhere:
     map markers, chips, light curves, list dots */
  --c-sn: #7dd3fc;
  --c-flare: #a78bfa;
  --c-mover: #fbbf24;
  --c-variable: #34d399;
  --c-weird: #f472b6;

  --serif: "Iowan Old Style", "Palatino Nova", Palatino, Georgia, "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--sans);
  min-height: 100vh;
}
body.page {
  background:
    radial-gradient(1200px 700px at 80% -10%, rgba(167, 139, 250, 0.08), transparent 60%),
    radial-gradient(900px 600px at 10% 110%, rgba(125, 211, 252, 0.05), transparent 60%),
    var(--bg);
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

.serif { font-family: var(--serif); }
.mono, .num { font-family: var(--mono); font-size: 0.92em; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }

/* ---------- header: a masthead, not a toolbar ---------- */
.masthead {
  display: flex; align-items: baseline; gap: 1.1rem; flex-wrap: wrap;
  padding: 1rem 1.4rem 0.9rem;
}
.masthead .brand {
  font-family: var(--serif); font-size: 1.35rem; letter-spacing: 0.01em;
  color: var(--ink); white-space: nowrap;
}
.masthead .brand em { color: var(--accent); font-style: italic; }
.masthead nav { display: flex; gap: 1.1rem; margin-left: auto; }
.masthead nav a { color: var(--muted); font-size: 0.9rem; }
.masthead nav a[aria-current="page"] { color: var(--ink); }
.masthead nav a:hover { color: var(--ink); text-decoration: none; }

/* overlay variant used on the map page */
.masthead.overlay {
  position: fixed; inset: 0 0 auto 0; z-index: 30;
  background: linear-gradient(rgba(8, 7, 13, 0.85), rgba(8, 7, 13, 0));
  padding-bottom: 1.6rem; pointer-events: none;
}
.masthead.overlay > * { pointer-events: auto; }

/* ---------- the sky map stage ---------- */
#skymap { position: fixed; inset: 0; z-index: 0; background: var(--bg); }
#skymap .aladin-logo-container { opacity: 0.55; } /* keep CDS attribution, quietly */
/* Aladin's coordinate/FoV readouts collide with the masthead and footer — off */
#skymap .aladin-location, #skymap .aladin-fov, #skymap .aladin-cooFrame,
#skymap .aladin-status-bar, #skymap .aladin-statusBar, #skymap .aladin-snackbar,
#skymap .aladin-popup-container { display: none; }

.map-ui { position: relative; z-index: 10; pointer-events: none; }
.map-ui > * { pointer-events: auto; }

/* headline strip — the daily sentence */
.headline {
  position: fixed; left: 1.4rem; right: min(1.4rem, 4vw); bottom: 1.2rem; z-index: 20;
  max-width: 44rem;
}
.headline .glass { padding: 0.9rem 1.2rem; }
.headline h1 {
  font-family: var(--serif); font-weight: 400; font-size: 1.22rem; line-height: 1.5;
  margin: 0;
}
.headline h1 .count { font-family: var(--mono); font-size: 0.95em; padding: 0 0.1em; }
.headline .sub { margin: 0.35rem 0 0; color: var(--muted); font-size: 0.83rem; }

/* glass card primitive */
.glass {
  background: var(--glass);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.45);
}

/* highlights rail */
.rail {
  position: fixed; top: 4.6rem; right: 1.2rem; bottom: 6.5rem; z-index: 20;
  width: min(21.5rem, calc(100vw - 2.4rem));
  display: flex; flex-direction: column;
}
.rail .glass { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.rail header {
  padding: 0.85rem 1.1rem 0.6rem;
  display: flex; align-items: baseline; justify-content: space-between; gap: 0.5rem;
}
.rail header h2 { font-family: var(--serif); font-weight: 400; font-size: 1.02rem; margin: 0; }
.rail ol { list-style: none; margin: 0; padding: 0 0.4rem 0.6rem; overflow-y: auto; }
.rail li { margin: 0; }
.rail li button {
  all: unset; box-sizing: border-box; /* all:unset re-defaults to content-box */
  display: block; width: 100%; cursor: pointer;
  padding: 0.55rem 0.7rem; border-radius: 10px;
}
.rail li button:hover, .rail li button:focus-visible { background: rgba(232, 230, 240, 0.06); }
.rail .ev-top { display: flex; align-items: center; gap: 0.5rem; }
.rail .ev-id { font-family: var(--mono); font-size: 0.8rem; color: var(--ink); }
.rail .ev-kind {
  font-size: 0.8rem; color: var(--muted); margin-left: auto; white-space: nowrap;
  max-width: 45%; overflow: hidden; text-overflow: ellipsis;
}
.rail .ev-sub { font-size: 0.78rem; color: var(--faint); margin-top: 0.1rem; padding-left: 1.05rem; }

.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; box-shadow: 0 0 8px currentColor; }
.dot.sn { color: var(--c-sn); background: var(--c-sn); }
.dot.flare { color: var(--c-flare); background: var(--c-flare); }
.dot.mover { color: var(--c-mover); background: var(--c-mover); }
.dot.variable { color: var(--c-variable); background: var(--c-variable); }
.dot.weird { color: var(--c-weird); background: var(--c-weird); }

/* context row: the norms sparkline linking to /stats */
.context {
  display: flex; align-items: center; gap: 0.7rem; margin-top: 0.65rem;
  font-family: var(--sans); font-size: 0.78rem; color: var(--muted);
  text-decoration: none;
}
.context:hover { color: var(--ink); text-decoration: none; }
.context canvas { flex: none; }
.context-more { color: var(--accent); white-space: nowrap; margin-left: auto; }

/* night-over-night delta badges in the rail */
.tag {
  display: inline-block; font-size: 0.64rem; letter-spacing: 0.06em;
  text-transform: uppercase; border-radius: 4px; padding: 0 0.4em;
  margin-right: 0.45em; border: 1px solid; vertical-align: 1px;
}
.tag.new { color: var(--c-sn); border-color: rgba(125, 211, 252, 0.45); }
.tag.bright { color: var(--c-variable); border-color: rgba(52, 211, 153, 0.45); }
.tag.peaked { color: var(--c-mover); border-color: rgba(251, 191, 36, 0.45); }
.tag.reclassified { color: var(--c-weird); border-color: rgba(244, 114, 182, 0.45); }

/* stats page: chart + table twin */
.chart-wrap { position: relative; }
.nightschart { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); cursor: pointer; display: block; }
.data-table { font-family: var(--sans); font-size: 0.84rem; border-collapse: collapse; margin-top: 0.8rem; min-width: 26rem; }
.data-table th { text-align: left; color: var(--faint); font-weight: 500; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.3rem 1.2rem 0.3rem 0; }
.data-table td { padding: 0.22rem 1.2rem 0.22rem 0; border-top: 1px solid var(--line); color: var(--muted); }
details > summary { cursor: pointer; margin-top: 1rem; }

/* the time machine: night navigation in the headline card */
.night-nav { display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap; margin-top: 0.65rem; }
.night-nav .chip { line-height: 1.4; }
.night-nav input[type="date"] {
  color-scheme: dark; background: transparent; color: var(--muted);
  font-family: var(--mono); font-size: 0.76rem;
}
.night-nav input[type="date"]:hover { color: var(--ink); }

/* map hover tooltip — follows the cursor, never intercepts it */
.map-tip {
  position: fixed; z-index: 26; pointer-events: none; animation: none;
  padding: 0.55rem 0.85rem; max-width: 17rem;
  font-family: var(--sans); font-size: 0.8rem; line-height: 1.45; color: var(--muted);
}
.map-tip .t-top { display: flex; align-items: center; gap: 0.45rem; margin-bottom: 0.15rem; }
.map-tip .t-id { font-family: var(--mono); font-size: 0.82rem; color: var(--ink); }
.map-tip .t-kind { margin-left: auto; padding-left: 0.6rem; white-space: nowrap; }
.map-tip .t-cta { color: var(--faint); font-size: 0.74rem; }
#skymap.picking { cursor: pointer; }

/* status line (degraded / cached / empty states speak plainly) */
.status { font-size: 0.8rem; color: var(--muted); }
.status.warn { color: var(--c-mover); }

/* ---------- article pages (event story, science, about) ---------- */
.sheet {
  max-width: 46rem; margin: 0 auto; padding: 1rem 1.3rem 4rem;
}
.article { font-family: var(--serif); font-size: 1.08rem; line-height: 1.75; }
.article h1 {
  font-weight: 400; font-size: 1.9rem; line-height: 1.3; margin: 1.2rem 0 0.4rem;
}
.article h2 { font-weight: 400; font-size: 1.35rem; margin: 2.4rem 0 0.6rem; }
.article .kicker {
  font-family: var(--sans); font-size: 0.8rem; letter-spacing: 0.12em;
  text-transform: uppercase; margin: 1.5rem 0 0;
}
.kicker.sn { color: var(--c-sn); } .kicker.flare { color: var(--c-flare); }
.kicker.mover { color: var(--c-mover); } .kicker.variable { color: var(--c-variable); }
.kicker.weird { color: var(--c-weird); }
.article .dek { color: var(--muted); font-size: 1.05rem; margin: 0.2rem 0 1.4rem; }
.article p { margin: 0 0 1.1rem; }
.article .aside {
  font-family: var(--sans); font-size: 0.88rem; color: var(--muted);
  border-left: 2px solid var(--line); padding: 0.15rem 0 0.15rem 1rem; margin: 1.4rem 0;
}

/* facts row: the mono zone */
.facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr));
  gap: 0.8rem; margin: 1.4rem 0; font-family: var(--sans);
}
.facts .fact { border: 1px solid var(--line); border-radius: 10px; padding: 0.6rem 0.8rem; }
.facts .label { font-size: 0.72rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.facts .value { font-family: var(--mono); font-size: 0.95rem; margin-top: 0.2rem; }

/* cutout figure */
.cutout { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); }
.cutout img { display: block; width: 100%; max-width: 100%; filter: saturate(0.9); }
.cutout .cross { position: absolute; left: 50%; top: 50%; width: 34px; height: 34px; transform: translate(-50%, -50%); pointer-events: none; }
.cutout .cross::before, .cutout .cross::after {
  content: ""; position: absolute; background: var(--accent); opacity: 0.9;
}
.cutout .cross::before { left: 50%; top: -6px; width: 1px; height: 12px; }
.cutout .cross::after { top: 50%; left: -6px; height: 1px; width: 12px; }
figcaption { font-family: var(--sans); font-size: 0.82rem; color: var(--muted); margin-top: 0.5rem; }

/* light curve canvas */
.lightcurve { width: 100%; border: 1px solid var(--line); border-radius: 14px; background: var(--bg-2); }

/* probability bars */
.probs { font-family: var(--sans); font-size: 0.88rem; margin: 1rem 0; }
.probs .row { display: grid; grid-template-columns: 11rem 1fr 3.4rem; gap: 0.7rem; align-items: center; padding: 0.28rem 0; }
.probs .bar { height: 6px; border-radius: 3px; background: rgba(232, 230, 240, 0.08); overflow: hidden; }
.probs .bar i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.probs .pct { font-family: var(--mono); font-size: 0.8rem; text-align: right; color: var(--muted); }

/* buttons */
.btn {
  display: inline-block; font-family: var(--sans); font-size: 0.88rem;
  color: var(--ink); background: rgba(232, 230, 240, 0.07);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.45rem 1rem;
  cursor: pointer;
}
.btn:hover { background: rgba(232, 230, 240, 0.13); text-decoration: none; }
.btn.primary { background: rgba(125, 211, 252, 0.14); border-color: rgba(125, 211, 252, 0.4); color: var(--accent); }

/* chips (class filters) */
.chips { display: flex; gap: 0.45rem; flex-wrap: wrap; }
.chip {
  font-family: var(--sans); font-size: 0.78rem; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.22rem 0.7rem;
  background: transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 0.4rem;
}
.chip[aria-pressed="true"] { color: var(--ink); background: rgba(232, 230, 240, 0.08); }

/* records grid */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 1rem; margin: 1.5rem 0; }
.cards .glass { padding: 1.1rem 1.2rem; }
.cards h3 { font-family: var(--serif); font-weight: 400; font-size: 1.05rem; margin: 0 0 0.3rem; }
.cards .big { font-family: var(--mono); font-size: 1.7rem; color: var(--accent); }

/* science page explainer canvases */
.demo { width: 100%; border-radius: 12px; border: 1px solid var(--line); background: var(--bg-2); }

/* footer */
.footer {
  font-family: var(--sans); font-size: 0.8rem; color: var(--faint);
  border-top: 1px solid var(--line); margin-top: 3rem; padding: 1.2rem 1.4rem 2rem;
  display: flex; gap: 1.2rem; flex-wrap: wrap;
}
.footer a { color: var(--muted); }
.map-ui .footer {
  position: fixed; left: 1.4rem; bottom: 0.15rem; z-index: 15;
  border: 0; margin: 0; padding: 0.3rem 0; background: transparent;
}

/* motion — sparing, and off for those who ask */
@keyframes fadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.glass { animation: fadeUp 0.5s ease both; }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* small screens: rail tucks under the map, headline hugs the bottom */
@media (max-width: 760px) {
  .rail { position: static; width: auto; margin: 58vh 0.8rem 0; max-height: none; }
  .rail .glass { max-height: 50vh; }
  .headline { position: static; margin: 0.8rem; max-width: none; }
  .map-ui .footer { position: static; padding: 0.6rem 1.4rem 1.2rem; }
  #skymap { position: fixed; height: 62vh; }
  .masthead.overlay { position: absolute; }
  body.map-page { overflow-x: hidden; }
}
