/* ==========================================================================
   Bariatric Istanbul — Layout/header/footer/CTA (T-021, T-026 round 3)
   Token-only colours. BEM classes use the .bi- prefix.
   Depends on tokens.css and base.css (load them first).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Header — constant 52 px, frosted glass, hairline edge
   -------------------------------------------------------------------------- */
.bi-header {
    position: sticky;
    inset-block-start: 0;
    /* Above the fixed cookie card (50) so the menu/language popovers that
       hang below the header are never covered by it. */
    z-index: 60;
    border-block-end: 1px solid var(--bi-color-border);
    /* Opaque default: readable even before/without backdrop-filter support. */
    background-color: var(--bi-color-bg);
    transition:
        box-shadow var(--bi-duration-fast) var(--bi-ease-standard),
        border-color var(--bi-duration-fast) var(--bi-ease-standard);
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .bi-header {
        /* L0 2026-11-16: nearly opaque — text scrolling underneath was still readable through 82 % glass. */
        background-color: color-mix(in srgb, var(--bi-color-bg) 95%, transparent);
        -webkit-backdrop-filter: var(--bi-blur-glass);
        backdrop-filter: var(--bi-blur-glass);
    }
}

/* Header height stays constant in both states: no layout shift on scroll. */
.bi-header__inner {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--bi-space-3);
    min-block-size: var(--bi-header-height);
    min-inline-size: 0;
    padding-block: 0;
}

.bi-header--compact {
    border-block-end-color: transparent;
    box-shadow: var(--bi-shadow-sm);
}

.bi-header__brand {
    display: inline-flex;
    align-items: center;
    gap: var(--bi-space-2);
    flex: 0 1 auto;
    min-block-size: var(--bi-touch-target);
    min-inline-size: 0;
    color: var(--bi-color-heading);
    font-size: var(--bi-font-size-base);
    font-weight: var(--bi-font-weight-semibold);
    letter-spacing: var(--bi-letter-spacing-heading);
    text-decoration: none;
}

.bi-header__brand:hover {
    color: var(--bi-color-link);
}

/*
 * The source logo is a horizontal lockup inside a 1024x1024 square with wide
 * white margins. A square box (or a circle with object-fit: cover) cropped the
 * mark down to a few pixels. A 3:2 box with `cover` trims only the empty
 * top/bottom bands and keeps the whole lockup legible at a 48 px height.
 */
.bi-header__logo {
    flex: 0 0 auto;
    inline-size: auto;
    block-size: 3rem;
    aspect-ratio: 3 / 2;
    border-radius: var(--bi-radius-xs);
    object-fit: cover;
    object-position: center;
    background-color: var(--bi-color-bg);
}

.bi-header__brand-text {
    min-inline-size: 0;
    overflow-wrap: anywhere;
    line-height: var(--bi-line-height-snug);
}

.bi-header__desktop {
    display: none;
}

.bi-header__actions {
    display: flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    align-items: center;
    gap: var(--bi-space-2);
    min-inline-size: 0;
    margin-inline-start: auto;
}

/* The compact language trigger only appears when the one-row header fits. */
.bi-header__lang {
    display: none;
}

/* The mobile CTA lives inside the menu panel, not in the top bar. */
.bi-header__cta {
    display: none;
}

.bi-header__menu {
    position: relative;
}

.bi-header__menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-block-size: var(--bi-touch-target);
    min-inline-size: var(--bi-touch-target);
    padding: 0;
    border-radius: var(--bi-radius-button);
    color: var(--bi-color-text);
    cursor: pointer;
    list-style: none;
}

.bi-header__menu-toggle::-webkit-details-marker {
    display: none;
}

.bi-header__menu-toggle:hover {
    background-color: var(--bi-color-bg-muted);
}

/* Hamburger: three bars, short to long (right-aligned); turns into an X
   when the <details> menu is open. Pure CSS, no JS. */
.bi-burger {
    position: relative;
    display: block;
    inline-size: 22px;
    block-size: 16px;
}

.bi-burger__bar {
    position: absolute;
    inset-inline-end: 0;
    block-size: 2px;
    border-radius: 2px;
    background-color: currentColor;
    transition:
        transform var(--bi-duration-base) var(--bi-ease-standard),
        opacity var(--bi-duration-fast) var(--bi-ease-standard),
        inline-size var(--bi-duration-base) var(--bi-ease-standard);
}

