/* A phone can stay upright for the entire visit. */
:root { --app-height: 100vh; --browser-guide-height: 0px; }
@supports (height: 100dvh) { :root { --app-height: 100dvh; } }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
#exhibition { height: var(--app-height); }
#entrance, #gallery, #viewer, .reading-page {
  top: var(--browser-guide-height); bottom: auto;
  height: calc(var(--app-height) - var(--browser-guide-height));
}
body.browser-guide-visible { --safe-top: 0px; }
#exhibition:fullscreen > section { top: 0; height: 100%; }
#viewer-content { position: absolute; inset: 0; }

/* One scroll surface keeps reading separate from horizontal photo swipes. */
#viewer.mobile-reading { background: #f3f0e7; color: #263e32; }
#viewer.mobile-reading #viewer-content {
  top: var(--reading-top, 76px); bottom: var(--reading-bottom, 74px);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior-y: contain;
  scrollbar-width: thin; scrollbar-color: #a7b1a1 transparent;
  -webkit-overflow-scrolling: touch; scroll-padding-top: 16px;
}
#viewer.mobile-reading #image-stage {
  position: relative; inset: auto; width: 100%;
  height: var(--reading-photo-height, 42vh);
  background: #122019; touch-action: pan-y;
}
#viewer.mobile-reading.is-infographic #image-stage { touch-action: none; background: #e4e7dc; }
#viewer.mobile-reading.is-video #image-stage { touch-action: auto; }
#viewer.mobile-reading #full-image,
#viewer.mobile-reading #preview-image { object-fit: contain; }
#viewer.mobile-reading .viewer-shade { display: none; }
#viewer.mobile-reading .viewer-header { top: calc(10px + var(--safe-top)); }
#viewer.mobile-reading .viewer-header .glass-button {
  color: #263e32; background: #e4e8dd; border: 0; backdrop-filter: none;
}
#viewer.mobile-reading .viewer-location { text-shadow: none; }
#viewer.mobile-reading #viewer-chapter { font-size: 14px; color: #263e32; }
#viewer.mobile-reading #viewer-count { color: #647461; }
#viewer.mobile-reading:not(.is-infographic) .image-tools { display: none; }
#viewer.mobile-reading.is-infographic .image-tools .glass-button,
#viewer.mobile-reading.is-infographic #zoom-label {
  color: #263e32; background: #e4e8dd; border-color: #263e3222; backdrop-filter: none;
}
#viewer.mobile-reading .caption {
  position: relative; inset: auto; width: 100%; max-width: none;
  max-height: none; margin: 0; padding: 22px 24px 32px;
  background: transparent; border: 0; border-radius: 0; color: #263e32;
  box-shadow: none; text-shadow: none; backdrop-filter: none; overflow: visible;
}
#viewer.mobile-reading .caption::before { display: none; }
#viewer.mobile-reading .caption-heading { align-items: baseline; gap: 4px 12px; }
#viewer.mobile-reading .photo-date { color: #63735f; font-size: 13px; letter-spacing: .05em; }
#viewer.mobile-reading #photo-place { color: #63735f; font-size: 10px; letter-spacing: .055em; }
#viewer.mobile-reading #caption-body {
  max-height: none; overflow: visible; margin-top: 14px; padding: 0;
}
#viewer.mobile-reading #photo-description {
  color: #263e32; font-size: clamp(18px, 4.9vw, 20px); line-height: 1.85;
  word-break: keep-all; overflow-wrap: break-word;
}
#viewer.mobile-reading .caption-original {
  font-size: 13px; color: #526b54; border-color: #526b5466;
  min-height: 44px; margin-top: 18px;
}
#viewer.mobile-reading .viewer-footer {
  background: #f3f0e7f5; border-top: 1px solid #263e3226;
  box-shadow: 0 -5px 18px #233c2908;
}
#viewer.mobile-reading .nav-photo { background: #244a37; color: #fffdf1; }
#viewer.mobile-reading .viewer-secondary .glass-button { color: #354d3b; }
#viewer.mobile-reading .chapter-next { display: none; }
#viewer.mobile-reading #image-loading {
  top: calc(var(--reading-top) + 16px); bottom: auto; font-size: 12px;
  color: #f7f4e9; background: #132e23e6;
}
#viewer.mobile-reading #image-error { color: #fffdf1; }
#viewer.mobile-reading.story-hidden #viewer-content { overflow: hidden; }

