/* ==========================================================================
   Photography portfolio — dark theme, zero dependencies
   Sections: tokens → reset → base → nav → gallery → lightbox → about →
             toast → footer → utilities → media queries
   ========================================================================== */

/* ---------- Design tokens ---------- */
:root {
  --bg: #0e0f12;
  --surface: #16181d;
  --surface-2: #1d2027;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8e6e1;
  --text-dim: #9a9aa3;
  --accent: #d4a253;               /* warm gold — used sparingly */
  --shadow-rest: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 10px 28px rgba(0, 0, 0, 0.55);
  --radius: 10px;
  --container: 1200px;
  --nav-height: 64px;
  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
               Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- Minimal reset ---------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

h1, h2, p { margin: 0; }
ul { margin: 0; padding: 0; list-style: none; }

/* Visible focus for keyboard users only */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection { background: rgba(212, 162, 83, 0.35); }

/* ---------- Skip link ---------- */
.skip-link {
  position: absolute;
  top: -48px;
  left: 16px;
  z-index: 200;
  padding: 10px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 0 0 8px 8px;
  color: var(--text);
  text-decoration: none;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 0; }

/* ---------- Sticky navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(14, 15, 18, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-nav {
  max-width: var(--container);
  margin: 0 auto;
  height: var(--nav-height);
  padding: 0 clamp(16px, 4vw, 32px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.95rem;
}

.nav-links { display: flex; gap: clamp(8px, 3vw, 28px); }

.nav-links a {
  position: relative;
  display: inline-block;
  padding: 6px 2px;
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
}

/* Animated underline; visible only on the active route or hover */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  border-radius: 2px;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.25s ease;
}

.nav-links a:hover,
.nav-links a[aria-current="page"] { color: var(--text); }

.nav-links a:hover::after,
.nav-links a[aria-current="page"]::after { transform: scaleX(1); }

/* ---------- Main layout ---------- */
.site-main {
  flex: 1;
  width: 100%;
  max-width: var(--container);
  margin: 0 auto;
  padding: clamp(24px, 4vw, 48px) clamp(16px, 4vw, 32px) 64px;
}

.site-main:focus { outline: none; } /* focus target only */

.page-header { margin-bottom: clamp(20px, 3vw, 32px); }

.page-header h1 {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.page-header .page-sub {
  margin-top: 4px;
  color: var(--text-dim);
  font-size: 0.95rem;
}

/* ---------- Gallery grid: 3 → 2 → 1 columns ---------- */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* ---------- Gallery tiles ---------- */
.tile {
  display: block;
  width: 100%;
  text-align: left;
  border-radius: var(--radius);
}

.tile:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.thumb {
  position: relative;
  aspect-ratio: 3 / 2;           /* matches source images; avoids layout shift */
  overflow: hidden;
  border-radius: var(--radius);
  background: var(--surface-2);
  box-shadow: var(--shadow-rest);
  transition: box-shadow 0.3s ease;
}

.thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;             /* mixed orientations crop; lightbox shows full */
  opacity: 0;
  transform: scale(1);
  transition: opacity 0.45s ease, transform 0.35s ease;
}

.thumb img.is-loaded { opacity: 1; }

/* Shimmer shown while an image is loading */
.thumb::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg,
      transparent 32%, rgba(255, 255, 255, 0.06) 50%, transparent 68%);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}

.thumb.is-loaded::after,
.thumb.is-error::after { display: none; }

@keyframes shimmer {
  to { transform: translateX(100%); }
}

/* Subtle hover: shadow lift + slight scale (pointer devices only) */
@media (hover: hover) {
  .tile:hover .thumb {
    box-shadow: var(--shadow-hover);
  }
  .tile:hover .thumb img { transform: scale(1.03); }
}