.bi-burger__bar:nth-child(1) {
    inset-block-start: 0;
    inline-size: 12px;
}

.bi-burger__bar:nth-child(2) {
    inset-block-start: 7px;
    inline-size: 17px;
}

.bi-burger__bar:nth-child(3) {
    inset-block-start: 14px;
    inline-size: 22px;
}

.bi-header__menu[open] .bi-burger__bar {
    inline-size: 22px;
}

.bi-header__menu[open] .bi-burger__bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.bi-header__menu[open] .bi-burger__bar:nth-child(2) {
    opacity: 0;
}

.bi-header__menu[open] .bi-burger__bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
    .bi-burger__bar {
        transition: none;
    }
}

.bi-menu-panel {
    position: absolute;
    inset-block-start: calc(100% + var(--bi-space-2));
    inset-inline-end: 0;
    z-index: 10;
    inline-size: min(20rem, calc(100vw - (2 * var(--bi-space-gutter))));
    max-block-size: 70vh;
    overflow-y: auto;
    padding: var(--bi-space-3);
    border: 1px solid var(--bi-color-border);
    border-radius: var(--bi-radius-popover);
    background-color: var(--bi-color-bg);
    box-shadow: var(--bi-shadow-md);
}

.bi-menu-panel__cta {
    inline-size: 100%;
    margin-block-start: var(--bi-space-3);
}

/* --------------------------------------------------------------------------
   2. Primary navigation — 14 px, quiet (Apple-style)
   -------------------------------------------------------------------------- */
.bi-nav__list {
    display: flex;
    flex-direction: column;
    gap: var(--bi-space-1);
    margin: 0;
    padding: 0;
    list-style: none;
}

.bi-nav__item {
    margin: 0;
}

.bi-nav__link {
    display: inline-flex;
    align-items: center;
    min-block-size: var(--bi-touch-target);
    padding-inline: var(--bi-space-2);
    color: var(--bi-color-text);
    font-weight: var(--bi-font-weight-medium);
    text-decoration: none;
}

.bi-nav__link:hover {
    color: var(--bi-color-link);
}

.bi-nav__link[aria-current="page"] {
    color: var(--bi-color-link);
    font-weight: var(--bi-font-weight-semibold);
}

.bi-nav--mobile .bi-nav__list {
    gap: var(--bi-space-1);
}

.bi-nav--mobile .bi-nav__link {
    inline-size: 100%;
}

/* --------------------------------------------------------------------------
   3. Language switcher — header popover, footer disclosure, menu list
   Endonyms only, decorative flags, 44 px rows.
   -------------------------------------------------------------------------- */
.bi-lang {
    position: relative;
    min-inline-size: 0;
}

.bi-lang__disclosure {
    position: relative;
}

.bi-lang__summary {
    display: inline-flex;
    align-items: center;
    gap: var(--bi-space-2);
    min-block-size: var(--bi-touch-target);
    padding-inline: var(--bi-space-2);
    border-radius: var(--bi-radius-button);
    color: var(--bi-color-text);
    font-size: var(--bi-font-size-sm);
    font-weight: var(--bi-font-weight-medium);
    line-height: var(--bi-line-height-snug);
    cursor: pointer;
    list-style: none;
    transition: background-color var(--bi-duration-fast) var(--bi-ease-standard);
}

.bi-lang__summary::-webkit-details-marker {
    display: none;
}

.bi-lang__summary:hover {
    background-color: var(--bi-color-bg-muted);
}

.bi-lang__disclosure[open] > .bi-lang__summary {
    background-color: var(--bi-color-bg-muted);
}

.bi-lang__flag {
    flex: 0 0 auto;
    inline-size: 1.25rem;
    block-size: 0.9375rem;
    border-radius: 3px;
    object-fit: cover;
    /* Inset hairline: white flags must not disappear on the light surface. */
    box-shadow: inset 0 0 0 1px var(--bi-color-flag-ring);
}

.bi-lang__code {
    font-size: var(--bi-font-size-xs);
    font-weight: var(--bi-font-weight-semibold);
    letter-spacing: var(--bi-letter-spacing-normal);
}

.bi-lang__chevron {
    flex: 0 0 auto;
    color: var(--bi-color-text-muted);
    transition: transform var(--bi-duration-fast) var(--bi-ease-standard);
}

