/* duo-prep-20261010 + launch-pack-preview (STAGED, not live; C2 chosen by Rich 2:54 AM Oct 10): foldable / iPhone Duo readiness. Every rule is additive and
 * harmless on today's phones. Load after mxkb.css. */

/* 1) dvh: 100vh on iOS is the *largest* viewport, so on a resized/unfolded screen it overshoots. */
body { min-height: 100vh; min-height: 100dvh; }
.help-chat-panel { height: min(640px, calc(100dvh - 1.5rem)); max-height: min(640px, calc(100dvh - 1.5rem)); }

/* 2) Soft-crease band: on wide touch screens (unfolded ≈ 626–669 wide, or landscape) keep the
 *    Matrix keyboard's keys out of a ~40pt centre band. mxkb.js adds .mxkb__gap mid-row. */
.mxkb__gap { display: none; }
.mxkb__half { display: contents; }
/* rr-duo = js/duo-detect.js (Viewport Segments, or open-Duo size fallback); the same test mxkb.js uses.
 * Landscape phones and iPads never get .rr-duo. */
.rr-duo .mxkb__gap { display: block; flex: 0 0 var(--duo-crease, 44px); }
.rr-duo .mxkb__half { display: flex; flex: 1 1 0; gap: 5px; min-width: 0; }
.rr-duo .mxkb__half--l { justify-content: flex-end; }
.rr-duo .mxkb__half--r { justify-content: flex-start; }
.rr-duo .mxkb__row--inset { padding: 0; }
.rr-duo .mxkb__key:not(.mxkb__key--space):not(.mxkb__key--return) { max-width: 52px; }
.rr-duo .mxkb__key--space { max-width: none; }
/* typing bar: tools stay left, Send stays right; never let them meet in the middle */
.rr-duo .rr-typebar > :last-child { margin-left: auto; }

/* 3) Unequal safe-area insets (left ≠ right): pad each side with its own inset. */
body.has-bottom-nav .bottom-nav { padding-left: env(safe-area-inset-left, 0px); padding-right: env(safe-area-inset-right, 0px); }
[data-dm-compose] { padding-left: max(.5rem, env(safe-area-inset-left, 0px)); padding-right: max(.5rem, env(safe-area-inset-right, 0px)); }

/* 4) (Container queries for post action rows: proposed for the admin/feed redesign, not staged here —
 *    the current owner-actions row fix relies on viewport media queries.) */

/* 5) OPTIONAL Viewport Segments (Safari has NO support today; this whole block is ignored there).
 *    If a browser reports two side-by-side segments, size the crease gap to the real hinge. */
@media (horizontal-viewport-segments: 2) {
  :root { --duo-crease: calc(env(viewport-segment-left 1 0, 0px) - env(viewport-segment-right 0 0, 0px) + 16px); }
  .mxkb__gap { display: block; flex: 0 0 var(--duo-crease); }
}

/* 6) Tab bar (CHOSEN C2, Rich 2:54 AM Oct 10). Not an open Duo (incl. landscape phones, iPads): original 5 tabs,
 *    original order, no rules. Open Duo (.rr-duo): all 5 tabs, original order, 2 | crease gap | 3. */
  /* CHOSEN C2 (Rich, 2:54 AM; STAGED for Oct 18): all 5 tabs, original order, 2 | crease gap | 3; each side shares its half evenly */
  .rr-duo body.has-bottom-nav .bottom-nav [data-bottom-nav-feed] { order: 1; flex: 0 0 calc((100% - var(--duo-crease, 44px)) / 2 / 2); }
  .rr-duo body.has-bottom-nav .bottom-nav [data-bottom-nav-profile] { order: 2; flex: 0 0 calc((100% - var(--duo-crease, 44px)) / 2 / 2); }
  .rr-duo body.has-bottom-nav .bottom-nav::after { content: ""; order: 3; flex: 0 0 var(--duo-crease, 44px); }
  .rr-duo body.has-bottom-nav .bottom-nav [data-bottom-nav-messages] { order: 4; flex: 0 0 calc((100% - var(--duo-crease, 44px)) / 2 / 3); }
  .rr-duo body.has-bottom-nav .bottom-nav [data-bottom-nav-notifications] { order: 5; flex: 0 0 calc((100% - var(--duo-crease, 44px)) / 2 / 3); }
  .rr-duo body.has-bottom-nav .bottom-nav [data-bottom-nav-settings] { order: 6; flex: 0 0 calc((100% - var(--duo-crease, 44px)) / 2 / 3); }
  /* equal side padding so the gap lands on the true centre even with unequal insets */
  .rr-duo body.has-bottom-nav .bottom-nav { padding-left: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) !important;
    padding-right: max(env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px)) !important; }

  /* 7) Typing bar: keep the tool cluster left of the crease (the 📷 overlapped it by ~15px at 669) */
  .rr-duo .rr-typebar .rr-typebar__prompt { display: none; }
  .rr-duo .rr-typebar { gap: .3rem; }

