/* Navigation and working views. The product owns selection and disclosure state. */
@media screen and (prefers-reduced-motion: no-preference) {
  /* Lovable. Animate the existing button rotation; the sidebar owns its direction. */
  .sidebar[data-sidebar] .sidebar-toggle {
    transition: transform var(--mi-state) var(--mi-ease), color var(--mi-fast), border-color var(--mi-fast);
  }
  /* Banky. Only the first few rows of the opened phone menu are sequenced. */
  @media (max-width: 768px) {
    .sidebar[data-sidebar].mobile-open .nav-menu > li:nth-child(-n+4) > .nav-link {
      animation: mi-menu-row var(--mi-state) var(--mi-ease) backwards;
    }
    .sidebar.mobile-open .nav-menu > li:nth-child(2) { --mi-row-delay: 24ms; }
    .sidebar.mobile-open .nav-menu > li:nth-child(3) { --mi-row-delay: 48ms; }
    .sidebar.mobile-open .nav-menu > li:nth-child(4) { --mi-row-delay: 72ms; }
    .sidebar[data-sidebar].mobile-open .nav-menu > li:nth-child(-n+4) > .nav-link { animation-delay: var(--mi-row-delay, 0ms); }
    .sidebar[data-sidebar].mobile-open .nav-menu > li > .nav-link:focus-visible { animation: none; }
    @keyframes mi-menu-row { from { opacity: .65; translate: -4px 0; } to { opacity: 1; translate: 0 0; } }
  }

  /* Ethos. Light passes across the one primary action. */
  body.cmd-page .cmd-next .cmd-btn-primary {
    background-image: linear-gradient(110deg, var(--cmd-gold) 28%, #ffe5a1 52%, var(--cmd-gold) 78%);
    background-size: 240% 100%;
    background-position: 100% center;
    transition: background-position 260ms var(--mi-ease), box-shadow var(--mi-fast) var(--mi-ease);
  }
  /* Claude. The existing underline tracks the selected view; the surface crossfades with it. */
  body.opportunity-page .opp-view-switch button[aria-selected] {
    transition: background-color var(--mi-state) var(--mi-ease), color var(--mi-state) var(--mi-ease), scale var(--mi-fast) var(--mi-ease);
  }
  /* SVZ. Bring the backdrop up behind the icon without moving the nav label. */
  .sidebar[data-sidebar] .nav-link .nav-icon { position: relative; isolation: isolate; }
  .sidebar[data-sidebar] .nav-link .nav-icon::before {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 7px;
    pointer-events: none;
    z-index: -1;
    background: var(--mx-selected-surface);
    opacity: 0;
    scale: .76;
    transition: scale var(--mi-fast) var(--mi-ease), opacity var(--mi-fast) var(--mi-ease);
  }
  /* Ventriloc. Two fine inset marks frame the action on intent. */
  .xln-profile .profile-actions > :is(a.btn, button.btn):not(:disabled) {
    transition: box-shadow var(--mi-state) var(--mi-ease), background-color var(--mi-fast) var(--mi-ease), border-color var(--mi-fast) var(--mi-ease);
  }
  /* Spendesk. Indicate that the entire community card opens a destination. */
  .xln-community-grid .xln-community { position: relative; }
  .xln-community-grid .xln-community::after {
    content: "";
    pointer-events: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #102238 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3 8h9M8 4l4 4-4 4' fill='none' stroke='white' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5'/%3E%3C/svg%3E") center / 15px no-repeat;
    opacity: 0;
    translate: -4px 0;
    transition: opacity var(--mi-fast) var(--mi-ease), translate var(--mi-state) var(--mi-ease);
  }
  /* Ideogram. The date already reads at rest; a pill picks it out on intent. */
  .cal-page :is(.cal-upcoming-item > span:last-child > span, .cal-event small) {
    width: fit-content;
    max-width: 100%;
    border-radius: 4px;
    transition: box-shadow var(--mi-fast) var(--mi-ease), background-color var(--mi-fast) var(--mi-ease);
  }
  @media (hover: hover) and (pointer: fine) {
    body.cmd-page .cmd-next .cmd-btn-primary:hover { background-position: 0 center; }
    .sidebar[data-sidebar] .nav-link:hover .nav-icon::before { opacity: 1; scale: 1; }
    .xln-profile .profile-actions > :is(a.btn, button.btn):not(:disabled):not([aria-disabled="true"]):hover { box-shadow: inset 2px 0 currentColor, inset -2px 0 currentColor; }
    .xln-community-grid a:hover .xln-community::after, .xln-community-grid .xln-community:hover::after { opacity: 1; translate: 0 0; }
    .cal-page :is(.cal-upcoming-item:hover > span:last-child > span, .cal-event:hover small) { background-color: var(--mx-selected-surface); box-shadow: 0 0 0 3px var(--mx-selected-surface); }
  }
  body.cmd-page .cmd-next .cmd-btn-primary:is(:focus-visible, :active) { background-position: 0 center; }
  .sidebar[data-sidebar] .nav-link:focus-visible .nav-icon::before { opacity: 1; scale: 1; }
  .xln-profile .profile-actions > :is(a.btn, button.btn):focus-visible { box-shadow: inset 2px 0 currentColor, inset -2px 0 currentColor; }
  .xln-community-grid a:focus-visible .xln-community::after, .xln-community-grid .xln-community:focus-visible::after { opacity: 1; translate: 0 0; }
  .cal-page :is(.cal-upcoming-item:focus-visible > span:last-child > span, .cal-event:focus-visible small) { background-color: var(--mx-selected-surface); box-shadow: 0 0 0 3px var(--mx-selected-surface); }
}

/* Public pages and account setup. The resting layout and tab order are also the fallback. */
@media screen {
  /* Clay's directional arrow moves independently of its hit target. */
  :is(.simple-button--hero, .lp5-hero .lp5-btn, .zc-hero-action .zc-button, .vnext-hero .vnext-button-primary) > svg {
    transition: translate var(--mi-fast) var(--mi-ease);
  }

  /* LAS Art Foundation's editorial bullet occupies the gutter between links. */
  :is(.simple-footer nav a, .lp5-footer nav a, .zc-footer nav a, .vnext-footer > a, .cr-footer nav a) { position: relative; }
  :is(.simple-footer nav a, .lp5-footer nav a, .zc-footer nav a, .vnext-footer > a, .cr-footer nav a)::before {
    content: "";
    position: absolute;
    inset-inline-start: -.64em;
    top: calc(50% - 2px);
    width: 4px;
    height: 4px;
    background: currentColor;
    border-radius: 50%;
    opacity: 0;
    scale: .4;
    transition: opacity var(--mi-fast) var(--mi-ease), scale var(--mi-fast) var(--mi-ease);
  }

  /* Cubex's header pill changes contrast in place. */
  :is(body.simple .simple-header-actions .simple-button--header, .zc-header-actions .zc-button-small, .lp5-header .lp5-btn--sm, .vnext-header .vnext-button-outline) {
    transition: background-color var(--mi-fast) var(--mi-ease), color var(--mi-fast) var(--mi-ease);
  }

  /* Inversion's closing CTA carries an ink fill from the arrow end of the pill. */
  body.simple :is(.simple-close, .simple-proof-card) .simple-button--dark {
    color: white;
    background-color: #182c42;
    background-image: linear-gradient(90deg, #304c67, #304c67);
    background-position: right;
    background-size: 0% 100%;
    background-repeat: no-repeat;
    transition: background-size var(--mi-state) var(--mi-ease);
  }
  body.simple :is(.simple-close, .simple-proof-card) .simple-button--dark > svg {
    box-sizing: content-box;
    width: 16px;
    height: 16px;
    padding: 5px;
    border-radius: 50%;
    background-color: #304c67;
  }

  /* Lobelia's arrow badge is decorative; the label, busy indication and submit stay native. */
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit) {
    position: relative;
    padding-inline: 44px;
  }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit)::before,
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit)::after {
    content: "";
    position: absolute;
    top: 50%;
    pointer-events: none;
    translate: 0 -50%;
  }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit)::before {
    width: 24px;
    height: 24px;
    inset-inline-end: 12px;
    box-sizing: border-box;
    border-radius: 50%;
    border: 1px solid currentColor;
    background: currentColor;
    transition: background-color var(--mi-fast) var(--mi-ease);
  }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit)::after {
    width: 12px;
    height: 12px;
    inset-inline-end: 18px;
    background: var(--mx-accent-gold);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2 8h11m-5-5 5 5-5 5' fill='none' stroke='black' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: translate var(--mi-fast) var(--mi-ease), background-color var(--mi-fast) var(--mi-ease);
  }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit):is(:disabled, [aria-disabled="true"])::before,
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit):is(:disabled, [aria-disabled="true"])::after { opacity: 0; }
}
@media screen and (hover: hover) and (pointer: fine) {
  :is(.simple-button--hero, .lp5-hero .lp5-btn, .zc-hero-action .zc-button, .vnext-hero .vnext-button-primary):hover > svg { translate: 3px -2px; }
  :is(.simple-footer nav a, .lp5-footer nav a, .zc-footer nav a, .vnext-footer > a, .cr-footer nav a):hover::before { opacity: 1; scale: 1; }
  :is(body.simple .simple-header-actions .simple-button--header, .zc-header-actions .zc-button-small, .lp5-header .lp5-btn--sm, .vnext-header .vnext-button-outline):hover {
    background-color: #15283d; color: white; transform: none;
  }
  body.simple :is(.simple-close, .simple-proof-card) .simple-button--dark:hover { background-size: 100% 100%; transform: none; }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit):enabled:hover::before { background: transparent; }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit):enabled:hover::after { background: currentColor; translate: 2px -50%; }
}
@media screen {
  :is(.simple-button--hero, .lp5-hero .lp5-btn, .zc-hero-action .zc-button, .vnext-hero .vnext-button-primary):focus-visible > svg { translate: 3px -2px; }
  :is(.simple-footer nav a, .lp5-footer nav a, .zc-footer nav a, .vnext-footer > a, .cr-footer nav a):focus-visible::before { opacity: 1; scale: 1; }
  :is(body.simple .simple-header-actions .simple-button--header, .zc-header-actions .zc-button-small, .lp5-header .lp5-btn--sm, .vnext-header .vnext-button-outline):focus-visible { background-color: #15283d; color: white; }
  body.simple :is(.simple-close, .simple-proof-card) .simple-button--dark:is(:focus-visible, :active) { background-size: 100% 100%; }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit):enabled:is(:focus-visible, :active)::before { background: transparent; }
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit):enabled:is(:focus-visible, :active)::after { background: currentColor; }
}
@media screen and (prefers-reduced-motion: no-preference) {
  /* CapWords: the portrait resolves first, then the three cards, in reading order. */
  .simple .simple-collage :is(.simple-collage-back, .simple-profile-card, .simple-float-card, .simple-orbit, .simple-collage-note) {
    animation-name: mi-profile-deal;
    animation-duration: 420ms;
  }
  .simple .simple-profile-card { --simple-enter-delay: 40ms; }
  .simple .simple-float-card--goal { --simple-enter-delay: 120ms; }
  .simple .simple-float-card--people { --simple-enter-delay: 165ms; }
  .simple .simple-float-card--community { --simple-enter-delay: 210ms; }
  .simple .simple-orbit { --simple-enter-delay: 220ms; }
  .simple .simple-collage-note { --simple-enter-delay: 240ms; }
  @keyframes mi-profile-deal {
    from { opacity: .4; translate: 0 12px; scale: .985; }
    to { opacity: 1; translate: 0 0; scale: 1; }
  }

  /* Jiddo: the portrait and cards recede together as their section leaves view. */
  @supports (animation-timeline: view()) and (animation-range: exit 0% exit 100%) {
    /* Clip the artwork without making the hero the timeline's scroll container. */
    .simple .simple-hero { overflow: clip; }
    .simple .simple-collage {
      animation: mi-collage-dock 1s linear both;
      animation-timeline: view(block);
      animation-range: exit 0% exit 85%;
      transform-origin: center 65%;
    }
    @keyframes mi-collage-dock { from { scale: 1; } to { scale: .94; } }
  }

  /* Mailboard: the real handoff to a new step is visible as soon as it opens. */
  .ax-page :is(.ob-panel[data-panel], #done, #card-2fa):not([hidden]) {
    animation: mi-account-step var(--mi-state) var(--mi-ease);
  }
  @keyframes mi-account-step { from { opacity: .72; translate: 4px 0; } to { opacity: 1; translate: 0 0; } }

  /* ClickUp: the radio indicator settles around the selected role. */
  .ax-page .ob-role input:checked + span::before { animation: mi-role-ring var(--mi-state) var(--mi-ease); }
  @keyframes mi-role-ring {
    from { scale: .82; box-shadow: 0 0 0 3px var(--mx-accent-gold-border); }
    to { scale: 1; box-shadow: 0 0 0 0 transparent; }
  }
}
@media (prefers-reduced-motion: reduce) {
  :is(.simple-button--hero, .lp5-hero .lp5-btn, .zc-hero-action .zc-button, .vnext-hero .vnext-button-primary) > svg { transition: none !important; translate: none !important; }
  :is(.simple-footer nav a, .lp5-footer nav a, .zc-footer nav a, .vnext-footer > a, .cr-footer nav a)::before,
  :is(body.simple .simple-header-actions .simple-button--header, .zc-header-actions .zc-button-small, .lp5-header .lp5-btn--sm, .vnext-header .vnext-button-outline),
  body.simple :is(.simple-close, .simple-proof-card) .simple-button--dark,
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit)::before,
  .ax-page :is(#btn-submit, #btn-verify, #regForm #submit)::after { transition: none !important; }
}

