/* The catalogue (catalogue.js), after docs/design-direction.md §2 and §4:
   true black and flat. Separation by lightness only (no borders, rules or
   shadows), the selected state is Ink, the team blue is only the focus ring
   (from style.css). Tokens fall back to the direction's values until
   style.css defines --space, --panel, --raised, --ink and --muted. */

.cat {
  --c-ground: var(--space, #05070A);
  --c-panel: var(--panel, #10151B);
  --c-raised: var(--raised, #1A2129);
  --c-ink: var(--ink, #E6EBF0);
  --c-muted: var(--muted, #8A96A3);
  --c-under: color-mix(in srgb, var(--c-ink) 40%, transparent);

  --m: 32px;          /* outer margin */
  --gutter: 24px;
  --ctl-h: 36px;      /* control height; 44px on touch */
  --thumb-h: 72px;
  --strip-h: calc(var(--thumb-h) + 39px); /* a month label, a thumbnail and its bar */
  --info-w: 400px;
  --back-h: 0px;
  --head-h: 40px;     /* the page's heading, "Pictures from FrontierSat", and the gap under it */
  --dock-h: 190px;    /* the dock under the picture; catalogue.js measures it */
  /* the sides, clear of a phone's notch in landscape (viewport-fit=cover) */
  --m-l: max(var(--m), env(safe-area-inset-left, 0px));
  --m-r: max(var(--m), env(safe-area-inset-right, 0px));

  /* A picture in One fills its stage, up to twice its own size (640 x 480, or
     512 x 512 for the attitude camera); in Two and Four pictures are never
     shown larger than their own size. The stage is
     one Panel area, as tall as fits above the dock (up to 720px), the same
     in One, Two and Four so the dock doesn't move, with the pictures centred
     on it. On a short window Two and Four outgrow that, for
     pictures worth comparing, but never so far that the strip starts below the
     window (--view-room), with Filters open too. The whole
     catalogue is capped at a width where two pictures side by side still fit
     at 1x, and on very wide screens where four do (at the end of this file). */
  --view-max: 720px;
  --view-fit: clamp(240px, calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - var(--dock-h) - 48px), var(--view-max));
  /* as tall as leaves the strip's month labels and the top of its pictures on the screen */
  --view-room: calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - var(--dock-h) + var(--strip-h) - 64px);
  --view-h: var(--view-fit);
  --cap-h: 80px;      /* a compare caption: place; time and Remove; the status when not whole */
  --content-max: 1720px;

  /* The catalogue's ground reaches the bottom of the screen. */
  min-height: calc(100svh - var(--nav-h, 60px));
  background: var(--c-ground);
  color: var(--c-ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
}

.cat.has-back { --back-h: 56px; }

/* the stage for a 240px tall picture in Two, and 165px tall pictures in Four */
.cat[data-size="2"] { --view-h: max(var(--view-fit), min(calc(240px + var(--cap-h) + 49px), var(--view-room))); }
.cat[data-size="4"] { --view-h: max(var(--view-fit), min(calc(2 * (165px + var(--cap-h) + 1px) + 64px), var(--view-room))); }

.cat-nobr { white-space: nowrap; }

@media (max-width: 1099px) { .cat { --m: 24px; } }
@media (max-width: 599px) { .cat { --m: 16px; --gutter: 16px; --thumb-h: 56px; } }
@media (pointer: coarse) { .cat { --ctl-h: 44px; --cap-h: 106px; } }

.cat-in {
  max-width: calc(var(--content-max) + var(--m-l) + var(--m-r));
  margin: 0 auto;
  padding: 16px var(--m-r) 32px var(--m-l);
}

/* The page's own heading, light beside the picture's name */
.cat-page-title {
  margin: 0 0 12px;
  color: var(--c-ink);
  font-size: 20px;
  font-weight: 400;
  line-height: 28px;
  letter-spacing: 0;
}

.cat-small,
.cat-month {
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

.cat-muted,
.cat-small { color: var(--c-muted); }

/* Controls */

.cat-text-btn,
.cat-inline-btn {
  border: 0;
  border-radius: 0;
  padding: 0;
  background: none;
  color: var(--c-ink);
  font: inherit;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 4px;
  text-decoration-color: var(--c-under);
  cursor: pointer;
}

.cat-text-btn {
  display: inline-flex;
  align-items: center;
  min-height: var(--ctl-h);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.2;
}

.cat-text-btn:hover,
.cat-inline-btn:hover { text-decoration-color: currentColor; }

.cat-text-btn[aria-disabled="true"] {
  color: var(--c-muted);
  text-decoration: none;
  cursor: default;
}

/* A larger target on touch, without spreading the lines of text around it:
   44px tall, reaching further down than up, so it never covers the controls
   above the count. Text buttons are 44px wide at least. */
@media (pointer: coarse) {
  .cat-inline-btn { position: relative; }
  .cat-inline-btn::after {
    content: "";
    position: absolute;
    inset: -10px -6px -15px;
  }
  .cat-text-btn { justify-content: center; min-width: 44px; }
}

/* The way back to the globe: first on the page, kept in reach on phones. */

.cat-back-row { margin: 0 0 12px; }

.cat-back {
  display: inline-flex;
  align-items: center;
  height: 44px;
  padding: 0 16px;
  border: 0;
  border-radius: 0;
  background: var(--c-panel);
  color: var(--c-ink);
  font: 500 16px/1 var(--sans);
  cursor: pointer;
}
.cat-back:hover { background: var(--c-raised); }

.cat-missing,
.cat-notice {
  max-width: 62ch;
  margin: 0 0 12px;
}
.cat-notice { padding: 48px 0; }
.cat-notice code { font-family: var(--mono); font-size: 14px; }
.cat-notice .cat-text-btn { margin-left: 0.4em; }

/* Layout: the picture and the dock on the left, the facts on the right.
   The dock sits under the picture, so a long facts column never pushes it
   down or opens a gap between them. */

.cat-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--info-w);
  grid-template-rows: auto 1fr;
  grid-template-areas:
    "viewer info"
    "dock info";
  column-gap: var(--gutter);
  align-items: start;
}

/* The stage: one Panel area for One, Two and Four, the same height in all. */
.cat-viewer {
  grid-area: viewer;
  min-width: 0;
  width: 100%;
  height: var(--view-h);
  background: var(--c-panel);
}

/* One picture, whole, centred on the stage. The img carries the picture's
   own width and height; it shrinks (and keeps its shape, object-fit) when
   the stage is smaller, and beside the facts column (900px and wider) it
   also grows to fill a larger stage, up to twice its own size (--nat-w and
   --nat-h, set by catalogue.js), so a big screen isn't mostly empty Panel. */

.cat-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  touch-action: pan-y pinch-zoom;
}

.cat-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
@media (min-width: 900px) {
  .cat:not([data-fit="actual"]) .cat-img { /* "Actual size" (catalogue.js) keeps it at 1x */
    width: min(100%, var(--nat-w, 640px) * 2);
    height: min(100%, var(--nat-h, 480px) * 2);
  }
}

.cat[data-state="loading"] .cat-img,
.cat[data-state="loading"] .cat-actions { visibility: hidden; } /* in place, so nothing moves when they come */

.cat-fail {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  padding: 24px;
  background: var(--c-panel);
}
.cat-fail-text { margin: 0; }
.cat-frame.is-failed .cat-img { visibility: hidden; }

/* No picture to show: the filters let nothing through. */
.cat-none {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  align-content: center;
  justify-content: center;
  gap: 0 16px;
  height: 100%;
  min-height: 240px;
  margin: 0;
  padding: 24px;
}

/* Compare: two side by side, or two by two, centred on the stage as a group,
   each caption directly under its picture and starting at its left edge.
   No per-cell mats. A cell is as wide as the smallest of: the picture's own
   width (--nat-w), its share of the stage's width (--stage-w, measured by
   catalogue.js), and what the row's height allows (--cell-h x --ratio). */

.cat-compare {
  --pad-s: 24px;
  --col-gap: 24px;
  --cols: 2;
  --cell-h: calc(var(--view-h) - 2 * var(--pad-s) - var(--cap-h) - 1px);
  --cell-w: calc((var(--stage-w, 640px) - 2 * var(--pad-s) - (var(--cols) - 1) * var(--col-gap)) / var(--cols));
  display: grid;
  grid-template-columns: repeat(var(--cols), auto);
  align-content: safe center;
  justify-content: safe center;
  gap: 16px var(--col-gap);
  height: 100%;
  padding: var(--pad-s);
}
.cat-compare[data-size="4"] {
  --cell-h: calc((var(--view-h) - 2 * var(--pad-s) - 16px) / 2 - var(--cap-h) - 1px);
}

/* A short, wide window (a 1280 x 720 laptop): two rows of Four would push the strip
   off the screen, so the four sit in one row, on a stage like Two's. */
@media (min-width: 1200px) and (max-height: 860px) {
  .cat[data-size="4"] { --view-h: max(var(--view-fit), min(calc(240px + var(--cap-h) + 49px), var(--view-room))); }
  .cat-compare[data-size="4"] {
    --cols: 4;
    --cell-h: calc(var(--view-h) - 2 * var(--pad-s) - var(--cap-h) - 1px);
  }
}

.cat-cell {
  display: grid;
  justify-items: start;
  align-content: start;
  min-width: 0;
}

.cat-cell-pick {
  position: relative;
  display: block;
  width: min(var(--nat-w, 640px), var(--cell-w), var(--cell-h) * var(--ratio, 1.3333));
  aspect-ratio: var(--ratio, 4 / 3);
  border: 0;
  border-radius: 0;
  padding: 0;
  background: none;
  color: inherit;
  cursor: pointer;
}
.cat-cell.is-active .cat-cell-pick { cursor: default; }

.cat-cell-pick img {
  display: block;
  width: 100%;
  height: 100%;
}

/* An empty cell: a main-camera frame in Raised, so it reads on the stage. */
.cat-cell.is-empty .cat-cell-pick {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--c-raised);
}

.cat-cell-empty {
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.01em;
  text-align: center;
}

/* width 0 / min-width 100%: the caption takes its picture's width and
   never widens the column. */
.cat-cell-cap {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  column-gap: 16px;
  width: 0;
  min-width: 100%;
  min-height: var(--cap-h);
  padding: 8px 0 11px;
}
/* The active cell, the one the next pick fills: a 3px Ink bar under its caption. */
.cat-cell-cap::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
}
.cat-cell.is-active .cat-cell-cap::after { background: var(--c-ink); }

