/* ==========================================================================
   Work page + project pages. Owned by the Work session.
   Uses tokens and components from base.css (see DESIGN.md).
   ========================================================================== */

/* ---------- Work page: hero ---------- */
.work-hero { padding-top: calc(var(--nav-h) + clamp(72px, 12vw, 150px)); padding-bottom: var(--s-7); display: grid; gap: var(--s-4); }
.work-hero .h1 { max-width: 12ch; }

/* ---------- Filter (glass segmented control) ---------- */
.work-list { padding-bottom: var(--section); }
.work-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); flex-wrap: wrap; margin-bottom: var(--s-6); }
.filter {
  position: relative; display: flex; gap: 2px; padding: 5px; border-radius: var(--r-pill);
  max-width: 100%; overflow-x: auto; scrollbar-width: none; overscroll-behavior-x: contain;
}
.filter::-webkit-scrollbar { display: none; }
.filter-btn {
  position: relative; z-index: 1; flex: none;
  padding: 10px 16px; border-radius: var(--r-pill);
  font-size: 14px; font-weight: 500; color: var(--dim); white-space: nowrap;
  transition: color var(--t-fast);
}
.filter-btn:hover { color: var(--ink); }
.filter-btn[aria-current="true"] { color: var(--ink); }
/* The white pill slides under the active button (positioned by work.js) */
.filter-pill {
  position: absolute; z-index: 0; top: 5px; bottom: 5px; left: 0; width: 0;
  border-radius: var(--r-pill);
  /* pink-tinted liquid glass, same as .btn--solid in base.css */
  background: linear-gradient(180deg, rgba(255, 123, 172, .34), rgba(242, 71, 143, .14));
  border: 1px solid rgba(255, 123, 172, .45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -1px 0 rgba(255, 255, 255, .06);
  transition: transform var(--t-med) var(--ease), width var(--t-med) var(--ease);
}
.filter:not(.is-ready) .filter-btn[aria-current="true"] { background: rgba(255, 123, 172, .25); }
.work-count { color: var(--faint); font-size: var(--fs-small); letter-spacing: .04em; }

/* ---------- Work grid + cards ---------- */
.work-grid { list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(28px, 4vw, 48px) var(--s-6); }
.work-item[hidden] { display: none; }
.work-card { display: grid; gap: var(--s-4); }
.work-card__media { position: relative; aspect-ratio: 4 / 3; transform: translateZ(0); }
.work-card__media img { transition: transform 1.2s var(--ease); }
.work-card:hover .work-card__media img { transform: scale(1.05); }
.work-card__go {
  position: absolute; right: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center;
  opacity: 0; transform: translateY(8px) scale(.9);
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease);
}
.work-card__go svg { width: 18px; height: 18px; }
.work-card:hover .work-card__go, .work-card:focus-visible .work-card__go { opacity: 1; transform: none; }
.work-card__body { display: grid; gap: 6px; padding-inline: 4px; }
.work-card__services { font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--pink); }
.work-card__summary { color: var(--dim); max-width: 46ch; }
@media (hover: none) { .work-card__go { opacity: 1; transform: none; } }
@media (max-width: 720px) {
  .work-grid { grid-template-columns: 1fr; }
  .work-toolbar { flex-direction: column; align-items: stretch; }
  .filter { align-self: stretch; }
  /* Let the filter run edge to edge on phones so it can be swiped */
  .work-toolbar { margin-inline: calc(var(--gutter) * -1); }
  .filter { border-radius: 0; border-inline: 0; padding-inline: var(--gutter); }
  .filter-pill { margin-left: 0; }
  .work-count { padding-inline: var(--gutter); }
}

/* ---------- Project hero (photo behind the title) ---------- */
.pj-hero { position: relative; min-height: min(88svh, 900px); display: flex; align-items: flex-end; overflow: hidden; }
/* The photo stays still while the page scrolls over it (like the original site).
   clip-path keeps the fixed photo inside the hero. */
