/* Spossity motion system (web). Curves come from shared/motion-tokens.js.
   Only transform and opacity animate, except the brief deletion collapse.
   SOS is intentionally excluded: its hold and countdown keep their own timing. */
:root {
  --sp-ease-snappy: cubic-bezier(.34, 1.4, .64, 1);
  --sp-ease-glide: cubic-bezier(.2, .9, .3, 1.03);
  --sp-ease-out: cubic-bezier(.22, .61, .36, 1);
  --sp-dur-snappy: 510ms;
  --sp-dur-glide: 375ms;
}
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --sp-ease-snappy: linear(0, 0.0278, 0.0998, 0.2004, 0.3169, 0.4388, 0.5583, 0.6697, 0.7692, 0.8547, 0.9253, 0.9813, 1.0235, 1.0534, 1.0725, 1.0828, 1.0859, 1.0837, 1.0777, 1.0691, 1.0591, 1.0486, 1.0384, 1.0287, 1.0202, 1.0128, 1.0066, 1.0018, 0.9981, 0.9955, 0.9938, 0.9929, 0.9926, 0.9928, 0.9933, 0.994, 0.9949, 0.9958, 0.9967, 0.9975, 1);
    --sp-ease-glide: linear(0, 0.0168, 0.0610, 0.1245, 0.2005, 0.2835, 0.3692, 0.4541, 0.5357, 0.6122, 0.6823, 0.7455, 0.8013, 0.8499, 0.8913, 0.9261, 0.9547, 0.9777, 0.9959, 1.0097, 1.0198, 1.0268, 1.0312, 1.0335, 1.0342, 1.0337, 1.0321, 1.0300, 1.0274, 1.0245, 1.0216, 1.0187, 1.0159, 1.0133, 1.0109, 1.0087, 1.0068, 1.0051, 1.0037, 1.0025, 1);
  }
}

/* 1. Elastic toggles: spring travel with overshoot, plus a stretch toward the
   direction of travel (individual `scale` so it composes with `transform`). */
.profile-location-toggle::after {
  transition: transform var(--sp-dur-snappy) var(--sp-ease-snappy) !important;
}
.profile-location-toggle.sp-stretch-on::after { transform-origin: left center; animation: sp-thumb-stretch 300ms var(--sp-ease-out); }
.profile-location-toggle.sp-stretch-off::after { transform-origin: right center; animation: sp-thumb-stretch 300ms var(--sp-ease-out); }
.timeline-location-switch span { transition: transform var(--sp-dur-snappy) var(--sp-ease-snappy); }
.timeline-location-switch[aria-checked="true"] span { left: 3px !important; transform: translateX(20px); }
.timeline-location-switch.sp-stretch-on span { transform-origin: left center; animation: sp-thumb-stretch 300ms var(--sp-ease-out); }
.timeline-location-switch.sp-stretch-off span { transform-origin: right center; animation: sp-thumb-stretch 300ms var(--sp-ease-out); }
@keyframes sp-thumb-stretch { 0% { scale: 1 1; } 35% { scale: 1.38 .94; } 100% { scale: 1 1; } }