.cat-cell-place {
  flex: 1 0 100%;
  margin: 0;
  font-size: 16px;
  font-weight: 500;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.cat-cell-time,
.cat-cell-status {
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.cat-cell-time { color: var(--c-muted); }
.cat-cell-status { order: 3; flex: 1 0 100%; }
.cat-cell-remove { min-height: 0; font-size: 13px; letter-spacing: 0.01em; }

@media (pointer: coarse) {
  .cat-cell-remove { min-height: 44px; }
}

/* Beside the facts the stage's height is shared out on the caption being
   --cap-h tall, so it keeps to its lines; the whole text is in the facts. A
   narrow picture's caption may be wider than the picture. */
@media (min-width: 900px) {
  .cat-cell-cap {
    display: grid;
    grid-template-columns: minmax(0, auto) auto;
    justify-content: start;
  }
  .cat-compare[data-size="4"] .cat-cell-cap { min-width: max(100%, min(220px, var(--cell-w))); }
  .cat-cell-place,
  .cat-cell-status { grid-column: 1 / -1; }
  .cat-cell-place,
  .cat-cell-time,
  .cat-cell-status {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

/* Dock: a row of controls, then the filmstrip */

.cat-dock {
  grid-area: dock;
  min-width: 0;
  padding-top: 16px;
}

.cat-dock-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 24px;
  min-height: var(--ctl-h);
}

.cat-modes {
  display: flex;
  align-items: center;
  gap: 12px;
}

.cat-seg {
  display: inline-flex;
  background: var(--c-panel);
}

.cat-seg-btn {
  height: var(--ctl-h);
  min-width: 44px;
  padding: 0 14px;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--c-muted);
  font: 500 16px/1 var(--sans);
  cursor: pointer;
}
.cat-seg-btn:hover { background: var(--c-raised); color: var(--c-ink); }
.cat-seg-btn[aria-pressed="true"] { background: var(--c-ink); color: var(--c-ground); }

.cat-steps {
  display: flex;
  align-items: center;
  gap: 20px;
}

/* The count: a full-width row of its own under the controls, one line of a
   fixed height, so nothing under it moves when the pictures arrive or the
   numbers change. */
.cat-dock-end {
  flex: 1 1 100%;
  min-width: 0;
  margin-top: 4px;
}

.cat-count {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  height: 24px;
  margin: 0;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 19px;
  letter-spacing: 0.01em;
  white-space: pre;
}
.cat-count-text { color: var(--c-ink); }
.cat-count .cat-inline-btn { color: var(--c-ink); white-space: nowrap; }
.cat-filter-toggle { flex: none; margin-left: auto; }

.cat-filter-toggle[aria-expanded="true"] { text-decoration-color: currentColor; }

/* The filters: plain fields in one row, label above, Panel fill, no border. */

.cat .cat-filters {
  position: static;
  z-index: auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px 16px;
  margin: 12px 0 0;
  padding: 0;
  background: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  border: 0;
  font-size: 16px;
}

.cat .cat-filters .filter,
.cat .cat-filters .search {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 4px;
  min-width: 0;
  margin: 0;
}

.cat .cat-filters .filter-label {
  color: var(--c-muted);
  font-size: 13px;
  letter-spacing: 0.01em;
}

.cat .cat-filters .filter select {
  height: var(--ctl-h);
  max-width: 14em;
  padding: 0 30px 0 10px;
  background-color: var(--c-panel);
  background-position: right 11px center;
  color: var(--c-ink);
  font-size: 16px;
  text-align: left;
}
.cat .cat-filters .filter select:hover { background-color: var(--c-raised); text-decoration: none; }
.cat .cat-filters .filter select.is-set { color: var(--c-ink); font-weight: 600; }
.cat .cat-filters .filter select:disabled { color: var(--c-muted); background-color: var(--c-panel); }

.cat .cat-filters .search { flex: 1 1 200px; max-width: 360px; }
/* style.css gives the input flex: 1, which in this column would size it
   from its content (23px) instead of the control height. */
.cat .cat-filters .search input,
.cat .cat-filters .search input.is-set {
  flex: none;
  height: var(--ctl-h);
  padding: 0 10px;
  border: 0;
  background: var(--c-panel);
  font-size: 16px;
}
.cat .cat-filters .search input:hover { background: var(--c-raised); }
.cat .cat-filters .search input.is-set { font-weight: 600; }
.cat .cat-filters .search input::placeholder { color: var(--c-muted); }

/* The sheet's own heading and Done: phones only (below) */
.cat-sheet-head { display: none; }

/* Also show: dark frames and mostly missing pictures, a row of their own under
   the fields, each box with its reason under it. */
.cat-also {
  flex: 1 1 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 32px;
  min-width: 0;
  margin: 0;
  border: 0;
  padding: 0;
}
.cat-also > legend { float: left; width: 100%; margin: 0 0 4px; padding: 0; } /* float: a plain line above the boxes */
.cat-check { display: flex; flex-direction: column; min-width: 0; max-width: 360px; }
.cat-check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--ctl-h);
  font-size: 16px;
  font-weight: 500;
  line-height: 1.3;
  cursor: pointer;
}
.cat-check-box {
  flex: none;
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--c-ink);
  cursor: pointer;
}
.cat-check-n { color: var(--c-muted); font-weight: 400; }
.cat-check-why {
  padding-left: 30px;
  color: var(--c-muted);
  font-size: 13px;
  line-height: 1.45;
  letter-spacing: 0.01em;
}

