/* ==========================================================================
   Himalayan Trails — photograph viewer

   Full-bleed dark stage, the photograph as the only bright thing on screen, and
   controls that stay out of its way until you look for them.
   ========================================================================== */

.ht-lightbox {
  position: fixed;
  inset: 0;
  z-index: var(--ht-z-drawer);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-rows: auto minmax(0, 1fr) auto;
  grid-template-areas:
    "bar   bar   bar"
    "prev  stage next"
    "cap   cap   cap";
  align-items: center;
  gap: var(--ht-space-3);
  padding: var(--ht-space-4);
  background: rgb(7 14 11 / 0.94);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity var(--ht-duration-base) var(--ht-ease);
}

.ht-lightbox[data-open="true"] {
  opacity: 1;
}

/* ---- Bar ----------------------------------------------------------------- */

.ht-lightbox__bar {
  grid-area: bar;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ht-space-4);
}

.ht-lightbox__counter {
  font-size: var(--ht-text-sm);
  font-weight: 600;
  letter-spacing: var(--ht-tracking-caps);
  text-transform: uppercase;
  color: rgb(242 239 232 / 0.7);
  font-variant-numeric: tabular-nums;
}

.ht-lightbox__tools {
  display: flex;
  gap: var(--ht-space-2);
}

.ht-lightbox__btn {
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.16);
  color: var(--ht-text-inverse);
  transition: background-color var(--ht-duration-fast) var(--ht-ease), border-color var(--ht-duration-fast) var(--ht-ease);
}

.ht-lightbox__btn:hover {
  background: rgb(255 255 255 / 0.12);
  border-color: rgb(255 255 255 / 0.32);
}

.ht-lightbox__btn[aria-pressed="true"] {
  background: var(--ht-clay-600);
  border-color: var(--ht-clay-600);
}

.ht-lightbox__btn svg {
  width: 1.25rem;
  height: 1.25rem;
}

/* ---- Stage --------------------------------------------------------------- */

.ht-lightbox__stage {
  grid-area: stage;
  /*
   * The photograph is positioned against this box rather than sized by it.
   * A percentage max-height on the image cannot resolve against a grid track
   * that is itself sized by its content, so the picture overflowed and was
   * clipped by the stage instead of being letterboxed inside it.
   */
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.ht-lightbox__img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  /* `contain` letterboxes the photograph, and the global img placeholder colour
     was painting those bars pale on the dark stage. */
  background: transparent;
  border-radius: var(--ht-radius-sm);
  box-shadow: 0 30px 80px -30px rgb(0 0 0 / 0.8);
  /* Only the transform animates, so panning a zoomed photograph stays smooth. */
  transition: transform var(--ht-duration-base) var(--ht-ease-out), opacity var(--ht-duration-fast) linear;
  cursor: zoom-in;
}

.ht-lightbox[data-zoomed="true"] .ht-lightbox__img {
  cursor: grab;
  /* Panning follows the pointer, so it must not lag behind it. */
  transition: opacity var(--ht-duration-fast) linear;
}

.ht-lightbox[data-zoomed="true"] .ht-lightbox__img:active {
  cursor: grabbing;
}

.ht-lightbox[data-loading="true"] .ht-lightbox__img {
  opacity: 0.35;
}

/* ---- Navigation ---------------------------------------------------------- */

.ht-lightbox__nav {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  border: 1px solid rgb(255 255 255 / 0.16);
  background: rgb(11 22 17 / 0.5);
  color: var(--ht-text-inverse);
  transition: background-color var(--ht-duration-fast) var(--ht-ease), transform var(--ht-duration-fast) var(--ht-ease);
}

.ht-lightbox__nav:hover {
  background: rgb(255 255 255 / 0.16);
}

.ht-lightbox__nav:active {
  transform: scale(0.94);
}

.ht-lightbox__nav svg {
  width: 1.5rem;
  height: 1.5rem;
}

.ht-lightbox__nav--prev {
  grid-area: prev;
}

.ht-lightbox__nav--prev svg {
  /* One arrow glyph, mirrored — no second icon to keep in step with the first. */
  transform: scaleX(-1);
}

.ht-lightbox__nav--next {
  grid-area: next;
}

/* ---- Caption ------------------------------------------------------------- */

.ht-lightbox__caption {
  grid-area: cap;
  max-width: 60ch;
  margin-inline: auto;
  padding-block: var(--ht-space-2);
  text-align: center;
  font-size: var(--ht-text-base);
  line-height: var(--ht-leading-normal);
  color: rgb(242 239 232 / 0.78);
}

/* ---- Phones -------------------------------------------------------------
   The arrows move below the photograph: at 375px a pair of side buttons eats a
   third of the width the picture should be using. */
@media (max-width: 47.9375rem) {
  .ht-lightbox {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr) auto auto;
    grid-template-areas:
      "bar"
      "stage"
      "cap"
      "prev";
    padding: var(--ht-space-3);
  }

  .ht-lightbox__nav--prev,
  .ht-lightbox__nav--next {
    grid-area: prev;
  }

  /* Both arrows share the final row, side by side and centred. */
  .ht-lightbox__nav--prev {
    justify-self: center;
    translate: -2.5rem 0;
  }

  .ht-lightbox__nav--next {
    justify-self: center;
    translate: 2.5rem 0;
  }

  .ht-lightbox__caption {
    font-size: var(--ht-text-sm);
  }
}

@media (prefers-reduced-motion: reduce) {
  .ht-lightbox,
  .ht-lightbox__img {
    transition: none;
  }
}
