/* Phones first (roadmap 114), shared by the guide, the editor and the site's pages. Three patterns:
   1. Bottom sheets: any box made with core/phone.js sheetify() (.rr-sheet, its backdrop .rr-sheet-back) docks to the
      bottom edge on a phone (760 px, as everywhere else), slides up, has rounded top corners and a grab handle
      (.rr-grab), and scrolls inside itself. Larger screens keep each box's own look: nothing here applies there.
   2. One bar along the bottom with the screen's main button (.rr-bar, and the bars that predate it: the guide's card
      foot .g-foot, its photos screen's .gm-foot and "Plan it for me" .g-ai-row): pinned to the bottom of whatever
      scrolls, clear of the home indicator (safe area), content scrolling under it. Each page sets --rr-bar-bg.
   3. The keyboard: --rr-kb (core/phone.js) is the height the on-screen keyboard covers; the pages, the bars and the
      sheets are lifted above it, so the main button and the box being typed in stay in view.
   Tap targets (44 × 44 px to a finger) are set in each page's own stylesheet under
   @media (max-width: 760px), (pointer: coarse); .rr-hit there makes a small control's hit area 44 px without
   changing how it looks. tests/browser/tap_targets.py measures them. */

.rr-grab { display: none; }

@media (max-width: 760px), (pointer: coarse) {
  .rr-hit { position: relative; }
  .rr-hit::after { content: ""; position: absolute; left: 50%; top: 50%; width: max(100%, 44px); height: max(100%, 44px); transform: translate(-50%, -50%); }
}

/* ---- 1. Bottom sheets --------------------------------------------------------------------------------------- */
@media (max-width: 760px) {
  .rr-sheet-back { align-items: flex-end; justify-content: center; padding: 0; }
  .rr-sheet-back > .rr-sheet, dialog.rr-sheet {
    width: 100%; max-width: none; margin: 0; max-height: calc(100% - max(16px, env(safe-area-inset-top)));
    border-radius: 20px 20px 0 0; border-bottom-width: 0; box-shadow: 0 -18px 50px rgba(0, 0, 0, .5);
    overscroll-behavior: contain; animation: rr-sheet-up .3s cubic-bezier(.2, .8, .2, 1) both; will-change: transform;
  }
  /* A modal <dialog> is centred by the browser: dock it to the bottom instead. */
  dialog.rr-sheet { position: fixed; inset: auto 0 var(--rr-kb, 0px) 0; max-height: calc(100dvh - var(--rr-kb, 0px) - max(16px, env(safe-area-inset-top))); }
  .rr-grab { display: flex; flex: none; align-items: center; justify-content: center; height: 20px; margin: 0 0 -6px; touch-action: none; cursor: grab; }
  .rr-grab span { display: block; width: 40px; height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .26); }
  .rr-sheet [data-sheet-drag] { touch-action: none; }
  .rr-sheet.rr-dragging { animation: none; transition: none; }
  .rr-sheet.rr-settle { animation: none; transition: transform .2s ease; }
}
@keyframes rr-sheet-up { from { transform: translateY(100%); } }

/* ---- 2. The bottom bar with the main button ----------------------------------------------------------------- */
@media (max-width: 900px) {
  .rr-bar, .g-foot, .gm-foot, .g-ai-row { position: sticky; bottom: 0; z-index: 6; }
  .rr-bar { background: var(--rr-bar-bg, var(--panel, #141a21)); box-shadow: 0 -10px 22px -12px rgba(0, 0, 0, .55); }
}

/* ---- 3. Above the keyboard ---------------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .g-app, .modal-back, .mode-back, .dlg-backdrop { bottom: var(--rr-kb, 0px); }
}

@media (prefers-reduced-motion: reduce) {
  .rr-sheet, .rr-sheet-back > .rr-sheet, dialog.rr-sheet { animation: none !important; }
  .rr-sheet.rr-settle { transition: none; }
}
