/* ═══════════════════════════════════════════════════════════
   Savannah Jia — Portfolio
   ═══════════════════════════════════════════════════════════ */

/* ── Tokens ─────────────────────────────────────────────── */
:root {
  --sidebar-w:    240px;
  --bg:           #faf9f7;
  --bg-panel:     #ffffff;
  --text:         #111110;
  --text-mid:     #555550;
  --text-muted:   #999990;
  --border:       #e8e6e0;
  --accent:       #111110;
  --ink:          #111110;
  --ink-light:    #888880;

  --serif:        'Cormorant Garamond', 'Palatino Linotype', Georgia, serif;
  --serif-sc:     'Cormorant SC', 'Palatino Linotype', Georgia, serif;
  --sans:         'Helvetica Neue', Helvetica, Arial, sans-serif;

  --ease:         cubic-bezier(.25,.46,.45,.94);
  --trans:        0.22s var(--ease);
}

/* ── Reset ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }

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

a { color: inherit; text-decoration: none; }
button { background: none; border: none; cursor: pointer; font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  height: 100dvh;
  overscroll-behavior-y: contain;
  position: fixed;
  top: 0; left: 0;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  flex-shrink: 0;
  padding: 48px 32px 40px;
}

/* Site name */
.site-name {
  font-family: var(--serif-sc);
  font-size: 17px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text);
  display: block;
  margin-bottom: 52px;
  cursor: pointer;
  transition: opacity var(--trans);
  line-height: 1.3;
}
.site-name:hover { opacity: 0.6; }

/* Nav root list */
.nav-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.nav-item { border-top: 1px solid var(--border); }
.nav-item:last-child { border-bottom: 1px solid var(--border); }

/* Medium button */
.nav-medium {
  width: 100%;
  text-align: left;
  padding: 14px 0;
  font-family: var(--sans);
  font-size: 11px;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-mid);
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: color var(--trans);
}
.nav-medium::after {
  content: '';
  width: 7px; height: 7px;
  border-right: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  transform: rotate(45deg) translateY(-2px);
  transition: transform var(--trans);
  flex-shrink: 0;
  opacity: 0.5;
}
.nav-medium:hover,
.nav-item.open .nav-medium { color: var(--text); }
.nav-item.open .nav-medium::after { transform: rotate(-135deg) translateY(-2px); opacity: 1; }

/* Year list */
.nav-years {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s var(--ease);
}
.nav-item.open .nav-years { max-height: 300px; }

.nav-years li { padding-bottom: 2px; }
.nav-years li:last-child { padding-bottom: 14px; }

.nav-years li a {
  display: block;
  padding: 5px 0 5px 14px;
  font-family: var(--serif);
  font-size: 15px;
  font-weight: 300;
  color: var(--text-muted);
  transition: color var(--trans);
  cursor: pointer;
}
.nav-years li a:hover,
.nav-years li a.active { color: var(--text); }

/* Footer links */
.nav-footer {
  margin-top: 40px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.nav-link-secondary {
  font-family: var(--sans);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--trans);
}
.nav-link-secondary:hover { color: var(--text); }

/* ── Mobile header ───────────────────────────────────────── */
.mobile-header {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  z-index: 300;
}
.mobile-name {
  font-family: var(--serif-sc);
  font-size: 14px;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.hamburger {
  width: 28px; height: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 2px;
}
.hamburger span {
  display: block;
  height: 1px;
  background: var(--text);
  transition: transform var(--trans), opacity var(--trans);
}
body.menu-open .hamburger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.menu-open .hamburger span:nth-child(2) { opacity: 0; }
body.menu-open .hamburger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: 190;
}