/* Filters on a phone: a sheet over the bottom of the screen, so opening it moves
   nothing under it; the picture stays in view above it. Two even columns, each
   menu as wide as its column, so a longer choice doesn't move the next one. */
@media (max-width: 599px), (max-height: 500px) and (orientation: landscape) {
  .cat .cat-filters {
    position: fixed;
    top: auto; /* not style.css's sticky top */
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: end;
    gap: 12px;
    max-height: calc(100svh - var(--nav-h, 52px) - 48px);
    margin: 0;
    padding: 0 var(--m-r) calc(16px + env(safe-area-inset-bottom, 0px)) var(--m-l);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--c-panel);
  }
  .cat .cat-filters .filter select {
    width: 100%;
    max-width: none;
    field-sizing: fixed;
    background-color: var(--c-raised);
  }
  .cat .cat-filters .filter select:hover,
  .cat .cat-filters .search input:hover { background-color: #262F39; }
  .cat .cat-filters .search { grid-column: 1 / -1; max-width: none; }
  .cat .cat-filters .search input { background: var(--c-raised); }
  .cat-also {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
    gap: 0 12px;
  }
  .cat-also > legend { grid-column: 1 / -1; }
  .cat-check { max-width: none; }

  .cat-sheet-head {
    position: sticky;
    top: 0;
    z-index: 1;
    grid-column: 1 / -1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 48px;
    background: var(--c-panel);
  }
  .cat-sheet-title { margin: 0; font-size: 20px; font-weight: 600; line-height: 28px; outline: none; }
  .cat-sheet-done { padding: 0 0 0 16px; }
}

