/*
 * photo_banner, photo_tiles and photo_gallery ferns, and the photo lightbox.
 * Theme tokens for every surface; the black scrim and white text sit on
 * photos, so they stay the same in both themes. Brand stylesheets restyle
 * these classes.
 */

/* ---- Photo banner ---- */
.cb-photo-banner {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: var(--bg-elev-2);
}

.cb-photo-banner--tall {
  min-height: clamp(320px, 65vh, 760px);
}

.cb-photo-banner--medium {
  min-height: clamp(260px, 45vh, 520px);
  border-radius: var(--radius, 10px);
}

.cb-photo-banner--no-media {
  background: color-mix(in srgb, var(--accent) 22%, var(--bg-elev));
}

.cb-photo-banner__media {
  position: absolute;
  inset: 0;
  z-index: -1;
}

.cb-photo-banner__image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.2s ease;
}

.cb-photo-banner__image--active {
  opacity: 1;
}

.cb-photo-banner__card {
  max-width: 36rem;
  margin: var(--space-6, 1.5rem);
  padding: var(--space-5, 1.25rem) var(--space-6, 1.5rem);
  border-radius: var(--radius, 10px);
  background: rgb(0 0 0 / 0.62);
  color: white;
}

.cb-photo-banner--no-media .cb-photo-banner__card {
  background: transparent;
  color: var(--text);
}

.cb-photo-banner__title {
  margin: 0;
  font-size: clamp(1.4rem, 3.5vw, 2.1rem);
  line-height: 1.15;
  color: inherit;
}

.cb-photo-banner--tall .cb-photo-banner__title {
  font-size: clamp(1.6rem, 5vw, 2.75rem);
}

.cb-photo-banner__subtitle {
  margin: var(--space-1, 0.25rem) 0 0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0.85;
}

.cb-photo-banner__body {
  margin: var(--space-3, 0.75rem) 0 0;
  line-height: 1.5;
}

.cb-photo-banner__link {
  margin-top: var(--space-4, 1rem);
}

.cb-photo-banner__pause {
  position: absolute;
  top: var(--space-3, 0.75rem);
  right: var(--space-3, 0.75rem);
  padding: var(--space-1, 0.25rem) var(--space-3, 0.75rem);
  border: 1px solid rgb(255 255 255 / 0.5);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.5);
  color: white;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.cb-photo-banner__pause:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

@media (max-width: 640px) {
  .cb-photo-banner--tall {
    min-height: clamp(280px, 55vh, 520px);
  }

  .cb-photo-banner--medium {
    min-height: clamp(220px, 40vh, 380px);
  }

  .cb-photo-banner__card {
    max-width: none;
    margin: var(--space-3, 0.75rem);
    padding: var(--space-4, 1rem);
  }
}

/* ---- Photo tiles ---- */
.cb-photo-tiles__title {
  margin: 0 0 var(--space-4, 1rem);
}

