/* Catalogue (views/catalogue.js), Re-entries (views/reentries.js) and Beyond Earth orbit
   (views/beyond.js). */

/* ---- Catalogue: the headline numbers ------------------------------------------------------- */
.catalogue-overview { margin-bottom: var(--space-4); }
.catalogue-overview .skeleton { margin-bottom: var(--space-2); }
.tiles.catalogue-tiles { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); margin: 0; }
/* A tile whose number has a list of exactly those objects: the whole tile leads there, its label
   says so with an arrow, and it looks like its neighbours otherwise (equal weight). */
.catalogue-tiles .tile { position: relative; display: flex; flex-direction: column; }
/* Its own box at least 24 px high (WCAG 2.2, 2.5.8), though the whole tile leads there (::after). */
.catalogue-tiles .tile .label a.tile-link { padding: 0; min-height: 24px; color: var(--ink-2); text-decoration: none; }
.catalogue-tiles .tile .label a.tile-link::after { content: ""; position: absolute; inset: 0; border-radius: var(--radius); }
.catalogue-tiles .tile .label a.tile-link::before { content: "→"; float: right; margin-left: var(--space-2); color: var(--accent-ink); font-weight: 700; }
.catalogue-tiles .tile:has(.tile-link) { transition: border-color var(--dur-fast) var(--ease-out), background-color var(--dur-fast) var(--ease-out); }
.catalogue-tiles .tile:has(.tile-link:hover) { border-color: var(--field-border); background: var(--raised); }
.catalogue-tiles .tile:has(.tile-link:hover) .tile-link { color: var(--ink); text-decoration: underline; }
.catalogue-tiles .tile:has(.tile-link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.catalogue-tiles .tile .tile-link:focus-visible { outline: none; }

/* On a phone each tile is a line of the almanac: the label and the figure side by side, the note
   beneath, so the five fit in a screen and a half rather than three. */
@media (max-width: 520px) {
  .tiles.catalogue-tiles { gap: var(--space-2); }
  .catalogue-tiles .tile { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 0 var(--space-3); }
  .catalogue-tiles .tile .value { grid-row: 1; grid-column: 2; margin: 0; }
  .catalogue-tiles .tile .label { grid-row: 1; grid-column: 1; }
  .catalogue-tiles .tile .note { grid-column: 1 / -1; margin-top: var(--space-1); }
  .catalogue-tiles .tile .label a.tile-link::before { float: none; margin: 0 0 0 var(--space-1); }
  .catalogue-tiles .tile .label a.tile-link { display: inline-flex; flex-direction: row-reverse; justify-content: flex-end; gap: var(--space-1); }
}
@media (pointer: coarse) {
  .filters label.check { min-height: 44px; }
}

/* What the tiles leave out, and what the bars count. */
.count-notes ul { margin: 0 0 var(--space-6); padding-left: 18px; display: grid; gap: var(--space-1); font-size: var(--step--1); color: var(--ink-2); max-width: 90ch; }
.count-notes ul a { font-weight: 600; }
.catalogue-bars { margin-bottom: var(--space-3); align-items: stretch; }
.catalogue-bars > .card { margin: 0; }
.count-explainer { margin: 0 0 var(--space-8); font-size: var(--step--2); max-width: 90ch; }

/* Ranked bars: each row lists exactly what it counts. */
.bars { display: grid; gap: 2px; }
.bar-row {
  display: grid; grid-template-columns: minmax(110px, 160px) 1fr auto; align-items: center; gap: var(--space-3);
  min-height: 32px; margin: 0 calc(-1 * var(--space-2)); padding: 0 var(--space-2); border-radius: var(--radius-sm);
  font-size: var(--step--1); color: inherit; text-decoration: none;
}
a.bar-row:hover { background: var(--surface-2); }
a.bar-row:hover .bar-label { text-decoration: underline; }
.bar-row .track { height: 10px; border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.bar-row .fill { display: block; height: 100%; min-width: 2px; background: var(--series-1); border-radius: 0 var(--radius-xs) var(--radius-xs) 0; }
.bar-row .v { min-width: 56px; text-align: right; color: var(--ink); font-weight: 650; font-variant-numeric: tabular-nums; }

/* ---- Catalogue: finding an object ---------------------------------------------------------- */
.catalogue-find { margin-bottom: var(--space-5); }
.catalogue-find > h2 { margin-bottom: var(--space-4); }
.filters { display: grid; gap: var(--space-3) var(--space-4); }
.filter-more > summary {
  display: flex; align-items: center; gap: var(--space-2); min-height: 44px; list-style: none;
  font-size: var(--step--1); font-weight: 650; color: var(--ink);
}
.filter-more > summary::-webkit-details-marker { display: none; }
.filter-more > summary::before {
  content: ""; flex: none; width: 8px; height: 8px; margin: 0 6px 0 4px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform var(--dur) var(--ease-out);
}
.filter-more[open] > summary::before { transform: rotate(45deg); }
.filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3) var(--space-4); padding-top: var(--space-2); }
.filters .checks { display: flex; flex-wrap: wrap; gap: var(--space-2) var(--space-5); align-items: center; }
/* The search and the order first, side by side; the other choices beneath them. */
.filters { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 521px) {
  .filters { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); align-items: end; }
  .filters > .filter-more, .filters .checks { grid-column: 1 / -1; }
}
@media (min-width: 721px) {
  /* Wide enough for every choice at once: no fold. */
  .filter-more > summary { display: none; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); padding-top: 0; }
}
@media (min-width: 1100px) {
  .filter-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
/* The filters in force, each a chip that takes it off. */
.applied-filters { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--hairline); }
.applied-label { font-size: var(--step--2); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-2); }
.applied-filters .chips { margin: 0; padding: 0; list-style: none; }
button.filter-chip {
  min-height: 32px; padding: 0 var(--space-2) 0 var(--space-3); gap: var(--space-2); cursor: pointer; white-space: normal; text-align: left;
  font: inherit; font-size: var(--step--1); font-weight: 600; color: var(--ink); background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, var(--border));
}
/* A long search (or code from an address) is cut short (views/catalogue.js), but even that can be one
   unbroken word wider than a phone: it wraps anywhere rather than run off the row. */
