/* One continuous scene: the existing left-aligned story flows above a tilted
   3-row desktop / 5-row mobile archive. Rows stay filled while moving. */
main>.section.past-works {
  --works-opacity:.28;
  --works-deck-y:28px;
  --works-rotate-x:14deg;
  --works-rotate-z:9deg;
  --works-scale:1;
  --works-controls-bottom:clamp(22px,4svh,44px);
  position:relative;
  isolation:isolate;
  width:100%;max-width:none;margin:0;padding:0;
  min-height:0;
  overflow:clip;
  perspective:1200px;
}
.past-works::before {
  content:'';position:absolute;inset:0;z-index:-1;pointer-events:none;
  background:radial-gradient(ellipse at 50% 28%,oklch(.88 .145 96 / .028),transparent 55%);
}
.past-works .works-scene {
  position:sticky;
  top:var(--header-height);
  height:calc(100svh - var(--header-height));
  width:100%;margin:0;overflow:hidden;
  display:grid;place-items:center;
  z-index:0;
  transform-style:preserve-3d;
}
.past-works .works-deck {
  display:grid;
  gap:clamp(15px,2.2vw,26px);
  width:max-content;
  position:absolute;
  left:50%;top:50%;
  opacity:var(--works-opacity);
  transform:translate3d(-50%,calc(-50% + var(--works-deck-y)),0)
    rotateX(var(--works-rotate-x)) rotateZ(var(--works-rotate-z)) scale(var(--works-scale));
  transform-origin:center;
  will-change:transform,opacity;
  transform-style:preserve-3d;
}
.past-works .works-deck-mobile,.past-works .works-deck-compact,.past-works .works-deck-single {display:none}
/* Quiet the moving covers beneath the story, then lift the same veil as the
   archive straightens. Text stays on the page rather than inside a new card. */
