:root {
  color-scheme: light;
  --bg: #fff;
  --fg: #111;
  --soft: #333;
  --muted: #767676;
  --line: #e7e7e7;
  --pad: clamp(20px, 3.2vw, 48px);
  --gap: clamp(6px, 0.8vw, 12px);
  --cols: 6;
  --font: "Helvetica Neue", Helvetica, Arial, system-ui, -apple-system, "Segoe UI", sans-serif;
}

/* dark theme: system setting by default, overridden by data-theme="light" / "dark" */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111;
    --fg: #f1f1f1;
    --soft: #cfcfcf;
    --muted: #8c8c8c;
    --line: #2b2b2b;
  }
  :root:not([data-theme="light"]) .brand img { filter: invert(1); }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111;
  --fg: #f1f1f1;
  --soft: #cfcfcf;
  --muted: #8c8c8c;
  --line: #2b2b2b;
}
:root[data-theme="dark"] .brand img { filter: invert(1); }

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scrollbar-gutter: stable; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.65 var(--font);
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main { flex: 1; width: 100%; max-width: 1920px; margin: 0 auto; padding: 0 var(--pad); }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--muted); }

p { margin: 0 0 1em; }
h1, h2 { margin: 0; font-weight: 500; letter-spacing: -0.01em; line-height: 1.25; }

img, video { display: block; max-width: 100%; height: auto; }

:focus-visible { outline: 2px solid var(--fg); outline-offset: 3px; }

/* ---------- header / footer ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px var(--pad);
  background: var(--bg);
}
.brand { display: block; line-height: 0; flex-shrink: 0; }
.brand img { height: 24px; width: auto; }
.site-header nav { display: flex; gap: clamp(18px, 3vw, 40px); }
.site-header nav a { text-decoration: none; color: var(--muted); transition: color .15s; }
.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: var(--fg); }

.site-footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 32px;
  padding: 80px var(--pad) 28px;
  color: var(--muted);
  font-size: 14px;
}
.site-footer .links { display: flex; flex-wrap: wrap; gap: 8px 28px; }
.site-footer a { text-decoration: none; }
.site-footer a:hover { color: var(--fg); }
.theme-toggle {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.theme-toggle:hover { color: var(--fg); }

/* ---------- home ---------- */
.home { padding: clamp(48px, 12vh, 160px) 0 0; max-width: 1000px; }
.home .lead {
  font-size: clamp(26px, 3.6vw, 52px);
  line-height: 1.18;
  letter-spacing: -0.025em;
  margin-bottom: clamp(32px, 5vw, 64px);
}
.home .intro { max-width: 38em; font-size: 17px; color: var(--soft); }

/* ---------- about ---------- */
.about { padding-top: clamp(32px, 6vh, 80px); max-width: 760px; }
.about .lead {
  font-size: clamp(22px, 2.4vw, 34px);
  line-height: 1.25;
  letter-spacing: -0.02em;
  margin-bottom: clamp(32px, 4vw, 56px);
}
.bio p { font-size: 17px; margin-bottom: 1.2em; }

.cv { margin-top: clamp(56px, 8vw, 112px); }
.cv h2 {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
  margin: 56px 0 0;
}
.cv h2:first-child { margin-top: 0; }
.cv ul { list-style: none; margin: 0; padding: 0; }
.cv li {
  display: grid;
  grid-template-columns: minmax(64px, 140px) 1fr;
  gap: 16px;
  padding: 13px 0;
  border-bottom: 1px solid var(--line);
}
.cv ul.plain li { display: block; padding: 12px 0; }
.cv p { margin: 20px 0 0; }
.cv .label { color: var(--muted); margin-bottom: 4px; }
.cv p:not(.label) + ul { margin-top: 28px; }
.cv .y { color: var(--muted); font-variant-numeric: tabular-nums; }
.cv .t { font-weight: 500; }
.cv .v { color: var(--soft); }
.cv .t + .v { margin-left: .5em; }
.cv .d { display: block; color: var(--muted); font-size: 15px; margin-top: 4px; }

