/* ==========================================================================
   Luke Cheng — Photography Portfolio
   Dark brutalist point-cloud London. Black, white, one TfL-red accent.
   Archivo (heavy grotesque display) + Space Mono (metadata). Hard edges:
   no border-radius, no glow, no italics. Film grain over everything.
   ========================================================================== */

:root {
  --bg: #050505;            /* matches the 3D background so fade-out is seamless */
  --ink: #f2f2ef;
  --ink-dim: #7d7d78;
  --accent: #dc241f;        /* roundel red */
  --line: rgba(242, 242, 239, 0.18);
  --display: "Archivo", "Arial Black", sans-serif;
  --mono: "Space Mono", "Consolas", monospace;
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: auto; }

html, body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--display);
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}

/* The whole site hides the native cursor — a hard white square replaces it */
@media (hover: hover) and (pointer: fine) {
  html, body, a, button { cursor: none; }
}

::selection { background: var(--accent); color: #fff; }

/* the one repeated micro-label style: mono, tracked caps, used sparingly */
.hero-eyebrow, .beat-eyebrow, .kicker {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--accent);
}

/* ==========================================================================
   Canvas — fixed full-screen; the whole journey renders here
   ========================================================================== */
#webgl {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  z-index: 1;
}

/* ---- filmic finish ------------------------------------------------------- */
#vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse 130% 100% at 50% 45%, transparent 55%, rgba(0, 0, 0, 0.5) 100%);
}
#grain {
  position: fixed; inset: -120px; z-index: 86; pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='280' height='280'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.06;
  animation: grainShift 0.85s steps(1) infinite;
}
@keyframes grainShift {
  0%   { transform: translate(0, 0); }
  25%  { transform: translate(-46px, 32px); }
  50%  { transform: translate(28px, -54px); }
  75%  { transform: translate(-22px, -28px); }
  100% { transform: translate(40px, 18px); }
}

/* ==========================================================================
   Scroll track — its height IS the length of the 3D intro
   ========================================================================== */
/* long scroll track => slow camera = the flythrough reads detail-by-detail */
#journey { height: 560vh; }
@media (max-width: 768px) { #journey { height: 480vh; } }

/* ==========================================================================
   Preloader — black, mono counter, heavy wordmark
   ========================================================================== */
#loader {
  position: fixed; inset: 0; z-index: 100;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  transition: opacity 0.8s var(--ease), visibility 0.8s;
}
#loader.done { opacity: 0; visibility: hidden; }

.loader-clouds { display: none; }

.loader-inner { position: relative; text-align: center; color: var(--ink); }
.loader-name {
  font-family: var(--display); font-weight: 900; font-stretch: 125%;
  font-size: 22px; letter-spacing: 0.3em; text-transform: uppercase;
  margin-bottom: 28px;
}
.loader-bar {
  width: 240px; height: 2px; background: rgba(242, 242, 239, 0.15);
  margin: 0 auto 14px; overflow: hidden;
}
#loader-fill {
  display: block; width: 100%; height: 100%;
  background: var(--ink); transform: scaleX(0); transform-origin: left;
  transition: transform 0.25s var(--ease);
}
#loader-pct {
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.3em; opacity: 0.6;
}

/* ==========================================================================
   Fixed UI — nav, mute, progress, cursor
   ========================================================================== */
#nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  padding: 22px 34px;
  transform: translateY(-110%);
  transition: transform 0.55s var(--ease);
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.82), transparent);
}
#nav.visible { transform: translateY(0); }
.nav-logo {
  font-family: var(--display); font-weight: 900;
  color: var(--ink); text-decoration: none;
  letter-spacing: 0.08em; font-size: 16px;
  border: 2px solid var(--ink); padding: 5px 8px;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
.nav-logo:hover { background: var(--ink); color: var(--bg); }
.nav-links a {
  font-family: var(--mono);
  color: var(--ink-dim); text-decoration: none; font-size: 11px;
  letter-spacing: 0.22em; text-transform: uppercase; margin-left: 30px;
  transition: color 0.3s var(--ease);
}
.nav-links a:hover, .nav-links a:focus-visible { color: var(--ink); }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 3px;
}

#mute {
  position: fixed; right: 26px; bottom: 24px; z-index: 41;
  width: 42px; height: 42px;
  border: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.6); color: var(--ink);
  display: flex; align-items: center; justify-content: center;
  transition: border-color 0.3s var(--ease), background 0.3s var(--ease);
}
#mute:hover { border-color: var(--ink); }
#mute:active { transform: scale(0.96); }

