/* Case-study page (/work/<slug>/). Mobile-first. */

/* ------------------------------------------------------------------ Hero */
.case-hero { padding-top: var(--space-6); }
.case-hero__crumb { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.case-hero__crumb a { display: inline-flex; align-items: center; min-height: var(--tap-target-min); min-width: var(--tap-target-min); color: var(--color-text-secondary); text-decoration: none; }
.case-hero__crumb a:hover { color: var(--color-text-primary); }
.case-hero__crumb > span { display: inline-flex; align-items: center; }
.case-hero__crumb [aria-current] { color: var(--color-text-primary); }

.case-hero__head { display: grid; gap: var(--space-4); padding-block: var(--space-6) var(--space-7); }
.case-hero__meta { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.case-hero__num { color: var(--color-text-link); }
.case-hero__title { font-size: var(--font-size-4xl); max-width: 14ch; }
.case-hero__descriptor {
  font-size: var(--font-size-lg);
  font-stretch: var(--font-stretch-label);
  font-weight: var(--font-weight-semibold);
  line-height: var(--line-height-snug);
}
.case-hero__intro { display: grid; gap: var(--space-4); margin-top: var(--space-2); }
.case-hero__client { display: flex; flex-wrap: wrap; align-items: center; column-gap: var(--space-3); }

/* Hero image: left edge cut at the V angle (like the home hero), shallower on phones. */
.case-hero__media { --cut: clamp(2rem, 9vw, 9rem); }
.case-hero__frame { aspect-ratio: 16 / 10; }
/* The cut sits on the <picture>, not the frame: data-wipe clears clip-path on its direct child. */
.case-hero__frame picture {
  display: block;
  background: var(--color-bg-secondary);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% 100%, 0 100%);
}
.case-hero__frame picture, .case-hero__frame img { width: 100%; height: 100%; }
.case-hero__frame img { object-fit: cover; }

@media (min-width: 960px) {
  .case-hero__head {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-gutter);
    align-items: end;
    padding-block: var(--space-8) var(--space-8);
  }
  .case-hero__meta, .case-hero__title { grid-column: 1 / -1; }
  .case-hero__descriptor { grid-column: 1 / span 5; align-self: start; }
  .case-hero__intro { grid-column: 7 / -1; margin-top: 0; }
  .case-hero__frame { aspect-ratio: 21 / 9; }
}

/* ----------------------------------------------------------- Spec highlights */
.case-specs { padding-top: var(--space-7); }
.case-specs__list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);   /* 2 columns from 360 px */
  border-top: var(--border-width-hairline) solid var(--color-border-primary);
}
.spec {
  container-type: inline-size;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-4) var(--space-5) 0;
  border-bottom: var(--border-width-hairline) solid var(--color-border-primary);
}
@media (min-width: 360px) {
  .case-specs__list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .spec:nth-child(2n) { padding-left: var(--space-4); border-left: var(--border-width-hairline) solid var(--color-border-primary); }
}
.spec__value {
  order: -1;
  font-family: var(--font-family-numeric);
  /* Never break a word: shrink so the longest word (--chars, set in the template) fits the
     cell. Expanded 800 averages up to ≈ 0.73 em per character ("Aluminum"); 0.76 leaves a margin. Short values keep the full size. */
  font-size: min(var(--font-size-xl), 100cqi / (var(--chars, 6) * 0.76));
  font-stretch: var(--font-stretch-display);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  font-variant-numeric: tabular-nums;
  text-wrap: balance;
}
@media (min-width: 960px) {
  .case-specs__list { grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); grid-auto-flow: column; border-bottom: var(--border-width-hairline) solid var(--color-border-primary); }
  .spec { padding: var(--space-6) var(--space-5); border-bottom: 0; }
  .spec:first-child { padding-left: 0; }
  .spec + .spec { border-left: var(--border-width-hairline) solid var(--color-border-primary); padding-left: var(--space-5); }
}

/* ------------------------------------------------------------ Feature blocks
   Text + image pairs, alternating sides on desktop. Text-only features
   (no images in the write-up) sit side by side in columns instead. */
