/* V64 — motion pass. Only places where motion has a job: sheets that arrive and
   leave the same way, a drag-to-dismiss handle that actually works, a toast that
   enters and exits through the same edge, a sliding segment indicator, quiet
   reloads, smooth accordions and one small celebration for unlocks.
   transform/opacity only (plus `translate`, which composes with the existing
   translateX(-50%) on sheets). */
:root{
  --swm-ease-out:cubic-bezier(0.23,1,0.32,1);
  --swm-ease-drawer:cubic-bezier(0.32,0.72,0,1);
}

/* ---------- Sheets: enter and exit along the same path ---------- */
.sheet.is-closing{display:block}
.sheet.is-closing{pointer-events:none}
.sheet .sheet-content{animation:none!important;translate:0 0;transition:translate 420ms var(--swm-ease-drawer)}
.sheet .sheet-backdrop{opacity:1;transition:opacity 300ms var(--swm-ease-out)}
.sheet.is-entering .sheet-content,.sheet.is-closing .sheet-content{translate:0 100%}
.sheet.is-entering .sheet-backdrop,.sheet.is-closing .sheet-backdrop{opacity:0}
.sheet.is-closing .sheet-content{transition-duration:280ms}
.sheet.is-closing .sheet-backdrop{transition-duration:240ms}
.sheet.is-dragging .sheet-content{transition:none}

/* The handle promises a drag; give it a real hit area and the right cursor. */
.sheet-handle{position:relative;touch-action:none;cursor:grab}
.sheet-handle:after{content:"";position:absolute;inset:-14px -70px}
.sheet.is-dragging .sheet-handle{cursor:grabbing}
.sheet-title{touch-action:none}

/* ---------- Toast: in and out through the top edge ---------- */
.toast{top:max(28px,calc(env(safe-area-inset-top) + 12px));opacity:0;transform:translate(-50%,calc(-100% - 48px));transition:transform 400ms var(--swm-ease-out),opacity 200ms var(--swm-ease-out)!important;pointer-events:none}
.toast.show{opacity:1;transform:translate(-50%,0)}

