/* Shared mobile refinements for development pages.
   This file is intentionally not loaded by profile-dev.html. */

:root{
  --dev-safe-top:env(safe-area-inset-top, 0px);
  --dev-safe-bottom:env(safe-area-inset-bottom, 0px);
  --mobile-rail-clearance:calc(96px + var(--dev-safe-bottom));
}

html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
}

body.mobile-page{
  min-height:100vh;
  min-height:100dvh;
}

body.mobile-page :is(button,a,[role="button"],summary){
  touch-action:manipulation;
  -webkit-tap-highlight-color:rgba(143,255,46,.16);
}

body.mobile-page :is(button,a,input,select,textarea,summary):focus-visible{
  outline:2px solid var(--toxic,#8fff2e);
  outline-offset:3px;
}

body.mobile-page :is(.cp-overlay,.overlay,.pm-overlay,.tb-overlay,.tier-overlay,
  .sw-overlay,.wish-overlay,.lot-overlay,.gdn-overlay,.tip-overlay,.verdict,.gate){
  overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
}

@supports(height:100dvh){
  body.mobile-page .pm-modal{
    height:90dvh;
    max-height:90dvh;
  }
  body.mobile-page .pm-overlay.fill .pm-modal{
    height:100dvh;
    max-height:100dvh;
  }
  body.mobile-page .pm-overlay.fill .pm-bigcover-media{
    max-height:min(62dvh,calc(100dvh - 250px));
  }
  body.mobile-page .gdn-panel{max-height:88dvh}
  body.mobile-shop .wish-modal{max-height:92dvh}
  body.mobile-shop .lot-modal{max-height:94dvh}
}

@media(max-width:820px){
  html{
    scroll-padding-top:calc(64px + var(--dev-safe-top));
    scroll-padding-bottom:var(--mobile-rail-clearance);
  }

  /* Keep swipe gestures inside an open sheet or player instead of moving the
     page behind it. The overlay remains the scroll container. */
  body.mobile-page:has(:is(.cp-overlay.on,.overlay.on,.pm-overlay.on,
    .tb-overlay.on,.tier-overlay.on,.sw-overlay.on,.wish-overlay.on,
    .lot-overlay.on,.gdn-overlay.gdn-open,.tip-overlay.on,.verdict.on,
    .gate:not(.hidden))){
    overflow:hidden;
  }

  body.mobile-chair.gd-railed{
    padding-bottom:var(--mobile-rail-clearance) !important;
  }

  /* gd-rail.css removes the old left gutter on phones. Restore equal page
     padding on both sides instead of leaving only the desktop right padding. */
  body.mobile-page.gd-railed > .wrap{
    padding-left:12px !important;
    padding-right:12px !important;
    padding-bottom:var(--mobile-rail-clearance) !important;
  }

  body.mobile-page .gd-rail-flyout{
    bottom:var(--mobile-rail-clearance);
    max-height:min(60dvh,560px);
    overscroll-behavior:contain;
  }
  body.mobile-page .gd-rail-flyout .admin-drawer{
    max-height:min(60dvh,560px);
  }
  body.mobile-page .gd-gear{
    width:44px;
    height:44px;
  }
  body.mobile-page .gd-menu-row{min-height:44px}

  /* Keep active overlays inside the browser's visible viewport. This avoids
     controls slipping behind a collapsing mobile address bar. */
  body.mobile-page :is(.cp-overlay,.overlay,.tb-overlay,.tier-overlay,
    .sw-overlay,.wish-overlay,.lot-overlay,.gdn-overlay,.tip-overlay,.verdict,.gate){
    padding-top:max(10px,var(--dev-safe-top));
    padding-right:10px;
    padding-bottom:max(10px,var(--dev-safe-bottom));
    padding-left:10px;
  }
  body.mobile-page .pm-overlay{padding:8px}
  body.mobile-page .pm-modal{
    height:calc(100dvh - 16px);
    max-height:calc(100dvh - 16px);
    border-radius:12px;
  }
  body.mobile-page .pm-overlay.fill{padding:0}
  body.mobile-page .pm-overlay.fill .pm-modal{
    height:100dvh;
    max-height:100dvh;
    border-radius:0;
  }
  body.mobile-page :is(.cp-modal,.amodal,.tier-modal,.sw-modal,.tb-modal,
    .tip-modal,.roller,.lot-modal){
    max-height:calc(100dvh - 20px);
    overflow-y:auto;
    overscroll-behavior:contain;
    -webkit-overflow-scrolling:touch;
  }
  body.mobile-page .gdn-panel{
    max-height:calc(100dvh - max(20px,var(--dev-safe-top)) - max(20px,var(--dev-safe-bottom)));
  }
  body.mobile-shop .wish-modal{
    height:calc(100dvh - max(20px,var(--dev-safe-top)) - max(20px,var(--dev-safe-bottom)));
    max-height:none;
  }
  body.mobile-shop .wish-list{min-height:0}

  /* Prevent iOS from zooming the page when a form control receives focus. */
  body.mobile-page :is(input,select,textarea){font-size:16px}

  /* Common player controls get thumb-friendly targets without making the
     compact desktop controls larger. */
  body.mobile-page :is(.pm-iconbtn,.pm-textsize,.amodal-x,.gdn-x,
    .tip-modal-x,.wish-close){
    min-width:44px;
    width:44px;
    min-height:44px;
    height:44px;
  }
  body.mobile-page :is(.copy-link,.suno-s,.yt-y){
    width:42px;
    height:42px;
  }
  body.mobile-page .pm-head{
    align-items:center;
    gap:10px;
    padding:14px 12px 11px;
  }
  body.mobile-page .pm-headbtns{margin-left:auto;gap:6px}
  body.mobile-page .pm-lyr-head{
    gap:8px;
    padding:12px;
  }
  body.mobile-page .pm-lyr-word{
    min-width:0;
    font-size:clamp(1rem,5.5vw,1.3rem);
    letter-spacing:.06em;
  }
  body.mobile-page .pm-lyr-btns{gap:6px}

  /* Fixed utilities must sit above the bottom navigation and phone safe area. */
  body.mobile-page :is(.to-top,.lp-to-top){
    bottom:calc(104px + var(--dev-safe-bottom)) !important;
  }
  body.mobile-page :is(.toast,.lp-toast){
    bottom:var(--mobile-rail-clearance) !important;
  }
  body.mobile-page .hype-meter{
    bottom:calc(88px + var(--dev-safe-bottom)) !important;
  }
  body.mobile-page :is(.perf-toggle,.admin-toggle){
    bottom:var(--mobile-rail-clearance) !important;
  }

  /* Live status and chat used to share the rail cluster's top-right corner. */
  body.mobile-page :is(.live-float,
    .chat-float:not(.pos-main):not(.pos-party):not(.pos-player):not(.pos-fill)){
    top:calc(var(--gd-chrome-top,14px) + 54px);
  }
  body.mobile-page :is(.chat-float.pos-main,.chat-float.pos-party),
  body.mobile-spin .chat-float{
    top:auto;
    bottom:var(--mobile-rail-clearance);
  }

  /* Horizontally browsable shelves and archives should settle on an item. */
  body.mobile-page :is(.arch-strip,.ap-shelf-items,.bk-scroll){
    scroll-snap-type:x proximity;
    scroll-padding-inline:12px;
    overscroll-behavior-inline:contain;
    -webkit-overflow-scrolling:touch;
  }
  body.mobile-page .arch-strip > *,
  body.mobile-page .bk-scroll > *{scroll-snap-align:start}
}

@media(max-width:600px){
  /* Landing page */
  body.mobile-index .intro{margin-top:52px}
  body.mobile-index .stage{width:100%;margin-top:0}
  body.mobile-index .choice{
    min-height:76px;
    display:flex;
    flex-direction:column;
    justify-content:center;
  }

  /* Diagnosis Engine: let short phones scroll instead of clipping the action
     buttons below a fixed 100vh stage. */
  body.mobile-spin{
    height:auto;
    min-height:100dvh;
    overflow-x:hidden;
    overflow-y:auto;
  }
  body.mobile-spin .stage{
    height:auto;
    min-height:100dvh;
    padding-bottom:var(--mobile-rail-clearance);
  }
  body.mobile-spin .engine{
    flex:none;
    justify-content:flex-start;
    gap:14px;
    padding:10px 12px;
  }
  body.mobile-spin .chamber{width:min(100%,620px)}
  body.mobile-spin .mut-zone{gap:10px}
  body.mobile-spin .vial{width:min(200px,calc(50vw - 18px))}
  body.mobile-spin .actions{
    gap:10px;
    padding:10px 12px 18px;
  }
  body.mobile-spin .actions .btn{
    width:min(100%,380px);
    min-height:50px;
    justify-content:center;
  }
  body.mobile-spin .verdict,
  body.mobile-spin .gate{overflow-y:auto}
  body.mobile-spin .chart{
    padding:24px 18px 30px;
    max-height:calc(100dvh - 20px);
    overflow-y:auto;
  }
  body.mobile-spin .seal{
    right:0;
    bottom:0;
    width:104px;
    height:104px;
  }

  /* Creator interviews */
  body.mobile-chair :is(.intro,.transcript,.showcase){padding-inline:14px}
  body.mobile-chair .turn{gap:8px}
  body.mobile-chair .avatar{width:42px;height:42px}
  body.mobile-chair .bubble{
    max-width:calc(100% - 50px);
    padding:12px 14px;
  }
  body.mobile-chair .q-divider{gap:10px;margin:28px 0 18px}
  body.mobile-chair .closing{margin-inline:14px;padding:20px 16px}
  body.mobile-chair .diagnosis{padding:20px 16px}
  body.mobile-chair .sc-banner{
    grid-template-columns:1fr;
    gap:14px;
    padding:20px 14px;
    text-align:center;
  }
  body.mobile-chair .sc-avatar{margin-inline:auto}
  body.mobile-chair .sc-body{padding:18px 14px}
  body.mobile-chair .sc-songs{grid-template-columns:1fr}

  /* Apothecary */
  body.mobile-shop .ap-head{
    gap:10px;
    padding:14px 12px;
  }
  body.mobile-shop .ap-head-text{flex-basis:calc(100% - 50px);min-width:0}
  body.mobile-shop .ap-wish-btn,
  body.mobile-shop .ap-lot-btn{min-height:44px}
  body.mobile-shop .ap-head-bal{min-height:44px}
  body.mobile-shop .ap-cab-arrow{
    width:44px;
    height:34px;
  }
  body.mobile-shop .lot-modal{padding:16px 12px}
  body.mobile-shop .lot-title{font-size:clamp(1.25rem,7vw,1.7rem)}

  /* Listening party controls and dense tool rows */
  body.mobile-listening :is(.view-toggle-row,.lp2-extra-controls,
    .party-host-controls,.pm-manage-head){align-items:stretch}
  body.mobile-listening :is(.view-toggle-row,.lp2-extra-controls) > *{
    min-height:44px;
  }
  body.mobile-listening :is(.ch-grant-row,.at-add-row){flex-wrap:wrap}
  body.mobile-listening :is(.ch-grant-row,.at-add-row) > :is(input,select){
    flex:1 1 180px;
    min-width:0;
  }
}

@media(prefers-reduced-motion:reduce){
  html{scroll-behavior:auto !important}
  body.mobile-page *,
  body.mobile-page *::before,
  body.mobile-page *::after{
    scroll-behavior:auto !important;
  }
}