.bi-lang__disclosure[open] .bi-lang__chevron {
    transform: rotate(180deg);
}

.bi-lang__panel {
    position: absolute;
    inset-block-start: calc(100% + var(--bi-space-2));
    inset-inline-end: 0;
    z-index: 20;
    min-inline-size: 14rem;
    padding: var(--bi-space-2);
    border: 1px solid var(--bi-color-border);
    border-radius: var(--bi-radius-popover);
    background-color: var(--bi-color-bg);
    box-shadow: var(--bi-shadow-lg);
}

/* Popovers stay OPAQUE: inside the frosted header (its backdrop-filter makes
   a new backdrop root) a nested backdrop-filter cannot blur the page, so a
   translucent panel would let page text show through. */

/* Footer: the panel opens upwards, aligned to the trigger's right edge. */
.bi-lang__panel--up {
    inset-block-start: auto;
    inset-block-end: calc(100% + var(--bi-space-2));
}

/* Mobile menu panel: the same rows, in normal flow. */
.bi-lang__panel--static {
    position: static;
    min-inline-size: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background-color: transparent;
    box-shadow: none;
}

@supports ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .bi-lang__panel--static {
        background-color: transparent;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }
}

.bi-lang__list {
    display: grid;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bi-lang__item {
    margin: 0;
}

.bi-lang__link {
    display: flex;
    align-items: center;
    gap: var(--bi-space-3);
    min-block-size: var(--bi-touch-target);
    padding-inline: var(--bi-space-3);
    border-radius: var(--bi-radius-sm);
    color: var(--bi-color-text);
    font-size: var(--bi-font-size-sm);
    font-weight: var(--bi-font-weight-regular);
    text-decoration: none;
}

.bi-lang__link:hover {
    background-color: var(--bi-color-bg-muted);
    color: var(--bi-color-text);
}

.bi-lang__link[aria-current="page"] {
    font-weight: var(--bi-font-weight-semibold);
}

.bi-lang__name {
    min-inline-size: 0;
    overflow-wrap: anywhere;
}

.bi-lang__check {
    flex: 0 0 auto;
    margin-inline-start: auto;
    color: var(--bi-color-link);
}

.bi-lang__globe {
    flex: 0 0 auto;
    color: var(--bi-color-text-muted);
}

.bi-lang--menu {
    margin-block-start: var(--bi-space-3);
    padding-block-start: var(--bi-space-3);
    border-block-start: 1px solid var(--bi-color-border);
}

.bi-lang__title {
    margin: 0 0 var(--bi-space-2);
    padding-inline: var(--bi-space-3);
    color: var(--bi-color-text-muted);
    font-size: var(--bi-font-size-xs);
    font-weight: var(--bi-font-weight-semibold);
}

/* --------------------------------------------------------------------------
   4. Footer — light grey surface, small text, hairline separators
   -------------------------------------------------------------------------- */
.bi-footer {
    padding-block: var(--bi-space-12);
    border-block-start: 1px solid var(--bi-color-border);
    background-color: var(--bi-color-bg-subtle);
    color: var(--bi-color-text);
    font-size: 0.8125rem;
}

.bi-footer a {
    color: var(--bi-color-text);
}

.bi-footer a:hover {
    color: var(--bi-color-link);
}

.bi-footer__inner {
    display: grid;
    gap: var(--bi-space-8);
}

.bi-footer__top {
    display: grid;
    gap: var(--bi-space-6);
}

.bi-footer__brand-link {
    justify-self: start;
    font-size: var(--bi-font-size-lg);
    font-weight: var(--bi-font-weight-semibold);
    letter-spacing: var(--bi-letter-spacing-heading);
    text-decoration: none;
}

.bi-footer__columns {
    display: grid;
    gap: var(--bi-space-6);
}

.bi-footer__column {
    min-inline-size: 0;
}

/* Footer accordion: <details> per link column. Narrow screens: full-width
   44 px rows with hairlines and a rotating chevron. From 900 px: plain
   column titles, always open (nav.js), no toggle affordance. */
.bi-footer__group > .bi-footer__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bi-space-2);
    min-block-size: var(--bi-touch-target);
    cursor: pointer;
    list-style: none;
}

