/* ==========================================================================
   EDAMA QMS list pages (UX stage 11)

   The portal's list pages: the head, then (later tasks) the state-keeping pager, the chips, the groups and the phone cards.
   Linked once, in `shared_ui/base_shell.html`, after `blocks.css`.

   Rules of this sheet (its test reads them):
     - every colour, size and gap is a token of `tokens.css`; no colour literal is written here;
     - logical properties only, so Arabic mirrors without a second rule;
     - no declaration here is marked important;
     - no text under 12px (`--type-caption` is the floor);
     - the only width breakpoint is the portal's one phone breakpoint (767px), written beside the coarse-pointer query where a touch
       target is meant.
   ========================================================================== */

/* -- The head (Task 3) ---------------------------------------------------------------------------------------------------------- */

/* "Also in": under the line, not inside the heading. The badges had no rule of their own before; a quiet caption and pill-like links. */
.list-also-in .cross-stream-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-block: var(--sp-2) 0;
}

.list-also-in .xref-label {
    font-size: var(--type-caption);
    color: var(--ink-soft);
}

.list-also-in .xref-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding-block: var(--sp-1);
    padding-inline: var(--sp-3);
    border: 1px solid var(--info-border);
    border-radius: var(--radius-full);
    background: var(--info-bg);
    color: var(--brand-secondary);
    font-size: var(--type-caption);
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
}

.list-also-in .xref-badge:hover {
    background: var(--btn-plain-bg);
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.list-also-in .xref-badge:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

/* The sentence that stands where a Create control would, for a person the drawer would refuse. */
.list-reader-note {
    margin: 0;
    align-self: center;
    font-size: var(--type-meta);
    color: var(--ink-soft);
}

/* -- The chips (Task 6) ------------------------------------------------------------------------------------------------------- */

/* Plain links in a wrapping row: they mirror in Arabic with the page, and wrap on a phone rather than shrink. */
.list-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    margin-block: 0 var(--sp-3);
}

.list-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding-block: var(--sp-1);
    padding-inline: var(--sp-3);
    border: 1px solid var(--btn-line);
    border-radius: var(--radius-full);
    background: var(--btn-plain-bg);
    color: var(--ink-soft);
    font-size: var(--type-meta);
    font-weight: 600;
    line-height: 1.4;
    text-decoration: none;
    white-space: nowrap;
}

.list-chip:hover {
    border-color: var(--brand-primary);
    color: var(--brand-primary);
}

.list-chip:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

.list-chip__count {
    font-size: var(--type-caption);
    font-variant-numeric: tabular-nums;
}

/* Review due carries the warning colours, so a number that asks for attention reads as one. */
.list-chip--warn {
    border-color: var(--warning-border);
    background: var(--warning-bg);
    color: var(--warning-ink);
}

.list-chip--warn:hover {
    border-color: var(--warning);
    color: var(--warning-ink);
}

/* The chip the list on screen belongs to (at most one). Also marked by aria-current in the markup. */
.list-chip.is-active {
    border-color: var(--brand-primary);
    background: var(--brand-primary);
    color: var(--on-brand);
}

/* -- The document cell and the quiet cells (Task 7) --------------------------------------------------------------------------- */

/* The title leads and is the door; the code sits under it as a caption. Block children of the cell, so the cell itself stays a table cell. */
.data-table td.doc-cell {
    min-inline-size: 12rem;
}

/* The title and the code are ONE block child of the cell: below 768 px a `td` is a flex row (the card), and two loose children would sit side by
   side with the label; one block keeps the code under the title in a card as in a table. */
.data-table .doc-text {
    display: block;
    min-inline-size: 0;
    text-align: start;
}

/* The word of an overdue or due review beside its date (a state is never told by colour alone). */
.data-table .review-word {
    font-weight: 600;
}

