/* ==========================================================================
   Andrea Yiu — Photo Portfolio
   Layout follows the PDF spreads; type + interaction language: small
   uppercase Spline Sans Mono for UI, Inter Display for headlines.
   ========================================================================== */

:root {
  --bg: #030608;
  --fg: #ededed;
  --dim: rgba(237, 237, 237, .42);
  --line: rgba(237, 237, 237, .14);
  --mono: "Spline Sans Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: "Inter", "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --ease: cubic-bezier(.16, 1, .3, 1);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --gutter: 20px;
  --ink: #ededed;
  --page: #030608;
  --ink-dim: rgba(237, 237, 237, .45);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  font-optical-sizing: auto;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color 1s var(--ease-io);
  overflow-x: hidden;
}
body.is-loading, body.is-locked { overflow: hidden; }
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
::selection { background: var(--fg); color: #000; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }

.mono {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 12px;
  line-height: 1.25;
  letter-spacing: -.01em;
  text-transform: uppercase;
}
.dim { color: var(--dim); }
.link { position: relative; transition: color .3s; }
.link::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -2px; height: 1px;
  background: currentColor; transform: scaleX(0); transform-origin: right;
  transition: transform .5s var(--ease);
}
.link:hover::after, .link:focus-visible::after { transform: scaleX(1); transform-origin: left; }

.skip {
  position: fixed; left: 12px; top: -60px; z-index: 200; padding: 8px 12px;
  background: var(--fg); color: #000; font: 500 12px var(--mono); text-transform: uppercase;
}
.skip:focus { top: 12px; }

