/* Gallery page: highlights strip, album tabs, photo grid and full-screen viewer.
   Uses the colour and font tokens defined on the page's :root. */

/* ---------- Highlights strip ---------- */
.highlights {
  padding-inline: 0;
  padding-top: clamp(16px, 3vh, 32px);
  padding-bottom: clamp(8px, 2vh, 20px);
}

.highlights[hidden] {
  display: none;
}

.strip {
  width: 100%;
  display: flex;
  gap: clamp(10px, 2vw, 18px);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 16px;
  padding: 14px 16px 16px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.strip::-webkit-scrollbar {
  display: none;
}

/* Mouse users get a thin gold scrollbar so they can tell the strip scrolls */
@media (hover: hover) and (pointer: fine) {
  .strip {
    scrollbar-width: thin;
    scrollbar-color: rgba(232, 200, 120, .45) transparent;
  }

  .strip::-webkit-scrollbar {
    display: block;
    height: 6px;
  }

  .strip::-webkit-scrollbar-thumb {
    background: rgba(232, 200, 120, .45);
    border-radius: 3px;
  }
}

/* Centre the strip when it doesn't fill the screen */
.strip::before,
.strip::after {
  content: "";
  flex: 1 0 0;
}

.hl {
  position: relative;
  flex: 0 0 auto;
  height: min(62svh, 520px);
  aspect-ratio: var(--ar, 2 / 3);
  max-width: 82vw;
  scroll-snap-align: center;
  border: 0;
  padding: 0;
  cursor: zoom-in;
  background: var(--c, #1a1712);
  outline: 1px solid var(--line-faint);
  outline-offset: 5px;
  transition: outline-color .3s;
}

.hl:hover,
.hl:focus-visible {
  outline-color: var(--gold-3);
}

.hl img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ---------- Videos ---------- */
.films {
  padding-top: clamp(16px, 3vh, 32px);
  padding-bottom: clamp(8px, 2vh, 20px);
}

.films[hidden] {
  display: none;
}

.film-grid {
  width: min(1240px, 100%);
  margin-top: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(20px, 3vw, 30px);   /* room for each card's outline (offset 5px) */
}

/* Each card keeps its video's shape, as wide as fits but never taller than about half the screen */
.film {
  position: relative;
  width: min(100%, calc(min(56svh, 460px) * var(--arn, 1.778)));
  aspect-ratio: var(--ar, 16 / 9);
  border: 0;
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  background: var(--c, #1a1712);
  outline: 1px solid var(--line-faint);
  outline-offset: 5px;
  transition: outline-color .3s;
}

.film:hover,
.film:focus-visible {
  outline-color: var(--gold-3);
}

.film img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity .6s var(--ease), transform .8s var(--ease);
}

.film img.loaded {
  opacity: 1;
}

.film:hover img {
  transform: scale(1.03);
}

.film-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  color: var(--gold-4);
  background: rgba(11, 10, 8, .55);
  border: 1px solid var(--gold-3);
  border-radius: 50%;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  transition: transform .3s var(--ease), background .3s;
}

.film-play svg {
  width: 24px;
  height: 24px;
  margin-left: 3px;
  fill: currentColor;
}

.film:hover .film-play,
.film:focus-visible .film-play {
  transform: scale(1.08);
  background: rgba(36, 30, 16, .85);
}

.film-time {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 5px 8px;
  border-radius: 3px;
  font: 500 12px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #f4ead5;
  background: rgba(10, 9, 7, .62);
  font-variant-numeric: tabular-nums;
}

/* ---------- Gallery ---------- */
.gallery {
  padding-top: clamp(16px, 3vh, 32px);
  padding-bottom: clamp(16px, 3vh, 32px);
}

.gallery-lede {
  font-size: clamp(17px, .6vw + 14px, 20px);
  color: var(--ink-dim);
  margin-top: 4px;
}

.tabs {
  display: inline-flex;
  margin: 26px auto 0;
  border: 1px solid var(--line);
  padding: 4px;
  gap: 4px;
}

.tabs[hidden] {
  display: none;
}

.tab {
  font-family: var(--caps);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--ink-dim);
  background: transparent;
  border: 0;
  padding: 11px 16px 10px 19px;
  min-height: 44px;
  cursor: pointer;
  transition: color .3s, background .3s;
}