/* Each selector observes the app's existing controls or state. The shared CTA,
   filter, and feedback treatments also work in the embedded workspace frame. */
@media screen and (prefers-reduced-motion: no-preference) {
  /* Huly. Trace the edge of the engine the member has selected. */
  [data-medallion-app="moolah"] button.engine-card {
    transition: box-shadow var(--mi-state) var(--mi-ease), background-color var(--mi-state) var(--mi-ease), color var(--mi-state) var(--mi-ease);
  }
  [data-medallion-app="moolah"] button.engine-card.is-active { box-shadow: inset 0 0 0 2px #d5b773; }

  /* Drip. Only animate the open drawer after the owner has made it visible. */
  [data-medallion-app="moolah"] .m-drawer-pulse.is-open .m-drawer-pulse__panel {
    animation: studio-drawer var(--mi-sheet) var(--mi-ease);
  }
  @keyframes studio-drawer { from { opacity: .78; translate: 22px 0; } to { opacity: 1; translate: 0 0; } }

  /* MyFitnessPal. An existing notification picks up a brief, fading edge. */
  [data-medallion-app="moolah"] .m-toast.is-show,
  [data-medallion-app="crop-shoot"] .is-toast:not([hidden]),
  [data-medallion-app="smile-more"] .sl-state[data-state="live"],
  [data-medallion-app="zeknova"] #toast-stack .toast.visible {
    animation: studio-status-edge 320ms var(--mi-ease);
  }
  @keyframes studio-status-edge {
    from { outline: 2px solid currentColor; outline-offset: -2px; }
    to { outline: 2px solid transparent; outline-offset: 3px; }
  }

  /* Haus. A restrained radial highlight rises inside the primary button. */
  :is([data-medallion-app="link-studio"] .ls-primary, [data-medallion-app="approval"] .btn-primary):not(:disabled):not([aria-disabled="true"]) {
    position: relative;
    isolation: isolate;
  }
  :is([data-medallion-app="link-studio"] .ls-primary, [data-medallion-app="approval"] .btn-primary):not(:disabled):not([aria-disabled="true"])::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    background: radial-gradient(ellipse at 76% 105%, rgba(255,255,255,.28), transparent 68%);
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
    opacity: 0;
    transition: opacity var(--mi-state) var(--mi-ease);
  }

  /* Girafe. The existing tab observer supplies the position of the selected filter. */
  [data-medallion-app="link-studio"] .ls-tabs[data-mi-ready]::after {
    height: 4px;
    border-radius: 4px;
    background-color: var(--mx-accent-gold);
    opacity: 1;
    box-shadow: 0 -4px 8px -3px var(--mx-accent-gold);
  }

  /* Runna. Three dots replace the refresh glyph inside the same space during loading. */
  [data-medallion-app="link-studio"] .ls-refresh-mark { display: inline-block; width: 1.1em; }
  [data-medallion-app="link-studio"] .ls-main[aria-busy="true"] .ls-refresh-mark {
    color: transparent;
    --dot: radial-gradient(circle, var(--ls-text) 1.3px, transparent 1.7px);
    background-image: var(--dot), var(--dot), var(--dot);
    background-size: 30% 5px;
    background-repeat: no-repeat;
    animation: studio-refresh 760ms ease-in-out infinite;
  }
  @keyframes studio-refresh {
    0%, 100% { background-position: left 50%, center 50%, right 50%; }
    20% { background-position: left 25%, center 50%, right 50%; }
    40% { background-position: left 50%, center 25%, right 50%; }
    60% { background-position: left 50%, center 50%, right 25%; }
  }

  /* Lifesum. The room controls open out from their trigger. */
  [data-medallion-app="chat-exchange"] :is(.stream-panel.open, .cr-mode-menu.open) {
    animation: studio-room-menu var(--mi-state) var(--mi-ease);
    transform-origin: bottom right;
  }
  @keyframes studio-room-menu { from { opacity: .65; scale: .98; translate: 0 5px; } to { opacity: 1; scale: 1; translate: 0 0; } }

  /* Superorganism. The unselected secondary action reverses ink and paper. */
  :is([data-medallion-app="luxkey"] .feed-filter-btn, [data-medallion-app="moolah"] .m-btn--ghost, [data-medallion-app="chat-exchange"] .ce-btn-secondary) {
    transition: background-color var(--mi-fast) var(--mi-ease), color var(--mi-fast) var(--mi-ease), border-color var(--mi-fast) var(--mi-ease);
  }
  @media (hover: hover) and (pointer: fine) {
    :is([data-medallion-app="link-studio"] .ls-primary, [data-medallion-app="approval"] .btn-primary):not(:disabled):not([aria-disabled="true"]):hover::after { opacity: 1; }
    :is([data-medallion-app="luxkey"] .feed-filter-btn, [data-medallion-app="moolah"] .m-btn--ghost, [data-medallion-app="chat-exchange"] .ce-btn-secondary):not(:disabled):not(.active):not([aria-disabled="true"]):hover {
      background-color: var(--mx-text-primary, #172234); color: var(--mx-surface-primary, white); border-color: var(--mx-text-primary, #172234);
    }
  }
  :is([data-medallion-app="link-studio"] .ls-primary, [data-medallion-app="approval"] .btn-primary):not(:disabled):not([aria-disabled="true"]):is(:focus-visible, :active)::after { opacity: 1; }
  :is([data-medallion-app="luxkey"] .feed-filter-btn, [data-medallion-app="moolah"] .m-btn--ghost, [data-medallion-app="chat-exchange"] .ce-btn-secondary):not(:disabled):not(.active):not([aria-disabled="true"]):focus-visible {
    background-color: var(--mx-text-primary, #172234); color: var(--mx-surface-primary, white); border-color: var(--mx-text-primary, #172234);
  }
}
