/* The watchlist page. Tokens and type follow docs/design-direction.md:
   one ground, one ink, the team blue only for the satellite's path and
   focus rings; flat panels told apart by lightness; square corners;
   nothing under 13px, no capitals or tracking. */

:root {
  --space: #05070A;
  --panel: #10151B;
  --raised: #1A2129;
  --ink: #E6EBF0;
  --muted: #8A96A3;
  --blue: #3C9DF5;
  --link-rest: color-mix(in srgb, var(--ink) 40%, transparent);
  --margin: 16px;
  --gutter: 16px;
  --control: 36px;
  --nav-h: calc(var(--nav-bar) + 1px); /* the sticky nav (assets/nav.css) and its 1px rule */
  --filters-h: var(--filters-measured, 60px); /* the sticky filter bar, measured by watchlist.js */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --t-hover: 180ms;
  --sans: "Jost", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}

@media (min-width: 600px) { :root { --margin: 24px; } }
@media (min-width: 1100px) { :root { --margin: 32px; --gutter: 24px; } }
@media (pointer: coarse) { :root { --control: 44px; } }
@media (max-height: 500px) { :root { --filters-h: 0px; } } /* a phone on its side: the filters don't stay */

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

/* Keeps what gets focus clear of the sticky nav. What sits below the filter
   bar adds that bar's height with scroll-margin (see .list, below). */
html { -webkit-text-size-adjust: 100%; scroll-padding-top: var(--nav-h); scroll-padding-bottom: 16px; }

body {
  margin: 0;
  background: var(--space);
  color: var(--ink);
  font: 400 16px/1.5 var(--sans);
  font-variant-numeric: tabular-nums;
  overflow-wrap: break-word;
}

a { color: var(--ink); text-decoration: underline; text-decoration-color: var(--link-rest); text-underline-offset: 3px; transition: text-decoration-color var(--t-hover) var(--ease-out); }
a:hover { text-decoration-color: var(--ink); }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
#main:focus { outline: 0; }

h1, h2, h3, p, ol, ul { margin: 0; }
ol, ul { padding: 0; list-style: none; }

.small { font-size: 13px; line-height: 1.45; letter-spacing: .01em; color: var(--muted); }
.name { white-space: nowrap; }

/* Read aloud, not shown */
.vh { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* As on the main site (site/assets/style.css) */
.skip { position: absolute; left: var(--margin); top: -100px; z-index: 50; padding: 8px 12px; background: var(--ink); color: var(--space); font-size: 14px; }
.skip:focus { top: 8px; }

/* -- nav ------------------------------------------------------------------ */

/* The site's nav (assets/nav.css): sticky here, with a rule under it. */
.top {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--space);
  border-bottom: 1px solid #1C242D;
}

/* -- intro ---------------------------------------------------------------- */

.page { padding: 32px var(--margin) 64px; }
.intro { max-width: 62ch; }
h1 { font-size: clamp(24px, 1rem + 1.2vw, 32px); font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; }
.lead { margin-top: 12px; font-size: 20px; line-height: 1.4; }
.status { margin-top: 12px; font-size: 13px; line-height: 1.45; letter-spacing: .01em; color: var(--muted); }
.status.ink { color: var(--ink); } /* the list is old enough that newer events are missing */
.notes:empty { display: none; }
.notes { margin-top: 16px; display: grid; gap: 8px; }
.notes p { max-width: 62ch; }
.notes button { margin-top: 8px; }

/* -- filters -------------------------------------------------------------- */

/* Stays under the nav. On a phone it's one row that scrolls sideways, so it
   doesn't take a quarter of the screen. */