.tab span {
  font-family: var(--serif);
  font-size: 15px;
  letter-spacing: 0;
  opacity: .75;
  margin-left: 6px;
}

.tab:hover,
.tab:focus-visible {
  color: var(--gold-4);
  outline: none;
}

.tab[aria-selected="true"] {
  color: var(--bg);
  background: var(--gold-3);
}

/* Phones: two equal tabs across the width, photo count under the name, so names stay on one line */
@media (max-width: 480px) {
  .tabs {
    display: flex;
    width: 100%;
    max-width: 400px;
  }

  .tabs[hidden] {
    display: none;
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    padding: 9px 6px 8px;
    font-size: clamp(10px, 3.1vw, 12px);
    letter-spacing: .1em;
    line-height: 1.3;
    white-space: nowrap;
  }

  .tab span {
    display: block;
    margin: 2px 0 0;
    font-size: 14px;
  }
}

.tab[aria-selected="true"] span {
  opacity: .7;
}

.grid {
  width: min(1240px, 100%);
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

@media (min-width: 640px) {
  .grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
}

@media (min-width: 1024px) {
  .grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
}

.tile {
  position: relative;
  aspect-ratio: 2 / 3;
  overflow: hidden;
  background: var(--c, #1a1712);
}

.tile-open {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  padding: 0;
  background: none;
  cursor: zoom-in;
}

/* File name + copy button (Raw album) */
.tile-name {
  position: absolute;
  right: 6px;
  bottom: 6px;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  max-width: calc(100% - 12px);
  padding: 6px 9px;
  border: 0;
  border-radius: 3px;
  font: 500 11.5px/1 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: .02em;
  color: #f4ead5;
  background: rgba(10, 9, 7, .62);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  cursor: copy;
  transition: background .2s, color .2s;
}

.tile-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-name svg {
  flex: none;
  opacity: .85;
}

.tile-name:hover {
  background: rgba(10, 9, 7, .82);
}

.tile-name.copied {
  color: var(--bg);
  background: var(--gold-3);
}

.tile-name:focus-visible {
  outline: 2px solid var(--gold-3);
  outline-offset: 2px;
}

.tile img,
.hl img {
  opacity: 0;
  transition: opacity .6s var(--ease), transform .8s var(--ease);
}

.tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile img.loaded,
.hl img.loaded {
  opacity: 1;
}

.tile:hover img {
  transform: scale(1.035);
}

.tile-open:focus-visible {
  outline: 2px solid var(--gold-3);
  outline-offset: -2px;
}

/* Grey shimmer while photos.json loads */
.tile.skeleton {
  cursor: default;
  background: linear-gradient(100deg, #15130f 30%, #221e17 50%, #15130f 70%);
  background-size: 300% 100%;
  animation: skel 1.6s ease-in-out infinite;
}

@keyframes skel {
  from {
    background-position: 100% 0
  }

  to {
    background-position: 0 0
  }
}

.sentinel {
  height: 1px;
}

.status {
  margin-top: 18px;
  min-height: 1.5em;
  color: var(--ink-dim);
  font-size: 17px;
}

.status:empty {
  display: none;
}

.status button {
  font: inherit;
  color: var(--gold-3);
  background: none;
  border: 0;
  text-decoration: underline;
  cursor: pointer;
}

/* ---------- Full-screen viewer ---------- */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #060504;
  display: grid;
  grid-template-rows: auto 1fr;
  touch-action: none;
  opacity: 0;
  transition: opacity .25s ease;
}

.viewer[hidden] {
  display: none;
}

.viewer.open {
  opacity: 1;
}

.v-bar {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
}

.v-count {
  font-family: var(--caps);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .2em;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.v-actions {
  display: flex;
  gap: 8px;
}

.v-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  font-family: var(--caps);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--gold-4);
  background: rgba(232, 200, 120, .1);
  border: 1px solid var(--line);
  cursor: pointer;
  transition: background .25s, border-color .25s;
}

.v-btn:hover,
.v-btn:focus-visible {
  background: rgba(232, 200, 120, .2);
  border-color: var(--gold-4);
  outline: none;
}

.v-btn svg,
.v-nav svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.v-icon {
  width: 42px;
  padding: 0;
  justify-content: center;
}

.v-stage {
  position: relative;
  overflow: hidden;
  display: grid;
  place-items: center;
  padding: 0 0 max(12px, env(safe-area-inset-bottom));
}

/* gallery.js sets each image's width/height so both layers line up */
.v-stage img {
  grid-area: 1 / 1;
  position: relative; /* explicit stacking: the blurred layer must stay under the sharp one */
  max-width: none;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  transition: opacity .35s ease;
}

/* Thumbnail stretched underneath while the sharp version loads */
.v-low {
  z-index: 0;
  filter: blur(6px);
}

.v-img {
  z-index: 1;
  opacity: 0;
}

.v-img.loaded {
  opacity: 1;
}

.v-stage.dragging img {
  transition: none;
}

/* Video in the viewer: replaces the two photo layers */
.v-video {
  grid-area: 1 / 1;
  position: relative;
  z-index: 1;
  max-width: none;
  background: #000;
}

.v-video[hidden],
.viewer.is-video .v-low,
.viewer.is-video .v-img {
  display: none;
}

.v-nav {
  position: absolute;
  top: 50%;
  z-index: 2;
  width: 52px;
  height: 52px;
  margin-top: -26px;
  display: grid;
  place-items: center;
  color: var(--gold-4);
  background: rgba(11, 10, 8, .55);
  border: 1px solid var(--line-faint);
  border-radius: 50%;
  cursor: pointer;
  transition: background .25s, border-color .25s, opacity .25s;
}

.v-nav:hover,
.v-nav:focus-visible {
  background: rgba(36, 30, 16, .9);
  border-color: var(--gold-3);
  outline: none;
}

.v-nav:disabled {
  opacity: 0;
  pointer-events: none;
}

.v-prev {
  left: max(12px, env(safe-area-inset-left));
}

.v-next {
  right: max(12px, env(safe-area-inset-right));
}

/* On phones people swipe, so keep the arrows small and out of the way */
@media (hover: none) and (max-width: 720px) {
  .v-nav {
    width: 40px;
    height: 40px;
    margin-top: -20px;
    background: rgba(11, 10, 8, .35);
  }
}

@media (max-width: 380px) {
  .v-btn span {
    display: none;
  }

  .v-btn {
    width: 42px;
    padding: 0;
    justify-content: center;
  }

  /* Keep the percentage visible while downloading */
  .v-btn.busy {
    width: auto;
    min-width: 96px;
    padding: 0 12px;
  }

  .v-btn.busy span {
    display: inline;
  }

  .v-btn.busy svg {
    display: none;
  }
}

/* ---------- Download progress (fills the Download button) ---------- */
.v-btn.busy {
  --p: 0%;
  background: linear-gradient(90deg, rgba(232, 200, 120, .42) var(--p), rgba(232, 200, 120, .08) var(--p));
  border-color: var(--gold-3);
  font-variant-numeric: tabular-nums;
  min-width: 132px;
  justify-content: center;
}

.v-btn.done {
  border-color: #7fcf9a;
  color: #c8f2d4;
}

/* ---------- Download size menu ---------- */
.dl-wrap {
  position: relative;
}

.dl-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 3;
  width: min(280px, calc(100vw - 28px));
  padding: 6px;
  display: grid;
  gap: 6px;
  background: #14110c;
  border: 1px solid var(--line);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .6);
  animation: menuIn .18s ease;
}

