/*
 * components.css — Layer 7: the SYSTEM COMPONENT VOCABULARY.
 *
 * Every class in this file is a documented, reusable design-system
 * component, mirrored 1:1 on /core/design-system. Feature CSS composes
 * these (see features.css, layer 8); sanctioned divergences live in
 * overrides.css (layer 9). Adding or changing a component here is a
 * design-system change: it goes through the extension gate
 * (doc/architecture/architecture.md § CSS Organization → Authoring rules) and lands
 * on the Design System page in the same change. Coloring lives in
 * colors.css.
 */

.hidden {
    display: none;
    opacity: 0;
}

.gone {
    display: none;
    opacity: 0;
    height: 0;
    overflow: hidden;
}

/* Bound a content block to the app's half-fluid measure: the same width
   discipline forms use, for list pages and other primary content that would
   otherwise stretch edge-to-edge. Narrower content is unaffected. */
.content-measure {
    width: var(--content-measure);
    max-width: var(--form-measure-max);
    box-sizing: border-box;
}

/* A fieldset used for what `disabled` on it does, not for what a fieldset
   means: it disables every form control inside, of every kind, so a read-only
   sheet sitting inside a form that saves cannot post. Carries none of the
   grouping chrome, because it is not a group — it is a barrier.
   min-inline-size undoes the UA's min-content floor, which would otherwise stop
   the contents shrinking.

   Its reach is every form control, which includes buttons that only read: a
   chooser's Preview, a blob's copy-link, and the timestamp picker's zone select
   — which its atom deliberately leaves enabled so a viewer can re-display the
   same instant elsewhere — all go dead inside a barrier. Nothing nested can undo
   a disabled fieldset, so a sheet that needs one of those affordances needs a
   different answer, not a smaller barrier. Links are unaffected. */
.form-barrier {
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    min-inline-size: 0;
}

/* ********************* SPINNER ********************* */
.spinner {
    position: relative;
    width: 30px;
    height: 30px;
    border-radius: 10rem;
    border-style: solid;
    border-width: 0.25pt;
    animation: spin 1s linear infinite;
}

.spinner::before {
    position: absolute;
    content: "";
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 70%;
    height: 70%;
    border-radius: 10rem;
    border-style: solid;
    border-width: 0.25pt;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

/* ***************** END SPINNER ********************* */

/* ************ HTMX PROGRESS FEEDBACK ************** */

/* The rules htmx would otherwise inject as an inline <style>; the layouts turn
   that off in htmx-config because the app policy refuses inline style elements. */
.htmx-indicator {
    opacity: 0;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
    transition: opacity 200ms ease-in;
}

/* In-flight action buttons: fade the label and spin a ring centered in place,
   at the button's existing width (the label still occupies its space). htmx adds
   .htmx-request to the triggering element — the button itself, or the form when
   hx-post lives on the form; .htmx-retrying marks a pending conflict retry.
   Coloring is in colors.css. */
button.htmx-request,
button.htmx-retrying,
form.htmx-request button[type="submit"],
form.htmx-retrying button[type="submit"],
form.htmx-request button:not([type]),
form.htmx-retrying button:not([type]) {
    position: relative;
    color: transparent;
    pointer-events: none;
}

/* Triggers with no label to fade — a role checkbox, a select. The waiting state
   is the native disabled rendering warhol-apps.js applies alongside this. */
input.htmx-retrying,
select.htmx-retrying {
    pointer-events: none;
}

button.htmx-request::after,
button.htmx-retrying::after,
form.htmx-request button[type="submit"]::after,
form.htmx-retrying button[type="submit"]::after,
form.htmx-request button:not([type])::after,
form.htmx-retrying button:not([type])::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 1.1em;
    height: 1.1em;
    border-radius: var(--radius-full);
    border-style: solid;
    border-width: 2px;
    border-right-color: transparent;
    animation: spin 0.6s linear infinite;
}

/* Page-level loading bar for non-button triggers (nav swaps, search, htmx.ajax).
   Driven by the htmx event hooks in warhol-apps.js, which toggle .active. */
#htmx-progress {
    position: fixed;
    top: var(--titlebar-height);
    left: 0;
    right: 0;
    height: 3px;
    z-index: 2000;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease-out;
}

