:root {
  --bg: #fafaf8;
  --surface: #f0efeb;
  --fg: #1b1b1a;
  --muted: #6d6b66;
  --line: #e2e0da;
  --accent: #b4532a;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 4vw, 48px);
  --max: 1440px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #121211;
    --surface: #1c1c1a;
    --fg: #ecebe7;
    --muted: #9a978f;
    --line: #2b2a27;
    --accent: #e08a5f;
    color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #121211;
  --surface: #1c1c1a;
  --fg: #ecebe7;
  --muted: #9a978f;
  --line: #2b2a27;
  --accent: #e08a5f;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 16px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s, color .2s;
}
img { display: block; max-width: 100%; height: auto; }
a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
h1, h2 { font-weight: 500; line-height: 1.05; margin: 0 0 .4em; text-wrap: balance; }
h1 { font-size: clamp(2.2rem, 5.5vw, 4rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.3rem, 2.4vw, 1.75rem); letter-spacing: -.02em; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -9999px; }
.skip:focus { left: var(--gutter); top: 8px; background: var(--bg); padding: 8px 12px; z-index: 10; }

/* Header / footer */
.site-header, main, .site-footer { max-width: var(--max); margin-inline: auto; padding-inline: var(--gutter); }
.site-header {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 24px; padding-block: 24px;
}
.brand { font-size: 1.05rem; font-weight: 600; letter-spacing: -.01em; text-decoration: none; line-height: 1; }
.site-nav { display: flex; align-items: center; gap: 4px 22px; flex-wrap: wrap; font-size: .95rem; }
.site-nav a { text-decoration: none; color: var(--muted); padding-block: 4px; }
.site-nav a:hover, .site-nav a[aria-current], .site-nav a.active { color: var(--fg); }
.site-nav a[aria-current], .site-nav a.active { border-bottom: 1px solid currentColor; }
.theme-toggle {
  display: grid; place-items: center; width: 36px; height: 36px; margin-left: 4px;
  border: 1px solid var(--line); border-radius: 50%; background: none; color: var(--fg); cursor: pointer;
}
.theme-toggle:hover { border-color: var(--fg); }
.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 24px;
  margin-top: 96px; padding-block: 32px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: .9rem;
}
.site-footer p { margin: 0; }

/* Home hero + filters */
.hero { padding-block: clamp(32px, 8vw, 96px) clamp(24px, 4vw, 48px); }
.hero h1 { font-size: clamp(2.75rem, 9vw, 7rem); letter-spacing: -.045em; margin-bottom: .15em; }
.tagline { font-size: clamp(1.1rem, 2vw, 1.4rem); color: var(--muted); margin: 0; }
.availability { margin-top: 20px; font-size: .95rem; }
.availability a, p.availability { text-decoration: none; }
.availability::before {
  content: ''; display: inline-block; width: 8px; height: 8px; margin-right: 10px;
  border-radius: 50%; background: #3f9b5c; vertical-align: 1px;
}
.page-head { padding-block: clamp(24px, 6vw, 64px) 16px; }
.filters {
  display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none;
  margin-bottom: 32px; padding-bottom: 4px;
}
.filters::-webkit-scrollbar { display: none; }
.filters a {
  flex: none; padding: 6px 14px; border: 1px solid var(--line); border-radius: 999px;
  text-decoration: none; font-size: .9rem; color: var(--muted); white-space: nowrap;
}
.filters a:hover { color: var(--fg); border-color: var(--fg); }
.filters a[aria-current] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

/* Masonry grid */
.grid { list-style: none; margin: 0; padding: 0; columns: 3 320px; column-gap: clamp(16px, 2.5vw, 32px); }
.card { break-inside: avoid; margin-bottom: clamp(24px, 3vw, 40px); }
/* With JS: row-ordered masonry (site.js sets each card's row span). */
.grid.masonry {
  columns: auto; display: grid; align-items: start; grid-auto-rows: 4px;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
}
.grid.masonry .card { margin-bottom: 0; }
.grid.masonry .card a { padding-bottom: clamp(24px, 3vw, 40px); }
.card a { display: block; text-decoration: none; }
.card-media { position: relative; display: block; overflow: hidden; background: var(--surface); }
.card-media img { width: 100%; transition: transform .5s cubic-bezier(.2, .7, .2, 1), opacity .3s; }
.card a:hover .card-media img { transform: scale(1.025); }
.yt-thumb { aspect-ratio: 16 / 9; object-fit: cover; }
.play {
  position: absolute; left: 14px; bottom: 14px; width: 44px; height: 44px; border-radius: 50%;
  background: rgb(0 0 0 / .55); backdrop-filter: blur(6px);
}
.play::after {
  content: ''; position: absolute; left: 17px; top: 13px;
  border-left: 14px solid #fff; border-top: 9px solid transparent; border-bottom: 9px solid transparent;
}
.card-title { display: block; margin-top: 12px; font-weight: 500; }
.card-meta { display: block; color: var(--muted); font-size: .88rem; }
.empty { color: var(--muted); }

