/* /archive — the wall, and the concept viewer it opens into.
   Everything here consumes shell tokens; the tiles are images of the work
   and keep the work's own light appearance in both themes. */

.archive { padding-block: 0 var(--s10); }
/* A shorter opening than other pages: the wall is the point, and it should
   be on screen before the visitor scrolls. */
[data-design="editions"] .pagehead.archive-head { padding: clamp(26px, 3.2vw, 44px) clamp(28px, 4vw, 60px); margin-block: 24px 24px; }
[data-design="editions"] .pagehead.archive-head .lede { max-width: 76ch; margin-top: 16px; }

/* ── bar: filters, zoom, and a count that speaks when filtered ─────── */
.archive-bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3) var(--s7);
  flex-wrap: wrap; padding-block: 0 var(--s5); }
.archive-count { flex-basis: 100%; order: 2; font-family: var(--mono); font-size: var(--t-machine); color: var(--graphite); letter-spacing: .01em; }
.archive-controls { display: flex; align-items: center; justify-content: space-between; gap: var(--s5); flex-wrap: wrap; width: 100%; }
.archive-filters, .archive-density { display: flex; gap: 2px; }
.archive-filters button, .archive-density button {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding-inline: 12px;
  border-radius: var(--r-pill); font-size: var(--t-caption); font-weight: 500; color: var(--ink-2);
  transition: color var(--d-hover) ease, background-color var(--d-hover) ease;
}
.archive-filters small { font-family: var(--mono); font-size: var(--t-eyebrow); color: var(--graphite); font-variant-numeric: tabular-nums; }
.archive-filters button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
.archive-filters button[aria-pressed="true"] small { color: inherit; opacity: .8; }
.archive-density { padding: 3px; border: 1px solid var(--rule); border-radius: var(--r-pill); }
.archive-density button { min-height: 30px; padding-inline: 12px; }
.archive-density button[aria-pressed="true"] { background: var(--ink); color: var(--ground); }
@media (hover: hover) and (pointer: fine) {
  .archive-filters button:not([aria-pressed="true"]):hover { color: var(--ink); background: var(--paper-3); }
  .archive-density button:not([aria-pressed="true"]):hover { background: var(--paper-3); color: var(--ink); }
}
.archive-area { display: flex; align-items: center; gap: var(--s3); margin-bottom: var(--s4);
  font-size: var(--t-small); color: var(--ink-2); }
.archive-area-label { color: var(--ink); font-weight: 500; }
.archive-area-clear { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; min-height: 32px; }

/* ── the wall ────────────────────────────────────────────────────── */
.wall {
  --cols: 24; --wall-gap: 4px; --tile-r: 5px;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--wall-gap);
  grid-auto-flow: dense; align-items: start;
}
.tile { position: relative; min-width: 0; }
.tile > img, .tile > a > img {
  display: block; width: 100%; aspect-ratio: 4 / 3; height: auto; object-fit: cover;
  background: var(--paper-2); border: 1px solid var(--rule-soft); border-radius: var(--tile-r);
}
[data-theme="dark"] .tile > img, [data-theme="dark"] .tile > a > img { border-color: var(--rule); }
.tile-open > a { display: block; text-decoration: none; color: inherit; border-radius: var(--tile-r); outline-offset: 3px; }
.tile-open > a > img { transition: transform var(--d-hover) var(--ease-out), box-shadow var(--d-hover) ease; }
.tile-cap { display: none; }

/* Overview: the whole wall in one look. Featured pieces take a 2×2 cell so
   the curated set is legible inside the texture; their caption appears on
   hover or focus. */
[data-density="overview"] .tile-open { grid-column: span 2; grid-row: span 2; }
[data-density="overview"] .tile-open .tile-cap {
  display: grid; position: absolute; inset: auto 0 0 0; padding: 8px 9px 7px;
  background: linear-gradient(to top, rgba(17 17 17 / .78), rgba(17 17 17 / 0)); color: #fff;
  border-radius: 0 0 var(--tile-r) var(--tile-r); opacity: 0; visibility: hidden; font-size: var(--t-caption); line-height: 1.25;
  transition: opacity var(--d-hover) ease, visibility 0s var(--d-hover); pointer-events: none;
}
[data-density="overview"] .tile-cap small { font-size: var(--t-eyebrow); opacity: .8; }
[data-density="overview"] .tile-open > a:hover .tile-cap,
[data-density="overview"] .tile-open > a:focus-visible .tile-cap { opacity: 1; visibility: visible; transition-delay: 0s; }