.past-works .works-scene::after {
  content:'';position:absolute;inset:0;z-index:1;pointer-events:none;
  opacity:var(--works-reading-opacity,1);
  background:linear-gradient(90deg,oklch(.155 .008 90 / .82),oklch(.155 .008 90 / .76) 50%,oklch(.155 .008 90 / .3) 80%,transparent);
}
.works-row-window {
  width:155vw;
  display:flex;
  justify-content:flex-start;
  overflow:hidden;
}
.works-row-track {
  display:flex;
  flex:0 0 auto;
  width:max-content;
  will-change:transform;
}
.works-row {
  display:flex;
  flex:0 0 auto;
  width:max-content;
  gap:clamp(12px,1.7vw,22px);
  margin:0;
  padding:0 clamp(6px,.85vw,12px);
  list-style:none;
}
.work-card {
  flex:0 0 min(clamp(320px,26vw,430px),calc((100svh - var(--header-height) - 132px) * .59259));
  width:min(clamp(320px,26vw,430px),calc((100svh - var(--header-height) - 132px) * .59259));
  min-width:0;
}
.work-card a {
  position:relative;display:block;aspect-ratio:16/9;
  overflow:hidden;color:inherit;text-decoration:none;
  background:var(--surface);
  border:1px solid oklch(.43 .025 90 / .38);
  box-shadow:0 14px 42px oklch(.08 .006 90 / .18);
  transition:transform .34s var(--ease),border-color .3s var(--ease),box-shadow .34s var(--ease);
  transform:translateZ(0);
}
.work-card a::after {
  content:'';position:absolute;inset:0;z-index:1;pointer-events:none;
  background:linear-gradient(180deg,transparent 26%,oklch(.08 .008 90 / .9) calc(100% - 64px),oklch(.08 .008 90 / .95) 100%);
  opacity:1;
  transition:opacity .3s var(--ease);
}
.work-card a:hover,.work-card a:focus-visible {
  /* Inset highlight maintains depth without moving outside a clipped row. */
  transform:translate3d(0,0,0);
  border-color:oklch(.88 .145 96 / .72);
  box-shadow:inset 0 0 0 1px oklch(.88 .145 96 / .3),0 14px 42px oklch(.08 .006 90 / .18);
  outline:none;
}
.work-card a:hover::after,.work-card a:focus-visible::after{opacity:1}
.work-cover {display:block;position:absolute;inset:0;background:var(--surface);overflow:hidden}
.work-cover img {
  display:block;width:100%;height:100%;object-fit:cover;
  filter:saturate(.92) brightness(.94);
  transition:transform .65s var(--ease),filter .42s var(--ease);
}
.work-card a:hover img,.work-card a:focus-visible img {transform:scale(1.04);filter:saturate(1) brightness(1.04)}
.work-duration {
  position:absolute;z-index:3;right:9px;top:9px;
  padding:3px 6px;background:oklch(.1 .008 90 / .82);
  font:11px/1.4 var(--font-mono);color:var(--text);
}
.work-meta {
  position:absolute;z-index:2;left:13px;right:13px;bottom:10px;
  display:grid;grid-template-columns:minmax(0,1fr) auto;
  gap:2px 10px;align-items:end;pointer-events:none;
}
.work-meta,.work-duration{opacity:var(--work-metadata-opacity,1)}
.work-card h3 {
  grid-column:1/-1;margin:0;color:var(--text);
  font-size:clamp(13px,1.1vw,16px);line-height:1.35;font-weight:500;
  text-shadow:0 2px 10px oklch(.05 .005 90 / .6);
  overflow-wrap:anywhere;
}
.work-card a:hover h3,.work-card a:focus-visible h3 {color:var(--gold)}
.work-author {min-width:0;color:oklch(.86 .012 90);font-size:11px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.work-bvid {color:oklch(.72 .012 90);font:10px/1.4 var(--font-mono);letter-spacing:.02em;white-space:nowrap}

/* Preserve the original editorial typography and left alignment. */
.past-works .works-intro {
  position:relative;z-index:2;
  width:min(calc(100% - 2 * var(--gutter)),1120px);
  margin:calc(-100svh + var(--header-height)) auto 0;
  min-height:0;
  padding:clamp(65px,9svh,106px) 0 calc(100svh - var(--header-height) + 16px);
  background:transparent;
  text-align:left;
  pointer-events:none;
}
.past-works .works-intro::before {content:none}
.past-works .works-intro .section-heading {margin-bottom:clamp(20px,3vw,34px);opacity:1}
.past-works .works-intro h2 {text-align:left}
.works-intro-body {max-width:720px}
.works-intro-paragraph {
  margin:0 0 clamp(16px,2.5vw,26px);
  color:var(--muted);
  font-size:clamp(15px,1.28vw,17px);
  line-height:1.95;letter-spacing:.01em;
  white-space:pre-line;text-align:left;
  text-shadow:0 1px 7px rgb(0 0 0 / .35);
}
.works-intro-paragraph.is-lead {color:var(--text);font-size:clamp(17px,1.8vw,21px)}
.works-intro-paragraph.is-closing {color:var(--text);margin-bottom:0}
.past-works .works-intro .reveal-pending {opacity:1}

/* The supplied two-line logo remains unmodified. */
.gala-brand-logoonly .brand-wordmark {aspect-ratio:1882/384;width:100%;overflow:visible}
.gala-brand-logoonly .brand-wordmark img {position:static;display:block;max-width:100%;width:100%;height:auto}
.gala-brand-logoonly {width:clamp(164px,15vw,210px)}

@media(max-height:800px) and (min-width:601px) {
  .work-card{flex-basis:min(clamp(300px,26vw,400px),calc((100svh - var(--header-height) - 116px) * .59259));width:min(clamp(300px,26vw,400px),calc((100svh - var(--header-height) - 116px) * .59259))}
  .past-works .works-deck{gap:16px;top:calc(50% - 40px)}
}
@media(max-width:900px) {
  main>.section.past-works{min-height:0}
  .past-works .works-intro{padding-top:65px}
  .gala-brand-logoonly{width:170px}
  .works-row-window{width:155vw}
  .work-card{flex-basis:min(clamp(290px,40vw,355px),calc((100svh - var(--header-height) - 116px) * .59259));width:min(clamp(290px,40vw,355px),calc((100svh - var(--header-height) - 116px) * .59259))}
}
@media(max-width:600px) {
  .past-works .works-deck-desktop {display:none}
  .past-works .works-deck-mobile {display:grid}
  main>.section.past-works{min-height:0}
  .past-works .works-intro{padding-top:92px;padding-bottom:calc(100svh - var(--header-height) + 12px)}
  .works-intro-paragraph{font-size:14px;line-height:1.9}
  .works-intro-paragraph.is-lead{font-size:16px}
  .past-works .works-deck {--mobile-row-gap:clamp(6px,1svh,10px);--mobile-inset:clamp(44px,6.1svh,56px);gap:var(--mobile-row-gap)}
  .works-row-window{width:166vw}
  .works-row{gap:12px;padding:0 6px}
  /* Five 16:9 rows fit between the fixed header and the bottom of the scene.
     In short landscape/phone viewports height wins over width; no cropped rows. */
  .work-card{
    --mobile-card: min(65vw, calc((100svh - var(--header-height) - 2 * var(--mobile-inset) - 4 * var(--mobile-row-gap)) * .35555556));
    flex:0 0 var(--mobile-card);
    width:var(--mobile-card);
  }
  .work-meta{left:10px;right:10px;bottom:8px}
  .work-card h3{font-size:12px}
  .work-author{font-size:10px}
  .work-bvid{display:none}
  .work-duration{right:7px;top:7px;font-size:10px}
  .gala-brand-logoonly{width:154px}
}
@media(prefers-reduced-motion:reduce) {
  .past-works .works-scene::after{display:none}
  main>.section.past-works{display:flex;flex-direction:column;min-height:auto;padding:clamp(56px,8vw,96px) 0;perspective:none}
  .past-works .works-intro{order:1;margin:0 auto;padding:0 0 40px}
  .past-works .works-scene{order:2;position:relative;top:auto;height:auto;min-height:0;overflow:visible;display:block}
  .past-works .works-deck{position:static;transform:none;opacity:1;width:100%;gap:20px}
  .works-row-window{width:100%;overflow:visible}
  .works-row-track{transform:none!important;width:100%;display:block}
  .works-row-copy[aria-hidden='true']{display:none}
  .works-row{width:100%;display:flex;flex-wrap:wrap;justify-content:center;gap:16px}
  .work-card{flex:1 1 245px;max-width:290px;width:auto}
  .work-card a,.work-cover img{transition:none}
  .work-card a:hover,.work-card a:focus-visible{transform:none}
}

/* Small portrait screens get three legible rows; normal phones keep five. */
@media(max-width:600px) and (max-height:680px) {
  .past-works .works-deck-desktop{display:grid}
  .past-works .works-deck-mobile{display:none}
  .work-card{--mobile-card:min(76vw,calc((100svh - var(--header-height) - 104px) * .59259259))}
}
/* A short landscape viewport cannot carry three full metadata rows. Preserve
   every work in two larger rows and reserve space below for desktop controls. */
@media(orientation:landscape) and (max-height:500px) {
  .past-works .works-deck-desktop,.past-works .works-deck-mobile{display:none}
  .past-works .works-deck-compact{display:grid;gap:12px}
  .works-deck-compact .work-card h3{font-size:12px;line-height:1.3}
  .works-deck-compact .work-bvid{display:none}
  .works-deck-compact .work-meta{left:10px;right:10px;bottom:8px}
  main>.section.past-works{--works-controls-bottom:14px}
}

/* Reserve the arrow hit area before sizing/centering the three artwork rows.
   The upper bound preserves the original cover size on taller viewports. */
@media(prefers-reduced-motion:no-preference) and (min-width:601px) {
  .past-works .works-deck-desktop{
    --archive-gap:clamp(15px,2.2vw,26px);
    --archive-ideal:clamp(320px,26vw,430px);
    --archive-bottom:calc(var(--works-controls-bottom) + 46px + 12px);
    --archive-card:min(var(--archive-ideal),calc((100svh - var(--header-height) - var(--archive-bottom) - 8px - 2 * var(--archive-gap)) * .59259259));
    gap:var(--archive-gap);
    top:min(50%,calc(100% - var(--archive-bottom) - var(--archive-card) * .84375 - var(--archive-gap)));
  }
  .works-deck-desktop .work-card{flex-basis:var(--archive-card);width:var(--archive-card)}
}
@media(prefers-reduced-motion:no-preference) and (min-width:601px) and (max-height:800px) {
  .past-works .works-deck-desktop{--archive-gap:16px;--archive-ideal:clamp(300px,26vw,400px)}
}
@media(prefers-reduced-motion:no-preference) and (min-width:601px) and (max-width:900px) {
  .past-works .works-deck-desktop{--archive-ideal:clamp(290px,40vw,355px)}
}
@media(prefers-reduced-motion:no-preference) and (orientation:landscape) and (max-height:500px) {
  .past-works .works-deck-compact{
    --archive-bottom:calc(var(--works-controls-bottom) + 46px + 12px);
    --archive-card:min(300px,calc((100svh - var(--header-height) - var(--archive-bottom) - 8px - 12px) * .88888889));
    top:min(50%,calc(100% - var(--archive-bottom) - var(--archive-card) * .5625 - 6px));
  }
  .works-deck-compact .work-card{flex-basis:var(--archive-card);width:var(--archive-card)}
}
@media(prefers-reduced-motion:no-preference) and (orientation:landscape) and (max-height:500px) and (max-width:600px) {
  .past-works .works-deck-compact{--archive-bottom:20px}
}

/* Direct navigation target after the introduction: #works lands on the
   expanded perspective state without introducing another gallery section. */
.works-full-anchor {
  display:block;
  width:1px;
  height:1px;
  /* Leave the last story line above the fixed header when #works is opened. */
  margin:40px 0 0;
  padding:0;
  pointer-events:none;
  scroll-margin-top:0; /* Root already provides fixed-header scroll padding. */
}

/* A gallery consumes wheel input only over its visible artwork. Horizontal
   touch is handled in JS; pan-y remains browser-native and scrolls the page. */
.past-works .works-scene { touch-action:pan-y pinch-zoom; }
.past-works .works-intro .section-heading,
.past-works .works-intro-body { pointer-events:auto; }

/* Desktop archive navigation: small editorial arrow pair, not a scroll trap. */
.works-controls {
  position:absolute;
  z-index:5;
  right:var(--gutter);
  bottom:var(--works-controls-bottom);
  display:flex;
  gap:8px;
  align-items:center;
  opacity:var(--works-controls-opacity,0);
  transition:opacity .25s ease;
}
.works-arrow {
  display:grid;
  place-items:center;
  width:46px;
  height:46px;
  padding:0;
  background:oklch(.155 .008 90 / .3);
  border:1px solid oklch(.85 .03 90 / .27);
  border-radius:50%;
  color:var(--text);
  cursor:pointer;
  backdrop-filter:blur(5px);
  transition:color .22s ease,background .22s ease,border-color .22s ease,transform .22s ease;
}
.works-arrow svg {width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:round}
.works-arrow:hover,.works-arrow:focus-visible {color:var(--gold);background:oklch(.22 .018 90 / .72);border-color:var(--gold);outline:none}
.works-arrow:active {transform:scale(.93)}
@media (max-width:600px) { .works-controls {display:none} }
@media (prefers-reduced-motion:reduce) { .works-controls {display:none} }

/* Touch browsers synthesize :hover after tapping. Only precise hover devices
   should show the desktop hover style; keyboard focus remains accessible. */
@media (hover:none), (pointer:coarse) {
  .work-card a:hover {transform:none;border-color:oklch(.43 .025 90 / .38);box-shadow:0 14px 42px oklch(.08 .006 90 / .18)}
  .work-card a:hover::after {opacity:.85}
  .work-card a:hover img {transform:none;filter:saturate(.92) brightness(.94)}
  .work-card a:hover h3 {color:var(--text)}
  .work-card a:focus-visible {outline:2px solid var(--gold);outline-offset:-3px}
}

/* Mobile typography remains legible at the row count selected from the
   actual available scene. Do not override the measured deck with !important. */
@media(max-width:600px) and (orientation:portrait){
  .past-works .works-deck-mobile{
    --mobile-inset:clamp(21px,4.2svh,36px);
    --mobile-row-gap:clamp(5px,.75svh,9px);
    gap:var(--mobile-row-gap);
    top:50%;
  }
  .past-works .works-scene{max-width:100%;overflow:hidden;contain:paint}
  .past-works .works-row-window{width:150vw;max-width:none;overflow:hidden}
  .past-works .works-row{gap:10px;padding-inline:5px}
  .past-works .work-card{
    --mobile-card:min(64vw,calc((100svh - var(--header-height) - 2 * var(--mobile-inset) - 4 * var(--mobile-row-gap)) * .35555556));
    flex:0 0 var(--mobile-card);width:var(--mobile-card);max-width:none;
  }
  .past-works .work-card h3{
    font-size:clamp(10px,2.8vw,12px);line-height:1.24;
    display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
    overflow:hidden;
  }
  .past-works .work-author{font-size:10px}
  .past-works .work-meta{left:8px;right:8px;bottom:6px;gap:1px}
  .past-works .work-card a::after{background:linear-gradient(180deg,transparent 36%,rgba(0,0,0,.82) 100%)}
}

/* Active row count is measured from the scene, not a device-name breakpoint. */
@media(prefers-reduced-motion:no-preference){
 #about[data-archive-layout] .works-deck{display:none}
 #about[data-archive-layout] .works-deck.is-active{display:grid;gap:var(--adaptive-gap);top:var(--adaptive-center)}
 #about[data-archive-layout] .works-deck .work-card{flex-basis:var(--adaptive-card);width:var(--adaptive-card)}
 #about[data-archive-layout] .works-controls{display:flex}
}
@media(hover:none) and (pointer:coarse){#about[data-archive-layout] .works-controls{display:none}}
