/* ===== RESPONSIVE DESIGN - MOBILE FIRST ===== */

@media (max-width: 1024px) {
    .navbar {
        text-align: center;
    }

    .navbar .container {
        justify-content: center;
    }
}

@media (max-width: 900px) {
    .navbar .container {
        padding: clamp(0.75rem, 2vw, 1rem) clamp(0.75rem, 3vw, 1rem);
        gap: clamp(0.375rem, 1.5vw, 0.75rem);
    }
}

/* Mobile (480px and up) */
@media (max-width: 767px) {
    .navbar-brand {
        flex-basis: 100%;
        order: 1;
    }

    .navbar-code {
        flex-basis: 100%;
        order: 2;
        text-align: center;
        white-space: wrap;
        word-break: break-word;
        font-size: clamp(0.6rem, 1.2vw, 0.75rem);
    }

    .navbar .navbar-code,
    footer .navbar-code {
        display: none;
    }

    /* Security Matrix - Convert to card layout */
    .matrix-wrapper {
        overflow-x: visible;
        margin: clamp(1rem, 3vw, 1.5rem) 0;
    }

    .matrix > thead {
        display: none;
    }

    .matrix > tbody {
        display: flex;
        flex-direction: column;
        gap: clamp(1rem, 2vw, 1.5rem);
    }

    .matrix > tbody > tr {
        display: grid;
        grid-template-columns: 1fr;
        gap: clamp(0.5rem, 1vw, 0.75rem);
        background-color: var(--surface);
        border: 2px solid var(--border);
        border-radius: 8px;
        padding: clamp(1rem, 2vw, 1.5rem);
        transform: none !important;
    }

    .matrix > tbody > tr:nth-child(even) {
        background-color: var(--surface);
    }

    

    .matrix > tbody > tr > td {
        padding: clamp(0.5rem, 1vw, 0.75rem) 0;
        border: none;
        display: grid;
        grid-template-columns: 120px 1fr;
        gap: clamp(0.75rem, 1.5vw, 1rem);
        text-align: left;
        align-items: center;
    }

    .matrix > tbody > tr > td:first-child {
        grid-column: 1 / -1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: clamp(0.75rem, 1.5vw, 1rem);
        border-bottom: 2px solid var(--border);
        margin-bottom: clamp(0.5rem, 1vw, 0.75rem);
    }

    .matrix > tbody > tr > td:first-child .info-btn {
        min-width: 40px;
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .matrix > tbody > tr > td:not(:first-child)::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--accent-text);
        grid-column: 1 / 2;
        text-align: left;
    }

    /* Hide data-label for cells without it */
    .matrix > tbody > tr > .threat-name {
        grid-column: 1 / -1;
    }

    .matrix > tbody > tr > td > .matrix-icon {
        grid-column: 2 / 3;
        justify-self: start;
        width: clamp(24px, 4vw, 28px);
        height: clamp(24px, 4vw, 28px);
    }

    .matrix-legend {
        gap: clamp(0.75rem, 2vw, 1rem);
        padding: 0 clamp(0.75rem, 2vw, 1rem);
    }

    .legend-item {
        gap: clamp(0.375rem, 1vw, 0.5rem);
        font-size: clamp(0.75rem, 1.2vw, 0.85rem);
    }

    /* Device list - More compact */
    .device-list {
        padding: clamp(0.75rem, 1.5vw, 1rem);
    }

    .device-item {
        flex-direction: column;
        gap: clamp(0.5rem, 1vw, 0.75rem);
        padding: clamp(0.75rem, 1.5vw, 1rem);
    }

    section {
        padding: clamp(1rem, 3vw, 1.5rem) clamp(0.75rem, 2vw, 1rem);
    }

    #threat-modal .modal-content {
        /* The variable, not the padding: the sticky header derives its
           full-bleed negative margin from this, so overriding the padding
           directly would leave a gutter beside the header bar. */
        --threat-modal-pad: clamp(1.5rem, 3vw, 2rem);
        max-width: 95%;
    }

    #threat-modal {
        padding: 2rem 1rem;
    }

    /* `top`/`right` were dropped here: .modal-close is never positioned, so
       they had no effect. Its appearance comes from .threat-modal-close-btn,
       which main.js adds at render time. */
    #threat-modal .threat-modal-close-btn {
        font-size: clamp(1.15rem, 3vw, 1.35rem);
    }

    /* #threat-modal, not #modal-body: the header is a sibling of the
       scrollport. See the note in security-matrix.css. */
    #threat-modal .threat-modal-title {
        font-size: clamp(1rem, 2.6vw, 1.15rem);
    }

    pre {
        font-size: clamp(0.7rem, 1.2vw, 0.85rem);
        padding: clamp(0.75rem, 1.5vw, 1rem);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* footer p's phone size lives in footer.css (2026-10-31): only index.html
       loads this file, so every footer page kept 16px and split its first
       line after "Passkey Accounts™ ·". */
}

