/* ==========================================================================
   wangzxue.cn — photography portfolio
   Design system + all page styles. Single stylesheet, no build step.
   ========================================================================== */

/* --- 1. Tokens ----------------------------------------------------------- */

:root {
  /* Dark is the default: photo sites read better as a dark room. */
  --bg:            #0b0b0c;
  --bg-elevated:   #141416;
  --bg-sunken:     #08080a;
  --fg:            #f2f2f0;
  --fg-muted:      #a0a0a3;
  --fg-faint:      #66666b;
  --line:          rgba(255, 255, 255, 0.10);
  --line-strong:   rgba(255, 255, 255, 0.20);
  --accent:        #e8b464;
  --on-accent:     #17130c;
  --scrim:         rgba(0, 0, 0, 0.55);

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
               "Noto Sans SC", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Noto Serif SC", "Songti SC", "SimSun", Georgia, serif;

  /* Fluid type — scales with viewport so no breakpoint juggling for headings. */
  --step--1: clamp(0.80rem, 0.77rem + 0.15vw, 0.88rem);
  --step-0:  clamp(0.94rem, 0.90rem + 0.20vw, 1.05rem);
  --step-1:  clamp(1.15rem, 1.06rem + 0.45vw, 1.45rem);
  --step-2:  clamp(1.45rem, 1.25rem + 1.00vw, 2.10rem);
  --step-3:  clamp(1.95rem, 1.50rem + 2.20vw, 3.40rem);
  --step-4:  clamp(2.60rem, 1.60rem + 4.50vw, 6.00rem);

  --gutter: clamp(1.15rem, 4vw, 4rem);
  --maxw: 1680px;
  --radius: 4px;
  --radius-lg: 10px;

  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
  --dur: 420ms;
}

[data-theme="light"] {
  --bg:            #faf9f7;
  --bg-elevated:   #ffffff;
  --bg-sunken:     #f0eeea;
  --fg:            #16161a;
  --fg-muted:      #5c5c63;
  --fg-faint:      #94949b;
  --line:          rgba(0, 0, 0, 0.12);
  --line-strong:   rgba(0, 0, 0, 0.24);
  --accent:        #a8731a;
  --on-accent:     #ffffff;
  --scrim:         rgba(255, 255, 255, 0.72);
}

/* --- 2. Reset ----------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: var(--step-0);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* Locked while the lightbox is open so the page behind can't scroll. */
body.is-locked { overflow: hidden; }

img { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 2px;
}

::selection { background: var(--accent); color: var(--on-accent); }

/* --- 3. Layout primitives ----------------------------------------------- */

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

.section { padding-block: clamp(3.5rem, 9vw, 8rem); }

.eyebrow {
  font-size: var(--step--1);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-faint);
  font-weight: 500;
  margin: 0 0 0.6rem;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  flex-wrap: wrap;
  margin-bottom: clamp(1.75rem, 4vw, 3rem);
}

.section-head h2 {
  font-size: var(--step-2);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.15;
}

.section-head p {
  margin: 0.5rem 0 0;
  color: var(--fg-muted);
  max-width: 46ch;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 200;
  background: var(--accent);
  color: var(--on-accent);
  padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* --- 4. Header ---------------------------------------------------------- */

.site-header {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.9rem var(--gutter);
  transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease),
              backdrop-filter var(--dur) var(--ease);
  border-bottom: 1px solid transparent;
}

/* Solid once scrolled past the hero, so nav text stays legible on any photo. */
.site-header.is-stuck {
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom-color: var(--line);
}

/* While transparent over the hero, a soft top scrim keeps nav text readable
   against a bright sky without looking like a bar. */
.site-header:not(.is-stuck)::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.55), transparent);
  pointer-events: none;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  font-size: 0.95rem;
  text-transform: uppercase;
}

/* Sized in em so the mark keeps its proportion to the wordmark if the brand
   type scale ever moves. */