.case-features__list { display: grid; gap: var(--space-9); }
.feature { display: grid; gap: var(--space-6); align-items: center; }
.feature__frame { aspect-ratio: 16 / 10; background: var(--color-bg-secondary); overflow: hidden; }
.feature__frame picture, .feature__frame img { width: 100%; height: 100%; }
.feature__frame img { object-fit: cover; }
.feature__text { display: grid; gap: var(--space-4); align-content: start; }
.feature__num { color: var(--color-text-link); }
.feature__title {
  font-size: var(--font-size-xl);
  font-stretch: var(--font-stretch-label);
  font-weight: var(--font-weight-bold);
  letter-spacing: var(--letter-spacing-tight);
  max-width: 18ch;
}
@media (min-width: 960px) {
  .feature--media { grid-template-columns: repeat(12, minmax(0, 1fr)); column-gap: var(--space-gutter); }
  .feature--media .feature__media { grid-column: 1 / span 7; }
  .feature--media .feature__text { grid-column: 9 / -1; }
  .feature--media.feature--flip .feature__media { grid-column: 6 / -1; grid-row: 1; }
  .feature--media.feature--flip .feature__text { grid-column: 1 / span 4; grid-row: 1; }
  .case-features__list { gap: var(--space-10); }
}
/* Band: a feature without an image among features with images. Hairlines above and below;
   from 960 px the heading sits on the left and the points on the right, across the full width. */
.feature--band {
  padding-block: var(--space-6);
  border-block: var(--border-width-hairline) solid var(--color-border-primary);
}
@media (min-width: 960px) {
  .feature--band { padding-block: var(--space-8); }
  .feature--band .feature__text {
    grid-template-columns: repeat(12, minmax(0, 1fr));
    column-gap: var(--space-gutter);
    row-gap: var(--space-4);
  }
  .feature--band .feature__num { grid-column: 1 / span 5; grid-row: 1; }
  .feature--band .feature__title { grid-column: 1 / span 5; grid-row: 2; }
  .feature--band .points { grid-column: 7 / -1; grid-row: 1 / span 2; align-self: center; }
  .feature--band .feature__sources { grid-column: 7 / -1; }
}
.case-features--text .case-features__list { gap: var(--space-7); }
.case-features--text .feature { align-items: start; padding-top: var(--space-5); border-top: var(--border-width-hairline) solid var(--color-border-primary); }
@media (min-width: 640px) {
  .case-features--text .case-features__list { grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: var(--space-gutter); }
}
@media (min-width: 960px) {
  .case-features--text .case-features__list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .case-features--text .feature__title { font-size: var(--font-size-lg); }
}

/* --------------------------------------------------------- Video & gallery */
.case-section-title { margin-bottom: var(--space-5); }
.case-video { padding-top: 0; }
/* Video block: muted loop while in view (media.js). One play/pause button over the
   bottom-left corner; a red bar runs along the bottom edge while it loads. */