.bi-footer__summary::-webkit-details-marker {
    display: none;
}

.bi-footer__summary .bi-footer__column-title {
    margin: 0;
}

.bi-footer__chevron {
    flex: 0 0 auto;
    color: var(--bi-color-text-muted);
    transition: transform var(--bi-duration-fast) var(--bi-ease-standard);
}

.bi-footer__group[open] .bi-footer__chevron {
    transform: rotate(180deg);
}

@media (max-width: 899.98px) {
    .bi-footer__columns {
        gap: 0;
    }

    .bi-footer__column,
    .bi-footer__contact {
        border-block-end: 1px solid var(--bi-color-border);
    }

    .bi-footer__group[open] > .bi-footer__list {
        padding-block-end: var(--bi-space-3);
    }

    /* Contact continues the accordion list: no second divider or gap.
       Higher specificity: the base .bi-footer__bottom rule comes later. */
    .bi-footer .bi-footer__bottom {
        padding-block-start: 0;
        border-block-start: 0;
    }

    .bi-footer__inner {
        gap: 0;
    }
}

@media (min-width: 900px) {
    .bi-footer__group > .bi-footer__summary {
        min-block-size: 1.5rem; /* T-136: WCAG 2.2 target size (24 px) — the summary stays focusable */
        margin-block-end: var(--bi-space-1);
        cursor: default;
    }

    .bi-footer__chevron {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .bi-footer__chevron {
        transition: none;
    }
}

.bi-footer__column-title {
    margin: 0 0 var(--bi-space-1);
    color: var(--bi-color-text);
    font-size: 0.8125rem;
    font-weight: var(--bi-font-weight-semibold);
    letter-spacing: var(--bi-letter-spacing-normal);
}

.bi-footer__list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.bi-footer__list--inline {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--bi-space-4);
}

.bi-footer__list li {
    margin: 0;
}

/* Social profiles as brand icons; the name stays for screen readers. */
.bi-footer__list--icons {
    gap: var(--bi-space-2);
}

.bi-footer__social-link {
    justify-content: center;
    min-inline-size: var(--bi-touch-target);
}

.bi-footer__social-link .bi-icon {
    display: block;
}

.bi-footer__social-link:hover {
    text-decoration: none;
    opacity: 0.75;
}

.bi-footer__link {
    display: inline-flex;
    align-items: center;
    min-block-size: var(--bi-touch-target);
    text-decoration: none;
}

.bi-footer__link:hover {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

/* Pointer screens: 44 px rows made the link columns very tall; 32 px still clears WCAG 2.2 target size (24 px). */
@media (min-width: 64rem) and (pointer: fine) {
    .bi-footer__link {
        min-block-size: 2rem;
    }
}

.bi-footer__settings {
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: start;
    cursor: pointer;
}

.bi-footer__label {
    margin-inline-end: var(--bi-space-1);
    color: var(--bi-color-text-muted);
    font-size: 0.8125rem;
    font-weight: var(--bi-font-weight-semibold);
}

/* V2-A: contact channel icons (phone, WhatsApp, mail) before the label. */
.bi-footer__icon {
    display: inline-block;
    vertical-align: -0.2em;
    margin-inline-end: var(--bi-space-1);
    color: var(--bi-color-teal-strong);
}

.bi-footer__text {
    color: var(--bi-color-text-muted);
}

.bi-footer__bottom {
    display: grid;
    gap: var(--bi-space-6);
    padding-block-start: var(--bi-space-6);
    border-block-start: 1px solid var(--bi-color-border);
}

.bi-footer__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: var(--bi-space-3);
}

.bi-footer__copyright {
    margin: 0;
    padding-block-start: var(--bi-space-6);
    border-block-start: 1px solid var(--bi-color-border);
    text-align: center;
    color: var(--bi-color-text-muted);
    font-size: 0.8125rem;
}

/* T-140: copyright · last updated · editorial team, wrapping on narrow screens. */
.bi-footer__copyright {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--bi-space-1) var(--bi-space-4);
}

.bi-footer__copyright .bi-footer__editorial {
    min-block-size: 1.5rem;
    display: inline-flex;
    align-items: center;
}

/* Footer language control: small text, still a 44 px target. */
.bi-footer .bi-lang__summary {
    padding-inline: var(--bi-space-1);
    font-size: 0.8125rem;
}