.pj-hero__bg { position: absolute; inset: 0; z-index: -1; clip-path: inset(0);
  /* fade the photo into the page background so there's no hard edge where the hero ends */
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent); }
.pj-hero__bg picture { display: block; }
.pj-hero__bg img { position: fixed; top: 0; left: 0; width: 100%; height: 100vh; object-fit: cover; }
.pj-hero__bg::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(180deg, rgba(11, 11, 12, .55) 0%, rgba(11, 11, 12, 0) 28%),
    linear-gradient(0deg, rgba(11, 11, 12, .8) 0%, rgba(11, 11, 12, .6) 34%, rgba(11, 11, 12, 0) 72%);
}
.pj-hero { z-index: 1; isolation: isolate; }
.pj-hero__inner { padding-top: calc(var(--nav-h) + 96px); padding-bottom: clamp(40px, 7vw, 88px); display: grid; gap: var(--s-4); justify-items: start; }
.pj-hero .h1 { max-width: 14ch; }
.pj-hero .lede { color: rgba(245, 245, 247, .78); }
.pj-services { font-weight: 700; text-shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 0 18px rgba(0, 0, 0, .6); }
.pj-back { position: absolute; z-index: 2; top: calc(var(--nav-h) + max(12px, env(safe-area-inset-top)) + 20px); left: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter))); }
.pj-back svg, .btn svg { width: 16px; height: 16px; flex: none; }

/* ---------- Overview + What we did ---------- */
.pj-intro { position: relative; z-index: 1; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: clamp(32px, 5vw, 72px); align-items: start; padding-block: var(--s-8) var(--s-9); }
.pj-intro .eyebrow { margin-bottom: var(--s-4); }
.pj-lead { font-size: clamp(17px, 1.5vw, 20px); line-height: 1.6; }
.pj-lead p:first-child { color: var(--ink); }
.pj-intro__did { border-radius: var(--r-lg); padding: clamp(24px, 3vw, 36px); }
.did-list { list-style: none; display: grid; gap: var(--s-3); counter-reset: did; }
.did-list li { position: relative; padding-left: 40px; color: var(--dim); counter-increment: did; }
.did-list li::before {
  content: counter(did, decimal-leading-zero); position: absolute; left: 0; top: .15em;
  font-size: 11px; font-weight: 700; letter-spacing: .08em; color: var(--pink);
}
@media (max-width: 860px) { .pj-intro { grid-template-columns: 1fr; padding-top: var(--s-6); } }

/* ---------- Blocks ---------- */
.site-main > .pj-block, .pj-block { margin-bottom: clamp(56px, 8vw, 112px); position: relative; z-index: 1; }
.pj-block--flush { margin-top: calc(clamp(56px, 8vw, 112px) * -1 + var(--s-5)); }
.pj-actions { margin-top: var(--s-5); justify-content: center; }
.pj-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-4); margin-bottom: var(--s-5); min-height: 44px; }

/* Feature video / YouTube facade */
.feature-video { position: relative; aspect-ratio: 16 / 9; }
.feature-video video, .feature-video img, .feature-video iframe { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; border: 0; }
.feature-video::after { content: ""; position: absolute; inset: 0; background: radial-gradient(closest-side, rgba(0, 0, 0, .25), transparent); pointer-events: none; transition: opacity var(--t-med) var(--ease); }
.feature-video--vertical { aspect-ratio: 9 / 16; max-width: 420px; margin-inline: auto; }
.play-btn {
  position: absolute; left: 50%; top: 50%; z-index: 2; translate: -50% -50%;
  width: clamp(64px, 8vw, 92px); height: clamp(64px, 8vw, 92px); border-radius: 50%;
  display: grid; place-items: center; color: var(--ink);
  transition: transform var(--t-med) var(--ease), opacity var(--t-med) var(--ease);
}
.play-btn svg { width: 38%; height: 38%; margin-left: 6%; }
.feature-video:hover .play-btn { transform: scale(1.08); }
.feature-video.is-playing .play-btn, .feature-video.is-playing::after { opacity: 0; pointer-events: none; }

