/* Palette/type matches astrotonight-docs' existing pages (see index.html) for
   a consistent AstroTonight web presence, extended with the app's system-blue
   accent and grouped-list card styling for a denser, data-driven layout. */

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  max-width: 640px;
  margin: 32px auto;
  padding: 0 20px 40px;
  line-height: 1.45;
  color: #1c1c1e;
}

a {
  color: #007aff;
}

.page-header h1 {
  font-size: 1.6em;
  margin-bottom: 2px;
}

.muted {
  color: #8e8e93;
}

.small {
  font-size: 0.85em;
}

.centered {
  text-align: center;
  padding: 40px 0;
}

.error {
  color: #ff3b30;
}

.card {
  background: rgba(120, 120, 128, 0.08);
  border-radius: 10px;
  padding: 14px 16px;
  margin-top: 16px;
}

.card h2 {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8e8e93;
  margin: 0 0 10px;
  font-weight: 600;
}

.row-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.filter-summary {
  margin-top: 14px;
  font-size: 0.85em;
  color: #8e8e93;
}

.target-row {
  display: block;
  padding: 8px 0;
  border-top: 1px solid rgba(120, 120, 128, 0.16);
  color: inherit;
  text-decoration: none;
}

.target-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.target-row:hover {
  background: rgba(120, 120, 128, 0.1);
}

.target-row .chevron {
  flex: 0 0 auto;
  font-size: 1.1em;
}

.target-row .header {
  font-size: 1em;
}

.target-row .secondary {
  color: #8e8e93;
}

.target-row .caption {
  font-size: 0.85em;
  color: #8e8e93;
  margin-top: 2px;
}

.target-row .truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.target-row .transit {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.back-link {
  text-decoration: none;
  font-size: 0.9em;
}

/* Tracked-targets reference list (targets.html) */
.filter-box {
  width: 100%;
  margin-top: 12px;
  padding: 9px 12px;
  font-size: 1em;
  color: inherit;
  border: 1px solid rgba(120, 120, 128, 0.3);
  border-radius: 8px;
  background: rgba(120, 120, 128, 0.06);
}

.catalog-row {
  padding: 8px 0;
  border-top: 1px solid rgba(120, 120, 128, 0.16);
}

.catalog-row:first-of-type {
  border-top: none;
  padding-top: 0;
}

.catalog-row .header {
  font-size: 1em;
}

.catalog-row .secondary {
  color: #8e8e93;
}

.catalog-row .caption,
.catalog-row .designations {
  margin-top: 2px;
}

.detail-header {
  margin-top: 8px;
}

.detail-header h1 {
  font-size: 1.4em;
  margin: 0 0 2px;
}

.detail-header .secondary {
  color: #8e8e93;
  font-weight: 400;
}

.info-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding: 4px 0;
  border-top: 1px solid rgba(120, 120, 128, 0.16);
  font-variant-numeric: tabular-nums;
}

.info-row:first-of-type {
  border-top: none;
}

.info-label {
  color: #8e8e93;
}

.info-value {
  text-align: right;
}

.alt-chart {
  display: block;
  width: 100%;
  height: auto;
  margin-top: 12px;
}

.chart-legend {
  margin: 6px 0 0;
}

/* Attribution/about page (about.html) — grouped blocks inside a .card,
   divided like the list rows elsewhere. */
.source {
  padding: 10px 0;
  border-top: 1px solid rgba(120, 120, 128, 0.16);
}

.source:first-of-type {
  border-top: none;
  padding-top: 0;
}

.source:last-of-type {
  padding-bottom: 0;
}

.source p {
  margin: 0 0 4px;
}

.source p:last-child {
  margin-bottom: 0;
}

.source-title {
  font-weight: 600;
}

.card > p {
  margin: 0 0 6px;
}

.card > p:last-child {
  margin-bottom: 0;
}

.card code {
  font-size: 0.95em;
}

.page-footer {
  margin-top: 3em;
  font-size: 0.85em;
  color: #8e8e93;
}