/* ---------- sections: projects / commercial / archive ---------- */
.gallery { padding-top: clamp(16px, 3vh, 40px); }
.section { margin-bottom: clamp(88px, 11vw, 180px); }
.section-head { margin-bottom: clamp(28px, 3.4vw, 52px); }
.section-head h2 { font-size: clamp(20px, 1.8vw, 26px); }

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  gap: var(--gap);
}
.ph {
  display: block;
  aspect-ratio: 1;
  cursor: zoom-in;
  overflow: hidden;
}
.ph img,
.ph video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center top;
  transition: opacity .2s;
}
.ph:hover img,
.ph:hover video { opacity: .8; }

/* works with a name next to them (Commercial) */
.work { margin: 0; }
.work figcaption {
  font-size: 14px;
  line-height: 1.4;
  color: var(--fg);
}
.work .ph { aspect-ratio: auto; }
.work .ph img,
.work .ph video { height: auto; object-fit: initial; }

/* masonry: columns of works at natural proportions, name below each image */
.masonry {
  column-count: var(--cols);
  column-gap: clamp(14px, 1.8vw, 28px);
}
.masonry .work {
  break-inside: avoid;
  margin-bottom: clamp(20px, 2.4vw, 36px);
}
.masonry .work figcaption { margin-top: 10px; }
/* with JS: real columns filled left to right */
.masonry.is-ready {
  display: flex;
  column-count: auto;
  align-items: flex-start;
  gap: clamp(14px, 1.8vw, 28px);
}
.masonry-col { flex: 1 1 0; min-width: 0; }

.page-commercial { --cols: 4; }

/* a project that uses a 4-column grid, with an optional video spanning 2 columns
   (its row span is set inline; the other works flow into the columns beside it) */
.grid.cols-4 { --cols: 4; }
.ph.feature { aspect-ratio: auto; }

/* Projects: works keep their own proportions (width 100%, height auto);
   each row is as tall as its tallest work */
.page-projects .grid { align-items: start; }
.page-projects .grid .ph { aspect-ratio: auto; }
.page-projects .grid .ph img,
.page-projects .grid .ph video { height: auto; object-fit: initial; }
.page-archive { --cols: 4; }

/* a project with a single image is shown large, like a hero */
.grid.single { grid-template-columns: 1fr; }
.grid.single .ph { aspect-ratio: auto; }
.grid.single .ph img { height: auto; }

/* ---------- lightbox ---------- */
.lb {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  background: var(--bg);
}
.lb.open { display: block; }
.lb-stage {
  position: absolute;
  inset: 64px 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-stage img,
.lb-stage video {
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.lb-stage [hidden] { display: none; }
.lb-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  z-index: 2;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  height: 64px;
  padding: 22px var(--pad) 0;
  font-size: 14px;
  line-height: 1.4;
  color: var(--muted);
  pointer-events: none;
}
.lb-bar > * { pointer-events: auto; }
.lb-caption { color: var(--fg); }
.lb button {
  font: inherit;
  color: var(--fg);
  background: none;
  border: 0;
  cursor: pointer;
  padding: 8px;
  margin: -8px;
}
.lb button:hover { color: var(--muted); }
.lb-nav {
  position: absolute;
  top: 64px; bottom: 0;
  width: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lb-nav.prev { left: 0; }
.lb-nav.next { right: 0; }
.lb-nav svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.4; }
.lb-nav { margin: 0 !important; padding: 0 !important; }
.lb.single .lb-nav { display: none; }

body.lb-lock { overflow: hidden; }

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
  :root { --cols: 4; }
}

@media (max-width: 800px) {
  :root, .page-commercial, .page-archive, .grid.cols-4 { --cols: 3; }
  .site-header { padding-top: 14px; padding-bottom: 14px; }
  .cv li { grid-template-columns: 72px 1fr; gap: 12px; }
  .brand img { height: 20px; }
  .lb-stage { inset: 56px 0 56px; }
  .lb-bar { height: 56px; }
  .lb-nav { top: auto; bottom: 0; height: 56px; width: 25%; }
  .lb-nav.prev { left: 0; }
  .lb-nav.next { right: 0; }
}

@media (max-width: 560px) {
  :root, .page-commercial, .page-archive, .grid.cols-4 { --cols: 2; }
  .site-header { flex-direction: column; align-items: flex-start; gap: 10px; }
  .site-header nav { gap: 20px; font-size: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; }
}