/* ── Main ────────────────────────────────────────────────── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
}

.view { animation: fadeUp 0.28s var(--ease) both; }
.view.hidden { display: none !important; }
.view.active { display: block; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Featured grid / home ────────────────────────────────── */
.featured-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  padding: 48px;
  align-items: start;
}
.featured-item {
  cursor: pointer;
}
.featured-img-wrap {
  overflow: hidden;
  background: #f0eeeb;
}
.featured-img-wrap img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.6s var(--ease);
}
.featured-item:hover .featured-img-wrap img {
  transform: scale(1.025);
}
.featured-caption {
  padding: 12px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.featured-title {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.featured-meta {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  text-transform: uppercase;
}

/* ── Works grid ──────────────────────────────────────────── */
.works-header {
  padding: 40px 48px 28px;
  border-bottom: 1px solid var(--border);
}
.works-label {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  color: var(--text);
}

.grid {
  padding: 32px 48px 64px;
  columns: 3;
  column-gap: 20px;
}

.grid-item {
  break-inside: avoid;
  margin-bottom: 20px;
  cursor: pointer;
}

.grid-item img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s var(--ease);
}
.grid-item:hover img { transform: scale(1.02); }

.grid-item-caption {
  padding: 12px 2px 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.grid-item-title {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.grid-item-meta {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  text-transform: uppercase;
}

/* ── Prose pages (about, contact) ────────────────────────── */
.prose-page {
  max-width: 560px;
  padding: 72px 64px;
}
.prose-title {
  font-family: var(--serif-sc);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  margin-bottom: 40px;
  text-transform: uppercase;
}
.prose-body p {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 300;
  line-height: 1.75;
  color: var(--text);
  margin-bottom: 24px;
}
.prose-body p:last-child { margin-bottom: 0; }
.prose-body a {
  border-bottom: 1px solid var(--border);
  transition: border-color var(--trans);
}
.prose-body a:hover { border-color: var(--text); }

.contact-body p {
  font-size: 20px;
  letter-spacing: 0.01em;
}

/* ── Lightbox ────────────────────────────────────────────── */
.lightbox {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 400;
  display: flex;
  flex-direction: column;
}
.lightbox.hidden { display: none; }
body.lb-open { overflow: hidden; }

/* Toolbar */
.lb-toolbar {
  position: absolute;
  top: 20px; right: 24px;
  display: flex;
  gap: 8px;
  z-index: 10;
}

.lb-btn {
  width: 38px; height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-panel);
  border-radius: 2px;
  transition: background var(--trans), border-color var(--trans);
}
.lb-btn:hover { background: var(--text); border-color: var(--text); }
.lb-btn:hover svg { stroke: var(--bg); }
.lb-btn svg {
  width: 16px; height: 16px;
  stroke: var(--text-mid);
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke var(--trans);
}

/* Standard lightbox layout */
.lb-standard {
  flex: 1;
  display: flex;
  align-items: center;
  min-height: 0;
  padding: 56px 0 0;
}

.lb-arrow {
  flex-shrink: 0;
  width: 64px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--trans);
}
.lb-arrow:hover { color: var(--text); }
.lb-arrow svg {
  width: 22px; height: 22px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-center {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  padding: 0 8px;
}

.lb-img-wrap {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 12px;
}

#lb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  width: auto;
  height: auto;
  box-shadow: 0 4px 40px rgba(0,0,0,0.08);
  cursor: zoom-in;
}

.lb-meta {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 14px 0 18px;
  text-align: center;
}
.lb-title {
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.lb-info {
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--ink-light);
  text-transform: uppercase;
}

/* Filmstrip */
.lb-filmstrip-wrap {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  padding: 12px 64px;
  overflow-x: auto;
  background: var(--bg-panel);
}
.lb-filmstrip-wrap::-webkit-scrollbar { height: 3px; }
.lb-filmstrip-wrap::-webkit-scrollbar-track { background: transparent; }
.lb-filmstrip-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.lb-filmstrip {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  min-width: min-content;
}

.lb-thumb-btn {
  flex-shrink: 0;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 1px;
  transition: border-color var(--trans), opacity var(--trans);
  opacity: 0.45;
}
.lb-thumb-btn:hover { opacity: 0.75; }
.lb-thumb-btn.active { opacity: 1; border-color: var(--text); }

.lb-thumb-btn img {
  height: 52px;
  width: auto;
  display: block;
  pointer-events: none;
}

/* ── Zoom / pan viewer ───────────────────────────────────── */
.lb-zoom-view {
  position: absolute;
  inset: 0;
  background: #0d0d0d;
  z-index: 20;
  overflow: hidden;
  cursor: crosshair;
}
.lb-zoom-view.hidden { display: none; }

.zoom-canvas {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
  user-select: none;
}

#zoom-img {
  max-width: none;
  max-height: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

.zoom-hint {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  pointer-events: none;
  transition: opacity 0.5s;
}
.zoom-hint.hide { opacity: 0; }

.zoom-exit {
  position: absolute;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 2px;
  color: rgba(255,255,255,0.6);
  font-family: var(--sans);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  transition: color var(--trans), border-color var(--trans);
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(8px);
  z-index: 5;
}
.zoom-exit:hover { color: #fff; border-color: rgba(255,255,255,0.5); }
.zoom-exit svg {
  width: 14px; height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1100px) {
  .grid { columns: 2; }
}

@media (max-width: 800px) {
  .mobile-header { display: flex; }
  .sidebar-overlay { display: block; opacity: 0; pointer-events: none; transition: opacity var(--trans); }
  body.menu-open .sidebar-overlay { opacity: 1; pointer-events: auto; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s var(--ease);
  }
  body.menu-open .sidebar { transform: translateX(0); }

  .main { margin-left: 0; padding-top: 56px; }
  .sidebar-nav { padding: 80px 32px calc(32px + env(safe-area-inset-bottom)) 40px; }
  .nav-footer { margin-top: 28px; }
  .nav-link-secondary { padding: 12px 0; }
  body.menu-open { overflow: hidden; }
  .featured-grid { grid-template-columns: 1fr; padding: 24px; gap: 32px; }

  .grid { columns: 2; padding: 20px 20px 48px; column-gap: 12px; }
  .grid-item { margin-bottom: 12px; }
  .works-header { padding: 24px 20px 16px; }

  .prose-page { padding: 40px 24px; }

  .lb-standard { padding-top: 56px; }
  .lb-arrow { width: 40px; }
  .lb-filmstrip-wrap { padding: 10px 40px; }
  .lb-thumb-btn img { height: 40px; }
}

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

/* A next step after the final artwork. */
.view-more {
  margin: 0 48px 48px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
}
.view-more h2 {
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 400;
  margin-bottom: 14px;
}
.view-more-links { display: flex; flex-wrap: wrap; gap: 8px 24px; }
.view-more button {
  min-height: 44px;
  text-align: left;
  font-size: 13px;
  color: var(--text-mid);
  text-decoration: underline;
  text-underline-offset: 5px;
  text-decoration-color: var(--border);
}
.view-more button:hover { color: var(--text); text-decoration-color: currentColor; }
.view-more button:focus-visible { outline: 2px solid currentColor; outline-offset: 4px; }
@media (max-width: 800px) {
  .view-more { margin: 0 20px 32px; }
}

/* Brief lightbox transitions; the artwork remains the focus. */
.lightbox:not(.hidden) { animation: lightbox-open 160ms ease-out both; }
.lightbox:not(.hidden) .lb-center { animation: artwork-open 160ms ease-out both; }
.lightbox.closing:not(.hidden) { animation: lightbox-close 140ms ease-in both; pointer-events: none; }
.lightbox.closing:not(.hidden) .lb-center { animation: artwork-close 140ms ease-in both; }
@keyframes lightbox-open { from { opacity: 0; } to { opacity: 1; } }
@keyframes lightbox-close { from { opacity: 1; } to { opacity: 0; } }
@keyframes artwork-open { from { transform: scale(.98); } to { transform: scale(1); } }
@keyframes artwork-close { from { transform: scale(1); } to { transform: scale(.98); } }
@media (prefers-reduced-motion: reduce) {
  .lightbox:not(.hidden), .lightbox:not(.hidden) .lb-center { animation: none; }
}
