/* ==========================================================================
   Wphotographs — shared foundations
   ========================================================================== */

@font-face { font-family: 'Archivo'; src: url('../fonts/archivo.woff2') format('woff2-variations'); font-weight: 100 900; font-stretch: 62% 125%; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('../fonts/cormorant.woff2') format('woff2-variations'); font-weight: 300 700; font-style: normal; font-display: swap; }
@font-face { font-family: 'Cormorant'; src: url('../fonts/cormorant-italic.woff2') format('woff2-variations'); font-weight: 300 700; font-style: italic; font-display: swap; }
@font-face { font-family: 'JetBrains Mono'; src: url('../fonts/jetbrains-mono.woff2') format('woff2-variations'); font-weight: 100 800; font-display: swap; }

:root {
  --bg: #0e0e0d;
  --fg: #ece9e2;
  --muted: #8b877f;
  --accent: #d8c3a5;
  --line: color-mix(in srgb, var(--fg) 14%, transparent);
  --f-serif: 'Cormorant', 'Songti SC', 'STSong', 'Noto Serif SC', 'Source Han Serif SC', 'Noto Serif CJK SC', serif;
  --f-serif-jp: 'Cormorant', 'Hiragino Mincho ProN', 'Yu Mincho', 'YuMincho', 'Noto Serif JP', 'Noto Serif CJK JP', serif;
  --f-sans: 'Archivo', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Noto Sans SC', 'Noto Sans CJK SC', system-ui, sans-serif;
  --f-mono: 'JetBrains Mono', ui-monospace, 'SFMono-Regular', Menlo, monospace;
  --f-cjk-serif: 'Songti SC', 'STSong', 'Noto Serif SC', 'Source Han Serif SC', 'Noto Serif CJK SC', serif;
  --pad: clamp(16px, 4vw, 56px);
  --head-h: 64px;
  --ease: cubic-bezier(0.19, 1, 0.22, 1);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--f-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}
img { display: block; max-width: 100%; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }
p, h1, h2, h3, ol, ul, figure { margin: 0; padding: 0; }
:focus-visible { outline: 1px solid currentColor; outline-offset: 4px; }
::selection { background: var(--accent); color: var(--bg); }

/* Lenis */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }
html.is-locked, html.is-locked body { overflow: hidden; }

.page { position: relative; z-index: 1; }

/* Split text */
.sw { display: inline-block; overflow: hidden; vertical-align: top; padding-bottom: 0.1em; margin-bottom: -0.1em; }
.sw__i { display: inline-block; will-change: transform; }

/* ---------- WebGL canvases ---------------------------------------------------- */
.gl-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; opacity: 0; transition: opacity 0.9s ease; }
.gl-ready .gl-canvas, .gl-ready > .gl-canvas { opacity: 1; }
.gl-planes { position: fixed; inset: 0; width: 100%; height: 100%; display: block; pointer-events: none; z-index: 2; }
.no-webgl .gl-canvas, .no-webgl .gl-planes { display: none; }

