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

/* ─── Tokens ─────────────────────────────────────────────── */
:root {
  --serif: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --sans:  'Helvetica Neue', Helvetica, Arial, sans-serif;
  --sidebar-w: 220px;
  --bg:     #ffffff;
  --ink:    #111111;
  --muted:  #999999;
  --border: #e8e8e8;
  --pad-x:  64px;
  --pad-y:  60px;
}

html, body { height: 100%; }

body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--bg);
  display: flex;
  min-height: 100vh;
}

/* ─── Page transition overlay ────────────────────────────── */
#page-overlay {
  position: fixed;
  inset: 0;
  background: #ffffff;
  z-index: 9999;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.2s ease;
}
#page-overlay.clear { opacity: 0; }

/* ─── Sidebar ─────────────────────────────────────────────── */
#sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  padding: 48px 32px 40px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10000;
  background: var(--bg);
}

.sidebar-name {
  font-family: var(--sans);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #000;
  text-decoration: none;
  display: block;
  margin-bottom: 52px;
}

#main-nav {
  flex: 1;
}

.nav-group {
  margin-bottom: 28px;
}

.nav-group-label {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 14px;
  display: block;
}

.nav-group-children {
  display: flex;
  flex-direction: column;
}

.nav-link {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  padding: 4px 0;
  letter-spacing: 0.01em;
  line-height: 1.4;
  transition: color 0.15s;
}
.nav-link::after {
  content: attr(data-text);
  display: block;
  font-weight: 600;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}
.nav-link:hover { color: var(--muted); }
.nav-link.active {
  font-weight: 600;
  color: var(--ink);
}

.nav-solo {
  font-size: 0.76rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  display: block;
  padding: 4px 0;
  letter-spacing: 0.01em;
  margin-bottom: 6px;
  transition: color 0.15s;
}
.nav-solo::after {
  content: attr(data-text);
  display: block;
  font-weight: 600;
  height: 0;
  overflow: hidden;
  visibility: hidden;
}
.nav-solo:hover { color: var(--muted); }
.nav-solo.active { font-weight: 600; }

.sidebar-copyright {
  font-size: 0.62rem;
  color: var(--muted);
  letter-spacing: 0.07em;
  margin-top: auto;
  padding-top: 28px;
}

/* ─── Mobile toggle ──────────────────────────────────────── */
#mobile-toggle {
  display: none;
  background: none;
  border: none;
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  cursor: pointer;
  padding: 0;
  margin-bottom: 20px;
}

/* ─── Content ────────────────────────────────────────────── */
#content {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: var(--pad-y) var(--pad-x);
}

/* ─── Home ───────────────────────────────────────────────── */
#content.home {
  padding: var(--pad-y) var(--pad-x);
}
.home-img {
  display: block;
  width: auto;
  max-width: 52%;
  height: auto;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.home-img.loaded { opacity: 1; }

/* ─── Section label ──────────────────────────────────────── */
.section-label {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 28px;
}

/* ─── Commission caption ─────────────────────────────────── */
body[data-page="commissions"] .section-label,
body[data-page="work"] .section-label {
  color: var(--ink);
}
body[data-page="commissions"] .section-label {
  margin-bottom: 6px;
}
.commission-caption {
  margin-bottom: 28px;
}
.commission-caption-meta {
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.6;
}

/* ─── Grid ───────────────────────────────────────────────── */
body { overflow-x: hidden; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 28px 24px;
  transition: opacity 0.2s ease;
}
.grid.fading { opacity: 0; }

.grid-item {
  cursor: pointer;
  display: flex;
  flex-direction: column;
}
.grid-item-img {
  width: 100%;
  height: 250px;
  object-fit: contain;
  background: var(--bg);
  display: block;
  opacity: 0;
  transition: opacity 0.35s ease;
}
.grid-item-img.loaded { opacity: 1; }
.grid-item:hover .grid-item-img.loaded { opacity: 0.65; }

/* ─── Viewer ─────────────────────────────────────────────── */
#viewer {
  position: fixed;
  inset: -1px;
  background: rgba(8, 8, 8, 0.95);
  z-index: 500;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
#viewer.open { display: flex; }

#viewer-img-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 52px 8px;
  min-height: 0;
  overflow: hidden;
}
#viewer-img {
  max-width: 100%;
  max-height: 75vh;
  object-fit: contain;
  opacity: 0;
  transition: opacity 0.28s ease;
}
#viewer-img.visible { opacity: 1; }

