/* Keep the three action groups in a single layout on handsets. */
.cave-film-actions { display: contents; }
.cave-film-actions #projector-toggle { position: fixed; }
#loading[hidden], #failure[hidden] { display: none; }
body:not(.portal-preparing):has(#loading:not([hidden])) > .localized-cave-header { z-index: 9; }
body:not(.portal-preparing):has(#failure:not([hidden])) > .localized-cave-header { z-index: 9; }
.localized-cave-header :is(a, button, summary):focus-visible {
  outline: 2px solid #e8d2a8;
  outline-offset: 2px;
}
@media (max-width: 760px), (max-height: 500px) and (pointer: coarse) {
  body > .localized-cave-header {
    --cave-edge: clamp(10px, 3.6vw, 20px);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 6px 10px;
    inset: 0 0 auto;
    padding: max(6px, env(safe-area-inset-top)) max(var(--cave-edge), env(safe-area-inset-right))
      8px max(var(--cave-edge), env(safe-area-inset-left));
    background: linear-gradient(180deg, #18130fe8, #18130f94 75%, #18130f00);
    pointer-events: none;
  }
  .localized-cave-header > .brand {
    width: fit-content;
    max-width: 100%;
    min-height: 44px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    white-space: normal;
    line-height: 1.45;
  }
  .localized-cave-header > #site-language > summary { min-height: 44px; }
  body > .localized-cave-header > .header-links {
    display: grid;
    grid-column: 1 / -1;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px;
    gap: 6px;
    width: min(100%, 350px);
    justify-self: end;
    justify-content: stretch;
    pointer-events: none;
  }
  .localized-cave-header .header-links > :is(a,button) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    min-height: 44px;
    padding: 5px 6px;
    white-space: normal;
    overflow-wrap: anywhere;
    text-align: center;
    line-height: 1.2;
    pointer-events: auto;
  }
  .localized-cave-header .header-links .image-return {
    border: 1px solid #e5d5b448;
    border-radius: 2px;
    background: #24231ecc;
    font-size: 12px;
  }
  .localized-cave-header .header-links #help-toggle { padding: 4px; font-size: 0; gap: 0; }
  .localized-cave-header .header-links #help-toggle span { padding: 3px 6px; font-size: 12px; line-height: 1; }
  .localized-cave-header .cave-film-actions {
    display: none;
    grid-column: 1 / -1;
    justify-self: end;
    width: min(100%, 350px);
    gap: 6px;
    justify-content: flex-end;
    flex-wrap: wrap;
    pointer-events: none;
  }
  .localized-cave-header .cave-film-actions:has(button:not([hidden])) { display: flex; }
  .localized-cave-header:has(#site-language[open]) .cave-film-actions { visibility: hidden; }
  .localized-cave-header .cave-film-actions :is(#projector-toggle, #frame-film) {
    position: static;
    min-height: 44px;
    max-width: 100%;
    margin: 0;
    padding: 5px 10px;
    font-size: 12px;
    line-height: 1.2;
    white-space: normal;
    overflow-wrap: anywhere;
    pointer-events: auto;
    box-shadow: none;
  }
  .localized-cave-header .cave-film-actions #frame-film::before { margin-right: 5px; }
  body.portal-preparing .localized-cave-header :is(a, button, summary),
  body[data-overlay=open] .localized-cave-header .cave-film-actions :is(#projector-toggle, #frame-film) {
    pointer-events: none;
  }
  body[data-overlay=open] .localized-cave-header .cave-film-actions { visibility: hidden; }
  body > .localized-cave-header + main #help {
    top: calc(var(--cave-hud-height, 116px) + 5px);
    max-height: calc(100dvh - var(--cave-hud-height, 116px) - max(12px, env(safe-area-inset-bottom)) - 5px);
    overscroll-behavior: contain;
  }
}

