/* ============================================================
   Lens Legacy Photography — Main Stylesheet
   ============================================================ */

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

:root {
  /* ── Dark theme (default) ── */
  --color-bg:       #0a0a0a;
  --color-surface:  #111111;
  --color-border:   #222222;
  --color-text:     #e8e8e8;
  --color-muted:    #888888;
  --color-accent:   #c8a96e;
  --color-accent-h: #e0c080;
  --color-white:    #ffffff;
  --color-skeleton-base:  #1a1a1a;
  --color-skeleton-shine: #242424;
  --hero-overlay-top:    rgba(0,0,0,0.40);   /* darken top of hero photo */
  --hero-overlay-mid:    rgba(0,0,0,0.15);   /* lightest point — centre */
  --hero-overlay-bottom: rgba(0,0,0,0.50);   /* darken bottom for text */

  --font-sans:   -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-serif:  Georgia, 'Times New Roman', serif;
  --radius:      8px;
  --transition:  0.3s ease;
  --max-width:   1280px;
  --nav-height:  64px;
}

/* ── Light theme ─────────────────────────────────────────── */
[data-theme="light"] {
  --color-bg:       #f5f5f0;
  --color-surface:  #ffffff;
  --color-border:   #e0e0d8;
  --color-text:     #1a1a1a;
  --color-muted:    #666666;
  --color-accent:   #a0782a;
  --color-accent-h: #c8a96e;
  --color-white:    #1a1a1a;
  --color-skeleton-base:  #e8e8e4;
  --color-skeleton-shine: #f0f0ec;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
}

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Typography ──────────────────────────────────────────── */
h1, h2, h3 { font-weight: 400; letter-spacing: 0.02em; }
h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3vw, 2.25rem); margin-bottom: 1.5rem; }
h3 { font-size: 1.1rem; }
p  { color: var(--color-muted); }

/* ── Navigation ──────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  height: var(--nav-height);
  background: rgba(10,10,10,0.95);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--color-border);
}

.navbar .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.logo {
  font-family: var(--font-serif);
  font-size: 1.3rem;
  color: var(--color-accent);
  text-decoration: none;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-links {
  display: flex;
  list-style: none;
  gap: 32px;
}

.nav-links a {
  color: var(--color-muted);
  text-decoration: none;
  font-size: 0.875rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color var(--transition);
}

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

/* Hamburger button — hidden on desktop */
.nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-text);
  padding: 6px 10px;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}

/* ── Mobile nav ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .nav-toggle { display: block; }

  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0; right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    flex-direction: column;
    gap: 0;
    padding: 8px 0;
  }

  .nav-links.open { display: flex; }

  .nav-links li a {
    display: block;
    padding: 14px 24px;
    border-bottom: 1px solid var(--color-border);
  }

  .nav-links li:last-child a { border-bottom: none; }
}

/* ── Hero ────────────────────────────────────────────────── */
.hero {
  position: relative;
  min-height: 85vh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  overflow: hidden;
  background: linear-gradient(160deg, #0f0f0f 0%, #1a1208 50%, #0a0a0a 100%);
}

.hero-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 60%, rgba(200,169,110,0.08) 0%, transparent 70%);
}

/* When a hero photo is set, it sits behind the gradient overlay */
.hero-bg img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: center;
  transition: opacity 0.6s ease;
}

/* Dark overlay — only visible when a hero photo is set.
   Uses CSS variables so you can tune darkness by editing
   --hero-overlay-top / mid / bottom in the :root block above. */
.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    to bottom,
    var(--hero-overlay-top)    0%,
    var(--hero-overlay-mid)    50%,
    var(--hero-overlay-bottom) 100%
  );
  opacity: 0;           /* hidden by default (no photo) */
  transition: opacity 0.6s ease;
}

/* Show overlay when hero photo is loaded (JS adds .has-photo to hero-bg) */
/* CSS :has() is also supported in all modern browsers as a bonus */
.hero-bg.has-photo::after,
.hero-bg:has(#hero-image[src]:not([src=""]))::after {
  opacity: 1;
}

.hero-content { position: relative; z-index: 1; max-width: 800px; padding: 40px 24px; }