#progress {
  position: fixed; top: 0; right: 0; bottom: 0; width: 2px; z-index: 39;
  background: rgba(242, 242, 239, 0.08);
}
#progress-fill {
  display: block; width: 100%; height: 100%;
  background: var(--ink);
  transform: scaleY(0); transform-origin: top;
}

/* Custom cursor: hard white square + thin square frame */
#cursor, #cursor-ring {
  position: fixed; top: 0; left: 0; z-index: 90;
  pointer-events: none;
  transform: translate(-50%, -50%);
}
#cursor { width: 6px; height: 6px; background: var(--ink); }
#cursor-ring {
  width: 30px; height: 30px;
  border: 1px solid rgba(242, 242, 239, 0.4);
  transition: width 0.25s var(--ease), height 0.25s var(--ease),
    border-color 0.25s var(--ease), opacity 0.25s var(--ease);
}
body.cursor-active #cursor-ring { width: 48px; height: 48px; border-color: var(--accent); }
@media (hover: none), (pointer: coarse) {
  #cursor, #cursor-ring { display: none; }
}

#card-label {
  position: fixed; z-index: 91; pointer-events: none;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--bg); background: var(--ink);
  padding: 8px 14px; opacity: 0; white-space: nowrap;
  transform: translate(18px, 18px);
  transition: opacity 0.25s var(--ease);
}
#card-label.visible { opacity: 1; }

/* ==========================================================================
   Journey text overlays
   ========================================================================== */
#hero {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-end;
  text-align: left; pointer-events: none; color: var(--ink);
  padding: 0 0 7vh 6vw;
}
#hero h1 {
  font-weight: 900; font-stretch: 125%;
  font-size: clamp(34px, 5.5vw, 78px);
  letter-spacing: -0.01em;
  line-height: 0.92;
  text-transform: uppercase;
  margin-top: 14px;
}
.hero-meta {
  margin-top: 36px; display: flex; align-items: center; gap: 16px;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--ink); opacity: 0.8;
}
.hero-meta i { width: 26px; height: 1px; background: currentColor; opacity: 0.5; }

#scroll-hint {
  position: absolute; bottom: 6vh; left: 50%; transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.3em; text-transform: uppercase; opacity: 0.7;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
#scroll-hint span {
  display: block; width: 1px; height: 44px;
  background: linear-gradient(180deg, var(--ink), transparent);
  animation: hintdrop 1.8s ease-in-out infinite;
}
@keyframes hintdrop {
  0%   { transform: scaleY(0); transform-origin: top; opacity: 1; }
  60%  { transform: scaleY(1); transform-origin: top; }
  100% { transform: scaleY(1) translateY(10px); opacity: 0; }
}

/* short copy beats mid-journey (opacity driven from main.js) */
.beat {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; text-align: center; pointer-events: none; opacity: 0;
  color: var(--ink);
}
.beat-line {
  font-weight: 800; font-stretch: 116%;
  font-size: clamp(26px, 4.4vw, 58px); letter-spacing: 0.005em;
  text-transform: uppercase;
}

#work-label {
  position: fixed; top: 9vh; left: 0; right: 0; z-index: 10;
  text-align: center; pointer-events: none; opacity: 0;
}
#work-label h2 {
  font-weight: 900; font-stretch: 125%;
  font-size: clamp(28px, 4vw, 52px); text-transform: uppercase;
  letter-spacing: 0.02em;
}
#work-label p {
  font-family: var(--mono);
  margin-top: 12px; font-size: 10px; letter-spacing: 0.26em;
  text-transform: uppercase; color: var(--ink-dim);
}

