/* All projects. With motion, a pair of doors opens onto the index as you scroll (js/projects.js); then a toolbar filters
   the groups and switches list and grid, each row's thumbnail flips through moments of its film as it passes, and on a
   fine pointer a pixel lens previews the row you point at. Without JS it is a plain editorial index. */
.index { padding: 0 0 clamp(80px, 10vw, 140px); }
.doors { padding: calc(var(--nav-h) + clamp(56px, 10vh, 120px)) var(--gutter) 0; }
.index-head { max-width: 1280px; margin: 0 auto clamp(40px, 6vw, 80px); display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 24px 64px; align-items: end; }
.index-head h1 { margin: 0; font: 400 clamp(4.4rem, 12vw, 11rem)/.86 var(--font-display); letter-spacing: -.035em; }
.index-head p { margin: 0; color: var(--ink-soft); line-height: 1.7; max-width: 32em; }
.index-head .hairline { grid-column: 1 / -1; margin-top: clamp(16px, 3vw, 36px); }
.doors-media, .doors-cue { display: none; }

/* ── The doors: a pinned view whose film (a generated clip) follows the scroll ── */
.doors.is-on { height: 270svh; padding: 0; }
.doors.is-on .doors-pin { position: sticky; top: 0; height: 100svh; overflow: hidden; display: grid; place-items: center; background: #24180f; }
.doors.is-on .doors-media { display: block; position: absolute; inset: 0; }
.doors.is-on video { display: block; width: 100%; height: 100%; object-fit: cover; }
.doors-veil { position: absolute; inset: 0; background: var(--parchment); opacity: 0; }
.doors.is-on .index-head { position: relative; z-index: 2; grid-template-columns: minmax(0, 1fr); justify-items: center; gap: 22px; margin: 0; padding: 0 var(--gutter); text-align: center; color: #f6efe4; }
.doors.is-on .index-head h1 { font-size: clamp(5rem, 15.5vw, 15rem); text-shadow: 0 6px 60px rgba(14, 9, 4, .45); }
.doors.is-on .index-head p { max-width: 30em; color: rgba(246, 239, 228, .9); text-shadow: 0 1px 18px rgba(14, 9, 4, .6); }
.doors.is-on .index-head .hairline { display: none; }
.doors.is-on .doors-cue { position: absolute; left: var(--gutter); bottom: 22px; z-index: 2; display: flex; align-items: center; gap: 12px; margin: 0; padding: 6px 14px 6px 12px; border-radius: 999px;
  color: #f2ece0; background: rgba(27, 20, 14, .76); font-size: .8rem; white-space: nowrap; }
.doors-cue i { display: block; width: 1px; height: 18px; background: linear-gradient(rgba(242, 236, 224, 0), #f2ece0); transform-origin: top; animation: cue-drop 1.8s var(--ease-in-out) infinite; }
.doors-cue a { color: inherit; text-underline-offset: .25em; text-decoration-color: rgba(246, 239, 228, .5); }
@keyframes cue-drop { 0% { transform: scaleY(0); } 55% { transform: scaleY(1); transform-origin: top; } 56% { transform-origin: bottom; } 100% { transform: scaleY(0); transform-origin: bottom; } }

/* ── The list ── */
.index-list { padding: 0 var(--gutter); }
/* After the doors, the list rises over the last of the light instead of waiting for the pinned view to scroll away. */
.doors.is-on + .index-list { position: relative; z-index: 1; margin-top: -40svh; }
.index-tools { position: sticky; top: var(--sticky-top); z-index: 20; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 24px;
  max-width: 1280px; margin: 0 auto clamp(40px, 6vw, 72px); padding: 12px 0; background: color-mix(in srgb, var(--parchment) 92%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--rule); transition: top .45s var(--ease-out); }
.index-tools[hidden] { display: none; }
.index-filters, .index-view { display: flex; flex-wrap: wrap; gap: 6px; }
.index-tools button { min-height: 40px; padding: 0 16px; border: 1px solid var(--rule); border-radius: 999px; color: var(--ink-soft); background: transparent; font: 500 .9rem/1 var(--font-body);
  cursor: pointer; transition: color .3s, background-color .3s, border-color .3s; }
.index-tools button span { margin-left: 6px; color: var(--gold-deep); font-variant-numeric: tabular-nums; }
.index-tools button:hover { color: var(--ink); border-color: var(--ink); }
.index-tools button[aria-pressed="true"] { color: var(--parchment-bright); background: var(--ink); border-color: var(--ink); }
.index-tools button[aria-pressed="true"] span { color: var(--orange); }

.index-group { max-width: 1280px; margin: 0 auto clamp(64px, 8vw, 110px); }
.index-group[hidden] { display: none; }
.index-group-head { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: 16px 64px; align-items: end; margin-bottom: 18px; }
.index-group-head h2 { margin: 0; font: 400 clamp(2rem, 3.4vw, 3rem)/1.05 var(--font-display); letter-spacing: -.015em; }
.index-group-head p { margin: 0; color: var(--ink-soft); font-size: .95rem; line-height: 1.6; max-width: 34em; }

.rows { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--ink); }
.row { position: relative; display: grid; grid-template-columns: minmax(0, 3.6fr) minmax(0, 1.7fr) minmax(0, 4.4fr) 196px; grid-template-areas: "title kind line media" "title kind meta media";
  gap: 4px 32px; align-items: baseline; padding: 24px 0 22px; color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--rule); isolation: isolate; }
.row::before { content: ""; position: absolute; inset: 0 calc(var(--gutter) * -0.5); z-index: -1; background: var(--parchment-bright); transform: scaleY(0); transform-origin: bottom; transition: transform .5s var(--ease-out); }
.row:hover::before, .row:focus-visible::before { transform: scaleY(1); }
.row-title { grid-area: title; font: 400 clamp(2.2rem, 4.2vw, 3.8rem)/1 var(--font-display); letter-spacing: -.02em; transition: transform .6s var(--ease-out), color .3s; }
.row:hover .row-title, .row:focus-visible .row-title { transform: translateX(12px); color: var(--gold-deep); }
.row-kind { grid-area: kind; color: var(--ink-soft); font-size: .92rem; }
.row-line { grid-area: line; color: var(--ink); line-height: 1.55; }
.row-meta { grid-area: meta; color: var(--ink-soft); font-size: .86rem; }
/* A flip-book: six moments of the case film side by side; --f (set as the row scrolls past) picks the one on show. */
.row-media { grid-area: media; align-self: center; position: relative; display: block; aspect-ratio: 16 / 10; overflow: hidden; border-radius: var(--radius); background: var(--gown);
  box-shadow: 0 0 0 1px var(--rule); transition: transform .6s var(--ease-out), box-shadow .6s var(--ease-out); }
.row-strip { display: block; width: 600%; max-width: none; height: 100%; transform: translateX(calc(var(--f, 0) * -100% / 6)); }
/* Until its pixels play (motion.js), the strip waits unseen so it never flashes sharp first. */
.px-on .row-strip:not(.px-ready) { opacity: 0; }
.row:hover .row-media { transform: scale(1.04); box-shadow: 0 0 0 1px var(--rule), 0 18px 36px -22px rgba(25, 29, 29, .5); }

/* While Flip morphs the list (filters, list and grid), the rows' CSS transitions stay out of its way. */
.index.is-morphing :is(.row, .row-media, .row-title, .index-group-head) { transition: none !important; }

/* Grid view (wide screens): the same rows as cards. */
.index.is-grid .rows { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr)); gap: clamp(32px, 3.4vw, 52px) clamp(20px, 2.4vw, 36px); padding-top: clamp(24px, 3vw, 36px); }
.index.is-grid .row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "media" "title" "kind" "line"; gap: 6px; align-items: start; padding: 0 0 6px; border-bottom: 0; }
.index.is-grid .row::before { display: none; }
.index.is-grid .row-media { margin-bottom: 14px; }
.index.is-grid .row-title { font-size: clamp(1.9rem, 2.6vw, 2.5rem); }
.index.is-grid .row:hover .row-title { transform: none; }
.index.is-grid .row-meta { display: none; }

