/* ============================================================================
   summary.css — the Summary view's own thin layer on top of mds.css.
   Prefix: summary-
   ========================================================================= */

/* The five titled groups (issue #57) stack down the page and wear the section head — both come
   from the core .mds-groups--sections modifier now (promoted in #68, when Stowage needed the
   identical structure). What is left here is Summary-specific. */
.summary-groups {
    /* The label track of a wide card's data rows (see below): a floor, not a fixed width, so the
       values line up down a column instead of hanging off each label's own length. Measured, not
       guessed — 10em clears all TWELVE labels of the property inventory, the two conditional rows
       included: "Static Accumulator" is the widest at 140px and shows up on every static-accumulating
       cargo, so a floor sized to the ten unconditional rows let its value scrape past the column.
       A longer label keeps its full width: one ragged row beats a clipped label. */
    --summary-data-label: 10em;
}

/* The head's own bottom margin sets the air above the cards — except in Identification, where the
   synonym strip sits between the two and the cards would start 2px under its "Show all" toggle.
   The strip is the only thing that ever comes between head and cards, so the gap is stated exactly
   there instead of as a margin on every .mds-cards (which would double up under the head). */
.summary-groups .mds-chips-toggle + .mds-cards { margin-top: var(--mds-space-3); }

/* The cards go quiet underneath: no second rule, no second icon. The title stays — it names the
   card AND is the render-parity "section" fact. .mds-card__icon carries no text, so hiding it
   costs no fact (verified in #55). */
.summary-groups .mds-card__head {
    margin-bottom: var(--mds-space-2);
    padding-bottom: 0;
    border-bottom: none;
}
.summary-groups .mds-card__icon { display: none; }

/* The core pins the ⓘ to the RIGHT end of the card head — right for a 340px card, absurd for a card
   that spans the group: on the 1200px panel it ended up ~1000px from the title it belongs to, alone
   at the panel edge. In this view it stays a satellite of the title, for EVERY card, so the same
   element is not in two places on one page. */
.summary-groups .mds-card__info { margin-left: var(--mds-space-2); }

/* ---- the cards fill the group width ---------------------------------------------------------
   Two cards per row instead of the core's three: no Summary group holds more than two cards, so
   the third track would only ever be empty air on the right while the cards themselves stay
   needlessly narrow. */
@media (min-width: 1024px) {
    .summary-groups .mds-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* A card that is alone in its group owns the whole row — otherwise it sits in the left track with
   a card-sized white area beside it (Physical Properties on every cargo; Identification or a
   cleaning card whenever its partner gates itself away). :only-child, not a modifier class, so
   the layout follows the cards that actually rendered without the view having to know. */
.summary-groups .mds-cards > .mds-card:only-child { grid-column: 1 / -1; }

@media (min-width: 768px) {
    /* … and a full-width card lays its data rows out in COLUMNS instead of a narrow strip of
       labels with a desert beside it: as many ~260px columns as the card is wide (two from 768px,
       three on the capped 1200px panel). Pure display switching on the existing table — the row
       markup and row order are untouched, so every kv fact the golden master reads survives. */
    .summary-groups .mds-cards > .mds-card:only-child .mds-data {
        display: grid;
        /* auto-fit over a 260px minimum, capped at THREE columns: the fourth track a 1200px panel
           would still fit turns a property list into confetti (three rows per column) — and a
           label/value pair needs its width more than the page needs another column. The max()
           raises the track minimum to a third of the row as soon as that is the wider of the two. */
        grid-template-columns: repeat(auto-fit, minmax(max(260px, (100% - 2 * var(--mds-space-7)) / 3), 1fr));
        column-gap: var(--mds-space-7);
    }
    /* Blazor builds the table WITHOUT the tbody an HTML parser would insert, a parsed copy of the
       same markup (bUnit, a static page) with one — display: contents makes the rows items of the
       table grid either way. */
    .summary-groups .mds-cards > .mds-card:only-child .mds-data > tbody { display: contents; }

    .summary-groups .mds-cards > .mds-card:only-child .mds-data tr {
        display: grid;
        grid-template-columns: minmax(var(--summary-data-label), max-content) minmax(0, 1fr);
        align-items: baseline;
        border-bottom: 1px solid var(--mds-line);
    }
    /* The ROW draws the rule now: label and value cell can differ in height, and two cell borders
       at two heights read as a broken line. Every row keeps its rule — the core's "no rule under
       the last row" would, in a column grid, drop it under whichever row falls last in SOURCE
       order, i.e. under one column only. A rule under every row is the predictable version; the
       columns end level when the row count divides by the column count (12/3 does; 10/3 leaves
       the last column one row short, and that ragged foot is the layout's, not the rule's). */
    .summary-groups .mds-cards > .mds-card:only-child .mds-data td { border-bottom: none; }
    /* the table-layout "shrink to the widest label" trick means nothing to a grid item */
    .summary-groups .mds-cards > .mds-card:only-child .mds-data__k { width: auto; }
}

/* A wider card must not turn a paragraph into a wall: prose keeps the card-prose measure of the
   core. Tables are unaffected - a label/value row is not read as a line. */
.summary-groups .mds-cardtext {
    max-width: var(--mds-measure);
}