#htmx-progress.active {
    opacity: 1;
}

#htmx-progress::after {
    content: "";
    position: absolute;
    top: 0;
    height: 100%;
    width: 40%;
    border-radius: var(--radius-pill);
    animation: htmxProgressSlide 1.1s ease-in-out infinite;
}

@keyframes htmxProgressSlide {
    0% {
        left: -40%;
    }
    100% {
        left: 100%;
    }
}

/* ********** END HTMX PROGRESS FEEDBACK ************ */

section#alert {
    height: initial;
    /* Stack must not clip the slide-in/exit transforms or the drop shadow. */
    overflow: visible;
    padding: 0;

    section {
        /* Two animations share the element so neither fights the other for a property:
           toastIn owns transform (the slide), alertFadeOut owns opacity + the exit
           collapse. The keyframe name alertFadeOut is load-bearing — warhol-apps.js
           removes the node on its animationend, so it must stay named exactly this.
           --toast-life is the clock for the whole lifecycle; raising it mid-flight
           (which warhol-apps.js does on push-up) leaves elapsed time alone, so the
           remaining time grows by exactly the bonus instead of restarting. */
        animation: toastIn 0.35s ease-out, alertFadeOut var(--toast-life) forwards;
    }
}

/* Entrance: slide up into place from below the bottom-right anchor. */
@keyframes toastIn {
    from {
        transform: translateY(12px);
    }
    to {
        transform: translateY(0);
    }
}

/* Lifecycle: quick fade-in, hold at full size, then fade + collapse the vertical
   space in the final 6% so the stack reflows smoothly on exit. Every property that
   collapses at 100% is also pinned at full value at 94% — otherwise it would
   interpolate from its base across the whole life (and the card would visibly shrink
   the entire time). Only top/bottom box edges collapse; the 4px left accent is left
   alone since it doesn't affect height. */
@keyframes alertFadeOut {
    0% {
        opacity: 0;
        max-height: 40rem;
    }
    3% {
        opacity: 1;
        max-height: 40rem;
    }
    94% {
        opacity: 1;
        max-height: 40rem;
        margin-top: 0;
        padding-top: var(--space-sm);
        padding-bottom: var(--space-sm);
        border-top-width: 1px;
        border-bottom-width: 1px;
    }
    100% {
        opacity: 0;
        max-height: 0;
        margin-top: calc(-1 * var(--space-sm));
        padding-top: 0;
        padding-bottom: 0;
        border-top-width: 0;
        border-bottom-width: 0;
        overflow: hidden;
        /* End state stays display:none — JS removes the node on animationend, and the
           visual suite relies on Playwright fast-forwarding finite animations here so
           snapshots never capture a lingering alert (ensemble.visual.spec.ts). */
        display: none;
    }
}

/* Auto-dismiss countdown — depletes left-to-right over the toast's life, synced to
   alertFadeOut. Pure decoration via ::after, so no markup change is needed. */
@keyframes toastTimer {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

section.alert {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--divider);
    border-left-width: 4px;
    border-radius: var(--radius-lg);
    padding: var(--space-sm) var(--space-md);
    /* Inline callouts separate themselves from following content; the toast stack
       resets this and spaces itself via section#alert's flex gap instead. */
    margin-bottom: var(--space-md);

    .heading {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
        font-weight: var(--typography-fontWeightBold);
        font-size: var(--font-size-sm);

        span {
            display: flex;
            flex-direction: row;
            align-items: center;
            min-width: 0;

            .icon {
                font-size: 1.15rem;
                line-height: 1;
                flex-shrink: 0;
            }

            .title {
                padding-left: 0.7rem;
            }
        }

        a {
            font-size: 1rem;
            line-height: 1;
            flex-shrink: 0;
            margin-left: var(--space-sm);
            text-decoration: none;
        }
    }

    .message {
        height: auto;
        /* Align the message under the title text, past the icon gutter. */
        padding-left: calc(1.15rem + 0.7rem);
        margin-top: var(--space-xs);
        font-size: var(--font-size-sm);
        line-height: 1.5;
    }
}