.video { position: relative; background: var(--color-bg-secondary); }
.video__player { width: 100%; height: auto; aspect-ratio: 16 / 9; object-fit: cover; background: var(--color-bg-secondary); }
.video__controls {
  position: absolute;
  left: var(--space-3);
  bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.video__toggle { background: var(--color-surface-overlay); }
.video__toggle .icon-pause { display: none; }
.video[data-state="playing"] .video__toggle .icon-pause,
.video[data-state="loading"] .video__toggle .icon-pause { display: block; }
.video[data-state="playing"] .video__toggle .icon-play,
.video[data-state="loading"] .video__toggle .icon-play { display: none; }
.video__status:not(:empty) {
  padding: var(--space-1) var(--space-2);
  background: var(--color-surface-overlay);
  color: var(--color-text-primary);
}
.video__loading {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.video__loading::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 30%;
  background: var(--color-accent-primary);
  transform: translateX(-100%) skewX(calc(-1 * var(--v-lean)));
}
.video[data-state="loading"] .video__loading { opacity: 1; transition: opacity var(--duration-fast) var(--easing-default) 200ms; }
.video[data-state="loading"] .video__loading::before { animation: video-loading 1.1s var(--easing-in-out) infinite; }
@keyframes video-loading { to { transform: translateX(340%) skewX(calc(-1 * var(--v-lean))); } }
@media (min-width: 640px) {
  .video__controls { left: var(--space-5); bottom: var(--space-5); }
}
@media (prefers-reduced-motion: reduce) {
  .video[data-state="loading"] .video__loading::before { animation: none; width: 100%; transform: none; opacity: 0.6; }
}
.case-video__caption { margin-top: var(--space-3); color: var(--color-text-secondary); font-size: var(--font-size-sm); }

/* ---------------------------------------------------------------- Line-up
   Brand page (HELE Powersports): its products as cards (partials/card.njk), one column on
   phones, two from 960 px. */
.case-lineup { padding-bottom: 0; }
ul.case-lineup__grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-gutter); }
@media (min-width: 960px) { ul.case-lineup__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.case-gallery { padding-top: 0; }
/* Phones: a swipeable row (scroll-snap) bleeding to the screen edge; grid from 640. */
.case-gallery__grid {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 85%;
  gap: var(--space-3);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  margin-inline: calc(-1 * var(--space-page));
  padding-inline: var(--space-page);
  scroll-padding-inline: var(--space-page);
  scrollbar-width: none;
}
ul.case-gallery__grid { padding-inline: var(--space-page); } /* beats the ul[class] reset */
.case-gallery__grid::-webkit-scrollbar { display: none; }
.case-gallery__item { scroll-snap-align: start; }
.case-gallery__item { aspect-ratio: 16 / 10; overflow: hidden; background: var(--color-bg-secondary); }
.case-gallery__link { position: relative; display: block; height: 100%; color: var(--color-text-primary); cursor: zoom-in; }
.case-gallery__link:focus-visible { box-shadow: inset 0 0 0 3px var(--color-border-focus); border-radius: 0; }
.case-gallery__item picture, .case-gallery__item img { width: 100%; height: 100%; }
.case-gallery__item img { object-fit: cover; }
.case-gallery__zoom {
  position: absolute;
  z-index: 4;
  right: var(--space-3);
  bottom: var(--space-3);
  display: grid;
  place-items: center;
  width: var(--space-6);
  height: var(--space-6);
  background: var(--color-surface-overlay);
}
.case-gallery__zoom svg { width: 1rem; height: 1rem; }
@media (hover: hover) {
  .case-gallery__zoom { opacity: 0; transition: opacity var(--duration-fast) var(--easing-default); }
  .case-gallery__link:hover .case-gallery__zoom,
  .case-gallery__link:focus-visible .case-gallery__zoom { opacity: 1; }
}
@media (min-width: 640px) {
  .case-gallery__grid { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-gutter); overflow: visible; margin-inline: 0; }
  ul.case-gallery__grid { padding-inline: 0; }
}
@media (min-width: 960px) { .case-gallery__grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

/* ---------------------------------------------------------------- Lightbox
   Native modal <dialog> (media.js). Count + close on top, the image contained in the
   middle, caption + prev/next at the bottom (in reach of a thumb). Opening fades the
   overlay and reveals the image with a V-angle mask; slides move in the direction of
   travel. Reduced motion: no movement. */
.lightbox {
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: var(--color-surface-overlay);
  color: var(--color-text-primary);
  overscroll-behavior: contain;
}
.lightbox[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
/* The page behind is fully covered: an opaque backdrop under the translucent dialog. */
.lightbox::backdrop { background: var(--color-bg-primary); }
html.lightbox-open { overflow: hidden; }
.lightbox__bar, .lightbox__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-3) var(--space-page);
}
.lightbox__foot { align-items: flex-end; padding-bottom: max(var(--space-4), env(safe-area-inset-bottom)); }
.lightbox__count { display: flex; align-items: center; gap: var(--space-3); color: var(--color-text-secondary); }
.lightbox__count [data-lb-current] { color: var(--color-text-primary); }
.lightbox__caption { max-width: 60ch; color: var(--color-text-secondary); font-size: var(--font-size-sm); }
.lightbox__nav { display: flex; flex: none; gap: var(--space-2); }
.lightbox .icon-button { background: var(--color-bg-primary); }
.lightbox__stage {
  position: relative;
  display: grid;
  min-height: 0;
  padding-inline: var(--space-page);
  overflow: hidden;
  touch-action: pan-y pinch-zoom;   /* horizontal drags are swipes */
  user-select: none;
}
.lightbox__slide {
  grid-area: 1 / 1;
  min-height: 0;
  transform: translateX(var(--drag, 0px));
}
.lightbox__slide picture {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
.lightbox__slide img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  -webkit-user-drag: none;
}
/* motion (only when allowed) */
@media (prefers-reduced-motion: no-preference) {
  .lightbox[data-state="opening"] { animation: lb-fade var(--duration-normal) var(--easing-default) both; }
  .lightbox[data-state="closing"] { animation: lb-fade var(--duration-fast) var(--easing-default) reverse both; }
  .lightbox[data-state="opening"]::backdrop { animation: lb-fade var(--duration-normal) var(--easing-default) both; }
  .lightbox[data-state="closing"]::backdrop { animation: lb-fade var(--duration-fast) var(--easing-default) reverse both; }
  .lightbox[data-state="opening"] .lightbox__slide img { animation: lb-reveal var(--duration-slow) var(--easing-out) 60ms both; }
  .lightbox__slide.is-entering { animation: lb-in var(--duration-normal) var(--easing-out) both; }
  .lightbox__slide.is-leaving { animation: lb-out var(--duration-normal) var(--easing-out) both; }
  .lightbox__slide.is-snapping { transition: transform var(--duration-normal) var(--easing-out); }
}
@keyframes lb-fade { from { opacity: 0; } }
@keyframes lb-reveal {
  from { clip-path: polygon(0 0, 0 0, -28% 100%, 0 100%); }
  to   { clip-path: polygon(0 0, 128% 0, 100% 100%, 0 100%); }
}
@keyframes lb-in  { from { opacity: 0; transform: translateX(calc(var(--dir, 1) * 3rem + var(--drag, 0px))); } }
@keyframes lb-out { to   { opacity: 0; transform: translateX(calc(var(--dir, 1) * -3rem + var(--drag, 0px))); } }
.lightbox__slide.is-leaving { pointer-events: none; }
@media (min-width: 960px) {
  .lightbox__stage { padding-inline: var(--space-9); }
}

