:root {
  --bg: #0a0a0a;
  --fg: #ececec;
  --muted: #8a8a8a;
  --line: #222;
  --tile: #161616;
  --gap: clamp(8px, 1.2vw, 16px);
  --pad: clamp(16px, 4vw, 48px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: clamp(17px, 1.35vw, 21px);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Intro ---------- */

.intro {
  padding: clamp(56px, 12vh, 140px) var(--pad) clamp(48px, 9vh, 110px);
  max-width: 1400px;
}

.intro h1 {
  margin: 0 0 1.4em;
  font-size: 1em;
  font-weight: 500;
  letter-spacing: -0.005em;
}

.intro h1 span { color: var(--muted); font-weight: 400; }

.bio {
  max-width: 34em;
}

.bio p { margin: 0 0 1em; }

.bio .lead {
  font-size: clamp(24px, 2.6vw, 38px);
  line-height: 1.22;
  letter-spacing: -0.02em;
  font-weight: 450;
  max-width: 22em;
  margin-bottom: 1.1em;
}

.bio a {
  text-decoration: underline;
  text-decoration-color: #555;
  text-underline-offset: 0.2em;
  text-decoration-thickness: 1px;
  transition: text-decoration-color 0.2s;
}

.bio a:hover { text-decoration-color: var(--fg); }

.bio .note { color: var(--muted); }

.contact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em 1.6em;
  margin-top: 2em;
  padding: 0;
  list-style: none;
}

.contact a {
  text-decoration: none;
  color: var(--muted);
  transition: color 0.2s;
}

.contact a:hover { color: var(--fg); }

/* ---------- Gallery ---------- */

.gallery {
  padding: 0 var(--pad);
}

/* Fallback without JS: plain CSS columns */
.grid {
  columns: 3;
  column-gap: var(--gap);
}

.grid > .tile { margin-bottom: var(--gap); break-inside: avoid; }

/* With JS: row-ordered masonry columns */
.grid.is-masonry {
  columns: auto;
  display: flex;
  gap: var(--gap);
  align-items: flex-start;
}

.grid .col {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.grid.is-masonry .tile { margin: 0; }

.tile {
  display: block;
  overflow: hidden;
  background: var(--tile);
  cursor: zoom-in;
  outline-offset: 3px;
}

.tile img {
  display: block;
  width: 100%;
  height: auto;
  opacity: 0;
  transform: scale(1.015);
  transition: opacity 0.6s ease, transform 0.8s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.tile img.loaded { opacity: 1; transform: none; }

@media (hover: hover) {
  .tile img.loaded:hover { transform: scale(1.02); }
}

@media (max-width: 900px) { .grid { columns: 2; } }
@media (max-width: 520px) { .grid { columns: 1; } }

/* ---------- Footer ---------- */

footer {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1em;
  padding: clamp(56px, 10vh, 120px) var(--pad) var(--pad);
  color: var(--muted);
  font-size: 0.8em;
}

footer a { text-decoration: none; }
footer a:hover { color: var(--fg); }

/* ---------- Lightbox ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(6, 6, 6, 0.96);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.lightbox.open {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.25s ease;
}

.lightbox img {
  max-width: calc(100vw - 2 * var(--pad));
  max-height: calc(100vh - 120px);
  max-height: calc(100dvh - 120px);
  object-fit: contain;
  user-select: none;
}

.lb-btn {
  position: absolute;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.85em;
  padding: 16px;
  cursor: pointer;
  transition: color 0.2s;
}

.lb-btn:hover, .lb-btn:focus-visible { color: var(--fg); }
.lb-close { top: 8px; right: 8px; }
.lb-prev { left: 4px; top: 50%; transform: translateY(-50%); font-size: 1.6em; }
.lb-next { right: 4px; top: 50%; transform: translateY(-50%); font-size: 1.6em; }

.lb-count {
  position: absolute;
  bottom: 20px;
  left: 0;
  right: 0;
  text-align: center;
  color: var(--muted);
  font-size: 0.8em;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .lb-prev, .lb-next { display: none; }
}

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