/* A sheet from the bottom of the screen (SheetComponent): the dialog is only the top layer (`wi-native-dialog`), its
   overlay dims the page, its panel rises from the bottom. The grip and the title drag it down to close, and a tap on
   the grip closes it (sheet_controller.js): they take the finger from the page's scroll. */
.wi-sheet__overlay {
  position: fixed;
  inset: 0;
  z-index: var(--z-index-overlay);
  background-color: var(--background-scrim-light);
}
.wi-sheet__panel {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  flex-direction: column;
  max-height: 85%;
}
/* What a bottom sheet looks like (its surface), for its panel and for a popover shown as one on a phone (`data-sheet`, set by
   popover_controller.js, which `internal/Popover.css` lays out). */
.wi-sheet__panel,
.wi-popover[data-sheet] {
  box-sizing: border-box;
  padding: 0 var(--space-4) max(var(--space-4), env(safe-area-inset-bottom));
  border: 0;
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
  background-color: var(--background-surface);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  font-family: var(--font-family-sans);
}
.wi-sheet__grip {
  flex: none;
  display: grid;
  place-items: center;
  height: var(--space-5);
  margin-inline: calc(-1 * var(--space-4));
  touch-action: none;
  cursor: grab;
}
.wi-sheet__grip::before {
  content: "";
  width: var(--space-10);
  height: var(--space-1);
  border-radius: var(--radius-full);
  background-color: var(--border-strong);
}
.wi-sheet__head {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-1) var(--space-2);
  touch-action: none;
}
/* An address or a long name wraps rather than push the close button out. */
.wi-sheet__title {
  min-width: 0;
  overflow-wrap: anywhere;
  margin: 0;
  font-size: var(--font-size-lg);
  line-height: var(--font-line-height-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}
.wi-sheet__close {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--size-button-sm);
  height: var(--size-button-sm);
  padding: 0;
  color: var(--text-primary);
  background: var(--background-sunken);
  border: 0;
  border-radius: var(--radius-full);
  cursor: pointer;
}
.wi-sheet__close svg {
  width: var(--size-icon-sm);
  height: var(--size-icon-sm);
}
.wi-sheet__close[data-focus-visible] {
  outline: none;
  box-shadow: var(--focus-ring);
}
/* The body takes what the panel has left and scrolls when its content is longer (a content that scrolls by itself, a
   list under a search, sets its own height: FilterSelect.css). Its end doesn't scroll the page behind, which is held
   still while a dialog is open (application.css). */
.wi-sheet__body {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  outline: none;
}

/* Motion, as Material 3 sets it for a sheet: the page dims while the sheet rises (300ms, emphasized decelerate);
   closing plays both back down (200ms, emphasized accelerate), and dialog_controller waits for it. With reduced
   motion the sheet fades instead of moving. */
.wi-sheet[open] .wi-sheet__overlay {
  animation: wi-sheet-dim 0.3s var(--wi-ease-enter) both;
}
.wi-sheet[open] .wi-sheet__panel {
  animation: wi-sheet-rise 0.3s var(--wi-ease-enter) both;
}
.wi-sheet[data-closing] .wi-sheet__overlay {
  animation: wi-sheet-undim 0.2s var(--wi-ease-exit) both;
}
.wi-sheet[data-closing] .wi-sheet__panel {
  animation: wi-sheet-sink 0.2s var(--wi-ease-exit) both;
}
@keyframes wi-sheet-dim {
  from { opacity: 0; }
}
/* Closing has its own animations: the same name played in reverse would only update the finished opening one. */
@keyframes wi-sheet-undim {
  to { opacity: 0; }
}
@keyframes wi-sheet-rise {
  from { transform: translateY(100%); }
}
@keyframes wi-sheet-sink {
  to { transform: translateY(100%); }
}
@media (prefers-reduced-motion: reduce) {
  .wi-sheet[open] .wi-sheet__panel {
    animation: wi-sheet-dim 0.2s ease-out both;
  }
  .wi-sheet[data-closing] .wi-sheet__panel {
    animation: wi-sheet-undim 0.2s ease-in both;
  }
}

/* A sheet or a dialog with panels (SheetPanelsController: the More sheet, a FormDialog's search): the controller hides the main
   view's parts (`wi-sheet-panels__main`) and every panel but the open one with `hidden`, and this is the one rule that makes
   it hold whatever `display` a part has of its own. A panel is rendered `hidden`, so none shows before the controller runs. */
[data-panel][hidden],
.wi-sheet-panels__main[hidden] {
  display: none;
}

/* A modal card that is a bottom sheet on a phone (`wi-sheet-on-phone` on the card, `wi-sheet-on-phone__overlay` on its
   overlay: a FormDialog with `sheet_on_phone`, the date picker's calendar) and the card it was on a wider screen. Below
   768px it is the sheet's panel in look and motion: full width, radius-2xl top corners, the grip (hidden on a wider screen),
   Sheet.css's rise, sink, dim and undim, a fade with reduced motion. Its grip and title stay in view: only its content
   (`wi-sheet-on-phone__body`) scrolls, as a sheet's body does. It may be taller than a list of choices (92%, not 85%):
   a form or a calendar needs the room, and scrolls past it. */
.wi-sheet-on-phone > .wi-sheet__grip {
  display: none;
}
@media (max-width: 767.98px) {
  .wi-modal-dialog__overlay.wi-sheet-on-phone__overlay {
    align-items: flex-end;
    padding: 0;
  }
  /* The panel's surface and its column, as a sheet's (the modal's own are the page's colour and a larger shadow). Only what
     is under the grip and the title scrolls (`__body`, or a FormDialog's form), so they stay in view. */
  .wi-modal-dialog.wi-sheet-on-phone {
    display: flex;
    flex-direction: column;
    max-width: none;
    max-height: 92%;
    padding: 0 var(--space-4) max(var(--space-4), env(safe-area-inset-bottom));
    border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
    background-color: var(--background-surface);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
  }
  .wi-sheet-on-phone > .wi-modal-dialog__dialog {
    flex: 1;
    min-height: 0;
  }
  .wi-sheet-on-phone__body {
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .wi-sheet-on-phone > .wi-sheet__grip {
    display: grid;
  }
  /* A FormDialog's title is a sheet's (its size, and it drags the sheet), as a sheet's head is. */
  .wi-sheet-on-phone .wi-modal-dialog__title {
    font-size: var(--font-size-lg);
    line-height: var(--font-line-height-lg);
    touch-action: none;
  }
  .wi-native-dialog[open] .wi-sheet-on-phone__overlay {
    animation: wi-sheet-dim 0.3s var(--wi-ease-enter) both;
  }
  .wi-native-dialog[open] .wi-sheet-on-phone {
    animation: wi-sheet-rise 0.3s var(--wi-ease-enter) both;
  }
  .wi-native-dialog[data-closing] .wi-sheet-on-phone__overlay {
    animation: wi-sheet-undim 0.2s var(--wi-ease-exit) both;
  }
  .wi-native-dialog[data-closing] .wi-sheet-on-phone {
    animation: wi-sheet-sink 0.2s var(--wi-ease-exit) both;
  }
}
@media (max-width: 767.98px) and (prefers-reduced-motion: reduce) {
  .wi-native-dialog[open] .wi-sheet-on-phone {
    animation: wi-sheet-dim 0.2s ease-out both;
  }
  .wi-native-dialog[data-closing] .wi-sheet-on-phone {
    animation: wi-sheet-undim 0.2s ease-in both;
  }
}
