/* ============================================================
   slipcase — scrollable home: cursor, hero, collect-nav,
   gallery, slideshow
   ============================================================ */

html { scroll-behavior: smooth; }
body { overflow-x: hidden; overflow-y: auto; cursor: none; }
.home { position: relative; min-height: 100vh; }
* { cursor: none !important; }

/* ---------- custom cursor ---------- */
.cursor-dot {
  position: fixed; top: 0; left: 0;
  width: 16px; height: 16px; border-radius: 50%;
  background: #141310; pointer-events: none;
  z-index: 99999; will-change: transform;
  transition: background 160ms var(--ease), scale 160ms var(--ease), opacity 120ms var(--ease);
}
@media (pointer: coarse) { .cursor-dot { display: none; } body { cursor: auto; } * { cursor: auto !important; } }

/* ---------- hero ---------- */
.hero { position: relative; height: 100vh; width: 100%; }
.alt-hero { display: flex; align-items: center; justify-content: center; }

.stand-wrap { position: absolute; left: 8%; top: 13%; }
.wordlock {
  position: fixed; left: 0; top: 0; z-index: 60;
  transform-origin: top left; display: block; will-change: transform;
}
.wordlock-img {
  display: block;
  width: calc(clamp(280px, 34vw, 520px) * var(--word-scale));
  height: auto;
}

.hero-mono { position: absolute; right: 6%; bottom: 9%; display: block; }
.hero-mono img { display: block; }

.chevron {
  position: absolute; left: 50%; bottom: 5.5%; transform: translateX(-50%);
  background: none; border: 0; padding: 10px; color: var(--ink);
  cursor: none; animation: chevbob 2.4s ease-in-out infinite;
}
@keyframes chevbob { 0%,100% { transform: translateX(-50%) translateY(0); } 50% { transform: translateX(-50%) translateY(6px); } }

/* ---------- fixed squares (hero markers → nav) ---------- */
.sq-wrap {
  position: fixed; left: 0; top: 0; z-index: 60;
  display: block; will-change: transform;
  transform-origin: top left;
}
.rollsq { transition: scale 240ms var(--ease); transform-origin: center; }
.sq-wrap:hover .rollsq, .sq-wrap.is-hover .rollsq { scale: 1.16; }

.nav-label {
  position: fixed; left: 0; top: 0; z-index: 60;
  transform: translateY(-50%);
  opacity: 0;
  font-size: 12px; font-weight: 700; letter-spacing: 0.34em; text-indent: 0.34em;
  pointer-events: none; white-space: nowrap;
  transition: opacity 220ms var(--ease);
  will-change: transform;
}
.hover-label {
  position: fixed; left: 0; top: 0; z-index: 70;
  transform: translateX(-50%);
  font-size: 13px; font-weight: 700; letter-spacing: 0.34em; text-indent: 0.34em;
  pointer-events: none; white-space: nowrap;
  transition: opacity 160ms var(--ease);
}

/* ---------- collected nav bar ---------- */
.navbar {
  position: fixed; top: 0; left: 0; right: 0; height: 100px;
  background: var(--paper); border-bottom: 1px solid rgba(20,19,15,0.10);
  z-index: 50; pointer-events: none;
  transition: background 420ms var(--ease);
}

/* ---------- collapse: FALLBACK (no scroll-timeline support) ----------
   A triggered, compositor-only CSS transition between the hero and nav states.
   Smooth, but plays at its own pace rather than tracking the scroll. Gated on
   .tm-nav-ready (added after first paint) so nothing animates on load. */
.tm-nav-ready .sq-wrap,
.tm-nav-ready .wordlock { transition: transform 0.5s var(--ease); }
/* chips, EXPAND direction (default): drop out immediately as the squares fly back */
.tm-nav-ready .nav-label {
  transition: transform 0.5s var(--ease),
              opacity 0.2s var(--ease),
              clip-path 0.24s var(--ease);
}
/* chips, COLLAPSE direction: hold, then snap open just as the squares land */
.tm-nav-ready.tm-collapsing .nav-label {
  transition: transform 0.5s var(--ease),
              opacity 0.16s var(--ease) 0.36s,
              clip-path 0.2s var(--ease) 0.34s;
}
.tm-nav-ready .stand-wrap,
.tm-nav-ready .hero-mono,
.tm-nav-ready .chevron { transition: opacity 0.4s var(--ease); }
.tm-nav-ready .navbar { transition: opacity 0.45s var(--ease), background 420ms var(--ease); }