.brand-mark {
  width: 1.5em;
  height: 1.5em;
  flex: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: clamp(1rem, 2.5vw, 2.25rem);
}

.nav a {
  font-size: var(--step--1);
  color: var(--fg-muted);
  letter-spacing: 0.02em;
  position: relative;
  padding-block: 0.25rem;
  transition: color 200ms var(--ease);
}

.nav a::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 1px;
  background: currentColor;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 320ms var(--ease);
}

.nav a:hover, .nav a[aria-current="page"] { color: var(--fg); }
.nav a:hover::after, .nav a[aria-current="page"]::after { transform: scaleX(1); }

.header-tools { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  width: 40px; height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--fg-muted);
  transition: color 200ms var(--ease), background 200ms var(--ease);
}
.icon-btn:hover { color: var(--fg); background: var(--line); }
.icon-btn svg { width: 19px; height: 19px; }
[data-theme="light"] .icon-sun,
:root:not([data-theme="light"]) .icon-moon { display: none; }

.nav-toggle { display: none; }

/* With the drawer open on small screens the header sits over the elevated
   panel, so give its controls a visible surface. */
body.nav-open .site-header {
  background: var(--bg-elevated);
  border-bottom-color: var(--line);
}

/* --- 5. Hero ------------------------------------------------------------ */

.hero {
  position: relative;
  min-height: 100svh;
  display: grid;
  align-items: end;
  overflow: hidden;
  isolation: isolate;
}

.hero-media {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.hero-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 42%;
  /* Slight push so the horizon sits above the text block. */
  transform: scale(1.04);
  animation: heroIn 2s var(--ease) both;
}

@keyframes heroIn {
  from { opacity: 0; transform: scale(1.10); }
  to   { opacity: 1; transform: scale(1.04); }
}

.hero-media::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(to top, var(--bg) 0%, color-mix(in srgb, var(--bg) 60%, transparent) 26%, transparent 60%),
    linear-gradient(to right, color-mix(in srgb, var(--bg) 55%, transparent), transparent 55%);
}

.hero-inner {
  padding-block: clamp(2.5rem, 8vh, 6rem) clamp(3rem, 9vh, 7rem);
  max-width: 62rem;
}

.hero h1 {
  font-size: var(--step-4);
  line-height: 0.98;
  margin: 0.5rem 0 0;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.hero h1 em {
  font-family: var(--font-serif);
  font-style: normal;
  font-weight: 400;
  letter-spacing: 0.01em;
}

.hero p {
  font-size: var(--step-1);
  color: var(--fg-muted);
  max-width: 40ch;
  margin: 1.25rem 0 0;
}

.hero-meta {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: var(--step--1);
  color: var(--fg-faint);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hero-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 2rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  border: 1px solid var(--line-strong);
  transition: background 240ms var(--ease), color 240ms var(--ease),
              border-color 240ms var(--ease), transform 240ms var(--ease);
}

.btn:hover { transform: translateY(-2px); border-color: var(--fg); }

.btn--solid {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}
.btn--solid:hover { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

.btn svg { width: 15px; height: 15px; }

.scroll-cue {
  position: absolute;
  right: var(--gutter);
  bottom: clamp(3rem, 9vh, 7rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.7rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg-faint);
  /* Prefixed so the rotated label doesn't get squeezed by inherited
     horizontal flex sizing. */
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

.scroll-cue::after {
  content: "";
  width: 1px;
  height: 54px;
  background: linear-gradient(var(--fg-faint), transparent);
  animation: cueDrop 2.4s var(--ease) infinite;
}

@keyframes cueDrop {
  0%   { transform: scaleY(0); transform-origin: top; }
  45%  { transform: scaleY(1); transform-origin: top; }
  55%  { transform: scaleY(1); transform-origin: bottom; }
  100% { transform: scaleY(0); transform-origin: bottom; }
}

/* --- 6. Category cards -------------------------------------------------- */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: clamp(0.75rem, 1.6vw, 1.25rem);
}

.cat-card {
  position: relative;
  display: block;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  aspect-ratio: 3 / 4;
  isolation: isolate;
}

.cat-card img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform 900ms var(--ease), filter 600ms var(--ease);
  filter: saturate(0.9) brightness(0.82);
}

.cat-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.86) 4%, rgba(0,0,0,0.28) 42%, transparent 72%);
}

