/* aperture.css — dark, cinematic, gallery-grade */

/* Root theme */
.ap-root {
  --ap-bg: #0a0a0a;
  --ap-bg-2: #111111;
  --ap-fg: #e8e8e6;
  --ap-fg-2: rgba(232, 232, 230, 0.72);
  --ap-muted: rgba(232, 232, 230, 0.44);
  --ap-dim: rgba(232, 232, 230, 0.22);
  --ap-hair: rgba(232, 232, 230, 0.08);
  --ap-accent: rgba(232, 232, 230, 0.6);

  --ap-sans: "Geist", "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ap-mono: "Geist Mono", "JetBrains Mono", "SF Mono", ui-monospace, monospace;

  background: var(--ap-bg);
  color: var(--ap-fg);
  font-family: var(--ap-sans);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  letter-spacing: -0.005em;
}

.ap-mono {
  font-family: var(--ap-mono);
  font-feature-settings: "tnum" 1;
  font-size: 10.5px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.ap-muted { color: var(--ap-muted); }

/* Route fade — fires when the URL hash route changes */
.ap-route { animation: ap-route-in 320ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes ap-route-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Drifting background bloom — large soft warm halo that slowly traverses the page */
.ap-bg-bloom {
  position: fixed;
  bottom: -30%;
  right: -20%;
  width: 90vw;
  height: 90vw;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 215, 175, 0.05), transparent 65%);
  pointer-events: none;
  z-index: 0;
  filter: blur(30px);
  animation: ap-bg-drift 90s ease-in-out infinite alternate;
}
@keyframes ap-bg-drift {
  from { transform: translate(0, 0) scale(1); }
  50%  { transform: translate(-25vw, -10vh) scale(1.15); }
  to   { transform: translate(15vw, -28vh) scale(0.95); }
}

/* Header */
.ap-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 32px 22px;
  background: linear-gradient(to bottom, var(--ap-bg) 30%, rgba(10, 10, 10, 0.7) 80%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
  transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-header > * { pointer-events: auto; }
.ap-header.is-hidden { transform: translateY(-100%); }

.ap-wordmark {
  font-family: var(--ap-sans);
  font-weight: 400;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--ap-fg);
  text-transform: lowercase;
  text-decoration: none;
  transition: opacity 150ms ease;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
a.ap-wordmark:hover { opacity: 0.85; }
.ap-wordmark-text { display: inline-block; }
.ap-wordmark-iris {
  opacity: 0;
  transform: rotate(-90deg) scale(0.4);
  transform-origin: center;
  transition: opacity 240ms ease-out, transform 360ms cubic-bezier(0.2, 0.7, 0.2, 1);
  color: currentColor;
}
.ap-wordmark:hover .ap-wordmark-iris {
  opacity: 0.9;
  transform: rotate(0deg) scale(1);
}

.ap-header-l {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}
.ap-header-crumb {
  color: var(--ap-muted);
  letter-spacing: 0.08em;
}

.ap-header-meta {
  color: var(--ap-muted);
  display: flex;
  align-items: center;
  gap: 0;
}
.ap-header-sep { color: var(--ap-dim); padding: 0 2px; }
.ap-header-link {
  color: var(--ap-fg-2);
  text-decoration: none;
  transition: color 150ms ease;
}
.ap-header-link:hover { color: var(--ap-fg); }

/* Main layout */
.ap-main {
  padding: 32px 32px 80px;
  max-width: 1800px;
  margin: 0 auto;
}

/* Masonry */
.ap-masonry {
  display: flex;
  align-items: flex-start;
}
.ap-mcol {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Tile */
.ap-tile {
  appearance: none;
  border: 0;
  padding: 0;
  margin: 0;
  background: var(--ap-bg-2);
  width: 100%;
  display: block;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 900ms cubic-bezier(0.2, 0.7, 0.2, 1),
              transform 900ms cubic-bezier(0.2, 0.7, 0.2, 1),
              filter 320ms ease-out;
  will-change: opacity, transform;
}
.ap-tile[data-loaded="true"] {
  opacity: 1;
  transform: translateY(0);
}
.ap-tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.015) 100%);
  pointer-events: none;
}
.ap-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 900ms cubic-bezier(0.2, 0.7, 0.2, 1),
              filter 500ms ease-out,
              opacity 500ms ease-out;
}
.ap-tile:hover img {
  transform: scale(1.02);
}
.ap-tile:focus-visible {
  outline: 1px solid var(--ap-accent);
  outline-offset: 2px;
}