.hero-eyebrow {
  font-size: 0.75rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--color-accent);
  margin-bottom: 20px;
}

.hero h1 { color: var(--color-white); margin-bottom: 20px; line-height: 1.1; }

.hero p {
  font-size: 1.15rem;
  color: var(--color-muted);
  max-width: 540px;
  margin: 0 auto 40px;
}

.btn {
  display: inline-block;
  padding: 14px 36px;
  border: 1px solid var(--color-accent);
  color: var(--color-accent);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border-radius: var(--radius);
  transition: all var(--transition);
  cursor: pointer;
  background: transparent;
}

.btn:hover {
  background: var(--color-accent);
  color: var(--color-bg);
}

.btn-solid {
  background: var(--color-accent);
  color: var(--color-bg);
}

.btn-solid:hover {
  background: var(--color-accent-h);
  border-color: var(--color-accent-h);
}

/* ── Gallery grid ────────────────────────────────────────── */
.section { padding: 80px 0; }
.section-header { text-align: center; margin-bottom: 48px; }
.section-header h2 { color: var(--color-white); }

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2px;
}

.gallery-card {
  display: block;
  position: relative;
  overflow: hidden;
  aspect-ratio: 4/3;
  background: var(--color-surface);
  text-decoration: none;
  cursor: pointer;
}

.gallery-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
  display: block;
}

.gallery-card:hover img {
  transform: scale(1.04);
}

/* Dimming overlay — replaces filter:brightness() on the img.
   A CSS filter on an <img> forces GPU compositing at CSS-pixel resolution,
   which looks soft/blurry on retina displays. Using a pseudo-element instead
   keeps the image composited at full device-pixel resolution. */
.gallery-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  transition: opacity 0.6s ease;
  pointer-events: none;
  z-index: 1;
}

.gallery-card:hover::after {
  opacity: 0;
}

/* Keep overlay text above the dimming layer */
.gallery-card-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 20px;
  background: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 60%);
  transition: opacity var(--transition);
  z-index: 2;
}

.gallery-card h3 {
  color: var(--color-white);
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Lightbox */
.lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.96);
  align-items: center;
  justify-content: center;
}

.lightbox.open { display: flex; }


/* Photo caption in gallery pages */

/* ── Photo grid ─────────────────────────────────────────────────────────────── */
/*
 * Layout: auto-fill columns, each photo-item is aspect-ratio 4:3
 * aspect-ratio works in ANY layout context (grid, block, flex)
 * img is position:absolute filling its container via inset:0
 */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 10px;
  margin-top: 24px;
}

/* All photo items — aspect-ratio gives height in all layout contexts */
.photo-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius);
  cursor: pointer;
  background: var(--color-surface);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  aspect-ratio: 4 / 3;
}

/* ── Blur-up lazy-load placeholder ───────────────────────────────────────────
 * ::before holds the blurred preview.webp, scaled slightly to hide blur edges.
 * The <img> starts transparent and fades in once the full thumb is loaded.
 * --ll-preview is set inline by scripts.js when the slot enters the viewport.
 */
.photo-item::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: var(--ll-preview, none);
  background-size: cover;
  background-position: center;
  filter: blur(8px);
  transform: scale(1.05);
  z-index: 0;
  pointer-events: none;
}

/* Image fills the cell completely */
.photo-item img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transition: transform 0.5s ease, opacity 0.3s ease;
  display: block;
  z-index: 1;
}

/* While the full thumb is loading, hide it so the blurred ::before shows through */
.photo-item.ll-loading img {
  opacity: 0;
}

/* Full thumb loaded — fade it in over the blurred preview */
.photo-item.ll-loaded img {
  opacity: 1;
}

/* Hover effects */
.photo-item:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  z-index: 1;
}
.photo-item:hover img {
  transform: scale(1.04);
}

/* Fullscreen button */
.photo-item .fs-open-btn {
  position: absolute;
  bottom: 8px; right: 8px;
  width: 28px; height: 28px;
  background: rgba(0, 0, 0, 0.65);
  border: none; border-radius: 4px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; transition: opacity 0.15s;
}
.photo-item:hover .fs-open-btn {
  opacity: 1;
}