/* station name board — like a tube platform sign, with the line colour bar */
#station-name {
  position: fixed; left: 7vw; bottom: 12vh; z-index: 10;
  display: flex; gap: 18px; align-items: stretch; pointer-events: none;
  opacity: 0; transform: translateY(12px);
  transition: opacity 0.5s var(--ease), transform 0.5s var(--ease);
}
#station-name.in { opacity: 1; transform: translateY(0); }
.sn-bar { width: 6px; background: var(--accent); flex-shrink: 0; }
.sn-body h3 {
  font-family: var(--display); font-weight: 900; font-stretch: 118%;
  font-size: clamp(26px, 4vw, 50px); text-transform: uppercase;
  letter-spacing: -0.01em; line-height: 0.96;
}
.sn-body p {
  font-family: var(--mono); margin-top: 10px; font-size: 11px;
  letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-dim);
}
.sn-hint {
  display: inline-block; margin-top: 14px; font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase;
  color: var(--accent);
}
@media (max-width: 768px) { #station-name { left: 6vw; bottom: 16vh; } }

/* ==========================================================================
   The work — PROJECT INDEX (built by js/photogallery.js)
   ========================================================================== */
#photo-gallery { position: relative; padding: 0 0 8vh; }

/* arrival panel — kept compact so the projects are in view the moment the
   point cloud dissolves (no big empty header to scroll past) */
.work-intro {
  max-width: 1320px; margin: 0 auto; padding: 9vh 6vw 5vh;
}
/* a following region (e.g. Hong Kong after London) — more air + a divider */
.work-intro.region-next { padding-top: 15vh; margin-top: 4vh; border-top: 1px solid var(--line); }
.work-intro h2 {
  font-weight: 900; font-stretch: 121%;
  font-size: clamp(40px, 7vw, 104px); line-height: 0.9;
  text-transform: uppercase; letter-spacing: -0.015em; margin-top: 22px;
}
.work-sub {
  margin-top: 26px; font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.14em; line-height: 2; text-transform: uppercase; color: var(--ink-dim);
}

/* the three project covers */
.project-index {
  max-width: 1320px; margin: 0 auto; padding: 0 6vw;
  display: flex; flex-direction: column; gap: 4vh;
}
.project-card {
  position: relative; display: grid; grid-template-columns: 1fr;
  cursor: pointer; isolation: isolate;
}
.pc-media {
  position: relative; overflow: hidden; aspect-ratio: 16 / 8;
  border: 1px solid var(--line);
}
.pc-media img {
  width: 100%; height: 100%; object-fit: cover; display: block;
  filter: brightness(0.7) saturate(0.92) contrast(1.02);
  transform: scale(1.02);
  transition: transform 1.1s var(--ease), filter 0.7s var(--ease);
}
.pc-media::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(180deg, rgba(5,6,8,0.2) 0%, transparent 38%, rgba(5,6,8,0.78) 100%);
}
.project-card:hover .pc-media img,
.project-card:focus-visible .pc-media img { transform: scale(1.06); filter: brightness(0.92) saturate(1.04); }

.pc-meta {
  position: absolute; inset: auto 0 0 0; z-index: 2; pointer-events: none;
  padding: clamp(20px, 4vw, 48px); display: grid; align-content: end;
}
.pc-num {
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.3em; color: var(--accent);
}
.pc-meta h3 {
  margin-top: 12px; font-weight: 900; font-stretch: 110%;
  font-size: clamp(30px, 5.2vw, 68px); line-height: 0.92;
  text-transform: uppercase; letter-spacing: -0.01em;
}
.pc-meta p {
  margin-top: 12px; max-width: 40ch; font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim);
}
.pc-open {
  margin-top: 18px; font-family: var(--mono); font-size: 11px;
  letter-spacing: 0.2em; text-transform: uppercase; color: var(--ink);
  border-top: 1px solid var(--line); padding-top: 14px; width: max-content;
  transition: color 0.4s var(--ease), border-color 0.4s var(--ease);
}
.project-card:hover .pc-open { color: var(--accent); border-color: var(--accent); }

/* projects with no photos yet — a quiet "coming soon" cover, not clickable */
.project-card.empty { cursor: default; }
.pc-empty {
  width: 100%; height: 100%;
  background:
    repeating-linear-gradient(45deg, rgba(255,255,255,0.018) 0 12px, transparent 12px 24px),
    #0b0b0b;
  border: 0;
}
.project-card.empty .pc-open { color: var(--ink-dim); }

/* ==========================================================================
   Full-screen PROJECT VIEWER
   ========================================================================== */
#project-view {
  position: fixed; inset: 0; z-index: 65; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg);
  opacity: 0; visibility: hidden; pointer-events: none;
  transition: opacity 0.5s var(--ease), visibility 0.5s;
}
#project-view.open { opacity: 1; visibility: visible; pointer-events: auto; }
body.noscroll { overflow: hidden; }

