:root {
  --gallery-ocean: #1a6a8a;
  --gallery-ocean-dark: #0d4a62;
  --gallery-sand: #f5f0e8;
  --gallery-text: #1c2023;
  --gallery-muted: #6b7a84;
  --gallery-white: #ffffff;
}

body.photo-viewer-open {
  overflow: hidden;
}

.gallery-trigger {
  cursor: zoom-in;
}

.gallery-trigger:focus-visible {
  outline: 3px solid #f4c66f;
  outline-offset: 4px;
}

.gallery-strip-link {
  display: flex;
  justify-content: center;
  margin: 1.75rem 0 0;
}

.gallery-strip-link a {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.82rem 1.4rem;
  border: 1px solid var(--gallery-ocean);
  color: var(--gallery-ocean-dark);
  font-family: 'Jost', sans-serif;
  font-size: 0.73rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-decoration: none;
  text-transform: uppercase;
  transition: background 0.2s ease, color 0.2s ease;
}

.gallery-strip-link a:hover,
.gallery-strip-link a:focus-visible {
  background: var(--gallery-ocean-dark);
  color: var(--gallery-white);
}

.photo-viewer[hidden] {
  display: none;
}

.photo-viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.photo-viewer.is-open {
  opacity: 1;
}

.photo-viewer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 17, 24, 0.96);
}

.photo-viewer-dialog {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr) 5rem;
  grid-template-rows: minmax(0, 1fr) auto;
  width: min(96vw, 1560px);
  height: min(94vh, 1040px);
  background: #041820;
  color: var(--gallery-white);
}

.photo-viewer-stage {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 1.4rem 0 0.75rem;
}

.photo-viewer-stage picture {
  display: contents;
}

.photo-viewer-image {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.38);
}

.photo-viewer-close,
.photo-viewer-arrow {
  border: 0;
  color: var(--gallery-white);
  background: transparent;
  cursor: pointer;
}

.photo-viewer-close:focus-visible,
.photo-viewer-arrow:focus-visible {
  outline: 2px solid #f4c66f;
  outline-offset: 3px;
}

.photo-viewer-close {
  position: absolute;
  top: 0;
  right: 0.5rem;
  z-index: 2;
  width: 3.25rem;
  height: 3.25rem;
  font-size: 2.25rem;
  font-weight: 200;
  line-height: 1;
}

.photo-viewer-arrow {
  grid-row: 1;
  align-self: center;
  width: 4rem;
  height: 5rem;
  font-size: 4rem;
  font-weight: 200;
  line-height: 1;
  opacity: 0.82;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.photo-viewer-arrow:hover {
  opacity: 1;
  transform: scale(1.06);
}

.photo-viewer-prev {
  grid-column: 1;
}

.photo-viewer-next {
  grid-column: 3;
}

.photo-viewer-details {
  grid-column: 2;
  grid-row: 2;
  position: relative;
  z-index: 2;
  padding: 0.85rem 1rem 1rem;
  background: #041820;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.photo-viewer-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.35rem;
  color: rgba(255, 255, 255, 0.66);
  font-family: 'Jost', sans-serif;
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.photo-viewer-title {
  margin: 0;
  color: var(--gallery-white);
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.45rem, 2.5vw, 2.1rem);
  font-weight: 400;
  line-height: 1.05;
}

.photo-viewer-caption {
  max-width: 54rem;
  margin: 0.35rem 0 0;
  color: rgba(255, 255, 255, 0.72);
  font-family: 'Jost', sans-serif;
  font-size: 0.82rem;
  font-weight: 300;
  line-height: 1.55;
}

/* Dedicated gallery page */
.gallery-page {
  margin: 0;
  color: var(--gallery-text);
  background: #fcfbf8;
  font-family: 'Jost', sans-serif;
  font-weight: 300;
}

.gallery-page *,
.gallery-page *::before,
.gallery-page *::after {
  box-sizing: border-box;
}

.gallery-page-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 74px;
  padding: 0 4vw;
  background: rgba(9, 47, 61, 0.96);
  box-shadow: 0 4px 22px rgba(0, 0, 0, 0.12);
}