/* ---------- Photo figure ------------------------------------------------------- */
.ph { position: relative; }
.ph__frame { position: relative; overflow: hidden; aspect-ratio: var(--ar); background: var(--ph-color, #222); cursor: zoom-in; transform: translateZ(0); }
.ph__inner { position: absolute; inset: 0; }
.ph__lqip, .ph__img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ph__lqip { filter: blur(16px); transform: scale(1.1); }
.ph__img { opacity: 0; transition: opacity 0.9s ease; }
.ph.is-loaded .ph__img { opacity: 1; }
.ph__cap { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.35em 1.1em; margin-top: 0.9em; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.04em; color: var(--muted); }
.ph__t { color: var(--fg); font-family: var(--f-cjk-serif); font-size: 13px; letter-spacing: 0.08em; }
.ph__loc { margin-left: auto; }

/* ---------- Header ------------------------------------------------------------- */
.site-head {
  position: fixed; inset: 0 0 auto 0; z-index: 60; height: var(--head-h);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0 var(--pad); padding-top: env(safe-area-inset-top);
  color: #fff; mix-blend-mode: difference;
  transition: transform 0.7s var(--ease);
}
.site-head.is-hidden { transform: translateY(-110%); }
.menu-open .site-head { transform: none; }
.brand { font-family: var(--f-serif); font-weight: 600; font-size: 22px; letter-spacing: 0.01em; line-height: 1; }
.brand__short { display: none; }
.site-head__crumb { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; opacity: 0.85; }
.site-head__crumb span { opacity: 0.6; margin-right: 0.6em; }
.site-head__crumb i { font-style: normal; margin-left: 0.5em; font-family: var(--f-cjk-serif); letter-spacing: 0.2em; }
.menu-btn { display: flex; align-items: center; gap: 12px; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; height: 44px; }
.menu-btn__label { display: grid; overflow: hidden; height: 1.4em; line-height: 1.4em; }
.menu-btn__label > span { grid-area: 1 / 1; transition: transform 0.6s var(--ease); }
.menu-btn__label > span:last-child { transform: translateY(110%); }
.menu-btn[aria-expanded='true'] .menu-btn__label > span:first-child { transform: translateY(-110%); }
.menu-btn[aria-expanded='true'] .menu-btn__label > span:last-child { transform: none; }
.menu-btn__icon { position: relative; width: 22px; height: 10px; }
.menu-btn__icon i { position: absolute; left: 0; right: 0; height: 1px; background: currentColor; transition: transform 0.6s var(--ease), top 0.6s var(--ease); }
.menu-btn__icon i:first-child { top: 1px; }
.menu-btn__icon i:last-child { top: 8px; }
.menu-btn[aria-expanded='true'] .menu-btn__icon i:first-child { top: 4.5px; transform: rotate(45deg); }
.menu-btn[aria-expanded='true'] .menu-btn__icon i:last-child { top: 4.5px; transform: rotate(-45deg); }

/* ---------- Menu ---------------------------------------------------------------- */
.menu { position: fixed; inset: 0; z-index: 55; visibility: hidden; color: #ece9e2; }
.menu.is-open { visibility: visible; }
.menu__bg { position: absolute; inset: 0; background: #0b0b0a; clip-path: inset(0 0 100% 0); }
.menu__inner { position: relative; height: 100%; display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); grid-template-rows: 1fr auto; gap: 2rem 4vw; padding: calc(var(--head-h) + 4vh) var(--pad) 28px; }
.menu__nav { align-self: center; }
.menu__nav ol { list-style: none; }
.menu__nav li { overflow: hidden; border-bottom: 1px solid rgba(236, 233, 226, 0.12); }
.menu__nav a { display: grid; grid-template-columns: 3.2ch minmax(0, 1fr) auto 3ch; align-items: baseline; gap: 1rem; padding: 0.45rem 0 0.35rem; transition: opacity 0.4s ease; }
.menu__nav:hover a { opacity: 0.32; }
.menu__nav a:hover, .menu__nav a:focus-visible { opacity: 1; }
.menu__n, .menu__count { font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.08em; opacity: 0.6; }
.menu__count { text-align: right; }
.menu__name { font-family: var(--f-serif); font-weight: 300; font-size: clamp(2.2rem, 5vw, 4.4rem); line-height: 1.02; letter-spacing: -0.01em; transition: transform 0.6s var(--ease), font-style 0s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu__nav a:hover .menu__name { transform: translateX(0.4em); font-style: italic; }
.menu__nav a.is-current .menu__name::after { content: ' ·'; color: var(--accent); }
.menu__zh { font-family: var(--f-cjk-serif); font-size: clamp(1rem, 1.6vw, 1.4rem); letter-spacing: 0.3em; opacity: 0.75; }
.menu__preview { position: relative; align-self: stretch; }
.menu__preview img { position: absolute; inset: 6% 0 6% 8%; width: 92%; height: 88%; object-fit: cover; opacity: 0; transform: scale(1.06); transition: opacity 0.6s ease, transform 1.2s var(--ease); }
.menu__preview img.is-active { opacity: 1; transform: none; }
.menu__pages { display: flex; flex-wrap: wrap; gap: 0.4rem 1.6rem; }
.menu__pages a { position: relative; padding: 6px 0; opacity: 0.75; transition: opacity 0.3s; }
.menu__pages a:hover { opacity: 1; }
.menu__foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; opacity: 0.7; }

/* ---------- Page transition veil ---------------------------------------------- */
.veil { position: fixed; inset: 0; z-index: 100; opacity: 0; pointer-events: none; }
html.is-leaving { cursor: progress; }
/* Arriving from another page: content waits (invisible) over its own background colour. */
html.is-entering:not(.is-revealing) .page, html.is-entering:not(.is-revealing) .site-head { opacity: 0; }

/* ---------- Lightbox -------------------------------------------------------------- */
.lb { position: fixed; inset: 0; z-index: 80; color: #eeebe4; }
.lb[hidden] { display: none; }
.lb__bg { position: absolute; inset: 0; background: rgba(8, 8, 7, 0.97); }
.lb__stage { position: absolute; inset: 0; overflow: hidden; touch-action: none; cursor: zoom-in; }
.lb.is-pannable .lb__stage { cursor: grab; }
.lb.is-dragging .lb__stage { cursor: grabbing; }
.lb__img, .lb__lq { position: absolute; left: 50%; top: 50%; max-width: none; user-select: none; -webkit-user-drag: none; pointer-events: none; will-change: transform; }
.lb__lq { filter: blur(18px); }
.lb__img { opacity: 0; transition: opacity 0.5s ease; }
.lb__img.is-loaded { opacity: 1; }
.lb__ui { position: absolute; inset: 0; pointer-events: none; font-family: var(--f-mono); font-size: 11px; letter-spacing: 0.1em; }
.lb__ui > * { pointer-events: auto; }
.lb__top { position: absolute; inset: 0 0 auto 0; display: flex; justify-content: space-between; align-items: center; padding: calc(14px + env(safe-area-inset-top)) var(--pad) 14px; pointer-events: none; }
.lb__top > * { pointer-events: auto; }
.lb__btn { min-width: 44px; min-height: 44px; padding: 0 14px; border: 1px solid rgba(238, 235, 228, 0.22); border-radius: 999px; background: rgba(10, 10, 9, 0.45); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); letter-spacing: 0.12em; text-transform: uppercase; transition: background 0.3s, border-color 0.3s; }
.lb__btn:hover { background: rgba(238, 235, 228, 0.12); border-color: rgba(238, 235, 228, 0.5); }
.lb__close i { font-style: normal; margin-left: 0.4em; }
.lb__cap { position: absolute; left: var(--pad); bottom: calc(24px + env(safe-area-inset-bottom)); display: grid; gap: 4px; max-width: 46ch; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.6); pointer-events: none; }
.lb__t { font-family: var(--f-cjk-serif); font-size: 18px; letter-spacing: 0.12em; }
.lb__e { font-family: var(--f-serif); font-style: italic; font-size: 17px; letter-spacing: 0; }
.lb__loc { opacity: 0.6; }
.lb__bar { position: absolute; right: var(--pad); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.lb__map { position: absolute; right: var(--pad); bottom: calc(84px + env(safe-area-inset-bottom)); width: 180px; max-height: 90px; border: 1px solid rgba(238, 235, 228, 0.3); overflow: hidden; opacity: 0; transition: opacity 0.4s; pointer-events: none; }
.lb.is-pannable .lb__map { opacity: 1; }
.lb__map img { width: 100%; height: 100%; object-fit: cover; opacity: 0.6; }
.lb__map i { position: absolute; border: 1px solid #fff; box-shadow: 0 0 0 999px rgba(0, 0, 0, 0.35); }
.lb__hint { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); padding: 10px 16px; border-radius: 999px; background: rgba(10, 10, 9, 0.55); opacity: 0; transition: opacity 0.6s; pointer-events: none; text-transform: uppercase; }
.lb__hint.is-on { opacity: 1; }

/* ---------- Album scroll progress ---------------------------------------------------- */
.progress { position: fixed; right: 14px; top: 50%; z-index: 40; width: 1px; height: 96px; transform: translateY(-50%); background: rgba(255, 255, 255, 0.25); mix-blend-mode: difference; pointer-events: none; }
.progress i { display: block; height: 100%; background: #fff; transform-origin: top; transform: scaleY(0); }

/* ---------- Narrow screens -------------------------------------------------------------- */
@media (max-width: 760px) {
  :root { --head-h: 56px; }
  .brand__full { display: none; }
  .brand__short { display: inline; }
  .site-head__crumb { display: none; }
  .menu__inner { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .menu__preview { display: none; }
  .menu__nav a { grid-template-columns: 2.6ch minmax(0, 1fr) auto; gap: 0.7rem; padding: 0.55rem 0 0.4rem; }
  .menu__count { display: none; }
  .menu__name { font-size: clamp(2rem, 10.5vw, 3rem); }
  .lb__cap { left: 16px; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); }
  .lb__bar { left: 16px; right: 16px; justify-content: space-between; }
  .lb__bar .lb__mode { flex: 1; }
  .lb__map { right: 16px; top: calc(70px + env(safe-area-inset-top)); bottom: auto; width: 120px; }
  .progress { right: 8px; height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; }
}
