/* Shared controls */
.gallery-navigation { display: flex; align-items: center; gap: .5rem; }
.gallery-navigation button,
.lightbox-close {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  transition: background .3s, color .3s, border-color .3s, transform .2s var(--ease-out);
}
.gallery-navigation button:active,
.lightbox-close:active { transform: scale(.92); }
:is(.gallery-navigation, .lightbox-close) svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }


/* Slideshow stage */
.stage-frame { position: relative; overflow-x: clip; }
.stage {
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  height: clamp(18rem, 50vh, 32rem);
  cursor: zoom-in;
  touch-action: pan-y pinch-zoom;
  -webkit-tap-highlight-color: transparent;
}
.stage img,
.lightbox-view img { grid-area: 1 / 1; }
.ghost { pointer-events: none; }
.stage img {
  width: auto;
  max-height: 100%;
  object-fit: contain;
  box-shadow: 0 1px 2px rgb(22 19 16 / 12%), 0 24px 48px -24px rgb(22 19 16 / 45%);
}

.gallery-bar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  margin-top: clamp(1.25rem, 3vw, 2rem);
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}
.gallery-count { display: flex; margin: 0; }
.gallery-count > span:first-child { display: flex; align-items: center; gap: .75rem; }
.gallery-count b {
  display: inline-block;
  min-width: 2ch;
  font: italic 500 1.875rem/1 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
}
.gallery-count span span { color: var(--muted); font: 500 .8125rem/1 var(--sans); letter-spacing: .06em; font-variant-numeric: tabular-nums; }
.count-rule { position: relative; width: clamp(3rem, 10vw, 6rem); height: 1px; background: var(--line); }
.count-rule::after {
  content: "";
  position: absolute;
  inset: -.5px 0;
  background: var(--accent);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
  transition: transform .7s var(--ease-out);
}
.gallery-bar .gallery-navigation { margin-left: auto; }
.index-toggle {
  display: flex;
  align-items: center;
  gap: .6rem;
  min-height: 44px;
  padding: 0 .25rem;
  border: 0;
  background: none;
  font: var(--label);
  letter-spacing: var(--tracking);
  text-transform: uppercase;
}
.index-icon { display: grid; grid-template-columns: repeat(2, 5px); gap: 3px; transition: transform .5s var(--ease-out); }
.index-icon i { width: 5px; height: 5px; background: currentColor; transition: border-radius .4s; }
.index-toggle[aria-expanded="true"] .index-icon { transform: rotate(45deg); }
.index-toggle[aria-expanded="true"] .index-icon i { border-radius: 50%; }