#viewer-caption {
  flex-shrink: 0;
  text-align: center;
  padding: 20px 80px 48px;
}
#viewer-title {
  font-family: var(--sans);
  font-style: normal;
  font-weight: 400;
  font-size: 0.85rem;
  color: rgba(255,255,255,0.88);
  margin-bottom: 8px;
  line-height: 1.3;
  letter-spacing: 0.03em;
}
#viewer-title em {
  font-style: italic;
}
#viewer-meta {
  font-family: var(--sans);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.07em;
  color: rgba(255,255,255,0.55);
  line-height: 2;
}

.viewer-arrow {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 28px 24px;
  z-index: 501;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.viewer-arrow::before {
  content: '';
  display: block;
  width: 11px;
  height: 11px;
  border-color: rgba(255,255,255,0.35);
  border-style: solid;
  border-width: 0;
  transition: border-color 0.18s;
}
.viewer-arrow:hover::before { border-color: rgba(255,255,255,0.8); }
#viewer-prev { left: 4px; }
#viewer-prev::before {
  border-left-width: 1.5px;
  border-bottom-width: 1.5px;
  transform: rotate(45deg) translate(2px, -2px);
}
#viewer-next { right: 4px; }
#viewer-next::before {
  border-right-width: 1.5px;
  border-top-width: 1.5px;
  transform: rotate(45deg) translate(-2px, 2px);
}

#viewer-close {
  position: fixed;
  top: 20px;
  right: 24px;
  background: none;
  border: none;
  color: rgba(255,255,255,0.3);
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  padding: 10px;
  transition: color 0.18s;
  z-index: 501;
  touch-action: manipulation;
}
#viewer-close:hover { color: rgba(255,255,255,0.75); }

/* ─── CV ─────────────────────────────────────────────────── */
.cv-body {
  max-width: 580px;
}
.cv-body p,
.cv-body li {
  font-size: 0.83rem;
  font-weight: 400;
  line-height: 1.85;
  color: var(--ink);
}
.cv-section {
  margin-bottom: 52px;
}
.cv-section-title {
  font-family: var(--sans);
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.cv-row {
  display: flex;
  gap: 24px;
  margin-bottom: 12px;
  align-items: baseline;
}
.cv-year {
  font-size: 0.72rem;
  font-weight: 400;
  color: var(--muted);
  letter-spacing: 0.04em;
  width: 130px;
  flex-shrink: 0;
}
.cv-detail {
  font-size: 0.83rem;
  font-weight: 400;
  line-height: 1.6;
}
.cv-placeholder {
  font-size: 0.76rem;
  font-style: italic;
  color: var(--muted);
  margin-bottom: 8px;
  line-height: 1.6;
}

/* ─── Contact ────────────────────────────────────────────── */
.contact-wrap {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: flex-start;
}
.contact-photo {
  flex-shrink: 0;
}
.contact-photo img {
  display: block;
  width: 325px;
  height: auto;
}
.contact-photo-img {
  opacity: 0;
  transition: opacity 0.35s ease;
}
.contact-photo-img.loaded { opacity: 1; }
.contact-info {
  padding-top: 4px;
}
.contact-info p {
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.7;
  margin-bottom: 28px;
}
.contact-email {
  font-family: var(--sans);
  font-size: 0.83rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 2px;
  transition: color 0.15s, border-color 0.15s;
}
.contact-email:hover {
  color: var(--muted);
  border-color: transparent;
}

/* ─── Tablet ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .home-img { max-width: 100%; }
}

/* ─── Mobile ─────────────────────────────────────────────── */
@media (max-width: 760px) {
  body { flex-direction: column; }

  #sidebar {
    position: relative;
    width: 100%;
    height: auto;
    border-right: none;
    border-bottom: none;
    padding: 28px 24px 20px;
    overflow: visible;
  }
  .sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
  }
  .sidebar-name { margin-bottom: 0; }

  #mobile-toggle { display: block; margin-bottom: 0; }

  #main-nav {
    display: none;
    padding-top: 24px;
    padding-bottom: 20px;
    width: 100%;
  }
  #main-nav.open { display: block; }

  .sidebar-copyright { display: none; }

  #content {
    margin-left: 0;
    padding: 36px 24px 64px;
  }
  #content.home { padding: 0; }

  #viewer-img-wrap { padding: 44px 52px 16px; }
  #viewer-caption { padding: 14px 24px 36px; }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
  }
  .grid-item-img { height: 150px; }
  #content { max-width: 100%; }

  .contact-wrap { flex-direction: column; gap: 36px; }
  .contact-photo img { width: 100%; max-width: 320px; }
  .home-img { width: 100%; max-width: 100%; height: auto; }
}
