/* SheetLayout supplies these TrueSheet values on iOS (Hermes 3785133–3785151).
   The route's existing image, controls, footer and desktop width stay in its page. */
#page-dialog[data-native-presentation=sheet] {
  --sheet-color: #100f24;
  --sheet-radius: 24px;
  background-color: var(--sheet-color);
  border-radius: var(--sheet-radius) var(--sheet-radius) 0 0;
}
#page-dialog:is([data-native-presentation=sheet],[data-native-presentation=formSheet]) {
  overscroll-behavior: contain;
  overflow-y: auto;
  translate: var(--sheet-offset-xy, none);
}
#page-dialog:has(> .native-sheet-grip) { padding-top: 0; }
.native-sheet-grip {
  position: sticky;
  z-index: 3;
  top: 0;
  width: 96px;
  height: 32px;
  margin-inline: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
}
.native-sheet-grip::before {
  content: '';
  position: absolute;
  top: 12px;
  left: 50%;
  translate: -50% 0;
  width: 48px;
  height: 5px;
  border-radius: 2.5px;
  background: rgb(255 255 255 / 20%);
}
.native-sheet-grip[role=slider]:focus-visible { outline: 2px solid currentColor; outline-offset: -2px; }
#page-dialog[data-native-dragging] .native-sheet-grip { cursor: grabbing; }
#page-dialog[data-native-presentation] .close-layer { min-width: 44px; min-height: 44px; }
#page-dialog[data-native-presentation] .close-layer[aria-disabled=true] { opacity: .5; }

/* systemThickMaterialDark has no web equivalent. Use the existing dim layer
   for the route TrueSheet and a plain dim for UIKit's native FormSheet. */
#page-dialog[data-native-presentation=formSheet]::backdrop { backdrop-filter: none; }
#page-dialog[data-native-presentation=formSheet] {
  height: var(--sheet-height, auto);
  border-radius: var(--sheet-radius, 18px);
}
#page-dialog[data-native-presentation=sheet]::backdrop { opacity: var(--sheet-dim-opacity, 1); }
#page-dialog[data-native-undimmed]::backdrop { background: transparent; backdrop-filter: none; }

@media (max-width: 700px), (pointer: coarse) and (max-height: 600px) {
  #page-dialog:is([data-native-presentation=sheet],[data-native-presentation=formSheet]) {
    box-sizing: border-box;
    inset: auto 0 0;
    width: 100%;
    max-width: 100%;
    min-height: 0;
    height: var(--sheet-height, auto);
    max-height: min(var(--sheet-limit, 100dvh), calc(100dvh - env(safe-area-inset-top, 0px)));
    margin: 0 auto;
    padding-bottom: max(var(--native-sheet-bottom, 0px), env(safe-area-inset-bottom, 0px));
    border-bottom: 0;
    border-radius: var(--sheet-radius, 18px) var(--sheet-radius, 18px) 0 0;
  }
  #page-dialog[data-native-presentation]:has(.standard-page) { --native-sheet-bottom: 18px; }
  #page-dialog:is([data-native-presentation=full],[data-native-presentation=fullScreenModal]) {
    box-sizing: border-box;
    inset: 0;
    margin: 0;
    width: 100%;
    height: 100dvh;
    max-width: 100%;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
    padding-block-start: max(18px, env(safe-area-inset-top, 0px));
    padding-block-end: max(18px, env(safe-area-inset-bottom, 0px));
  }
}
/* Expanded iPhone uses the shorter window dimension less 16 (1984033–1984064). */
@media (pointer: coarse) and (min-width: 600px) and (min-height: 600px) {
  #page-dialog[data-native-expanded-width] { max-width: calc(100vmin - 16px); margin-inline: auto; }
}
@media (prefers-reduced-motion: no-preference) {
  :root:not(.reduced-motion) #page-dialog:is([data-native-presentation=sheet],[data-native-presentation=formSheet]):not([data-native-dragging]) {
    transition: translate .16s ease-out;
  }
}
@media (forced-colors: active) {
  .native-sheet-grip::before { background: ButtonText; }
}