/* On its side, down the right instead, beside the picture. */
@media (max-height: 500px) and (orientation: landscape) {
  .cat .cat-filters {
    top: calc(var(--nav-h, 52px) + 1px);
    left: auto;
    width: min(380px, 45%);
    max-height: none;
  }
}

/* Filmstrip: every picture at its own ratio, one row, newest first,
   scrolling sideways inside its own row only. */

.cat-strip {
  display: flex;
  gap: 4px;
  margin: 12px 0 0;
  padding: 0 4px 8px;
  list-style: none;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--c-muted) transparent; /* says there is more to the right */
}

/* On touch the strip is swiped; a scrollbar there reads as a second
   selection bar under the thumbnails. */
@media (pointer: coarse) {
  .cat-strip { scrollbar-width: none; }
  .cat-strip::-webkit-scrollbar { display: none; }
}

.cat-strip-item {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
}

.cat-month {
  display: block;
  height: 20px;
  color: var(--c-muted);
  line-height: 20px;
  white-space: nowrap;
}

.cat-thumb {
  position: relative;
  display: block;
  margin: 4px 0 0;
  border: 0;
  border-radius: 0;
  padding: 0 0 7px;
  background: none;
  cursor: pointer;
}

.cat-thumb img {
  display: block;
  width: auto;
  height: var(--thumb-h);
  background: var(--c-panel);
}