/* ---------- Segmented control: the active pill slides instead of jumping ---------- */
.swm-segmented{position:relative;isolation:isolate;--seg-count:2;--seg-index:0;--seg-gap:4px;--seg-pad:4px}
.swm-segmented:has(> :nth-child(3)){--seg-count:3}
.swm-segmented::before{content:"";position:absolute;z-index:-1;top:var(--seg-pad);bottom:var(--seg-pad);left:var(--seg-pad);
  width:calc((100% - 2 * var(--seg-pad) - (var(--seg-count) - 1) * var(--seg-gap)) / var(--seg-count));
  border-radius:10px;background:linear-gradient(180deg,#1d2a40,#162034);box-shadow:inset 0 0 0 1px #3a4d6e,0 4px 14px #0006;
  transform:translateX(calc((100% + var(--seg-gap)) * var(--seg-index)));transition:transform 240ms var(--swm-ease-out)}
.swm-segmented-small::before{border-radius:8px}
.swm-segmented button.is-active{background:transparent!important;box-shadow:none!important}

/* ---------- Quiet reloads: keep the old list, dim it, never flash a loading text ---------- */
.is-refreshing{opacity:.45;transition:opacity 150ms var(--swm-ease-out)}
#scoreboard-list,#crew-home,#crew-ranking{transition:opacity 200ms var(--swm-ease-out)}

/* ---------- Accordions open smoothly where the browser supports it ---------- */
@supports (interpolate-size:allow-keywords) and selector(::details-content){
  .profile-menu-details,.settings-group,.crew-invite-panel,.crew-edit,.combo-admin-section,.analytics-group,.collab-picker{interpolate-size:allow-keywords}
  .profile-menu-details::details-content,.settings-group::details-content,.crew-invite-panel::details-content,.crew-edit::details-content,.combo-admin-section::details-content,.analytics-group::details-content,.collab-picker::details-content{
    height:0;opacity:0;overflow:clip;transition:height 260ms var(--swm-ease-out),opacity 200ms var(--swm-ease-out),content-visibility 260ms allow-discrete}
  .profile-menu-details[open]::details-content,.settings-group[open]::details-content,.crew-invite-panel[open]::details-content,.crew-edit[open]::details-content,.combo-admin-section[open]::details-content,.analytics-group[open]::details-content,.collab-picker[open]::details-content{height:auto;opacity:1}
}

/* ---------- Unlock: rare, so it is allowed a small celebration ---------- */
.cosmetic-unlock-sheet .unlock-kicker,.cosmetic-unlock-sheet h2{animation:swm-rise 360ms var(--swm-ease-out) both}
.cosmetic-unlock-sheet h2{animation-delay:60ms}
.cosmetic-unlock-sheet .unlock-items>*{animation:swm-unlock-pop 520ms var(--swm-ease-out) both;animation-delay:calc(160ms + var(--i,0) * 70ms)}
.cosmetic-unlock-sheet .unlock-items>*:nth-child(2){--i:1}.cosmetic-unlock-sheet .unlock-items>*:nth-child(3){--i:2}.cosmetic-unlock-sheet .unlock-items>*:nth-child(4){--i:3}.cosmetic-unlock-sheet .unlock-items>*:nth-child(n+5){--i:4}
@keyframes swm-rise{from{opacity:0;transform:translateY(8px)}to{opacity:1;transform:translateY(0)}}
@keyframes swm-unlock-pop{0%{opacity:0;transform:scale(.7) translateY(10px)}60%{opacity:1;transform:scale(1.06) translateY(0)}100%{opacity:1;transform:scale(1)}}

/* ---------- Press feedback: tabs are tapped dozens of times a day, keep it subtle ---------- */
.tab{transition:transform 120ms var(--swm-ease-out)}
.tab:active{transform:scale(.96)}

/* ---------- Response: no grey tap flash, no double-tap delay, no accidental text selection on controls ---------- */
html{-webkit-tap-highlight-color:transparent}
button,[role="button"],.tab,.sheet-handle,summary{touch-action:manipulation;-webkit-user-select:none;user-select:none}

/* ---------- Depth: the app steps back while a sheet is in front (iOS sheet presentation) ---------- */
.app{transform-origin:50% 0;transition:transform 420ms var(--swm-ease-drawer),border-radius 420ms var(--swm-ease-drawer)}
body.sheet-presented .app{transform:translateY(10px) scale(.94);border-radius:18px;overflow:hidden}

/* With motion.dev loaded, springs drive sheets and depth from JS; switch the CSS transitions off. */
.swm-motion .sheet .sheet-content{transition:none!important}
.swm-motion .app{transition:none!important}
.swm-motion body.sheet-presented .app{transform:none}
/* The open spring overshoots a little; extend the sheet's colour below its edge so no gap shows. */
.swm-motion .sheet .sheet-content{box-shadow:0 80px 0 0 #0b111c}

/* NumberFlow inherits the score's type; keep digits tabular so the row doesn't shift. */
number-flow{font-variant-numeric:tabular-nums}
#scoreboard-own-points{background:none!important;-webkit-background-clip:border-box!important;background-clip:border-box!important;color:#f2f5fb!important;-webkit-text-fill-color:#f2f5fb}

/* ---------- Materials respect accessibility settings ---------- */
@media (prefers-reduced-transparency:reduce){
  .topbar,.tabbar,.toast,.launch-tip{backdrop-filter:none!important;-webkit-backdrop-filter:none!important}
  .topbar{background:#05070c!important}
  .tabbar{background:#080c15!important}
  .toast{background:#121a29!important}
}
@media (prefers-contrast:more){
  .tabbar{border-top:1px solid #8da6d8!important}
  .sheet-content{border:1px solid #8da6d8!important}
  .friends-empty,.scoreboard-note,.post-time{color:#c9d3e3!important}
}

/* ---------- Reduced motion: no sliding, but a gentle fade still explains what happened ---------- */
@media (prefers-reduced-motion:reduce){
  .sheet .sheet-content{transition:opacity 200ms ease!important;translate:none!important}
  .sheet.is-entering .sheet-content,.sheet.is-closing .sheet-content{opacity:0}
  .sheet .sheet-backdrop{transition:opacity 200ms ease!important}
  .toast{transform:translate(-50%,0);transition:opacity 200ms ease!important}
  .swm-segmented::before{transition:none!important}
  body.sheet-presented .app{transform:none;border-radius:inherit}
}
