/* The one sheet component (templates/components/sheet.html, static/js/sheet.js).
   Phones: bottom sheet with a drag handle. 1024px and up: centred dialog about 500px wide
   with a Close button. Slide-up only without the reduced-motion setting, once per open
   (.is-entering, fix wave A, C2). */

.sheet { position: fixed; inset: 0; z-index: var(--z-sheet); }
.sheet[hidden] { display: none; }
.sheet__backdrop { position: absolute; inset: 0; background: var(--scrim); }
.sheet__panel {
  position: absolute;
  inset-inline: 0;
  inset-block-end: 0;
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-2) var(--space-4) calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sheet);
  transform: translateY(var(--sheet-drag, 0px));
}
.sheet__panel:focus { outline: none; }
.sheet__handle {
  display: block;
  width: 3rem;
  height: var(--tap-min);
  margin: 0 auto;
  padding: 0;
  border: 0;
  background: transparent;
  touch-action: none;
  cursor: grab;
}
.sheet__handle::before {
  content: "";
  display: block;
  width: 3rem;
  height: 0.3125rem;
  margin: 1.0625rem auto 0;
  border-radius: var(--radius-pill);
  background: var(--outline);
}
/* On phones the Close button stays for screen readers and keyboards, off screen. */
.sheet__close {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
}
.sheet__close:focus-visible {
  width: auto;
  height: auto;
  margin: 0;
  clip-path: none;
  inset-block-start: var(--space-2);
  inset-inline-end: var(--space-2);
}
.sheet__body { padding-block-start: var(--space-2); }
.sheet-open { overflow: hidden; }

@media (min-width: 1024px) {
  .sheet__panel {
    inset-inline: 0;
    /* M17: use most of the window so frame 1 with guests fits at 1280x800 (it still scrolls
       inside when the window is truly short). */
    inset-block: 0;
    margin-block: auto;
    height: fit-content;
    width: min(var(--w-sheet), calc(100% - 2 * var(--gutter)));
    max-height: 92vh;
    max-height: 92dvh;
    margin-inline: auto;
    padding: var(--space-6);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    transform: none;
  }
  .sheet__handle { display: none; }
  .sheet__close {
    position: static;
    display: inline-flex;
    width: auto;
    height: auto;
    margin: 0 0 var(--space-3) auto;
    clip-path: none;
    overflow: visible;
  }
  .sheet__top { display: flex; justify-content: flex-end; }
}

/* C2: the slide-up hangs on .is-entering, which sheet.js sets once per open and clears on
   animationend or when a drag begins; the drag state never touches the animation, so
   ending a drag (or a tap) cannot restart it. */
@media (prefers-reduced-motion: no-preference) {
  .sheet__panel.is-entering { animation: sheet-up var(--dur-sheet) var(--ease-out); }
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
@media (min-width: 1024px) {
  @keyframes sheet-up { from { opacity: 0; } to { opacity: 1; } }
}
