/* The work page (src/pages/[...lang]/work.astro, src/scripts/work.ts, design/work/BRIEF.md). Base styles are the finished,
   still page (no JS, reduced motion); html.wk-run adds the long scroll hero. The viewer's content is built by the
   script, so these are global, every class prefixed. */
:root { --wk-tick: rgba(255, 255, 255, 0.34); --wk-shade: rgba(2, 3, 5, 0.82); --wk-glass: rgba(2, 3, 5, 0.6); }

/* the header carries WhatsApp at this width, so nothing floats over the photos */
@media (min-width: 861px) { html:has(.wk-grid) .fab { display: none; } }

/* ---------- hero: still ---------- */
.wk-hero { --y0: 96px; position: relative; }
.wk-sticky { position: relative; height: 100svh; min-height: 480px; overflow: hidden; }
.wk-shot { position: absolute; inset: 0; }
.wk-img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 34%; max-width: none; }
.wk-copy { position: absolute; inset: auto 0 0; padding: 0 var(--gut) clamp(40px, 8svh, 88px); display: flex; flex-direction: column; gap: var(--s4); align-items: flex-start; }
.wk-copy::before { content: ''; position: absolute; z-index: -1; inset: -40svh 0 0; background: linear-gradient(0deg, var(--wk-shade) 22%, transparent 80%); pointer-events: none; }
.wk-copy > * { margin: 0; }
.wk-copy .label { color: var(--text-2); }
.wk-copy h1 { font-size: var(--t-hero); }
.wk-lead { font-size: var(--t-lead); color: var(--text); max-width: 52ch; text-wrap: pretty; }
.wk-beat { display: none; }

/* ---------- hero: the running sequence ---------- */
html.wk-run .wk-hero { height: calc(100svh + 110svh + 100svh - var(--y0)); }
html.wk-run .wk-sticky { position: sticky; top: 0; z-index: 5; pointer-events: none; }
html.wk-run .wk-shot { inset: auto; left: 0; top: 0; transform-origin: 0 0; will-change: transform; }
html.wk-run .wk-img { object-fit: fill; }
.wk-lights { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
html.wk-run .wk-copy { z-index: 2; }
html.wk-run .wk-beat { display: block; position: absolute; z-index: 2; left: 0; right: 0; bottom: clamp(32px, 7svh, 72px); margin: 0 auto; padding: 0 var(--gut); max-width: 26ch; box-sizing: content-box; text-align: center; font-size: clamp(24px, 3vw, 44px); opacity: 0; }
/* the subtitle's own shade, so it reads over chrome and it leaves with the line */
html.wk-run .wk-beat::before { content: ''; position: absolute; z-index: -1; left: -100vw; right: -100vw; bottom: calc(clamp(32px, 7svh, 72px) * -1); height: 46svh; background: linear-gradient(0deg, var(--wk-shade) 35%, transparent); pointer-events: none; }
html.wk-run .wk-wall { position: relative; z-index: 1; margin-top: calc(var(--y0, 96px) - 100svh); }
/* in the dark until the shader or the fallback lights the photo. If nothing ever runs, the fail-safe shows it. */
html.motion:not(.mk-now, .wk-lit) .wk-img { opacity: 0; animation: wk-failsafe 0s 5s forwards; }
html.wk-lit .wk-img { opacity: 1; }
html.wk-lit:not(.wk-shader) .wk-img { animation: wk-up 1200ms var(--ease-x) backwards; }
@keyframes wk-failsafe { to { opacity: 1; } }
@keyframes wk-up { from { opacity: 0; filter: brightness(0.3); } }
html.wk-run .wk-first.wk-landing .wk-ph img { visibility: hidden; }

/* ---------- the wall ---------- */
.wk-wall { padding: var(--s6) var(--gut) var(--sec-y); }
.wk-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--s4) var(--s7); margin-bottom: var(--s5); }
.wk-head h2 { font-size: var(--t-h2); max-width: 16ch; }
.wk-hint { margin: 0; color: var(--muted); font-size: 14px; max-width: 34ch; }
.wk-hint .on-touch { display: none; }
@media (hover: none) { .wk-hint .on-touch { display: inline; } .wk-hint .on-fine { display: none; } }