/* A phone on its side (568-932 wide, 320-430 tall): height is the scarce axis,
   and the spacing above is sized for width. At 568x320 the threat modal left
   149px of a 320px screen for reading, about five lines. After the width rules,
   so it wins at 568 too. */
@media (max-height: 30rem) {
    #threat-modal {
        padding: 0.75rem 1rem;
    }

    #threat-modal .modal-content {
        --threat-modal-pad: 1.25rem;
        max-height: calc(100vh - 1.5rem);
        max-height: calc(100dvh - 1.5rem);
    }
}

@media (min-width: 900px) {
    .navbar .container {
        gap: clamp(0.75rem, 2vw, 1.5rem);
    }
}

@media (max-width: 900px) {
    .navbar .container {
        /* `block`, not `unset`. `unset` on a non-inherited property is `initial`,
           and the initial value of `display` is `inline` — so this turned the
           container into an inline box: its padding stopped reserving space and
           every flex-item rule above (:22-34) went dead. `block` reproduces the
           same stacked, centred layout that ships today at every width <= 900
           while the container's padding works again. */
        display: block;
     }
}

/* Tablet (768px and up) */
@media (min-width: 768px) {
    .navbar-code {
        white-space: wrap;
    }

    /* Table still uses card layout on tablet */
    .matrix-wrapper {
        overflow-x: visible;
    }

    .matrix > thead {
        display: none;
    }

    .matrix > tbody {
        display: flex;
        flex-direction: column;
        gap: clamp(1rem, 2vw, 1.5rem);
    }

    .matrix > tbody > tr {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 1fr;
        gap: clamp(0.75rem, 1.5vw, 1rem);
        background-color: var(--surface);
        border: 2px solid var(--border);
        border-radius: 8px;
        padding: clamp(1rem, 2vw, 1.5rem);
    }

    .matrix > tbody > tr > td {
        padding: clamp(0.75rem, 1.5vw, 1rem);
        border: none;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: clamp(0.5rem, 1vw, 0.75rem);
        position: relative;
    }

    .matrix > tbody > tr > td:not(:first-child)::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--accent-text);
        font-size: clamp(0.75rem, 1.2vw, 0.85rem);
        order: -1;
    }

    .matrix > tbody > tr > td:first-child {
        grid-column: 1 / -1;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding-bottom: clamp(0.75rem, 1.5vw, 1rem);
        border-bottom: 2px solid var(--border);
        margin-bottom: clamp(0.5rem, 1vw, 0.75rem);
    }

    .matrix > tbody > tr > .threat-name {
        grid-column: 1 / -1;
    }

    .matrix > tbody > tr > td > .matrix-icon {
        width: clamp(24px, 4vw, 32px);
        height: clamp(24px, 4vw, 32px);
    }
}