/* Website preview in a glass browser frame */
.site-frame { display: block; border-radius: var(--r-lg); padding: 10px; transition: transform var(--t-slow) var(--ease); }
.site-frame:hover { transform: translateY(-4px); }
.site-frame__bar { display: flex; align-items: center; gap: var(--s-4); padding: 6px 8px 14px; }
.site-frame__dots { display: flex; gap: 6px; }
.site-frame__dots i { width: 10px; height: 10px; border-radius: 50%; background: rgba(255, 255, 255, .22); }
.site-frame__url { flex: 1; max-width: 360px; margin-inline: auto; padding: 6px 14px; border-radius: var(--r-pill); background: rgba(0, 0, 0, .28); color: var(--dim); font-size: 12px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-frame__shot { display: block; border-radius: calc(var(--r-lg) - 10px); overflow: hidden; background: var(--bg-2); }
.site-frame__shot img { width: 100%; transition: transform 1.2s var(--ease); }
.site-frame:hover .site-frame__shot img { transform: scale(1.02); }
@media (max-width: 560px) { .site-frame { padding: 6px; border-radius: var(--r-md); } .site-frame__shot { border-radius: 14px; } .site-frame__dots { display: none; } }

/* ---------- Gallery: one row that scrolls sideways (one photo at a time on phones) ---------- */
.gallery__controls { display: flex; align-items: center; gap: var(--s-2); }
.gallery__count { color: var(--faint); font-size: var(--fs-small); font-variant-numeric: tabular-nums; margin-right: var(--s-2); }
.round-btn { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; color: var(--ink); transition: transform var(--t-med) var(--ease), opacity var(--t-fast); }
.round-btn svg { width: 18px; height: 18px; }
.round-btn:hover { transform: scale(1.08); }
.round-btn:disabled { opacity: .3; cursor: default; transform: none; }
.gallery__track {
  --h: clamp(300px, 44vw, 600px);
  list-style: none; display: flex; gap: var(--s-4);
  overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
  /* line the first photo up with the page content, let the row bleed off the right edge */
  padding-inline: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
  scroll-padding-inline: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
}
.gallery__track::-webkit-scrollbar { display: none; }
.gallery__track:focus-visible { outline-offset: -2px; }
.gallery__item { flex: none; scroll-snap-align: start; height: var(--h); }
.gallery__open { display: block; height: 100%; border-radius: var(--r-lg); overflow: hidden; background: var(--bg-2); cursor: zoom-in; }
.gallery__open img { height: 100%; width: auto; max-width: none; object-fit: cover; transition: transform 1.2s var(--ease); }
.gallery__open:hover img { transform: scale(1.03); }
@media (max-width: 720px) {
  .gallery__track { gap: var(--s-3); }
  .gallery__item { width: calc(100vw - var(--gutter) * 2); height: auto; scroll-snap-stop: always; display: flex; align-items: center; }
  .gallery__open { width: 100%; height: auto; border-radius: var(--r-md); }
  .gallery__open img { width: 100%; height: auto; max-height: 72svh; object-fit: cover; }
  .gallery__item.is-tall .gallery__open img { aspect-ratio: 4 / 5; }
}

/* ---------- Tiles: animations, vertical videos, Instagram reels ---------- */
.tiles { display: grid; gap: var(--s-4); padding-inline: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter))); }
.tiles--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.anim { display: grid; gap: var(--s-3); }
.anim__tile { border-radius: var(--r-lg); overflow: hidden; padding: 0; aspect-ratio: 4 / 3; }
.anim__tile video { width: 100%; height: 100%; object-fit: cover; }
.anim figcaption { color: var(--dim); font-size: 14px; padding-inline: 4px; }

