/* ============================================================ WORK — "Tasting flight"
   Selected Work as a horizontal flight of glass plates.
   Physics are native scroll-snap (touch, trackpad and RTL are 100% the browser's own).
   Focus, parallax and the liquid progress tube are scroll-driven on supporting browsers
   (zero JS per frame); js/work-swiper.js adds controls, keyboard, mouse drag, the counter,
   the pour-in and an IntersectionObserver fallback for the focus state.
   Motion curves and liquid colours come only from the shared :root tokens. */

#work { overflow-x: clip; } /* the track bleeds to the viewport edges */

.ws { position: relative; timeline-scope: --ws-x; }

/* ------------------------------------------------------------------ track */
.ws__track {
  --ws-w: min(1040px, 84vw);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: var(--ws-w);
  gap: clamp(16px, 2.4vw, 32px);
  /* full-bleed: break out of .container, then pad so the first and last plates centre */
  margin-inline: calc(50% - 50vw);
  padding-inline: calc((100vw - var(--ws-w)) / 2);
  padding-block: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scroll-timeline: --ws-x inline;
  list-style: none;
}
.js .ws__track { scrollbar-width: none; }
.js .ws__track::-webkit-scrollbar { display: none; }
.ws__track:focus { outline: none; }
.ws__track:focus-visible { outline: 2px solid #5b97a6; outline-offset: -2px; }
.ws__track.is-dragging { cursor: grabbing; user-select: none; -webkit-user-select: none; scroll-snap-type: none; }

/* ------------------------------------------------------------------ plate */
/* The <li> is the glass plate: it owns the surface, hairline and radius so the outlined
   numeral can sit between the plate and the (transparent) article. */
.ws__slide {
  position: relative;
  display: grid;
  isolation: isolate;
  overflow: hidden;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  transition: border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .ws__slide:hover { border-color: var(--line-strong); box-shadow: 0 30px 60px -40px rgba(13, 27, 33, .35); }
}

.ws .project {
  position: relative;
  z-index: 1;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  overflow: visible;
  min-width: 0;
}
@media (hover: hover) and (pointer: fine) {
  .ws .project:hover { box-shadow: none; } /* the plate carries the hover shadow */
}

/* Giant outlined numeral, behind the body copy at the top inline-end corner. */
.ws__num {
  position: absolute;
  z-index: 0;
  inset-block-start: .06em;
  inset-inline-end: .1em;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: clamp(120px, 16vw, 260px);
  line-height: .8;
  letter-spacing: -.04em;
  color: transparent;
  -webkit-text-stroke: 1px var(--line-strong);
  pointer-events: none;
  user-select: none;
}

@media (min-width: 900px) {
  .ws .project {
    display: grid;
    grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  }
  .ws .project__visual {
    display: flex;
    align-items: center;
    border-bottom: 0;
    border-inline-end: 1px solid var(--line);
  }
  .ws .frame { width: 100%; }
  .ws .project__body { justify-content: center; }
}
@media (max-width: 899.98px) {
  .ws__track { --ws-w: 86vw; }
  .ws__num { font-size: 120px; inset-block-start: auto; inset-block-end: .02em; }
}

/* --------------------------------------------------------------- controls */
.ws__controls {
  display: flex;
  align-items: center;
  gap: 16px 20px;
  margin-top: clamp(12px, 2vw, 24px);
}
html:not(.js) .ws__controls { display: none; }

.ws__count {
  font-family: var(--mono);
  font-size: .8rem;
  letter-spacing: .08em;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: .5ch;
  white-space: nowrap;
}
.ws__count-cur {
  position: relative;
  display: inline-block;
  height: 1.3em;
  line-height: 1.3em;
  overflow: clip;
  color: var(--ink);
  font-weight: 500;
}
.ws__count-cur i { display: block; font-style: normal; }
.ws__count-cur i + i { position: absolute; inset: 0; }

/* Liquid progress tube: a hairline capsule the cobalt pours along. */
.ws__tube {
  position: relative;
  flex: none;
  width: 200px;
  height: 6px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  overflow: hidden;
}
.ws__tube-fill {
  position: absolute;
  inset: 0;
  display: block;
  background: linear-gradient(to bottom, var(--liquid-top), var(--liquid));
  /* translate (not scaleX) keeps the meniscus undistorted; 1/3 is the floor because slide 1 is "filled" */
  transform: translateX(calc(-66.667% * var(--dir)));
}
.ws__tube-fill::after {
  /* the meniscus: a bright lens of liquid at the leading edge; it sloshes on scroll end */
  content: "";
  position: absolute;
  inset-block: -2px;
  inset-inline-end: -2px;
  width: 5px;
  border-radius: 50%;
  background: var(--meniscus);
  box-shadow: 0 0 6px 1px rgba(91, 151, 166, .55);
}
@supports (animation-timeline: scroll()) {
  .ws__tube-fill { animation: ws-tube linear both; animation-timeline: --ws-x; }
}
@keyframes ws-tube {
  from { transform: translateX(calc(-66.667% * var(--dir))); }
  to   { transform: none; }
}

.ws__btn {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: none;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: border-color var(--dur-1) var(--ease), opacity var(--dur-1) var(--ease), transform var(--dur-press) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.ws__btn--prev { margin-inline-start: auto; }
.ws__btn .icon { width: 18px; height: 18px; }
.ws__btn--prev .dir-arrow { --flip: -1; }
[dir="rtl"] .ws__btn--prev .dir-arrow { --flip: 1; }
.ws__btn:active:not([aria-disabled="true"]) { transform: scale(.96); }
.ws__btn[aria-disabled="true"] { opacity: .38; cursor: default; }
.ws__btn:focus-visible { outline: 2px solid #5b97a6; outline-offset: 3px; }
@media (hover: hover) and (pointer: fine) {
  .ws__btn:not([aria-disabled="true"]):hover { border-color: var(--ink); }
  .ws__btn--next:not([aria-disabled="true"]):hover .dir-arrow { --ax: 2px; }
  .ws__btn--prev:not([aria-disabled="true"]):hover .dir-arrow { --ax: -2px; }
  [dir="rtl"] .ws__btn--next:not([aria-disabled="true"]):hover .dir-arrow { --ax: -2px; }
  [dir="rtl"] .ws__btn--prev:not([aria-disabled="true"]):hover .dir-arrow { --ax: 2px; }
}
@media (max-width: 899.98px) {
  .ws__controls { justify-content: center; gap: 14px; }
  .ws__btn--prev { margin-inline-start: 0; }
  .ws__tube { width: clamp(96px, 30vw, 200px); }
}

/* ================================================================ MOTION
   Everything below is motion-only; reduced motion keeps the static, full-opacity flight. */

/* ---- focus: scroll-driven (compositor)
   Every plate runs on the track's own scroll timeline (--ws-x). Plate i peaks at scroll
   progress --ws-p = i / (n - 1) (written once by JS) and bottoms out when a neighbour is
   centred, so the range is ±one step around its peak. A shared scroll() timeline is used
   instead of view(inline) because Chromium mis-resolves view timelines in RTL scrollers. */
@supports (animation-timeline: scroll()) {
  .motion-ok .ws__slide,
  .motion-ok .ws .frame__screen,
  .motion-ok .ws__num {
    animation: ws-focus linear both;
    animation-timeline: --ws-x;
    animation-range: calc(var(--ws-p, 0%) - var(--ws-step, 50%)) calc(var(--ws-p, 0%) + var(--ws-step, 50%));
  }
  .motion-ok .ws .frame__screen { animation-name: ws-par; }
  .motion-ok .ws__num { animation-name: ws-num; }
}
@keyframes ws-focus {
  0%, 100% { transform: scale(.92); opacity: .45; filter: saturate(.55); }
  50%      { transform: none; opacity: 1; filter: saturate(1); }
}
/* the screen drifts against the plate like a lens, and settles exactly at rest */
@keyframes ws-par {
  0%   { transform: translateX(calc(5% * var(--dir))) scale(1.12); }
  50%  { transform: none; }
  100% { transform: translateX(calc(-5% * var(--dir))) scale(1.12); }
}
@keyframes ws-num {
  from { transform: translateX(calc(-10% * var(--dir))); }
  to   { transform: translateX(calc(10% * var(--dir))); }
}

/* ---- focus fallback (no scroll-driven animations): JS toggles .is-current */
@supports not (animation-timeline: scroll()) {
  .motion-ok .ws.is-live .ws__slide {
    transition: transform 450ms var(--ease), opacity 450ms var(--ease), filter 450ms var(--ease),
      border-color var(--dur-2) var(--ease), box-shadow var(--dur-2) var(--ease);
  }
  .motion-ok .ws.is-live .ws__slide:not(.is-current) { transform: scale(.94); opacity: .5; filter: saturate(.6); }
}
/* keyboard users always read a plate at full contrast (!important beats animations) */
.ws__slide:focus-within { opacity: 1 !important; filter: none !important; }

/* ---- section reveal: the plates' contents fan in. Applied to the children (never the
        <li>): Chromium snaps to transformed snap areas, and the <li> owns the focus animation. */
.js.motion-ok .ws[data-reveal] { opacity: 1; transform: none; }
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__slide > * {
  transition: opacity 600ms var(--ease) var(--ws-d, 0ms), translate 600ms var(--ease) var(--ws-d, 0ms);
}
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__slide:nth-child(2) { --ws-d: 70ms; }
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__slide:nth-child(3) { --ws-d: 140ms; }
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__slide:nth-child(n+4) { --ws-d: 210ms; }
.js.motion-ok:not(.lang-arrive) .ws.is-live:not(.is-in) .ws__slide > * { opacity: .01; translate: calc(8% * var(--dir)) 0; }
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__controls { transition: opacity 500ms var(--ease) 260ms, transform 600ms var(--ease) 260ms; }
.js.motion-ok:not(.lang-arrive) .ws.is-live:not(.is-in) .ws__controls { opacity: .01; transform: translateY(8px); }

/* ---- pour-in: the first time a plate becomes current its screen fills bottom → top,
        with a wave-topped cobalt band riding the liquid line. Slide 1 pours with the reveal. */
.js.motion-ok:not(.lang-arrive) .ws.is-live .frame__screen {
  clip-path: inset(0); /* explicit end value: inset() cannot interpolate from `none` */
  transition: clip-path 700ms var(--ease-pour) var(--ws-pd, 0ms);
}
.js.motion-ok:not(.lang-arrive) .ws.is-live:not(.is-in) .frame__screen,
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__slide:not(.is-poured) .frame__screen { clip-path: inset(100% 0 0 0); }
.js.motion-ok:not(.lang-arrive) .ws.is-live .ws__slide:first-child { --ws-pd: 180ms; }

.ws .frame__screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(to bottom, var(--liquid-top) 0, var(--liquid) 11px, rgba(46, 107, 124, .3) 12px, rgba(46, 107, 124, 0) 52px);
  -webkit-mask: var(--wave) 0 0 / 64px 8px repeat-x, linear-gradient(#000 0 0) 0 6px / 100% 100% no-repeat;
  mask: var(--wave) 0 0 / 64px 8px repeat-x, linear-gradient(#000 0 0) 0 6px / 100% 100% no-repeat;
}
.js.motion-ok:not(.lang-arrive) .ws.is-live.is-in .ws__slide.is-poured .frame__screen::after {
  animation: ws-pour 700ms var(--ease-pour) var(--ws-pd, 0ms) both;
}
@keyframes ws-pour {
  0%   { transform: translateY(100%); opacity: 1; }
  78%  { opacity: 1; }
  100% { transform: translateY(-6px); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .ws__slide, .ws__slide > *, .ws .frame__screen, .ws__num { animation: none !important; transition: none !important; }
  .ws .frame__screen::after { display: none; }
}