@media (max-width: 760px), (pointer: coarse), (max-width: 1024px) and (max-height: 600px) {
  /* The joystick and guided walk occupy separate thumb areas. */
  .world-bottom { left: 12px; right: 12px; bottom: 16px; justify-content: flex-end; }
  .world-bottom .movement, .world-bottom .walk-help { display: none; }
  .guided-walk { width: auto; max-width: calc(100% - 150px); flex-direction: column; gap: 8px; }
  .guided-walk > div { display: flex; gap: 5px; }
  .guided-walk .glass-button { padding: 8px 10px; min-height: 46px; font-size: 12px; }
  .guided-walk .primary-button { width: 100%; min-height: 50px; font-size: 14px; padding: 10px; }
  #easel-prev { width: 44px; flex: 0 0 44px; }
  #easel-next { flex: 1; white-space: nowrap; }
  #aim-label { top: calc(50% + 24px); max-width: 86%; }
  .gallery-footer { gap: 4px; }
  .gallery-header { flex-wrap: wrap; }
  #gallery { grid-template-rows: calc(100px + var(--safe-top)) minmax(0, 1fr) calc(50px + var(--safe-bottom)); }
  .gallery-header { display: grid; grid-template-columns: 1fr auto; grid-template-rows: 48px 42px; padding: var(--safe-top) 12px 6px; gap: 0 8px; }
  .gallery-brand .serif { font-size: 18px; }
  .gallery-brand .icon-button { margin-left: -8px; }
  .gallery-header > #open-index { grid-column: 2; grid-row: 1; font-size: 12px; padding: 6px 10px; }
  .gallery-header > #open-index span { font-size: 14px; margin-left: 4px; }
  .region-picker { grid-column: 1 / -1; grid-row: 2; width: 100%; margin: 0; }
  .region-picker select { width: 100%; max-width: none; font-size: 13px; min-height: 38px; height: 38px; padding: 6px 12px; }
  #index-dialog { height: var(--app-height); max-height: var(--app-height); }
  .cover-copy { bottom: calc(66px + var(--safe-bottom)); }
  .cover-copy h1 { font-size: clamp(39px, 10.6vw, 61px); }
  .cover-footer { bottom: calc(18px + var(--safe-bottom)); }
}
@media (max-width: 359px) {
  #viewer.mobile-reading .caption { padding: 20px 20px 28px; }
  .guided-walk { max-width: calc(100% - 135px); gap: 6px; }
  .guided-walk .glass-button { padding: 8px 6px; font-size: 11px; }
  .guided-walk .primary-button { font-size: 13px; }
  #easel-prev { width: 42px; flex-basis: 42px; }
  .viewer-secondary #story-toggle { font-size: 11px; padding: 8px 5px; }
  .cover-copy { left: 20px; right: 20px; }
}
@media (max-height: 600px) and (orientation: portrait) {
  .cover-copy { top: 104px; bottom: auto; }
  .cover-copy .eyebrow { margin-bottom: 10px; }
  .cover-copy h1 { font-size: 36px; }
  .cover-intro { margin: 14px 0; }
}
@media (orientation: landscape) and (max-height: 600px) {
  #gallery { grid-template-rows: calc(54px + var(--safe-top)) minmax(0,1fr) calc(42px + var(--safe-bottom)); }
  .gallery-header { display: flex; flex-wrap: nowrap; padding: var(--safe-top) 14px 0; gap: 12px; }
  .region-picker { margin-left: auto; width: auto; }
  .region-picker select { max-width: 180px; }
  .gallery-brand .serif { font-size: 18px; }
  .guided-walk { max-width: 215px; }
  .guided-walk .primary-button { min-height: 44px; }
  .world-bottom { bottom: 12px; }
}

/* A portrait photograph and its story can share a short, wide screen. */
@media (orientation: landscape) and (max-height: 600px) {
  #viewer.mobile-wide-orientation.is-portrait:not(.story-hidden) #image-stage {
    inset: calc(65px + var(--safe-top)) 0 calc(72px + var(--safe-bottom)) 43%;
  }
  #viewer.mobile-wide-orientation.is-portrait:not(.story-hidden) .caption {
    top: calc(65px + var(--safe-top)); bottom: calc(76px + var(--safe-bottom));
    left: max(12px, env(safe-area-inset-left)); width: calc(43% - 24px);
    max-width: none; max-height: none; padding: 12px 14px; overflow: auto;
  }
  #viewer.mobile-wide-orientation.is-portrait #caption-body { max-height: none; overflow: visible; }
  #viewer.mobile-wide-orientation.is-portrait #photo-description { font-size: 18px; line-height: 1.75; }
}