.cat-card:hover img { transform: scale(1.07); filter: saturate(1.05) brightness(0.95); }

.cat-card-body {
  position: absolute;
  inset: auto 0 0 0;
  z-index: 1;
  padding: clamp(1rem, 2vw, 1.6rem);
  color: #fff;
}

.cat-card-body h3 {
  margin: 0;
  font-size: var(--step-1);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.cat-card-body span {
  display: block;
  font-size: 0.72rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.62);
  margin-top: 0.2rem;
}

.cat-card-body p {
  margin: 0.5rem 0 0;
  font-size: var(--step--1);
  color: rgba(255,255,255,0.74);
  line-height: 1.5;
}

.cat-count {
  position: absolute;
  top: 0.9rem; right: 0.9rem;
  z-index: 1;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.16);
}

/* --- 7. Filter bar ------------------------------------------------------ */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding-block: 0.5rem clamp(1.5rem, 3vw, 2.25rem);
}

.chip {
  padding: 0.42rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: var(--step--1);
  color: var(--fg-muted);
  transition: all 200ms var(--ease);
  white-space: nowrap;
}

.chip:hover { border-color: var(--line-strong); color: var(--fg); }

.chip[aria-pressed="true"] {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.chip-count { opacity: 0.5; margin-left: 0.35rem; font-size: 0.85em; }

/* --- 8. Masonry gallery ------------------------------------------------- */

/* CSS columns give true masonry with zero JS and no layout shift, as long as
   each image carries width/height + aspect-ratio so the column height is known
   before the bytes arrive. */
.masonry {
  columns: 3;
  column-gap: clamp(0.6rem, 1.4vw, 1.1rem);
}

.tile {
  break-inside: avoid;
  margin-bottom: clamp(0.6rem, 1.4vw, 1.1rem);
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: zoom-in;
  display: block;
  width: 100%;
}

.tile img {
  width: 100%;
  height: auto;
  transition: transform 800ms var(--ease), opacity 700ms var(--ease);
  opacity: 0;
}

.tile img.is-loaded { opacity: 1; }
.tile:hover img { transform: scale(1.035); }

.tile-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 1.4rem 1.1rem 0.95rem;
  background: linear-gradient(to top, rgba(0,0,0,0.82), transparent);
  color: #fff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 340ms var(--ease), transform 340ms var(--ease);
  pointer-events: none;
}

.tile:hover .tile-overlay,
.tile:focus-visible .tile-overlay { opacity: 1; transform: none; }

.tile-overlay strong { display: block; font-weight: 600; font-size: var(--step-0); }
.tile-overlay span { font-size: 0.76rem; color: rgba(255,255,255,0.7); }

/* Touch devices never hover, so the caption is always visible there. */
@media (hover: none) {
  .tile-overlay { opacity: 1; transform: none; }
}

.tile-badge {
  position: absolute;
  top: 0.7rem; left: 0.7rem;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.15);
}

.empty-state {
  padding: 4rem 0;
  color: var(--fg-faint);
  text-align: center;
}