.dl-menu[hidden] {
  display: none;
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.dl-opt {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  text-decoration: none;
  background: rgba(232, 200, 120, .06);
  border: 1px solid var(--line-faint);
  transition: background .25s, border-color .25s;
}

.dl-opt:hover,
.dl-opt:focus-visible {
  background: rgba(232, 200, 120, .14);
  border-color: var(--gold-3);
  outline: none;
}

.dl-opt-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.dl-opt-title {
  font-family: var(--caps);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--gold-4);
}

.dl-opt-size {
  font-size: 15px;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.dl-opt-sub {
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.3;
  color: var(--ink-dim);
}

/* ---------- Share card ---------- */
.sheet {
  position: absolute;
  z-index: 3;
  left: 50%;
  bottom: 0;
  width: min(520px, 100%);
  transform: translate(-50%, 0);
  padding: 22px 18px max(18px, env(safe-area-inset-bottom));
  background: #14110c;
  border: 1px solid var(--line);
  border-bottom: 0;
  box-shadow: 0 -18px 50px rgba(0, 0, 0, .6);
  text-align: center;
  touch-action: manipulation;
  animation: sheetUp .35s var(--ease);
}

.sheet[hidden] {
  display: none;
}

@keyframes sheetUp {
  from {
    transform: translate(-50%, 100%)
  }
}

.sheet::before {
  content: "";
  position: absolute;
  inset: 5px 5px 0;
  border: 1px solid var(--line-faint);
  border-bottom: 0;
  pointer-events: none;
}

.sheet-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: var(--ink-dim);
  background: none;
  border: 0;
  cursor: pointer;
}

