/* public/css/cover-flow.css
   "Selected Work" cover flow on the homepage — the lead image of ten
   curated work series in an Apple-style 3D flow: flat centre card, the
   rest collapsed into a tight raked fan on each side, prev/next arrows
   and dot markers. Driven by public/js/cover-flow.js, which sets
   --cf-tx / --cf-ry / --cf-sc / --cf-br + z-index per slide every
   animation frame from each slide's distance to the viewport centre, and
   JS-snaps to the nearest slide on scroll-end. Visual language borrowed
   from Niklas Knaack's CSS-only cover flow, rebuilt with JS so it runs
   in every current browser rather than Chrome-canary only.

   Everything is scoped under .cf-section. Reuses the host page's design
   tokens (--void / --ink / --line / --gradient-brand …) and the existing
   .work-teaser-cta / .work-teaser-cta-outline button styles. */

.cf-section {
  overflow: hidden;                 /* raked slides never widen the page */
  padding-block: clamp(2.5rem, 7vw, 5rem);
}

/* ---------- flow shell ----------
   The stack geometry (how far each side slide sits from centre, its rake
   and scale) is computed in cover-flow.js and pushed onto every slide as
   --cf-tx / --cf-ry / --cf-sc / --cf-br each animation frame. The model
   is Niklas Knaack's: every <li> is a full centre-width flex slot, and
   the inner element is then translated back over the centre so distant
   slides collapse into a tight raked fan instead of marching outward. */
.cf {
  /* centred image width — one continuous clamp (no breakpoint jump, so a
     drag across ~640px doesn't snap the whole flow) */
  --cf-w: clamp(15rem, 80vw, 33rem);
  position: relative;
}
.cf[data-state="loading"] { min-height: clamp(18rem, 46vw, 34rem); }

/* full-bleed: break out of the section's 8vw side padding so the stacks
   can reach toward the screen edges and the arrows can sit at them */
.cf-viewport {
  position: relative;
  width: 100vw;
  margin-inline: calc(50% - 50vw);
}

.cf-track {
  display: flex;
  align-items: center;
  gap: 0;
  list-style: none;
  margin: 0;
  padding-block: clamp(2rem, 6vw, 4rem);
  /* first / last slide can still reach dead centre */
  padding-inline: calc(50vw - var(--cf-w) / 2);
  overflow-x: auto;
  overflow-y: hidden;
  /* no CSS scroll-snap — cover-flow.js snaps to the nearest slide itself
     on scroll-end. Native snap kept re-snapping to the wrong slide when
     the section scrolled into view; JS snap is fully predictable and the
     arrows / dots already drive scrollTo() directly. */
  scroll-snap-type: none;
  scrollbar-width: none;
  -ms-overflow-style: none;
  overscroll-behavior-x: contain;
  overflow-anchor: none;
  -webkit-overflow-scrolling: touch;
}
.cf-track::-webkit-scrollbar { display: none; }

.cf-slide {
  flex: 0 0 var(--cf-w);
  display: flex;
  justify-content: center;
  /* translate back toward centre (their wrapper <div>); the 3D rake/scale
     lives on .cf-media (their <img>) */
  translate: var(--cf-tx) 0;
  will-change: translate;
  /* defaults so first paint (before JS) isn't broken */
  --cf-tx: 0px;
  --cf-ry: 0deg;
  --cf-sc: 1;
  --cf-br: 1;
  --ad: 0;
}

.cf-media {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 4px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  transform-origin: center center;
  backface-visibility: hidden;
  transform: perspective(1000px) rotateY(var(--cf-ry)) scale(var(--cf-sc));
  filter: brightness(var(--cf-br));
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.8);
  will-change: transform;
  transition: transform 0.12s ease-out, border-color 0.3s ease;
}
.cf-media img,
.cf-media video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  display: block;
  filter: grayscale(1) contrast(1.04);
  transition: filter 0.4s ease;
  -webkit-user-drag: none;
  user-select: none;
}

/* the centred card: flat, full colour, a live edge */
.cf-slide[data-active="true"] .cf-media {
  border-color: var(--red-dim);
}
.cf-slide[data-active="true"] .cf-media img,
.cf-slide[data-active="true"] .cf-media video {
  filter: grayscale(0) contrast(1.05);
}

/* flat 30% dark wash over the whole image — fades in with the overlay
   text so the title / teaser stay legible without a gradient scrim */