/* The selected frame: a 3px Ink bar under it; hover shows the bar at 40%. */
.cat-thumb::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
}
/* The newest picture: "Latest" on its top-left corner (the button's label says it). */
.cat-thumb.is-latest::before {
  content: "Latest" / "";
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 1;
  padding: 0 5px;
  background: color-mix(in srgb, var(--c-ground) 82%, transparent);
  color: var(--c-ink);
  font-size: 12px;
  font-weight: 500;
  line-height: 18px;
  pointer-events: none;
}
.cat-thumb:hover::after { background: var(--c-under); }
.cat-thumb[aria-current="true"]::after { background: var(--c-ink); }

/* A thumbnail that didn't load: its flat frame, not a broken-image icon. */
.cat-thumb.is-failed {
  background: var(--c-panel);
  background-clip: content-box;
}
.cat-thumb.is-failed img {
  width: calc(var(--thumb-h) * 4 / 3);
  visibility: hidden;
}

/* Compare: the active cell's picture has the full bar, the others in cells
   have it at 40%, and hover shows nothing (it would read as a cell). */
.cat:not([data-size="1"]) .cat-thumb:hover::after { background: none; }
.cat:not([data-size="1"]) .cat-thumb[aria-pressed="true"]::after { background: var(--c-under); }
.cat:not([data-size="1"]) .cat-thumb.is-target::after { background: var(--c-ink); }

.cat-thumb-ghost {
  display: block;
  width: calc(var(--thumb-h) * 4 / 3);
  height: var(--thumb-h);
  margin: 4px 0 7px;
  background: var(--c-panel);
}

.cat-strip-note {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 16px;
  min-height: var(--strip-h);
  margin: 12px 0 0;
}

/* Info column */

.cat-info {
  grid-area: info;
  min-width: 0;
}