.applied-filters .chips, .applied-filters .chips > li { min-width: 0; max-width: 100%; }
button.filter-chip { max-width: 100%; overflow-wrap: anywhere; }
button.filter-chip:hover { border-color: var(--accent); }
button.filter-chip .chip-cross { flex: none; color: var(--ink-2); }
button.filter-chip:hover .chip-cross { color: var(--ink); }
@media (pointer: coarse) { button.filter-chip { min-height: 44px; } }

/* ---- Catalogue: the results ---------------------------------------------------------------- */
.catalogue-results { container-type: inline-size; transition: opacity var(--dur) var(--ease-out); }
.catalogue-results.is-loading { opacity: 0.55; }
.results-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); margin: 0 0 var(--space-3); }
.results-count { margin: 0; font-size: var(--step--1); font-weight: 600; color: var(--ink-2); font-variant-numeric: tabular-nums; max-width: none; }
.results-caption { caption-side: top; text-align: left; padding: var(--space-3) var(--space-4) var(--space-2); font-size: var(--step--1); color: var(--ink-2); }
/* Ten columns in the page's width: heads may take two lines, long words wrap. */
.results-table th, .results-table td { padding-left: var(--space-2); padding-right: var(--space-2); }
.results-table th:first-child, .results-table td:first-child { padding-left: var(--space-4); }
.results-table th:last-child, .results-table td:last-child { padding-right: var(--space-4); }
.results-table thead th { padding-top: var(--space-3); padding-bottom: var(--space-3); white-space: normal; vertical-align: middle; line-height: 1.3; }
.results-table td { vertical-align: middle; }
.results-table td.cell-type, .results-table td.cell-owner, .results-table td.cell-orbit { white-space: normal; min-width: 88px; }
.results-table td.wrap.cell-name { min-width: 170px; }
.results-table .row-link { font-weight: 650; color: var(--ink); text-decoration: none; }
.results-table tr.link:hover .row-link { text-decoration: underline; }
/* A column that sorts: its head is a button with a mark that shows the order. */
.results-table th.sortable button { gap: 6px; color: var(--ink-2); }
.results-table th.sortable button:hover { color: var(--ink); }
.results-table th[aria-sort] button { color: var(--ink); }
.sort-icon { flex: none; }
.sort-icon path { fill: currentColor; opacity: 0.35; }
.sort-icon.asc .up, .sort-icon.desc .down { opacity: 1; }
.sort-icon.asc .down, .sort-icon.desc .up { opacity: 0.15; }
.height-note { max-width: 90ch; }