.filters {
  position: sticky;
  top: var(--nav-h);
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 16px calc(-1 * var(--margin)) 0;
  padding: 8px var(--margin);
  background: var(--space);
}
.filters[hidden] { display: none; }
@media (max-width: 599px) {
  .filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; scroll-padding-inline: var(--margin); }
  .filters::-webkit-scrollbar { display: none; }
  .filters button { flex: none; }
  /* With more chips off the right edge, the row fades out there. It sits after the last chip, so
     scrolled to the end it covers none. */
  .filters::after {
    content: "";
    position: sticky;
    right: 0;
    flex: none;
    width: 48px;
    background: linear-gradient(to right, transparent, var(--space));
    pointer-events: none;
  }
}
@media (max-height: 500px) { .filters { position: static; } }

/* A phone: a shorter way in, so the first event shows with the intro, not a screen below it. The
   orbit's date gives way (each event says how old its orbit is by then). */
@media (max-width: 599px) {
  .page { padding-top: 16px; }
  .lead { margin-top: 8px; font-size: 16px; line-height: 1.45; }
  .status { margin-top: 8px; }
  .status-orbit { display: none; }
  .filters { margin-top: 12px; }
}

/* A phone on its side: the title beside the lead and the age line, and closer bars, so the first
   event starts in the top half of the screen. */
@media (max-height: 500px) and (orientation: landscape) {
  .page { padding-top: 12px; }
  .intro { display: grid; grid-template-columns: auto minmax(0, 62ch); column-gap: 24px; align-items: baseline; max-width: none; }
  .intro h1 { grid-column: 1; grid-row: 1 / span 3; }
  .intro .lead, .intro .status, .intro .notes { grid-column: 2; }
  .lead { margin-top: 0; font-size: 16px; line-height: 1.45; }
  .status { margin-top: 4px; }
  .status-orbit { display: none; }
  .filters { margin-top: 8px; padding-top: 4px; padding-bottom: 4px; }
}

.filters button, .btn {
  height: var(--control);
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: var(--panel);
  color: var(--muted);
  font: 500 16px/1 var(--sans);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  transition: background-color var(--t-hover) var(--ease-out), color var(--t-hover) var(--ease-out);
}
.filters button:hover, .btn:hover { background: var(--raised); color: var(--ink); }
.filters button[aria-pressed="true"] { background: var(--ink); color: var(--space); }
.filters .n { margin-left: 6px; font-weight: 400; }
/* A touch screen or a phone's size: at least 44 px to tap, though a chip or a footer link looks no
   bigger. A footer link keeps to one line, and its own words stay over a neighbour's 44 px. */
@media (pointer: coarse), (max-width: 599px), (max-height: 500px) {
  .filters button, .foot a { position: relative; }
  .filters button::after { content: ""; position: absolute; inset: min(0px, (var(--control) - 44px) / 2) 0; }
  .foot a { white-space: nowrap; }
  .foot a::after { content: ""; position: absolute; inset: calc(50% - 22px) 0; }
  .foot a::before { content: ""; position: absolute; inset: 0; z-index: 1; }
}
/* a secondary button, as across the site: raised grey, Ink text */
.btn { background: var(--raised); color: var(--ink); }
.btn:hover { background: color-mix(in srgb, var(--raised), var(--ink) 10%); }

/* -- the list: one compact row per event ---------------------------------- */

.list { display: grid; gap: 4px; grid-template-columns: minmax(0, 1fr); margin-top: 8px; }
.list, .item, .row { scroll-margin-top: var(--filters-h); }
.list a, .empty .btn, .later a, .how a, .foot a { scroll-margin-top: calc(var(--filters-h) + 8px); }

.item { background: var(--panel); }
.row-line { container: row / inline-size; }
.item.open .row-line { box-shadow: inset 3px 0 0 var(--ink); } /* the mark the site gives a selected row */
.row-grid { display: flex; flex-wrap: wrap; align-items: stretch; }
.row-h { flex: 1 1 100%; min-width: 0; font: inherit; }