.tiles--v { grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)); }
.tiles--v.tiles--n2 { --cols: 2; max-width: calc(640px + var(--gutter) * 2); margin-inline: auto; }
.tiles--v.tiles--n5 { --cols: 5; }
.vtile { aspect-ratio: 9 / 16; position: relative; }
.vtile video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; }

.tiles--reels { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tiles--reels.tiles--n1 { grid-template-columns: minmax(0, 420px); justify-content: center; }
.reel { position: relative; aspect-ratio: 4 / 5; border-radius: var(--r-lg); overflow: hidden; background: var(--bg-2); }
.reel iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* On phones, tile rows become swipeable rows */
@media (max-width: 860px) {
  .tiles--3, .tiles--v, .tiles--reels:not(.tiles--n1) {
    display: grid; grid-auto-flow: column; grid-template-columns: none; grid-auto-columns: min(78%, 340px);
    max-width: none; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x mandatory;
    scroll-padding-inline: var(--gutter); scrollbar-width: none; -webkit-overflow-scrolling: touch;
  }
  .tiles--v { grid-auto-columns: min(62%, 280px); }
  .tiles > * { scroll-snap-align: start; }
  .tiles::-webkit-scrollbar { display: none; }
}

/* ---------- Previous / next project ---------- */
.pj-next { display: flex; justify-content: space-between; gap: var(--s-5); padding-top: var(--s-5); margin-top: var(--s-6); border-top: 1px solid var(--line); position: relative; z-index: 1; font-size: 14px; }
.pj-next a { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); transition: color var(--t-fast); }
.pj-next a:hover { color: var(--ink); }
.pj-next a span { color: var(--faint); }
.pj-next svg { width: 14px; height: 14px; flex: none; }
.pj-next__link--next { margin-left: auto; text-align: right; }
@media (max-width: 480px) { .pj-next a span { display: none; } }

/* ---------- Lightbox (built by work.js) ---------- */
.lightbox { position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(11, 11, 12, .94); color: var(--ink); overflow: hidden; }
.lightbox::backdrop { background: rgba(11, 11, 12, .6); }
.lightbox[open] { animation: lb-in var(--t-med) var(--ease); }
@keyframes lb-in { from { opacity: 0; } }
.lightbox__track { display: flex; height: 100%; overflow-x: auto; scroll-snap-type: x mandatory; overscroll-behavior: contain; scrollbar-width: none; }
.lightbox__track::-webkit-scrollbar { display: none; }
.lightbox__slide { flex: none; width: 100%; height: 100%; display: grid; place-items: center; padding: 72px var(--gutter); scroll-snap-align: center; scroll-snap-stop: always; }
.lightbox__slide img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; border-radius: var(--r-sm); }
.lightbox__bar { position: absolute; top: max(16px, env(safe-area-inset-top)); left: var(--gutter); right: var(--gutter); display: flex; justify-content: space-between; align-items: center; pointer-events: none; }
.lightbox__bar > * { pointer-events: auto; }
.lightbox__count { padding: 8px 14px; border-radius: var(--r-pill); font-size: var(--fs-small); font-variant-numeric: tabular-nums; }
.lightbox__nav { position: absolute; top: 50%; translate: 0 -50%; }
.lightbox__nav--prev { left: var(--gutter); }
.lightbox__nav--next { right: var(--gutter); }
@media (hover: none) { .lightbox__nav { display: none; } }

/* ---------- Touch screens ---------- */
/* Phones keep :hover "stuck" after a tap, so no hover movement there */
@media (hover: none) {
  .work-card:hover .work-card__media img, .site-frame:hover, .site-frame:hover .site-frame__shot img,
  .gallery__open:hover img, .round-btn:hover, .feature-video:hover .play-btn { transform: none; }
}
/* Taller previous/next links so they're easy to tap */
@media (pointer: coarse) { .pj-next a { padding-block: 10px; } }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .work-card:hover .work-card__media img, .site-frame:hover, .gallery__open:hover img { transform: none; }
}