.cb-photo-tiles__list {
  display: grid;
  gap: var(--space-4, 1rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cb-photo-tiles--cols-2 .cb-photo-tiles__list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.cb-photo-tiles--cols-3 .cb-photo-tiles__list {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.cb-photo-tiles--cols-4 .cb-photo-tiles__list {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.cb-photo-tiles__tile {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 15rem;
  overflow: hidden;
  border-radius: var(--radius, 10px);
  background: var(--bg-elev-2);
}

.cb-photo-tiles__tile--no-image {
  border: 1px solid var(--border);
  background: var(--bg-elev);
}

.cb-photo-tiles__image {
  position: absolute;
  inset: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}

.cb-photo-tiles__tile:hover .cb-photo-tiles__image {
  transform: scale(1.04);
}

.cb-photo-tiles__copy {
  padding: var(--space-6, 1.5rem) var(--space-4, 1rem) var(--space-4, 1rem);
  background: linear-gradient(to top, rgb(0 0 0 / 0.8), rgb(0 0 0 / 0.5) 65%, rgb(0 0 0 / 0));
  color: white;
}

.cb-photo-tiles__tile--no-image .cb-photo-tiles__copy {
  background: none;
  color: var(--text);
}

.cb-photo-tiles__tile-title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.2;
  color: inherit;
}

.cb-photo-tiles__subtitle {
  margin: var(--space-1, 0.25rem) 0 0;
  font-weight: 600;
  opacity: 0.9;
}

.cb-photo-tiles__body {
  margin: var(--space-2, 0.5rem) 0 0;
  font-size: 0.95rem;
  line-height: 1.45;
}

.cb-photo-tiles__link {
  color: inherit;
  font-weight: 600;
}

.cb-photo-tiles__copy > .cb-photo-tiles__link {
  display: inline-block;
  margin-top: var(--space-2, 0.5rem);
}

/* The link's box covers the tile, so the whole tile is clickable. */
.cb-photo-tiles__link::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.cb-photo-tiles__tile:has(.cb-photo-tiles__link):hover .cb-photo-tiles__link {
  text-decoration: underline;
}

.cb-photo-tiles__link:focus-visible {
  outline: none;
}

.cb-photo-tiles__link:focus-visible::after {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@media (max-width: 900px) {
  .cb-photo-tiles--cols-3 .cb-photo-tiles__list,
  .cb-photo-tiles--cols-4 .cb-photo-tiles__list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .cb-photo-tiles .cb-photo-tiles__list {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ---- Photo gallery ---- */
.cb-photo-gallery--cols-2 { --cb-gallery-columns: 2; }
.cb-photo-gallery--cols-3 { --cb-gallery-columns: 3; }
.cb-photo-gallery--cols-4 { --cb-gallery-columns: 4; }
.cb-photo-gallery--cols-5 { --cb-gallery-columns: 5; }
.cb-photo-gallery--cols-6 { --cb-gallery-columns: 6; }

.cb-photo-gallery__title {
  margin: 0 0 var(--space-4, 1rem);
}

.cb-photo-gallery__list {
  display: grid;
  grid-template-columns: repeat(var(--cb-gallery-columns, 4), minmax(0, 1fr));
  gap: var(--space-2, 0.5rem);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cb-photo-gallery__link {
  display: block;
  overflow: hidden;
  border-radius: var(--radius-sm, 6px);
  background: var(--bg-elev-2);
}

.cb-photo-gallery__thumb {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.cb-photo-gallery__link:hover .cb-photo-gallery__thumb {
  transform: scale(1.04);
}

.cb-photo-gallery__link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cb-photo-gallery__caption {
  margin: var(--space-1, 0.25rem) 0 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-line;
}

/* Tablets show at most 3 columns and phones 2. */
@media (max-width: 900px) {
  .cb-photo-gallery--cols-4,
  .cb-photo-gallery--cols-5,
  .cb-photo-gallery--cols-6 {
    --cb-gallery-columns: 3;
  }
}

@media (max-width: 640px) {
  .cb-photo-gallery {
    --cb-gallery-columns: 2;
  }
}

/* ---- Photo lightbox (js/photo-lightbox.js) ---- */
html:has(.cb-photo-lightbox[open]) {
  overflow: hidden;
}

.cb-photo-lightbox {
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: var(--space-4, 1rem) var(--space-4, 1rem) var(--space-3, 0.75rem);
  border: 0;
  background: rgb(0 0 0 / 0.92);
  color: white;
}

.cb-photo-lightbox[open] {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  place-items: center;
}

.cb-photo-lightbox::backdrop {
  background: rgb(0 0 0 / 0.6);
}

.cb-photo-lightbox__figure {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 0;
  max-height: 100%;
  margin: 0;
}

.cb-photo-lightbox__image {
  display: block;
  min-height: 0;
  max-width: 100%;
  max-height: calc(100dvh - 9rem);
  object-fit: contain;
}

.cb-photo-lightbox__caption {
  max-width: 48rem;
  margin-top: var(--space-3, 0.75rem);
  line-height: 1.45;
  text-align: center;
  white-space: pre-line;
}

.cb-photo-lightbox__counter {
  margin: var(--space-2, 0.5rem) 0 0;
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
  opacity: 0.8;
}

.cb-photo-lightbox__button {
  position: absolute;
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 0.35);
  border-radius: 999px;
  background: rgb(0 0 0 / 0.5);
  color: white;
  font: inherit;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.cb-photo-lightbox__button:hover {
  background: rgb(0 0 0 / 0.8);
}

.cb-photo-lightbox__button:focus-visible {
  outline: 2px solid white;
  outline-offset: 2px;
}

.cb-photo-lightbox__close {
  top: var(--space-3, 0.75rem);
  right: var(--space-3, 0.75rem);
}

.cb-photo-lightbox__prev,
.cb-photo-lightbox__next {
  top: 50%;
  transform: translateY(-50%);
}

.cb-photo-lightbox__prev {
  left: var(--space-3, 0.75rem);
}

.cb-photo-lightbox__next {
  right: var(--space-3, 0.75rem);
}

@media (prefers-reduced-motion: reduce) {
  .cb-photo-banner__image,
  .cb-photo-tiles__image,
  .cb-photo-gallery__thumb {
    transition: none;
  }

  .cb-photo-tiles__tile:hover .cb-photo-tiles__image,
  .cb-photo-gallery__link:hover .cb-photo-gallery__thumb {
    transform: none;
  }
}