/* Broken-image state */
.thumb.is-error {
  display: grid;
  place-items: center;
}
.thumb.is-error::before {
  content: "Image unavailable";
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* Discovery loading / empty / error states */
.gallery-status {
  padding: 64px 16px;
  text-align: center;
  color: var(--text-dim);
}

.gallery-status .spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.gallery-status .spinner {
  width: 28px;
  height: 28px;
  margin: 0 auto 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.gallery-status code {
  display: inline-block;
  margin-top: 12px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Lightbox ---------- */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 9, 11, 0.93);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity 0.25s ease;
}
.lightbox.is-open { opacity: 1; }
.lightbox[hidden] { display: none; }

.lb-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* keep the photo clear of the close button, arrows and caption */
  padding: 72px 88px 88px;
}

#lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 16px 64px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.3s ease;
}
#lightbox-img.is-loaded { opacity: 1; }

.lb-spinner {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
  display: none;
}
.lb-stage.is-loading .lb-spinner { display: block; }

.lb-btn {
  position: fixed;
  z-index: 2;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  transition: background 0.2s ease, transform 0.2s ease;
}
.lb-btn:hover { background: rgba(255, 255, 255, 0.18); }
.lb-btn svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.lb-close { top: 16px; right: 16px; }
.lb-prev { left: 18px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 18px; top: 50%; transform: translateY(-50%); }
.lb-prev:active { transform: translateY(-50%) scale(0.94); }
.lb-next:active { transform: translateY(-50%) scale(0.94); }

.lb-caption {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  max-width: 86vw;
  display: flex;
  gap: 14px;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#lb-counter { color: rgba(154, 154, 163, 0.7); }

/* ---------- About page ---------- */
.about {
  max-width: 620px;
  margin: 0 auto;
  padding-top: clamp(8px, 3vw, 32px);
  text-align: center;
}

.avatar {
  width: 132px;
  height: 132px;
  margin: 0 auto 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background:
    radial-gradient(circle at 30% 25%, rgba(212, 162, 83, 0.16), transparent 60%),
    var(--surface-2);
  color: var(--text-dim);
  font-size: 2.1rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  user-select: none;
}

.about h1 {
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 600;
  letter-spacing: 0.01em;
}

.about-tagline {
  margin-top: 6px;
  color: var(--accent);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.about .bio {
  margin-top: 28px;
  text-align: left;
}

.about .bio p {
  margin-bottom: 16px;
  line-height: 1.75;
  color: var(--text);
}

.email-block {
  margin-top: 40px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
}

.email-label {
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.email-copy {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.email-copy:hover {
  border-color: rgba(212, 162, 83, 0.6);
  transform: translateY(-1px);
}
.email-copy svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--text-dim);
}

.email-mailto {
  display: inline-block;
  margin-top: 14px;
  color: var(--text-dim);
  font-size: 0.9rem;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 0.2s ease, border-color 0.2s ease;
}
.email-mailto:hover {
  color: var(--text);
  border-color: var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  z-index: 150;
  transform: translate(-50%, 12px);
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text);
  box-shadow: var(--shadow-hover);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s;
}
.toast.is-visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0);
}

