/* Keep the approved palette when a browser supports opting out of auto-darkening.
   This does not disable OS accessibility colour filters or browser page zoom. */
:root { color-scheme: only light; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Intrinsic labels: narrow screens and enlarged text must not overflow the tabs. */
@media (max-width: 760px) {
  html .repertoire-page .repertoire-intro {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: start;
    gap: 26px;
    padding: 32px 0 8px;
    min-height: 0;
    height: auto;
  }
  .repertoire-page .media-title {
    display: block;
    min-width: 0;
  }
  .repertoire-page .media-title .eyebrow { margin-bottom: 18px; }
  .repertoire-page .media-title h1 {
    font-size: clamp(42px, 12.4vw, 72px);
    line-height: 1.05;
    overflow-wrap: anywhere;
  }
  .repertoire-page .repertoire-controls {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
    transform: none;
  }
  .repertoire-page .control-reserve { display: none; }
  .repertoire-page .repertoire-tabs {
    display: grid;
    grid-template-columns: minmax(0, .8fr) minmax(0, 1fr) minmax(0, 1.4fr);
    align-items: stretch;
    gap: 8px;
    width: 100%;
    height: auto;
    min-height: 0;
  }
  html .repertoire-page .repertoire-tab {
    min-width: 0;
    min-height: 54px;
    height: auto;
    margin: 0;
    padding: 13px 6px 17px;
    font-size: clamp(13px, 3.7vw, 18px);
    line-height: 1.3;
    white-space: normal;
    text-align: center;
    overflow-wrap: anywhere;
    hyphens: none;
    align-self: stretch;
  }
  .repertoire-page .tab-label { min-width: 0; max-width: 100%; }
  .repertoire-page .catalogue-frame { margin-top: 0; }
}

/* Both photo viewers use the actual available height, not width-only breakpoints. */
html #lightbox,
html .photo-lightbox {
  position: fixed;
  inset: 0;
  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  background: #131313;
  color: #F3EDE2;
  color-scheme: dark;
}
html .photo-lightbox[open] { display: block; }
#lightbox .lb-shell,
.photo-lightbox .js-photo-shell {
  --viewer-edge: 20px;
  --viewer-control: 44px;
  box-sizing: border-box;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  align-content: stretch;
  gap: 10px;
  width: 100%;
  height: 100%;
  min-height: 0;
  min-width: 0;
  padding: max(var(--viewer-edge), env(safe-area-inset-top))
           max(var(--viewer-edge), env(safe-area-inset-right))
           max(var(--viewer-edge), env(safe-area-inset-bottom))
           max(var(--viewer-edge), env(safe-area-inset-left));
}
#lightbox .lb-top,
.photo-lightbox .js-photo-top {
  position: static;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  min-width: 0;
  min-height: var(--viewer-control);
}
.photo-lightbox .photo-lightbox-title {
  position: static;
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
#lightbox .lb-top .meta { overflow-wrap: anywhere; }
html .photo-lightbox .photo-close,
html .photo-lightbox .photo-navigation,
html .photo-lightbox .photo-navigation .photo-lightbox-control {
  position: relative;
  inset: auto;
  margin: 0;
}
html .photo-lightbox .photo-close,
html .photo-lightbox .photo-navigation .photo-lightbox-control,
html #lightbox .lb-button {
  width: var(--viewer-control);
  height: var(--viewer-control);
  min-width: var(--viewer-control);
  min-height: var(--viewer-control);
}
#lightbox .lb-bottom,
.photo-lightbox .js-photo-bottom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 12px 24px;
  min-height: var(--viewer-control);
  min-width: 0;
}
html .photo-lightbox .photo-lightbox-meta {
  width: auto;
  max-width: none;
  margin: 0;
  min-width: 0;
  min-height: 0;
  text-align: left;
  align-items: flex-start;
  justify-content: flex-end;
  gap: 4px;
}
.photo-lightbox .photo-lightbox-caption {
  max-height: 4.8em;
  overflow: auto;
  overflow-wrap: anywhere;
}
html .photo-lightbox .photo-exif {
  justify-content: flex-start;
  flex-wrap: wrap;
  gap: 4px 16px;
  font-size: 10px;
  text-align: left;
}
.photo-exif div { white-space: nowrap; }
html .photo-lightbox .photo-navigation,
html #lightbox .lb-controls {
  display: grid;
  grid-template-columns: var(--viewer-control) 64px var(--viewer-control);
  gap: 8px;
  align-items: center;
  justify-self: end;
  grid-column: 2;
}
html #lightbox .lb-position { min-width: 64px; width: 64px; }
html #lightbox .lb-image-area,
html .photo-lightbox .photo-lightbox-stage {
  display: block;
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: contain;
}
.js-photo-object {
  position: absolute;
  left: 50%;
  top: 50%;
  margin: 0;
  transform-origin: center;
  will-change: transform;
  touch-action: none;
}
html #lightbox .lb-frame img,
html .photo-lightbox .js-photo-object .photo-lightbox-image {
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.js-photo-zoomed { cursor: grab; }
.js-photo-zoomed .lb-corner { visibility: hidden; }
.js-photo-reset {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid #77736d;
  padding: 0;
  background: transparent;
  color: #F3EDE2;
  font: 24px/1 var(--sans);
  cursor: pointer;
}
.js-photo-reset[hidden] { display: none; }
#lightbox .lb-top #lb-close, .photo-lightbox .photo-close { grid-column: 3; }
.js-photo-reset { grid-column: 2; grid-row: 1; }
.js-photo-reset:focus-visible { outline: 2px solid #F3EDE2; outline-offset: 3px; }
.photo-lightbox .photo-loading { position: absolute; inset: 50% auto auto 50%; transform: translate(-50%,-50%); }
@media (max-width: 520px) and (min-height: 501px) {
  #lightbox .lb-shell, .photo-lightbox .js-photo-shell { --viewer-edge: 14px; }
  #lightbox .lb-bottom { gap: 8px 12px; }
  .photo-lightbox .js-photo-bottom { gap: 8px 12px; }
  html .photo-lightbox .photo-navigation { grid-template-columns: 44px 44px 44px; gap: 4px; }
  html .photo-lightbox .photo-position { min-width: 44px; font-size: 10px; }
  html .photo-lightbox .photo-exif { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 10px; }
  html #lightbox .lb-controls { grid-template-columns: 44px 44px 44px; gap: 4px; }
  html #lightbox .lb-position { min-width: 44px; width: 44px; font-size: 10px; }
  #lightbox .lb-shell { --viewer-nav-width: 140px; --viewer-footer-gap: 12px; }
}
@media (max-height: 500px) {
  #lightbox .lb-shell, .photo-lightbox .js-photo-shell { --viewer-edge: 8px; gap: 6px; }
  .photo-lightbox .photo-lightbox-caption { max-height: 2.8em; font-size: 10px; }
  #lightbox .lb-caption { max-height: 3.4em; overflow: auto; }
}

/* Fit actual translated labels and values, independent of phone model. */
html .photo-lightbox .photo-exif { width: 100%; }
.photo-lightbox .photo-exif > div { display: flex; column-gap: 6px; }
.photo-lightbox .photo-exif dt, .photo-lightbox .photo-exif dd { white-space: nowrap; }
html .photo-lightbox .photo-exif.exif-compact { display: grid; grid-template-columns: max-content max-content; }
.photo-lightbox .photo-exif.exif-compact > div:last-child { grid-column: 1 / -1; }
html .photo-lightbox .photo-exif.exif-stacked { grid-template-columns: minmax(0,1fr) minmax(0,1fr); }
.photo-lightbox .photo-exif.exif-stacked > div:not(:last-child) { flex-direction: column; align-items: flex-start; row-gap: 1px; }
/* Short viewports: protect individual top controls, not an empty horizontal strip. */
@media (max-height: 500px) and (min-width: 521px) {
  #lightbox .lb-shell, .photo-lightbox .js-photo-shell { grid-template-rows: minmax(0, 1fr) auto; }
  #lightbox .lb-top, .photo-lightbox .js-photo-top {
    position: absolute; z-index: 3;
    top: max(var(--viewer-edge), env(safe-area-inset-top));
    left: max(var(--viewer-edge), env(safe-area-inset-left));
    right: max(var(--viewer-edge), env(safe-area-inset-right));
    pointer-events: none;
  }
  #lightbox .lb-top > *, .photo-lightbox .js-photo-top > * { pointer-events: auto; background: #131313; box-shadow: 0 0 0 6px #131313; }
  #lightbox .lb-top .meta, .photo-lightbox .photo-lightbox-title { justify-self: start; width: max-content; max-width: min(55vw, 100%); }
}

/* One reveal for the decoded photograph and its fitted corner ornaments. */
html #lightbox .lb-frame { visibility: hidden; }
html #lightbox.photo-ready .lb-frame { visibility: visible; }

/* A fixed footer prevents captions and credits from moving the photograph. */
#lightbox .lb-shell { --viewer-nav-width: 168px; --viewer-footer-gap: 24px; }
html #lightbox .lb-bottom { position: relative; height: 44px; min-height: 44px; grid-template-columns: minmax(0,1fr) auto; }
html #lightbox .lb-controls { grid-column: 2; }
html #lightbox .lb-caption {
  position: absolute; left: 0; bottom: 0;
  width: calc(100% - var(--viewer-nav-width) - var(--viewer-footer-gap));
  max-height: 44px; min-width: 0; margin: 0; overflow: auto;
  text-align: left; font-size: clamp(10px,.9vw,12px); line-height: 1.4; gap: 3px;
  overflow-wrap: anywhere; overscroll-behavior: contain;
}
html #lightbox .lb-caption[hidden] { display: none; }
@media (max-width:520px) and (min-height:501px) {
  #lightbox .lb-shell { --viewer-nav-width: 140px; --viewer-footer-gap: 12px; }
}