/* --- 9. Lightbox -------------------------------------------------------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  background: color-mix(in srgb, var(--bg-sunken) 96%, transparent);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.lightbox[open], .lightbox.is-open { display: grid; }

.lightbox-inner {
  display: grid;
  grid-template-columns: 1fr minmax(0, 22rem);
  height: 100%;
}

.lightbox-stage {
  position: relative;
  display: grid;
  place-items: center;
  padding: clamp(1rem, 3vw, 2.5rem);
  min-width: 0;
  min-height: 0;
}

.lightbox-stage img {
  max-width: 100%;
  max-height: calc(100svh - 2 * clamp(1rem, 3vw, 2.5rem));
  width: auto;
  object-fit: contain;
  border-radius: var(--radius);
  box-shadow: 0 30px 90px rgba(0,0,0,0.55);
  animation: lbIn 380ms var(--ease) both;
}

@keyframes lbIn {
  from { opacity: 0; transform: scale(0.97); }
  to   { opacity: 1; transform: none; }
}

.lightbox-side {
  border-left: 1px solid var(--line);
  padding: clamp(1.25rem, 2.5vw, 2.25rem);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
  min-height: 0;
}

.lightbox-side h2 {
  font-size: var(--step-1);
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.lightbox-side .lb-caption {
  color: var(--fg-muted);
  margin: 0.6rem 0 0;
  line-height: 1.7;
}

.lb-spec {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.55rem 1.25rem;
  font-size: var(--step--1);
  margin: 0;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.lb-spec dt { color: var(--fg-faint); letter-spacing: 0.06em; }
.lb-spec dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; }

.lb-nav {
  margin-top: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.lb-counter {
  font-size: var(--step--1);
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
}

.lb-arrows { display: flex; gap: 0.5rem; }

.lb-arrow {
  width: 42px; height: 42px;
  border-radius: 50%;
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  color: var(--fg-muted);
  transition: all 200ms var(--ease);
}
.lb-arrow:hover { border-color: var(--fg); color: var(--fg); }
.lb-arrow svg { width: 17px; height: 17px; }

.lb-close {
  position: absolute;
  top: clamp(0.75rem, 2vw, 1.5rem);
  right: clamp(0.75rem, 2vw, 1.5rem);
  z-index: 2;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--line);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--fg);
  transition: background 200ms var(--ease);
}
.lb-close:hover { background: var(--line-strong); }
.lb-close svg { width: 18px; height: 18px; }

/* --- 10. Page header (category / about) -------------------------------- */

.page-hero {
  padding-top: clamp(7rem, 16vh, 12rem);
  padding-bottom: clamp(1.5rem, 4vw, 3rem);
}

.page-hero h1 {
  font-size: var(--step-3);
  margin: 0.4rem 0 0;
  font-weight: 600;
  letter-spacing: -0.028em;
  line-height: 1.05;
}

.page-hero p {
  color: var(--fg-muted);
  max-width: 54ch;
  margin: 1rem 0 0;
  font-size: var(--step-1);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: var(--step--1);
  color: var(--fg-faint);
  letter-spacing: 0.06em;
}
.breadcrumb a:hover { color: var(--fg); }

/* --- 11. About ---------------------------------------------------------- */

.about-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  gap: clamp(2rem, 6vw, 5rem);
  align-items: start;
}

.about-prose p { color: var(--fg-muted); margin: 0 0 1.15rem; max-width: 62ch; }
.about-prose p:first-of-type { font-size: var(--step-1); color: var(--fg); }

.about-prose h2 {
  font-size: var(--step-1);
  margin: 2.5rem 0 1rem;
  font-weight: 600;
}

.fact-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--line);
}

.fact-list li {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
  font-size: var(--step--1);
}

.fact-list dt, .fact-list .fkey { color: var(--fg-faint); }
.fact-list .fval { color: var(--fg); text-align: right; }

.kit-list { list-style: none; margin: 0; padding: 0; }
.kit-list li {
  padding: 0.6rem 0 0.6rem 1.4rem;
  border-bottom: 1px solid var(--line);
  position: relative;
  color: var(--fg-muted);
  font-size: var(--step--1);
}
.kit-list li::before {
  content: "";
  position: absolute;
  left: 0; top: 50%;
  width: 6px; height: 1px;
  background: var(--accent);
}

/* --- 12. Contact / footer ---------------------------------------------- */

