/* Compact viewer chrome gives the scene more room and the photo collection emphasis. */
:root { --viewer-header: 48px; }
.viewer-header {
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  padding-inline: max(14px, env(safe-area-inset-left, 0px)) max(14px, env(safe-area-inset-right, 0px));
  box-shadow: 0 2px 10px #00000020;
}
.viewer-header .back-button,
.viewer-header .fullscreen-button,
.photo-gallery-open { height: 36px; min-height: 36px; border-radius: 7px; }
.viewer-header .back-button {
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid #aabacb30;
  background: #142535;
  box-shadow: none;
  color: #d4dee5;
  font-size: 11px;
  font-weight: 500;
}
.viewer-header .back-button .control-icon { width: 14px; height: 14px; }
.viewer-header .fullscreen-button { width: 36px; padding: 9px; background: #122334; }
.viewer-header .fullscreen-button svg { width: 16px; height: 16px; }
.photo-gallery-open {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 11px;
  border: 1px solid #ead7b4;
  background: linear-gradient(145deg, #ead8b6, #c7a775);
  box-shadow: inset 0 1px 0 #fff7e555;
  color: #14202d;
  font-size: 11px;
  font-weight: 650;
  white-space: nowrap;
}
.photo-gallery-open .control-icon { width: 16px; height: 16px; }
.photo-gallery-count { color: #48515b; font-size: 10px; padding-left: 7px; border-left: 1px solid #23344740; }
.photo-label-short { display: none; }
.loading p { text-wrap: balance; }
.loading-project-detail { display: block; margin-top: 8px; white-space: nowrap; font-family: var(--sans); font-size: 13px; line-height: 1.5; color: #b7c4cf; letter-spacing: .4px; }
.project-gallery-note { margin: 14px 0 0; color: #cfbd9d; font-size: 11px; line-height: 1.65; }

/* The collection fits its image, rather than leaving a tall empty stage on phones. */
.photo-gallery {
  width: min(1100px, calc(100vw - 32px), calc((100dvh - 284px) * 16 / 9 + 32px));
  height: fit-content;
  max-width: none;
  max-height: calc(100dvh - 32px);
  inset: 0;
  margin: auto;
  padding: 0;
  border: 1px solid #aebdcb42;
  border-radius: 14px;
  background: #0b1825;
  color: #f1ede5;
  box-shadow: 0 22px 100px #0009;
  overflow: auto;
  overscroll-behavior: contain;
}
.photo-gallery::backdrop { background: #02070ebd; backdrop-filter: blur(7px); }
.photo-gallery-shell { display: flex; flex-direction: column; width: 100%; padding: 16px 16px 12px; }
.photo-gallery-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex: none; margin-bottom: 12px; }
.photo-gallery-eyebrow { color: #ccb790; font-size: 9px; line-height: 1.4; letter-spacing: 1.4px; margin: 0 0 5px; }
.photo-gallery-header h2 { margin: 0; font: 400 28px/1.1 var(--serif); }
.photo-gallery-subtitle { color: #acbdcb; font-size: 11px; line-height: 1.5; margin: 4px 0 0; }
.photo-icon-button {
  flex: none;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 12px;
  border: 1px solid #b8c7d336;
  border-radius: 50%;
  background: #142537;
  color: #e1cfad;
}
.photo-icon-button svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.photo-gallery-figure { flex: none; min-width: 0; margin: 0; }
.photo-gallery-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #102031;
  border-radius: 7px;
  touch-action: pan-y pinch-zoom;
  user-select: none;
}
.photo-gallery-image { display: block; position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.photo-gallery-enlarge {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  min-height: 0;
  border: 0;
  border-radius: inherit;
  padding: 12px;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  background: transparent;
  color: #f2e7d3;
  cursor: zoom-in;
  touch-action: pan-y pinch-zoom;
}
.photo-gallery-enlarge:disabled { visibility: hidden; }
.photo-gallery-enlarge > span { display: inline-flex; align-items: center; gap: 7px; padding: 8px 11px; border: 1px solid #e5d3ae66; border-radius: 20px; background: #091724dc; box-shadow: 0 2px 12px #0003; font-size: 10px; line-height: 1.4; }
.photo-gallery-enlarge svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.photo-gallery-enlarge:focus-visible { outline-offset: -4px !important; }
.photo-gallery-status { position: relative; max-width: 280px; margin: 0; padding: 14px; border-radius: 6px; background: #0a1724d9; text-align: center; color: #c2cfda; font-size: 11px; line-height: 1.65; }
.photo-gallery-caption { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 10px 1px 2px; }
#photo-gallery-view { font-size: 12px; line-height: 1.5; color: #e7dece; }
#photo-gallery-position { flex: none; color: #acbccc; font-size: 10px; letter-spacing: 1px; }
.photo-gallery-navigation { flex: none; display: flex; justify-content: center; align-items: center; gap: 16px; margin-top: 6px; }
.photo-gallery-pages { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 4px; min-width: 0; }
.photo-gallery-page { display: grid; place-items: center; width: 44px; height: 44px; min-height: 44px; border: 0; border-radius: 50%; background: transparent; color: #a8b7c4; font-size: 11px; }
.photo-gallery-page[aria-current='true'] { background: #ddc298; color: #132132; }
.photo-gallery-note { flex: none; max-width: 720px; margin: 10px auto 0; text-align: center; color: #9aabba; font-size: 10px; line-height: 1.65; text-wrap: balance; }
.photo-gallery button:focus-visible,
.photo-gallery-open:focus-visible { outline: 2px solid #ddc298; outline-offset: 2px; }

/* The enlarged image uses the viewport, with the close control on the image.
   Its frame remains 16:9 and never crops the generated composition. */
.photo-lightbox {
  width: min(calc(100vw - 24px), calc((100dvh - 104px) * 16 / 9));
  height: fit-content;
  max-width: none;
  max-height: calc(100dvh - 24px);
  inset: 0;
  margin: auto;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: #07121e;
  color: #f1ede5;
  box-shadow: 0 24px 120px #000b;
  overflow: auto;
  overscroll-behavior: contain;
}
.photo-lightbox::backdrop { background: #02060cf0; }
.photo-lightbox-figure { margin: 0; }
.photo-lightbox-stage { position: relative; display: grid; place-items: center; width: 100%; aspect-ratio: 16 / 9; background: #102031; overflow: hidden; touch-action: pan-y pinch-zoom; user-select: none; }
.photo-lightbox-image { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: contain; }
.photo-lightbox-close { position: absolute; z-index: 2; top: 10px; right: 10px; background: #07121ee6; border-color: #f5e5c8a6; color: #fff4dd; box-shadow: 0 2px 15px #0005; }
.photo-lightbox-caption { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 10px 14px; font-size: 12px; line-height: 1.5; }
.photo-lightbox-caption small { display: block; margin-top: 2px; color: #9aabba; font-size: 10px; }
.photo-lightbox-navigation { display: inline-flex; flex: none; align-items: center; gap: 14px; }
#photo-lightbox-position { color: #c4cfd8; font-size: 10px; letter-spacing: 1px; white-space: nowrap; }
.photo-lightbox button:focus-visible { outline: 2px solid #ddc298; outline-offset: -4px; }
@media (hover: hover) {
  .viewer-header .back-button:hover,.photo-icon-button:hover { border-color: #d9bd8e88; background: #1d3245; }
  .photo-gallery-open:hover { border-color: #f3e4c8; background: #ecd9b6; color: #14202d; }
  .photo-gallery-page:hover { color: #eddfc6; background: #1d3245; }
  .photo-gallery-page[aria-current='true']:hover { background: #e5cca4; color: #132132; }
  .photo-gallery-enlarge:hover > span { background: #142b3eea; border-color: #f1ddbc; }
  .photo-lightbox-close:hover { background: #152b3fea; border-color: #fff4dd; }
}
@media (max-width: 600px) {
  .viewer-header { gap: 8px; padding-inline: max(10px, env(safe-area-inset-left, 0px)) max(10px, env(safe-area-inset-right, 0px)); }
  .viewer-header .back-button { padding-inline: 9px; font-size: 11px; }
  .viewer-header .back-label-long,.photo-label-long { display: none; }
  .viewer-header .back-label-short,.photo-label-short { display: inline; }
  .photo-gallery-open { padding-inline: 10px; gap: 6px; }
  .photo-gallery-count { padding-left: 6px; }
  .photo-gallery { width: calc(100vw - 20px); max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); border-radius: 12px; }
  .photo-gallery-shell { padding: 14px 12px 12px; }
  .photo-gallery-header { margin-bottom: 12px; gap: 12px; }
  .photo-gallery-header h2 { font-size: 26px; }
  .photo-gallery-eyebrow { font-size: 8px; }
  .photo-gallery-navigation { justify-content: center; gap: 32px; margin-top: 5px; }
  .photo-gallery-pages { display: none; }
  .photo-gallery-note { font-size: 10px; margin-top: 9px; }
  .project-gallery-note { font-size: 12px; }
  .photo-lightbox { width: 100vw; max-height: calc(100dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); border-radius: 0; }
  .photo-lightbox-close { top: 8px; right: 8px; }
  .photo-lightbox-caption { align-items: flex-start; gap: 8px; padding: 10px 12px; font-size: 11px; }
  .photo-lightbox-caption small { max-width: 190px; font-size: 9px; }
  .photo-lightbox-navigation { gap: 4px; }
  #photo-lightbox-position { font-size: 9px; letter-spacing: .4px; }
}
@media (max-height: 450px) and (orientation: landscape) {
  .photo-gallery {
    width: min(1100px, calc(100vw - 24px), calc((100dvh - 72px) * 16 / 9 + 252px));
    max-height: calc(100dvh - 16px);
    border-radius: 10px;
  }
  .photo-gallery-shell { padding: 12px 16px; display: grid; grid-template-columns: minmax(0,1fr) 204px; grid-template-rows: auto 1fr auto; gap: 4px 16px; }
  .photo-gallery-header { grid-column: 2; grid-row: 1; margin-bottom: 0; gap: 8px; }
  .photo-gallery-header h2 { font-size: 23px; }
  .photo-gallery-eyebrow { font-size: 7px; letter-spacing: 1px; }
  .photo-gallery-subtitle { font-size: 10px; }
  .photo-gallery-figure { grid-column: 1; grid-row: 1 / 4; align-self: center; }
  .photo-gallery-caption { padding-top: 7px; }
  .photo-gallery-navigation { grid-column: 2; grid-row: 2; align-self: center; justify-content: center; gap: 28px; margin: 0; }
  .photo-gallery-pages { display: none; }
  .photo-gallery-note { grid-column: 2; grid-row: 3; margin: 0; font-size: 9px; line-height: 1.5; }
  .photo-lightbox { width: min(calc(100vw - 16px), calc((100dvh - 76px) * 16 / 9)); max-height: calc(100dvh - 12px); }
  .photo-lightbox-caption { padding: 6px 10px; }
}
@media (prefers-reduced-motion: reduce) {
  .photo-gallery,.photo-gallery-open,.photo-icon-button { scroll-behavior: auto; transition: none; }
}