#pv-close {
  position: fixed; top: 22px; right: 26px; z-index: 3;
  width: 44px; height: 44px; background: var(--bg); border: 1px solid var(--line);
  color: var(--ink); font-size: 24px; line-height: 1; cursor: pointer;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
}
#pv-close:hover { background: var(--ink); color: var(--bg); }

.pv-head { max-width: 1320px; margin: 0 auto; padding: 16vh 6vw 6vh; }
.pv-head #pv-num { font-family: var(--mono); font-size: 12px; letter-spacing: 0.3em; color: var(--accent); }
.pv-head h2 {
  margin-top: 14px; font-weight: 900; font-stretch: 121%;
  font-size: clamp(40px, 7vw, 104px); line-height: 0.9;
  text-transform: uppercase; letter-spacing: -0.015em;
}
.pv-head p {
  margin-top: 16px; font-family: var(--mono); font-size: 12px;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim);
}

#pv-grid {
  max-width: 1320px; margin: 0 auto; padding: 0 6vw 16vh;
  display: flex; flex-direction: column; gap: 9vh;
}
.pv-photo { position: relative; margin: 0; cursor: zoom-in; width: 100%; }
.pv-photo img {
  display: block; width: 100%; height: auto;
  filter: brightness(0.97) saturate(0.99);
  transition: filter 0.5s var(--ease);
}
.pv-photo:hover img { filter: brightness(1.04) saturate(1.05); }
.pv-photo.feature { width: min(100%, 1180px); margin-inline: auto; }
.pv-photo:not(.feature):not(.wide) { width: min(86%, 1000px); }
.pv-photo.wide { width: 100%; }
.pv-photo:not(.feature):not(.wide):nth-of-type(odd) { margin-right: auto; }
.pv-photo:not(.feature):not(.wide):nth-of-type(even) { margin-left: auto; }
.pv-photo figcaption {
  margin-top: 14px; font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-dim);
}
.pv-photo figcaption span { border-left: 2px solid var(--accent); padding-left: 12px; }

/* scroll-in reveal */
.reveal { opacity: 0; transform: translateY(40px); filter: blur(6px);
  transition: opacity 0.9s var(--ease), transform 0.9s var(--ease), filter 0.9s var(--ease); }
.reveal.in { opacity: 1; transform: none; filter: blur(0); }

@media (max-width: 768px) {
  .work-intro { padding-top: 10vh; }
  .pc-media { aspect-ratio: 4 / 5; }
  #pv-grid { gap: 6vh; }
  .pv-photo, .pv-photo.feature, .pv-photo:not(.feature):not(.wide) { width: 100%; }
}

/* ==========================================================================
   Post-intro DOM sections
   ========================================================================== */
#after { position: relative; z-index: 5; background: var(--bg); }

.section { position: relative; padding: 20vh 8vw 16vh; }
.section-inner { position: relative; max-width: 1140px; margin: 0 auto; }

.kicker { display: block; margin-bottom: 26px; }
.section h2 {
  font-weight: 900; font-stretch: 121%;
  font-size: clamp(36px, 5.6vw, 76px); line-height: 0.98;
  text-transform: uppercase; letter-spacing: -0.005em;
  margin-bottom: 56px;
  text-wrap: balance;
}

.about-cols { display: grid; grid-template-columns: 1fr 1.2fr; gap: 64px; align-items: start; }
.about-photo {
  border: 1px solid var(--line);
  padding: 10px;
}
.about-photo img {
  width: 100%; height: auto; display: block;
  filter: grayscale(0.9) contrast(1.05);
}
.about-text p {
  color: var(--ink-dim); line-height: 1.8; font-size: 16px;
  margin-bottom: 24px; max-width: 56ch;
}
.about-meta {
  font-family: var(--mono);
  color: var(--ink) !important; font-size: 12px !important; letter-spacing: 0.14em;
  text-transform: uppercase;
}

.contact-mail {
  display: inline-block; color: var(--ink); text-decoration: none;
  font-family: var(--mono); font-weight: 700;
  font-size: clamp(17px, 2.6vw, 30px);
  border: 1px solid var(--line);
  padding: 16px 22px;
  transition: background 0.3s var(--ease), color 0.3s var(--ease), border-color 0.3s var(--ease);
}
.contact-mail:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.contact-socials { margin-top: 52px; display: flex; gap: 36px; }
.contact-socials a {
  font-family: var(--mono);
  color: var(--ink-dim); text-decoration: none; font-size: 11px;
  letter-spacing: 0.24em; text-transform: uppercase;
  transition: color 0.3s var(--ease);
}
.contact-socials a:hover { color: var(--ink); }

