/* The Safari photo essays share the typography and gutters of the route pages. */
.saf-gallery {
  width: 100%;
  max-width: var(--hub-max, 1240px);
  margin-inline: auto;
  padding: var(--hub-section-space, clamp(36px, 5vw, 76px)) var(--hub-pad, clamp(20px, 4vw, 48px));
  scroll-margin-top: 100px;
}

.saf-gallery > .section-title {
  margin: 0 0 clamp(18px, 2.6vw, 36px);
  color: var(--sand);
  font: 400 clamp(1.75rem, 3.8vw, 3.4rem)/1.08 'Playfair Display', serif;
  letter-spacing: -.015em;
}

.saf-photo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(0, 1fr);
  grid-auto-rows: clamp(144px, 21vw, 270px);
  gap: clamp(8px, 1.2vw, 16px);
  margin: 0;
  padding: 0;
  list-style: none;
}

.saf-photo-grid:not(.saf-photo-grid-more):has(> :nth-child(3)) > :first-child {
  grid-row: span 2;
}

.saf-photo-grid:not(.saf-photo-grid-more) > li:only-child {
  grid-column: 1 / -1;
}

.saf-photo-grid-more {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-auto-rows: clamp(144px, 18vw, 240px);
}

.saf-photo-more summary {
  width: fit-content;
  min-height: 44px;
  margin-block: 16px;
  padding-block: 10px;
  color: var(--gold-light);
  font-size: .95rem;
  cursor: pointer;
}

.saf-photo {
  position: relative;
  margin: 0;
  display: block;
  height: 100%;
  overflow: hidden;
  color: #fff;
  background: #262019;
  text-decoration: none;
}

.saf-photo picture {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
}

.saf-photo img {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.saf-photo-label {
  position: absolute;
  inset: auto 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px clamp(10px, 1.6vw, 20px);
  color: #fff;
  background: rgba(17, 15, 12, .84);
  font: 500 clamp(.8125rem, 1.3vw, 1rem)/1.3 'Source Sans 3', sans-serif;
}

.saf-photo-expand {
  flex: none;
  width: 15px;
  height: 15px;
  border: 1px solid currentColor;
  background: linear-gradient(currentColor, currentColor) center / 7px 1px,
    linear-gradient(currentColor, currentColor) center / 1px 7px;
  background-repeat: no-repeat;
}

.saf-photo-label [data-saf-caption] {
  min-width: 0;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .saf-photo-label [data-saf-caption] {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
}

.saf-photo:focus-visible,
.saf-photo-more summary:focus-visible,
.saf-photo-viewer button:focus-visible {
  outline: 2px solid var(--gold-light);
  outline-offset: 3px;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
  .saf-photo img {
    transition: transform .65s ease;
  }

  .saf-photo:not(.saf-photo-still):hover img {
    transform: scale(1.035);
  }
}

@media (max-width: 720px) {
  .saf-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-auto-rows: auto;
  }

  .saf-photo-grid:not(.saf-photo-grid-more):has(> :nth-child(3)) > :first-child {
    grid-column: 1 / -1;
    grid-row: auto;
  }

  .saf-photo { display: flex; flex-direction: column; }

  .saf-photo picture {
    height: auto;
    aspect-ratio: 5 / 4;
  }

  .saf-photo-grid:not(.saf-photo-grid-more) > li:first-child:nth-last-child(n+3) picture,
  .saf-photo-grid > li:only-child picture {
    aspect-ratio: 3 / 2;
  }

  .saf-photo-label {
    position: static;
    flex: 1;
    min-height: 44px;
  }

  .saf-photo-expand {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background-color: rgba(17, 15, 12, .84);
  }
}

.saf-photo-viewer:not([open]) { display: none; }

.saf-photo-viewer {
  position: fixed;
  inset: 0;
  width: min(1560px, calc(100% - 28px));
  max-width: none;
  max-height: calc(100% - 28px);
  margin: auto;
  padding: 0 clamp(10px, 2vw, 20px);
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid rgba(245, 237, 224, .22);
  background: #151310;
  color: var(--sand);
  color-scheme: dark;
}

.saf-photo-viewer::backdrop { background: rgba(10, 9, 8, .92); }

.saf-photo-toolbar,
.saf-photo-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 58px;
}

.saf-photo-toolbar p,
.saf-photo-status { margin: 0; }

.saf-photo-toolbar p {
  color: var(--gold-light);
  font-size: .79rem;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.saf-photo-viewer button {
  min-width: 44px;
  min-height: 44px;
  padding: 4px 10px;
  color: inherit;
  border: 1px solid rgba(245, 237, 224, .4);
  background: transparent;
  font: 600 .875rem/1.2 'Source Sans 3', sans-serif;
  cursor: pointer;
}

.saf-photo-viewer button span { font-size: 1.18rem; }
.saf-photo-viewer button:hover { border-color: var(--gold-light); }
.saf-photo-viewer button[hidden] { visibility: hidden; display: block; }

.saf-photo-stage {
  display: grid;
  place-items: center;
  min-height: clamp(112px, 56vh, 620px);
  min-height: min(clamp(112px, 56dvh, 620px), max(112px, calc(100dvh - 172px)));
  background: #100f0d;
}

.saf-photo-stage img {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: max(112px, calc(100vh - 172px));
  max-height: max(112px, calc(100dvh - 172px));
  object-fit: contain;
}

.saf-photo-status {
  text-align: center;
  line-height: 1.3;
  padding-block: 8px;
}

[data-saf-photo-count] {
  display: block;
  color: var(--gold-light);
  font-size: .82rem;
  font-variant-numeric: tabular-nums;
}

html.saf-photo-lock { overflow: hidden; }

@media (prefers-reduced-motion: no-preference) {
  .saf-photo-viewer[open] { animation: saf-photo-in .22s ease-out; }

  @keyframes saf-photo-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
