/* Rockstar Style Explorer — editorial book-publisher register, dark.
 *
 * The palette is rockstar-viewer's `body.route-plate` block promoted to the
 * site-wide default: #0f1614 ground, #e8efeb text, #88d490 phosphor green.
 * In the viewer that register was scoped to the plate page while the gallery
 * stayed cream; here Jordan asked for the dark one throughout, so it moves to
 * :root and the cream register does not ship at all. Fonts are the viewer's.
 *
 * This is a viewing surface, so the chrome stays quiet: the pictures carry the
 * colour and the UI is near-monochrome until something is interactive.
 */

:root {
  --bg: #0f1614;
  --bg-elev: #181f1c;
  --bg-sunk: #0a0f0e;
  --fg: #e8efeb;
  --fg-muted: #9aa39e;
  --fg-soft: #6e7672;
  --border: #2a322e;
  --border-strong: #3a423d;
  --accent: #88d490;
  --accent-dim: #58b163;
  --accent-soft: #1f2a23;
  --warn: #f59e0b;

  --font-serif: 'Source Serif 4', Georgia, serif;
  --font-sans: 'IBM Plex Sans', system-ui, sans-serif;
  --font-mono: 'IBM Plex Mono', Menlo, monospace;

  --max-w: 1700px;
  --page-pad: clamp(1rem, 4vw, 3rem);
  --shadow-lift: 0 6px 22px rgba(0, 0, 0, 0.55);
  --header-h: 3.5rem;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ─── Header: document tabs ──────────────────────────────────────────
 * Tabs read as index tabs on a document — they sit ON the header's lower
 * edge and the active one merges with the page beneath it by painting over
 * the header border. That shared edge is the whole illusion; without it they
 * are just buttons.
 */

.header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.header__inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 var(--page-pad);
  min-height: var(--header-h);
  display: flex;
  align-items: flex-end;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.header__title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 0;
  padding-bottom: 0.7rem;
  align-self: flex-end;
  white-space: nowrap;
}
.header__title span { color: var(--fg-soft); font-weight: 400; }

.tabs {
  display: flex;
  gap: 0.25rem;
  margin-bottom: -1px;   /* overlap the header border — see note above */
  flex: 1;
}

.tab {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-soft);
  padding: 0.6rem 1.1rem;
  border: 1px solid transparent;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  transition: color 120ms, background 120ms;
}
.tab:hover { color: var(--fg); }
.tab[aria-selected='true'] {
  color: var(--fg);
  background: var(--bg);
  border-color: var(--border);
  /* Paint over the header's own bottom border so the tab and the page below
   * share one continuous surface. */
  box-shadow: 0 1px 0 0 var(--bg);
}
.tab__count {
  color: var(--fg-soft);
  margin-left: 0.4rem;
  font-size: 0.7rem;
}
.tab[aria-selected='true'] .tab__count { color: var(--accent-dim); }

.header__actions { display: flex; align-items: center; gap: 0.75rem; padding-bottom: 0.55rem; }

.btn {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.45rem 0.85rem;
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--fg-muted);
  transition: color 120ms, border-color 120ms, background 120ms;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { color: var(--fg); border-color: var(--accent-dim); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border-color: var(--accent);
  font-weight: 500;
}
.btn-primary:hover:not(:disabled) { background: var(--accent-dim); border-color: var(--accent-dim); color: var(--bg); }

.identity-chip {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-soft);
  letter-spacing: 0.04em;
}
.identity-chip button { color: var(--accent-dim); text-decoration: underline; font: inherit; }

/* ─── Page ───────────────────────────────────────────────────────── */

.page { max-width: var(--max-w); margin: 0 auto; padding: 0 var(--page-pad) 6rem; }

.panel[hidden] { display: none; }

/* First section carries the panel's top margin now the intro paragraph is gone. */
.section { margin-top: 3.5rem; }
.panel > .section:first-child { margin-top: 2.5rem; }

.section__head {
  display: flex;
  align-items: baseline;
  gap: 0.9rem;
  padding-bottom: 0.7rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.section__title {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 0;
}
.section__meta {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-soft);
}

/* ─── Favourites row ─────────────────────────────────────────────────
 * The three picks, larger. A row rather than part of the masonry, because
 * the whole point is that they are NOT one of the crowd.
 */

/* Three across, or one — never two.
 *
 * `auto-fit` with a min track width was the obvious spelling and it is wrong
 * here: with exactly three items it lands on two columns at any mid width and
 * orphans the third onto its own row, which reads as a bug rather than a
 * layout. Measured at 910px it computed to `408px 408px`.
 *
 * The other constraint is that a favourite must be visibly larger than a
 * masonry tile, and the masonry's column count floats with the viewport. So
 * three-across is held back until there is room for the masonry to reach four
 * columns; below that a favourite takes a single capped-width column, which is
 * unambiguously bigger than a ~340px tile without swallowing the whole screen.
 */