/* ---------- Footer ---------- */
.site-footer {
  padding: 24px 16px;
  border-top: 1px solid var(--border);
  text-align: center;
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ---------- Utilities ---------- */
.noscript-note {
  max-width: var(--container);
  margin: 24px auto;
  padding: 0 16px;
  color: var(--text-dim);
}

/* ---------- Responsive: tablet → 2 columns, mobile → 1 ---------- */
@media (max-width: 1024px) {
  .gallery-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .gallery-grid { grid-template-columns: 1fr; gap: 16px; }
  .lb-stage { padding: 64px 12px 88px; }
  .lb-btn { width: 42px; height: 42px; }
  .lb-prev { left: 10px; }
  .lb-next { right: 10px; }
  .lb-caption { font-size: 0.8rem; }
}

/* Respect users who prefer minimal motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
}
/* ---------- Prevent layout shift from scrollbar appearing/disappearing ----------
 * scrollbar-gutter reserves space for the vertical scrollbar even when content
 * fits (no scroll needed). This eliminates the 1–3px horizontal jitter that
 * happens when page content crosses the scroll threshold or when the lightbox
 * toggles body overflow-hidden.                          */
html {
  scrollbar-gutter: stable;
}
body {
  overflow-y: auto;
}

/* ---------- Portrait photo on About page ---------- */
.portrait {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 24px;
}

.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ==========================================================================
   Project pages — title, text & photo grids (lightbox-integrated)
   ========================================================================== */

/* ---- Projects overview ---- */
.projects-overview {
  max-width: var(--container);
  margin: 0 auto;
  padding-top: clamp(16px, 3vw, 48px);
}

.projects-overview h1 {
  font-size: clamp(1.5rem, 2.6vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.01em;
  margin-bottom: 24px;
}

.project-card {
  display: block;
  width: 100%;
  text-align: left;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.project-card:hover {
  border-color: rgba(212, 162, 83, 0.5);
  transform: translateY(-2px);
}

.project-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.project-card h2 {
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.card-desc {
  margin-top: 8px;
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.6;
}

.empty-note {
  color: var(--text-dim);
  font-style: italic;
}

.not-found {
  max-width: var(--container);
  margin: 0 auto;
  text-align: center;
  padding-top: 48px;
}

.back-link-btn {
  display: inline-block;
  margin-top: 16px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease;
}

.back-link-btn:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.back-link-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- Project single-page hero ---- */
.project-hero {
  position: relative;
  padding: clamp(48px, 8vw, 96px) clamp(16px, 4vw, 32px) clamp(32px, 6vw, 72px);
  text-align: center;
  overflow: hidden;
}

.hero-gradient {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(14, 15, 18, 0.3) 60%,
    rgba(14, 15, 18, 0.9) 100%);
  pointer-events: none;
}

.project-hero-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
}

.project-hero-title {
  font-size: clamp(2rem, 4.5vw, 3.2rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0;
  line-height: 1.2;
}

.project-hero-text {
  margin-top: 16px;
  color: var(--text);
  font-size: clamp(0.95rem, 1.5vw, 1.1rem);
  line-height: 1.7;
}

/* ---- Project content wrapper ---- */
.project-content-wrap {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 clamp(16px, 4vw, 32px) 64px;
}

/* ---- Photo sections within a project ---- */
.photo-section {
  margin-bottom: 64px;
}

.photo-section:last-child {
  margin-bottom: 0;
}

.photo-section-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

/* Same tile styles as gallery — reused via shared .tile/.thumb classes */
.photo-section .tile {
  /* inherited from base .tile */
}

/* ---- Project nav bar ---- */
.project-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 0;
  border-top: 1px solid var(--border);
  margin-top: 32px;
}

.nav-btn {
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.nav-btn:hover:not(:disabled) {
  border-color: rgba(212, 162, 83, 0.6);
  transform: translateY(-1px);
}

.nav-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.nav-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

/* ---- Responsive: tablet ---- */
@media (max-width: 1024px) {
  .photo-section-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .project-hero-title {
    font-size: clamp(1.8rem, 5vw, 2.8rem);
  }
  .project-hero-text {
    font-size: 1rem;
  }
}

/* ---- Responsive: mobile ---- */
@media (max-width: 640px) {
  .photo-section-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .project-hero {
    padding-top: clamp(36px, 6vw, 64px);
    padding-bottom: clamp(24px, 4vw, 48px);
  }
  .project-hero-title {
    font-size: 1.8rem;
  }
  .project-hero-text {
    font-size: 0.95rem;
  }
  .project-nav {
    flex-direction: column;
    gap: 10px;
  }
  .lb-stage {
    padding: 64px 12px 88px;
  }
  .lb-btn {
    width: 42px;
    height: 42px;
  }
  .lb-prev {
    left: 10px;
  }
  .lb-next {
    right: 10px;
  }
  .lb-caption {
    font-size: 0.8rem;
  }
}