/* Narrow: name, then time, then distance and light on one line. */
.row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) 14px;
  gap: 2px 12px;
  width: 100%;
  min-height: 44px;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-variant-numeric: tabular-nums;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--t-hover) var(--ease-out);
}
.row:hover { background: var(--raised); }
.row:focus-visible { outline-offset: -2px; }
.row .main { display: block; }
.row .small { display: block; }
.row .what .main { font-weight: 600; line-height: 1.4; }
.row .what { grid-column: 1 / 3; grid-row: 1; }
.row .icon { grid-column: 3; grid-row: 1; }
.row .when { grid-column: 1 / -1; grid-row: 2; display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; margin-top: 4px; }
.row .utc, .row .spare { display: none; } /* UTC is in what opens */
.row .close { display: contents; }
.row .close .main { grid-column: 1; grid-row: 3; margin-top: 4px; }
.row .light { grid-column: 2 / -1; grid-row: 3; margin-top: 4px; }
.row .close .small { grid-column: 1 / -1; grid-row: 4; }
.row .close .main, .row .light .main { font-size: 13px; line-height: 1.45; letter-spacing: .01em; }

/* Plus to open, minus to close, flat and square. */
.icon { position: relative; display: block; width: 14px; height: 14px; margin-top: 5px; }
.icon::before, .icon::after { content: ""; position: absolute; background: var(--muted); transition: background-color var(--t-hover) var(--ease-out); }
.icon::before { left: 0; right: 0; top: 6px; height: 2px; }
.icon::after { top: 0; bottom: 0; left: 6px; width: 2px; }
.row:hover .icon::before, .row:hover .icon::after,
.row[aria-expanded="true"] .icon::before { background: var(--ink); }
.row[aria-expanded="true"] .icon::after { display: none; }

/* The Orbit link: first in what opens, and from the medium row on, in the row. */
.orbit {
  display: none;
  flex: 0 0 100%;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: .01em;
}
.item.open .orbit { display: inline-flex; }

/* Medium: name, time, then distance over light. */
@container row (min-width: 640px) {
  .row-h { flex: 1 1 0; }
  .orbit, .item.open .orbit { display: inline-flex; flex: none; padding: 0 16px 0 4px; }
  .orbit .long { display: none; }
  .row { grid-template-columns: 14px minmax(0, 1.25fr) minmax(0, 1.2fr) minmax(0, 1fr); gap: 2px 16px; align-items: start; }
  .row .icon { grid-column: 1; grid-row: 1 / span 2; }
  .row .what { grid-column: 2; grid-row: 1 / span 2; }
  .row .when { grid-column: 3; grid-row: 1 / span 2; display: block; margin-top: 0; }
  .row .utc { display: inline; }
  .row .spare { display: block; }
  .row .close { display: block; grid-column: 4; grid-row: 1; }
  .row .close .main { margin-top: 0; font-size: 16px; line-height: 1.5; letter-spacing: 0; }
  .row .light { grid-column: 4; grid-row: 2; margin-top: 0; }
}

/* Wide: one column each. */
@container row (min-width: 900px) {
  .row { grid-template-columns: 14px minmax(0, 1.5fr) minmax(0, 1.15fr) minmax(0, .95fr) minmax(0, 1fr); }
  .row .close { grid-column: 4; grid-row: 1 / span 2; }
  .row .light { grid-column: 5; grid-row: 1 / span 2; }
  .row .light .main { font-size: 16px; line-height: 1.5; letter-spacing: 0; }
}

/* -- what a row opens ----------------------------------------------------- */

.detail { display: grid; gap: 16px; padding: 4px 12px 16px; }
.detail[hidden] { display: none; }
.pane-only { display: none; }
.fact-next { display: none; } /* the medium and wide rows already say it */
@media (max-width: 687px) { .fact-next { display: block; } } /* below that the row has no UTC */
@media (min-width: 760px) {
  .detail { grid-template-columns: clamp(280px, 30%, 520px) minmax(0, 1fr); gap: var(--gutter); padding: 8px 16px 20px 12px; }
}

.map { aspect-ratio: 3 / 2; background: var(--space); }
.map canvas { display: block; width: 100%; height: 100%; }