.cat-title {
  margin: 0;
  max-width: 26ch;
  color: var(--c-ink);
  font-size: clamp(24px, 1rem + 1.2vw, 32px);
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  outline: none;
}
.cat-title:focus-visible { outline: 2px solid var(--accent, #3C9DF5); outline-offset: 2px; }

.cat-empty-note {
  max-width: 62ch;
  margin: 12px 0 0;
  color: var(--c-ink);
}

/* The picture's own buttons (photo-info.js), then Pictures' two text buttons. */
.cat-actions-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
  margin-top: 8px;
}

.cat-ghost {
  display: inline-block;
  height: 0.85em;
  vertical-align: middle;
  background: var(--c-raised);
}

/* Narrower screens: picture, dock, then the facts, one column. */

@media (max-width: 899px) {
  .cat-in { max-width: none; padding-top: 12px; }

  .cat-grid {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas:
      "viewer"
      "dock"
      "info";
  }

  .cat-viewer { height: auto; }
  .cat-frame { aspect-ratio: 4 / 3; height: auto; max-height: 560px; }
  .cat-none { min-height: 200px; }

  /* The stage grows with its cells here: no height to share out. */
  .cat-compare,
  .cat-compare[data-size="4"] { --cell-h: 10000px; height: auto; }

  /* Comparing: the strip comes straight under the stage, so a picked
     thumbnail is seen landing in its cell. */
  .cat:not([data-size="1"]) .cat-dock { display: flex; flex-direction: column; }
  .cat:not([data-size="1"]) .cat-strip,
  .cat:not([data-size="1"]) .cat-strip-note { order: -1; margin: 0 0 8px; }

  .cat-info { margin-top: 32px; }

  /* The way back stays in reach while the page scrolls. */
  .cat-back-row {
    position: sticky;
    top: calc(var(--nav-h, 52px) + 1px); /* under the sticky site nav */
    z-index: 5;
    margin: -12px calc(-1 * var(--m-r)) 12px calc(-1 * var(--m-l));
    padding: 8px var(--m-r) 8px var(--m-l);
    background: var(--c-ground);
  }
}

/* A phone, either way up: One, Two and Four, Newer and Older, and Filters on one
   row, with "Show" only for screen readers. */
@media (max-width: 599px), (max-height: 500px) and (orientation: landscape) {
  .cat-dock { padding-top: 12px; }
  .cat-dock-row { gap: 4px 12px; }
  .cat-modes > .cat-small {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .cat-seg-btn { padding: 0 9px; }
  .cat-steps { gap: 8px; }
}

/* and the picture's name and time on the first screen */
@media (max-width: 599px) {
  .cat-info { margin-top: 24px; }

  /* 24px between rows, so the active bar doesn't read as a divider. */
  .cat-compare { --pad-s: 12px; --col-gap: 12px; row-gap: 24px; }
  .cat-compare[data-size="4"] .cat-cell-time { display: none; }
  .cat { --cap-h: 64px; }

  /* Two on a phone: one above the other, each caption beside its picture,
     and short enough that both and the strip are on the screen together. */
  .cat-compare[data-size="2"] {
    --cols: 1;
    --cell-w: calc(var(--stage-w, 358px) - 2 * var(--pad-s) - var(--side-cap));
    --cell-h: calc((100svh - var(--nav-h, 52px) - var(--back-h) - var(--head-h) - 12px - 2 * var(--pad-s) - 24px - 8px - var(--strip-h)) / 2);
  }
}

@media (max-width: 599px) and (pointer: coarse) {
  .cat { --cap-h: 85px; } /* Remove is 44px tall */
}

/* The narrowest phones: Filters moves down beside the count, on a second row as
   tall as Filters, so either can grow (two lines of count, "Filters (2)") and
   nothing moves. */
@media (max-width: 374px) {
  .cat-dock-end { order: 1; flex: 1 1 150px; margin-top: 0; }
  .cat-filter-toggle { order: 2; }
  .cat-count { height: auto; min-height: 24px; white-space: pre-wrap; }
  /* and a little less space around the strip, for the name and time */
  .cat-strip { margin-top: 8px; }
  .cat-info { margin-top: 16px; }
}

/* A phone on its side: nothing is taller than the screen. One picture has the
   whole height, Two and Four share what the strip leaves, in one row. */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) {
  .cat { --thumb-h: 56px; --cap-h: 64px; }
  .cat-frame {
    aspect-ratio: auto;
    height: calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - 24px);
    max-height: none;
  }
  .cat-compare { --pad-s: 6px; --col-gap: 12px; }
  .cat-compare,
  .cat-compare[data-size="4"] {
    --cell-h: calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - 12px - 2 * var(--pad-s) - 8px - var(--strip-h) - var(--cap-h) - 1px);
  }
  .cat-compare[data-size="4"] { --cols: 4; }
  .cat-compare[data-size="4"] .cat-cell-time { display: none; }
  .cat-compare[data-size="2"] {
    --cols: 2;
    --cell-w: calc((var(--stage-w, 640px) - 2 * var(--pad-s) - var(--col-gap)) / 2 - var(--side-cap));
    --cell-h: calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - 12px - 2 * var(--pad-s) - 8px - var(--strip-h));
  }
}

@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) and (pointer: coarse) {
  .cat { --cap-h: 85px; }
}