/* Toast-only behaviours, scoped to the floating #alert stack. Inline <@alertBox>
   callouts elsewhere share the card look above but stay static — no countdown bar
   (the ::after only generates where `content` is set) and no hover-pause. */
section#alert section.alert {
    /* Stack spacing comes from section#alert's flex gap, not per-card margin. */
    margin-bottom: 0;

    /* Hovering or keyboard-focusing a toast pauses both its lifecycle and its
       countdown, holding it open (and deferring removal, since that fires on
       alertFadeOut's end). */
    &:hover,
    &:focus-within {
        animation-play-state: paused;

        &::after {
            animation-play-state: paused;
        }
    }

    /* Countdown bar. Geometry here; per-severity colour lives in colors.css. */
    &::after {
        content: "";
        position: absolute;
        left: 0;
        bottom: 0;
        width: 100%;
        height: 3px;
        transform-origin: left center;
        animation: toastTimer var(--toast-life) linear forwards;
    }
}

/* Persistent toasts: warnings and errors are the ones the user is expected to act
   on, and an alert carrying an action (e.g. "Approve now") likewise. They skip the
   auto-dismiss and survive until the user closes them or a later response clears
   the stack. animationend removal in warhol-apps.js is keyed to alertFadeOut, so
   simply never running that animation is enough — no JS change needed. */
section#alert section.alert-sticky,
section#alert section.alert-warning,
section#alert section.alert-error {
    animation: toastIn 0.35s ease-out forwards;

    &::after {
        display: none;
    }
}

/* Respect reduced-motion: no slide, no depleting bar — appear instantly and still
   auto-dismiss via opacity/collapse. */
@media (prefers-reduced-motion: reduce) {
    section#alert section {
        animation: alertFadeOut var(--toast-life) forwards;
    }

    section#alert section.alert-sticky,
    section#alert section.alert-warning,
    section#alert section.alert-error {
        animation: none;
    }

    section#alert section.alert::after {
        animation: none;
        display: none;
    }
}

.avatar-square {
    border-radius: 10%;
    overflow: hidden;

    img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.avatar-round {
    border-radius: 50%;
    overflow: hidden;

    img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
}

.report-avatar {
    img {
        width: 20px;
        height: 20px;
    }
}

/* ============= DUAL SELECT COMPONENT ============= */

.dual-select-container {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: var(--space-md);
    margin: var(--space-md) 0;
    width: 100%;

    & > label {
        width: 100%;
        margin-bottom: var(--space-sm);
    }

    .dual-select-left-container,
    .dual-select-right-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--space-ms);

        label {
            font-weight: var(--typography-fontWeightMedium);
        }

        select {
            min-width: 15rem;
            min-height: 10rem;

            option {
                padding: var(--space-sm);
            }
        }

        button {
            width: 100%;
        }
    }

    .dual-select-order-btns {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: var(--space-sm);
        padding-top: var(--space-xl);

        button {
            min-width: 4rem;
        }
    }
}

@media screen and (max-width: 768px) {
    .dual-select-container {
        flex-direction: column;
        align-items: stretch;

        .dual-select-left-container,
        .dual-select-right-container {
            width: 100%;

            select {
                min-width: 100%;
            }
        }

        .dual-select-order-btns {
            flex-direction: row;
            padding-top: 0;
            justify-content: center;
        }
    }
}

/* ============= END DUAL SELECT COMPONENT ============= */

.tooltip {
    position: relative;
    display: inline-block;

    .tooltiptext {
        visibility: hidden;
        width: 140px;
        text-align: center;
        border-radius: var(--radius-md);
        padding: 5px;
        position: absolute;
        z-index: 1;
        bottom: 150%;
        left: 50%;
        margin-left: -75px;
        opacity: 0;
        transition: opacity 0.3s;
    }

    .tooltiptext::after {
        content: "";
        position: absolute;
        top: 100%;
        left: 50%;
        margin-left: -5px;
        border-width: 5px;
        border-style: solid;
    }

    &:hover .tooltiptext {
        visibility: visible;
        opacity: 1;
    }
}

/*
 * Button — base layout.
 * Moved here from forms.css; buttons aren't form inputs and the layout
 * rules belong with the rest of the component primitives. Color
 * variants stay in colors.css with the other coloring rules.
 */
