/* Phone pass, loaded last (behaviour in mobile.js): tucking top bar, scroller edge fades, bottom
   sheets, a readable floor for small labels, and short landscape screens. */

/* ---------- top bar tucks away while scrolling down ---------- */
@media(max-width:760px),(max-height:500px) and (orientation:landscape){
  .topbar{transition:transform .25s ease;backdrop-filter:none;-webkit-backdrop-filter:none}
  .topbar.is-tucked{transform:translateY(-100%)}
}

/* ---------- compact header (mobile.js folds the account tools into the ☰ menu) ----------
   Brand row + one row of community tabs with Join LSU. "Community home" is the menu's "Enter LSU". */
@media(max-width:760px),(max-height:500px) and (orientation:landscape){
  .community-subnav-heading{display:none}
  .community-subnav-inner{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:0 8px;min-height:0;padding-top:0;padding-bottom:0}
  .community-feature-links{grid-column:1;grid-row:1;--fade:44px}
  .community-actions{grid-column:2;grid-row:1;flex-wrap:nowrap!important}
  .subnav-account{min-height:38px;padding:6px 12px;font-size:.74rem;white-space:nowrap}

  .nav-extras{display:flex;flex-wrap:wrap;align-items:center;gap:8px;padding:4px 0 12px;margin-bottom:6px;border-bottom:1px solid var(--line)}
  .nav-extras .subnav-signin{color:var(--paper);font-size:.88rem;padding:0 12px 0 0}
  .nav-extras .quick-trigger,.nav-extras .translate-trigger{color:var(--paper);border-color:#ffffff40;font-size:.8rem;min-width:0;padding:0 12px}
  .nav-extras .translate-trigger span{font-size:1rem}
  .nav-extras .translate-menu[open]{flex-basis:100%;order:5}
  .nav-extras .translate-panel{position:static;width:auto;max-height:none;margin-top:8px;box-shadow:none}
  .nav-extras .unit-switch{margin:0 0 0 auto}
  .nav-extras .unit-help-panel{position:fixed;top:66px;left:12px;right:12px;width:auto}
}
@media(max-width:560px){
  .brand-name{white-space:nowrap;max-width:none;overflow:hidden;text-overflow:ellipsis}
}

/* ---------- touch feedback ---------- */
@media(hover:none){
  a,button,summary,[role=button]{-webkit-tap-highlight-color:#dfb56c40}
}

@media(max-width:760px){
  /* The action bar steps aside for dialogs and the on-screen keyboard. */
  html.modal-open .mobile-actions,
  body:has(:is(input:not([type=checkbox]):not([type=radio]),textarea,select):focus) .mobile-actions{display:none}

  /* Hero headline scales smoothly with the screen: 3 lines from 360 px up. */
  .hero h1{font-size:clamp(1.8rem,8vw,2.6rem);line-height:1.08}

  /* The action bar waits until the hero (and its search box) has scrolled away. */
  html.actions-wait:not(.past-hero) .mobile-actions{transform:translateY(110%);visibility:hidden}
  .mobile-actions{transition:transform .25s ease,visibility .25s}

  /* ---------- horizontal scrollers fade only where more content waits ---------- */
  :is(.community-feature-links,.layer-controls,.scene-tabs,.program-grid,.rm-table-wrap)[data-edge]{--fade:28px}
  :is(.community-feature-links,.layer-controls,.scene-tabs,.program-grid)[data-edge=""]{-webkit-mask-image:none;mask-image:none}
  :is(.community-feature-links,.layer-controls,.scene-tabs,.program-grid,.rm-table-wrap)[data-edge=end]{-webkit-mask-image:linear-gradient(to right,#000 calc(100% - var(--fade)),transparent);mask-image:linear-gradient(to right,#000 calc(100% - var(--fade)),transparent)}
  :is(.community-feature-links,.layer-controls,.scene-tabs,.program-grid)[data-edge=start]{-webkit-mask-image:linear-gradient(to left,#000 calc(100% - var(--fade)),transparent);mask-image:linear-gradient(to left,#000 calc(100% - var(--fade)),transparent)}
  :is(.community-feature-links,.layer-controls,.scene-tabs,.program-grid)[data-edge=both]{-webkit-mask-image:linear-gradient(to right,transparent,#000 var(--fade),#000 calc(100% - var(--fade)),transparent);mask-image:linear-gradient(to right,transparent,#000 var(--fade),#000 calc(100% - var(--fade)),transparent)}
  /* The roadmap table keeps its sticky first column crisp: fade the far edge only. */
  .rm-table-wrap[data-edge=both]{-webkit-mask-image:linear-gradient(to right,#000 calc(100% - var(--fade)),transparent);mask-image:linear-gradient(to right,#000 calc(100% - var(--fade)),transparent)}
  .rm-table-wrap[data-edge=start]:after,.rm-table-wrap[data-edge=""]:after{visibility:hidden}

  /* ---------- dialogs open as bottom sheets (swipe down to close) ---------- */
  .dialog-backdrop:not(.account-dialog){align-items:flex-end;padding:0}
  .rm-dialog-backdrop{place-items:end center;padding:0}
  .dialog-backdrop:not(.account-dialog)>.dialog,.rm-dialog-backdrop>.rm-dialog{
    width:100%;max-height:calc(100dvh - 32px - env(safe-area-inset-top));border-radius:18px 18px 0 0;
    padding-top:34px;padding-bottom:calc(20px + env(safe-area-inset-bottom));
    transition:transform .22s ease;animation:sheet-up .3s cubic-bezier(.2,.8,.2,1)}
  .dialog-backdrop:not(.account-dialog)>.dialog:before,.rm-dialog-backdrop>.rm-dialog:before{content:"";position:absolute;top:10px;left:50%;width:40px;height:4px;margin-left:-20px;border-radius:2px;background:#18232340}
  .rm-dialog-backdrop>.rm-dialog{position:relative}
  .dialog-backdrop>.dialog.is-dragging,.rm-dialog-backdrop>.rm-dialog.is-dragging{transition:none}
  .dialog-backdrop:not(.account-dialog) .dialog-close{top:12px}

  /* ---------- readable floor for small uppercase labels (11px) ---------- */
  .globe-ui,.rm-scene-ui,.ll-centre small,.sx-chip span,.sx-group h3,.ll-private,.status-pill,.founding-status,
  .hero-note,.h3d-note,.h3d-label,.h3d-read,.vs-phase,.vs-note,.sk-label.vs-layer,.gt-phase,.gt-note,.vs-hud,.gt-hud,.fl3d-label,
  .atlas-scene-head,.atlas-detail-grid h4,.atlas-tool h4,.atlas-relation,.atlas-path-step span,.mission-goal,.scenario-reading dt,
  .atlas-passport dt,.passport-kind,.trace-chain span,.mission-card-n,.mission-rail .rail-n,.mission-rail .rail-label,.msc-head,
  .status,.passport .eyebrow,.passport dt,.state,.sample-art,.goal span:first-child,.goal-detail-grid h4,.pilot-facts dt,
  .footer-group .footer-title,.scene-index,.scene-question strong,.program-card .program-status,.pilot-facts div small,
  .pilot-sequence-label,.pilot-phase-head .eyebrow,.pilot-phase-details h4,.point-record figcaption{font-size:.7rem}
  .hero-motion-controls .pause-motion,.hero-replay{font-size:.72rem}
}
@media(max-width:520px){.subnav-account{font-size:.7rem}}
@media(max-width:390px){.community-home{font-size:.7rem}}
/* The translate trigger becomes an icon below 430px: keep its text hidden. */
@media(max-width:430px){.translate-trigger{font-size:0}}

@keyframes sheet-up{from{transform:translateY(100%)}}
@media(prefers-reduced-motion:reduce){
  .topbar,.mobile-actions,.dialog-backdrop>.dialog,.rm-dialog-backdrop>.rm-dialog{transition:none!important;animation:none!important}
}

/* ---------- short landscape screens ---------- */
@media(max-height:500px) and (orientation:landscape){
  .dialog-backdrop,.rm-dialog-backdrop{padding:8px}
  .dialog,.rm-dialog{max-height:calc(100dvh - 16px)}
  .account-dialog .dialog{max-height:100dvh}
  .navlinks{max-height:calc(100dvh - 64px)}
}

/* ---------- phones: search lives behind a top-bar icon; the hero gives its space to the 3D scene ---------- */
.search-toggle{display:none}
@media(max-width:760px){
  .nav .search-toggle{order:3;display:block;flex:none;margin-left:auto;min-width:44px;min-height:44px;background:none;border:1px solid var(--line);color:var(--paper);position:relative}
  .search-toggle:before{content:"";position:absolute;left:13px;top:12px;width:13px;height:13px;border:2px solid currentColor;border-radius:50%}
  .search-toggle:after{content:"";position:absolute;left:26px;top:28px;width:7px;height:2px;background:currentColor;transform:rotate(45deg);transform-origin:left center}
  .search-toggle:active{color:var(--amber)}
  .hero .lsu-search{display:none}

  /* Leave an open band of terrain under the copy and lift the veil so the scene reads. */
  .hero{padding-bottom:max(150px,40svh)}
  .hero.has-3d:after{background:linear-gradient(180deg,rgba(16,26,27,.88) 0%,rgba(16,26,27,.66) calc(100% - 46svh),rgba(16,26,27,0) calc(100% - 22svh))}
  .hero-copy{text-shadow:0 1px 12px #101a1bcc}
}
