/* Model Cards -- hover/focus/tap capability cards on docs/models.html.
   Loaded only by docs/models.html. css/docs.css is pinned byte-for-byte by the
   preservation suite and is not touched; this file layers on top of it and
   reuses .concept-grid / .concept-card for the visual language. */

/* The grid inherits .concept-grid's gap and auto-fit behaviour. A wider track
   than .concept-grid's 250px is used so a revealed card, which is constrained
   to its own column (see .mc-card below), has room for its parameter table. */
.mc-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    align-items: start;
}

.mc-item {
    position: relative;
    min-width: 0;
}

/* Trigger: a real <button>, so it is focusable and operable without JS. */
.mc-trigger {
    display: block;
    width: 100%;
    text-align: left;
    cursor: pointer;
    font: inherit;
    color: var(--ucsb-navy);
    background-color: var(--ucsb-light-gray);
    border: 1px solid var(--ucsb-clay);
    border-left: 4px solid var(--ucsb-aqua);
    border-radius: 6px;
    padding: 0.75rem 1rem;
}

.mc-trigger:hover {
    background-color: var(--ucsb-white);
    border-color: var(--ucsb-aqua);
}

/* Focus ring: navy against the light-gray trigger and the white page, with a
   gold halo outside it. Gold alone is ~1.6:1 on both of those surfaces, which
   is not a usable indicator; navy carries the visibility and gold keeps the
   ring in the UCSB palette. */
.mc-trigger:focus-visible {
    outline: 3px solid var(--ucsb-navy);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(254, 188, 17, 0.6);
}

.mc-trigger code {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
}

/* Supporting label text. Navy, not --ucsb-dark-gray (#767676): that gray is
   the minimum passing contrast on white (~4.54:1) and these labels render on
   --ucsb-light-gray #F5F5F5 -- the trigger background and the .concept-card
   background -- where it computes ~4.17:1, under the 4.5:1 needed at 0.8rem.
   Navy on #F5F5F5 is ~13:1. */
.mc-provider,
.mc-row-label {
    display: block;
    margin-top: 0.15rem;
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--ucsb-navy);
}

/* Collapsed card. `visibility: hidden` rather than `display: none` so the
   content stays in the accessibility tree's reach once revealed, and the
   transition has something to animate.

   The card is pinned to its own grid column -- left: 0 with width: 100% and
   box-sizing: border-box -- so it can never extend past the item box, whatever
   column it lands in and however many columns the auto-fit grid produces. An
   earlier :nth-child(even) heuristic for choosing a left or right anchor was
   wrong: nth-child does not track column position. */
.mc-card {
    position: absolute;
    z-index: 20;
    top: calc(100% + 0.4rem);
    left: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.15s ease-in-out;
    box-shadow: 0 6px 18px rgba(0, 54, 96, 0.18);
    padding: 1rem 1.25rem;
}

/* Hover bridge. The 0.4rem offset above puts a gap between the trigger and the
   card that belongs to neither box, so a pointer travelling down into the card
   would leave .mc-item on the way and close an unpinned card before arriving --
   making the card's table unscrollable and its text unselectable without first
   clicking to pin. This transparent strip spans the gap. A pseudo-element
   generates :hover and mouseenter/mouseleave on its originating element, so
   crossing it counts as staying inside the card, and therefore inside the item.
   It inherits the collapsed card's `visibility: hidden`, so it is not
   hit-testable while the card is closed. */
.mc-card::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: -0.5rem;
    height: 0.5rem;
}

/* No-JS path: reveal on pointer hover and on keyboard focus anywhere inside
   the item. Hover alone would exclude keyboard users. These rules are scoped to
   :not(.mc-js) because when js/model-cards.js runs it owns the reveal, and
   `aria-expanded` can only stay truthful if exactly one state drives it. */
html:not(.mc-js) .mc-item:hover .mc-card,
html:not(.mc-js) .mc-item:focus-within .mc-card {
    visibility: visible;
    opacity: 1;
}

/* Enhanced path: js/model-cards.js sets `is-open` from hover, focus and tap,
   and sets aria-expanded from the same call. One state, one announcement. */
.mc-item.is-open .mc-card {
    visibility: visible;
    opacity: 1;
}

.mc-card h4 {
    margin: 0 0 0.6rem;
    color: var(--ucsb-navy);
    font-size: 1rem;
}

.mc-facts {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.15rem 0.75rem;
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
}