.data-table .doc-title {
    display: block;
    font-weight: 600;
    color: var(--brand-primary);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.data-table .doc-title:hover {
    text-decoration: underline;
}

.data-table .doc-title:focus-visible {
    outline: var(--focus-ring);
    outline-offset: var(--focus-offset);
}

.data-table .doc-code {
    display: block;
    margin-block-start: var(--sp-1);
    font-size: var(--type-caption);
    color: var(--ink-soft);
    letter-spacing: 0.02em;
}

/* A conditional column's cell with nothing in it: the dash stays (a person reads it today) but recedes. */
.data-table td.is-empty {
    color: var(--ink-soft);
}

/* The pill in the Next review cell is the stage 7 pill (blocks.css owns its name: no other sheet may spell it); `.review-pill` is this page's
   own hook on it, and here it only keeps the date on one line and its digits aligned. */
.data-table td .review-pill time {
    font-variant-numeric: tabular-nums;
}

/* -- The groups (Task 8) ------------------------------------------------------------------------------------------------------ */

/* One section per procedure: a heading line that names it, then its own table. The words wrap (a long title never pushes the page).
   `section.list-group`, never the bare class: this sheet is linked on every page, and Bootstrap's `.list-group` is a `ul` or a `div` on
   My Day, four dashboards and the report builder, which must not gain a top margin. */
section.list-group {
    margin-block: var(--sp-5) 0;
}

.list-group__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--sp-1) var(--sp-3);
    margin-block: 0 var(--sp-2);
    font-size: var(--type-title);
    line-height: 1.3;
    color: var(--ink);
}

.list-group__title {
    font-weight: 700;
    overflow-wrap: anywhere;
}

.list-group__meta,
.list-group__continued {
    font-size: var(--type-meta);
    font-weight: 400;
    color: var(--ink-soft);
}

.list-group__continued {
    font-style: italic;
}

/* "Needs an owner": the warning colours, so a group nobody answers for reads as one that asks for attention. */
.list-group__flag {
    display: inline-block;
    padding-block: var(--sp-1);
    padding-inline: var(--sp-2);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-full);
    background: var(--warning-bg);
    color: var(--warning-ink);
    font-size: var(--type-caption);
    font-weight: 600;
    line-height: 1.3;
}

/* -- The one phone seam: cards that read (Task 9) -------------------------------------------------------------------------------- */

/* The card rules themselves (thead hidden, a row a card, a cell a labelled line) are `site.css`, at this same 767px (the table's 768px
   block gave them up). Here only what makes a card read: no table width, no empty lines, the title first, targets 44 by 44.
   The page's end is cleared of the bottom bar by `shell.css` (`.shell-main` padding at 767px): the last card and the pager need nothing more. */
@media (max-width: 767px) {
    /* The 680px table width (site.css) would scroll a card sideways between 761 and 767; a card has no width of its own. */
    .data-table {
        min-inline-size: 0;
    }

    /* A cell with nothing to say is not a card line: the dash and its label go (the cell stays in the markup, one td per th).
       Specificity 0,2,1 beats `.data-table tbody td` (0,1,2) that sets display: flex. */
    .data-table td.is-empty {
        display: none;
    }

    /* The document cell is the card's heading: a block, no label of its own, the title first and the code under it. Its children are
       blocks, so nothing here undoes the cell's own stacking. */
    .data-table td.doc-cell {
        display: block;
        min-inline-size: 0;
        text-align: start;
    }

    /* `site.css` sets `[dir="rtl"] .data-table tbody td { text-align: left }` (0,2,2): `td.doc-cell` (0,2,1) alone would lose to it in Arabic and the
       code caption would stay left-aligned under a right-aligned title. This one (0,3,1) outranks it. */
    [dir="rtl"] .data-table td.doc-cell {
        text-align: start;
    }

    .data-table td.doc-cell::before {
        display: none;
    }

    .data-table td.doc-cell .doc-title {
        font-size: var(--type-body);
    }

    /* The row's doors: each at least 44 by 44. */
    .data-table .row-actions .btn,
    .data-table .row-actions .inline-link {
        min-block-size: var(--target);
        min-inline-size: var(--target);
    }

    /* A group's heading over its cards. */
    .list-group__head {
        margin-block: var(--sp-4) var(--sp-3);
    }

    /* Previous and Next. */
    .pager a,
    .pager .btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-block-size: var(--target);
        min-inline-size: var(--target);
    }
}

/* A touch target is 44 by 44 (the badge and the chip wrap to the next line rather than shrinking). */
@media (max-width: 767px), (pointer: coarse) {
    .list-also-in .xref-badge,
    .list-chip {
        min-block-size: var(--target);
        min-inline-size: var(--target);
    }

    .data-table .doc-title {
        display: flex;
        align-items: center;
        min-block-size: var(--target);
    }
}