.filmstrip {
  position: relative;
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
  padding: .25rem 1.5rem .75rem 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  mask-image: linear-gradient(90deg, #000 calc(100% - 3rem), transparent);
}
.filmstrip::-webkit-scrollbar { display: none; }
.filmstrip a {
  position: relative;
  flex: none;
  height: 3.75rem;
  scroll-snap-align: start;
  opacity: .42;
  filter: grayscale(.7);
  transition: opacity .4s, filter .4s;
}
.filmstrip a::after {
  content: "";
  position: absolute;
  inset: auto 0 -.5rem;
  height: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transition: transform .5s var(--ease-out);
}
.filmstrip a[aria-current] { opacity: 1; filter: none; }
.filmstrip a[aria-current]::after { transform: scaleX(1); }
.filmstrip img { width: auto; height: 100%; object-fit: cover; }

.filmstrip.is-index {
  flex-wrap: wrap;
  gap: 1rem .6rem;
  padding-right: 0;
  overflow: visible;
  mask-image: none;
}
.filmstrip.is-index a { height: 4.75rem; opacity: 1; filter: none; transition: transform .4s var(--ease-out); }

.slideshow-caption { margin-top: 1rem; font-size: .9375rem; }
.slideshow-caption strong { font: italic 500 1.25rem/1.3 var(--serif); }
.slideshow-caption span { display: block; color: var(--muted); }

/* Archive: justified rows on the artworks' own proportions */
.archive { display: grid; gap: clamp(1.5rem, 3vw, 2.25rem); --row-height: 7.5rem; }
.archive-works { display: flex; flex-wrap: wrap; gap: 1.75rem .875rem; }
.archive-works::after { content: ""; flex: 999 1 0; }
.archive figure { flex: var(--ratio) 1 calc(var(--ratio) * var(--row-height)); min-width: 0; margin: 0; }
.archive-thumbnail { display: block; overflow: hidden; background: var(--paper-deep); cursor: zoom-in; }
.archive-thumbnail img {
  width: 100%;
  aspect-ratio: var(--ratio);
  object-fit: cover;
  transition: transform 1s var(--ease-out), opacity .8s;
}
.archive figcaption { display: flex; align-items: baseline; gap: .6rem; margin-top: .6rem; min-width: 0; }
.archive-number { flex: none; font: italic 500 1.0625rem/1 var(--serif); font-variant-numeric: lining-nums; transition: color .3s; }
.archive-title { overflow: hidden; color: var(--muted); font-size: .8125rem; line-height: 1.3; white-space: nowrap; text-overflow: ellipsis; transition: color .3s; }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #0f0d0b;
  color: #f4f0e8;
  --line: rgb(244 240 232 / 18%);
  --ink: #f4f0e8;
  --paper: #0f0d0b;
}
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.lightbox::backdrop { background: transparent; }
html:has(.lightbox[open]) { overflow: hidden; }
.lightbox { overscroll-behavior: contain; touch-action: none; }
.lightbox-view { overflow: hidden; }
.lightbox-top { display: flex; align-items: center; gap: 1.5rem; padding: .75rem clamp(.75rem, 3vw, 1.75rem); }
.lightbox-count { margin: 0; font: italic 500 1.375rem/1 var(--serif); font-variant-numeric: lining-nums tabular-nums; }
.lightbox-count small { margin-left: .35rem; color: rgb(244 240 232 / 50%); font: 500 .75rem/1 var(--sans); font-style: normal; letter-spacing: .06em; }
.lightbox-file {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  min-height: 44px;
  color: rgb(244 240 232 / 60%);
  font: var(--label);
  letter-spacing: var(--tracking);
  text-transform: uppercase;
  text-decoration: none;
  transition: color .3s;
}
.lightbox-count { margin-right: auto; }
.lightbox-close { width: 44px; height: 44px; margin-right: -10px; border: 0; border-radius: 0; background: none; }
.lightbox-close svg { width: 22px; height: 22px; stroke-width: 1.75; }
.file-icon { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.lightbox-close svg { transition: transform .5s var(--ease-out); }
.lightbox-view {
  position: relative;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
  place-items: center;
  min-height: 0;
  padding: 0 clamp(.75rem, 6vw, 6rem);
  -webkit-tap-highlight-color: transparent;
}
.lightbox-view img { width: auto; max-height: 100%; object-fit: contain; user-select: none; box-shadow: 0 30px 80px -30px rgb(0 0 0 / 80%); }
.lightbox-view img { cursor: pointer; }
.lightbox-view { cursor: zoom-out; }
.lightbox-bottom { position: relative; display: grid; place-items: center; min-height: 1.5rem; padding: .75rem 1rem 1.25rem; }
.lightbox-progress {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: var(--accent);
  transform: scaleX(var(--progress, 0));
  transform-origin: left;
  transition: transform .7s var(--ease-out);
}

@media (width < 34rem) {
  .gallery-bar { gap: .75rem; }
  .index-toggle .index-icon { display: none; }
  .file-label { display: none; }
  .file-icon { width: 18px; height: 18px; }
}

@media (width < 741px) {
  .stage { height: auto; aspect-ratio: 4 / 3; max-height: 60svh; place-items: start center; }
}

@media (min-width: 52rem) {
  .archive { --row-height: 10.5rem; }
}

@media (prefers-reduced-motion: no-preference) {
  .filmstrip.is-index a { animation: rise-in .6s var(--ease-out) backwards; }
  @supports (animation-timeline: view()) {
    .archive figure { animation: rise-in linear both; animation-timeline: view(); animation-range: entry 0% entry 60%; }
  }
}


/* Hover looks only where a pointer can hover; on touch screens they would stick after a tap. */
@media (hover: hover) {
  .gallery-navigation button:hover { background: var(--ink); border-color: var(--ink); color: var(--paper); }
  .index-toggle:hover .index-icon { transform: rotate(90deg); }
  .filmstrip a:is(:hover, :focus-visible) { opacity: .85; filter: none; }
  .filmstrip.is-index a:hover { transform: translateY(-2px); }
  .archive-thumbnail:hover img { transform: scale(1.04); }
  .archive figure:hover :is(.archive-number) { color: var(--accent); }
  .archive figure:hover .archive-title { color: var(--ink); }
  .lightbox-file:hover { color: #f4f0e8; }
  .lightbox-close:hover { background: none; color: #f4f0e8; }
  .lightbox-close:hover svg { transform: rotate(90deg); }
}
