/* portfolio.css: portfolio.html and every portfolio-<slug>.html case-study page.
   Look: a white page with black text and small floating black squares. Cards are photos
   with a white info plate in the bottom-left corner; on hover a grid of black pixel blocks
   dissolves over the photo diagonally (projects.js adds the blocks). Square corners only.
   Colours come from themes.css, so dark mode works; --mute is the soft grey of the
   two-tone headings (4.5:1 on the page in both themes). */
:root { --mute: #767676; --pf-ease: cubic-bezier(.22, 1, .36, 1); }
:root[data-theme="dark"] { --mute: #8f8f8f; }

/* ---------- Header with floating squares ---------- */
.pf-head { position: relative; overflow: hidden; padding: var(--s8) 0 var(--s7); }
@media (min-width: 1024px) { .pf-head { padding-top: var(--s9); } }
.pf-head__inner { position: relative; z-index: 1; max-width: 56rem; text-align: center; }
.pf-badge { display: inline-block; margin-top: var(--s6); margin-bottom: var(--s5); padding: 6px var(--s4); background: var(--ink); color: var(--bg); font-size: .8125rem; font-weight: 500; letter-spacing: .04em; }
.pf-title { font-size: clamp(1.9rem, 1.2rem + 2.6vw, 3.25rem); font-weight: 300; line-height: 1.2; letter-spacing: -.02em; }
.pf-title > span { display: block; }
.pf-title--long { font-size: clamp(1.75rem, 1.1rem + 2.2vw, 2.9rem); }
.pf-mute { color: var(--mute); }
.pf-lede { max-width: 40rem; margin: var(--s5) auto 0; color: var(--ink-soft); font-size: var(--t-sm); line-height: 1.7; }
.pf-sq { position: absolute; z-index: 0; display: block; background: var(--ink); pointer-events: none; will-change: transform; }
@media (max-width: 599px) { .pf-sq:not(.pf-sq--m) { display: none; } }

/* ---------- Filter + grid ---------- */
.pf-list { padding-bottom: var(--s8); }
.pf-toolbar { display: flex; flex-direction: column; align-items: center; gap: var(--s3); margin-bottom: var(--s6); }
.pf-filter { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); list-style: none; padding: 0; }
.pf-filter button { min-height: 40px; padding: var(--s2) var(--s4); border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent); background: transparent; color: var(--ink); font: inherit; font-size: var(--t-xs); font-weight: 400; transition: background var(--fast), color var(--fast), border-color var(--fast); }
.pf-filter button:hover { border-color: var(--ink); }
.pf-filter button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--bg); font-weight: 500; }
.pf-count { font-size: var(--t-xs); color: var(--ink-soft); }
.pf-grid { display: grid; gap: var(--s4); list-style: none; padding: 0; }
@media (min-width: 768px) { .pf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.pf-grid > li { max-width: none; }

/* ---------- Case-study card ---------- */
.pcard { position: relative; aspect-ratio: 4 / 3; overflow: hidden; background: var(--surface-2); isolation: isolate; }
.pcard__media, .pcard__media img { position: absolute; inset: 0; width: 100%; height: 100%; }
.pcard__media img { object-fit: cover; transition: transform .8s var(--pf-ease); }
.pcard:hover .pcard__media img { transform: scale(1.03); }
.pcard__plus { position: absolute; top: var(--s4); right: var(--s4); z-index: 10; display: grid; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(255, 255, 255, .45); color: #fff; font-size: .8rem; line-height: 1; background: rgba(0, 0, 0, .12); transition: background .3s, transform .4s var(--pf-ease); }
.pcard:hover .pcard__plus { background: #000; transform: rotate(90deg); }
.pcard__view { position: absolute; top: 42%; left: 50%; z-index: 8; transform: translate(-50%, 8px); color: #fff; font-size: var(--t-sm); font-weight: 500; letter-spacing: .02em; opacity: 0; transition: opacity .3s .15s, transform .5s .15s var(--pf-ease); pointer-events: none; }
.pcard:hover .pcard__view, .pcard:focus-within .pcard__view { opacity: 1; transform: translate(-50%, 0); }
.pcard__plate { position: absolute; bottom: 0; left: 0; z-index: 20; max-width: 78%; padding: 10px var(--s4) 12px; background: var(--bg); color: var(--ink); }
@media (min-width: 1024px) { .pcard__plate { max-width: 70%; } }
.pcard__title { display: block; font-size: clamp(1.15rem, .9rem + 1.1vw, 1.75rem); font-weight: 400; line-height: 1.2; }
.pcard__link { color: inherit; text-decoration: none; }
/* The plate is positioned, so the stretched link reaches up and right past it; the card clips it to its own box */
.pcard__link::after { content: ""; position: absolute; top: -300vh; right: -300vw; bottom: -20px; left: -20px; z-index: 30; }
.pcard__link:focus-visible { outline: none; }
.pcard:has(.pcard__link:focus-visible) { outline: 2px solid var(--focus); outline-offset: 3px; }
.pcard__meta { display: flex; flex-wrap: wrap; gap: 2px var(--s4); margin-top: 6px; font-size: .75rem; line-height: 1.4; color: var(--ink-soft); }
.pcard__count { color: var(--ink); font-weight: 500; }

/* Pixel-block hover overlay (12 x 8 blocks, added by projects.js; delays set per block) */
.pcard__px { position: absolute; inset: 0; z-index: 5; opacity: .8; display: grid; grid-template-columns: repeat(12, 1fr); grid-template-rows: repeat(8, 1fr); pointer-events: none; }
.pcard__px i { background: #000; transform: scale(0); opacity: 0; transition: transform .25s var(--pf-ease) var(--out), opacity .25s var(--pf-ease) var(--out); }
.pcard:hover .pcard__px i, .pcard:focus-within .pcard__px i { transform: scale(1.08); opacity: 1; transition-delay: var(--in); }
/* Magnetic squares (projects.js moves them toward the pointer through --dx/--dy) */
.pcard__mag { position: absolute; z-index: 6; display: block; background: #000; pointer-events: none; transform: translate(calc(var(--dx, 0) * var(--k, 1) * 1px), calc(var(--dy, 0) * var(--k, 1) * 1px)); transition: transform .6s cubic-bezier(.2, .9, .3, 1.15), background .3s; }
.pcard:hover .pcard__mag { background: #fff; }

/* ---------- Case-study page ---------- */
.pf-head--case { padding-bottom: var(--s6); }
.cs-hero__fig { position: relative; margin: 0; aspect-ratio: 16 / 9; overflow: hidden; background: var(--surface-2); }
@media (max-width: 599px) { .cs-hero__fig { aspect-ratio: 4 / 3; } }
.cs-hero__fig img { width: 100%; height: 100%; object-fit: cover; }
.cs-hero__fig .pcard__plate { max-width: 85%; }
.cs-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--s5); margin: 0; }
@media (min-width: 768px) { .cs-facts { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.cs-facts > div { padding: var(--s4) 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); }
.cs-facts dt { font-size: .75rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.cs-facts dd { margin: 6px 0 0; font-weight: 500; line-height: 1.45; }
.cs-th { display: block; font-weight: 300; color: var(--ink-soft); }
.cs-about { max-width: 46rem; margin-top: var(--s6); }

.cs-sec { padding-top: var(--s8); }
.cs-sec__head { display: flex; align-items: baseline; gap: var(--s4); margin-bottom: var(--s5); padding-bottom: var(--s3); border-bottom: 1px solid var(--ink); }
.cs-sec__idx { display: grid; place-items: center; min-width: 28px; height: 28px; padding: 0 4px; background: var(--ink); color: var(--bg); font-size: .75rem; font-weight: 500; align-self: center; }
.cs-sec__head h2 { flex: 1; font-size: var(--t-lg); font-weight: 400; line-height: 1.2; letter-spacing: -.01em; }
.cs-sec__count { font-size: var(--t-xs); color: var(--ink-soft); white-space: nowrap; }
a.cs-sec__count { color: var(--ink); }

/* Editorial photo grid: a large photo, then smaller ones, repeating */
.cs-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 44vw; grid-auto-flow: dense; gap: var(--s2); list-style: none; padding: 0; }
.cs-grid > li { max-width: none; }
.cs-grid > li:nth-child(5n + 1) { grid-column: span 2; grid-row: span 2; }
@media (min-width: 768px) {
  .cs-grid { grid-template-columns: repeat(12, minmax(0, 1fr)); grid-auto-rows: clamp(70px, 7.5vw, 105px); gap: var(--s3); }
  .cs-grid > li { grid-column: span 4; grid-row: span 3; }
  .cs-grid > li:nth-child(5n + 1) { grid-column: span 8; grid-row: span 6; }
  .cs-grid > li:nth-child(5n + 4), .cs-grid > li:nth-child(5n + 5) { grid-column: span 6; grid-row: span 4; }
  .cs-grid--few > li, .cs-grid--few > li:nth-child(n) { grid-column: span 6; grid-row: span 5; }
}
.cs-tile figure { position: relative; height: 100%; margin: 0; overflow: hidden; background: var(--surface-2); }
.cs-tile a { display: block; height: 100%; cursor: zoom-in; }
.cs-tile img { width: 100%; height: 100%; object-fit: cover; transition: transform .8s var(--pf-ease); }
.cs-tile a:hover img { transform: scale(1.04); }
.cs-tile figcaption { position: absolute; left: 0; bottom: 0; z-index: 2; max-width: 88%; padding: 6px 10px 7px; background: var(--bg); color: var(--ink); font-size: .75rem; line-height: 1.4; pointer-events: none; }
@media (hover: hover) and (min-width: 768px) {
  .cs-tile figcaption { opacity: 0; transform: translateY(6px); transition: opacity .3s, transform .4s var(--pf-ease); }
  .cs-tile figure:hover figcaption, .cs-tile figure:focus-within figcaption { opacity: 1; transform: none; }
}
@media (max-width: 767px) { .cs-tile:not(:nth-child(5n + 1)) figcaption { display: none; } }
.cs-tile a:focus-visible { outline: 2px solid var(--focus); outline-offset: -4px; }

.videos { display: flex; flex-wrap: wrap; gap: var(--s5); }
.video { margin: 0; flex: 1 1 18rem; }
.video video { display: block; width: 100%; height: auto; background: #000; }
.video--wide { max-width: 48rem; }
.video--tall { max-width: 22rem; }
.video figcaption { margin-top: var(--s2); font-size: var(--t-xs); color: var(--ink-soft); }

/* ---------- CTA + client marquee ---------- */
.pf-cta { padding: var(--s8) 0; }
.pf-cta__inner { display: flex; flex-direction: column; gap: var(--s6); }
@media (min-width: 900px) { .pf-cta__inner { flex-direction: row; align-items: flex-end; justify-content: space-between; } }
.pf-cta__text { max-width: 28rem; }
.pf-plus { display: grid; place-items: center; width: 28px; height: 28px; margin-bottom: var(--s4); border: 1px solid color-mix(in srgb, var(--ink) 20%, transparent); font-size: .8rem; }
.pf-cta__title { font-size: var(--t-lg); font-weight: 400; margin-bottom: var(--s2); }
.pf-cta__text p { font-size: .875rem; line-height: 1.7; color: var(--ink-soft); }
.pf-btn { display: inline-flex; align-items: flex-end; margin-top: var(--s5); text-decoration: none; }
.pf-btn__label { display: inline-flex; align-items: center; min-height: 44px; padding: var(--s2) var(--s4); background: var(--ink); color: var(--bg); font-weight: 500; transition: opacity var(--fast); }
.pf-btn:hover .pf-btn__label { opacity: .86; }
.pf-btn__arrow { display: grid; place-items: center; width: 24px; height: 24px; margin-bottom: 24px; background: var(--ink); color: var(--bg); transition: margin .3s var(--pf-ease); }
.pf-btn:hover .pf-btn__arrow, .pf-btn:focus-visible .pf-btn__arrow { margin-bottom: 36px; }
.pf-btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px; }
.pf-marquee { flex: 1; min-width: 0; overflow: hidden; padding: var(--s4) 0; border-top: 1px solid color-mix(in srgb, var(--ink) 12%, transparent); -webkit-mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); mask-image: linear-gradient(90deg, transparent, #000 8%, #000 92%, transparent); }
@media (min-width: 900px) { .pf-marquee { margin-left: var(--s7); border-top: 0; } }
.pf-marquee__track { display: flex; width: max-content; animation: pf-marquee 40s linear infinite; }
.pf-marquee:hover .pf-marquee__track { animation-play-state: paused; }
.pf-marquee__list { display: flex; list-style: none; padding: 0; margin: 0; }
.pf-marquee__item { display: flex; flex-shrink: 0; align-items: center; gap: 10px; padding: 0 var(--s6); max-width: none; color: var(--ink); }
.pf-marquee__item span { white-space: nowrap; font-size: .875rem; font-weight: 500; letter-spacing: .02em; color: var(--ink); }
@keyframes pf-marquee { from { transform: translateX(0); } to { transform: translateX(-50%); } }

/* ---------- Entrance (projects.js adds .is-in) ---------- */
.pf-anim [data-reveal] { opacity: 0; transform: translateY(26px); transition: opacity .7s var(--pf-ease) var(--d, 0s), transform .7s var(--pf-ease) var(--d, 0s); }
.pf-anim [data-reveal].is-in { opacity: 1; transform: none; }

@media (prefers-reduced-motion: reduce) {
  .pf-anim [data-reveal] { opacity: 1; transform: none; transition: none; }
  .pcard__media img, .cs-tile img, .pcard__mag, .pcard__plus { transition: none; }
  .pcard:hover .pcard__media img, .cs-tile a:hover img { transform: none; }
  .pcard__px i { transform: scale(1.08); transition: opacity .2s; }
  .pcard:hover .pcard__px i { transition-delay: 0s; }
  .pf-marquee__track { animation: none; }
  .pf-marquee__list[aria-hidden] { display: none; }
  .pf-marquee__list { flex-wrap: wrap; row-gap: var(--s3); }
  .pf-marquee { -webkit-mask-image: none; mask-image: none; }
}

/* ---------- Photo viewer (gallery.js) ---------- */
.viewer { width: 100vw; height: 100vh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(10, 10, 10, .96); color: #fff; }
.viewer::backdrop { background: rgba(10, 10, 10, .6); }
.viewer[open] { display: grid; place-items: center; }
.viewer__fig { margin: 0; padding: 3.5rem 1rem 1rem; max-width: 100%; text-align: center; }
.viewer__img { display: block; margin: 0 auto; max-width: min(100%, 1600px); max-height: calc(100vh - 9rem); width: auto; height: auto; object-fit: contain; }
.viewer__cap { margin: .75rem auto 0; max-width: 48rem; font-size: var(--t-xs); color: #e8e6e3; }
.viewer__count { position: absolute; top: 1rem; left: 1rem; margin: 0; padding: 4px 10px; background: #fff; color: #0a0a0a; font-size: .75rem; font-weight: 500; }
.viewer__btn { position: absolute; display: grid; place-items: center; width: 44px; height: 44px; border: 1px solid rgba(255, 255, 255, .35); background: transparent; color: #fff; font: inherit; font-size: 1.6rem; line-height: 1; cursor: pointer; transition: background var(--fast), color var(--fast); }
.viewer__btn:hover { background: #fff; color: #0a0a0a; }
.viewer__btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.viewer__close { top: .75rem; right: .75rem; }
.viewer__prev { left: .75rem; top: 50%; transform: translateY(-50%); }
.viewer__next { right: .75rem; top: 50%; transform: translateY(-50%); }