/* Work page */
.work-head { padding-block: clamp(24px, 5vw, 56px) 24px; max-width: 900px; }
.eyebrow { margin: 0 0 12px; font-size: .85rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.eyebrow a { text-decoration: none; }
.meta { color: var(--muted); margin: 0; }
.work-media { margin-bottom: 40px; }
.work-image { display: block; cursor: zoom-in; }
.work-image img { width: auto; max-height: 85svh; margin-inline: auto; }
.video { position: relative; width: 100%; margin-inline: auto; background: #000; }
.video iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.prose { max-width: 68ch; }
.prose p { margin: 0 0 1em; }
.work-body { font-size: 1.05rem; }
.process { margin-top: 64px; padding-top: 40px; border-top: 1px solid var(--line); }
.process-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 45%), 1fr)); gap: 20px;
}
.process-grid a { display: block; cursor: zoom-in; background: var(--surface); }
.process-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; }
.process-grid p { margin: 8px 0 0; font-size: .88rem; color: var(--muted); }
.pager {
  display: flex; justify-content: space-between; gap: 24px;
  margin-top: 80px; padding-top: 24px; border-top: 1px solid var(--line);
}
.pager a { text-decoration: none; font-size: 1.15rem; font-weight: 500; letter-spacing: -.01em; line-height: 1.3; }
.pager a span { display: block; font: 400 .8rem/1.6 var(--sans); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.pager a[rel='next'] { text-align: right; margin-left: auto; }

/* About */
.about { display: grid; gap: clamp(24px, 5vw, 72px); padding-top: clamp(24px, 5vw, 56px); }
@media (min-width: 800px) { .about { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); align-items: start; } }
.portrait { margin: 0; }
.portrait img { width: 100%; }
.about h2 { margin-top: 1.4em; }

/* CV */
.cv section { margin-top: 48px; max-width: 900px; }
.cv-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.cv-list li { display: grid; grid-template-columns: 9rem 1fr; gap: 16px; padding-block: 14px; border-bottom: 1px solid var(--line); }
.cv-year { color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 560px) { .cv-list li { grid-template-columns: 1fr; gap: 2px; } }
.button {
  display: inline-block; padding: 10px 18px; border: 1px solid var(--fg); border-radius: 999px;
  text-decoration: none; font-size: .95rem;
}
.button:hover { background: var(--fg); color: var(--bg); }

/* Contact */
.contact { padding-top: clamp(24px, 5vw, 56px); }
.email { margin: 32px 0; font-size: clamp(1.4rem, 4.5vw, 2.6rem); font-weight: 500; letter-spacing: -.03em; line-height: 1.1; overflow-wrap: anywhere; }
.email a { text-decoration-thickness: 1px; }
.socials { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.socials a { display: inline-block; padding: 8px 16px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; }
.socials a:hover { border-color: var(--fg); color: var(--fg); }
.notfound { min-height: 40vh; }

/* Lightbox */
.lightbox {
  width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0;
  background: rgb(10 10 10 / .96); color: #eee; overflow: hidden;
}
.lightbox::backdrop { background: transparent; }
.lightbox figure { height: 100%; margin: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; grid-template-columns: minmax(0, 1fr); place-items: center; padding: 56px 64px 16px; }
.lightbox img { min-height: 0; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; user-select: none; touch-action: pan-y; }
.lightbox figcaption { padding-top: 12px; font-size: .9rem; color: #bbb; min-height: 1.6em; text-align: center; }
.lightbox button {
  position: absolute; background: none; border: 0; color: #eee; cursor: pointer;
  font: 300 2.2rem/1 var(--sans); width: 56px; height: 56px; display: grid; place-items: center;
}
.lightbox button:hover { color: #fff; }
.lb-close { top: 4px; right: 4px; }
.lb-prev { left: 4px; top: 50%; translate: 0 -50%; }
.lb-next { right: 4px; top: 50%; translate: 0 -50%; }
.lb-count { position: absolute; top: 18px; left: 20px; margin: 0; font-size: .85rem; color: #999; }
.lightbox.single .lb-prev, .lightbox.single .lb-next { display: none; }
@media (max-width: 640px) {
  .lightbox figure { padding: 56px 8px 16px; }
  .lb-prev, .lb-next { top: auto; bottom: 8px; translate: none; }
}

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