/* ---------- Tokens ---------- */
:root {
  --bg: #fff;
  --fg: #333;
  --muted: #777;
  --link: #3367b5;
  --line: #d5d5d5;
  --tile-bg: #f1f1f1;
  --gap: 10px;
  --radius: 4px;
  --max: 1120px;
  --pad: 16px;
  --font: Roboto, ui-sans-serif, system-ui, -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 400 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
img, video { display: block; max-width: 100%; }
[hidden] { display: none !important; }
a { color: var(--link); }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--link); outline-offset: 3px; }

/* ---------- Landing ---------- */
.home {
  min-height: 100vh; min-height: 100svh;
  display: grid; place-items: center; padding: var(--pad);
}
.home a { display: block; border-radius: 2px; }
.home img { width: 300px; height: 300px; }

/* ---------- Portfolio header ---------- */
.portfolio { max-width: calc(var(--max) + 2 * var(--pad)); margin: 0 auto; padding: 0 var(--pad) 60px; }
.portfolio-header { padding: 6px 0 0; }
.portfolio-header h1 { margin: 0; font-size: clamp(32px, 6vw, 48px); font-weight: 400; line-height: 1.3; color: #333; }
.contact { display: flex; flex-wrap: wrap; gap: 6px 28px; margin: 10px 0 0; padding: 0 0 0 4px; list-style: none; font-size: 14px; }
.contact li { display: flex; align-items: center; gap: 10px; }
.contact svg { width: 14px; height: 14px; fill: #333; flex: none; }
.portfolio-header hr { border: 0; border-top: 1px solid var(--line); margin: 14px 0 20px; }

/* ---------- Masonry grid ---------- */
.grid { display: flex; gap: var(--gap); align-items: flex-start; }
.col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }
.tile {
  position: relative; display: block; overflow: hidden; border-radius: var(--radius);
  background: var(--tile-bg); cursor: zoom-in;
}
.tile figure > i { display: block; padding-bottom: calc(100% / var(--ar)); }
.tile img, .tile video {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
  opacity: 0; transition: opacity .4s ease, transform .6s ease;
}
.tile .is-loaded { opacity: 1; }
.tile:hover img, .tile:hover video { transform: scale(1.03); }
.tile figcaption {
  position: absolute; inset: auto 0 0 0; padding: 30px 12px 10px;
  color: #fff; font-size: 14px; line-height: 1.35;
  background: linear-gradient(transparent, rgba(0,0,0,.6));
  opacity: 0; transform: translateY(6px); transition: opacity .25s, transform .25s;
  pointer-events: none;
}
.tile figcaption small { display: block; font-size: 12px; opacity: .8; }
.tile:hover figcaption, .tile:focus-visible figcaption { opacity: 1; transform: none; }
@media (hover: none) { .tile figcaption { display: none; } }

.empty { color: var(--muted); padding: 40px 0; }

/* ---------- Lightbox ---------- */
html.lb-open { overflow: hidden; }
.lightbox {
  position: fixed; inset: 0; width: 100%; height: 100%; max-width: none; max-height: none;
  margin: 0; padding: 0; border: 0; background: #0b0b0b; color: #eee;
}
.lightbox::backdrop { background: #0b0b0b; }
.lightbox[open] { display: grid; grid-template-columns: 1fr auto; animation: lb-in .2s ease; }
@keyframes lb-in { from { opacity: 0; } }

.lb-stage {
  position: relative; min-width: 0; min-height: 0; height: 100%;
  display: grid; place-items: center; padding: 64px 72px; overflow: hidden;
  touch-action: pan-y pinch-zoom;
}
.lb-stage img, .lb-stage video {
  grid-area: 1 / 1; max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain;
  user-select: none; -webkit-user-drag: none;
}
.lb-placeholder { filter: blur(14px); opacity: .5; }
.lb-full { opacity: 0; transition: opacity .3s ease; }
.lb-full.is-loaded { opacity: 1; }
.lb-spinner {
  grid-area: 1 / 1; width: 28px; height: 28px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.2); border-top-color: #fff; animation: spin .8s linear infinite;
}
.lb-stage.is-loaded .lb-spinner { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

.lb-btn {
  position: absolute; z-index: 2; display: grid; place-items: center;
  width: 44px; height: 44px; padding: 0; border: 0; border-radius: 50%;
  background: transparent; color: #eee; cursor: pointer; opacity: .75; transition: opacity .15s, background .15s;
}
.lb-btn:hover { opacity: 1; background: rgba(255,255,255,.08); }
.lb-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.lb-prev { left: 14px; top: 50%; translate: 0 -50%; }
.lb-next { right: 14px; top: 50%; translate: 0 -50%; }
.lb-close { right: 14px; top: 12px; }
.lb-info-btn { right: 64px; top: 12px; }
.lb-info-btn[aria-pressed="true"] { opacity: 1; background: rgba(255,255,255,.12); }
.lb-counter { position: absolute; left: 22px; top: 22px; font-size: 13px; color: #999; font-variant-numeric: tabular-nums; }
.lb-caption {
  position: absolute; left: 0; right: 0; bottom: 18px; margin: 0; text-align: center; font-size: 14px; color: #ddd;
  padding: 0 72px; pointer-events: none;
}
.lb-caption span { color: #999; }
.lightbox.show-info .lb-caption { display: none; }

.lb-info {
  display: none; width: min(360px, 34vw); height: 100%; overflow-y: auto;
  padding: 72px 28px 32px; background: #141414; border-left: 1px solid #222;
}
.lightbox.show-info .lb-info { display: block; }
.lb-info h2 { margin: 0 0 6px; font-size: 20px; font-weight: 500; line-height: 1.3; color: #fff; }
.lb-meta { margin: 0 0 18px; color: #999; font-size: 14px; }
.lb-desc { font-size: 15px; line-height: 1.65; color: #cfcfcf; }
.lb-desc p { margin: 0 0 1em; }

@media (max-width: 760px) {
  .lightbox[open] { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .lb-stage { padding: 60px 8px 64px; }
  .lb-prev, .lb-next { top: auto; bottom: 8px; translate: none; }
  .lb-prev { left: 6px; } .lb-next { right: 6px; }
  .lb-caption { padding: 0 60px; bottom: 20px; }
  .lb-info { width: auto; height: auto; max-height: 45vh; padding: 20px 20px 28px; border-left: 0; border-top: 1px solid #222; }
}

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

/* ---------- 404 ---------- */
.notfound { min-height: 100vh; display: grid; place-content: center; text-align: center; padding: var(--pad); }
.notfound img { width: 120px; height: 120px; margin: 0 auto 24px; }
.notfound h1 { font-weight: 400; font-size: 22px; margin: 0 0 8px; }
.notfound p { color: var(--muted); margin: 0; }