/* Empty state */
.ap-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 160px 24px;
  color: var(--ap-muted);
  text-align: center;
}
.ap-empty-label {
  color: var(--ap-fg);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.ap-empty-sub { font-size: 9.5px; letter-spacing: 0.1em; }
.ap-empty-sub a { color: var(--ap-fg-2); text-decoration: none; border-bottom: 1px solid var(--ap-hair); padding-bottom: 1px; }
.ap-empty-sub a:hover { color: var(--ap-fg); }

/* Footer */
.ap-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 48px 2px 8px;
  color: var(--ap-dim);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  border-top: 1px solid var(--ap-hair);
  margin-top: 48px;
}

/* Lightbox */
.ap-lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--ap-bg);
  display: flex;
  flex-direction: column;
  animation: ap-lb-in 350ms ease-out;
}
@keyframes ap-lb-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.ap-lb-scrim {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0) 30%, rgba(0,0,0,0.6) 100%);
  z-index: 0;
  pointer-events: none;
}

.ap-lb-top {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px 32px;
  flex-shrink: 0;
}
.ap-lb-counter {
  font-family: var(--ap-mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  color: var(--ap-fg);
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.ap-lb-sep { color: var(--ap-dim); }

.ap-lb-close {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ap-muted);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 10px;
  font-family: var(--ap-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  transition: color 150ms ease;
  text-transform: uppercase;
}
.ap-lb-close:hover { color: var(--ap-fg); }

.ap-kbd {
  font-family: var(--ap-mono);
  font-size: 9px;
  letter-spacing: 0.06em;
  color: var(--ap-muted);
  border: 1px solid var(--ap-hair);
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  display: inline-block;
  line-height: 1;
  min-width: 18px;
  text-align: center;
}

/* Stage */
.ap-lb-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 0 68px;
}

.ap-lb-framewrap {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
  max-width: 100%;
  max-height: 100%;
  flex-direction: row;
}

/* Edge color glow — soft halo behind the figure tinted by the photo's dominant color */
.ap-lb-glow {
  position: absolute;
  inset: -12%;
  background: radial-gradient(ellipse at center, var(--glow, transparent) 0%, transparent 60%);
  filter: blur(60px);
  opacity: 0.55;
  pointer-events: none;
  z-index: 0;
  transition: background 600ms ease-out;
}

.ap-lb-figure {
  margin: 0;
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  max-height: 100%;
  animation: ap-fig-in 480ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-lb-figure.is-from-right { animation: ap-fig-from-right 380ms cubic-bezier(0.2, 0.7, 0.2, 1); }
.ap-lb-figure.is-from-left  { animation: ap-fig-from-left  380ms cubic-bezier(0.2, 0.7, 0.2, 1); }
@keyframes ap-fig-in {
  from { opacity: 0; transform: scale(0.985); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes ap-fig-from-right {
  from { opacity: 0; transform: translateX(48px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes ap-fig-from-left {
  from { opacity: 0; transform: translateX(-48px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Cinematic close — chrome fades out while the figure animates to the tile rect via JS */
.ap-lb.is-closing .ap-lb-scrim,
.ap-lb.is-closing .ap-lb-top,
.ap-lb.is-closing .ap-lb-side,
.ap-lb.is-closing .ap-lb-nav,
.ap-lb.is-closing .ap-lb-hints,
.ap-lb.is-closing .ap-lb-glow {
  opacity: 0;
  transition: opacity 220ms ease-out;
}
.ap-lb-figure img {
  max-width: min(72vw, 1280px);
  max-height: min(82vh, calc(100vh - 140px));
  display: block;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

/* Side panel — always-visible metadata to the right of the image */
.ap-lb-side {
  width: 240px;
  flex-shrink: 0;
  align-self: center;
  color: var(--ap-fg-2);
  animation: ap-fig-in 480ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-lb-side .ap-placard-grid {
  grid-template-columns: 1fr;
  gap: 0;
}
.ap-lb-side .ap-placard-row {
  border-top: 1px solid var(--ap-hair);
  padding: 10px 0;
}
.ap-lb-side .ap-placard-row:first-child {
  border-top: 0;
  padding-top: 0;
}

/* Nav buttons */
.ap-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  appearance: none;
  background: transparent;
  border: 0;
  color: var(--ap-muted);
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  transition: color 200ms ease, opacity 200ms ease;
  opacity: 0.7;
}
.ap-lb-prev { left: 12px; }
.ap-lb-next { right: 12px; }
.ap-lb-nav:hover { color: var(--ap-fg); opacity: 1; }

/* Keyboard hints */
.ap-lb-hints {
  display: flex;
  justify-content: center;
  gap: 28px;
  padding: 14px 32px 22px;
  color: var(--ap-muted);
  font-family: var(--ap-mono);
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.ap-lb-hints span {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Placard */
.ap-placard {
  color: var(--ap-fg-2);
  max-width: 100%;
  width: 100%;
}
.ap-placard-head {
  margin-bottom: 14px;
}
.ap-placard-title {
  font-family: var(--ap-sans);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.02em;
  color: var(--ap-fg);
  margin-bottom: 4px;
}

/* Compact (overlay-hover) placard — EXIF in a single row */
.ap-placard-grid {
  display: grid;
  margin: 0;
  padding: 6px 0 0;
  grid-template-columns: repeat(6, auto);
  gap: 18px;
  justify-content: flex-start;
  border: 0;
}
.ap-placard-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ap-placard-row dt {
  font-family: var(--ap-mono);
  font-size: 8.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ap-muted);
  margin: 0;
}
.ap-placard-row dd {
  margin: 0;
  font-size: 11px;
  color: var(--ap-fg);
  letter-spacing: 0.02em;
}

/* Body reset */
html, body {
  margin: 0;
  padding: 0;
  background: #0a0a0a;
  color: #e8e8e6;
  font-family: "Geist", -apple-system, system-ui, sans-serif;
  overflow-x: hidden;
}
* { box-sizing: border-box; }
button { font-family: inherit; }

/* Scrollbar — near-invisible */
.ap-root ::-webkit-scrollbar { width: 6px; height: 6px; }
.ap-root ::-webkit-scrollbar-track { background: transparent; }
.ap-root ::-webkit-scrollbar-thumb { background: rgba(232,232,230,0.1); border-radius: 3px; }
.ap-root ::-webkit-scrollbar-thumb:hover { background: rgba(232,232,230,0.18); }

/* Now-viewing chip — floating bottom-center indicator */
.ap-now {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  z-index: 45;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 11px 18px 12px;
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(14px) saturate(140%);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  border: 1px solid rgba(232, 232, 230, 0.08);
  border-radius: 14px;
  color: var(--ap-fg-2);
  font-size: 11.5px;
  letter-spacing: 0.01em;
  pointer-events: none;
  animation: ap-now-in 480ms ease-out;
  min-width: 0;
  max-width: min(560px, calc(100vw - 80px));
}
@keyframes ap-now-in {
  from { opacity: 0; transform: translate(-50%, 6px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.ap-now-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}
.ap-now-num { color: var(--ap-muted); font-size: 9.5px; flex-shrink: 0; }
.ap-now-title { color: var(--ap-fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ap-now-exif {
  font-size: 9.5px;
  letter-spacing: 0.1em;
  color: var(--ap-fg-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hide chip while lightbox is open */
body:has(.ap-lb) .ap-now { display: none; }

/* Comet cursor — head dot + chain of lagging trail dots */
.ap-comet {
  position: fixed;
  top: 0; left: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  transition: opacity 220ms ease-out;
  /* Soft white glow halo gives legibility over both dark page and light photos
     without the color-inverting feel of mix-blend-mode: difference. */
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.45));
}
.ap-comet[data-on="true"]   { opacity: 0.95; }
.ap-comet[data-tile="true"] { opacity: 1; }

.ap-comet-head,
.ap-comet-tail {
  position: absolute;
  top: 0; left: 0;
  background: var(--ap-fg, #f0ece4);
  border-radius: 50%;
  pointer-events: none;
  will-change: transform;
}

.ap-comet-head {
  width: 8px; height: 8px;
  transition: width 220ms cubic-bezier(0.2, 0.7, 0.2, 1),
              height 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-comet[data-tile="true"] .ap-comet-head {
  width: 14px; height: 14px;
}

/* Each tail dot shrinks and fades the further back it is.
   --i = index (0 = closest to head); --n = total tail count. */
.ap-comet-tail {
  --frac: calc(var(--i) / var(--n));
  --size: calc(6px - var(--frac) * 4.5px);
  width: var(--size); height: var(--size);
  opacity: calc(1 - var(--frac) * 0.78);
}

@media (prefers-reduced-motion: reduce) {
  .ap-comet-tail { display: none; }
}

/* Hide system cursor over the grid when lens is active */
@media (hover: hover) and (pointer: fine) {
  .ap-main, .ap-tile { cursor: none; }
}

/* Responsive */
@media (max-height: 640px) {
  .ap-lb-framewrap { gap: 20px; }
  .ap-placard-row dd { font-size: 10.5px; }
}
@media (max-width: 1100px) {
  .ap-lb-framewrap { flex-direction: column; gap: 20px; }
  .ap-lb-figure img { max-width: min(92vw, 1600px); max-height: min(60vh, calc(100vh - 260px)); }
  .ap-lb-side { width: min(560px, 92vw); }
  .ap-lb-side .ap-placard-grid { grid-template-columns: repeat(3, 1fr); gap: 0 18px; }
}
@media (max-width: 900px) {
  .ap-header { padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 18px; }
  .ap-main { padding: 20px 16px 60px; }
  .ap-lb-stage { padding: 0 16px; }
  .ap-lb-prev { left: 0; }
  .ap-lb-next { right: 0; }
}

/* ── Mobile reel ──────────────────────────────────────── */
.ap-root-mobile {
  position: fixed;
  inset: 0;
  background: var(--ap-bg);
  overflow: hidden;
}
.ap-reel {
  position: relative;
  z-index: 1;
  height: 100dvh;
  height: 100svh;
  width: 100vw;
  overflow-y: scroll;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  background: transparent;
}
.ap-reel::-webkit-scrollbar { display: none; }

.ap-reel-item {
  position: relative;
  height: 100dvh;
  height: 100svh;
  width: 100vw;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: grid;
  place-items: center;
  background: transparent;
  overflow: hidden;
}
.ap-reel-photo {
  position: relative;
  z-index: 1;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
  animation: ap-reel-fade 320ms ease-out;
}
@keyframes ap-reel-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Global ambient bloom — single layer behind the reel, two slots cross-fade */
.ap-reel-bloom-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}
.ap-reel-bloom {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(72px) saturate(1.45);
  transform: scale(1.22);
  opacity: 0;
  transition: opacity 700ms ease-out;
  pointer-events: none;
  user-select: none;
}
.ap-reel-bloom[data-on="true"] {
  opacity: 0.6;
  animation: ap-reel-bloom-in 700ms ease-out;
}
@keyframes ap-reel-bloom-in {
  from { opacity: 0; }
  to   { opacity: 0.6; }
}

/* Magazine HUDs — fixed bars over the reel */
.ap-reel-hud-top,
.ap-reel-hud-bottom {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 10;
  pointer-events: none;
  color: var(--ap-fg);
}

.ap-reel-hud-top {
  top: 0;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  background: linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.25) 65%, transparent 100%);
}
.ap-reel-hud-l {
  display: flex;
  align-items: baseline;
  gap: 10px;
  pointer-events: auto;
  min-width: 0;
}
.ap-reel-hud-mark {
  font-family: var(--ap-sans);
  font-weight: 500;
  text-transform: lowercase;
  letter-spacing: 0.16em;
  opacity: 0.9;
  color: var(--ap-fg);
  text-decoration: none;
}
.ap-reel-hud-link {
  color: var(--ap-fg-2);
  opacity: 0.9;
  text-decoration: none;
  letter-spacing: 0.1em;
  text-transform: lowercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50vw;
}
.ap-reel-hud-counter {
  opacity: 0.85;
  animation: ap-counter-pulse 320ms ease-out;
}
@keyframes ap-counter-pulse {
  0%   { opacity: 0.55; transform: translateY(-1px); }
  60%  { opacity: 1;    transform: translateY(0); }
  100% { opacity: 0.85; transform: translateY(0); }
}
/* Make the top HUD interactive (default rule sets pointer-events: none) */
.ap-reel-hud-top { pointer-events: none; }
.ap-reel-hud-top > * { pointer-events: auto; }

/* Pull-to-refresh aperture spin — drag down at the top of the reel */
.ap-reel-pull {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 24px);
  left: 50%;
  z-index: 25;
  color: var(--ap-fg);
  pointer-events: none;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.35));
}

/* End-of-reel cap — appears under the bottom HUD on the last photo */
.ap-reel-end {
  margin-top: 10px;
  font-size: 9.5px;
  letter-spacing: 0.18em;
  color: var(--ap-muted);
  animation: ap-reel-end-in 600ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes ap-reel-end-in {
  from { opacity: 0; transform: translateY(6px); filter: blur(3px); }
  to   { opacity: 1; transform: translateY(0); filter: blur(0); }
}

.ap-reel-hud-bottom {
  bottom: 0;
  padding: 32px 18px calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(to top, rgba(0,0,0,0.72) 0%, rgba(0,0,0,0.4) 55%, transparent 100%);
}
.ap-reel-hud-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  animation: ap-hud-in 280ms ease-out;
}
.ap-reel-hud-title {
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.ap-reel-hud-exif {
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ap-fg-2);
}
@keyframes ap-hud-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Collections index ─────────────────────────────────── */
@property --bloom-sat {
  syntax: "<number>";
  initial-value: 1.5;
  inherits: false;
}

.ap-collections {
  min-height: 100vh;
  background: var(--ap-bg);
}

/* Cursor spotlight — soft white halo follows the cursor and lightens whatever's underneath */
.ap-cursor-spot {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  background: radial-gradient(360px circle at var(--mx, 50vw) var(--my, 50vh),
                              rgba(255, 255, 255, 0.09),
                              transparent 60%);
  mix-blend-mode: screen;
  opacity: 0;
  transition: opacity 280ms ease-out;
}
.ap-cursor-spot[data-on="true"] { opacity: 1; }
.ap-collections-head {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 32px 22px;
  background: linear-gradient(to bottom, var(--ap-bg) 30%, rgba(10,10,10,0.7) 80%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.ap-collections-main {
  max-width: 1800px;
  margin: 0 auto;
  padding: 8px 32px 120px;
}
.ap-collections-title {
  font-family: var(--ap-sans);
  font-weight: 200;
  font-style: italic;
  font-size: clamp(56px, 11vw, 156px);
  line-height: 0.92;
  letter-spacing: -0.04em;
  color: var(--ap-fg);
  margin: 40px 0 32px;
  text-transform: lowercase;
}

.ap-collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 64px;
}

/* Home page — "explore the archive" tile placed inside the masonry's
 * shortest column so it occupies an existing gap rather than adding a
 * separate footer block. Aspect ratio is set per-render to roughly match
 * the column's missing height. */
.ap-archive-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  width: 100%;
  padding: 24px 18px;
  text-decoration: none;
  color: inherit;
  background: transparent;
  /* aspect-ratio uses the inverse: width / height. tail-aspect is height / width. */
  aspect-ratio: 1 / var(--tail-aspect, 1);
  opacity: 0;
  transform: translateY(8px);
  transition:
    opacity 720ms cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 480ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-archive-tile.is-in {
  opacity: 1;
  transform: translateY(0);
}
.ap-archive-tile-rule {
  width: 72px;
  height: 1px;
  background: var(--ap-hair);
  transition: width 320ms cubic-bezier(0.2, 0.7, 0.2, 1), background 280ms ease;
}
.ap-archive-tile-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.ap-archive-tile-label {
  font-family: var(--ap-sans);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(30px, 3.4vw, 52px);
  letter-spacing: -0.01em;
  color: var(--ap-fg-2);
  text-align: center;
  line-height: 1.1;
  transition: color 280ms ease;
}
.ap-archive-tile-arrow {
  font-family: var(--ap-sans);
  font-style: normal;
  font-size: clamp(22px, 2.2vw, 32px);
  color: var(--ap-fg-2);
  opacity: 0.9;
  line-height: 1;
  transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1), color 280ms ease;
}
.ap-archive-tile:hover .ap-archive-tile-rule {
  width: 112px;
  background: rgba(232, 232, 230, 0.24);
}
.ap-archive-tile:hover .ap-archive-tile-label { color: var(--ap-fg); }
.ap-archive-tile:hover .ap-archive-tile-arrow {
  color: var(--ap-fg);
  transform: translateY(3px);
}

/* Mobile reel — final editorial trailer slide */
.ap-reel-trailer {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 18px;
  text-align: center;
  padding: 0 32px;
}
.ap-reel-trailer-headline {
  font-family: var(--ap-sans);
  font-weight: 300;
  font-style: italic;
  font-size: clamp(26px, 7vw, 36px);
  letter-spacing: -0.01em;
  color: var(--ap-fg);
  line-height: 1.15;
}
.ap-reel-trailer-arrow {
  font-family: var(--ap-sans);
  font-size: 26px;
  color: var(--ap-fg);
  opacity: 0.85;
  line-height: 1;
  transition: transform 280ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-reel-trailer:active .ap-reel-trailer-arrow {
  transform: translateY(2px);
}

.ap-collection-card {
  position: relative;
  display: block;
  text-decoration: none;
  color: var(--ap-fg);
  isolation: isolate;
  aspect-ratio: 4 / 5;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 720ms cubic-bezier(0.2, 0.7, 0.2, 1),
    transform 380ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-collection-card.is-in {
  opacity: 1;
  transform: translateY(0);
  transition-delay: calc(var(--i, 0) * 70ms);
}
.ap-collection-card.is-in:hover {
  transform: translateY(-4px) scale(1.015);
  transition-delay: 0ms;
}

/* Click ripple — brief scale + flash before navigation */
.ap-collection-card.ap-cc-pressed {
  animation: ap-cc-pulse 240ms ease-out forwards;
}
.ap-collection-card.ap-cc-pressed::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(255, 255, 255, 0.16);
  pointer-events: none;
  animation: ap-cc-flash 240ms ease-out forwards;
}
@keyframes ap-cc-pulse {
  0%   { transform: translateY(-4px) scale(1.015); }
  35%  { transform: translateY(-1px) scale(0.985); }
  100% { transform: translateY(-8px) scale(1.04); }
}
@keyframes ap-cc-flash {
  from { opacity: 1; }
  to   { opacity: 0; }
}

/* Wrapper — passthrough so children stack predictably inside the card */
.ap-collection-tilt {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Ambient bloom — clipped to card bounds so it doesn't bleed onto neighbors,
   but the card itself has no border or hard edge */
.ap-collection-bloom-wrap {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 0;
  pointer-events: none;
}
.ap-collection-bloom {
  position: absolute;
  inset: -8%;
  width: 116%;
  height: 116%;
  object-fit: cover;
  --bloom-sat: 1.5;
  filter: blur(60px) saturate(var(--bloom-sat));
  opacity: 0.55;
  transform: scale(1.1);
  transition: opacity 480ms ease-out;
  animation: ap-cc-bloom-drift 11s ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -1.7s);
}
@keyframes ap-cc-bloom-drift {
  from { --bloom-sat: 1.35; }
  to   { --bloom-sat: 1.85; }
}
.ap-collection-card:hover .ap-collection-bloom {
  opacity: 0.78;
}

/* Deck has no clipping — peeks can extend past the cover edge */
.ap-collection-deck {
  position: absolute;
  inset: 0;
  z-index: 1;
}
.ap-collection-deck img {
  position: absolute;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.ap-collection-cover {
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 3;
  transition: transform 520ms cubic-bezier(0.2, 0.7, 0.2, 1);
}
.ap-collection-card:hover .ap-collection-cover {
  transform: scale(0.98);
}
/* Frame holds position + idle sway. Inner img holds the hover transform.
   Two transform layers compose, so leaving hover transitions cleanly
   while the sway keeps running uninterrupted. */
.ap-collection-peek-frame {
  position: absolute;
  display: block;
  width: 38%;
  aspect-ratio: 4 / 5;
}
.ap-collection-peek-frame-1 {
  bottom: -10%;
  right: -10%;
  z-index: 4;
  transform-origin: 30% 30%;
  animation: ap-cc-sway-1 7.5s ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -1.3s);
}
.ap-collection-peek-frame-2 {
  top: -9%;
  left: -7%;
  width: 30%;
  z-index: 2;
  transform-origin: 70% 70%;
  animation: ap-cc-sway-2 8.5s ease-in-out infinite alternate;
  animation-delay: calc(var(--i, 0) * -1.7s);
}
.ap-collection-peek {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #111;
  border: 1px solid rgba(232,232,230,0.08);
  box-shadow: 0 14px 32px rgba(0,0,0,0.55), 0 2px 6px rgba(0,0,0,0.4);
  transform: rotate(0deg);
  opacity: 0;
  transition:
    transform 520ms cubic-bezier(0.2, 0.7, 0.2, 1),
    opacity 360ms ease-out;
}
.ap-collection-peek.is-on { opacity: 1; }
@keyframes ap-cc-sway-1 {
  from { transform: rotate(5deg); }
  to   { transform: rotate(8deg); }
}
@keyframes ap-cc-sway-2 {
  from { transform: rotate(-8deg); }
  to   { transform: rotate(-5.5deg); }
}
.ap-collection-card:hover .ap-collection-peek-1 {
  transform: rotate(4deg) translate(4%, -4%);
}
.ap-collection-card:hover .ap-collection-peek-2 {
  transform: rotate(-4deg) translate(-5%, -3%);
}

@media (prefers-reduced-motion: reduce) {
  .ap-collection-card { opacity: 1; transform: none; transition: none; }
  .ap-collection-card.is-in { opacity: 1; transform: none; }
  .ap-collection-card.ap-cc-pressed { animation: none; }
  .ap-collection-card.ap-cc-pressed::before { display: none; }
  .ap-collection-bloom { animation: none; }
  .ap-collection-peek-frame-1, .ap-collection-peek-frame-2 { animation: none; }
  .ap-cursor-spot { display: none; }
}

.ap-collection-meta {
  position: absolute;
  left: 22px;
  right: 22px;
  bottom: 18px;
  z-index: 6;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.ap-collection-name {
  font-family: var(--ap-sans);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--ap-fg);
  text-transform: lowercase;
  text-shadow: 0 2px 18px rgba(0,0,0,0.6);
}
.ap-collection-count {
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: rgba(232, 232, 230, 0.78);
}

@media (max-width: 760px) {
  .ap-collections-head { padding: 18px 18px; }
  .ap-collections-main { padding: 4px 14px 80px; }
  .ap-collections-title { margin: 20px 0 18px; }
  .ap-collections-grid { grid-template-columns: repeat(2, 1fr); gap: 24px; }
  .ap-collection-deck { inset: 12px; }
  .ap-collection-name { font-size: 18px; }
}