/* On a narrow screen each row is a card: the name first, then each figure under its column's name. */
@container (max-width: 760px) {
  .results-table, .results-table > tbody { display: block; }
  .results-table > thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .results-table tr {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: var(--space-2) var(--space-4);
    padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--hairline);
  }
  .results-table > tbody > tr:last-child { border-bottom: 0; }
  table.results-table td { display: block; min-width: 0; padding: 0; border: 0; white-space: normal; text-align: left; font-size: var(--step--1); line-height: 1.35; }
  table.results-table td.cell-name { grid-column: 1 / -1; min-width: 0; padding: 0; font-size: var(--step-0); }
  .results-table td[data-label]::before {
    content: attr(data-label); content: attr(data-label) / ""; display: block;
    font-size: var(--step--2); font-weight: 600; line-height: 1.3; color: var(--ink-2);
  }
  .results-table td.cell-status::before { margin-bottom: 2px; }
  .results-table > caption { display: block; }
}

/* ---- Re-entries ---------------------------------------------------------------------------- */
.reentries .page-head { margin-bottom: var(--space-5); }
/* The short answer, large, in ink; the caution right under it. */
.reentries .page-head .lead { color: var(--ink); font-size: var(--step-2); font-family: var(--font-display); font-weight: 500; line-height: 1.3; max-width: 40ch; }
.reentry-caution { margin: 0 0 var(--space-3); }
.reentry-recent { margin: 0 0 var(--space-8); color: var(--ink-2); max-width: var(--measure); }
.reentry-section { container-type: inline-size; }
.reentry-section > h2 { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2) var(--space-3); }
.section-count { font: 650 var(--step--1)/1.4 var(--font-text); color: var(--ink-2); font-variant-numeric: tabular-nums; }
.reentry-section > .secondary { max-width: var(--measure); margin: 0 0 var(--space-3); font-size: var(--step--1); }
.reentry-section .disclosure { margin-bottom: var(--space-4); }
.reentry-section .disclosure > summary { font-size: var(--step--1); }
.reentry-section .disclosure-body > p { font-size: var(--step--1); color: var(--ink-2); }
.reentry-section .empty { padding: var(--space-2) 0 0; text-align: left; margin: 0; }
.reentry-help { max-width: var(--measure); margin: 0 0 var(--space-4); }
.reentries th[scope="row"] { font-weight: 500; font-size: inherit; color: var(--ink); white-space: normal; min-width: 9rem; }
.reentries th[scope="row"] a { font-weight: 650; }
.reentries th[scope="row"] .sub { display: block; font-size: var(--step--2); color: var(--muted); font-weight: 400; }
.reentries td.wrap { min-width: 7rem; }
.reentries td .chip { white-space: normal; }
.reentries td .sub + .sub { margin-top: 2px; }

/* ---- Beyond Earth orbit -------------------------------------------------------------------- */
.beyond-page .page-head { margin-bottom: var(--space-5); }
.beyond-page .page-head .lead { color: var(--ink); font-size: var(--step-2); font-family: var(--font-display); font-weight: 500; line-height: 1.3; max-width: 44ch; }
.beyond-caution { margin: 0 0 var(--space-8); }
.beyond-section { container-type: inline-size; }
.beyond-table th[scope="row"] { font-weight: 650; font-size: inherit; color: var(--ink); white-space: normal; min-width: 10rem; }
.beyond-table th .sub { display: block; font-size: var(--step--2); font-weight: 400; color: var(--muted); }
.beyond-table td { white-space: normal; }
.beyond-rest h3 { margin: var(--space-6) 0 var(--space-1); }
.beyond-rest h2 + h3 { margin-top: 0; }
.beyond-rest h3 + .secondary { font-size: var(--step--1); margin-bottom: var(--space-2); }
.beyond-list { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr)); gap: var(--space-1) var(--space-6); font-size: var(--step--1); }
.beyond-list li { padding: var(--space-1) 0; border-bottom: 1px solid var(--hairline); }
.beyond-list a { display: inline-block; min-height: 24px; font-weight: 600; }
.beyond-rest .disclosure { margin-top: var(--space-2); }

@media (max-width: 640px) {
  .reentries .page-head .lead, .beyond-page .page-head .lead { font-size: var(--step-1); }
  .count-explainer { margin-bottom: var(--space-6); }
}
.beyond-list.described { grid-template-columns: minmax(0, 1fr); }
.beyond-table td.r { white-space: nowrap; }
/* Stacked into one block per row (table.stackable, narrow): every line starts at the left. */
@container (max-width: 900px) {
  .beyond-table td.r, .reentries table.stackable td.r { text-align: left; white-space: normal; }
}