.mc-facts dt {
    font-weight: 600;
    color: var(--ucsb-navy);
}

.mc-facts dd {
    margin: 0;
}

/* Narrow-screen table semantics. docs.css sets `table { display: block;
   overflow-x: auto; white-space: nowrap }` below 968px, which drops the table
   role and with it the row/column association these tables carry -- the whole
   content of a card's table is "this parameter, in this arm, has this verdict".
   The scroll behaviour moves to this wrapper so the table itself can stay a
   table at every width. */
.mc-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.mc-table-wrap table {
    display: table;
    white-space: normal;
    margin: 0;
}

.mc-card .mc-table-wrap table {
    font-size: 0.8rem;
}

/* Verdict words. The word itself is text, so it survives CSS being off and is
   read out by a screen reader; colour is redundant reinforcement only. */
.mc-flag {
    font-weight: 600;
    white-space: nowrap;
}

.mc-flag-honored {
    color: #1a6b2f;
}

.mc-flag-ignored {
    color: #a32015;
}

.mc-flag-clamped,
.mc-flag-forced {
    color: #8a5a00;
}

/* 968px is the breakpoint docs.css actually uses: it is where .concept-grid
   collapses to a single column and where the sidebar becomes a drawer. From
   there down the card becomes a static block under its trigger, so it neither
   overlays the content that follows nor needs clamping against the viewport. */
@media (max-width: 968px) {
    .mc-grid {
        grid-template-columns: 1fr;
    }

    /* `position: static` alone is not enough: a `visibility: hidden` static box
       is invisible but still laid out at full height, which would leave every
       trigger separated by a card-sized void. The closed card is taken out of
       layout with `display: none` here and put back by the reveal selectors
       below. Above this breakpoint the card is absolutely positioned, so it
       occupies no layout space and `visibility` can keep driving the reveal. */
    .mc-card {
        position: static;
        width: auto;
        max-width: none;
        box-shadow: none;
        display: none;
    }

    /* No gap to bridge once the card is a static block under its trigger. */
    .mc-card::before {
        display: none;
    }

    html:not(.mc-js) .mc-item:hover .mc-card,
    html:not(.mc-js) .mc-item:focus-within .mc-card,
    .mc-item.is-open .mc-card {
        display: block;
    }
}

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

/* Header cells: docs.css sets `code { color: navy }` globally, which beats the
   white inherited from `thead` and leaves navy text on a navy header. Scoped
   to header cells only; `td code` keeps its pill. */
thead th code {
    color: inherit;
    background-color: transparent;
}

/* Legend and caption above the sampling matrix. */
.mc-legend {
    margin: 0 0 1rem;
}
.mc-legend dt {
    font-weight: 600;
    margin-top: 0.5rem;
}
.mc-legend dd {
    margin: 0 0 0 1.25rem;
}
.mc-caption {
    caption-side: top;
    text-align: left;
    color: var(--ucsb-navy);
    padding: 0.5rem 0;
}

/* Sidebar sub-links under "Available Models" (docs/models.html only).
   Scoped to `.nav-menu .nav-sub` so css/docs.css stays untouched. The nested
   list sits inside the active <li>, so docs.css's `.nav-menu li.active a`
   (gold fill, navy text) would otherwise cascade onto it; the selectors below
   reset that on purpose. Sub-links are smaller, indented and ruled on the left,
   in light text on the navy sidebar, so they read as children of the gold item
   rather than as a second one. */
.nav-menu .nav-sub {
    list-style: none;
    margin: 0;
    padding: 0.25rem 0 0.5rem;
}
.nav-menu li.active .nav-sub a,
.nav-menu .nav-sub a {
    margin-left: 1.5rem;
    padding: 0.4rem 1.5rem 0.4rem 1rem;
    border-left: 2px solid rgba(255, 255, 255, 0.35);
    background-color: transparent;
    color: var(--ucsb-mist);
    font-size: 0.85rem;
    font-weight: 400;
}
.nav-menu li.active .nav-sub a:hover,
.nav-menu .nav-sub a:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-left-color: var(--ucsb-white);
    color: var(--ucsb-white);
}
.nav-menu .nav-sub a:focus-visible {
    outline: 2px solid var(--ucsb-white);
    outline-offset: -2px;
}
/* The two headings the sub-links point at must not land under the fixed
   56px mobile header. */
#per-model-cards,
#sampling-parameter-support {
    scroll-margin-top: 72px;
}