button,
span.button,
a.button {
    display: inline-block;
    margin: 0;
    padding-block: 2px;
    padding-inline: 9px;
    text-indent: 0;
    text-shadow: none;
    text-align: center;
    box-sizing: border-box;
    border-width: thin;
    border-radius: var(--radius-md);
    border-style: solid;
    cursor: default;
}

button,
span.button,
a.button,
a:visited.button {
    i {
        display: inline-block;
        transition: transform 0.175s ease;
    }

    &:hover:not(:disabled) i {
        transform: scale(1.15);
    }
}

button.full,
.button.full {
    width: 100%;
}

/*===========ACCORDION START=================*/

input.accordion-check {
    position: absolute;
    opacity: 0;
    z-index: -1;
}

.accordion {
    overflow: hidden;

    /* Forms render attribute groups as accordions side-by-side with
       <label>-wrapped text/textarea/select inputs that all have
       `width: 100%`. The accordion is a plain <div>, so without an
       explicit width it shrinks to its content under the form's
       `display: flex; flex-direction: column; align-items: center`
       layout. Match the label/section width so a grouped section
       spans the full form column like adjacent inputs do. */
    width: 100%;
    box-sizing: border-box;

    .accordion-label {
        display: flex;
        justify-content: space-between;
        cursor: pointer;
        padding: var(--space-md);
        margin: 0;
        width: calc(100% - 2rem);
        /* same as h4 (M3 Headline Small) */
        font-weight: var(--typography-fontWeightRegular);
        font-size: 1.5rem;
        line-height: 2rem;
        letter-spacing: 0;

        /* Hover/checked backgrounds live in colors.css. */

        /* Icon */

        &::after {
            content: "\276F";
            width: 1em;
            height: 1em;
            text-align: center;
            transition: all .35s;
        }
    }

    .accordion-content {
        max-height: 0;
        padding: 0 1em;
        transition: all .35s;

        border-top-style: solid;
        border-top-width: 1px;
    }

    border-spacing: 0;
    border-style: solid;
    border-width: 1px;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;

    margin: var(--space-lg) 0;
}

/* checked */
input.accordion-check:checked {
    + .accordion-label {
        &::after {
            transform: rotate(90deg);
        }
    }

    ~ .accordion-content {
        max-height: fit-content;
        padding: 1em;
    }
}

/*====================ACCORDION END=======================*/

/* Info list — THE key/value <dl> grid. Modifiers: -lg widens the column
   gap; -left drops the right-aligned label look for quiet metadata. All
   variants collapse to a single column on mobile. */
.info-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: var(--space-sm) var(--space-md);
    margin: 0;

    dt {
        font-weight: var(--typography-fontWeightMedium);
        text-align: right;
    }

    dd {
        margin: 0;
    }
}

.info-list-lg {
    column-gap: var(--space-lg);
}

.info-list-left dt {
    font-weight: var(--typography-fontWeightSemiBold);
    text-align: left;
}

@media screen and (max-width: 768px) {
    .info-list {
        grid-template-columns: 1fr;
        gap: var(--space-xs);

        dt {
            text-align: left;
            margin-top: var(--space-sm);
        }
    }
}

/* Status badges — THE static label/count pill. Semantic color variants
   (.badge-neutral/-info/-success/-warning/-error) carry the coloring; shape
   and tone modifiers below. Interactive pills are .chip, not .badge. */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: 0.25rem 0.625rem;
    font-size: 0.8rem;
    font-weight: var(--typography-fontWeightMedium);
    line-height: 1;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

/* Fully-rounded shape (counts, live-status pills). */
.badge-pill {
    border-radius: var(--radius-pill);
}

/* Quiet outlined tone for lowercase counts/metadata (colors in colors.css). */
.badge-outline {
    text-transform: none;
    letter-spacing: normal;
    border-style: solid;
    border-width: 1px;
}

/* Overlay badge — anchored to a corner of a thumbnail to telegraph what
   the image is (e.g. the media-type glyph on chooser thumbnails). The
   anchoring container must be position: relative with overflow hidden.
   One neutral treatment only: type identity is not status, so semantic
   variants don't apply. Solid paper surface + shadow (coloring in
   colors.css) keeps it legible over arbitrary image content in both
   color schemes. Non-interactive by definition. */
