/* =============================================================================
   COMPONENT: FILM REEL (project cards)
   One frame template (js/components/project-card.js), two looks:
     .reel            horizontal film strip on the home page (js/components/reel.js)
     .reel--list      calm, readable cards in door portals and "Up next"
   ============================================================================= */

/* ---- Spool: CSS-only film reel that spins with scroll ------------------ */
.spool {
  position: relative;
  flex: none;
  width: clamp(80px, 9vw, 120px);
  aspect-ratio: 1;
  margin-top: 8px;
  border-radius: 50%;
  background:
    radial-gradient(circle, var(--film-edge) 0 9%, var(--c-paper) 9.5% 14%, var(--film-edge) 14.5% 17%, transparent 17.5%),
    radial-gradient(circle at 50% 21%, var(--c-mint) 0 11%, transparent 11.5%),
    radial-gradient(circle at 79% 41%, var(--c-mint) 0 11%, transparent 11.5%),
    radial-gradient(circle at 68% 75%, var(--c-mint) 0 11%, transparent 11.5%),
    radial-gradient(circle at 32% 75%, var(--c-mint) 0 11%, transparent 11.5%),
    radial-gradient(circle at 21% 41%, var(--c-mint) 0 11%, transparent 11.5%),
    var(--film);
  border: var(--b-thin) solid var(--film-edge);
  box-shadow: inset 0 0 0 8px var(--film-soft);
  rotate: var(--spin, 0deg);
}

/* ---- The band (horizontal) -------------------------------------------- */
.reel {
  /* Film stock: the original ink black */
  --film: var(--c-ink);
  --film-soft: #3b342d;
  --film-edge: #3b342d;
  --hole-h: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='34' height='16'%3E%3Crect x='8' y='3' width='18' height='10' rx='3' fill='%23faf1dc'/%3E%3C/svg%3E");
  --hole-v: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='34'%3E%3Crect x='3' y='8' width='10' height='18' rx='3' fill='%23faf1dc'/%3E%3C/svg%3E");
  position: relative;
  margin-top: clamp(4px, 1vw, 12px);
  background: var(--film);
  border-block: var(--b-thin) solid var(--film-edge);
}

.reel__track {
  --edge: max(var(--gutter), calc((100vw - var(--wrap)) / 2 + var(--gutter)));
  position: relative; /* offsetParent for frames: reel.js measures against it */
  display: flex;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: var(--edge);
  padding-inline: var(--edge);
  scrollbar-width: none;
  cursor: grab;
  touch-action: pan-x pan-y;
}

.reel__track::-webkit-scrollbar { display: none; }
.reel__track.is-dragging { cursor: grabbing; scroll-snap-type: none; }
/* Auto-scroll drifts a pixel at a time, so snapping must stay out of the way */
.reel__track.is-free { scroll-snap-type: none; }
.reel__track.is-dragging a { pointer-events: none; }
.reel__track img { -webkit-user-drag: none; user-select: none; }

/* ---- Frame ------------------------------------------------------------ */
.frame {
  position: relative;
  flex: none;
  width: min(760px, 86vw);
  padding: 28px 14px;
  scroll-snap-align: start;
  border-right: 1px solid var(--film-edge);
}

/* Sprocket holes travel with each frame on the horizontal film */
.frame::before,
.frame::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 16px;
  background: var(--hole-h) repeat-x 0 0 / 34px 16px;
  opacity: 0.92;
}

.frame::before { top: 6px; }
.frame::after  { bottom: 6px; }

.frame__inner {
  position: relative; /* the stretched title link fills this */
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.15fr);
  grid-template-areas: "shot body";
  height: 100%;
  background: var(--c-paper);
  border: var(--b) solid var(--c-cream);
  border-radius: 4px;
  overflow: hidden;
}

.frame__shot {
  grid-area: shot;
  position: relative;
  min-height: 220px;
  background: var(--tone, var(--c-butter));
  border-right: var(--b-thin) solid var(--film-edge);
  overflow: hidden;
}