@media (prefers-color-scheme: dark) {
  body {
    background: #000;
    color: #f2f2f7;
  }
  a {
    color: #0a84ff;
  }
  .card {
    background: rgba(120, 120, 128, 0.16);
  }
  .target-row {
    border-top-color: rgba(120, 120, 128, 0.24);
  }
  .filter-box {
    border-color: rgba(120, 120, 128, 0.4);
    background: rgba(120, 120, 128, 0.16);
  }
  .catalog-row {
    border-top-color: rgba(120, 120, 128, 0.24);
  }
  .source {
    border-top-color: rgba(120, 120, 128, 0.24);
  }
}

/* Name, what this build is, who owns it -- the order an About box has used
   since long before any of this, and the same three lines on every one of
   these sites. */
.colophon { line-height: 1.5; margin-bottom: .7rem; font-size: .8rem; }
.colophon strong { font-size: .9rem; }

/* ---- The full site (2026-11-30): tabs, controls, the filter panel, the
   object image. Same palette and grouped-card look as above. ---- */

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px 16px;
}

.page-header h1 { margin: 0; }

nav.tabs {
  display: flex;
  gap: 4px;
  background: rgba(120, 120, 128, 0.12);
  border-radius: 9px;
  padding: 3px;
}

nav.tabs a {
  padding: 5px 12px;
  border-radius: 7px;
  font-size: 0.9em;
  text-decoration: none;
  color: inherit;
}

nav.tabs a.active {
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  font-weight: 600;
}

.button {
  font: inherit;
  font-size: 0.9em;
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: #007aff;
  color: #fff;
  cursor: pointer;
}

.button:disabled { opacity: 0.5; cursor: default; }
.secondary-button { background: rgba(120, 120, 128, 0.2); color: inherit; }
.button.destructive { background: none; color: #ff3b30; padding-left: 0; }

.icon-button {
  font: inherit;
  font-size: 1.5em;
  line-height: 1;
  padding: 0 10px;
  border: none;
  background: none;
  color: #007aff;
  cursor: pointer;
}

.icon-button:disabled { color: rgba(120, 120, 128, 0.4); cursor: default; }

.night .row-line { align-items: center; }
.night-name { font-weight: 600; font-size: 1.1em; }
.night .site-line { text-align: center; margin: 2px 0 0; }
.site-line { margin: 0 0 6px; }

.filter-summary {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.85em;
  color: #007aff;
  background: rgba(120, 120, 128, 0.08);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
}

.card-head { align-items: center; margin-bottom: 6px; }
.card-head h2 { margin: 0; }

.sort select {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid rgba(120, 120, 128, 0.3);
  border-radius: 6px;
  padding: 2px 4px;
}

.list-tools { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; }

/* NGC runs to 8,000 rows: let the browser skip laying out the ones off screen. */
.long-list .target-row { content-visibility: auto; contain-intrinsic-size: auto 52px; }

.target-row .count { flex: 0 0 auto; }
.flame { font-size: 0.8em; }

dialog.filters {
  width: min(560px, 94vw);
  max-height: 88vh;
  border: none;
  border-radius: 14px;
  padding: 16px 18px;
  color: inherit;
  background: #fff;
}

dialog.filters::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; font-size: 1.1em; }

dialog.filters fieldset {
  border: none;
  border-top: 1px solid rgba(120, 120, 128, 0.2);
  margin: 12px 0 0;
  padding: 10px 0 0;
}

dialog.filters legend {
  font-size: 0.75em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8e8e93;
  font-weight: 600;
  padding: 0;
}

.slider { margin: 8px 0; }
.slider label { display: block; font-size: 0.95em; }
.slider input { width: 100%; }
.check { display: block; margin: 6px 0; }

.site-card .coords label { display: inline-block; margin: 4px 12px 4px 0; }
.site-card .coords input {
  font: inherit;
  width: 9em;
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid rgba(120, 120, 128, 0.35);
  background: none;
  color: inherit;
}