/* ── Masonry layout ───────────────────────────────────────────────────────── */
.photo-grid.masonry {
  display: block;
  column-count: 3;
  column-gap: 10px;
  grid-auto-rows: unset;
}
.photo-grid.masonry .photo-item {
  break-inside: avoid;
  margin-bottom: 10px;
  display: block;
  width: 100%;
  grid-column: unset;
  grid-row: unset;
  aspect-ratio: unset;  /* natural height in masonry */
}
.photo-grid.masonry .photo-item:first-child,
.photo-grid.masonry .photo-item.landscape,
.photo-grid.masonry .photo-item.portrait,
.photo-grid.masonry .photo-item.square {
  grid-column: unset;
  grid-row: unset;
  aspect-ratio: unset;
}
.photo-grid.masonry .photo-item img {
  position: static;
  height: auto;
  width: 100%;
  object-fit: unset;
}

/* Responsive masonry columns */
@media (max-width: 900px)  { .photo-grid.masonry { column-count: 2; } }
@media (max-width: 540px)  { .photo-grid.masonry { column-count: 1; } }




/* ── Gallery page sections ───────────────────────────────────────────────────── */
.gallery-section {
  margin-bottom: 64px;
}

.gallery-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.gallery-section-title {
  font-size: 1.1rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin: 0;
}

/* ── Sub-galleries section ───────────────────────────────────────────────────── */
.subgalleries-section {
  margin-bottom: 64px;
  padding-top: 48px;
  border-top: 1px solid var(--color-border);
}

.subgallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

/* Card redesign — richer with cover image */
.subgallery-card {
  display: block;
  text-decoration: none;
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  background: var(--color-surface);
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}

.subgallery-card:hover {
  border-color: var(--color-accent);
  transform: translateY(-3px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.subgallery-card-cover {
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--color-surface);
}

.subgallery-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.subgallery-card:hover .subgallery-card-cover img {
  transform: scale(1.04);
}

/* Placeholder cover when no image is set */
.subgallery-card-cover-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface);
  color: var(--color-muted);
  font-size: 2rem;
}

.subgallery-card-info {
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subgallery-card-title {
  font-size: 0.9rem;
  color: var(--color-text);
  font-weight: 400;
}

.subgallery-card-meta {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 2px;
}

.subgallery-card-arrow {
  color: var(--color-accent);
  font-size: 1.1rem;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.subgallery-card:hover .subgallery-card-arrow {
  transform: translateX(4px);
}

/* ── Gallery page hero header ────────────────────────────────────────────────── */
.page-hero {
  padding: 48px 0 32px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 32px;
}

.page-hero h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 300;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  margin: 0 0 8px;
}

.page-hero p {
  font-size: 1rem;
  color: var(--color-muted);
  margin: 0;
  max-width: 600px;
}

/* Ensure selected elements in editor scroll clear of the navbar */
.__sel {
  scroll-margin-top: 80px;
}

/* ── Full-screen immersive gallery ──────────────────────────────────────────── */
.fs-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 900;
  background: #000;
  flex-direction: column;
}
.fs-overlay.open { display: flex; }

.fs-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: rgba(0,0,0,0.7);
  flex-shrink: 0;
  z-index: 2;
}
.fs-title {
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 70vw;
}
.fs-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  opacity: 0.7;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
}
.fs-close:hover { opacity: 1; }

.fs-main {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  min-height: 0;
}

.fs-img {
  max-width: calc(100% - 130px);
  max-height: 100%;
  object-fit: contain;
  transition: opacity 0.12s;
  display: block;
}
.fs-img.fading { opacity: 0; }

/* Navigation arrows — gold box, vertically centred */
.fs-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 52px;
  border-radius: 6px;
  border: 2px solid #c8a96e;
  background: rgba(200,169,110,0.15);
  color: #c8a96e;
  font-size: 1.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  transition: background 0.2s;
}
.fs-arrow:hover { background: rgba(200,169,110,0.4); }
.fs-prev { left: 16px; }
.fs-next { right: 16px; }
.fs-arrow.hidden { display: none; }