/* 2. Reactions: spring pop on the icon, then a brief ring and particle burst. */
.sp-pop svg, .sp-pop > span[aria-hidden="true"] { animation: sp-pop 420ms var(--sp-ease-snappy); }
.sp-pop-soft svg { animation: sp-pop-soft 300ms var(--sp-ease-snappy); }
@keyframes sp-pop { 0% { scale: 1; } 30% { scale: 1.24; } 60% { scale: .95; } 100% { scale: 1; } }
@keyframes sp-pop-soft { 0% { scale: 1; } 40% { scale: .9; } 100% { scale: 1; } }
.sp-burst { position: fixed; z-index: 2147482000; width: 0; height: 0; pointer-events: none; color: var(--sp-burst-color, #7836ef); }
.sp-burst-ring { position: absolute; left: -18px; top: -18px; width: 36px; height: 36px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: sp-ring 520ms var(--sp-ease-out) forwards; }
.sp-burst-dot { position: absolute; left: -2.5px; top: -2.5px; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: 0; animation: sp-dot 560ms var(--sp-ease-out) forwards; }
@keyframes sp-ring { 0% { opacity: .55; transform: scale(.4); } 100% { opacity: 0; transform: scale(1.55); } }
@keyframes sp-dot { 0% { opacity: .9; transform: rotate(var(--a)) translateY(-8px) scale(1); } 100% { opacity: 0; transform: rotate(var(--a)) translateY(-26px) scale(.4); } }

/* 3. Contextual menus grow from their trigger and shrink back into it. */
.sp-menu-in { animation: sp-menu-in 300ms var(--sp-ease-snappy); }
.sp-menu-out { animation: sp-menu-out 160ms var(--sp-ease-out) forwards; pointer-events: none !important; }
@keyframes sp-menu-in { 0% { opacity: 0; transform: translateY(-6px) scale(.86); } 60% { opacity: 1; } 100% { opacity: 1; transform: none; } }
@keyframes sp-menu-out { 0% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-4px) scale(.9); } }