/* ---------- HUD (header + bottom bar) ---------- */
.hud {
  position: fixed; left: 0; right: 0; z-index: 50;
  padding: 18px var(--gutter);
  color: var(--ink);
  pointer-events: none;
  transition: color .8s var(--ease-io);
}
.hud a, .hud button { pointer-events: auto; }
.hud--top { top: 0; display: flex; justify-content: space-between; align-items: baseline; }
.wordmark {
  font-family: var(--sans); font-weight: 600; font-size: 16px; letter-spacing: -.035em;
  font-variation-settings: "opsz" 32;
}
.hud__nav { display: flex; gap: 22px; }
.hud--bottom {
  bottom: 0; display: grid; grid-template-columns: 1fr auto 1fr; align-items: end;
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}
.hud__count { white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud__proj { margin-left: 16px; overflow: hidden; text-overflow: ellipsis; }
.hud__hint { justify-self: end; transition: opacity .6s; }
.hud__hint.is-gone { opacity: 0; }
.views { display: flex; gap: 12px; }
.hud .dim { color: var(--ink-dim); transition: color .8s var(--ease-io); }
.view-btn { color: var(--ink-dim); transition: color .3s; }
.view-btn:hover, .view-btn.is-active { color: var(--ink); }
body.view-grid .hud__count, body.view-grid .hud__hint { opacity: 0; }

/* ---------- Loader ---------- */
.loader {
  position: fixed; inset: 0; z-index: 90; background: #030608;
  display: grid; place-items: center;
  transition: transform 1.1s var(--ease-io), visibility 0s 1.1s;
}
.loader__top {
  position: absolute; top: 18px; left: var(--gutter); right: var(--gutter);
  display: flex; justify-content: space-between;
}
.loader__count { display: flex; gap: 6px; font-variant-numeric: tabular-nums; }
.loader__bar {
  position: absolute; left: var(--gutter); right: var(--gutter); bottom: 22px; height: 1px; background: var(--line);
}
.loader__bar i { display: block; height: 100%; width: 100%; background: var(--fg); transform: scaleX(0); transform-origin: left; transition: transform .4s var(--ease); }
body.is-loaded .loader { transform: translateY(-100%); visibility: hidden; }

/* ---------- Spreads ---------- */
.spread {
  position: relative;
  height: 100vh; height: 100svh;
  display: grid; place-items: center;
  color: var(--fg);
}
.spread.is-light { --fg: #0b0b0b; --dim: rgba(11, 11, 11, .5); }
.stage {
  position: relative;
  width: min(100vw, calc(100svh * 16 / 9));
  aspect-ratio: 16 / 9;
  container-type: inline-size;
}
.stack { display: none; }
.spreads { transition: opacity .3s var(--ease-io); }
body.is-jumping .spreads { opacity: 0; }

/* One photograph on a spread: a frame (the PDF's crop) holding the image. */
.layer {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  overflow: hidden;
  opacity: 0;
  translate: var(--px, 0px) var(--py, 0px);
  background: var(--ph);
  clip-path: inset(0 0 100% 0);
  transition:
    clip-path 1.25s var(--ease) var(--d, 0s),
    opacity .7s var(--ease-io) var(--d, 0s);
  cursor: none;
  will-change: translate;
}
.layer.is-echo { clip-path: inset(0); background: none; }
.layer img {
  position: absolute;
  left: var(--ix); top: var(--iy); width: var(--iw); height: var(--ih);
  max-width: none; object-fit: cover;
  scale: 1.14;
  opacity: 0;
  transition: scale 1.6s var(--ease) var(--d, 0s), opacity .6s ease;
}
.layer img.is-ready { opacity: 1; }
.spread.in .layer { clip-path: inset(0); opacity: var(--a); }
.spread.in .layer img { scale: 1; }
.spread.in .layer.is-done { transition: opacity .55s var(--ease-io), clip-path 0s; }
.spread.in .layer.is-done img { transition: scale 1.4s var(--ease), opacity .6s ease; }

/* Hover: the photo under the cursor stays lit, the rest of the spread falls back. */
.stage:has(.layer:hover) .layer.is-done:not(:hover) { opacity: calc(var(--a) * .32); }
.spread.in .layer.is-done:hover { opacity: 1; }
.spread.in .layer.is-done:hover img { scale: 1.035; }
.layer:focus-visible { outline: 1px solid var(--fg); outline-offset: -1px; opacity: 1; }

/* Captions, positioned like the PDF */
.cap { position: absolute; z-index: 30; pointer-events: none; }
.cap a, .cap button { pointer-events: auto; }
.cap--right { text-align: right; }
.cap__title {
  margin: 0;
  font-family: var(--sans); font-weight: 500;
  font-size: 2.2cqw; line-height: .98; letter-spacing: -.028em;
  text-transform: uppercase;
}
.cap--s .cap__title { font-size: 1.3cqw; }
.cap__credits { margin: .8cqw 0 0; display: grid; gap: .28cqw; }
.cap--s .cap__credits { margin-top: .45cqw; }
.cap__row { font-size: max(10px, .86cqw); }
.cap--s .cap__row { font-size: max(10px, .74cqw); }
.cap__row .k { color: var(--dim); margin-right: .7em; }
.cap--right .cap__row { justify-self: end; }

/* Line-mask reveal shared by captions and the hero */
.ln { display: block; overflow: hidden; padding-bottom: .06em; margin-bottom: -.06em; }
.ln > span { display: block; transform: translateY(105%); transition: transform 1.1s var(--ease) var(--d, 0s); }
.spread.in .ln > span { transform: none; }

/* Hero (PDF page 1) */
.hero-name {
  position: absolute; left: 8.47%; top: 5.9%; z-index: 30; margin: 0;
  font-family: var(--sans); font-weight: 500; color: #d9d9d9;
  font-size: 9.55cqw; line-height: .862; letter-spacing: -.045em;
  font-variation-settings: "opsz" 32;
}

/* Focus pull: each line rises a touch while going from soft to sharp */
.fl { display: block; }
.fw {
  display: inline-block;
  opacity: 0; filter: blur(.13em); transform: translate3d(0, .16em, 0) scale(1.015); transform-origin: 0 100%;
  transition:
    opacity 1.1s var(--ease-io) var(--d, 0s),
    filter 1.6s var(--ease) var(--d, 0s),
    transform 1.8s var(--ease) var(--d, 0s);
  will-change: filter, transform, opacity;
}
.spread.in .fw { opacity: 1; filter: blur(0); transform: none; }
.hero-meta {
  position: absolute; left: 8.47%; top: 38.6%; z-index: 30; display: flex; gap: 2.2cqw;
  font-size: max(10px, .8cqw); color: var(--dim);
  opacity: 0; transition: opacity 1s ease .9s;
}
.spread.in .hero-meta { opacity: 1; }

/* Contact spread (PDF page 22) */
.contact { position: absolute; left: 3.2%; top: 11.6%; z-index: 30; }
.contact__title {
  margin: 0; font-family: var(--sans); font-weight: 500; font-size: 5.6cqw; line-height: .862;
  letter-spacing: -.045em; text-transform: uppercase; font-variation-settings: "opsz" 32;
  color: #d9d9d9;
}
/* label above value, like the credits elsewhere on the site */
.contact__list { display: flex; flex-wrap: wrap; gap: 1.2cqw 4.2cqw; margin: 2.3cqw 0 0; }
.contact__item { font-size: max(11px, .92cqw); }
.contact__item dt { color: var(--dim); margin-bottom: .45em; }
.contact__item dd { margin: 0; display: flex; align-items: baseline; gap: .9em; }
.copy-btn { color: var(--dim); transition: color .3s; }
.copy-btn:hover, .copy-btn:focus-visible { color: var(--fg); }
.contact__foot {
  position: absolute; left: 3.2%; right: 3.2%; bottom: 4.2%; z-index: 30;
  display: flex; justify-content: space-between; font-size: max(10px, .8cqw); color: var(--dim);
}
.contact__foot a { color: var(--fg); }
.contact__list, .contact__foot {
  opacity: 0; transform: translateY(10px);
  transition: opacity 1s ease var(--d, 0s), transform 1s var(--ease) var(--d, 0s);
}
.spread.in .contact__list, .spread.in .contact__foot { opacity: 1; transform: none; }

/* ---------- Grid view ---------- */
.grid-view { padding: 84px var(--gutter) 64px; min-height: 100vh; }
.filters {
  display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 3px; margin-bottom: 22px;
  background: rgba(255, 255, 255, .06);
}
.chip { padding: 4px 7px 3px; color: var(--dim); transition: color .3s, background-color .3s; }
.chip sup { font-size: 8px; margin-left: 3px; vertical-align: 4px; }
.chip:hover { color: var(--fg); }
.chip.is-active { color: var(--fg); background: rgba(255, 255, 255, .08); }
.jgrid { position: relative; transition: height .8s var(--ease); }
.tile {
  position: absolute; left: 0; top: 0;
  transition: transform .9s var(--ease), opacity .5s ease, scale .6s var(--ease);
  cursor: none;
}
.tile.is-out { opacity: 0; scale: .96; pointer-events: none; }
.tile.is-pre { opacity: 0; translate: 0 18px; }
.jgrid.no-move .tile { transition: opacity .7s ease, translate 1s var(--ease); }
.tile__img { position: relative; overflow: hidden; background: var(--ph); }
.tile__img img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity .6s ease, scale 1.4s var(--ease); }
.tile__img img.is-ready { opacity: 1; }
.tile:hover .tile__img img { scale: 1.04; }
.tile__cap { display: flex; justify-content: space-between; gap: 12px; padding: 7px 8px 0 2px; font-size: 11px; white-space: nowrap; }
.tile__cap span:first-child { overflow: hidden; text-overflow: ellipsis; }
.jgrid:has(.tile:hover) .tile:not(:hover):not(.is-out) { opacity: .3; }
.grid-foot { display: flex; justify-content: space-between; margin-top: 56px; padding-bottom: 28px; }

/* ---------- Index overlay ---------- */
.index {
  position: fixed; inset: 0; z-index: 60; background: #000; overflow: hidden;
  opacity: 0; transition: opacity .6s var(--ease-io);
}
.index.is-open { opacity: 1; }
.index__bg { position: absolute; inset: 0; }
.index__bg img {
  position: absolute; inset: -6%; width: 112%; height: 112%; max-width: none; object-fit: cover;
  filter: blur(36px) brightness(.36) saturate(1.15);
  transition: opacity .5s ease;
}
.index__preview {
  position: absolute; left: 50%; top: 50%; height: 60vh; translate: -50% -50%;
  display: grid; place-items: center;
}
.index__preview img {
  height: 60vh; width: auto; max-width: 34vw; object-fit: contain;
  transition: opacity .45s ease, translate .9s var(--ease), clip-path .9s var(--ease);
  clip-path: inset(0);
}
.index__preview img.is-swap { opacity: 0; translate: 0 12px; }
.index__list {
  position: absolute; left: var(--gutter); top: 50%; translate: 0 -50%;
  margin: 0; padding: 0; list-style: none; display: grid; gap: 14px;
}
.index__row { display: block; text-align: left; color: var(--fg); opacity: .32; transition: opacity .35s ease; }
.index__row:hover, .index__row.is-active, .index__row:focus-visible { opacity: 1; }
.index__row .t { display: block; }
.index__row .n { display: block; color: var(--dim); }
.index__credits {
  position: absolute; right: var(--gutter); top: 50%; translate: 0 -50%; margin: 0;
  display: grid; gap: 2px; text-align: right; max-width: 28vw;
}
.index__credits div { display: flex; justify-content: flex-end; gap: 8px; }
.index__credits dt { color: var(--dim); }
.index__credits dd { margin: 0; }
.index__close { position: absolute; right: var(--gutter); top: 18px; color: var(--fg); }
.index__list li { opacity: 0; transform: translateY(8px); transition: opacity .6s ease, transform .8s var(--ease); transition-delay: calc(var(--i) * 45ms + .1s); }
.index.is-open .index__list li { opacity: 1; transform: none; }

/* ---------- Lightbox ---------- */
.lb {
  position: fixed; inset: 0; z-index: 70; background: #050505;
  opacity: 0; transition: opacity .45s var(--ease-io);
}
.lb.is-open { opacity: 1; }
.lb__stage { position: absolute; inset: 62px var(--gutter) 92px; }
.lb__img {
  position: absolute; inset: 0; margin: auto;
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  transition: opacity .35s ease, translate .7s var(--ease);
  user-select: none; -webkit-user-drag: none;
}
.lb__img.is-swap { opacity: 0; }
.lb__img.from-next { translate: 24px 0; }
.lb__img.from-prev { translate: -24px 0; }
.lb__zone { position: absolute; top: 62px; bottom: 92px; width: 50%; cursor: none; }
.lb__zone--prev { left: 0; }
.lb__zone--next { right: 0; }
.lb__zone:focus-visible { outline: none; }
.lb__top {
  position: absolute; left: 0; right: 0; top: 0; padding: 18px var(--gutter);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; z-index: 2;
}
.lb__meta { display: grid; gap: 2px; }
.lb__meta .k { color: var(--dim); margin-right: 8px; }
.lb__bottom {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 0 var(--gutter) max(16px, env(safe-area-inset-bottom));
  display: grid; grid-template-columns: 120px 1fr 120px; align-items: end; gap: 16px; z-index: 2;
}
.lb__count { font-variant-numeric: tabular-nums; }
.lb__keys { justify-self: end; }
.lb__strip {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; justify-self: center; max-width: 100%;
  padding: 2px 0; mask-image: linear-gradient(90deg, transparent, #000 6%, #000 94%, transparent);
}
.lb__strip::-webkit-scrollbar { display: none; }
.lb__thumb { flex: none; height: 42px; opacity: .3; transition: opacity .3s; }
.lb__thumb img { height: 100%; width: auto; }
.lb__thumb:hover, .lb__thumb.is-active { opacity: 1; }

/* ---------- Cursor label ---------- */
.cursor {
  position: fixed; left: 0; top: 0; z-index: 100; pointer-events: none;
  color: #fff; text-shadow: 0 0 14px rgba(0, 0, 0, .55), 0 0 2px rgba(0, 0, 0, .35);
  will-change: transform;
}
.cursor__label {
  position: absolute; left: 0; top: 0; translate: -50% -50%; white-space: nowrap;
  opacity: 0; scale: .9; transition: opacity .25s ease, scale .35s var(--ease);
}
.cursor.is-on .cursor__label { opacity: 1; scale: 1; }
.cursor__dot { display: none; }
@media (hover: none), (pointer: coarse) {
  .cursor { display: none; }
  .layer, .tile, .lb__zone { cursor: pointer; }
}

.toast {
  position: fixed; left: 50%; bottom: 56px; z-index: 80; translate: -50% 12px;
  padding: 7px 10px 6px; background: var(--fg); color: #000;
  opacity: 0; pointer-events: none; transition: opacity .3s ease, translate .5s var(--ease);
}
.toast.is-on { opacity: 1; translate: -50% 0; }
.noscript { padding: 40px var(--gutter); }

/* ==========================================================================
   Stacked layout: phones and portrait screens. The spreads become an
   editorial scroll, same order, same colours, captions first.
   ========================================================================== */
@media (max-width: 760px), (max-aspect-ratio: 1/1) {
  :root { --gutter: 16px; }
  .spread {
    height: auto; display: block; padding: 72px var(--gutter) 40px;
    background: var(--sbg); transition: none;
  }
  .spread + .spread { padding-top: 40px; }
  .stage { display: none; }
  .stack { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  /* the observed box stays unclipped (IntersectionObserver ignores clipped targets); the image wipes in */
  .stack .ph { position: relative; overflow: hidden; aspect-ratio: var(--ar); cursor: pointer; }
  .stack .ph--land { grid-column: span 2; }
  .stack .ph img {
    width: 100%; height: 100%; object-fit: cover; opacity: 0; background: var(--ph);
    clip-path: inset(0 0 100% 0); scale: 1.08;
    transition: clip-path 1.1s var(--ease) var(--d, 0s), scale 1.4s var(--ease) var(--d, 0s), opacity .6s ease;
  }
  .stack .ph img.is-ready { opacity: 1; }
  .stack .ph.in img { clip-path: inset(0); scale: 1; }
  .stack-cap { grid-column: 1 / -1; margin: 6px 0 14px; position: static; }
  .stack-cap .cap__title { font-size: 34px; }
  .stack-cap .cap__credits { margin-top: 10px; gap: 4px; }
  .stack-cap .cap__row { font-size: 11px; }
  .stack-cap .ln > span { transform: none; }
  .stack-hero { grid-column: 1 / -1; margin: 18vh 0 22px; }
  .stack-hero .hero-name { position: static; font-size: 23vw; }
  .stack-hero .hero-meta { position: static; margin-top: 18px; font-size: 11px; opacity: 1; flex-direction: column; gap: 3px; }
  .stack-contact { grid-column: 1 / -1; margin: 24px 0 18px; }
  .stack-contact .contact__title { font-size: 15vw; }
  .stack-contact .contact__list { flex-direction: column; gap: 16px; margin-top: 24px; opacity: 1; transform: none; }
  .stack-contact .contact__item { font-size: 12px; }
  .stack-foot { grid-column: 1 / -1; display: flex; justify-content: space-between; margin-top: 28px; color: var(--dim); font-size: 11px; }
  .stack-foot a { color: var(--fg); }
  .hud__proj, .hud__hint { display: none; }
  /* soft scrim so the HUD stays legible over photos on small screens */
  .hud::before {
    content: ""; position: absolute; left: 0; right: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(var(--page), transparent);
    transition: opacity .3s;
  }
  .hud--top::before { top: 0; height: 84px; }
  .hud--bottom::before { bottom: 0; height: 84px; background: linear-gradient(transparent, var(--page)); }
  .hud--bottom { grid-template-columns: auto 1fr; }
  .views { justify-self: end; }
  .index__preview { display: none; }
  .index__list { left: var(--gutter); right: var(--gutter); }
  .index__credits { top: auto; bottom: 22px; translate: none; left: var(--gutter); right: var(--gutter); max-width: none; text-align: left; }
  .index__credits div { justify-content: flex-start; }
  .lb__stage { inset: 70px 0 110px; }
  .lb__zone { top: 70px; bottom: 110px; }
  .lb__bottom { grid-template-columns: 1fr auto; }
  .lb__strip { grid-column: 1 / -1; grid-row: 1; justify-self: stretch; }
  .lb__keys { display: none; }
  .grid-view { padding-top: 72px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; transition-delay: 0s !important; animation: none !important; }
  .layer img, .spread.in .layer.is-done:hover img { scale: 1; }
}
