/* ============ Gallery — album index ============ */

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
}
.album-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition:
    transform 0.25s var(--ease),
    border-color 0.25s var(--ease),
    box-shadow 0.25s var(--ease);
}
.album-card:hover,
.album-card:focus-visible {
  transform: translateY(-3px);
  border-color: var(--gold);
  box-shadow: 0 14px 28px -16px rgba(0, 0, 0, 0.7);
  text-decoration: none;
  outline: none;
}
.album-card__cover {
  position: relative;
  aspect-ratio: 16 / 10;
  background: var(--bg-1);
  overflow: hidden;
}
.album-card__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.45s var(--ease);
}
.album-card:hover .album-card__cover img {
  transform: scale(1.04);
}
.album-card__placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-size: 3rem;
  color: var(--text-muted);
  opacity: 0.4;
}
.album-card__body {
  padding: 0.85rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1;
}
.album-card__title {
  font-family: "EB Garamond", serif;
  font-size: 1.15rem;
  color: var(--gold-bright);
  margin: 0;
  line-height: 1.2;
}
.album-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  letter-spacing: 0.04em;
}
.album-card__meta > * + *::before {
  content: "·";
  margin-right: 0.45rem;
  color: var(--text-muted);
}
.album-card__desc {
  margin: 0.2rem 0 0;
  font-size: 0.85rem;
  color: var(--text-dim);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.breadcrumb {
  margin: 0 0 0.75rem;
  font-size: 0.88rem;
}
.breadcrumb a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.15s var(--ease);
}
.breadcrumb a:hover {
  color: var(--gold-bright);
}

.album-header {
  align-items: flex-start;
}
.album-header__meta {
  margin: 0.1rem 0 0;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.88rem;
}
.album-header__desc {
  margin: 0.5rem 0 0;
  max-width: 56ch;
  color: var(--text-dim);
}

/* ============ Gallery — album view ============ */

/* Uniform-thumbnail grid. Flows left-to-right, row-by-row (which reads
   naturally — the earlier CSS-columns masonry filled top-to-bottom so
   image #2 ended up below image #1 instead of next to it). Each card
   crops to 4:3; the lightbox still shows the full-aspect original. */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 0.75rem;
}

.gallery-card {
  position: relative;
  display: block;
  padding: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  transition:
    transform 0.2s var(--ease),
    border-color 0.2s var(--ease),
    box-shadow 0.2s var(--ease);
}
.gallery-card:hover,
.gallery-card:focus-visible {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 10px 20px -10px rgba(0, 0, 0, 0.6);
  outline: none;
}
.gallery-card img {
  /* Uniform 4:3 crop so every row in the grid has the same height.
     The full aspect-ratio original is still shown in the lightbox. */
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}
.gallery-card__overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0.6rem 0.75rem;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.85) 100%);
  text-align: left;
  color: var(--text);
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.22s var(--ease),
    transform 0.22s var(--ease);
  pointer-events: none;
}
.gallery-card:hover .gallery-card__overlay,
.gallery-card:focus-visible .gallery-card__overlay {
  opacity: 1;
  transform: translateY(0);
}
.gallery-card__title {
  font-family: "EB Garamond", serif;
  font-size: 0.98rem;
}
.gallery-card__caption {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.92);
  /* No padding: the image extends to the viewport edges; the close button
     and arrows float on top at a 1rem inset. */
  padding: 0;
}
.lightbox.hidden {
  display: none;
}

/* Figure hugs the image's rendered size (width: auto from max-height) so
   figcaption can be absolutely positioned at the bottom of the IMAGE, not
   the bottom of the viewport. */