/* ---------------------------------------------------------- Services used */
.case-services__inner {
  display: grid;
  gap: var(--space-4);
  padding-block: var(--space-6);
  border-top: var(--border-width-hairline) solid var(--color-border-primary);
}
@media (min-width: 960px) {
  .case-services__inner { grid-template-columns: 3fr 9fr; align-items: center; }
}

/* ------------------------------------------------------------ Next project */
.case-next { margin-top: var(--space-4); }
.case-next__link {
  position: relative;
  display: grid;
  gap: var(--space-2);
  padding-block: var(--space-7);
  border-block: var(--border-width-hairline) solid var(--color-border-primary);
  color: inherit;
  text-decoration: none;
}
.case-next__label { color: var(--color-text-link); }
.case-next__title { font-size: var(--font-size-2xl); transition: color var(--duration-fast) var(--easing-default); }
.case-next__descriptor { color: var(--color-text-secondary); }
.case-next__link:hover .case-next__title { color: var(--color-text-link); }
.case-next__link:focus-visible { box-shadow: var(--shadow-focus); }
.case-next__media { display: none; }
@media (min-width: 960px) {
  .case-next__link { grid-template-columns: 1fr auto; grid-template-rows: auto auto 1fr; column-gap: var(--space-gutter); align-items: start; }
  .case-next__label, .case-next__title, .case-next__descriptor { grid-column: 1; }
  .case-next__media {
    --cut: 3rem;
    display: block;
    grid-column: 2;
    grid-row: 1 / span 3;
    width: 22rem;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--color-bg-secondary);
    clip-path: polygon(var(--cut) 0, 100% 0, calc(100% - var(--cut)) 100%, 0 100%);
  }
  .case-next__media picture, .case-next__media img { width: 100%; height: 100%; }
  .case-next__media img { object-fit: cover; transition: transform var(--duration-slower) var(--easing-out); }
  .case-next__link:hover .case-next__media img { transform: scale(1.04); }
}
@media (prefers-reduced-motion: reduce) {
  .case-next__link:hover .case-next__media img { transform: none; }
}

/* ------------------------------------------------------- Product variant */
.case-hero__title--logo { line-height: 1; }
.case-hero__logo { height: clamp(4.5rem, 11vw, 9rem); width: auto; }
.case-hero__actions { margin-top: var(--space-2); }

/* ------------------------------------------------ Line-art feature frame
   A live drawing (lineart.js) in place of a render: panel colour, a faint navy
   glow behind the model, a mono readout and a pause button in the corners. */
.lineart-frame {
  position: relative;
  background:
    radial-gradient(ellipse 55% 60% at 50% 48%, var(--color-accent-glow), transparent 70%),
    var(--color-bg-secondary);
}
.lineart-frame__canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.lineart-frame__readout {
  position: absolute;
  left: var(--space-4);
  bottom: var(--space-4);
  margin: 0;
  color: var(--color-text-primary);
  font-variant-numeric: tabular-nums;
}
.lineart-frame__readout:empty { display: none; }
.lineart-frame__pause { position: absolute; right: var(--space-2); bottom: var(--space-2); }
.lineart-frame__pause .icon-play { display: none; }
.lineart-frame__pause[aria-pressed="true"] .icon-pause { display: none; }
.lineart-frame__pause[aria-pressed="true"] .icon-play { display: block; }
html:not(.js) .lineart-frame__canvas, html:not(.js) .lineart-frame__pause { display: none; }