.cf-media::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}

@media (hover: hover) {
  .cf-slide:not([data-active="true"]) .cf-media:hover {
    filter: brightness(calc(var(--cf-br) + 0.08));
  }
  .cf-slide[data-active="true"] .cf-media:hover {
    transform: perspective(1000px) rotateY(var(--cf-ry)) scale(calc(var(--cf-sc) * 1.02));
  }
}

/* full-cover click target — centred slide opens the gallery, an
   off-centre slide scrolls itself to centre */
.cf-media-open {
  position: absolute;
  inset: 0;
  z-index: 1;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  font: inherit;
  cursor: pointer;
}
.cf-slide[data-active="true"] .cf-media-open { cursor: zoom-in; }

/* ---------- overlay on the centred image ----------
   Default (centred, not hovered): just the two corner buttons — View
   bottom-left, Save bottom-right. On hover of the centred card the title
   + teaser fade in above the buttons, and a flat 30% dark wash fades in
   over the whole image (.cf-media::after). Where there's no hover (touch)
   both are always shown. No gradient scrim. */
.cf-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 2.4rem 0.85rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.cf-slide[data-active="true"] .cf-overlay { opacity: 1; }

.cf-overlay-reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.cf-overlay-title {
  margin: 4px 0 6px;
  font-family: "Anton", sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.01em;
  line-height: 1.05;
  font-size: clamp(1.1rem, 2.6vw, 1.7rem);
  color: #fff;
}
.cf-overlay-desc {
  margin: 0;
  color: #fff;
  font-size: 0.86rem;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cf-overlay-actions {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 0.55rem;
  pointer-events: none;
}
.cf-slide[data-active="true"] .cf-overlay-actions { pointer-events: auto; }

.cf-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-family: "Space Mono", monospace;
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease,
    border-color 0.2s ease, color 0.2s ease;
}
.cf-btn svg { flex: 0 0 auto; }
.cf-view,
.cf-save {
  color: var(--ink);
  background: rgba(10, 9, 8, 0.6);
  border-color: var(--line);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.cf-view:hover,
.cf-save:hover { border-color: var(--ink-dim); }
.cf-save.is-saved { border-color: var(--red-dim); color: var(--ink); }

@media (hover: hover) {
  .cf-slide[data-active="true"] .cf-media:hover::after { opacity: 1; }
  .cf-slide[data-active="true"] .cf-media:hover .cf-overlay-reveal {
    opacity: 1;
    transform: none;
  }
}
@media (hover: none) {
  .cf-slide[data-active="true"] .cf-media::after { opacity: 1; }
  .cf-overlay-reveal { opacity: 1; transform: none; }
}

/* ---------- arrows ---------- */
/* z-index sits above the slides (JS gives those ~980–1000) and the arrows
   ride near the viewport edges, clear of the raked fan */
.cf-arrow {
  position: absolute;
  top: calc(50% - clamp(0.75rem, 2vw, 1.5rem));
  transform: translateY(-50%);
  z-index: 1100;
  width: clamp(2.5rem, 6vw, 3.25rem);
  height: clamp(2.5rem, 6vw, 3.25rem);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 9, 8, 0.82);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.25s ease, color 0.25s ease, opacity 0.25s ease;
}
.cf-arrow:hover { border-color: var(--red); color: var(--red); }
.cf-arrow:disabled { opacity: 0.25; pointer-events: none; }
.cf-arrow--prev { left: clamp(0.75rem, 3vw, 2.5rem); }
.cf-arrow--next { right: clamp(0.75rem, 3vw, 2.5rem); }
.cf-arrow svg { display: block; }

/* ---------- dot markers ---------- */
.cf-dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.cf-dot {
  width: 0.5rem;
  height: 0.5rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(245, 240, 230, 0.24);
  cursor: pointer;
  transition: width 0.25s ease, background-color 0.25s ease;
}
.cf-dot:hover { background: rgba(245, 240, 230, 0.5); }
.cf-dot[aria-selected="true"] {
  width: 1.6rem;
  background: var(--gradient-brand);
}