/* 4. Error feedback: one shake per failed submit, red outline until edited. */
.sp-field-error { outline: 2px solid #e5383b !important; outline-offset: 1px; border-color: #e5383b !important; }
.sp-shake { animation: sp-shake 420ms var(--sp-ease-out); }
@keyframes sp-shake { 0%, 100% { transform: translateX(0); } 15% { transform: translateX(-8px); } 30% { transform: translateX(7px); } 45% { transform: translateX(-5px); } 60% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

/* 5. Navigation indicators glide between tabs. The sidebar keeps its approved
   pill (same gradient and accent bar); it now moves instead of jumping. */
.sp-nav-indicator { position: absolute; left: 0; top: 0; z-index: 0; pointer-events: none; border-radius: 14px; transition: transform var(--sp-dur-glide) var(--sp-ease-glide), width var(--sp-dur-glide) var(--sp-ease-glide), height var(--sp-dur-glide) var(--sp-ease-glide); }
.sp-nav-indicator.sp-no-transition { transition: none; }
/* 5b. Segmented tabs and pill rows: one glowing thumb glides to the selected choice. */
.sp-seg { isolation: isolate; }
/* The thumb rides above the other choices while it glides and sits under the chosen one. */
.sp-seg-item { z-index: 1; }
.sp-seg-item.sp-seg-on { z-index: 3; }
.sp-seg-thumb { position: absolute; left: 0; top: 0; z-index: 2; pointer-events: none; border-radius: 999px;
  background: linear-gradient(140deg, #9a6bff 0%, #7b4dff 45%, #5b6cff 100%);
  transition: transform var(--sp-dur-snappy) var(--sp-ease-snappy), width var(--sp-dur-glide) var(--sp-ease-glide), height var(--sp-dur-glide) var(--sp-ease-glide), opacity .2s ease; }
html:root body .sp-seg-thumb { box-shadow: 0 6px 16px rgba(123, 77, 255, .36), inset 0 1px 0 rgba(255, 255, 255, .35) !important; }
html:root body .sp-seg-thumb.sp-seg-moving { box-shadow: 0 8px 22px rgba(123, 77, 255, .5), inset 0 1px 0 rgba(255, 255, 255, .4) !important; }
.sp-seg-thumb.sp-no-transition { transition: none; }
/* Doubled classes outrank every screen's own selected style, so only the thumb shows. */
html:root body .sp-seg.sp-seg .sp-seg-item.sp-seg-on.sp-seg-on, html:root body .sp-seg.sp-seg .sp-seg-item.sp-seg-on.sp-seg-on:hover { background: transparent !important; background-image: none !important; border-color: transparent !important; box-shadow: none !important; color: #fff !important; }
html:root body .sp-seg.sp-seg .sp-seg-item.sp-seg-on.sp-seg-on :is(strong, span, b, small) { color: #fff !important; }
html:root body .sp-seg.sp-seg .sp-seg-item.sp-seg-on.sp-seg-on::before, html:root body .sp-seg.sp-seg .sp-seg-item.sp-seg-on.sp-seg-on::after { opacity: 0 !important; }
.sp-seg :is(button, [role="tab"]):not(.sp-seg-thumb) { transition: color .25s var(--sp-ease-out), scale var(--sp-dur-snappy) var(--sp-ease-snappy); }
html:root body.is-logged-in .app-sidebar .app-nav.sp-has-indicator { position: relative; }
html:root body.is-logged-in .app-sidebar .app-nav.sp-has-indicator .app-nav-button { position: relative; z-index: 1; }
html:root body.is-logged-in .app-sidebar .app-nav.sp-has-indicator .app-nav-button.active { background: transparent !important; box-shadow: none !important; }
html:root body.is-logged-in .app-sidebar .app-nav.sp-has-indicator .app-nav-button.active::before { opacity: 0 !important; }
html:root body.is-logged-in .app-sidebar .app-nav .sp-nav-indicator { background: var(--nav-selected); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .16); }
html:root body.is-logged-in .app-sidebar .app-nav .sp-nav-indicator::before { content: ""; position: absolute; left: 0; top: 18px; bottom: 18px; width: 3px; border-radius: 3px; background: var(--nav-accent); }
html:not([data-theme="dark"]) body.is-logged-in .app-sidebar .app-nav .sp-nav-indicator { background: linear-gradient(90deg, rgba(33, 103, 245, .085), rgba(33, 103, 245, 0)); }
/* Bottom bar: a slim accent line under the active tab. */
.mobile-bottom-nav .sp-nav-indicator { top: auto; bottom: max(4px, env(safe-area-inset-bottom)); height: 3px !important; border-radius: 3px; background: var(--nav-accent, #7836ef); }

/* 6. Deletion: the item fades, shrinks and its space collapses. */
.sp-collapsing { overflow: hidden !important; pointer-events: none !important; transition: height 280ms var(--sp-ease-out), margin 280ms var(--sp-ease-out), padding 280ms var(--sp-ease-out), opacity 200ms var(--sp-ease-out), transform 280ms var(--sp-ease-out); }

@media (prefers-reduced-motion: reduce) {
  .profile-location-toggle::after, .timeline-location-switch span, .sp-nav-indicator, .sp-seg-thumb, .sp-seg button { transition: none !important; }
  .sp-stretch-on::after, .sp-stretch-off::after, .sp-stretch-on span, .sp-stretch-off span,
  .sp-pop svg, .sp-pop > span[aria-hidden="true"], .sp-pop-soft svg, .sp-menu-in, .sp-shake { animation: none !important; }
  .sp-burst, .sp-menu-out { display: none !important; }
  .sp-collapsing { transition: none !important; }
}

/* 7. Calling: the call screen shows the other person's full avatar on a stage
   (no photo). While an outgoing call rings, a soft violet glow pulses at their feet. */
.call-avatar-stage { position: relative; display: block; margin: 0 auto; width: 120px; height: 200px; }
.home-call-avatars .call-avatar-stage { width: clamp(170px, 18vw, 230px); height: clamp(280px, 30vw, 380px); }
.home-call-avatars:has(.call-avatar-stage) { padding-left: 0; }
html { --sp-ring-color: #7836ef; }
html[data-theme="dark"] { --sp-ring-color: #9b6cff; }
body.sp-call-ringing .call-avatar-stage::before, body.sp-call-ringing .call-avatar-stage::after {
  content: ""; position: absolute; left: 50%; bottom: 2%; width: 55%; height: 9%; margin-left: -27.5%;
  border-radius: 50%; background: var(--sp-ring-color); filter: blur(10px); opacity: 0; pointer-events: none;
  animation: sp-call-floor 2.4s linear infinite;
}
body.sp-call-ringing .call-avatar-stage::after { animation-delay: -1.2s; }
@keyframes sp-call-floor { 0% { opacity: 0; transform: scale(.7); } 15% { opacity: .35; } 100% { opacity: 0; transform: scale(1.6); } }
@media (prefers-reduced-motion: reduce) {
  body.sp-call-ringing .call-avatar-stage::before { animation: none; opacity: .22; }
  body.sp-call-ringing .call-avatar-stage::after { display: none; }
}

/* 7. One animated plus everywhere (see web/motion.js). Drawn with two bars so it can turn. */
.sp-plus { position: relative; display: inline-block; flex: none; width: .82em; height: .82em; vertical-align: -.08em; transition: transform var(--sp-dur-snappy) var(--sp-ease-snappy); }
.sp-plus::before, .sp-plus::after { content: ""; position: absolute; left: 50%; top: 50%; width: 100%; height: max(2px, .12em); border-radius: 99px; background: currentColor; transform: translate(-50%, -50%); }
.sp-plus::after { transform: translate(-50%, -50%) rotate(90deg); }
.sp-plus.sp-plus-lead { margin-right: .35em; width: .7em; height: .7em; }
[aria-expanded="true"] > .sp-plus, [aria-expanded="true"] > * > .sp-plus { transform: rotate(45deg); }
.sp-plus.sp-plus-pop { animation: sp-plus-pop .38s var(--sp-ease-snappy); }
@keyframes sp-plus-pop { 0% { scale: 1; } 35% { scale: .72; } 100% { scale: 1; } }
/* Trays opened by a plus flow out of it, one tool after another. */
:is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]) { transform-origin: left center; animation: sp-tray-grow .38s var(--sp-ease-snappy) both; }
:is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]) > * { animation: sp-tray-item .4s var(--sp-ease-snappy) both; }
:is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]) > :nth-child(2) { animation-delay: .05s; }
:is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]) > :nth-child(3) { animation-delay: .1s; }
:is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]) > :nth-child(4) { animation-delay: .15s; }
@keyframes sp-tray-grow { from { opacity: 0; transform: translateX(-8px) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes sp-tray-item { from { opacity: 0; transform: translateX(-10px) scale(.7); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .sp-plus, .sp-plus.sp-plus-pop, :is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]), :is(.vibe-message-tools, .comment-tools, [data-chat-action-tray]):not([hidden]) > * { animation: none !important; transition: none !important; }
}

/* 5c. Vibe person card: when you switch Family/Friends or page through people, the new card
   glides in from the side you are moving toward (individual `translate`, so it composes with
   the card's own map-position transform). */
@media (prefers-reduced-motion: no-preference) {
  .sp-card-in-next { animation: sp-card-in-next var(--sp-dur-glide) var(--sp-ease-glide) both; }
  .sp-card-in-prev { animation: sp-card-in-prev var(--sp-dur-glide) var(--sp-ease-glide) both; }
}
@keyframes sp-card-in-next { 0% { opacity: 0; translate: 26px 0; scale: .97; } 100% { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes sp-card-in-prev { 0% { opacity: 0; translate: -26px 0; scale: .97; } 100% { opacity: 1; translate: 0 0; scale: 1; } }

/* 8. Pop-ups (every <dialog>): the panel springs up and fades in on the glide spring
   while the backdrop fades; on close it settles back down (web/motion.js plays the exit
   before the real close). Individual `translate`/`scale` compose with each dialog's own
   positioning transform. Dialogs that need to stay still carry data-motion="none". */
html { --sp-dur-exit: 160ms; }
dialog[open]:not([data-motion="none"]):not([class*="sos"]) { animation: sp-sheet-in var(--sp-dur-glide) var(--sp-ease-glide) backwards; }
dialog[open]:not([data-motion="none"])::backdrop { animation: sp-backdrop-in var(--sp-dur-glide) var(--sp-ease-out) both; }
dialog.sp-dialog-out[open] { animation: sp-sheet-out var(--sp-dur-exit) var(--sp-ease-out) forwards !important; pointer-events: none; }
dialog.sp-dialog-out[open]::backdrop { animation: sp-backdrop-out var(--sp-dur-exit) var(--sp-ease-out) forwards !important; }
@keyframes sp-sheet-in { 0% { opacity: 0; translate: 0 16px; scale: .975; } 60% { opacity: 1; } 100% { opacity: 1; translate: 0 0; scale: 1; } }
@keyframes sp-sheet-out { 0% { opacity: 1; translate: 0 0; scale: 1; } 100% { opacity: 0; translate: 0 10px; scale: .985; } }
@keyframes sp-backdrop-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes sp-backdrop-out { from { opacity: 1; } to { opacity: 0; } }
/* 8b. Overlay pop-ups (panels with role="dialog" outside a <dialog>; web/motion.js): the same
   spring in and settle out, and their backdrop fades. */
.sp-pop-in { animation: sp-sheet-in var(--sp-dur-glide) var(--sp-ease-glide) backwards; }
.sp-pop-out { animation: sp-sheet-out var(--sp-dur-exit) var(--sp-ease-out) forwards !important; }
.sp-overlay-in { animation: sp-backdrop-in var(--sp-dur-glide) var(--sp-ease-out) backwards; }
.sp-overlay-out { animation: sp-backdrop-out var(--sp-dur-exit) var(--sp-ease-out) forwards !important; }
.sp-overlay-ghost { pointer-events: none !important; }
/* Full-page sheets keep the same feel (Notifications, Host Event and Spots forms). */
.event-studio-position-modal:not([hidden]) .event-studio-position-dialog { animation-duration: var(--sp-dur-glide); }

/* 9. Screens: each main page (Home, Vibe, Live, Timeline, Me, Spots) rises in on the
   glide spring when you switch to it, the same as the iPhone and iPad tabs. */
@keyframes sp-screen-in { 0% { opacity: 0; translate: 0 12px; } 70% { opacity: 1; } 100% { opacity: 1; translate: 0 0; } }
.sp-screen-in { animation: sp-screen-in var(--sp-dur-glide) var(--sp-ease-glide) backwards; }
/* `backwards`, not `both`: once settled no transform is left behind, so full-screen
   pieces inside a page (studio stage, map, pop-ups) keep the viewport as their frame. */
html:root body :is(.home-view, .vibe-view, .live-view, .timeline-view, .me-view, .event-studio-view, .avatar-studio-view):not([hidden]) { animation: sp-screen-in var(--sp-dur-glide) var(--sp-ease-glide) backwards; }

/* 10. Press feedback: buttons and cards dip to 97% while pressed and spring back
   (individual `scale`, so it never fights a component's own transform). */
:where(button, [role="button"], a.button, .card-button, summary):not(:disabled):not([aria-disabled="true"]):not([data-press="none"]) { transition-property: scale; transition-duration: var(--sp-dur-snappy); transition-timing-function: var(--sp-ease-snappy); }
:where(button, [role="button"], a.button, .card-button, summary):not(:disabled):not([aria-disabled="true"]):not([data-press="none"]):active { scale: .97; transition-duration: 90ms; transition-timing-function: var(--sp-ease-out); }

/* 10b. Me detail pages (Profile Photo, Account, Invite, Block, Spossity meter, …): the page rises in
   on the glide spring like the app's Me detail pages, and its rows follow one after another.
   Every detail button glides its colour and lifts slightly under the pointer, then dips on press. */
@media (prefers-reduced-motion: no-preference) {
  html:root body .profile-settings-panel:not([hidden]) > :not(.profile-panel-close) { animation: sp-screen-in var(--sp-dur-glide) var(--sp-ease-glide) backwards; }
  html:root body .profile-settings-panel:not([hidden]) > :nth-child(3) { animation-delay: 30ms; }
  html:root body .profile-settings-panel:not([hidden]) > :nth-child(4) { animation-delay: 60ms; }
  html:root body .profile-settings-panel:not([hidden]) > :nth-child(n+5) { animation-delay: 90ms; }
  html:root body .profile-settings-panel:not([hidden]) :is(.profile-settings-account, .profile-invite-options, .profile-setting-stack, .profile-menu-list) > * { animation: sp-screen-in var(--sp-dur-glide) var(--sp-ease-glide) backwards; }
  html:root body .profile-settings-panel:not([hidden]) :is(.profile-settings-account, .profile-invite-options, .profile-setting-stack, .profile-menu-list) > :nth-child(2) { animation-delay: 110ms; }
  html:root body .profile-settings-panel:not([hidden]) :is(.profile-settings-account, .profile-invite-options, .profile-setting-stack, .profile-menu-list) > :nth-child(3) { animation-delay: 140ms; }
  html:root body .profile-settings-panel:not([hidden]) :is(.profile-settings-account, .profile-invite-options, .profile-setting-stack, .profile-menu-list) > :nth-child(4) { animation-delay: 170ms; }
  html:root body .profile-settings-panel:not([hidden]) :is(.profile-settings-account, .profile-invite-options, .profile-setting-stack, .profile-menu-list) > :nth-child(5) { animation-delay: 200ms; }
  html:root body .profile-settings-panel:not([hidden]) :is(.profile-settings-account, .profile-invite-options, .profile-setting-stack, .profile-menu-list) > :nth-child(n+6) { animation-delay: 230ms; }
}
html:root body :is(.profile-security-action, .profile-invite-option):not(:disabled) {
  transition: scale var(--sp-dur-snappy) var(--sp-ease-snappy), translate var(--sp-dur-snappy) var(--sp-ease-snappy),
    background-color .25s var(--sp-ease-out), border-color .25s var(--sp-ease-out), box-shadow .25s var(--sp-ease-out), color .25s var(--sp-ease-out);
}
@media (hover: hover) {
  /* Profile rows and actions tint under the pointer (web/styles/profile-canonical.css); cards lift. */
  html:root body .profile-invite-option:not(:disabled):hover { translate: 0 -1px; box-shadow: 0 8px 20px rgba(123, 77, 255, .18); }
}
html:root body .profile-security-action:focus-visible { outline: 2px solid #9b6cff; outline-offset: 2px; }
html:root body :is(.profile-security-action, .profile-invite-option):not(:disabled):active { translate: 0 0; scale: .97; transition-duration: 90ms; transition-timing-function: var(--sp-ease-out); }
/* Profile photo: a new photo springs into the frame (web/motion.js swapIn). */
.sp-swap-in > img { animation: sp-photo-in var(--sp-dur-snappy) var(--sp-ease-snappy); }
@keyframes sp-photo-in { 0% { opacity: .35; scale: .9; } 100% { opacity: 1; scale: 1; } }

/* 11. Reduce Motion: the system setting or the account's "Reduce motion" (html.reduce-motion)
   turns every transition and animation into an instant change. SOS keeps its own timing. */
@media (prefers-reduced-motion: reduce) {
  html:root *:not([class*="sos"], [class*="sos"] *), html:root *::before, html:root *::after, html:root *::backdrop { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
}
html.reduce-motion:root *:not([class*="sos"], [class*="sos"] *), html.reduce-motion:root *::before, html.reduce-motion:root *::after, html.reduce-motion:root *::backdrop { animation-duration: 1ms !important; animation-iteration-count: 1 !important; animation-delay: 0ms !important; transition-duration: 1ms !important; transition-delay: 0ms !important; scroll-behavior: auto !important; }
