:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #8a8a8a;
  --line: #e6e6e6;
  --frame-shadow: 0 1px 3px rgba(0,0,0,.08), 0 8px 24px rgba(0,0,0,.06);
  --row: 320px;        /* height of a row in the photo grids */
  --gap: 20px;
  --side: 40px;
  --panel: #f1ece5;
  --ease-out: cubic-bezier(.2,.8,.2,1);
}
[data-theme="dark"] {
  --bg: #000000;
  --fg: #f2f2f2;
  --muted: #7a7a7a;
  --line: #222222;
  --frame-shadow: none;
  --panel: #151413;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { background: var(--bg); color: var(--fg); }
body {
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 14px; line-height: 1.5; letter-spacing: .01em;
  min-height: 100vh; display: flex; flex-direction: column;
  transition: background .3s ease, color .3s ease;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
img { display: block; }

/* photos arrive soft and sharpen once loaded */
img.bl { filter: blur(12px); opacity: .35; transition: filter .8s ease, opacity .8s ease; }
img.bl.in { filter: none; opacity: 1; }

/* ---------- header ---------- */
header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 28px var(--side);
}
.name {
  font-family: "Homemade Apple", cursive;
  font-size: 30px; line-height: 1.2; padding-top: 8px;
}
nav { display: flex; gap: 28px; align-items: center; }
nav a { color: var(--muted); transition: color .2s; }
nav a:hover, nav a.active { color: var(--fg); }
.toggle {
  width: 12px; height: 12px; border-radius: 50%;
  border: 1px solid var(--fg);
  background: linear-gradient(90deg, var(--fg) 50%, transparent 50%);
}

main { flex: 1; padding: 24px var(--side) 80px; }
footer { padding: 28px var(--side); font-size: 12px; color: var(--muted); }

/* ---------- home: single portrait ---------- */
.home { display: flex; justify-content: center; align-items: center; min-height: 100%; }
.home img { height: auto; width: auto; max-height: min(74vh, 860px); max-width: 100%; box-shadow: var(--frame-shadow); }

/* ---------- home: turning ring of portraits ---------- */
.ring-wrap {
  position: relative; height: min(76vh, 860px); margin-top: -8px;
  perspective: 1700px; perspective-origin: 50% 45%;
  cursor: grab; user-select: none; -webkit-user-select: none; touch-action: pan-y; outline: none;
}
.ring-wrap.grabbing { cursor: grabbing; }
.ring { position: absolute; inset: 0; transform-style: preserve-3d; }
.ring-card {
  position: absolute; left: 50%; top: 46%;
  width: min(30vw, 440px);
  will-change: transform, opacity;
}
.ring-card img { width: 100%; height: auto; box-shadow: var(--frame-shadow); pointer-events: none; -webkit-user-drag: none; }

/* ---------- About: panel sliding down from the top ---------- */
.about-panel {
  position: fixed; left: 0; right: 0; top: 0; z-index: 20;
  height: min(64vh, 600px);
  background: var(--panel); color: var(--fg);
  transform: translateY(-101%);
  transition: transform .9s cubic-bezier(.7,0,.2,1), background .3s ease;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.about-open .about-panel { transform: none; }
.about-inner {
  display: grid; grid-template-columns: minmax(0, 620px) 1fr; gap: 40px; align-items: end;
  padding: 0 var(--side) 48px;
}
.about-bio p { font-size: clamp(20px, 2.1vw, 28px); line-height: 1.4; letter-spacing: -.005em; margin-bottom: .6em; }
.about-contact { justify-self: end; text-align: right; }
.about-contact a { border-bottom: 1px solid var(--muted); }
.about-panel .reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .6s var(--ease-out); }
.about-open .about-panel .reveal { opacity: 1; transform: none; transition-delay: calc(.55s + var(--d, 0ms)); }
.about-close {
  position: absolute; top: 20px; right: 24px; width: 44px; height: 44px;
  font-size: 30px; font-weight: 200; color: var(--muted); transition: color .2s;
}
.about-close:hover { color: var(--fg); }
.about-backdrop {
  position: fixed; inset: 0; z-index: 19; background: rgba(0,0,0,.28);
  opacity: 0; pointer-events: none; transition: opacity .6s ease;
}
.about-open .about-backdrop { opacity: 1; pointer-events: auto; }

/* ---------- sub navigation (projects / categories) ---------- */
.subnav {
  display: flex; flex-wrap: wrap; gap: 8px 24px;
  margin-bottom: 40px; color: var(--muted);
}
.subnav a:hover, .subnav a.active { color: var(--fg); }
.subnav .count { font-size: 11px; margin-left: 4px; vertical-align: super; }

.group-title { font-size: 14px; font-weight: 500; margin-bottom: 24px; }

/* ---------- justified grid: photos keep their real shape ---------- */
.grid { display: flex; flex-wrap: wrap; gap: var(--gap); }
.grid::after { content: ""; flex-grow: 999999; }
.item {
  position: relative;
  flex-grow: calc(var(--ar) * 100);
  flex-basis: calc(var(--ar) * var(--row));
  cursor: zoom-in;
}
.item img { width: 100%; height: auto; background: var(--line); }
.polaroid .item img { box-shadow: var(--frame-shadow); }

/* Polaroids: uniform grid, every frame the same width, rows lined up */
.polaroid .grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  align-items: start;
}
.polaroid .grid::after { display: none; }

