@layer cinder.tokens, cinder.foundation, cinder.components, cinder.utilities;
@layer cinder.components {
  /* ========================================
 * DROPDOWN
 * ======================================== */

  .cinder-dropdown {
    position: relative;
    display: inline-block;
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  .cinder-dropdown-trigger {
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  /* The trigger's own bordered face. A trigger drawn as a Button (`variant`, `size`, or inside a
   * ButtonGroup as a split button) carries `.cinder-button` and takes the Button's face instead. */
  .cinder-dropdown-trigger:not(.cinder-button) {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--cinder-space-2);
    min-block-size: var(--cinder-button-height-md);
    padding-block: var(--cinder-button-padding-y-md);
    padding-inline: var(--cinder-button-padding-x-md);
    border: 1px solid var(--cinder-border);
    border-radius: var(--cinder-button-radius-md);
    background: var(--cinder-surface);
    color: var(--cinder-text-default);
    font: inherit;
    font-size: var(--cinder-button-font-size-md);
    line-height: 1;
    cursor: pointer;
    transition:
      background-color var(--cinder-duration-fast) var(--cinder-ease-standard),
      border-color var(--cinder-duration-fast) var(--cinder-ease-standard),
      box-shadow var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  /* An icon-only trigger (`iconOnly`) is square, never a pill (COR-2489). One drawn as a Button
     takes the Button's own icon-only rules, which square it at its size, compact in a header. */
  .cinder-dropdown-trigger:not(.cinder-button)[data-cinder-icon-only] {
    padding-inline: 0;
    aspect-ratio: 1;
    min-inline-size: var(--cinder-button-height-md);
  }

  /* On a coarse pointer the trigger paints at a Button's painted height, as a Button beside it does,
     and reaches 44px through a positioned pseudo-element that takes no layout space: the raised
     `--cinder-button-height-md` would otherwise draw it 44px tall in a row of 32px buttons. A fine
     pointer keeps the rule above unchanged. `min()` keeps a trigger already 44px or more from
     shrinking its own region. A trigger drawn as a Button has the Button's own painted height and
     hit area. */
  @media (any-pointer: coarse) {
    .cinder-dropdown-trigger:not(.cinder-button) {
      position: relative;
      min-block-size: var(--_cinder-painted-height-md);
    }

    .cinder-dropdown-trigger:not(.cinder-button)::before {
      content: '';
      position: absolute;
      inset-block: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
      inset-inline: min(0px, calc((100% - var(--cinder-touch-target-min)) / 2));
    }

    .cinder-dropdown-trigger:not(.cinder-button)[data-cinder-icon-only] {
      min-inline-size: var(--_cinder-painted-height-md);
    }

    /* A compact icon-only trigger reaches (44px - 24px) / 2 past its face, so after a compact
       button across a header's 8px gap the menu steps away by the 2px rest, as two compact
       Buttons do (button.css, COR-2388); the trigger sits in the Dropdown's own wrapper. */
    .cinder-button[data-cinder-compact]
      + .cinder-dropdown:has(
        > .cinder-dropdown-trigger[data-cinder-compact][data-cinder-icon-only]
      ) {
      margin-inline-start: calc(
        (var(--cinder-touch-target-min) - var(--_cinder-compact-control-height)) / 2 -
          var(--cinder-space-2)
      );
    }
  }

  /* Inert (a stale region's mutating menu): muted like a disabled button, but it keeps focus. */
  .cinder-dropdown-trigger[aria-disabled='true'] {
    cursor: not-allowed;
    color: var(--cinder-text-disabled);
  }

  .cinder-dropdown-trigger:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow:
      0 0 0 var(--cinder-ring-offset) var(--cinder-ring-offset-color),
      0 0 0 calc(var(--cinder-ring-offset) + var(--cinder-ring-width))
        var(--_cinder-dropdown-trigger-ring, var(--cinder-ring-color));
  }

  .cinder-button-group
    > .cinder-dropdown[data-cinder-button-group-item]
    > .cinder-dropdown-trigger:focus-visible {
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: inset 0 0 0 var(--cinder-ring-width)
      var(--_cinder-dropdown-trigger-ring, var(--cinder-ring-color));
  }

  @media (forced-colors: active) {
    /* box-shadow is suppressed in Windows High Contrast Mode, so paint a
   * solid outline that respects ButtonText for visible focus. */
    .cinder-dropdown-trigger:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: 3px;
    }

    .cinder-button-group
      > .cinder-dropdown[data-cinder-button-group-item]
      > .cinder-dropdown-trigger:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: calc(var(--cinder-ring-width) * -1);
    }
  }

  .cinder-dropdown-trigger[aria-expanded='true'] {
    background: var(--cinder-surface-pressed);
  }

  .cinder-dropdown-trigger__caret {
    display: block;
    flex: none;
    inline-size: 0.75em;
    block-size: 0.75em;
    opacity: 0.65;
  }

  /* ----------------------------------------
 * Trigger wrapper
 * ---------------------------------------- */

  .cinder-dropdown__trigger {
    display: inline-block;
    max-inline-size: 100%;
    min-inline-size: 0;
  }

  /* ----------------------------------------
 * Menu panel
 * ---------------------------------------- */

  .cinder-dropdown__menu,
  .cinder-dropdown-menu {
    /* The check mark's column (COR-2681): only as wide as the mark, so a checkable item's text
       starts one mark and one row gap past the shared 8px inset. */
    --_cinder-dropdown-check-size: 0.875rem;
    border: 1px solid var(--cinder-border);
    border-radius: var(--cinder-radius-md);
    background: var(--cinder-surface-raised);
    color: var(--cinder-text-default);
    box-shadow: var(--cinder-shadow-overlay);
  }

  .cinder-dropdown__menu {
    position: absolute;
    z-index: var(--cinder-z-dropdown);
    min-width: 12rem;
    padding: var(--cinder-space-1) 0;
    overflow: hidden;

    font-size: var(--cinder-text-sm);
    line-height: var(--cinder-leading-normal);
  }

  .cinder-dropdown-menu {
    position: absolute;
    inset-block-start: calc(100% + var(--cinder-space-1));
    min-width: 12rem;
    max-width: calc(100vw - 1rem);
    max-height: calc(100vh - 2rem);
    margin: 0;
    padding: var(--cinder-space-1);
    overflow-y: auto;
    outline: none;
  }

  .cinder-dropdown-menu:where(
    :not([dir='rtl'], [dir='rtl'] *),
    [dir='rtl'] [dir='ltr'],
    [dir='rtl'] [dir='ltr'] *
  ) {
    right: 0;
  }

  .cinder-dropdown-menu:where(
    :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
  ) {
    left: 0;
  }

  .cinder-dropdown-menu[data-cinder-position-ready='false'] {
    visibility: hidden;
  }

  .cinder-dropdown-menu[data-cinder-position-ready] {
    inset: auto;
  }

  .cinder-dropdown-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    width: 100%;
    /* A modern menu row (COR-2681): 32px on a fine pointer, the 44px list-row minimum on a coarse
       one, with one 8px inset that group labels share. */
    min-block-size: max(2rem, var(--cinder-list-row-min-height));
    padding-block: var(--cinder-space-1-5);
    padding-inline: var(--cinder-space-2);
    border: 0;
    border-radius: var(--cinder-radius-sm);
    background: transparent;
    color: var(--cinder-text-default);
    cursor: pointer;
    font-size: var(--cinder-text-sm);
    text-align: left;
    user-select: none;
    outline: none;
    transition:
      background-color var(--cinder-duration-fast) var(--cinder-ease-standard),
      color var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  /* Scoped to the BEM-style menu (.cinder-dropdown__menu), which uses padding-block-only
 * (no horizontal inset). Items inset themselves so the rounded hover/focus background
 * doesn't bleed into the menu's outer corners. The flat-named .cinder-dropdown-menu
 * variant already has padding on all sides — items there sit at full width. */
  .cinder-dropdown__menu .cinder-dropdown-item {
    width: calc(100% - var(--cinder-space-1) * 2);
    margin-inline: var(--cinder-space-1);
  }

  .cinder-dropdown-item[data-disabled] {
    pointer-events: none;
    color: var(--cinder-text-disabled);
  }

  /* Hover, keyboard focus and press are a neutral ink overlay (COR-2681), as a sidebar row's hover
     is: it shows on the raised menu in both themes, where `--cinder-surface-hover` (mixed from the
     page surface) all but vanished in dark. */
  .cinder-dropdown-item[data-cinder-variant='default']:focus-visible {
    background: color-mix(in oklch, var(--cinder-border-ink), transparent 92%);
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: inset 0 0 0 var(--cinder-ring-width)
      var(--_cinder-dropdown-item-ring, var(--cinder-ring-color));
  }

  .cinder-dropdown-item[data-cinder-variant='danger'] {
    --_cinder-dropdown-item-ring: var(--cinder-status-danger-text);
    color: var(--cinder-status-danger-text);
  }

  .cinder-dropdown-item[data-cinder-variant='danger']:focus-visible {
    background: var(--cinder-status-danger-background);
    color: var(--cinder-status-danger-text);
    outline: var(--cinder-ring-width) solid transparent;
    box-shadow: inset 0 0 0 var(--cinder-ring-width)
      var(--_cinder-dropdown-item-ring, var(--cinder-ring-color));
  }

  /* A disabled item reads as disabled in either variant: the danger colour above would
     otherwise win now that the fade is gone. */
  .cinder-dropdown-item[data-cinder-variant='danger'][data-disabled] {
    color: var(--cinder-text-disabled);
  }

  /* A radio or checkbox item's check mark (COR-2664). Every checkable item keeps the slot, checked
     or not, so the labels of a group start at one edge; the mark is drawn in the item's own colour,
     so it dims with a disabled item and follows forced colours. */
  .cinder-dropdown-item__check {
    display: inline-flex;
    flex: none;
    align-items: center;
    justify-content: center;
    inline-size: var(--_cinder-dropdown-check-size);
    block-size: var(--_cinder-dropdown-check-size);
  }

  .cinder-dropdown-item__check > svg {
    inline-size: var(--_cinder-dropdown-check-size);
    block-size: var(--_cinder-dropdown-check-size);
    color: currentColor;
  }

  /* A disabled item with a `disabledReason` (COR-2327): the label row, and the reason under it as a
     second line in the muted text colour, starting where the label's text starts (the indent past
     a leading icon is measured). It is drawn at every width, so touch reads it without a hover. */
  .cinder-dropdown-item[data-cinder-reason] {
    flex-direction: column;
    align-items: stretch;
    justify-content: center;
    gap: var(--cinder-space-0-5);
  }

  .cinder-dropdown-item__label {
    display: flex;
    align-items: center;
    gap: var(--cinder-space-2);
    min-inline-size: 0;
  }

  .cinder-dropdown-item__reason {
    max-inline-size: 16rem;
    padding-inline-start: var(--_cinder-dropdown-item-reason-indent, 0px);
    /* Never brighter than the disabled label it explains (COR-2680): the same colour, smaller. */
    color: var(--cinder-text-disabled);
    font-size: var(--cinder-text-xs);
    line-height: var(--cinder-leading-snug);
    text-align: start;
    white-space: normal;
  }

  /* Sticky-hover suppression on touch: wrap hover-only chrome so it doesn't
 * "stick" after tap. Placed before :active rules so press feedback wins on tap. */
  @media (hover: hover) {
    .cinder-dropdown-trigger:hover:not([aria-expanded='true']):not([aria-disabled='true']) {
      background: var(--cinder-surface-hover);
    }

    .cinder-dropdown-item[data-cinder-variant='default']:hover {
      background: color-mix(in oklch, var(--cinder-border-ink), transparent 92%);
    }

    .cinder-dropdown-item[data-cinder-variant='danger']:hover {
      background: var(--cinder-status-danger-background);
      color: var(--cinder-status-danger-text);
    }
  }

  /* :active stays unwrapped — fires on tap. */
  .cinder-dropdown-item[data-cinder-variant='default']:active {
    background: color-mix(in oklch, var(--cinder-border-ink), transparent 88%);
  }

  .cinder-dropdown-item[data-cinder-variant='danger']:active {
    background: var(--cinder-status-danger-border);
    color: var(--cinder-status-danger-text);
  }

  @media (forced-colors: active) {
    /* Inset box-shadow rings vanish in HCM — paint a solid outline instead. */
    .cinder-dropdown-item[data-cinder-variant='default']:focus-visible,
    .cinder-dropdown-item[data-cinder-variant='danger']:focus-visible {
      outline: var(--cinder-ring-width) solid ButtonText;
      outline-offset: calc(var(--cinder-ring-width) * -1);
    }
  }

  /* An inset item, and the label of a group of radio or checkbox items, start their text where a
     checkable item's text starts: the inset, the check column and the row gap (COR-2681). */
  .cinder-dropdown-item--inset {
    padding-inline-start: calc(
      var(--cinder-space-2) + var(--_cinder-dropdown-check-size) + var(--cinder-space-2)
    );
  }

  .cinder-dropdown-label {
    padding-block: var(--cinder-space-2) var(--cinder-space-1);
    padding-inline: var(--cinder-space-2);
    color: var(--cinder-text-muted);
    font-size: var(--cinder-text-xs);
    font-weight: var(--cinder-font-semibold);
  }

  .cinder-dropdown-group:has(
      > .cinder-dropdown-item:is([role='menuitemradio'], [role='menuitemcheckbox'])
    )
    > .cinder-dropdown-label {
    /* Dropdown.Label measures where its items' text starts, past a leading icon, and sets
       `--_cinder-dropdown-label-indent`; until then, and in server HTML, the check column stands. */
    padding-inline-start: var(
      --_cinder-dropdown-label-indent,
      calc(var(--cinder-space-2) + var(--_cinder-dropdown-check-size) + var(--cinder-space-2))
    );
  }

  .cinder-dropdown-separator {
    height: 1px;
    margin-block: var(--cinder-space-1);
    background: var(--cinder-border-faint);
  }

  /* ----------------------------------------
 * Popover-API positioning (CSS Anchor Positioning)
 * ----------------------------------------
 *
 * When popover="auto" is set, the menu is promoted to the top layer where
 * its containing block becomes the viewport — percent-based offsets like
 * `top: 100%` no longer point at the trigger. The component sets
 * `anchor-name` on the trigger wrapper and `position-anchor` on the menu so
 * we can use anchor() to position relative to the trigger regardless of the
 * top-layer promotion.
 *
 * `position-try-fallbacks: flip-block, flip-inline` lets the browser flip
 * to the opposite side if the natural placement would clip the viewport.
 *
 * The anchor() rules are gated behind `@supports` so that browsers which
 * shipped popover but not anchor positioning (a roughly 6-month window in
 * Chrome / Firefox, mostly past as of this writing) fall through to the
 * `:not([popover])`-style fallback path below. Without the gate, those
 * browsers would render the menu at viewport-relative `inset: auto`.
 */

  @supports (anchor-name: --x) and (position-anchor: --x) and (top: anchor(bottom)) {
    .cinder-dropdown-menu[popover],
    .cinder-dropdown__menu[popover] {
      position: fixed;
      inset: auto;
      inset-block-start: calc(anchor(bottom) + var(--cinder-space-1));
      position-try-fallbacks: flip-block, flip-inline;
    }

    .cinder-dropdown__menu[popover] {
      margin: 0;
    }

    .cinder-dropdown-menu[popover][data-cinder-placement^='top-'],
    .cinder-dropdown[data-cinder-placement^='top-'] .cinder-dropdown__menu[popover] {
      inset-block-start: auto;
      inset-block-end: calc(anchor(top) + var(--cinder-space-1));
    }

    .cinder-dropdown-menu[popover]:where(:not([data-cinder-placement$='-start'])):where(
        :not([dir='rtl'], [dir='rtl'] *),
        [dir='rtl'] [dir='ltr'],
        [dir='rtl'] [dir='ltr'] *
      ),
    .cinder-dropdown-menu[popover][data-cinder-placement$='-start']:where(
        :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
      ),
    .cinder-dropdown[data-cinder-placement$='-end']
      .cinder-dropdown__menu[popover]:where(
        :not([dir='rtl'], [dir='rtl'] *),
        [dir='rtl'] [dir='ltr'],
        [dir='rtl'] [dir='ltr'] *
      ),
    .cinder-dropdown[data-cinder-placement$='-start']
      .cinder-dropdown__menu[popover]:where(
        :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
      ) {
      right: anchor(right);
    }

    .cinder-dropdown-menu[popover]:where(:not([data-cinder-placement$='-start'])):where(
        :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
      ),
    .cinder-dropdown-menu[popover][data-cinder-placement$='-start']:where(
        :not([dir='rtl'], [dir='rtl'] *),
        [dir='rtl'] [dir='ltr'],
        [dir='rtl'] [dir='ltr'] *
      ),
    .cinder-dropdown[data-cinder-placement$='-end']
      .cinder-dropdown__menu[popover]:where(
        :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
      ),
    .cinder-dropdown[data-cinder-placement$='-start']
      .cinder-dropdown__menu[popover]:where(
        :not([dir='rtl'], [dir='rtl'] *),
        [dir='rtl'] [dir='ltr'],
        [dir='rtl'] [dir='ltr'] *
      ) {
      left: anchor(left);
    }
  }

  /* Without the popover API, the menu positions against its dropdown root. */
  .cinder-dropdown[data-cinder-placement^='bottom-'] .cinder-dropdown__menu:not([popover]) {
    position: absolute;
    inset-block-start: calc(100% + var(--cinder-space-1));
  }

  .cinder-dropdown[data-cinder-placement^='top-'] .cinder-dropdown__menu:not([popover]) {
    position: absolute;
    inset-block-start: auto;
    inset-block-end: calc(100% + var(--cinder-space-1));
  }

  .cinder-dropdown[data-cinder-placement$='-end']
    .cinder-dropdown__menu:not([popover]):where(
      :not([dir='rtl'], [dir='rtl'] *),
      [dir='rtl'] [dir='ltr'],
      [dir='rtl'] [dir='ltr'] *
    ),
  .cinder-dropdown[data-cinder-placement$='-start']
    .cinder-dropdown__menu:not([popover]):where(
      :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ) {
    right: 0;
  }

  .cinder-dropdown[data-cinder-placement$='-end']
    .cinder-dropdown__menu:not([popover]):where(
      :is([dir='rtl'], [dir='rtl'] *):not([dir='rtl'] [dir='ltr'], [dir='rtl'] [dir='ltr'] *)
    ),
  .cinder-dropdown[data-cinder-placement$='-start']
    .cinder-dropdown__menu:not([popover]):where(
      :not([dir='rtl'], [dir='rtl'] *),
      [dir='rtl'] [dir='ltr'],
      [dir='rtl'] [dir='ltr'] *
    ) {
    left: 0;
  }

  /* ----------------------------------------
 * Reduced motion
 * ----------------------------------------
 *
 * The motion-preference path uses an entrance animation that fades opacity
 * 0 → 1. When reduced motion is preferred, the animation is skipped — but
 * the menu must still be visible, so we set opacity: 1 unconditionally below.
 */

  .cinder-dropdown__menu {
    opacity: 1;
  }

  /*
   * Fallback (non-popover-API) branch entry animation only. The `[popover]`
   * branch below owns its own enter/exit via `@starting-style` +
   * `transition-behavior: allow-discrete` — layering this keyframe
   * `animation` on top of it as well would fight that transition for the
   * same `opacity`/`translate` properties on the same element.
   */
  @media (prefers-reduced-motion: no-preference) {
    .cinder-dropdown__menu:not([popover]) {
      animation: cinder-dropdown-enter var(--cinder-duration-fast) var(--cinder-ease-standard)
        forwards;
    }

    @keyframes cinder-dropdown-enter {
      from {
        opacity: 0;
        translate: 0 -0.25rem;
      }
      to {
        opacity: 1;
        translate: 0 0;
      }
    }
  }

  /* `:where(...)` around the `:root`/preference-attribute condition (CIN-376
   * round 17 review — see the closing rule below for the full story): a
   * selector's condition prefix still needs to SELECT the same elements
   * whether or not the app has explicitly forced motion on, but it must not
   * outrank the later `[data-cinder-closing]` override once closing starts.
   * `:where()` zeroes the specificity of everything inside it while
   * matching identically, so this selector's specificity collapses to that
   * of the bare `.cinder-dropdown__menu:not([popover])` it's attached to —
   * letting the closing rule's genuinely higher specificity (one more
   * attribute selector) win on its own, with no reliance on source-order
   * tie-breaking or a `:root`-anchored selector (which the build's
   * class-anchoring guard for component CSS sidecars rejects outright). */
  :where(:root:is([data-cinder-reduced-motion='false'], [data-reduced-motion='off']))
    .cinder-dropdown__menu:not([popover]) {
    animation: cinder-dropdown-enter var(--cinder-duration-fast) var(--cinder-ease-standard)
      forwards;
  }

  /* ----------------------------------------
 * Exit transition (CIN-376, OVERLAY-POLICY.md § "Transition lifecycle")
 * ----------------------------------------
 *
 * Non-popover-API fallback branch only (`:not([popover])`) — the component
 * keeps this element mounted for the duration of this transition instead of
 * removing it the instant `open` goes false (see dropdown.svelte's
 * `exitState`/`AnchoredOverlayExitState`). Named properties, never `all`, so
 * `waitForTransitionCompletion` can enumerate them.
 * ---------------------------------------- */

  .cinder-dropdown__menu:not([popover]) {
    transition:
      opacity var(--cinder-duration-fast) var(--cinder-ease-standard),
      translate var(--cinder-duration-fast) var(--cinder-ease-standard);
  }

  /* This selector must genuinely OUTRANK the explicit-motion
   * entry-animation override above (CIN-376 round 17 review): that rule's
   * `forwards`-filled `animation` kept winning and supplying
   * `opacity: 1`/`translate: 0` even while closing, whenever an application
   * explicitly forced motion on — so `animation: none` below never took
   * effect. Rather than raising THIS selector's specificity (a `:root`
   * prefix here would violate the build's class-anchoring guard for
   * component CSS sidecars, which rejects any selector whose first compound
   * isn't a class), the entry rule's condition prefix above is wrapped in
   * `:where(...)` instead, zeroing its specificity contribution — this
   * selector's ordinary extra `[data-cinder-closing]` attribute is then
   * sufficient to win outright, no tie-break needed. */
  .cinder-dropdown__menu:not([popover])[data-cinder-closing] {
    /* The entry `animation` above uses `forwards` fill, so it keeps supplying
     * opacity/translate for this element even after the keyframe finishes —
     * without disabling it here, that held value overrides the closing
     * declarations below and the exit transition never visibly plays. */
    animation: none;
    opacity: 0;
    translate: 0 -0.25rem;
    pointer-events: none;
  }

  @media (prefers-reduced-motion: reduce) {
    :root:not([data-cinder-reduced-motion='false']):not([data-reduced-motion='off'])
      .cinder-dropdown__menu:not([popover]) {
      transition: none;
    }
  }

  /* Explicit-preference override, OUTSIDE the media query: an application
   * that explicitly sets its preference to reduced motion
   * (`data-cinder-reduced-motion="true"` / `data-reduced-motion="on"`, see
   * use-reduced-motion.svelte.ts's `applyReducedMotionPreference`) must
   * collapse this transition even while the OS-level media query itself
   * still reports `no-preference` — the media query above only ever reflects
   * the OS setting, never the app's own explicit override. Mirrors the
   * explicit-off override above (`[data-cinder-reduced-motion='false']`),
   * just for the opposite (force-on) direction. */
  :root[data-cinder-reduced-motion='true'] .cinder-dropdown__menu:not([popover]) {
    transition: none;
  }

  /* ----------------------------------------
 * Popover-API path exit transition (native equivalent)
 * ----------------------------------------
 *
 * `menu.hidePopover()` (dropdown.svelte) synchronously removes this element
 * from the top layer — there is no JS hook to delay that the way
 * `waitForTransitionCompletion` does for the fallback branch above. The
 * platform-native equivalent is `transition-behavior: allow-discrete` +
 * `@starting-style`, which lets the UA itself defer the discrete
 * `display`/`overlay` flip until the named transitions finish. This keeps
 * entry/exit symmetric and reduced-motion-safe without a JS wait.
 * ---------------------------------------- */

  .cinder-dropdown__menu[popover] {
    opacity: 0;
    translate: 0 -0.25rem;
    /* `display`/`overlay` stay at their :popover-open computed values for the
     full transition (that's what `allow-discrete` buys), so without this the
     visually-fading-out menu would remain hit-testable and a stray click
     could still activate an item during teardown. */
    pointer-events: none;
    transition:
      opacity var(--cinder-duration-fast) var(--cinder-ease-standard),
      translate var(--cinder-duration-fast) var(--cinder-ease-standard),
      display var(--cinder-duration-fast) allow-discrete,
      overlay var(--cinder-duration-fast) allow-discrete;
  }

  .cinder-dropdown__menu[popover]:popover-open {
    opacity: 1;
    translate: 0 0;
    pointer-events: auto;
  }

  @starting-style {
    .cinder-dropdown__menu[popover]:popover-open {
      opacity: 0;
      translate: 0 -0.25rem;
    }
  }

  @media (prefers-reduced-motion: reduce) {
    :root:not([data-cinder-reduced-motion='false']):not([data-reduced-motion='off'])
      .cinder-dropdown__menu[popover] {
      transition: none;
    }
  }

  /* Explicit-preference override, OUTSIDE the media query (CIN-376 round 16
   * review): unlike the fallback branch above, this native Popover-API path
   * has NO JS teardown (`AnchoredOverlayExitState`/`waitForTransitionCompletion`)
   * to collapse the wait when reduced motion is active — `menu.hidePopover()`
   * relies entirely on this CSS transition (via `allow-discrete`) actually
   * being `none` to skip the wait. Without this selector, an application
   * that explicitly sets its preference to reduced motion while the OS
   * media query still reports `no-preference` would still run the full
   * opacity/translate exit transition here, ignoring the explicit
   * preference entirely. Mirrors the explicit-off override above, for the
   * opposite (force-on) direction. */
  :root[data-cinder-reduced-motion='true'] .cinder-dropdown__menu[popover] {
    transition: none;
  }

  /* ----------------------------------------
 * Docked sheet — below Dropdown's `sheetBelow` viewport width the menu
 * leaves its trigger and docks to the bottom edge with the bottom Drawer's
 * geometry (the same values as `_floating-surface.css`'s docked rule, which
 * the legacy `.cinder-dropdown__menu` does not carry). The component drops
 * `data-cinder-placement` and the anchor style while docked, so only the
 * placement-free `[popover]` and position-ready rules above compete with
 * these, at equal specificity and earlier in the file.
 * ---------------------------------------- */

  .cinder-dropdown__menu[data-cinder-sheet='docked'],
  .cinder-dropdown-menu[data-cinder-sheet='docked'] {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: 90dvh;
    margin: 0;
    overflow-y: auto;
    padding-bottom: max(var(--cinder-space-1), env(safe-area-inset-bottom));
    border-width: 1px 0 0;
    border-radius: var(--cinder-radius-lg) var(--cinder-radius-lg) 0 0;
    translate: none;
  }
}