.frame__shot img {
  width: 100%;
  height: 100%;
  min-height: 220px;
  object-fit: cover;
  transition: scale 600ms var(--e-out), rotate 600ms var(--e-out);
}

/* Shine that sweeps across the shot on hover (and once on reveal in portals) */
.frame__shot::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(105deg, transparent 38%, rgb(255 255 255 / 0.55) 50%, transparent 62%);
  translate: -110% 0;
  pointer-events: none;
}

/* No screenshot yet: halftone + comic lines in the project's tone */
.frame__placeholder {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: inherit;
  padding: 28px;
  background:
    radial-gradient(rgb(22 19 15 / 0.2) 1.4px, transparent 1.6px) 0 0 / 12px 12px,
    repeating-conic-gradient(from 0deg at 50% 50%, rgb(255 255 255 / 0.4) 0 6deg, transparent 6deg 18deg),
    var(--tone, var(--c-butter));
}

.frame__placeholder span {
  padding: 8px 14px;
  background: var(--c-paper);
  border: var(--b) solid var(--c-ink);
  box-shadow: var(--sh);
  font: 400 clamp(1.1rem, 0.9rem + 0.8vw, 1.5rem)/1 var(--f-heading);
  letter-spacing: 0.03em;
  text-align: center;
  text-transform: uppercase;
  rotate: -3deg;
}

.frame__no {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  padding: 3px 9px;
  background: var(--c-ink);
  color: var(--c-paper);
  font: 700 0.72rem/1.3 var(--f-label);
  letter-spacing: 0.08em;
}

/* "New" sticker with a ring that pings outward */
.frame__fresh {
  position: absolute;
  top: 10px;
  right: 12px;
  z-index: 2;
  padding: 4px 12px 2px;
  background: var(--c-mustard);
  border: var(--b-thin) solid var(--c-ink);
  box-shadow: var(--sh-sm);
  font: 400 1.15rem/1 var(--f-heading);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  rotate: 6deg;
}

.frame__fresh::after {
  content: "";
  position: absolute;
  inset: -6px;
  border: 3px solid var(--c-mustard);
  border-radius: 6px;
  animation: ping 1.8s var(--e-out) infinite;
}

@keyframes ping {
  from { opacity: 0.9; scale: 0.9; }
  to   { opacity: 0; scale: 1.35; }
}

.frame__sample {
  position: absolute;
  right: 12px;
  bottom: 14px;
  z-index: 2;
  background: rgb(255 250 240 / 0.85);
  font-size: 0.8rem;
}

.frame__body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: clamp(16px, 2.2vw, 24px);
}

.frame__title {
  font: 800 clamp(1.5rem, 1.1rem + 1.4vw, 2.15rem)/1.12 var(--f-body);
  letter-spacing: -0.02em;
}

/* The whole card is clickable (see project-card.js), but the text stays selectable:
   there is no overlay on top of it. */
.frame__body :is(.frame__title, .frame__rhyme, .frame__text, .meta) { user-select: text; cursor: text; }
.frame__body .frame__link { cursor: pointer; }

.frame__link:focus-visible { outline: none; }
.frame--link:has(.frame__link:focus-visible) .frame__inner { outline: 3px solid var(--c-red); outline-offset: 3px; }

.frame__rhyme {
  font: 700 var(--t-sm)/1.4 var(--f-accent);
  color: var(--c-ink-soft);
}

.frame__text { font-size: var(--t-sm); line-height: 1.5; color: var(--c-ink-soft); }
.frame__body .btn { align-self: flex-start; margin-top: auto; }

@media (hover: hover) {
  .frame--link { cursor: pointer; }
  .frame--link:hover .frame__shot img { scale: 1.04; rotate: -0.6deg; }
  .frame--link:hover .frame__shot::after { translate: 110% 0; transition: translate 900ms var(--e-out); }
  .frame--link:hover .frame__cta { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--c-ink); }
}