.contact-band {
  border-top: 1px solid var(--line);
  padding-block: clamp(3rem, 8vw, 6rem);
}

.contact-band h2 {
  font-size: var(--step-3);
  margin: 0.4rem 0 1rem;
  font-weight: 600;
  letter-spacing: -0.028em;
  max-width: 24ch;
  line-height: 1.08;
}

.mailto {
  display: inline-block;
  font-size: var(--step-1);
  border-bottom: 1px solid var(--line-strong);
  padding-bottom: 0.15rem;
  transition: color 200ms var(--ease), border-color 200ms var(--ease);
}
.mailto:hover { color: var(--accent); border-color: var(--accent); }

.site-footer {
  border-top: 1px solid var(--line);
  padding-block: 2rem 2.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: var(--step--1);
  color: var(--fg-faint);
}

.site-footer nav { display: flex; gap: 1.25rem; }
.site-footer a:hover { color: var(--fg); }

/* Copyright and filing number share one row so the footer's space-between
   still reads as two groups; they wrap together on narrow screens. */
.site-footer .footer-legal {
  display: flex;
  align-items: center;
  gap: 0.4rem 1.1rem;
  flex-wrap: wrap;
}
.site-footer .footer-legal a { white-space: nowrap; }

/* --- 13. Reveal on scroll ---------------------------------------------- */

.reveal {
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 900ms var(--ease), transform 900ms var(--ease);
  will-change: opacity, transform;
}
.reveal.is-visible { opacity: 1; transform: none; }

/* --- 14. Responsive ----------------------------------------------------- */

@media (max-width: 1100px) {
  .masonry { columns: 2; }
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .lightbox-inner { grid-template-columns: 1fr; }
  .lightbox-side {
    border-left: 0;
    border-top: 1px solid var(--line);
    max-height: 42svh;
  }
  .lightbox-stage img { max-height: 48svh; }
}

@media (max-width: 860px) {
  .about-grid { grid-template-columns: 1fr; }
  .scroll-cue { display: none; }

  .nav-toggle {
    display: grid;
    place-items: center;
    width: 40px; height: 40px;
    border-radius: 50%;
    color: var(--fg);
  }

  .nav {
    position: fixed;
    /* Start below the header so the brand and close control are never covered. */
    inset: var(--header-h, 3.9rem) 0 0 auto;
    width: min(78vw, 20rem);
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.5rem;
    padding: 4rem 2rem;
    background: var(--bg-elevated);
    border-left: 1px solid var(--line);
    transform: translateX(100%);
    transition: transform 420ms var(--ease);
    z-index: 120;
    /* Keeps the brand and toggle above the drawer surface. */
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.45);
  }

  .nav.is-open { transform: none; }
  .nav a { font-size: var(--step-1); padding-block: 0.5rem; }

  /* Dim the page behind the open drawer. Kept below the drawer's own
     stacking context and stops short of the header band so the brand and
     close button stay fully visible. */
  .nav.is-open::before {
    content: "";
    position: fixed;
    top: 0;
    bottom: 0;
    right: 100%;
    width: 100vw;
    background: rgba(0, 0, 0, 0.5);
    z-index: -1;
  }

  /* Header sits above the drawer so the close affordance stays reachable. */
  .site-header { z-index: 130; }

  .nav-toggle svg { transition: transform 300ms var(--ease); }
  .nav-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
}

@media (max-width: 620px) {
  .masonry { columns: 1; }
  .cat-grid { grid-template-columns: 1fr; }
  .cat-card { aspect-ratio: 4 / 3; }
  .site-header { padding-block: 0.7rem; }
  .hero-inner { max-width: none; }
}

/* --- 15. Reduced motion / print ---------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .tile img { opacity: 1; }
}

@media print {
  .site-header, .scroll-cue, .lightbox, .filter-bar { display: none !important; }
  body { background: #fff; color: #000; }
}