.body { display: grid; gap: 16px; align-content: start; min-width: 0; }
.meta { display: grid; gap: 2px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px 24px; margin: 0; }
.fact dt { font-size: 13px; line-height: 1.45; letter-spacing: .01em; color: var(--muted); }
.fact dd { margin: 0; min-width: 0; }
.fact dd .small { display: block; }
.facts .ink, .notes .ink { color: var(--ink); }

.links { display: flex; flex-wrap: wrap; gap: 4px 20px; font-size: 13px; line-height: 1.45; letter-spacing: .01em; }
.links a { display: inline-flex; align-items: center; min-height: 32px; font-weight: 500; }
@media (pointer: coarse) { .links a { min-height: 44px; } }

.more h3 { font-size: 13px; font-weight: 600; line-height: 1.45; letter-spacing: .01em; color: var(--muted); }
.passes { display: grid; gap: 8px; margin-top: 6px; }
/* One line each when there's room, wrapping when there isn't. */
.passes li { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 16px; }
.passes li > :nth-child(1) { flex: 0 0 11em; }
.passes li > :nth-child(2) { flex: 0 0 13em; }
.passes li > :nth-child(3) { flex: 1 1 15em; }

.empty { max-width: 62ch; margin-top: 24px; font-size: 20px; line-height: 1.4; }
.empty .btn { margin-top: 16px; }
.pane-hint { display: none; }

/* -- events with no pass, and the method -------------------------------- */

.later, .how { margin-top: 64px; max-width: 62ch; }
.later h2, .how h2 { font-size: 20px; font-weight: 600; line-height: 1.4; }
.later .small { margin-top: 4px; }
.later ul { display: grid; gap: 12px; margin-top: 16px; }
.later li .small { display: block; }
.how { margin-top: 48px; }
.how summary { display: inline-flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; list-style: none; scroll-margin-top: calc(var(--filters-h) + 8px); }
.how summary::-webkit-details-marker { display: none; }
.how summary .icon { margin-top: 0; }
.how summary:hover .icon::before, .how summary:hover .icon::after,
.how[open] summary .icon::before { background: var(--ink); }
.how[open] summary .icon::after { display: none; }
.how div { display: grid; gap: 12px; margin-top: 12px; }

.foot { padding: 0 var(--margin) 48px; display: grid; gap: 8px; }
.foot p { max-width: 80ch; font-size: 13px; line-height: 1.45; letter-spacing: .01em; color: var(--muted); }

.nojs { padding: 24px var(--margin); }

/* -- big monitors: the open row in a panel beside the list ----------------- */

/* The page narrows to make room, and the panel stays put while the list
   scrolls. Opening a row moves nothing, and the map can be large. */
@media (min-width: 1680px) {
  :root { --pane: min(40vw, 1500px); }
  .page, .foot { padding-right: calc(var(--margin) + var(--pane) + var(--gutter)); }
  .filters { margin-right: 0; padding-right: 0; }

  .detail, .pane-hint {
    position: fixed;
    top: calc(var(--nav-h) + 16px);
    right: var(--margin);
    z-index: 10;
    width: var(--pane);
    background: var(--panel);
  }
  .detail {
    max-height: calc(100vh - var(--nav-h) - 32px);
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    gap: 16px;
    overflow-y: auto;
    padding: 24px;
  }
  .pane-hint { display: block; padding: 24px; color: var(--muted); }
  .pane-hint[hidden] { display: none; }
  .detail-title.pane-only { display: block; font-size: 20px; font-weight: 600; line-height: 1.4; }
  .small.pane-only, .fact-next { display: block; }
  .map { width: 100%; max-height: 52vh; }
  .item.open .row-line { background: var(--raised); }
}

/* Very wide: two columns of rows, read down the first and then the second. */
@media (min-width: 3000px) {
  .list {
    grid-auto-flow: column;
    grid-template-rows: repeat(var(--rows, 12), auto);
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 16px;
  }
}

/* only ?motion=reduced stills the page (watchlist.js), as across the site, whatever the system asks */
.motion-reduced * { transition: none !important; }