/* On its side the page's heading is for screen readers only: the nav says where this is. */
@media (max-height: 500px) and (orientation: landscape) {
  .cat { --head-h: 0px; }
  .cat-page-title {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* One picture on its side: the facts beside it, as on a bigger screen, and the picture as
   tall as leaves the row of controls under it on the screen. */
@media (max-width: 899px) and (max-height: 500px) and (orientation: landscape) {
  .cat[data-size="1"] .cat-grid {
    grid-template-columns: minmax(0, 1fr) minmax(260px, 38%);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "viewer info"
      "dock info";
  }
  .cat[data-size="1"] .cat-frame {
    height: calc(100svh - var(--nav-h, 52px) - 1px - var(--back-h) - 12px - 12px - var(--ctl-h) - 8px);
  }
  .cat[data-size="1"] .cat-info { margin-top: 0; }
}

/* Two on a phone, either way up: the caption beside the picture, which keeps
   the height for the picture. */
@media (max-width: 599px), (max-width: 899px) and (max-height: 500px) and (orientation: landscape) {
  .cat-compare[data-size="2"] {
    --side-cap: 112px;
    grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
    justify-content: stretch;
  }
  .cat-compare[data-size="2"] .cat-cell {
    grid-template-columns: auto minmax(0, 1fr);
    column-gap: 12px;
    justify-items: stretch;
  }
  .cat-compare[data-size="2"] .cat-cell-cap {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: flex-start;
    width: auto;
    min-width: 0;
    min-height: 0;
    padding: 0 0 11px;
  }
  .cat-compare[data-size="2"] .cat-cell-place,
  .cat-compare[data-size="2"] .cat-cell-status { flex: none; }
  .cat-compare[data-size="2"] .cat-cell-status { order: 0; }
}

/* Tall, wide screens: the strip becomes a contact sheet under the stage, so
   the pictures themselves fill the screen there. The dock stays in the
   picture's column, straight under the stage, however long the facts beside it
   run. The stage (all three modes alike) may grow to 1100px, which lets Two and
   Four come close to 1x; it leaves room for the dock's controls and the sheet's
   first row (--dock-top-h, measured by catalogue.js), not the whole sheet. */
@media (min-width: 1800px) and (min-height: 1100px) {
  .cat {
    --thumb-h: 96px;
    --view-max: 1100px;
    --view-fit: clamp(240px, calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - var(--dock-top-h, 80px) - var(--strip-h) - 48px), var(--view-max));
    --view-room: calc(100svh - var(--nav-h, 60px) - var(--back-h) - var(--head-h) - var(--dock-top-h, 80px) - 64px);
  }
  .cat-strip {
    flex-wrap: wrap;
    overflow: visible;
    row-gap: 8px;
  }
}

/* Very wide screens: a wider cap, and on the widest Four sits in one row,
   every picture at its own size. */
@media (min-width: 2400px) {
  .cat { --content-max: 2400px; --info-w: 480px; }
}
@media (min-width: 3000px) {
  .cat { --content-max: 3400px; --info-w: 560px; }
  .cat-compare[data-size="4"] {
    --cols: 4;
    --cell-h: calc(var(--view-h) - 2 * var(--pad-s) - var(--cap-h) - 1px);
  }
}
/* A 4K screen: larger thumbnails (they are 360px tall, so still not enlarged)
   fill the height under the stage. */
@media (min-width: 3000px) and (min-height: 1500px) {
  .cat { --thumb-h: 240px; --view-max: 1200px; }
}

/* ---- Mission ops (ops.js): a dropdown beside Filters, opening up from the controls over the
   picture; on a phone, a sheet over the bottom of the screen like Filters ---- */
.cat-dock-row { position: relative; }
.cat-ops-toggle { flex: none; margin-left: auto; }
.cat-ops-toggle:not([hidden]) + .cat-filter-toggle { margin-left: 0; }
.cat-ops-toggle[aria-expanded="true"] { text-decoration-color: currentColor; }
.cat-ops-count { color: var(--c-muted); }
.cat-ops {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 20;
  width: min(640px, 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 20px 16px;
  background: var(--c-panel);
  box-shadow: 0 0 0 1px var(--c-raised), 0 12px 32px rgba(0, 0, 0, 0.5);
  text-align: left;
}
.cat-ops[hidden] { display: none; }
.cat-ops-top {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0 4px;
  background: var(--c-panel);
}
.cat-ops-title { margin: 0; color: var(--c-ink); font-size: 1.125rem; font-weight: 600; line-height: 1.3; }
.cat-ops-title:focus { outline: none; }
.cat-ops-title:focus-visible { outline: 2px solid var(--c-accent, #3C9DF5); outline-offset: 2px; }
.cat-ops-intro { margin: 4px 0 0; color: var(--c-muted); font-size: 0.875rem; line-height: 1.45; }
.cat-ops-tools { margin: 6px 0 2px; }
.cat-ops-list { margin: 0; padding: 0; list-style: none; }
.cat-ops-item { padding: 12px 0; border-top: 1px solid var(--c-raised); font-size: 0.875rem; line-height: 1.45; }
.cat-ops-item p { margin: 0; }
.cat-ops-head-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 10px; }
.cat-ops-name { color: var(--c-ink); font-size: 1rem; font-weight: 600; }
a.cat-ops-name { text-decoration: underline; text-decoration-color: var(--c-raised); text-underline-offset: 3px; }
a.cat-ops-name:hover { text-decoration-color: currentColor; }
.cat-ops-tag { color: var(--c-muted); font-size: 0.8125rem; }
.cat-ops-file { color: var(--c-muted); overflow-wrap: anywhere; }
.cat-ops-missing { color: var(--c-ink); }
.cat-ops-note { color: var(--c-muted); }
@media (max-width: 599px), (max-height: 500px) and (orientation: landscape) {
  .cat-ops {
    position: fixed;
    top: auto;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 25;
    width: auto;
    max-height: calc(100svh - var(--nav-h, 52px) - 48px);
    padding: 0 var(--m-r) calc(16px + env(safe-area-inset-bottom, 0px)) var(--m-l);
  }
  .cat-ops-close, .cat-ops-tools .cat-text-btn { min-height: 44px; }
}
@media (min-width: 600px) and (min-height: 501px) {
  .cat-ops-close { display: none; } /* a click outside, Esc or Mission ops again puts it away */
}
/* each entry's tiny preview, left of its words */
.cat-ops-item { display: grid; grid-template-columns: 56px minmax(0, 1fr); align-items: start; gap: 0 12px; }
.cat-ops-thumb { display: block; width: 56px; height: 42px; margin-top: 3px; overflow: hidden; background: var(--c-raised); }
.cat-ops-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
button.cat-ops-thumb { border: 0; padding: 0; color: inherit; font: inherit; cursor: zoom-in; }
button.cat-ops-thumb:hover img { opacity: 0.85; }
button.cat-ops-thumb:focus-visible { outline: 2px solid var(--c-accent, #3C9DF5); outline-offset: 2px; }
/* the pop-up a preview opens: that picture by itself, small, the page dimmed behind it */
.cat-ops-lb {
  box-sizing: border-box;
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  margin: auto;
  border: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--c-panel, #10151B);
  color: var(--c-ink, #E6EBF0);
  box-shadow: 0 0 0 1px var(--c-raised), 0 16px 40px rgba(0, 0, 0, 0.55);
}
.cat-ops-lb::backdrop { background: rgba(5, 7, 10, 0.72); }
.cat-ops-lb-figure { margin: 0; }
.cat-ops-lb-img {
  display: block;
  width: 100%;
  height: auto;
  max-height: calc(100dvh - 140px);
  object-fit: contain;
  background: var(--c-raised) center / contain no-repeat;
}
.cat-ops-lb-caption { padding: 10px 56px 14px 16px; font-size: 0.875rem; line-height: 1.45; }
.cat-ops-lb-caption p { margin: 0; }
.cat-ops-lb-name { color: var(--c-ink); font-size: 1rem; font-weight: 600; }
.cat-ops-lb-file { color: var(--c-muted); overflow-wrap: anywhere; }
.cat-ops-lb-link {
  display: inline-block;
  margin-top: 4px;
  color: var(--c-ink);
  text-decoration: underline;
  text-decoration-color: var(--c-raised);
  text-underline-offset: 3px;
}
.cat-ops-lb-link:hover { text-decoration-color: currentColor; }
/* the × sits over the picture's top right corner, on its own dark disc so it shows on clouds */
.cat-ops-lb-close {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  padding: 0;
  background: rgba(5, 7, 10, 0.6);
  color: #E6EBF0;
  font: 400 26px/1 system-ui, sans-serif;
  cursor: pointer;
}
.cat-ops-lb-close:hover { background: rgba(5, 7, 10, 0.85); }
.cat-ops-lb-close:focus { outline: none; }
.cat-ops-lb-close:focus-visible { outline: 2px solid var(--c-accent, #3C9DF5); outline-offset: 2px; }
/* nothing to show yet: an empty frame struck through */
.cat-ops-thumb.is-none {
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-muted) 60%, transparent);
  background: linear-gradient(to top right, transparent calc(50% - 0.75px),
    color-mix(in srgb, var(--c-muted) 60%, transparent) 50%, transparent calc(50% + 0.75px));
}