/* Desktop (1024px and up) */
@media (min-width: 1024px) {
    /* Security Matrix - Back to table view */
    .matrix-wrapper {
        overflow-x: auto;
    }

    .matrix > thead {
        display: table-header-group;
        background-color: var(--accent);
        color: var(--text-on-accent);
    }

    .matrix > thead > tr > th {
        padding: clamp(1rem, 1.5vw, 1.5rem);
        text-align: center;
        font-weight: 600;
        border: 1px solid var(--accent);
        font-size: clamp(0.85rem, 1.2vw, 0.95rem);
    }

    .matrix > tbody {
        display: table-row-group;
        gap: 0;
    }

    .matrix > tbody > tr {
        display: table-row;
        background-color: var(--surface);
        border: none;
        padding: 0;
        gap: 0;
        /* border-bottom: 1px solid var(--border); */
    }

    .matrix > tbody > tr:nth-child(even) {
        background-color: var(--surface-2);
    }

    .matrix > tbody > tr > td {
        padding: clamp(1rem, 1.5vw, 1.5rem);
        border: 1px solid var(--border);
        display: table-cell;
        flex-direction: row;
        text-align: center;
    }

    /* The real header row is back at this width, so the per-cell data-label
       echoes from the card layout would print every column heading twice. */
    .matrix > tbody > tr > td:not(:first-child)::before {
        content: none;
    }

    .matrix > tbody > tr > td:first-child {
        grid-column: unset;
        display: table-cell;
        border: 1px solid var(--border);
        text-align: left;
        padding-bottom: clamp(1rem, 1.5vw, 1.5rem);
        border-bottom: 1px solid var(--border);
        margin-bottom: 0;
    }

    .matrix > tbody > tr > .threat-name {
        grid-column: unset;
    }

    .matrix > tbody > tr > td > .matrix-icon {
        width: clamp(28px, 2vw, 32px);
        height: clamp(28px, 2vw, 32px);
    }

    .navbar .container {
        flex-wrap: nowrap;
    }

    /* Was `white-space: nowrap`, which forced the header tagline and the footer
       credit onto one line at every wide width. At the default text size they
       fit, so nowrap changed nothing; with the browser's text size raised to
       200% (not page zoom, so no breakpoint moves) the credit line measured
       1,700px in a 1,280px window and every page with a footer scrolled
       sideways. Normal wrapping only does anything when the line does not fit. */
    .navbar-code {
        white-space: normal;
    }

    section {
        padding: clamp(2rem, 5vw, 3rem) clamp(1rem, 4vw, 2rem);
    }
}

/* Extra large screens (1200px and up) */
@media (min-width: 1200px) {
    .navbar .container {
        justify-content: space-between;
    }

    .container {
        padding: 0 var(--spacing-lg);
    }

    section {
        padding: var(--spacing-xl) var(--spacing-lg);
    }

    .matrix > thead > tr > th,
    .matrix > tbody > tr > td {
        padding: var(--spacing-md);
    }
}

/* ==================== MATRIX DROPDOWN ROW ====================
 * The knowledge-capital dropdown row lives inside .matrix, so it would
 * otherwise be turned into a bordered card like every other hero row at the
 * two narrow breakpoints. These blocks sit last in the file so they win the
 * specificity ties against the card-transform and zebra rules above.
 */
@media (max-width: 767px) {
    .matrix > tbody > tr.matrix-dropdown-row {
        display: block;
        grid-template-columns: none;
        background-color: transparent;
        border: 0;
        border-radius: 0;
        padding: 0;
        gap: 0;
    }

    .matrix > tbody > tr.matrix-dropdown-row > td {
        display: block;
        grid-column: auto;
        border: 0;
        margin-bottom: 0;
        padding: 0;
    }
}

@media (min-width: 768px) {
    .matrix > tbody > tr.matrix-dropdown-row {
        display: block;
        grid-template-columns: none;
        background-color: transparent;
        border: 0;
        border-radius: 0;
        padding: 0;
        gap: 0;
    }

    .matrix > tbody > tr.matrix-dropdown-row > td {
        display: block;
        grid-column: auto;
        border: 0;
        margin-bottom: 0;
        padding: 0;
    }
}

@media (min-width: 1024px) {
    .matrix > tbody > tr.matrix-dropdown-row {
        display: table-row;
    }

    .matrix > tbody > tr.matrix-dropdown-row > td {
        display: table-cell;
        border: 0;
        padding: 0 0 0.5rem;
    }
}

/* Last word on collapsed state. The author display rules above beat the UA
   [hidden] rule, so hiding has to be said explicitly and unconditionally. */