footer {
  padding: 40px 8vw 48px; display: flex; justify-content: space-between;
  border-top: 1px solid var(--line);
  color: var(--ink-dim); font-family: var(--mono); font-size: 11px; letter-spacing: 0.04em;
}

@media (max-width: 768px) {
  .about-cols { grid-template-columns: 1fr; }
  footer { flex-direction: column; gap: 10px; }
  .hero-meta { flex-direction: column; gap: 12px; letter-spacing: 0.22em; }
  .hero-meta i { width: 1px; height: 14px; }
}

/* ==========================================================================
   Project gallery overlay
   ========================================================================== */
#gallery {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(5, 5, 5, 0.99);
  overflow-y: auto; overscroll-behavior: contain;
  transform: translateY(100%); visibility: hidden;
}
#gallery.open { visibility: visible; }

.gallery-head {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: baseline; gap: 40px;
  padding: 28px 5vw;
  background: linear-gradient(180deg, rgba(5, 5, 5, 0.96) 65%, transparent);
}
#gallery-back {
  font-family: var(--mono);
  background: none; border: 1px solid var(--ink);
  color: var(--ink); padding: 11px 20px; font-size: 10px;
  letter-spacing: 0.22em; text-transform: uppercase;
  transition: background 0.3s var(--ease), color 0.3s var(--ease);
  flex-shrink: 0;
}
#gallery-back:hover { background: var(--ink); color: var(--bg); }
#gallery-back:active { transform: scale(0.98); }
#gallery-title {
  font-weight: 900; font-stretch: 121%;
  font-size: clamp(26px, 3.4vw, 46px); text-transform: uppercase;
}
#gallery-sub {
  font-family: var(--mono);
  color: var(--ink-dim); font-size: 11px; letter-spacing: 0.22em;
  text-transform: uppercase; margin-top: 8px;
}

/* Masonry via CSS columns — items keep natural aspect ratios */
.gallery-grid { columns: 3 320px; column-gap: 14px; padding: 10px 5vw 60px; }
.gallery-item { break-inside: avoid; margin-bottom: 14px; position: relative; overflow: hidden; }
.gallery-item img {
  width: 100%; display: block; transform: scale(1);
  transition: transform 0.6s var(--ease), filter 0.6s var(--ease);
  filter: grayscale(0.35) brightness(0.92);
}
.gallery-item:hover img { transform: scale(1.04); filter: grayscale(0) brightness(1.04); }
.gallery-item figcaption {
  position: absolute; left: 0; bottom: 0;
  font-family: var(--mono);
  padding: 8px 12px; font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--bg); background: var(--ink);
  opacity: 0; transition: opacity 0.3s var(--ease);
}
.gallery-item:hover figcaption { opacity: 1; }

.gallery-foot {
  font-family: var(--mono);
  padding: 0 5vw 70px; color: var(--ink-dim); font-size: 10px;
  letter-spacing: 0.26em; text-transform: uppercase;
}

/* ==========================================================================
   Lightbox
   ========================================================================== */
#lightbox {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(3, 3, 3, 0.97);
  display: flex; align-items: center; justify-content: center;
  opacity: 0; visibility: hidden;
  transition: opacity 0.35s var(--ease), visibility 0.35s;
}
#lightbox.open { opacity: 1; visibility: visible; }
#lb-img { max-width: 86vw; max-height: 84vh; border: 1px solid var(--line); }
#lightbox button {
  position: absolute; background: none; border: none; color: var(--ink);
  font-size: 26px; padding: 18px; opacity: 0.7;
  transition: opacity 0.25s var(--ease);
}
#lightbox button:hover { opacity: 1; }
#lb-close { top: 18px; right: 24px; }
#lb-prev  { left: 18px; top: 50%; transform: translateY(-50%); }
#lb-next  { right: 18px; top: 50%; transform: translateY(-50%); }
#lb-caption {
  position: absolute; bottom: 26px; left: 0; right: 0; text-align: center;
  font-family: var(--mono);
  font-size: 10px; letter-spacing: 0.26em; text-transform: uppercase; color: var(--ink-dim);
}

/* ==========================================================================
   Reduced motion — calm everything down
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  #scroll-hint span, #grain { animation: none; }
  * { transition-duration: 0.01s !important; }
}