/* Centred on the page, not ragged left (Jordan, 14Aug26f). Below the
 * three-across breakpoint the row is a single capped column, and left-aligning
 * that against a full-width masonry made the picks read as the start of the
 * grid rather than as a row above it. */
.faves {
  display: grid;
  grid-template-columns: 1fr;
  justify-items: center;
  gap: 1.25rem;
  margin: 1.75rem auto 2.5rem;
  max-width: 900px;
}
.faves > .frame { min-width: 0; }

@media (min-width: 1500px) {
  .faves { grid-template-columns: repeat(3, 1fr); max-width: none; }
}

.provisional-note {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--warn);
  margin: 1.5rem 0 -0.75rem;
}

/* ─── Masonry ────────────────────────────────────────────────────────
 * CSS columns, not grid. Grid masonry is still not shipping cross-browser,
 * and columns give true variable-height packing with no JS and no layout
 * thrash on resize. The trade is reading order: columns flow top-to-bottom
 * then across, so the DOM order is not the visual order. That is acceptable
 * here — the grid is a field of pictures to browse, not a ranked list — and
 * the lightbox navigates in DOM (i.e. ref-code) order regardless.
 */

.masonry { columns: 4 300px; column-gap: 1rem; margin-top: 1.75rem; }
.masonry .frame { break-inside: avoid; margin-bottom: 1rem; }

.frame { display: block; width: 100%; text-align: left; position: relative; }

.frame__shot {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-elev);
  transition: border-color 140ms, transform 140ms;
}
.frame:hover .frame__shot { border-color: var(--accent-dim); }
.frame:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.faves .frame__shot { border-color: var(--border-strong); }

.frame__cap {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.5rem 0.1rem 0;
  flex-wrap: wrap;
}
.frame__code {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  color: var(--accent-dim);
  white-space: nowrap;
}
.frame__badge {
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--bg);
  background: var(--accent-dim);
  border-radius: 999px;
  padding: 0.05rem 0.4rem;
  white-space: nowrap;
}
.frame__badge[hidden] { display: none; }

/* ─── Arc video ──────────────────────────────────────────────────── */

.arc { margin-top: 4rem; }

/* THE WHOLE PLAYER STAYS IN VIEW AT ANY WIDTH (Jordan, 14Aug26f).
 *
 * `width: 100%` plus `aspect-ratio: 3/2` is a height that grows with the
 * viewport: on a wide display the box became taller than the screen, so the
 * arc could only ever be seen a slice at a time — and an arc video watched in
 * slices is not an arc. Capping the HEIGHT directly would not have worked
 * either: with a definite width, `aspect-ratio` computes the height and a
 * `max-height` merely clips the box while the iframe keeps its own size.
 *
 * So the cap goes on the WIDTH, derived from the height it is allowed to
 * occupy — 74dvh × 3/2. Width is the free dimension here, so constraining it
 * constrains the aspect box legitimately, and the player is centred in the
 * space that leaves.
 */
.arc__frame {
  width: 100%;
  max-width: calc(74dvh * 3 / 2);
  margin-inline: auto;
  aspect-ratio: 3 / 2;
  border: 1px solid var(--border);
  border-radius: 2px;
  background: var(--bg-sunk);
  display: block;
}
.arc__note {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--fg-soft);
  letter-spacing: 0.04em;
  margin-top: 0.6rem;
}
.arc__pending {
  display: grid;
  place-items: center;
  color: var(--fg-soft);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  text-align: center;
  padding: 1rem;
}

/* ─── Comments ───────────────────────────────────────────────────── */

.thread { margin-top: 2rem; border-top: 1px solid var(--border); padding-top: 1.25rem; }
.thread--section { max-width: 70ch; }

.thread__title {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--fg-soft);
  margin: 0 0 0.9rem;
}

.comment { padding: 0.7rem 0; border-bottom: 1px solid var(--border); }
.comment:last-of-type { border-bottom: none; }
.comment__head { display: flex; gap: 0.6rem; align-items: baseline; }
.comment__author { font-weight: 600; font-size: 0.85rem; }
.comment__when { font-family: var(--font-mono); font-size: 0.65rem; color: var(--fg-soft); }
.comment__body { font-family: var(--font-serif); margin: 0.25rem 0 0; white-space: pre-wrap; }
.comment--mine .comment__author { color: var(--accent); }

.thread__empty { color: var(--fg-soft); font-style: italic; font-family: var(--font-serif); margin: 0 0 1rem; }

.comment-form { display: flex; flex-direction: column; gap: 0.6rem; margin-top: 1rem; }
.comment-form textarea {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.65rem 0.75rem;
  resize: vertical;
  min-height: 4.5rem;
  width: 100%;
}
.comment-form textarea:focus { outline: none; border-color: var(--accent-dim); }
.comment-form__row { display: flex; align-items: center; gap: 0.75rem; }
.comment-form__status { font-size: 0.78rem; color: var(--fg-soft); }
.comment-form__status--error { color: var(--warn); }