.hover-title {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 28px 14px 12px;
  font-size: 12px; color: #fff;
  background: linear-gradient(transparent, rgba(0,0,0,.45));
  opacity: 0; transition: opacity .25s;
  pointer-events: none;
}
.item:hover .hover-title { opacity: 1; }

/* section index: one cover per project */
.cover { cursor: pointer; }
.cover .label { margin-top: 10px; color: var(--muted); transition: color .2s; }
.cover:hover .label { color: var(--fg); }

.empty { color: var(--muted); }

/* ---------- viewer: large photo + filmstrip + progress line ---------- */
.lightbox {
  position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  display: flex; flex-direction: column;
}
.lightbox[hidden] { display: none; }
.lb-stage {
  flex: 1; min-height: 0; position: relative;
  display: flex; align-items: center; justify-content: center;
  padding: 64px 96px 16px;
}
.lb-stage img {
  max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  transition: filter .6s ease, transform .6s ease;
}
.lb-stage img.soft { filter: blur(14px); transform: scale(1.01); }
.lb-meta {
  display: flex; justify-content: space-between; gap: 16px;
  padding: 4px var(--side) 14px; font-size: 12px; color: var(--muted); min-height: 36px;
}
#lb-title { color: var(--fg); }
.lb-strip {
  display: flex; gap: 10px; overflow-x: auto; scroll-behavior: smooth;
  padding: 0 var(--side) 18px; scrollbar-width: none;
}
.lb-strip::-webkit-scrollbar { display: none; }
.lb-strip button { flex: none; height: 64px; padding: 0; opacity: .35; transition: opacity .25s; }
.lb-strip button:hover { opacity: .75; }
.lb-strip button.on { opacity: 1; }
.lb-strip img { height: 100%; width: auto; }
.lb-progress { height: 2px; background: var(--line); }
#lb-bar { height: 100%; width: 0; background: var(--fg); transition: width .45s ease; }
.lightbox.single .lb-strip, .lightbox.single .lb-progress, .lightbox.single .lb-arrow { display: none; }

.lb-arrow, .lb-close {
  position: absolute; color: var(--muted); transition: color .2s;
  font-size: 34px; font-weight: 200; line-height: 1;
}
.lb-arrow:hover, .lb-close:hover { color: var(--fg); }
.lb-arrow { top: 64px; bottom: 0; width: 88px; }
.lb-prev { left: 0; }
.lb-next { right: 0; }
.lb-close { top: 16px; right: 24px; font-size: 30px; z-index: 2; width: 44px; height: 44px; }

@media (prefers-reduced-motion: reduce) {
  img.bl, .lb-stage img.soft { filter: none; opacity: 1; transform: none; }
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- phones ---------- */
@media (max-width: 640px) {
  :root { --row: 170px; --gap: 10px; --side: 20px; }
  header { flex-direction: column; gap: 12px; padding: 20px var(--side); }
  .name { font-size: 26px; }
  nav { gap: 22px; }
  main { padding-top: 16px; }
  .home img { width: 100%; max-height: none; }
  .ring-wrap { height: 72vh; }
  .ring-card { width: 62vw; top: 44%; }
  .about-panel { height: auto; min-height: 70vh; }
  .about-inner { grid-template-columns: 1fr; gap: 24px; padding-bottom: 36px; }
  .about-contact { justify-self: start; text-align: left; }
  footer { text-align: center; }
  .subnav { margin-bottom: 28px; gap: 6px 18px; }
  .hover-title { display: none; }
  .polaroid .grid { grid-template-columns: repeat(2, 1fr); }
  .lb-stage { padding: 64px 12px 12px; }
  .lb-arrow { display: none; }
  .lb-strip button { height: 52px; }
}