/* Browse: every tile the same size, the curated ones captioned beneath. */
[data-density="browse"] .wall { --cols: 6; --wall-gap: var(--s5) var(--s4); --tile-r: var(--r-lg); }
[data-density="browse"] .tile-cap { display: grid; gap: 2px; margin-top: var(--s2); font-size: var(--t-small); font-weight: 500; color: var(--ink); }
[data-density="browse"] .tile-cap small { font-size: var(--t-caption); font-weight: 400; color: var(--graphite); }
[data-density="browse"] .tile:not(.tile-open) { opacity: .92; }

@media (hover: hover) and (pointer: fine) {
  .tile-open > a:hover > img { transform: translateY(-2px); box-shadow: var(--shadow-card); }
}
.tile-open > a:focus-visible > img { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Arrival: the wall builds itself once, in about a second, tile by tile.
   After it has settled the animation is removed so filtering never
   replays it. */
@media (prefers-reduced-motion: no-preference) {
  .wall:not(.settled) .tile { animation: wall-in var(--d-arrive) var(--ease-out) both;
    animation-delay: calc(min(var(--i), 260) * 4ms); }
  @keyframes wall-in { from { opacity: 0; transform: translateY(6px); } }
}

.tile.is-out { display: none; }
.archive-empty { padding-block: var(--s9); color: var(--graphite); }
.archive-foot { margin-top: var(--s8); color: var(--graphite); font-size: var(--t-small); }

@media (max-width: 1100px) { .wall { --cols: 16; } [data-density="browse"] .wall { --cols: 4; } }
@media (max-width: 760px) {
  .wall { --cols: 10; --wall-gap: 3px; }
  [data-density="browse"] .wall { --cols: 3; --wall-gap: var(--s4) var(--s3); }
  .archive-bar { padding-bottom: var(--s4); }
  .archive-controls { width: 100%; justify-content: space-between; }
  .archive-filters { overflow-x: auto; scrollbar-width: none; max-width: 100%; padding-bottom: 2px;
    mask-image: linear-gradient(to right, #000 calc(100% - 36px), transparent); padding-right: 36px; }
  .archive-filters::-webkit-scrollbar { display: none; }
}
@media (max-width: 480px) { .wall { --cols: 8; } }

/* ── the concept viewer, and the lightbox that shares its frame ──── */
.concept-viewer, .lightbox { position: fixed; inset: 0; z-index: 60; display: grid; grid-template-rows: auto minmax(0, 1fr);
  background: var(--ground); color: var(--ink); }
body.viewing { overflow: hidden; }
.viewer-toolbar { display: flex; align-items: center; gap: var(--s2); padding: var(--s2) var(--s3);
  border-bottom: 1px solid var(--rule); min-width: 0; min-height: 64px; }
.viewer-toolbar button, .viewer-toolbar select {
  display: inline-flex; align-items: center; gap: var(--s2); min-height: 40px; padding: 8px 12px;
  border: 1px solid var(--rule); border-radius: var(--r-md); background: var(--paper); color: var(--ink);
  font-size: var(--t-caption); white-space: nowrap; cursor: pointer;
}
.viewer-toolbar button svg { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) { .viewer-toolbar button:hover, .viewer-toolbar select:hover { background: var(--paper-2); } }
.viewer-toolbar button:disabled { opacity: .45; cursor: default; }
.viewer-title { min-width: 0; flex: 1; padding-inline: var(--s2); display: flex; align-items: baseline; gap: var(--s3); }
.viewer-title h2 { display: block; min-width: 0; font-size: 1.0625rem; font-weight: 600; letter-spacing: -.015em; border-radius: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; outline-offset: 4px; }
.viewer-label { min-width: 0; display: flex; align-items: center; gap: var(--s3); padding: 4px 0; }
#back svg, #lightbox-back svg { transform: scaleX(-1); }
.concept-data-note { font-family: var(--mono); font-size: var(--t-eyebrow); color: var(--graphite); white-space: nowrap; padding: 2px 7px;
  border: 1px solid var(--rule); border-radius: var(--r-pill); }
#detail-deck { color: var(--graphite); font-size: var(--t-caption); white-space: nowrap; }
#position { font-family: var(--mono); font-size: var(--t-eyebrow); color: var(--graphite); white-space: nowrap; margin-inline: var(--s1); }
.detail-scroll { position: relative; margin: 3vh 8vw 5vh; min-width: 0; min-height: 0; overflow: auto; overscroll-behavior: contain;
  scrollbar-gutter: stable; background: #fff; border: 1px solid var(--rule); border-radius: var(--r-lg); overflow-anchor: none; }
.detail-loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--edition-palette-ink-quiet); font-size: var(--t-small); }
.detail-scroll:has(#detail-mount:not(:empty)) .detail-loading { display: none; }
#detail-mount { position: relative; min-height: 0; overflow: hidden; contain: layout paint; }
#concept-info { position: absolute; z-index: 2; right: 16px; top: 80px; bottom: 16px; width: min(370px, calc(100vw - 32px));
  padding: var(--s6); background: var(--paper); border: 1px solid var(--rule); border-radius: var(--r-lg);
  box-shadow: var(--shadow-dialog); overflow: auto; }
.info-heading { display: flex; justify-content: space-between; align-items: center; gap: var(--s5); }
.info-heading h2 { font-size: var(--t-heading); font-weight: 600; }
.info-heading button { min-height: 36px; padding-inline: 10px; border: 1px solid var(--rule); border-radius: var(--r-md); font-size: var(--t-caption); }
#concept-info > p { line-height: var(--lh-prose); margin-top: var(--s4); }
#detail-status { color: var(--accent); font-size: var(--t-caption); }
#concept-info dl { display: grid; grid-template-columns: 80px 1fr; gap: 10px; font-size: var(--t-caption); padding-block: var(--s5);
  margin-block: var(--s5); border-block: 1px solid var(--rule-soft); }
#concept-info dt { color: var(--graphite); }
#copy { min-height: 40px; padding-inline: 12px; border: 1px solid var(--rule); border-radius: var(--r-md); font-size: var(--t-caption); }
#copy-status { margin-top: var(--s2); font-size: var(--t-caption); color: var(--graphite); }

/* The lightbox: one brand piece as its full tile, captioned beneath. The
   image keeps the ground it was drawn on; the frame is the wall's. */
#lightbox-position { flex: 1; text-align: right; font-family: var(--mono); font-size: var(--t-eyebrow); color: var(--graphite);
  white-space: nowrap; margin-inline: var(--s1); }