.matrix > tbody > tr.matrix-dropdown-row[hidden] {
    display: none !important;
}

/* ==================== KNOWLEDGE-CAPITAL ROW, FEATURED ====================
 * The gold wash itself is in security-matrix.css, along with the three
 * intensity tiers (--kc-edge / --kc-edge-soft / --kc-glow) this block spends.
 *
 * The edge is a BOTTOM edge, lit at the two outer corners and fading out well
 * before the middle -- so the row is underlined by its own corners rather than
 * flagged by a bar down one side. It has to be said twice, because the row is
 * a real box below 1024px and a table-row above it, and the two cannot carry
 * the same painting: in card mode the row itself is the box, in table mode the
 * outer CELLS each own one corner and the merged middle cell owns nothing.
 *
 * Gradients, not box-shadow: a shadow would have to be clipped (the wrapper
 * scrolls, .security-matrix clips at the table edge) and cannot fade along the
 * edge it draws. Each corner is a crisp 2px line plus a soft radial halo
 * anchored to that corner.
 */

/* The wash has to read as ONE band across the row, not three tinted cells, so
 * the internal rules go; only the top edge survives, as the seam against the
 * row above. It has to be said HERE rather than beside the wash: the card
 * rules above give `td:first-child` its own border at the same specificity,
 * and source order is what settles that tie.
 */
.matrix > tbody > tr[data-matrix-dropdown] > td {
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
}

/* Card mode: the row IS the card (a grid), so both corners ride on it. The
 * split is 767/768, not 1024: from 768 up the cells are table-cells again and
 * the per-cell painting below is the one that lands. */
@media (max-width: 767px) {
    .matrix > tbody > tr[data-matrix-dropdown] {
        border-color: color-mix(in srgb, var(--featured) 40%, transparent);
        background-image:
            radial-gradient(120% 100% at 0% 100%, var(--kc-glow) 0%, transparent 72%),
            radial-gradient(120% 100% at 100% 100%, var(--kc-glow) 0%, transparent 72%),
            linear-gradient(to right, var(--kc-edge) 0%, var(--kc-edge-soft) 46%, transparent 76%),
            linear-gradient(to left, var(--kc-edge) 0%, var(--kc-edge-soft) 46%, transparent 76%);
        background-repeat: no-repeat;
        background-position: left bottom, right bottom, left bottom, right bottom;
        background-size: 55% 14px, 55% 14px, 50% 2px, 50% 2px;
    }
}

/* Table mode: the first cell carries the left corner, the verdict cell the
 * right one, and the merged range cell between them stays clean -- which is
 * what puts the fade-out well short of centre without measuring anything. */
@media (min-width: 768px) {
    .matrix > tbody > tr[data-matrix-dropdown] > td:first-child,
    .matrix > tbody > tr[data-matrix-dropdown] > td:last-child {
        background-repeat: no-repeat;
        background-size: 100% 14px, 100% 2px;
    }

    .matrix > tbody > tr[data-matrix-dropdown] > td:first-child {
        background-image:
            radial-gradient(120% 100% at 0% 100%, var(--kc-glow) 0%, transparent 72%),
            linear-gradient(to right, var(--kc-edge) 0%, var(--kc-edge-soft) 55%, transparent 88%);
        background-position: left bottom, left bottom;
    }

    .matrix > tbody > tr[data-matrix-dropdown] > td:last-child {
        background-image:
            radial-gradient(120% 100% at 100% 100%, var(--kc-glow) 0%, transparent 72%),
            linear-gradient(to left, var(--kc-edge) 0%, var(--kc-edge-soft) 55%, transparent 88%);
        background-position: right bottom, right bottom;
    }
}

/* ==================== THE OPENED INDEX, ENCLOSED ====================
 * When the dropdown is open the featured row is no longer the bottom of
 * anything, so the same gold carries on down the two sides of the sub-matrix
 * and closes under it -- the panel reads as the row's own body rather than as
 * loose content parked beneath the table. Painted on the cell, which is a real
 * box in every mode, so this needs saying only once. The row is hidden when
 * collapsed, so no open/closed guard is needed here.
 */