.bi-footer .bi-lang__panel {
    inset-inline-start: auto;
    /* Opaque: footer text must not show through the open list. */
    background-color: var(--bi-color-bg);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

/* The open footer list must sit above the fixed cookie card (z-index 50)
   and every footer column; ancestors create no stacking context. */
.bi-footer .bi-lang__disclosure[open] {
    z-index: 60;
}

/* --------------------------------------------------------------------------
   5. CTA bar — light surface, normal document flow (no overlap)
   -------------------------------------------------------------------------- */
.bi-cta-bar {
    padding-block: var(--bi-space-6);
    border-block-start: 1px solid var(--bi-color-border);
    background-color: var(--bi-color-bg-subtle);
}

.bi-cta-bar__inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--bi-space-4);
}

.bi-cta-bar__title {
    margin: 0;
    color: var(--bi-color-heading);
    font-size: var(--bi-font-size-xl);
    font-weight: var(--bi-font-weight-semibold);
    line-height: var(--bi-line-height-snug);
}

.bi-cta-bar__actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--bi-space-3);
}

/* --------------------------------------------------------------------------
   6. Responsive layout
   -------------------------------------------------------------------------- */
@media (min-width: 900px) {
    .bi-footer__columns {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: var(--bi-space-8);
    }

    /* Hairline separators between footer columns. */
    .bi-footer__column + .bi-footer__column {
        padding-inline-start: var(--bi-space-6);
        border-inline-start: 1px solid var(--bi-color-border);
    }

    .bi-footer__bottom {
        grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
        align-items: start;
    }
}

/* Brand + five nav items + language trigger + CTA need the full 1180 px
   container; below 1200 the header keeps the compact menu panel instead. */