/* ---------- click-through gallery (opened from the centred slide) ---------- */
.cfg {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(0.75rem, 2.5vw, 1.4rem);
  padding: clamp(1rem, 4vw, 3rem);
}
.cfg[hidden] { display: none; }
.cfg-scrim {
  position: absolute;
  inset: 0;
  background: rgba(8, 7, 6, 0.95);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.cfg-stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: min(1100px, 92vw);
}
.cfg-img,
.cfg-video {
  display: block;
  max-width: min(1100px, 92vw);
  max-height: 70vh;
  width: auto;
  height: auto;
  border: 1px solid var(--line);
  background: #000;
}
.cfg-video[hidden] { display: none; }
.cfg-close {
  position: absolute;
  top: clamp(0.75rem, 3vw, 1.75rem);
  right: clamp(0.75rem, 3vw, 1.75rem);
  z-index: 2;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 9, 8, 0.7);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.cfg-close:hover { border-color: var(--red); color: var(--red); }
.cfg-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  width: clamp(2.5rem, 6vw, 3.25rem);
  height: clamp(2.5rem, 6vw, 3.25rem);
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(10, 9, 8, 0.7);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.2s ease, color 0.2s ease;
}
.cfg-nav:hover { border-color: var(--red); color: var(--red); }
.cfg-nav[hidden] { display: none; }
.cfg-nav--prev { left: clamp(0.5rem, 3vw, 2rem); }
.cfg-nav--next { right: clamp(0.5rem, 3vw, 2rem); }
.cfg-meta {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 60ch;
}
.cfg-series {
  display: block;
  color: var(--red);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.cfg-caption {
  margin: 0.5rem 0 0.35rem;
  color: var(--ink-dim);
  font-size: 0.95rem;
  line-height: 1.55;
}
.cfg-count {
  color: var(--ink-faint);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
}

/* ---------- see-all link ---------- */
.cf-more {
  margin-top: clamp(1.75rem, 5vw, 3rem);
  text-align: center;
}
.cf-more-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: "Space Mono", monospace;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  padding-bottom: 4px;
  transition: color 0.25s ease, border-color 0.25s ease, gap 0.25s ease;
}
.cf-more-link:hover {
  color: var(--red);
  border-color: var(--red);
  gap: 16px;
}

/* ---------- loading / no-JS ---------- */
.cf[data-state="loading"] .cf-viewport,
.cf[data-state="loading"] .cf-dots { visibility: hidden; }
.cf[data-state="error"] { display: none; }

@media (max-width: 640px) {
  /* Phones get a near-full-bleed centre image in a tall editorial frame
     rather than a small square crop. The stack geometry (rake / scale /
     gutter) is also eased for <=640px in cover-flow.js so the side slides
     read as a calm sliver of the next photo, not a warped claw. --cf-w is
     the one value both sides share, so a resize across 640px stays smooth. */
  .cf-section { padding-block: clamp(2rem, 8vw, 3.5rem); }
  .cf { --cf-w: 88vw; }
  .cf-track { padding-block: 1.1rem; }

  .cf-media {
    aspect-ratio: 4 / 5;
    border-radius: 6px;
    box-shadow: 0 24px 60px -28px rgba(0, 0, 0, 0.85);
  }

  /* overlay: keep it low and quiet — just the title + the two buttons,
     no scrim (text rides on the image, held by its text-shadow). The
     teaser blurb is dropped on phones; it lives in the gallery a tap
     away. */
  .cf-overlay {
    padding: 3rem 1.15rem 1.15rem;
    gap: 0.7rem;
  }
  .cf-overlay-title { margin: 6px 0 0; font-size: 1.55rem; line-height: 1.06; }
  .cf-overlay-desc { display: none; }
  .cf-overlay-actions { gap: 0.6rem; margin-top: 0.2rem; }
  .cf-btn { font-size: 0.6rem; padding: 0.55rem 0.9rem; }

  /* arrows hug the screen edge, understated, centred on the image */
  .cf-arrow {
    width: 2.4rem;
    height: 2.4rem;
    background: rgba(10, 9, 8, 0.5);
    border-color: rgba(245, 240, 230, 0.16);
  }
  .cf-arrow--prev { left: 0.35rem; }
  .cf-arrow--next { right: 0.35rem; }

  .cf-dots { margin-top: 1.1rem; }
  .cf-more { margin-top: clamp(1.5rem, 7vw, 2.5rem); }
  .cfg-img, .cfg-video { max-height: 62vh; }
}

@media (prefers-reduced-motion: reduce) {
  .cf-slide { will-change: auto; }
  .cf-media { transition: none; }
  .cf-overlay { transition: none; }
}