.fs-bottombar {
  background: rgba(0,0,0,0.75);
  padding: 10px 20px 8px;
  flex-shrink: 0;
  z-index: 2;
}
.fs-caption {
  color: rgba(255,255,255,0.75);
  font-size: 0.875rem;
  text-align: center;
  margin-bottom: 4px;
  min-height: 1.2em;
}
.fs-exif {
  color: rgba(255,255,255,0.4);
  font-size: 0.75rem;
  text-align: center;
  margin-bottom: 6px;
  min-height: 1em;
}
.fs-counter {
  color: rgba(255,255,255,0.45);
  font-size: 0.8rem;
  text-align: center;
  margin-bottom: 8px;
}
.fs-thumbstrip {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  justify-content: center;
  padding-bottom: 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(200,169,110,0.4) transparent;
}
.fs-thumbstrip::-webkit-scrollbar { height: 3px; }
.fs-thumbstrip::-webkit-scrollbar-thumb { background: rgba(200,169,110,0.4); border-radius: 2px; }

.fs-thumb {
  width: 52px;
  height: 38px;
  object-fit: cover;
  cursor: pointer;
  opacity: 0.5;
  border-radius: 3px;
  flex-shrink: 0;
  transition: opacity 0.15s;
  border: 1px solid transparent;
}
.fs-thumb:hover  { opacity: 0.8; }
.fs-thumb.active {
  opacity: 1;
  border-color: #c8a96e;
}

/* Auto-hide controls */
.fs-overlay .fs-topbar,
.fs-overlay .fs-bottombar,
.fs-overlay .fs-arrow {
  transition: opacity 0.3s;
}
.fs-overlay:not(.controls-visible) .fs-topbar,
.fs-overlay:not(.controls-visible) .fs-bottombar,
.fs-overlay:not(.controls-visible) .fs-arrow {
  opacity: 0;
  pointer-events: none;
}
.fs-overlay.controls-visible .fs-topbar,
.fs-overlay.controls-visible .fs-bottombar,
.fs-overlay.controls-visible .fs-arrow {
  opacity: 1;
  pointer-events: auto;
}

/* ── Public site search ──────────────────────────────────── */
.search-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  padding: 6px 8px;
  cursor: pointer;
  border-radius: var(--radius);
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
  transition: color var(--transition), border-color var(--transition);
}
.search-btn:hover { color: var(--color-accent); border-color: var(--color-accent); }
.search-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Expand container sits between logo and theme-toggle in the flex row */
.search-expand {
  display: flex;
  align-items: center;
  position: relative;
  flex-shrink: 0;
}

/* The input slides open from 0 width */
.search-input-wrap {
  overflow: hidden;
  max-width: 0;
  opacity: 0;
  transition: max-width 0.3s ease, opacity 0.3s ease;
}
.search-expand.open .search-input-wrap {
  max-width: 220px;
  opacity: 1;
}

.search-field {
  width: 220px;
  padding: 6px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-size: 0.875rem;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color var(--transition);
}
.search-field:focus { border-color: var(--color-accent); }
.search-field::placeholder { color: var(--color-muted); }
/* Remove native clear button in WebKit — we close on Escape instead */
.search-field::-webkit-search-cancel-button { display: none; }

/* Results dropdown */
.search-dropdown {
  display: none;
  position: absolute;
  top: calc(var(--nav-height) - 4px);
  right: 0;
  width: 320px;
  max-width: 94vw;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
  z-index: 210;
  overflow: hidden;
}
.search-dropdown.visible { display: block; }

.search-result-item {
  display: block;
  padding: 12px 16px;
  text-decoration: none;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover,
.search-result-item:focus { background: var(--color-bg); outline: none; }

.search-result-title {
  font-size: 0.875rem;
  color: var(--color-text);
  font-weight: 500;
}
.search-result-meta {
  font-size: 0.75rem;
  color: var(--color-muted);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.search-no-results {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--color-muted);
  text-align: center;
}

/* ── Mobile search ───────────────────────────────────────── */
@media (max-width: 768px) {
  /* On mobile the input expands to full viewport width below the navbar */
  .search-expand.open .search-input-wrap {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    max-width: 100%;
    padding: 8px 16px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    z-index: 205;
    opacity: 1;
  }
  .search-expand.open .search-field { width: 100%; }

  .search-dropdown {
    position: fixed;
    top: calc(var(--nav-height) + 52px);
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}
