/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --font-display: 'Barlow Condensed', sans-serif;
  --font-body: 'Libre Baskerville', serif;
  --font-mono: 'IBM Plex Mono', monospace;
  --transition: 220ms ease;
  --nav-height: 56px;
}

[data-theme="light"] {
  --bg: #EDEAE4;
  --bg-raised: #E4E0D9;
  --border: #C8C3BA;
  --text: #1A1714;
  --text-muted: #5C5750;
  --text-faint: #9C978F;
  --hero-overlay: rgba(20,17,14,0.28);
  --lightbox-bg: rgba(20,17,14,0.96);
}

[data-theme="dark"] {
  --bg: #151210;
  --bg-raised: #1E1A17;
  --border: #332E2A;
  --text: #F2EDE6;
  --text-muted: #A09890;
  --text-faint: #635D57;
  --hero-overlay: rgba(0,0,0,0.45);
  --lightbox-bg: rgba(0,0,0,0.98);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  transition: background 300ms ease, color 300ms ease;
  min-height: 100vh;
  overflow-x: hidden;
}

img { display: block; max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; color: inherit; }

/* ── Header ─────────────────────────────────────────────── */
.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 200;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 300ms ease, border-color 300ms ease;
}
.site-header.scrolled {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.site-name {
  color: var(--text-faint);
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.site-name:hover { color: var(--text-muted); }

.header-right { display: flex; align-items: center; }

.theme-btn {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 2px;
  color: var(--text-muted);
  font-size: 18px;
  transition: background var(--transition), color var(--transition);
}
.theme-btn:hover { background: var(--bg-raised); color: var(--text); }
.theme-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

/* ── Hero ───────────────────────────────────────────────── */
.site-hero {
  height: 50vh;
  min-height: 320px;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  background: var(--bg-raised);
}

.hero-img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity 800ms ease;
}
.hero-img.loaded { opacity: 1; }

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    transparent 30%,
    var(--hero-overlay) 70%,
    rgba(0,0,0,0.62) 100%
  );
}

.hero-content {
  position: relative;
  z-index: 2;
  padding: 48px 32px;
  width: 100%;
}

.hero-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  margin-bottom: 12px;
}

.hero-title {
  font-family: var(--font-display);
  font-size: clamp(56px, 10vw, 100px);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: #fff;
  max-width: 900px;
}

/* ── Genre Nav — auto-hide ──────────────────────────────── */
.genre-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 32px;
  display: flex;
  position: sticky;
  top: 0;
  z-index: 100;
  overflow-x: auto;
  scrollbar-width: none;
  /* Slide transition */
  transform: translateY(0);
  transition: transform 300ms ease, box-shadow 300ms ease;
}
.genre-nav::-webkit-scrollbar { display: none; }

/* Hidden state — slides up out of view */
.genre-nav.nav-hidden {
  transform: translateY(-100%);
  box-shadow: none;
}

.genre-tab {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 18px 24px;
  border-bottom: 3px solid transparent;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.genre-tab:hover { color: var(--text-muted); }
.genre-tab.active { color: var(--text); border-bottom-color: var(--text); }
.genre-tab:focus-visible { outline: 2px solid var(--text); outline-offset: -3px; }

/* ── Panels ─────────────────────────────────────────────── */
.genre-panel { display: none; }
.genre-panel.active { display: block; }

.about-panel { display: none; }
.about-panel.active { display: block; }

/* ── Photo Grid ─────────────────────────────────────────── */
.photo-grid {
  padding: 24px 32px 32px;
  columns: 3;
  column-gap: 12px;
}
@media (max-width: 1100px) { .photo-grid { columns: 2; } }
@media (max-width: 640px)  { .photo-grid { columns: 1; padding: 16px; } }

.photo-item {
  break-inside: avoid;
  margin-bottom: 12px;
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-raised);
  display: block;
}

.photo-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 500ms cubic-bezier(0.25,0.46,0.45,0.94), opacity 300ms ease;
  opacity: 0;
}
.photo-item img.loaded { opacity: 1; }
.photo-item:hover img { transform: scale(1.04); }

.photo-meta {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 32px 14px 14px;
  background: linear-gradient(to top, rgba(0,0,0,0.65) 0%, transparent 100%);
  opacity: 0;
  transition: opacity var(--transition);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
}
.photo-item:hover .photo-meta { opacity: 1; }