/* The pixel lens (js/projects.js), or its plain fallback. */
.lens, .preview { position: fixed; left: 0; top: 0; z-index: 50; width: 340px; height: 212px; border-radius: var(--radius); pointer-events: none; opacity: 0;
  box-shadow: 0 30px 70px -20px rgba(25, 29, 29, .55); }
.lens.is-tall, .preview.is-tall { width: 190px; height: 304px; }
.preview { overflow: hidden; transform: scale(.85); background: var(--gown); }
.preview img { display: block; width: 100%; height: 100%; object-fit: cover; }

@media (max-width: 860px) {
  .index-head, .index-group-head { grid-template-columns: 1fr; }
  .doors.is-on { height: 220svh; }
  .doors.is-on + .index-list { margin-top: -30svh; }
  .doors.is-on .index-head h1 { font-size: clamp(4.2rem, 24vw, 7rem); }
    .index-view { display: none; }
  .index-tools { justify-content: flex-start; margin-left: calc(var(--gutter) * -1); margin-right: calc(var(--gutter) * -1); padding: 10px var(--gutter); }
  .index-filters { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; mask-image: linear-gradient(90deg, #000 82%, transparent); }
  .index-filters button { flex: 0 0 auto; }
  .row, .index.is-grid .row { grid-template-columns: minmax(0, 1fr); grid-template-areas: "media" "title" "kind" "line" "meta"; gap: 8px; padding: 26px 0; }
  .row-media { margin-bottom: 14px; }
  .row::before { display: none; }
  .row:hover .row-title, .row:hover .row-media { transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .doors-cue i { animation: none; }
}