.hero { position: relative; margin: 14px 0 0; }
.hero img { display: block; width: 100%; height: 260px; object-fit: cover; border-radius: 10px; }
.hero figcaption {
  position: absolute;
  right: 8px;
  bottom: 6px;
  font-size: 0.7em;
  color: rgba(255, 255, 255, 0.75);
}

.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; vertical-align: middle; }

@media (prefers-color-scheme: dark) {
  nav.tabs a.active { background: rgba(120, 120, 128, 0.36); box-shadow: none; }
  .button { background: #0a84ff; }
  .secondary-button { background: rgba(120, 120, 128, 0.3); }
  .icon-button, .filter-summary { color: #0a84ff; }
  .button.destructive { background: none; color: #ff453a; }
  .filter-summary { background: rgba(120, 120, 128, 0.16); }
  dialog.filters { background: #1c1c1e; }
}

/* Long one-line captions shrink and end in an ellipsis rather than widening
   the page; comma-joined identifier lists break anywhere. */
.row-line > * { min-width: 0; }
.target-row .truncate { flex: 1 1 auto; }
.break-anywhere { overflow-wrap: anywhere; }

/* Stage 2 (2026-11-30): rise and set pairs, the planets grid, the nights. */
.rise-sets { display: flex; gap: 22px; font-variant-numeric: tabular-nums; }
.rise-set .glyph { color: #ff9500; font-size: 0.9em; }
.moon-line { margin-top: 8px; }
.moon-line + .rise-sets .glyph { color: #8e8e93; }
.next-nights { margin-top: 10px; border-top: 1px solid rgba(120, 120, 128, 0.16); padding-top: 8px; }
.night-name { color: inherit; text-decoration: none; }
.planets { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px 18px; }
.planet .row-line { font-variant-numeric: tabular-nums; }
.optics { font-size: 0.75em; }
.night-row .check { color: #007aff; font-weight: 700; }
.moon-emoji { font-size: 1.1em; }
@media (prefers-color-scheme: dark) {
  .next-nights { border-top-color: rgba(120, 120, 128, 0.24); }
  .night-row .check { color: #0a84ff; }
}

/* The app card: on desktops with a mouse only. A phone can't scan its own
   screen, iPhone Safari shows Apple's banner instead, and Android visitors
   have the whole site without being sold an iPhone app. */
.app-card { display: none; }

@media (hover: hover) and (pointer: fine) and (min-width: 700px) {
  body[data-page="tonight"] .app-card {
    display: flex;
    gap: 18px;
    align-items: center;
    margin-top: 2.5em;
    padding: 14px 16px;
    border-radius: 10px;
    background: rgba(120, 120, 128, 0.08);
  }
  .app-card p { margin: 0 0 6px; }
  .app-card .qr { flex: 0 0 auto; border-radius: 6px; background: #fff; padding: 4px; }
  .app-card .badge { display: block; height: 40px; width: auto; margin-top: 4px; }
}

@media (prefers-color-scheme: dark) and (hover: hover) and (pointer: fine) and (min-width: 700px) {
  .app-card { background: rgba(120, 120, 128, 0.16); }
}

/* ---- Stage 3 (2026-11-30): the charts. ---- */

.chart-rows { margin-top: 12px; }
.chart-links { text-align: center; margin-top: 10px; }

.segmented { display: inline-flex; background: rgba(255,255,255,0.12); border-radius: 8px; padding: 2px; }
.segmented button { font: inherit; font-size: 0.85em; color: #fff; background: none; border: none; padding: 4px 14px; border-radius: 6px; cursor: pointer; }
.segmented button.on { background: rgba(255,255,255,0.28); font-weight: 600; }

.chip { font: inherit; font-size: 0.85em; padding: 4px 11px; border-radius: 8px; border: none; cursor: pointer;
  background: rgba(120,120,128,0.24); color: inherit; text-decoration: none; display: inline-block; }
.chip.on { background: #0a84ff; color: #fff; }
.link-button { font: inherit; background: none; border: none; color: #0a84ff; cursor: pointer; padding: 2px 6px; }

/* Sky View: dark, its background following the Sun. */
.sky-view { color: #fff; border-radius: 14px; padding: 14px; text-align: center; margin-top: 8px; transition: background 0.3s; }
.sky-view .readout { font-weight: 600; margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.sky-disc { display: block; width: 100%; aspect-ratio: 1; }
.slider-time { margin: 4px 0 0; font-weight: 500; font-variant-numeric: tabular-nums; }
.night-slider { width: 100%; }
.ticks { position: relative; height: 6px; margin: 0 7px; }
.ticks span { position: absolute; width: 2px; height: 6px; background: rgba(255,255,255,0.6); transform: translateX(-1px); }
.ticks span.transit-tick { background: #34c759; }
.sky-view .muted { color: rgba(255,255,255,0.6); }
.sky-view a { color: #64d2ff; }

/* The Sky Atlas. */
.atlas { margin-top: 8px; }
.atlas-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.atlas-head h1 { font-size: 1.3em; margin: 0; }
.overlays summary { cursor: pointer; color: #0a84ff; font-size: 0.9em; }
.overlays[open] { position: relative; }
.overlays[open] > label { white-space: nowrap; }
.atlas-chart { position: relative; margin-top: 8px; }
.atlas-chart canvas { display: block; width: 100%; height: min(70vh, 620px); border-radius: 12px; }
.atlas-chart .orient { position: absolute; right: 10px; bottom: 8px; font-size: 0.7em; color: rgba(255,255,255,0.6); }
.atlas-controls { margin-top: 10px; display: grid; gap: 8px; }
.atlas-controls .presets { display: flex; flex-wrap: wrap; gap: 6px; }
.rotation input { flex: 1; }
.field { display: block; margin: 6px 0; }
.field input, .field select { font: inherit; display: block; width: 100%; margin-top: 3px; padding: 5px 7px; border-radius: 7px;
  border: 1px solid rgba(120,120,128,0.35); background: none; color: inherit; }
.rig { align-items: center; }

/* The Planetarium: edge to edge, the sky filling the window under the header. */
.planetarium { width: 100vw; margin-left: calc(50% - 50vw); margin-top: 8px; }
.sky-stage { position: relative; height: 70vh; min-height: 380px; background: #000; overflow: hidden; }
.sky-stage > canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.sky-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.sky-button { font: inherit; font-size: 0.85em; color: #fff; background: rgba(28,28,30,0.7); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 16px; padding: 6px 12px; cursor: pointer; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.sky-button.on { background: rgba(10,132,255,0.85); }
.capsule { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); font: inherit; font-size: 0.8em; font-weight: 500;
  color: #fff; background: rgba(10,132,255,0.75); border: none; border-radius: 14px; padding: 6px 12px; cursor: pointer; white-space: nowrap; }
.compass-note { position: absolute; top: 50px; left: 50%; transform: translateX(-50%); font-size: 0.8em; color: #fff;
  background: rgba(0,0,0,0.6); border-radius: 12px; padding: 6px 12px; margin: 0; width: max-content; max-width: 90%; }
.sky-bottom { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 12px 10px; display: grid; gap: 8px;
  max-width: 640px; margin: 0 auto; }
.selection-card, .time-bar { color: #fff; background: rgba(28,28,30,0.72); border-radius: 16px; padding: 10px 12px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.selection-card { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.selection-card .muted { color: rgba(255,255,255,0.6); }
.card-actions { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.card-actions .chip { color: #fff; }
.time-bar .bar-row { align-items: center; margin-top: 4px; }
.night-bar { flex: 1; height: 44px; display: block; touch-action: none; cursor: pointer; }
.time-bar .icon-button { color: #0a84ff; }
.time-bar strong { font-variant-numeric: tabular-nums; font-size: 0.95em; }

@media (prefers-color-scheme: light) {
  .chip { background: rgba(120,120,128,0.16); }
  .atlas .chip.on, .chip.on { background: #007aff; color: #fff; }
}
.selection-card[hidden], .capsule[hidden], .compass-note[hidden] { display: none; }

/* Five tabs on a phone. */
@media (max-width: 480px) {
  .page-header h1 { font-size: 1.4em; }
  nav.tabs a { padding: 5px 8px; font-size: 0.84em; }
}

/* ---- Red night mode (js/night.js), as the app's: two layers over
   everything, color out then red in, on the dark palette. ---- */
.night-toggle { font: inherit; font-size: 1.15em; line-height: 1; background: rgba(120,120,128,0.14); color: inherit;
  border: none; border-radius: 50%; width: 34px; height: 34px; cursor: pointer; flex: 0 0 auto; }
.page-header .night-toggle { order: 2; margin-left: auto; }
.page-header nav.tabs { order: 3; }
/* The page's own pixels are recolored (the SVG filter js/night.js adds):
   brightness kept, all of it in red, the app's two layers in one step.
   Not layers over the page: iOS Safari draws what passes behind its floating
   bar without them, and tints its own bars from a layer's color. Dialogs
   sit in the top layer, outside the body, so they carry the filter too. */
html.red-night .page-header, html.red-night main > :not(.planetarium):not(.sky-view):not(.atlas),
html.red-night .planetarium > :not(.sky-stage), html.red-night .app-card, html.red-night footer,
html.red-night dialog { filter: url(#red-night); }
/* Safari doesn't run that filter on a canvas, and the planetarium runs past
   its reach, so the three charts take the app's own two layers inside their
   frames instead (not fixed to the screen, so neither Safari problem above). */
html.red-night .sky-stage, html.red-night .sky-view, html.red-night .atlas { position: relative; isolation: isolate; }
html.red-night .sky-stage::before, html.red-night .sky-stage::after,
html.red-night .sky-view::before, html.red-night .sky-view::after,
html.red-night .atlas::before, html.red-night .atlas::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 50; border-radius: inherit; }
html.red-night .sky-stage::before, html.red-night .sky-view::before, html.red-night .atlas::before {
  box-shadow: inset 0 0 0 200vmax gray; mix-blend-mode: saturation; }
html.red-night .sky-stage::after, html.red-night .sky-view::after, html.red-night .atlas::after {
  box-shadow: inset 0 0 0 200vmax #f00; mix-blend-mode: multiply; }
html.red-night { color-scheme: dark; }
html.red-night body { background: #000; color: #f2f2f7; }
/* Blue accents would come out dim red; white ones stay as bright as text. */
html.red-night a, html.red-night .link-button, html.red-night .icon-button, html.red-night .filter-summary,
html.red-night .overlays summary, html.red-night .night-row .check, html.red-night .time-bar .icon-button { color: #fff; }
html.red-night .button, html.red-night .chip.on, html.red-night .sky-button.on, html.red-night .capsule { background: #fff; color: #000; }
html.red-night .button.destructive { background: none; color: #fff; }
html.red-night input[type="range"], html.red-night input[type="checkbox"], html.red-night input[type="radio"] { accent-color: #fff; }

/* Step-by-step lists (install.html). */
.card .steps { margin: 0; padding-left: 1.3em; }
.card .steps li { margin: 6px 0; }
.card .steps + p { margin-top: 10px; }
/* About and Install: the heading under the back link, not beside it. */
.page-header:has(.back-link) { display: block; }
.page-header:has(.back-link) h1 { margin-top: 6px; }
.card h2.subgroup { margin: 14px 0 8px; padding-top: 10px; border-top: 1px solid rgba(120, 120, 128, 0.16); }

/* The time bar's step menu (1.4). */
.time-actions { display: flex; align-items: center; gap: 8px; }
.step-menu { font: inherit; font-size: 0.85em; color: #0a84ff; background: none; border: none; cursor: pointer; padding: 0; }
html.red-night .step-menu { color: #fff; }