/* ─── Lightbox ───────────────────────────────────────────────────────
 * The stage is capped against dvh DIRECTLY, never a percentage. A percentage
 * max-height on a child of an auto-height parent resolves to `none`, which is
 * how the avatar surface's lightbox overflowed its stage (project CLAUDE.md).
 */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(6, 10, 9, 0.94);
  backdrop-filter: blur(6px);
  display: grid;
  grid-template-rows: auto 1fr;
}
.lightbox[hidden] { display: none; }

.lightbox__bar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem var(--page-pad);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.lightbox__code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.06em;
  color: var(--accent);
}
.lightbox__meta { font-family: var(--font-mono); font-size: 0.68rem; color: var(--fg-soft); }
.lightbox__spacer { flex: 1; }

/* THE IMAGE GETS THE WHOLE WIDTH; THE COMMENTS SIT UNDER IT (14Aug26f).
 *
 * The side column was costing the picture more than it looked. At 1440px it
 * took min(30rem, 34vw) = 480px plus the gap, so the stage was ~880px wide —
 * and a favourite in the grid is up to 900px. The lightbox was showing the
 * image SMALLER than the page it opened from, which is the opposite of what a
 * lightbox is for, and on this project registers are adjudicated at 1:1.
 *
 * One column instead: the image takes the full width and is capped against
 * dvh, and the thread scrolls into view beneath it. The cap stays a DIRECT dvh
 * calculation and never a percentage — a percentage max-height on a child of
 * an auto-height parent resolves to `none`, which is how the avatar surface's
 * lightbox overflowed its stage (project CLAUDE.md).
 */
.lightbox__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-auto-rows: min-content;
  gap: 1.5rem;
  padding: 1.25rem var(--page-pad) 2.5rem;
  overflow-y: auto;
  min-height: 0;
}

.lightbox__stage {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 0;
}
.lightbox__img {
  max-width: 100%;
  max-height: calc(100dvh - var(--header-h) - 7rem);
  width: auto;
  height: auto;
  object-fit: contain;
  border: 1px solid var(--border);
  border-radius: 2px;
}

.lightbox__nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: clamp(2.5rem, 4vw, 3.25rem);
  height: clamp(2.5rem, 4vw, 3.25rem);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  border: 1px solid var(--border-strong);
  border-radius: 50%;
  color: var(--fg);
  font-size: 1.2rem;
  line-height: 1;
  transition: border-color 120ms, background 120ms;
}
.lightbox__nav:hover { border-color: var(--accent); background: var(--bg-elev); }
.lightbox__nav--prev { left: -0.5rem; }
.lightbox__nav--next { right: -0.5rem; }

/* Beneath the image, and held to a reading measure rather than the full width
 * of a 2560px display — a comment box the width of the picture is unreadable. */
.lightbox__side { min-height: 0; width: min(70ch, 100%); margin-inline: auto; }
.lightbox__side .thread { margin-top: 0; border-top: none; padding-top: 0; }

.lightbox__close { font-size: 1.1rem; padding: 0.3rem 0.6rem; color: var(--fg-muted); }
.lightbox__close:hover { color: var(--fg); }

/* ─── Modal ──────────────────────────────────────────────────────── */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6, 10, 9, 0.8);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal {
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1.5rem;
  width: min(26rem, 100%);
  box-shadow: var(--shadow-lift);
}
.modal__title { font-family: var(--font-serif); font-size: 1.25rem; margin: 0 0 0.35rem; }
.modal__sub { color: var(--fg-muted); font-size: 0.85rem; margin: 0 0 1.1rem; }
.identity-options { display: flex; flex-direction: column; gap: 0.4rem; }
.identity-option {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
}
.identity-option:hover { border-color: var(--border-strong); }
.identity-option--selected { border-color: var(--accent); background: var(--accent-soft); }
.identity-option__input {
  font-family: inherit;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.5rem 0.6rem;
  margin-top: 0.2rem;
}
.modal__actions { display: flex; justify-content: flex-end; gap: 0.6rem; margin-top: 1.25rem; }

/* ─── Mobile ─────────────────────────────────────────────────────────
 * The lightbox side panel becomes a stacked row beneath the image rather
 * than a column, and the whole body scrolls. Stewart reads on a phone.
 */

@media (max-width: 860px) {
  .lightbox__img { max-height: 58dvh; }
  .lightbox__nav--prev { left: 0.1rem; }
  .lightbox__nav--next { right: 0.1rem; }
  .masonry { columns: 2 150px; }
  .header__inner { gap: 0.75rem; }
  .header__title { display: none; }
}

@media (max-width: 520px) {
  .masonry { columns: 1; }
  .faves { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
