/* Editions page: albums by year (image, title, simple explanation).
   Pressing a card slides a viewer over the page from the right:
   large photo + a strip of the album's photos with ‹ › arrows. */

/* Page-local colors (Night values; Day overrides below) */
.ed-page, .ed-viewer {
  --ed-chip: rgb(7 8 15 / 0.72);          /* "8 photos" chip on covers */
  --ed-dot: rgb(120 116 108 / 0.16);      /* placeholder tile pattern */
  --ed-veil: rgb(7 8 15 / 0.72);          /* viewer layer over the page */
}
:root[data-theme="light"] .ed-page {
  --ed-chip: rgb(247 245 239 / 0.85);
  --ed-dot: rgb(20 21 28 / 0.07);
}
/* Day: the photo viewer stays a dark lightbox (photos read best on dark),
   so it re-scopes the Night tokens for everything inside it. */
:root[data-theme="light"] .ed-viewer {
  color-scheme: dark;
  --ed-veil: rgb(7 8 15 / 0.9);
  --bg: #07080f;
  --bg-raised: #0e1020;
  --ink: #ecebe5;
  --ink-2: rgb(236 235 229 / 0.68);
  --ink-3: rgb(236 235 229 / 0.42);
  --line: rgb(236 235 229 / 0.12);
  --line-strong: rgb(236 235 229 / 0.24);
  --signature-text: var(--signature);
  --hover-fill: rgb(236 235 229 / 0.12);
  --soft-fill: rgb(236 235 229 / 0.07);
}

.ed-page {
  min-height: 100svh;
  padding-top: calc(var(--header-h) + 48px);
  padding-bottom: clamp(64px, 8vw, 120px);
}
.ed-year + .ed-year { margin-top: clamp(64px, 8vw, 104px); }
[id^="v20"] { scroll-margin-top: calc(var(--header-h) + 24px); }

/* Year heading */
.ed-year-head {
  display: flex; align-items: baseline; gap: 16px;
  padding-bottom: 14px;
  margin-bottom: clamp(28px, 3.5vw, 44px);
  border-bottom: 1px solid var(--line-strong);
}
.ed-year-title {
  margin: 0;
  font: 400 clamp(56px, 7vw, 88px)/0.95 var(--font-serif);
  letter-spacing: -0.02em;
}
.ed-year-meta {
  margin: 0;
  font: 400 12px/1.4 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---------- Cards ---------- */
.ed-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: clamp(28px, 3.5vw, 48px) clamp(20px, 2.5vw, 32px);
  margin: 0; padding: 0;
  list-style: none;
}
@media (max-width: 960px) { .ed-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .ed-grid { grid-template-columns: 1fr; } }

.ed-card { position: relative; min-width: 0; }

/* Image */
.ed-cover {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border-radius: 16px;
}
.ed-cover .ed-ph { transition: transform .5s cubic-bezier(.2,.7,.2,1); }
.ed-card:hover .ed-cover .ed-ph { transform: scale(1.03); }
.ed-count {
  position: absolute; right: 10px; bottom: 10px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--ed-chip);
  font: 400 11px/1.3 var(--font-mono);
  color: var(--ink-2);
}

/* Title: the button covers the whole card */
.ed-card-title { margin: 16px 0 0; }
.ed-card-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: 500 20px/1.25 var(--font-sans);
  letter-spacing: -0.01em;
  text-align: left;
  cursor: pointer;
}
.ed-card-btn::after { content: ""; position: absolute; inset: 0; }
.ed-card-btn:focus-visible { outline: none; }
.ed-card:has(.ed-card-btn:focus-visible) .ed-cover { outline: 2px solid var(--signature-text); outline-offset: 3px; }
.ed-card:hover .ed-card-btn { color: var(--signature-text); }