.badge-overlay {
    position: absolute;
    bottom: var(--space-xs);
    left: var(--space-xs);
    z-index: 2;
    padding: 0.2rem 0.3rem;
    font-size: 0.7rem;
    pointer-events: none;
    box-shadow: var(--shadow-1);
}

/* Status dot — colored by the parent's text color so semantic variants
   tint it for free; state-specific animation hooks stay with the feature. */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: var(--radius-full);
    display: inline-block;
    background-color: currentColor;
}

/* Semantic variant coloring (.badge-neutral/-info/-success/-warning/-error)
   lives in colors.css. */

/* Muted text utility - use for secondary, placeholder, or unavailable values.
   Color in colors.css; the opacity dim stays here. */
.text-muted {
    opacity: 0.8;
}

/* ============= CARD COMPONENT ============= */

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: var(--space-lg);
    padding: var(--space-md) 0;
}

.card {
    border-radius: var(--radius-lg);
    border-style: solid;
    border-width: 1px;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-4);
}

.card-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: 1.25rem;
    border-bottom-style: solid;
    border-bottom-width: 1px;
}

.card-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    font-size: 1.5rem;
    /* Kill the inherited 1.5 line-height: the glyph's line box otherwise
       sits below the flex-centered midpoint (the off-center star). */
    line-height: 1;
}

.card-icon-sm {
    width: 36px;
    height: 36px;
    font-size: var(--font-size-lg);
}

.card-icon-lg {
    width: 64px;
    height: 64px;
    font-size: 2rem;
}

.card-title {
    flex: 1;
    min-width: 0;
}

.card-title h3 {
    margin: 0 0 var(--space-xs) 0;
    font-size: var(--font-size-xl);
    font-weight: var(--typography-fontWeightMedium);
}

.card-title p {
    margin: 0;
    font-size: var(--font-size-sm);
    opacity: 0.7;
}

.card-body {
    padding: 1.25rem;
}

@media screen and (max-width: 768px) {
    .card-grid,
    .card-grid-2 {
        grid-template-columns: 1fr;
    }

    .card-header {
        padding: var(--space-md);
    }

    .card-body {
        padding: var(--space-md);
    }

    .card-icon {
        width: 40px;
        height: 40px;
        font-size: var(--font-size-xl);
    }
}

/* ============= END CARD COMPONENT ============= */

/* ============= CHIP/PILL COMPONENT ============= */

/* Chip — THE interactive pill (filters, pickers, tag values). Interactivity
   keys off the element: a/button/label chips lift on hover and take the
   selected state; a bare span.chip is static chrome (e.g. tag values whose
   only affordance is the embedded .chip-remove). Colors in colors.css. */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
    padding: 0;
    list-style: none;
}

/* Bar flavour: a chip-group used as a standalone filter row. */
.chip-bar {
    margin: var(--space-sm) 0 var(--space-md);
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-pill);
    border-style: solid;
    border-width: 1px;
    font-size: 0.9rem;
    font-weight: var(--typography-fontWeightMedium);
    text-decoration: none;
    transition: all 0.15s ease;
}

a.chip, button.chip, label.chip {
    cursor: pointer;
}

a.chip:hover, button.chip:hover, label.chip:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-2);
}

.chip i {
    font-size: var(--font-size-xs);
    opacity: 0.7;
}

.chip-sm {
    padding: 0.2rem 0.6rem;
    font-size: var(--font-size-sm);
    font-weight: var(--typography-fontWeightRegular);
}

.chip-label {
    white-space: nowrap;
}

/* Remove affordance inside a chip (colors in colors.css). */
.chip-remove {
    display: inline-flex;
    align-items: center;
    background: none;
    border: 0;
    padding: 0 0.1rem;
    cursor: pointer;
    line-height: 1;
    font-size: var(--font-size-xs);
}

/* ============= END CHIP/PILL COMPONENT ============= */

/* ============= EMPTY STATE ============= */

.empty-state {
    margin: 0;
    padding: var(--space-md);
    text-align: center;
    font-style: italic;
    opacity: 0.6;
}

/* ============= END EMPTY STATE ============= */

/* ============= BUTTON GROUP ============= */