.lightbox__content {
  position: relative;
  margin: 0;
  max-width: 100vw;
  max-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox__content img {
  display: block;
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  object-fit: contain;
  border: none;
  border-radius: 0;
  box-shadow: none;
}

/* Title pill mirrors the caption pill but sits at the TOP of the image.
   Same soft radial mask so it blends into the photo. Hidden when empty. */
.lightbox__content .lightbox__title {
  position: absolute;
  left: 50%;
  top: 2rem;
  transform: translateX(-50%);
  max-width: min(90vw, 760px);
  padding: 0.6rem 1.75rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  color: var(--text);
  font-family: "EB Garamond", serif;
  font-size: 1.15rem;
  line-height: 1.3;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-mask-image: radial-gradient(
    ellipse 70% 100% at center,
    #000 60%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse 70% 100% at center,
    #000 60%,
    transparent 100%
  );
  pointer-events: none;
}
.lightbox__content .lightbox__title:empty {
  display: none;
}

/* Position counter ("3 / 18") — sits just under the title pill, small and
   unobtrusive. Hidden for single-image albums (JS leaves it empty). */
.lightbox__content .lightbox__counter {
  position: absolute;
  left: 50%;
  top: 4.6rem;
  transform: translateX(-50%);
  z-index: 1;
  padding: 0.15rem 0.7rem;
  background: rgba(0, 0, 0, 0.55);
  border-radius: 999px;
  color: var(--text-dim);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  pointer-events: none;
}
.lightbox__content .lightbox__counter:empty {
  display: none;
}
@media (max-width: 640px) {
  .lightbox__content .lightbox__counter {
    top: 3.4rem;
  }
}
@media (max-width: 640px) and (orientation: portrait) {
  /* Title pill is relocated above the image on portrait phones; keep the
     counter with it so it doesn't float over the photo. */
  .lightbox__content .lightbox__counter {
    top: auto;
    bottom: calc(100% + 0.25rem);
  }
}

/* Caption is a centred pill floating over the bottom of the image.
   mask-image gives it a soft radial fade-out at the edges so it blends
   into the photo instead of cutting a hard rectangle. Hidden entirely
   when empty (JS sets textContent to '' for images with no title /
   caption / credit). */
.lightbox__content figcaption {
  position: absolute;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  max-width: min(90vw, 760px);
  padding: 0.6rem 1.75rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  color: var(--text);
  font-size: 1rem;
  line-height: 1.4;
  text-align: center;
  font-family: "EB Garamond", serif;
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  -webkit-mask-image: radial-gradient(
    ellipse 70% 100% at center,
    #000 60%,
    transparent 100%
  );
  mask-image: radial-gradient(
    ellipse 70% 100% at center,
    #000 60%,
    transparent 100%
  );
  pointer-events: none; /* clicks fall through to the backdrop for easy dismiss */
}
.lightbox__content figcaption:empty {
  display: none;
}

.lightbox__close,
.lightbox__nav {
  position: absolute;
  /* Explicit z-index: in DOM source order the left arrow sits BEFORE the
     figure, so without this it paints under the image and disappears.
     Needs to be above the figcaption (no z-index, stacking-context 0) too. */
  z-index: 1;
  /* Semi-opaque backdrop + blur so buttons remain visible over bright
     screenshots. Transparent-only would disappear against sunlit photos. */
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border: 1px solid var(--border);
  color: var(--text);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
}
.lightbox__close svg,
.lightbox__nav svg {
  width: 18px;
  height: 18px;
  /* Inline-SVG chevrons; styling is done with currentColor so hover
     picks up the gold like a normal icon font. */
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.lightbox__close:hover,
.lightbox__nav:hover {
  border-color: var(--gold);
  color: var(--gold-bright);
  background: rgba(200, 170, 110, 0.25);
}
.lightbox__close {
  top: 1rem;
  right: 1rem;
}
.lightbox__nav--prev {
  left: 1rem;
  top: 50%;
  transform: translateY(-50%);
}
.lightbox__nav--next {
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

/* Mobile / portrait: the full-size 44px circles + generous pill padding
   swallow a meaningful slice of a 400-wide viewport. Tighten everything
   so the photo stays the hero. Caption is allowed to wrap (the nowrap
   ellipsis on desktop would otherwise drop half the sentence). */
@media (max-width: 640px) {
  .lightbox__content .lightbox__title {
    top: 1rem;
    padding: 0.35rem 1rem;
    font-size: 0.95rem;
    max-width: 92vw;
  }
  .lightbox__content figcaption {
    bottom: 1rem;
    padding: 0.35rem 0.9rem;
    font-size: 0.82rem;
    line-height: 1.3;
    max-width: 92vw;
    /* Allow long captions to wrap to 2 lines instead of truncating with an
       ellipsis; the mask-image still softens the pill edges. */
    white-space: normal;
    text-overflow: clip;
  }
  /* Keep the controls at a 44px tap target on touch (the WCAG minimum); only
     pull them tighter to the viewport edge to reclaim photo space. */
  .lightbox__close,
  .lightbox__nav {
    width: 44px;
    height: 44px;
  }
  .lightbox__close {
    top: 0.5rem;
    right: 0.5rem;
  }
  .lightbox__nav--prev {
    left: 0.5rem;
  }
  .lightbox__nav--next {
    right: 0.5rem;
  }
}

/* Portrait phones: landscape screenshots centred on a tall viewport leave a
   lot of black letterbox above and below the image. Relocate the title and
   caption pills INTO that space so the photo itself isn't partially obscured
   by overlay text. Uses `calc(100% + Xrem)` on the figure-relative pills so
   they sit just outside the image edges. Falls back to the overlay
   positioning for landscape-phone or portrait-image edge cases. */
@media (max-width: 640px) and (orientation: portrait) {
  .lightbox__content .lightbox__title {
    top: auto;
    bottom: calc(100% + 0.75rem);
    /* Mask fade was for softening against varied photo backgrounds — on
       pure black we want crisp pill edges. */
    -webkit-mask-image: none;
    mask-image: none;
  }
  .lightbox__content figcaption {
    top: calc(100% + 0.75rem);
    bottom: auto;
    -webkit-mask-image: none;
    mask-image: none;
  }
}