/* ---------- collapse: PREFERRED (scroll-driven) ----------
   The collapse is SCRUBBED against scroll position on the compositor — it follows
   the scroll exactly (like the original) but stays smooth because JS never drives
   it per frame. JS only publishes each element's --from/--to (and --clip-*)
   endpoints; these keyframes interpolate between them over the first ~70vh of
   scroll, so the motion fills the hero rather than triggering all at once. */
@keyframes tm-xform { from { transform: var(--from); } to { transform: var(--to); } }
@keyframes tm-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes tm-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes tm-chip { /* phone chip: hold, then wipe + fade in as the square lands */
  0%, 62% { opacity: 0; clip-path: var(--clip-from); pointer-events: none; }
  100% { opacity: 1; clip-path: var(--clip-to); pointer-events: auto; }
}
@keyframes tm-label-in { /* desktop label: fade in + become clickable once collapsed */
  from { opacity: 0; pointer-events: none; }
  to { opacity: 1; pointer-events: auto; }
}
@supports (animation-timeline: scroll()) {
  .tm-scroll-driven .sq-wrap,
  .tm-scroll-driven .wordlock {
    animation: tm-xform linear both;
    animation-timeline: scroll(root block);
    animation-range: 0 70vh;
  }
  .tm-scroll-driven .stand-wrap,
  .tm-scroll-driven .hero-mono {
    animation: tm-fade-out linear both;
    animation-timeline: scroll(root block);
    animation-range: 0 32vh;
  }
  .tm-scroll-driven .chevron {
    animation: chevbob 2.4s ease-in-out infinite, tm-fade-out linear both;
    animation-timeline: auto, scroll(root block);
    animation-range: normal, 0 22vh;
  }
  .tm-scroll-driven .navbar {
    animation: tm-fade-in linear both;
    animation-timeline: scroll(root block);
    animation-range: 0 46vh;
  }
  @media (max-width: 767px) {   /* phones: chip wipes open as the square lands */
    .tm-scroll-driven .nav-label {
      animation: tm-xform linear both, tm-chip linear both;
      animation-timeline: scroll(root block), scroll(root block);
      animation-range: 0 70vh, 0 70vh;
    }
  }
  @media (min-width: 768px) {   /* desktop: label rides beside its square, fades in late */
    .tm-scroll-driven .nav-label {
      animation: tm-xform linear both, tm-label-in linear both;
      animation-timeline: scroll(root block), scroll(root block);
      animation-range: 0 70vh, 30vh 70vh;
    }
  }
}

/* ---------- gallery ---------- */
.gallery { position: relative; z-index: 5; padding: 14vh 7vw 6vh; background: var(--paper); }
.gallery-flow { display: flex; flex-direction: column; align-items: flex-start; width: 100%; }
.tile {
  padding: 0; display: block; position: relative;
  opacity: 0; transform: translateY(48px) rotate(var(--rot, 0deg));
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease);
}
.tile.in { opacity: 1; transform: translateY(0) rotate(var(--rot, 0deg)); }
.tile:hover { z-index: 8 !important; transform: translateY(0) rotate(0deg) scale(1.02); }
.tile-img {
  width: 100%; display: block; overflow: hidden;
  background-size: cover; background-position: center;
  transition: filter 0.55s var(--ease);
}
.tile:hover .tile-img { filter: saturate(1.06); }
.tile-cap { font-size: 13px; margin: 9px 2px 0; color: var(--ink-soft); }
.tile-place { color: var(--ink-faint); }