/* Active card (home film strip only): the hovered card lifts, the others step back */
.reel:not(.reel--list) .frame__inner { transition: transform 280ms var(--e-out), box-shadow 280ms var(--e-out); }
.reel:not(.reel--list) .frame { transition: opacity 280ms var(--e-out), filter 280ms var(--e-out); }
.reel__track.has-active .frame:not(.is-active) { opacity: 0.45; filter: saturate(0.6); }
.reel__track .frame.is-active .frame__inner { transform: translateY(-4px) scale(1.02); box-shadow: 0 18px 34px -10px rgb(0 0 0 / 0.55); z-index: 2; }
.reel__track .frame.is-active .frame__cta { transform: translate(-2px, -2px); box-shadow: 7px 7px 0 var(--c-ink); }

/* ---- Last frame: film leader countdown ------------------------------- */
.frame--leader .frame__inner {
  grid-template-columns: 1fr;
  grid-template-areas: none;
  place-items: center;
  align-content: center;
  padding: clamp(24px, 4vw, 40px);
  text-align: center;
  background: #e9e1cc;
}

.frame--leader .frame__title { max-width: 18ch; }
.frame--leader .frame__text { max-width: 40ch; margin: 12px auto 0; }

.frame__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 18px;
}

/* ---- Small screens: shot on top, copy below --------------------------- */
@media (max-width: 760px) {
  .frame { width: 86vw; padding: 30px 10px; }

  .frame__inner {
    grid-template-columns: 1fr;
    grid-template-areas: "shot" "body";
  }

  .frame--leader .frame__inner { grid-template-areas: none; }

  .frame__shot {
    min-height: 0;
    border: 0;
    border-bottom: var(--b) solid var(--c-ink);
  }

  .frame__shot img { min-height: 0; aspect-ratio: 4 / 3; }
  .frame__placeholder { min-height: 0; aspect-ratio: 4 / 3; }
}

/* =============================================================================
   LIST: the same frames as calm, readable cards (no film, no flips).
   Used by each door's portal and by "Up next" on case studies. Every card has
   the same layout so a reader scans them in one rhythm:
     [ shot 5/12 ] [ meta · title (≤ 3 lines) · rhyme · summary (≤ 3 lines) · link ]
   ============================================================================= */
.reel--list {
  --list-surface: #fffdf8;
  --list-line:    rgb(29 25 20 / 0.16);
  --list-muted:   #57504a;
  --list-shadow:  0 1px 2px rgb(29 25 20 / 0.06), 0 8px 24px -12px rgb(29 25 20 / 0.22);
  display: grid;
  gap: clamp(16px, 2vw, 24px);
  margin: 0;
  background: none;
  border: 0;
}

.reel--list .frame {
  width: auto;
  padding: 0;
  border: 0;
}

.reel--list .frame::before,
.reel--list .frame::after { display: none; }

.reel--list .frame__inner {
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  grid-template-areas: "shot body";
  background: var(--list-surface);
  border: 1px solid var(--list-line);
  border-radius: 16px;
  box-shadow: var(--list-shadow);
  transition: border-color var(--d-mid), box-shadow var(--d-mid) var(--e-out), translate var(--d-mid) var(--e-out);
}

/* The leader is a quiet dashed panel, not a card */
.reel--list .frame--leader .frame__inner { box-shadow: none; }

/* The shot stretches to the full height of the card (no fixed ratio, which
   would stop it short of a tall text column); the image covers it. */
.reel--list .frame__shot {
  min-height: 240px;
  border-right: 1px solid var(--list-line);
}

.reel--list .frame__shot img,
.reel--list .frame__placeholder {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: cover;
}
.reel--list .frame__shot::after,
.reel--list .frame__no { display: none; }

.reel--list .frame__placeholder {
  background:
    repeating-linear-gradient(-45deg, rgb(255 255 255 / 0.35) 0 10px, transparent 10px 20px),
    var(--tone-tint, var(--c-butter-tint));
}

.reel--list .frame__placeholder span {
  padding: 0;
  background: none;
  border: 0;
  box-shadow: none;
  font: 600 0.9rem/1.4 var(--f-body);
  letter-spacing: 0;
  text-transform: none;
  color: var(--list-muted);
  rotate: none;
}