.wk-filter { position: sticky; top: 76px; z-index: 3; display: flex; gap: var(--s2); margin: 0 calc(var(--gut) * -1) var(--s5); padding: var(--s3) var(--gut); background: var(--bg); overflow-x: auto; scrollbar-width: none; box-shadow: 0 1px 0 var(--line); }
.wk-filter::-webkit-scrollbar { display: none; }
.wk-filter.more { -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent); mask-image: linear-gradient(90deg, #000 calc(100% - 56px), transparent); }
.wk-filter[hidden] { display: none; }
.wk-filter button { flex: none; display: inline-flex; align-items: center; gap: var(--s2); height: 38px; padding: 0 14px; background: none; border: 1px solid var(--line-2); border-radius: var(--r); font: 500 13px/1 var(--body); color: var(--text-2); white-space: nowrap; cursor: pointer; transition: border-color 160ms var(--ease), color 160ms var(--ease), background-color 160ms var(--ease); }
.wk-filter button small { font: inherit; font-variant-numeric: tabular-nums; color: var(--muted); }
.wk-filter button:hover { color: var(--text); border-color: var(--text-2); }
.wk-filter button:active { background: var(--bg-2); }
.wk-filter button[aria-pressed='true'] { background: var(--text); border-color: var(--text); color: var(--bg); }
.wk-filter button[aria-pressed='true'] small { color: var(--bg); opacity: 0.6; }

.wk-grid { --off: clamp(20px, 4vw, 64px); list-style: none; margin: 0; padding: 0 0 var(--off); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: clamp(28px, 3vw, 48px) clamp(12px, 1.7vw, 24px); }
.wk-c { min-width: 0; }
.wk-c[hidden], .wk-band[hidden] { display: none; }
.wk-c.off { translate: 0 var(--off); }
.wk-a { display: block; touch-action: pan-y; -webkit-tap-highlight-color: transparent; }
.wk-ph { position: relative; display: block; aspect-ratio: 3 / 4; overflow: hidden; background: var(--bg-2); border-radius: var(--r); }
.wk-ph img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.wk-f { opacity: 0; }
.wk-f.on { opacity: 1; }
.wk-tk { position: absolute; left: var(--s2); right: var(--s2); bottom: var(--s2); display: flex; gap: 3px; opacity: 0; transition: opacity 160ms var(--ease); }
.wk-tk i { flex: 1; height: 2px; background: var(--wk-tick); box-shadow: 0 0 6px var(--bg); }
.wk-tk i.on { background: var(--text); }
.wk-a:hover .wk-tk, .wk-a:focus-visible .wk-tk, .wk-demo .wk-tk { opacity: 1; }
@media (hover: none) { .wk-tk { opacity: 1; } }
.wk-n { display: block; margin-top: var(--s3); font: 600 15px/1.3 var(--body); color: var(--text); }
.wk-m { display: block; margin-top: 2px; font-size: 13px; line-height: 1.4; color: var(--muted); }
.wk-m::first-letter { text-transform: uppercase; }
.wk-p { margin-top: var(--s2); }

/* image bands break the wall after a dozen cars (a dozen divides by 4, 3 and 2 columns; narrow screens start with one
   full-width card, so they come one later) */
.wk-band { grid-column: 1 / -1; position: relative; overflow: hidden; aspect-ratio: 21 / 7; margin: calc(var(--off) + var(--s5)) calc(var(--gut) * -1) var(--s5); display: flex; align-items: flex-end; }
.wk-band-1 { order: 115; }
.wk-band-2 { order: 235; }
.wk-band img { position: absolute; inset: -9% 0; width: 100%; height: 118%; object-fit: cover; }
.wk-band::after { content: ''; position: absolute; inset: 0; background: linear-gradient(0deg, var(--wk-shade), transparent 55%); }
.wk-band p { position: relative; z-index: 1; margin: 0; padding: var(--s5) var(--gut); font-size: clamp(16px, 1.6vw, 22px); }

@media (max-width: 1199px) { .wk-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .wk-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .wk-first { grid-column: 1 / -1; }
  .wk-band-1 { order: 125; }
  .wk-band-2 { order: 245; }
  .wk-band { aspect-ratio: 16 / 9; }
  .wk-filter { top: 72px; }
}
@media (max-width: 560px) { .wk-n { font-size: 14px; } .wk-m { font-size: 12px; } }
@media (max-width: 760px) {
  .wk-copy { padding-bottom: calc(var(--s8) + var(--s4) + env(safe-area-inset-bottom)); }
  html.wk-run .wk-beat { bottom: calc(var(--s8) + var(--s4) + env(safe-area-inset-bottom)); }
  html.wk-run .wk-beat::before { bottom: calc((var(--s8) + var(--s4)) * -1); }
}

/* a little depth while scrolling, where the browser does it off the main thread */
@supports (animation-timeline: view()) {
  @media (hover: hover) and (min-width: 901px) {
    html.motion:not(.mk-now) .wk-c.off { animation: wk-drift linear both; animation-timeline: view(); }
    @keyframes wk-drift { from { translate: 0 calc(var(--off) + 26px); } to { translate: 0 calc(var(--off) - 26px); } }
  }
  html.motion:not(.mk-now) .wk-band img { animation: wk-pan linear both; animation-timeline: view(); }
  @keyframes wk-pan { from { transform: translateY(-7%); } to { transform: translateY(7%); } }
}

/* ---------- viewer ---------- */
/* phones: stop the page behind the viewer. Desktop has Lenis stopped and the wheel taken, so no scrollbar jump. */
@media (max-width: 900px) { html.wv-open, html.wv-open body { overflow: hidden; } }
.wv { position: fixed; inset: 0; width: 100vw; max-width: none; height: 100svh; max-height: none; margin: 0; padding: 0; border: 0; background: var(--bg); color: var(--text); overflow: hidden; overscroll-behavior: contain; }
.wv[open] { display: grid; grid-template-columns: minmax(280px, 340px) minmax(0, 1fr); }
.wv::backdrop { background: var(--bg); }
.wv-strip { position: relative; grid-column: 2; grid-row: 1; display: flex; height: 100svh; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; outline-offset: -4px; }
.wv-strip::-webkit-scrollbar { display: none; }
.wv-f { flex: none; height: 100svh; aspect-ratio: 3 / 4; margin: 0; }
.wv-f + .wv-f { margin-left: 2px; }
.wv-f img { width: 100%; height: 100%; object-fit: cover; background: var(--bg-2); }
.wv-side { grid-column: 1; grid-row: 1; display: flex; flex-direction: column; gap: var(--s5); padding: var(--s6) var(--s5) var(--s5); min-height: 0; overflow-y: auto; }
.wv-id p { margin: 0; }
.wv-id h2 { margin: var(--s3) 0 var(--s1); font-size: clamp(24px, 2.2vw, 32px); }
.wv-meta { color: var(--text-2); font-size: 15px; }
.wv-meta::first-letter { text-transform: uppercase; }
.wv-pack { margin-top: var(--s4) !important; display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.wv-pack[hidden] { display: none; }
.wv-pack a { font: 600 14px/1.3 var(--body); border-bottom: 1px solid var(--blue); }
.wv-pack a:hover { color: var(--blue-soft); }
.wv-view { margin: auto 0 0; line-height: 1.5; }
.wv-thumbs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s1); }
.wv-thumbs button { position: relative; display: block; padding: 0; background: var(--bg-2); border: 0; aspect-ratio: 3 / 4; cursor: pointer; overflow: hidden; opacity: 0.5; transition: opacity 160ms var(--ease); }
.wv-thumbs button:hover { opacity: 0.85; }
.wv-thumbs button[aria-current='true'] { opacity: 1; }
.wv-thumbs button[aria-current='true']::after { content: ''; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--text); }
.wv-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.wv-act { display: flex; flex-direction: column; gap: var(--s3); }
.wv-act .btn-wa { width: 100%; }
.wv-cars { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--s2); }
.wv-cars .btn { padding: 0 var(--s2); background: none; }
.wv-cars .btn:hover { border-color: var(--text); }
.wv-cars .btn:active { background: var(--bg-2); }
.wv-x { position: absolute; z-index: 3; top: var(--s4); right: var(--s4); height: 44px; padding: 0 var(--s4); background: var(--wk-glass); border: 1px solid var(--line-2); border-radius: var(--r); font: 500 14px/1 var(--body); color: var(--text); cursor: pointer; backdrop-filter: blur(10px); transition: border-color 160ms var(--ease); }
.wv-x:hover { border-color: var(--text); }
.wv-x:active { background: var(--bg-2); }
.wv-go { position: absolute; z-index: 2; top: 50%; width: 48px; height: 72px; margin-top: -36px; display: flex; align-items: center; justify-content: center; background: var(--wk-glass); border: 1px solid var(--line); border-radius: var(--r); color: var(--text); cursor: pointer; transition: opacity 160ms var(--ease), border-color 160ms var(--ease); }
.wv-go svg { width: 12px; height: 20px; }
.wv-go:hover:not(:disabled) { border-color: var(--text-2); }
.wv-go:disabled { opacity: 0; pointer-events: none; }
.wv-prev { left: calc(min(340px, 100vw) + var(--s4)); }
.wv-next { right: var(--s4); }
@media (max-width: 900px) {
  .wv[open] { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; }
  .wv-strip { grid-column: 1; grid-row: 1; height: 100%; scroll-snap-type: x mandatory; }
  .wv-f { width: 100%; height: 100%; aspect-ratio: auto; scroll-snap-align: center; scroll-snap-stop: always; }
  .wv-f img { object-fit: contain; background: var(--bg); }
  .wv-side { grid-column: 1; grid-row: 2; padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom)); gap: var(--s2); border-top: 1px solid var(--line); overflow: visible; }
  .wv-id { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; column-gap: var(--s3); }
  .wv-id > .label { grid-column: 2; grid-row: 1; }
  .wv-id h2 { grid-column: 1; grid-row: 1; margin: 0; font-size: 20px; }
  .wv-meta { grid-column: 1 / -1; font-size: 13px; }
  .wv-pack { grid-column: 1 / -1; margin-top: var(--s1) !important; }
  .wv-view { display: none; }
  .wv-thumbs { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .wv-thumbs button { aspect-ratio: 1; }
  .wv-act { flex-direction: row; gap: var(--s2); }
  .wv-act .btn-wa { flex: 1; width: auto; min-width: 0; padding: 0 var(--s2); height: 44px; font-size: 13px; overflow: hidden; }
  .wv-cars { flex: none; }
  .wv-cars .btn { height: 44px; width: 44px; padding: 0; font-size: 0; }
  .wv-cars .btn::before { font-size: 16px; }
  .wv-cars [data-wv-car='-1']::before { content: '←'; }
  .wv-cars [data-wv-car='1']::before { content: '→'; }
  .wv-go { display: none; }
  .wv-x { top: calc(var(--s3) + env(safe-area-inset-top)); right: var(--s3); }
}
@media (max-height: 620px) and (max-width: 900px) { .wv-thumbs { display: none; } }

/* photo morphs: card to viewer and back; cards to new places when filtering */
::view-transition-group(wv-hero) { animation-duration: 560ms; animation-timing-function: cubic-bezier(0.16, 1, 0.3, 1); z-index: 5; }
::view-transition-old(wv-hero), ::view-transition-new(wv-hero) { width: 100%; height: 100%; object-fit: cover; animation-duration: 280ms; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 320ms; }