.gallery-page-logo {
  color: var(--gallery-white);
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.65rem;
  letter-spacing: 0.03em;
  text-decoration: none;
}

.gallery-page-nav {
  display: flex;
  align-items: center;
  gap: clamp(0.9rem, 2vw, 2rem);
}

.gallery-page-nav a {
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.11em;
  text-decoration: none;
  text-transform: uppercase;
}

.gallery-page-nav a:hover,
.gallery-page-nav a:focus-visible {
  color: var(--gallery-white);
}

.gallery-page-nav a[aria-current="page"] {
  color: var(--gallery-white);
  box-shadow: inset 0 -1px var(--gallery-white);
}

.gallery-page-nav .gallery-page-book {
  padding: 0.7rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.65);
}

.gallery-hero {
  margin-top: 74px;
  color: var(--gallery-text);
  background: linear-gradient(135deg, #f4f0e7 0%, #eaf4f6 100%);
  border-bottom: 1px solid #d8d1c2;
}

.gallery-hero-content {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(24rem, 1.1fr);
  align-items: end;
  gap: clamp(2rem, 7vw, 8rem);
  width: min(92%, 1380px);
  margin: 0 auto;
  padding: 2.4rem 0 2.2rem;
}

.gallery-hero-eyebrow,
.gallery-category-eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.gallery-hero h1 {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(3rem, 5vw, 4.8rem);
  font-weight: 300;
  line-height: 0.95;
}

.gallery-hero h1 em {
  font-weight: 300;
}

.gallery-hero p:not(.gallery-hero-eyebrow) {
  max-width: 42rem;
  margin: 0 0 0.25rem;
  color: var(--gallery-muted);
  font-size: clamp(0.9rem, 1.5vw, 1.05rem);
  line-height: 1.7;
}

.gallery-hero-eyebrow {
  color: var(--gallery-ocean);
}

.gallery-category-nav-wrap {
  position: sticky;
  top: 74px;
  z-index: 80;
  overflow-x: auto;
  border-bottom: 1px solid #ded8cb;
  background: rgba(252, 251, 248, 0.96);
  backdrop-filter: blur(12px);
}

.gallery-category-nav {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  width: max-content;
  min-width: 100%;
  padding: 0.85rem 3vw;
}

.gallery-category-nav a {
  padding: 0.55rem 0.8rem;
  color: var(--gallery-ocean-dark);
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-decoration: none;
  text-transform: uppercase;
  white-space: nowrap;
}

.gallery-category-nav a:hover,
.gallery-category-nav a:focus-visible {
  background: #e8f4f8;
}

.gallery-sections {
  width: min(92%, 1380px);
  margin: 0 auto;
  padding: 0 0 6rem;
}

.gallery-category {
  scroll-margin-top: 145px;
  padding: 4.5rem 0 0;
}

.gallery-category:first-child {
  padding-top: 2.75rem;
}

.gallery-category-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 2rem;
  margin-bottom: 1.4rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px solid #d8d1c2;
}

.gallery-category-eyebrow {
  color: var(--gallery-ocean);
}

.gallery-category-heading h2 {
  margin: 0;
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(2.3rem, 5vw, 4rem);
  font-weight: 400;
  line-height: 1;
}

.gallery-category-heading > span {
  padding-bottom: 0.35rem;
  color: var(--gallery-muted);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.8rem;
}

.gallery-tile {
  position: relative;
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: #dfe6e7;
  aspect-ratio: 4 / 3;
  cursor: zoom-in;
}

.gallery-tile-portrait::before {
  position: absolute;
  z-index: 0;
  inset: -1rem;
  background: var(--gallery-tile-image) center / cover no-repeat;
  content: '';
  filter: blur(16px);
  opacity: 0.42;
  transform: scale(1.06);
}

.gallery-tile-featured {
  grid-column: span 2;
  grid-row: span 2;
}

.gallery-tile img {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.45s ease;
}

.gallery-tile-portrait img {
  object-fit: contain;
}

.gallery-tile:hover img,
.gallery-tile:focus-visible img {
  transform: scale(1.035);
}