@media (min-width: 1200px) {
    .bi-header__actions {
        gap: var(--bi-space-3);
    }

    .bi-header__lang {
        display: block;
    }

    .bi-header__cta {
        display: inline-flex;
    }

    .bi-header__desktop {
        display: block;
        margin-inline: auto;
    }

    .bi-header__menu {
        display: none;
    }

    /* Logo-only brand on desktop: the wordmark would push the CTA out.
       T-136: hidden visually only, so it stays the link's accessible name
       (the logo image is alt="" — the name is never announced twice). */
    .bi-header__brand-text {
        position: absolute;
        inline-size: 1px;
        block-size: 1px;
        margin: -1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .bi-nav--desktop .bi-nav__list {
        flex-direction: row;
        align-items: center;
        gap: var(--bi-space-4);
    }

    .bi-nav--desktop .bi-nav__link {
        padding-inline: var(--bi-space-1);
        font-size: 0.875rem;
    }
}

/* --------------------------------------------------------------------------
   7. Overflow hygiene (T-026 round 2)
   Root cause of the 390 px horizontal overflow was content that could not
   break (long URLs, list items, table cells) plus flex/grid children whose
   min-content width pushed the page wider than the viewport. These rules fix
   the cause; a global horizontal clip is deliberately NOT used to mask it.
   -------------------------------------------------------------------------- */
body {
    overflow-wrap: break-word;
}

:where(main, header, footer) :where(p, li, dd, dt, td, th, figcaption, blockquote, a) {
    overflow-wrap: anywhere;
}

:where(main, header, footer) :where(img, svg, video, iframe) {
    max-inline-size: 100%;
    block-size: auto;
}

.bi-page__body table {
    max-inline-size: 100%;
}

.bi-page__body :where(pre, code, kbd, samp) {
    max-inline-size: 100%;
    overflow-x: auto;
}

.bi-container {
    min-inline-size: 0;
}

.bi-footer__meta > * {
    min-inline-size: 0;
}

/* No movement under reduced-motion preferences. */
@media (prefers-reduced-motion: reduce) {
    .bi-lang__chevron,
    .bi-lang__summary {
        transition: none;
    }

    .bi-lang__disclosure[open] .bi-lang__chevron {
        transform: none;
    }
}

/* --------------------------------------------------------------------------
   8. Header height + top-of-page expansion (L0, 2026-11-11)
   At the top of the page the header is taller (--bi-header-height-top); once
   scrolled (nav.js adds .bi-header--compact) it eases down to
   --bi-header-height. The flow footprint stays constant: the compact header
   adds the difference back as margin-block-end, animated with the same
   duration/easing, so content below never moves (no layout shift).
   -------------------------------------------------------------------------- */
.bi-header {
    --bi-header-shrink: calc(var(--bi-header-height-top) - var(--bi-header-height));
    margin-block-end: 0;
    transition:
        margin-block-end var(--bi-duration-slow) var(--bi-ease-standard),
        box-shadow var(--bi-duration-slow) var(--bi-ease-standard),
        border-color var(--bi-duration-slow) var(--bi-ease-standard),
        background-color var(--bi-duration-slow) var(--bi-ease-standard);
}

.bi-header .bi-header__inner {
    min-block-size: var(--bi-header-height-top);
    transition: min-block-size var(--bi-duration-slow) var(--bi-ease-standard);
}

.bi-header--compact {
    margin-block-end: var(--bi-header-shrink);
}

.bi-header--compact .bi-header__inner {
    min-block-size: var(--bi-header-height);
}

/* CTA matches the nav typography: same size, one step bolder, pill. */
.bi-header .bi-header__cta {
    min-block-size: var(--bi-touch-target);
    padding-block: 0;
    padding-inline: var(--bi-space-4);
    font-size: 0.875rem;
    font-weight: var(--bi-font-weight-semibold);
    line-height: 1;
    letter-spacing: var(--bi-letter-spacing-normal);
}

.bi-header .bi-lang__summary {
    font-size: 0.875rem;
}

@media (prefers-reduced-motion: reduce) {
    .bi-header,
    .bi-header .bi-header__inner {
        transition: none;
    }
}

/* --------------------------------------------------------------------------
   T-144/T-145 — "Popular searches" band above the footer.
   A quiet index, not a feature. Each group is a closed <details> accordion
   on every width, in the footer's style (44 px rows, hairline, rotating
   chevron), so the band stays a few lines tall until a reader opens a group
   (operator, 2026-12-03).
   -------------------------------------------------------------------------- */
.bi-popular-band {
    padding-block: var(--bi-space-6);
    border-block-start: 1px solid var(--bi-color-border);
    background-color: var(--bi-color-bg);
}

.bi-popular {
    display: grid;
    align-items: start;
    gap: 0 var(--bi-space-8);
}

.bi-popular__title {
    margin: 0 0 var(--bi-space-2);
    color: var(--bi-color-heading);
    font-size: var(--bi-font-size-lg);
    font-weight: var(--bi-font-weight-heading);
}

.bi-popular__group {
    border-block-end: 1px solid var(--bi-color-border);
}

.bi-popular__summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--bi-space-2);
    min-block-size: var(--bi-touch-target);
    cursor: pointer;
    list-style: none;
}

.bi-popular__summary::-webkit-details-marker {
    display: none;
}

.bi-popular__heading {
    margin: 0;
    color: var(--bi-color-text);
    font-size: var(--bi-font-size-sm);
    font-weight: var(--bi-font-weight-semibold);
}

.bi-popular__chevron {
    flex: 0 0 auto;
    color: var(--bi-color-text-muted);
    transition: transform var(--bi-duration-fast) var(--bi-ease-standard);
}

.bi-popular__group[open] .bi-popular__chevron {
    transform: rotate(180deg);
}

.bi-popular__list {
    margin: 0;
    padding: 0 0 var(--bi-space-3);
    list-style: none;
    display: grid;
    gap: var(--bi-space-1);
}

/* The list gap does the spacing; drop the global li + li margin. */
.bi-popular__list > li {
    margin: 0;
}

.bi-popular__link {
    display: inline-block;
    padding-block: var(--bi-space-1);
    color: var(--bi-color-text);
    font-size: var(--bi-font-size-sm);
    line-height: 1.35;
    text-decoration: none;
}

.bi-popular__link:hover {
    color: var(--bi-color-link-hover);
    text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
    .bi-popular__chevron {
        transition: none;
    }
}

/* Phones: terms wrap side by side so an open group stays short. */
@media (max-width: 639px) {
    .bi-popular__list {
        display: flex;
        flex-wrap: wrap;
        gap: var(--bi-space-1) var(--bi-space-4);
    }
}

@media (min-width: 640px) {
    .bi-popular {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .bi-popular__title {
        grid-column: 1 / -1;
    }
}

@media (min-width: 1024px) {
    .bi-popular {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}