.button-group {
    display: inline-flex;
    gap: 1px;
    border-style: solid;
    border-width: 1px;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.button-group button,
.button-group a.button {
    border: 0;
    border-radius: 0;
    margin: 0;
    box-shadow: none;
}

/* ============= END BUTTON GROUP ============= */

/* ============= SEARCH BAR ============= */

.search-bar {
    display: flex;
    align-items: center;
    border-radius: var(--radius-md);
    padding: 0.4rem var(--space-ms);
    min-height: 1.3rem;
    gap: var(--space-sm);
}

.search-bar i {
    opacity: 0.6;
}

.search-bar input {
    flex: 1;
    border: none;
    background: transparent;
    box-shadow: none;
    padding: 0.25rem 0;
    font-size: 0.9rem;
}

.search-bar input:focus {
    outline: none;
    box-shadow: none;
}

/* The outline: none above had no replacement. */
.search-bar input:focus-visible {
    outline-width: 2px;
    outline-style: solid;
    outline-offset: 2px;
}

/* ============= END SEARCH BAR ============= */

/* ============= ROW + DRAG GRAMMAR ============= */

/* Row — THE compact bordered list row (drag lists, chooser selections,
   nav-tree rows). Composing features add only their own affordances.
   Coloring in colors.css. */
.row-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.35rem 0.6rem;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.row-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

/* Drag grammar — ONE set of states for every draggable row. The dragged row
   dims; drop position is signalled with inset primary edges (before/after)
   or a full inset outline ("nest under" for tree demotion). The coloured
   drop indicators live in colors.css. */
.row-item.dragging {
    opacity: 0.45;
}

/* ============= GENERIC <dialog> MODAL BASELINE =============
   Apply class="modal" to any <dialog> for theme-aware styling that
   responds to light/dark mode automatically. Layout structure:

       <dialog class="modal my-thing-modal">
           <div class="modal-header"><h3>…</h3><button data-close-modal>×</button></div>
           <div class="modal-body">…</div>
           <div class="modal-footer"><button>Close</button></div>
       </dialog>

   An anchored variant (class="modal modal-anchored") is positioned by JS via
   inline top/left/width instead of the default <dialog> centering. */

.modal {
    border-width: 1px;
    border-style: solid;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-16);
    padding: 0;
    max-width: min(640px, 92vw);
    max-height: 85vh;
}

/* JS-anchored dialog: positioned explicitly via inline top/left/width.
   border-box lets the JS-set width match the anchor element exactly. */
.modal-anchored {
    inset: auto;
    margin: 0;
    box-sizing: border-box;
    padding: var(--space-md);
    max-height: 70vh;
    overflow: auto;
}

/* Popover — THE anchored tip/preview panel (hover cards, tile previews).
   Composing rules supply placement (top/right/bottom/width). Coloring in
   colors.css. */
.popover {
    position: absolute;
    z-index: 900;
    border-width: 1px;
    border-style: solid;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-6);
    padding: var(--space-sm);
}

/* Icon button — THE borderless glyph button (close, info, open-link,
   favourite toggles, in-row utilities). Strips the global action-button
   chrome; colors in colors.css (muted, lifting on hover; -danger lifts to
   the error color instead). */
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    box-shadow: none;
    padding: var(--space-xs) var(--space-sm);
    font-size: var(--font-size-base);
    line-height: 1;
    cursor: pointer;
    text-decoration: none;

    &:disabled {
        cursor: not-allowed;
        opacity: 0.4;
    }
}

/* Compact flavour for tight rows (drag rows, chooser rows, tile corners). */
.icon-button-sm {
    padding: 0.1rem 0.35rem;
    font-size: var(--font-size-sm);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-ms) 1rem;
    border-bottom-width: 1px;
    border-bottom-style: solid;
}

.modal-header h3 {
    margin: 0;
    font-size: var(--font-size-lg);
}

/* Close buttons are system icon-buttons (class="icon-button modal-close" —
   the second class is the JS/behavior hook only). */

.modal-body {
    padding: var(--space-md);
    overflow: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding: var(--space-ms) 1rem;
    border-top-width: 1px;
    border-top-style: solid;
}

/* ============= END GROUP INFO POPOVER ============= */