/* Simple explanation */
.ed-card-date {
  margin: 6px 0 0;
  font: 400 12px/1.4 var(--font-mono);
  color: var(--ink-3);
}
.ed-card-text {
  margin: 8px 0 0;
  font-size: 15px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* ---------- Photo tile (real image or placeholder) ---------- */
.ed-ph {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(circle at var(--x, 30%) var(--y, 35%), var(--ed-dot) 0 7%, transparent 8%),
    linear-gradient(var(--a, 160deg), color-mix(in srgb, var(--ink) 9%, var(--bg-raised)), var(--bg-raised));
}
.ed-ph > span {
  font: 400 11px/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.ed-ph img {
  color: transparent;            /* hide alt text while a photo loads or if it is missing */
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}

/* ---------- Viewer (see-through layer over the entire page) ---------- */
html:has(.ed-viewer[open]) { overflow: hidden; }

.ed-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: 100vw;
  max-height: 100dvh;
  margin: 0;
  padding: 0;
  border: 0;
  /* the page stays faintly visible through the layer */
  background: var(--ed-veil);
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
  color: var(--ink);
}
.ed-viewer::backdrop { background: transparent; }
.ed-viewer[open] { animation: ed-fade .3s ease; }
.ed-viewer[open] .ed-viewer-inner { animation: ed-rise .4s cubic-bezier(.2,.7,.2,1); }
@keyframes ed-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes ed-rise { from { transform: translateY(16px); } to { transform: none; } }

.ed-viewer-inner {
  height: 100%;
  max-width: calc(1100px + var(--gutter) * 2);
  margin: 0 auto;
  display: flex; flex-direction: column;
  gap: 20px;
  padding: 28px var(--gutter) 32px;
  overflow-y: auto;
}

.ed-viewer-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
}
.ed-viewer-kicker {
  margin: 0 0 6px;
  font: 400 12px/1.4 var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--ink-3);
}
.ed-viewer-title {
  margin: 0;
  font: 400 clamp(32px, 4vw, 48px)/1 var(--font-serif);
  letter-spacing: -0.01em;
}
.ed-close {
  display: grid; place-items: center;
  flex: none;
  width: 44px; height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--soft-fill);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.ed-close svg { width: 16px; height: 16px; }
.ed-close:hover { background: var(--hover-fill); color: var(--signature-text); }

/* Large image */
.ed-stage { margin: 0; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.ed-stage-img {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  max-height: 64vh;
  margin-inline: auto;
  overflow: hidden;
  border-radius: 16px;
}
.ed-stage-img .ed-ph img { object-fit: contain; background: rgb(7 8 15 / 0.6); }
.ed-stage-count {
  font: 400 12px/1 var(--font-mono);
  color: var(--ink-3);
  text-align: right;
}

/* Group of images */
.ed-strip-wrap {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 40px;
  align-items: center;
  gap: 10px;
}
.ed-arrow {
  display: grid; place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: 50%;
  background: var(--soft-fill);
  color: var(--ink);
  cursor: pointer;
  transition: border-color .2s, color .2s;
}
.ed-arrow svg { width: 16px; height: 16px; }
.ed-arrow:hover { background: var(--hover-fill); color: var(--signature-text); }

.ed-strip {
  display: flex; gap: 8px;
  margin: 0; padding: 4px 2px;
  list-style: none;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
}
.ed-strip::-webkit-scrollbar { display: none; }
.ed-strip li { flex: none; scroll-snap-align: center; }
.ed-thumb {
  position: relative;
  display: block;
  width: 96px;
  aspect-ratio: 4 / 3;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity .2s;
}
.ed-thumb:hover { opacity: 0.85; }
.ed-thumb[aria-current="true"] { opacity: 1; }
/* current photo: a short signature bar under the thumbnail, not a frame */
.ed-thumb::after {
  content: "";
  position: absolute; left: 50%; bottom: 5px;
  width: 0; height: 2px;
  translate: -50% 0;
  border-radius: 2px;
  background: var(--signature);
  transition: width .2s;
}
.ed-thumb[aria-current="true"]::after { width: 40%; }

.ed-noscript { color: var(--ink-2); }

@media (max-width: 560px) {
  .ed-thumb { width: 72px; }
  .ed-strip-wrap { grid-template-columns: 36px minmax(0, 1fr) 36px; gap: 6px; }
  .ed-arrow { width: 36px; height: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .ed-viewer[open], .ed-viewer[open] .ed-viewer-inner { animation: none; }
  .ed-cover .ed-ph { transition: none; }
  .ed-card:hover .ed-cover .ed-ph { transform: none; }
}