/* ---------- home category tiles ---------- */
.cat-tile { color: var(--ink-soft); text-decoration: none; }
.cat-frame {
  position: relative; width: 100%; display: block; overflow: hidden;
  background: rgba(20,19,15,0.05);
}
.cat-frame-img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  animation: cat-fade 0.45s var(--ease);
}
@keyframes cat-fade { from { opacity: 0; } to { opacity: 1; } }
.cat-name { color: var(--ink); text-transform: lowercase; }
.cat-tile:hover .cat-name { font-style: italic; }

.home-foot { padding: 8vh 0 6vh; text-align: center; }
.home-foot .serif { font-size: 13px; color: var(--ink-faint); }

/* ---------- slideshow ---------- */
.slideshow {
  position: fixed; inset: 0; z-index: 9000;
  background: color-mix(in srgb, var(--paper) 84%, transparent);
  display: flex; align-items: center; justify-content: center;
  animation: ssfade 0.32s var(--ease);
}
@keyframes ssfade { from { opacity: 0; } to { opacity: 1; } }
.ss-stage { margin: 0; max-width: 88vw; }
.ss-img {
  height: min(74vh, 800px); max-width: 86vw; width: auto;
  background-repeat: no-repeat; background-position: center; background-size: contain;
  box-shadow: 0 18px 50px rgba(20,19,15,0.18);
}
.ss-cap {
  display: flex; align-items: baseline; gap: 18px; flex-wrap: wrap;
  margin-top: 16px; font-size: 14px; color: var(--ink-soft);
}
.ss-count { margin-left: auto; font-size: 11px; font-weight: 700; letter-spacing: 0.3em; color: var(--ink-faint); }
.ss-cap-text {
  flex: 1 1 auto; min-width: 0; max-width: 64ch;
  font-style: italic; line-height: 1.5; color: var(--ink-soft);
  text-wrap: pretty;
}
.ss-close {
  position: fixed; top: 20px; right: 22px; z-index: 6;
  width: 44px; height: 44px; display: flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0; line-height: 0;
  color: var(--ink); opacity: 0.66; transition: opacity 160ms var(--ease);
}
.ss-close:hover { opacity: 1; }
.ss-frame { position: relative; display: block; line-height: 0; }
.ss-arrow {
  position: fixed; top: 50%; transform: translateY(-50%);
  background: none; border: 0; color: var(--ink-soft); padding: 18px; line-height: 0;
  transition: color 160ms var(--ease);
}
.ss-arrow:hover { color: var(--ink); }
.ss-prev { left: 2vw; }
.ss-next { right: 2vw; }

/* phones: tuck the chevrons into the photo's bottom corners as discreet, semi-
   transparent discs (anchored to .ss-frame) instead of straddling the edges.
   Swipe also advances; see ProjectSlideshow. */
@media (max-width: 700px) {
  .ss-arrow {
    position: absolute; top: auto; bottom: 12px; transform: none;
    width: 38px; height: 38px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    /* solid translucent fill, NO backdrop-filter: on mobile Safari a blur
       backdrop freezes a stale snapshot of the previous photo inside the disc
       (a ghost that vanishes in screenshots). A slightly darker fill reads fine
       over both bright and dark photos without that artifact. */
    background: color-mix(in srgb, var(--ink) 52%, transparent);
    color: var(--paper);
  }
  .ss-arrow:hover { color: var(--paper); }
  .ss-prev { left: 12px; right: auto; }
  .ss-next { right: 12px; left: auto; }
  .ss-arrow svg { width: 13px; height: 22px; }
}

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .gallery { padding: 10vh 6vw; }
  .tile { width: 88% !important; margin-left: 6% !important; margin-top: 0 !important; }
}
/* phones: the collapsed square EXPANDS into this chip — a colored block (bg set
   inline per item) with the label reversed out white inside. Sizing/position +
   the clip-path reveal are driven in home-shared.jsx (update()). Desktop keeps
   the plain square + colored label beside it. */
@media (max-width: 767px) {
  .nav-label {
    display: inline-flex; align-items: center; justify-content: center;
    height: 22px; padding: 0 9px; color: #f5f2ea !important;
  }
  .nav-label.caps { font-size: 9.5px; letter-spacing: 0.16em; text-indent: 0.16em; }
}