.sheet-close svg,
.sheet .btn svg,
.share svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sheet-title {
  font-family: var(--caps);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--gold-4);
  padding: 0 36px;
}

.sheet-sub {
  margin-top: 2px;
  font-size: 16px;
  color: var(--ink-dim);
  overflow-wrap: anywhere;
}

.sheet .sheet-save {
  margin-top: 16px;
  width: 100%;
}

.sheet-label {
  margin-top: 18px;
  font-family: var(--caps);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .24em;
  text-transform: uppercase;
  color: var(--gold-3);
}

.share-grid {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.share {
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 6px;
  min-height: 78px;
  padding: 10px 4px;
  font-family: var(--serif);
  font-size: 15px;
  line-height: 1.2;
  color: var(--ink);
  background: rgba(232, 200, 120, .06);
  border: 1px solid var(--line-faint);
  cursor: pointer;
  transition: background .25s, border-color .25s;
}

.share[hidden] {
  display: none;
}

.share svg {
  width: 24px;
  height: 24px;
  color: var(--gold-3);
}

.share:hover,
.share:focus-visible {
  background: rgba(232, 200, 120, .14);
  border-color: var(--gold-3);
  outline: none;
}

.sheet-hint {
  margin-top: 12px;
  font-size: 15px;
  line-height: 1.45;
  color: var(--ink-dim);
}

.sheet-hint[hidden] {
  display: none;
}

/* ---------- Toast ---------- */
.toast {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: calc(64px + env(safe-area-inset-top));
  transform: translate(-50%, -8px);
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  font-size: 16px;
  color: var(--bg);
  background: var(--gold-3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {

  .sheet,
  .dl-menu {
    animation: none;
  }

  .tile img,
  .hl img,
  .film img,
  .film-play,
  .v-stage img,
  .viewer {
    transition: none;
  }

  .tile:hover img,
  .film:hover img,
  .film:hover .film-play {
    transform: none;
  }

  .tile.skeleton {
    animation: none;
  }
}
