/* ============================================================
   Dropdown — the site's one dropdown list: site/src/components/Dropdown.astro (Liliya, block map legal-02, 02.12.2026).
   Made from the home hero's «Add to Claude» MCP menu, whose look it keeps: a toggle and a card (.card.card--inset: the
   page's card fill, 8 inside) of link rows — Paragraph MD, 8 × 16 padding, the nested radius (16 − 8), the CTA Grey
   fill under the pointer and on keyboard focus. A row's mark is 24 (16 on phones), 8 (4 on phones) before the label;
   its note sits at the row's end. Opening: popover (no script); placement: CSS anchors, under the toggle, over it when
   the screen has no room below.
   Toggles: --cta  the grey CTA button, as wide as its slot, label at the start from 768, the arrow 24 in from its end;
                   the card as wide as the button (home hero).
            --text the label and the arrow inside the surrounding text (the legal «Effective date: 17 November 2026 ⌄»);
                   a chip S field (8 · 16, radius 12) round it fills with the list's grey on hover and while open, as live.
            --xs   the XS grey button (54, a chip's height) with a chip's side padding.
            --text and --xs: the card at least as wide as the toggle, from its start edge.
   --text and --xs sit on the surrounding text's baseline (a mark in its label is centred on the line, not on the baseline).
   The arrow turns over while open and grows a little under the pointer (mouse only, not with reduced motion).
   Current row (aria-current): the grey under the pointer stays on it (Liliya, /lab/dropdown, 03.12.2026: the fill, not a
   check mark — the system marks the current item by a fill everywhere). Rows stand 4 apart so the current row and the
   one under the pointer never merge into one grey block.
   A single row (--single): no arrow and nothing to open.
   Themes: the rows take the theme's text (--ink); the grey under the pointer is CTA Grey on dark pages, Surface muted on
   light ones (the card there is Surface, CTA Grey would be a dark block under dark text).
   ============================================================ */

.dropdown {
  --dropdown-hover: var(--color-bg-cta-grey);
  --dropdown-mark-size: var(--space);
  --dropdown-mark-gap: var(--space-xs);
}
.theme-light .dropdown { --dropdown-hover: var(--color-surface-muted); }
.theme-light .theme-dark .dropdown { --dropdown-hover: var(--color-bg-cta-grey); }
@media (max-width: 47.9375rem) {
  .dropdown {
    --dropdown-mark-size: var(--space-sm);
    --dropdown-mark-gap: var(--space-xxs);
  }
}
.dropdown--text, .dropdown--xs { display: inline-block; }
.dropdown__label {
  display: inline-flex;
  align-items: center;
  gap: var(--dropdown-mark-gap);
}
.dropdown__label img,
.dropdown__mark {
  flex: none;
  inline-size: var(--dropdown-mark-size);
  block-size: var(--dropdown-mark-size);
  object-fit: contain;
}

/* ── Toggles ── */
.dropdown .dropdown__toggle { --motion-scale: 1.25; }
.dropdown--cta .dropdown__toggle {
  position: relative;
  inline-size: 100%;
}
@media (min-width: 48rem) {
  .dropdown--cta .dropdown__toggle { justify-content: flex-start; }
}
.dropdown--cta .dropdown__chev {
  position: absolute;
  inset-inline-end: calc(var(--space) - var(--btn-border));
  inset-block-start: 50%;
  translate: 0 -50%; /* centred on the button's height without auto margins (the token check reads an auto margin as a px value) */
}
.dropdown--xs .dropdown__toggle { gap: var(--space-xs); padding-inline: var(--chip-pad-x); }
:is(.dropdown--text, .dropdown--xs) .dropdown__label { align-items: baseline; }
:is(.dropdown--text, .dropdown--xs) .dropdown__label img { align-self: center; }
/* a button's line is 1 (shorter than the mark): as tall as the mark, the text stays centred in the button with it */
.dropdown--xs .dropdown__label { line-height: var(--dropdown-mark-size); }
.dropdown--text .dropdown__toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xxs);
  min-block-size: var(--space);   /* the 24 tap minimum */
  padding: var(--space-xs) var(--space-sm);   /* a chip S's field: the wrapper shows on hover and while open (as live) */
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  cursor: pointer;
}
.dropdown--text .dropdown__toggle:focus-visible {
  outline: var(--border-thick) solid var(--color-accent-indigo);
  outline-offset: var(--border-thin);
}
.dropdown .dropdown__chev {
  flex: none;
  transition:
    rotate var(--duration-toggle) var(--ease-toggle),
    scale var(--duration-hover) var(--ease-hover);
}
.dropdown:has(:popover-open) .dropdown__chev {
  rotate: 180deg;
  scale: var(--motion-scale);
}
@media (hover: hover) {
  .dropdown__toggle:hover .dropdown__chev { scale: var(--motion-scale); }
  .dropdown--text .dropdown__toggle { transition: background-color var(--duration-hover) var(--ease-hover); }
  .dropdown--text .dropdown__toggle:hover { background: var(--dropdown-hover); }
}
.dropdown--text:has(:popover-open) .dropdown__toggle { background: var(--dropdown-hover); }
@media (prefers-reduced-motion: reduce) {
  .dropdown .dropdown__chev, .dropdown--text .dropdown__toggle { transition: none; }
}

/* ── The card ── */
.dropdown__panel {
  border: 0;
  color: var(--ink, var(--color-text));
  text-align: start;
  inset: auto;
  margin: var(--space-xs) 0;
  inline-size: max-content;
  max-inline-size: calc(100vw - 2 * var(--pad-horizontal));
  max-block-size: calc(100dvh - 2 * var(--space-xs));
  overflow: auto;
}
.dropdown__row {
  display: flex;
  align-items: center;
  gap: var(--dropdown-mark-gap);
  padding-block: var(--space-xs);
  padding-inline: calc(var(--space) - var(--space-xs));
  border-radius: calc(var(--radius-lg) - var(--space-xs));
  color: inherit;
}
.dropdown__note { margin-inline-start: auto; }
.dropdown__row:focus-visible { background: var(--dropdown-hover); }
@media (hover: hover) {
  .dropdown__row:hover { background: var(--dropdown-hover); }
}
.dropdown__row[aria-current] { background: var(--dropdown-hover); }
.dropdown__row + .dropdown__row { margin-block-start: var(--space-xxs); }

@supports (position-area: bottom center) and (width: anchor-size(width)) {
  .dropdown__panel {
    position-area: bottom span-right;
    position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline;
    min-inline-size: anchor-size(width);
  }
  .dropdown--cta .dropdown__panel {
    position-area: bottom center;
    position-try-fallbacks: flip-block;
    inline-size: anchor-size(width);
  }
}