.matrix > tbody > tr.matrix-dropdown-row > td {
    background-image:
        radial-gradient(120% 60% at 0% 100%, var(--kc-glow) 0%, transparent 72%),
        radial-gradient(120% 60% at 100% 100%, var(--kc-glow) 0%, transparent 72%),
        linear-gradient(to right, var(--kc-edge) 0%, var(--kc-edge-soft) 46%, transparent 76%),
        linear-gradient(to left, var(--kc-edge) 0%, var(--kc-edge-soft) 46%, transparent 76%),
        linear-gradient(to bottom, var(--kc-edge) 0%, var(--kc-edge-soft) 45%, var(--kc-edge) 100%),
        linear-gradient(to bottom, var(--kc-edge) 0%, var(--kc-edge-soft) 45%, var(--kc-edge) 100%),
        /* THE DRIP. The three layers above close the panel on its sides and
           its foot; its TOP was bare, and that is the one edge that meets the
           featured row. The cell's own padding plus each block's 12px radius
           left a pale notch in both top corners, right under the row's gold
           line -- the panel looked parked beneath the row rather than poured
           out of it. Two corner halos and a full-width fade carry the row's
           colour down over that band, and the blocks (opaque --surface) mask
           everything below it, so only the gap it exists to fill is ever seen.
           LAST in the list, so it paints UNDER the crisp 2px sides above: the
           enclosure keeps its hard edges and the drip fills behind them. */
        radial-gradient(120% 70% at 0% 0%, var(--kc-glow) 0%, transparent 72%),
        radial-gradient(120% 70% at 100% 0%, var(--kc-glow) 0%, transparent 72%),
        linear-gradient(to bottom, var(--kc-edge) 0%, var(--kc-edge-soft) 40%, transparent 100%);
    background-repeat: no-repeat;
    background-position:
        left bottom, right bottom,
        left bottom, right bottom,
        left top, right top,
        left top, right top, left top;
    background-size:
        55% 16px, 55% 16px,
        50% 2px, 50% 2px,
        2px 100%, 2px 100%,
        55% 22px, 55% 22px, 100% 26px;
}

/* ==================== KNOWLEDGE-CAPITAL RANGE CELL ====================
 * `.threat-kc-range` is the one cell in this table holding a SENTENCE rather
 * than a single glyph, and the card transforms above turn every cell into a
 * grid (narrow) or a column flex (tablet) container. Both wrap each contiguous
 * run of text in its own anonymous item, so "from a", the DB-leak link and
 * "to what AI knows zero about.." were laid out as three separate items: the
 * data-label echo took column one, the link fell into column one of the next
 * row, and the sentence read as a 2x2 table of fragments.
 *
 * Below the desktop breakpoint the cell opts out. `display: block` puts the
 * prose back into ordinary inline flow so it is one paragraph again, and the
 * label is dropped -- the merged Token/Cookie/Passkey heading says nothing the
 * sentence does not, and it is what pulled the link into a column of its own.
 *
 * Last in the file, like the dropdown block above and for the same reason:
 * source order is what breaks the specificity ties against the generic cell
 * rules earlier in each media query.
 */
@media (max-width: 767px) {
    .matrix > tbody > tr > td.threat-kc-range {
        display: block;
        padding: clamp(0.35rem, 1vw, 0.6rem) 0;
        text-align: center;
        text-wrap: pretty;
    }

    .matrix > tbody > tr > td.threat-kc-range::before {
        content: none;
    }
}

/* The row is a four-column card here, and `colspan` is inert once it stops
   being a table row -- so the merged cell has to say in CSS what the markup
   says in HTML, or the sentence is squeezed into a quarter track while columns
   three and four sit empty. Deliberately NOT `span 3` at the narrow width
   above, where the row has one column and the span would fabricate two
   implicit ones. */
@media (min-width: 768px) and (max-width: 1023px) {
    .matrix > tbody > tr > td.threat-kc-range {
        display: block;
        grid-column: span 3;
        text-align: center;
        text-wrap: pretty;
    }

    .matrix > tbody > tr > td.threat-kc-range::before {
        content: none;
    }
}