.gallery-tile-overlay {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 4.5rem 1rem 0.85rem;
  color: var(--gallery-white);
  text-align: left;
  background: linear-gradient(
    to top,
    rgba(3, 20, 28, 0.96) 0%,
    rgba(3, 20, 28, 0.78) 36%,
    rgba(3, 20, 28, 0.28) 70%,
    transparent 100%
  );
  z-index: 2;
}

.gallery-tile-overlay-at-top .gallery-tile-overlay {
  inset: 0 0 auto;
  align-items: start;
  padding: 0.85rem 1rem 4.5rem;
  background: linear-gradient(
    to bottom,
    rgba(3, 20, 28, 0.92) 0%,
    rgba(3, 20, 28, 0.68) 38%,
    rgba(3, 20, 28, 0.18) 72%,
    transparent 100%
  );
}

.gallery-tile-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: clamp(1.05rem, 1.8vw, 1.45rem);
  font-weight: 400;
  line-height: 1.05;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.9);
}

.gallery-tile-action {
  flex: 0 0 auto;
  font-size: 0.58rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.95);
}

.gallery-page-footer {
  padding: 3.5rem 5vw;
  color: rgba(255, 255, 255, 0.68);
  text-align: center;
  background: #0d3646;
}

.gallery-page-footer a {
  color: var(--gallery-white);
}

.gallery-footer-social {
  display: flex;
  justify-content: center;
  gap: 0.8rem;
  margin: 0.85rem 0 0;
}

.gallery-footer-social a {
  display: grid;
  width: 2.4rem;
  height: 2.4rem;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 50%;
  text-decoration: none;
  transition: border-color 0.25s, transform 0.25s;
}

.gallery-footer-social a:hover {
  border-color: rgba(255, 255, 255, 0.8);
  transform: translateY(-1px);
}

.gallery-footer-social img {
  width: 1rem;
  height: 1rem;
}

@media (max-width: 800px) {
  .photo-viewer-dialog {
    grid-template-columns: 3.2rem minmax(0, 1fr) 3.2rem;
    width: 100vw;
    height: 100vh;
    padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
  }

  .photo-viewer-stage {
    padding-top: 3.8rem;
  }

  .photo-viewer-close {
    top: max(0.35rem, env(safe-area-inset-top));
    right: 0.35rem;
  }

  .photo-viewer-arrow {
    width: 3rem;
    font-size: 3.2rem;
  }

  .photo-viewer-details {
    padding: 0.75rem 0.85rem 1rem;
  }

  .gallery-page-header {
    min-height: 64px;
    padding: 0 1rem;
  }

  .gallery-page-nav a:not(.gallery-page-book):not([aria-current="page"]) {
    display: none;
  }

  .gallery-hero {
    margin-top: 64px;
  }

  .gallery-hero-content {
    grid-template-columns: 1fr;
    gap: 0.9rem;
    padding: 1.8rem 0 1.6rem;
  }

  .gallery-hero h1 {
    font-size: clamp(2.8rem, 13vw, 4rem);
  }

  .gallery-category:first-child {
    padding-top: 2rem;
  }

  .gallery-category-nav-wrap {
    top: 64px;
  }

  .gallery-category-nav {
    justify-content: flex-start;
    min-width: max-content;
  }

  .gallery-sections {
    width: min(94%, 720px);
  }

  .gallery-category {
    scroll-margin-top: 130px;
    padding-top: 3.5rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem;
  }

  .gallery-tile-featured {
    grid-column: span 2;
    grid-row: auto;
    aspect-ratio: 16 / 10;
  }

  .gallery-tile-overlay {
    padding: 3.4rem 0.65rem 0.6rem;
  }

  .gallery-tile-action {
    display: none;
  }
}

@media (max-width: 480px) {
  .photo-viewer-dialog {
    grid-template-columns: 2.5rem minmax(0, 1fr) 2.5rem;
  }

  .photo-viewer-arrow {
    width: 2.4rem;
    font-size: 2.6rem;
  }

  .photo-viewer-caption {
    font-size: 0.75rem;
  }

  .gallery-category-heading {
    align-items: start;
    flex-direction: column;
    gap: 0.35rem;
  }

  .gallery-category-heading > span {
    padding-bottom: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .photo-viewer,
  .gallery-tile img,
  .photo-viewer-arrow {
    transition: none;
  }
}
