/* The rising panel (public/js/lib/sheet.js; spec 4.1): a sheet at the foot of a phone, a modal in the middle of a wide window. It is a fixed layer on <body> (outside #app, which is made
   inert while it is up) as wide as the window, so the wide layout is the window's own `@media (min-width: 700px)`, the same 700 px the pages' own breakpoint is (render.ts WIDE_PX), read by
   the script through the probe (never repeated there). Sizes, gaps and margins are the mockups' (watch-phone.png frame 3 for the phone's sheet, d2-d-guest.png for the modal).
   Nothing is placed by a coordinate: the panel hugs its content up to a highest (a phone's: 150 px from the top of the screen, where the mockup puts its top), and past that its head
   stays and its body scrolls, with a soft fade at the edges and one flash of a scroll bar. Only transform and opacity move: the springs are the script's. */
.sh-layer {
  --sh-vh: 100dvh; --sh-top: 0px; --sh-gap: 150px;
  position: fixed; left: 0; right: 0; top: var(--sh-top); height: var(--sh-vh); z-index: 60;
  display: flex; align-items: flex-end; justify-content: center;
}
.sh-scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, .62); }
.sh-layer[data-scrim="none"] .sh-scrim { background: transparent; }                 /* the wall's own frame is already dimmed (the mockups draw no scrim over it: the top row and the bar stay as bright as they are) */
.sh-probe { display: none; }
.sh-panel {
  position: relative; width: 100%; max-height: calc(var(--sh-vh) - var(--sh-gap)); display: flex; flex-direction: column;
  background: #121215; border-radius: 26px 26px 0 0; box-shadow: 0 -10px 40px rgba(0, 0, 0, .6); color: var(--text);
  touch-action: none; user-select: none; -webkit-user-select: none; outline: none;
}
/* a sheet is dragged past its foot by a finger or springs past it: the panel carries its own colour below its edge so no gap ever shows */
.sh-panel::after { content: ""; position: absolute; left: 0; right: 0; top: 100%; height: 160px; background: #121215; pointer-events: none; }
.sh-head { flex: none; position: relative; padding: 28px 24px 0; }
.sh-scroll-wrap { position: relative; flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.sh-scroll {
  --fade-len: 24px; --fade-top: 0; --fade-bottom: 0;
  position: relative; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none;
  padding: 0 24px calc(24px + env(safe-area-inset-bottom, 0px)); user-select: text; -webkit-user-select: text;
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 calc(var(--fade-len) * var(--fade-top)), #000 calc(100% - var(--fade-len) * var(--fade-bottom)), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 calc(var(--fade-len) * var(--fade-top)), #000 calc(100% - var(--fade-len) * var(--fade-bottom)), transparent 100%);
}
.sh-scroll::-webkit-scrollbar { display: none; }
.sh-thumb { position: absolute; top: 0; right: 6px; width: 3px; height: 0; border-radius: 2px; background: rgba(255, 255, 255, .4); opacity: 0; pointer-events: none; }
/* a phone's keyboard is up (the script sets data-keyboard from the visual viewport): the sheet keeps a small gap, not 150 px, and the whole panel scrolls as one (the lock, the title, the lede and the form) */
.sh-layer[data-keyboard="true"] { --sh-gap: 12px; }
.sh-layer[data-keyboard="true"] .sh-panel { overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; scrollbar-width: none; }
.sh-layer[data-keyboard="true"] .sh-panel::after { display: none; }
.sh-layer[data-keyboard="true"] .sh-scroll-wrap { flex: none; display: block; }
.sh-layer[data-keyboard="true"] .sh-scroll { overflow: visible; -webkit-mask-image: none; mask-image: none; }
.sh-x { position: absolute; top: 18px; right: 20px; width: 30px; height: 30px; border-radius: 50%; background: #27272a; display: flex; align-items: center; justify-content: center; color: #d4d4d8; z-index: 2; touch-action: manipulation; }
.sh-x::after { content: ""; position: absolute; inset: -9px; }                         /* a thumb's reach, with no box of its own */
.sh-x svg { width: 20px; height: 20px; }

/* a wide window: the modal, 460 wide, in the middle of the window, a touch above the middle (the mockup draws it at -52 %, the window's own centre less 2 % of its height) */
@media (min-width: 700px) {
  .sh-layer { align-items: center; }
  .sh-probe { display: block; }
  .sh-panel { width: 460px; max-width: calc(100% - 48px); max-height: calc(var(--sh-vh) - 64px); border: 1px solid #2a2a30; border-radius: 20px; box-shadow: 0 30px 90px rgba(0, 0, 0, .7); translate: 0 -2%; touch-action: auto; }
  .sh-panel::after { display: none; }
  .sh-head { padding: 30px 30px 0; }
  .sh-scroll { padding: 0 30px 24px; }
  .sh-x { top: 16px; right: 16px; background: #26262b; }
  .sh-x svg { width: 17px; height: 17px; }
}

@media (prefers-reduced-motion: reduce) { .sh-x { transition: none; } }