.lightbox-figure { display: grid; grid-template-rows: minmax(0, 1fr) auto; justify-items: center; align-items: center;
  gap: var(--s4); margin: 0; padding: 3vh 4vw 4vh; min-height: 0; }
.lightbox-figure img { display: block; width: auto; height: auto; max-width: 100%; max-height: 100%;
  border: 1px solid var(--rule); border-radius: var(--r-lg); background: var(--paper-2); }
.lightbox-figure figcaption { display: grid; justify-items: center; gap: 2px; text-align: center;
  font-size: var(--t-small); font-weight: 500; color: var(--ink); }
.lightbox-figure figcaption small { font-size: var(--t-caption); font-weight: 400; color: var(--graphite); }
#lightbox-title { outline-offset: 4px; border-radius: 3px; }

@media (max-width: 1100px) { #position, #detail-deck { display: none; } }
@media (max-width: 650px) {
  .viewer-toolbar { display: grid; grid-template-columns: auto 1fr auto auto; gap: 4px; padding: 6px 8px; min-height: 0; }
  .viewer-title { grid-column: 2 / 5; grid-row: 1; padding: 0 6px; }
  .viewer-title h2 { font-size: .9375rem; }
  .viewer-toolbar button, .viewer-toolbar select { min-height: 36px; font-size: var(--t-eyebrow); padding: 5px 8px; }
  .zoom-label { grid-row: 2; grid-column: 1; }
  .zoom-label select { max-width: 122px; }
  #info { grid-column: 2; grid-row: 2; }
  #prev { grid-column: 3; grid-row: 2; }
  #next { grid-column: 4; grid-row: 2; }
  #concept-info { top: 96px; }
  .detail-scroll { margin: 4px; border-radius: var(--r-md); }
  .lightbox .viewer-toolbar { grid-template-columns: auto 1fr auto auto; }
  .lightbox-figure { padding: 12px; gap: var(--s3); }
}