.photo-title {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
}

.photo-expand {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.5);
}

/* ── Loading / Empty / Error ────────────────────────────── */
.grid-loading { padding: 80px 32px; text-align: center; }

.loading-label {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.loading-dots span {
  display: inline-block;
  width: 4px; height: 4px;
  background: var(--text-faint);
  border-radius: 50%;
  margin: 0 3px;
  animation: pulse 1.2s ease-in-out infinite;
}
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

.empty-state { padding: 80px 32px; text-align: center; color: var(--text-faint); }
.empty-state p { font-size: 13px; margin-top: 8px; font-family: var(--font-mono); }

.error-state { padding: 80px 32px; text-align: center; }
.error-state p {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 8px;
  letter-spacing: 0.06em;
}

/* ── Projects ───────────────────────────────────────────── */
.project-grid {
  padding: 24px 32px 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
@media (max-width: 1100px) { .project-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .project-grid { grid-template-columns: 1fr; padding: 16px; } }

.project-card {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  background: var(--bg-raised);
  aspect-ratio: 4 / 3;
}

.project-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 500ms cubic-bezier(0.25,0.46,0.45,0.94), opacity 300ms ease;
  opacity: 0;
}
.project-card img.loaded { opacity: 1; }
.project-card:hover img { transform: scale(1.04); }

.project-card-info {
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 55%);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 20px 18px;
}

.project-card-title {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  line-height: 1;
  margin-bottom: 6px;
}

.project-card-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.55);
  letter-spacing: 0.08em;
}

/* Project gallery drill-down header */
.project-gallery-header {
  padding: 24px 32px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
}

.project-back {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  transition: color var(--transition);
  min-height: 44px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.project-back:hover { color: var(--text); }
.project-back:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.project-gallery-title {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 48px);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text);
  line-height: 1;
}

/* ── About ──────────────────────────────────────────────── */
.about-body-wrap {
  padding: 48px 32px 80px;
  max-width: 640px;
}

.about-body {
  font-size: 20px;
  line-height: 1.9;
  color: var(--text-muted);
  font-style: italic;
}
.about-body + .about-body { margin-top: 3em; }

/* ── Lightbox ───────────────────────────────────────────── */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: var(--lightbox-bg);
  align-items: center;
  justify-content: center;
}
.lightbox.open { display: flex; }

.lb-img-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: 96vw;
  max-height: 92vh;
}

.lb-img-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 92vw;
  max-height: 80vh;
  min-width: 120px;
  min-height: 80px;
}

.lb-img {
  max-width: 92vw;
  max-height: 80vh;
  object-fit: contain;
  display: block;
  opacity: 0;
  transition: opacity 400ms ease;
}
.lb-img.loaded { opacity: 1; }

.lb-loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 300ms ease;
  pointer-events: none;
}
.lb-loading.hidden { opacity: 0; }

.lb-spinner {
  width: 24px; height: 24px;
  border: 2px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.6);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.lb-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  gap: 24px;
  padding: 0 4px;
}

.lb-caption {
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.55);
  flex: 1;
}

.lb-size-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(255,255,255,0.22);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.lb-counter {
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(255,255,255,0.28);
  white-space: nowrap;
}

.lb-close {
  position: fixed;
  top: 20px; right: 20px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.45);
  font-size: 18px;
  border: 1px solid rgba(255,255,255,0.15);
  transition: color var(--transition), border-color var(--transition);
}
.lb-close:hover { color: #fff; border-color: rgba(255,255,255,0.4); }
.lb-close:focus-visible { outline: 1px solid rgba(255,255,255,0.6); }

.lb-nav {
  position: fixed;
  top: 50%; transform: translateY(-50%);
  width: 44px; height: 64px;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.35);
  font-size: 26px;
  border: 1px solid rgba(255,255,255,0.1);
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}
.lb-prev { left: 20px; }
.lb-next { right: 20px; }
.lb-nav:hover { color: #fff; border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.05); }
.lb-nav:disabled { opacity: 0.12; pointer-events: none; }
.lb-nav:focus-visible { outline: 1px solid rgba(255,255,255,0.5); }

/* ── Footer ─────────────────────────────────────────────── */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.footer-name {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.footer-copy {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.08em;
}

/* ── Accessibility ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
  }
}