/* "New" and "Sample": small, flat pills */
.reel--list :is(.frame__fresh, .frame__sample) {
  top: 12px;
  right: auto;
  bottom: auto;
  left: 12px;
  padding: 4px 10px;
  background: var(--c-paper);
  border: 1px solid var(--list-line);
  border-radius: 999px;
  box-shadow: none;
  font: 700 0.72rem/1.2 var(--f-body);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  rotate: none;
}

.reel--list .frame__fresh::after { display: none; }
.reel--list .frame__fresh + .frame__sample { left: 72px; }

.reel--list .frame__body {
  gap: 10px;
  padding: clamp(20px, 2.6vw, 32px);
}

.reel--list .meta {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--list-muted);
}

.reel--list .meta > * + *::before { content: "·"; color: inherit; }

/* Clamp as a safety net: titles and summaries never run past 3 lines */
.reel--list :is(.frame__title, .frame__text) {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
}

.reel--list .frame__title {
  font: 800 clamp(1.25rem, 1.1rem + 0.6vw, 1.6rem)/1.22 var(--f-body);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.reel--list .frame__rhyme {
  font: italic 500 0.95rem/1.4 var(--f-body);
  color: var(--list-muted);
}

.reel--list .frame__text {
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--list-muted);
}

/* CTA reads as a link, not a sticker */
.reel--list .frame__cta {
  min-height: 0;
  margin-top: auto;
  padding: 8px 0 0;
  background: none;
  border: 0;
  box-shadow: none;
  font: 700 0.95rem/1.3 var(--f-body);
  color: var(--c-ink);
}

.reel--list .frame__cta[aria-disabled="true"] { color: var(--list-muted); font-weight: 600; cursor: default; }

@media (hover: hover) {
  .reel--list .frame--link:hover .frame__inner {
    translate: 0 -3px;
    border-color: rgb(29 25 20 / 0.28);
    box-shadow: 0 18px 36px -22px rgb(29 25 20 / 0.45);
  }
  .reel--list .frame--link:hover .frame__shot img { scale: 1.03; rotate: none; }
  .reel--list .frame--link:hover .frame__cta { transform: none; box-shadow: none; text-decoration: underline; text-underline-offset: 4px; }
}

/* Last card: a quiet "more coming" panel with links to the other doors */
.reel--list .frame--leader .frame__inner {
  grid-template-columns: 1fr;
  grid-template-areas: none;
  padding: clamp(24px, 4vw, 40px);
  background: transparent;
  border-style: dashed;
  border-color: rgb(29 25 20 / 0.25);
  text-align: center;
}

.reel--list .frame--leader .frame__title { max-width: none; -webkit-line-clamp: unset; font-size: 1.2rem; }

.reel--list .frame__actions .btn {
  min-height: 40px;
  padding: 8px 16px;
  background: var(--list-surface);
  border: 1px solid rgb(29 25 20 / 0.25);
  border-radius: 999px;
  box-shadow: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.reel--list .frame__actions .btn:hover { transform: none; background: var(--c-paper); border-color: var(--c-ink); box-shadow: none; }
.reel--list .frame__actions .btn--mustard { background: var(--c-ink); color: var(--c-paper); border-color: var(--c-ink); }
.reel--list .frame__actions .btn--mustard:hover { background: #000; }

@media (max-width: 700px) {
  .reel--list .frame__inner { grid-template-columns: 1fr; grid-template-areas: "shot" "body"; }
  .reel--list .frame--leader .frame__inner { grid-template-areas: none; }
  .reel--list .frame__shot { min-height: 0; aspect-ratio: 16 / 10; border-right: 0; border-bottom: 1px solid var(--list-line); }
}

/* Thumbnails drawn as a whole picture (image.fit = "contain" in projects.js): shown uncropped
   on their own background colour, in the film reel and in every list card shape. */
.frame .frame__shot--fit { background: var(--shot-bg, var(--tone, var(--c-butter))); }
.frame .frame__shot--fit img,
.reel--list .frame__shot--fit img { object-fit: contain; }
