/* The per-threat pages (/threats/, generated by scripts/build-threat-pages.mjs).
   One sheet for 47 pages instead of the same <style> block in each. The class
   names and rules are terms.html's and privacy.html's, so the three read as one
   document set. Tokens only: theme-color-literals.spec.mjs scans this file.
   Groups are divs, not sections: sections.css hides every `section h2`. */

.privacy-main {
    padding: clamp(2rem, 7vw, 4.5rem) clamp(1rem, 4vw, 2rem);
}

/* An in-page jump (the summary cards, the category row, #related) lands the
   heading with room above it instead of flush against the window's edge. */
.privacy-card [id] {
    scroll-margin-top: 1.25rem;
}

.privacy-card {
    max-width: 46rem;
    margin: 0 auto;
    font-size: 1.0625rem;
    line-height: 1.65;
}

.privacy-card h1 {
    margin-top: 1.25rem;
    font-size: clamp(2rem, 6vw, 2.75rem);
    line-height: 1.15;
    color: var(--text-strong);
    text-wrap: balance;
    /* Only bites when one word is wider than the column: at 200% text on a
       phone (Android text scaling) "Misconfiguration" is, at the 2rem floor. */
    overflow-wrap: break-word;
}

.privacy-card h1 small {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.45em;
    font-weight: 500;
    color: var(--text-muted);
}

.privacy-card h2 {
    margin-top: 2.75rem;
    font-size: 1.4rem;
    line-height: 1.25;
    color: var(--text-strong);
    text-wrap: balance;
}

.privacy-card h3,
.privacy-card h4 {
    margin-top: 2rem;
    line-height: 1.3;
    color: var(--text-strong);
}

/* :where() keeps this at a class's weight, so the classes below that set their
   own margin-top (updated, lede, aside, keep, the demo link) win. As
   `.privacy-card p` it out-ranked every one of them: all read 0.75rem. */
.privacy-card :where(p, ul, ol) {
    margin-top: 0.75rem;
}

.privacy-updated {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.privacy-lede {
    margin-top: 1.5rem;
    font-size: clamp(1.2rem, 3.6vw, 1.5rem);
    line-height: 1.45;
    color: var(--text-strong);
    /* No last line holding one word, and no split of the bold phrase if it can
       be helped: this is the line a visitor reads first. */
    text-wrap: pretty;
}

.privacy-aside {
    margin-top: 1rem;
    padding-left: 0.9rem;
    border-left: 2px solid var(--border);
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.privacy-list {
    padding-left: 1.25rem;
}

.privacy-list li + li {
    margin-top: 0.6rem;
}

/* The essay's own lists (knowledge-capital) are bare <ul>s, and base.css's
   `* { padding: 0 }` reset left their bullets hanging outside the text column,
   on a phone at the screen's edge. The same indent and rhythm as .privacy-list. */
.threat-essay :where(ul, ol) {
    padding-left: 1.25rem;
}

.threat-essay li + li {
    margin-top: 0.6rem;
}

/* One step of the demo: who acted, and what happened. The marker carries the
   step's kind (an attacker's move, a failure, a success) by colour and by the
   bar's weight, so it is not colour alone. */
.threat-step {
    padding-left: 0.6rem;
    border-left: 3px solid var(--border);
}

.threat-step[data-type="hacker"],
.threat-step[data-type="error"] {
    border-left: 5px solid var(--danger);
}

.threat-step[data-type="warning"] {
    border-left: 4px solid var(--warning);
}

.threat-step[data-type="success"] {
    border-left: 4px solid var(--success);
}

/* The fifth kind matrix-data.json steps actually use (threat-demo.js's own
   default, step.type || 'system') -- PA's defensive "nothing happens" rows.
   Its sibling stylesheet for the same step data in the live modal
   (security-matrix.css's .log-system) already gives it this accent/muted
   treatment; this file had rules for the other four kinds but never this
   one, so these rows fell through to the plain base border on every
   generated /threats/ page. */
.threat-step[data-type="system"] {
    border-left: 4px solid var(--accent);
    color: var(--text-muted);
}

.threat-step strong {
    color: var(--text-strong);
}

.privacy-keep {
    list-style: none;
    padding: 0;
    margin-top: 1rem;
    border-top: 1px solid var(--border);
}

.privacy-keep li {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--border);
}

.privacy-keep a {
    color: inherit;
    text-decoration: none;
}

.privacy-keep a:hover strong,
.privacy-keep a:focus-visible strong {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.privacy-keep a:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

.privacy-keep strong {
    color: var(--text-strong);
}

.privacy-keep li > small {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.threat-demo-link {
    margin-top: 2.5rem;
    font-weight: 600;
}

/* The demo link, the pager and the essay's links are bare <a> (the generator
   gives them no class), so they fell through to the browser's own link colour:
   default blue on a light theme, lavender on a dark one, the one thing on these
   47 pages that ignored the theme. The same ink as every other link here; the
   focus ring is base.css's. */
.threat-demo-link a,
.threat-pager a,
.threat-essay a,
.threat-related a {
    color: var(--accent-text);
}

.threat-demo-link a:hover,
.threat-pager a:hover,
.threat-essay a:hover,
.threat-related a:hover {
    color: var(--accent-strong);
}

/* /threats/: the knowledge-capital overview, featured above the list it sums
   up. Quiet on purpose: an accent hairline and the faintest tint, no badge. */
.threat-featured {
    display: block;
    margin-top: 1.5rem;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--accent-soft);
    border-left: 3px solid var(--accent-text);
    border-radius: 10px;
    background: color-mix(in srgb, var(--accent-soft) 35%, transparent);
    color: inherit;
    text-decoration: none;
}

.threat-featured-kicker {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-text);
}

.threat-featured strong {
    display: block;
    margin-top: 0.15rem;
    color: var(--text-strong);
}

.threat-featured small {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.threat-featured:hover strong,
.threat-featured:focus-visible strong {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.threat-featured:focus-visible {
    outline: 2px solid var(--accent-text);
    outline-offset: 2px;
}

/* /threats/: the five categories under the title, each a jump to its group. The
   page runs about 5,000px with 46 entries; this is the way to the third group. */
.threat-jump {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin: 1.25rem 0 0;
}

.threat-jump a {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
    padding: 0.4rem 0.85rem;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--accent-text);
    font-weight: 600;
    font-size: 0.95rem;
    text-decoration: none;
}

.threat-jump a:hover {
    border-color: var(--accent-strong);
    color: var(--accent-strong);
}

.threat-jump small {
    color: var(--text-faint);
    font-weight: 400;
}

/* "Also in <category>": the rest of this threat's group, so a reader who came
   from a search for one attack has the next related one a click away. Plain
   links in columns; the tier is the catalog's own word. */
.threat-related {
    margin-top: 2.5rem;
}

.threat-related ul {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 17rem), 1fr));
    gap: 0 1.5rem;
}

/* The row's rhythm sits on the li, and the link is plain inline: an
   inline-block link always offers a break after itself, so a long title pushed
   its tier (the &nbsp;-joined <small>) onto a line of its own on a phone.
   Inline, the tier stays with the title's last word. The padding still widens
   the link's hit area; on an inline box it does not move the layout. */
.threat-related li {
    padding: 0.35rem 0;
}

.threat-related a {
    padding: 0.35rem 0;
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.threat-related small {
    color: var(--text-faint);
    white-space: nowrap;
}

.privacy-credit {
    margin-top: 2.75rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    color: var(--text-muted);
}

.privacy-credit p {
    margin-top: 0;
}

/* Links in running text are told apart by more than their colour (WCAG 1.4.1),
   as on terms.html. The back link and the list rows stand alone. */
.privacy-card p a:not(.docs-link),
.privacy-card .privacy-list a,
.threat-essay a {
    text-decoration: underline;
    text-underline-offset: 0.18em;
    overflow-wrap: anywhere;
}

.privacy-card code {
    font-family: var(--font-mono);
    font-size: 0.9em;
    padding: 0.1em 0.35em;
    border-radius: 0.3rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-strong);
    overflow-wrap: anywhere;
}

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

/* Printed, paper colours whatever theme is saved (terms.html has the reasons).
   System colour keywords, not literals. */
@media print {
    html {
        color-scheme: light !important;
    }

    /* Sixteen links at most, and a link is no use on paper. */
    .threat-related,
    .threat-jump {
        display: none;
    }

    body,
    .privacy-main {
        background: Canvas !important;
    }

    .privacy-card,
    .privacy-card * {
        color: CanvasText !important;
        background: transparent !important;
        border-color: GrayText !important;
        box-shadow: none !important;
    }

    .privacy-card a {
        text-decoration: underline;
    }
}

/* Previous / next threat, in matrix order. */
.threat-pager {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    margin-top: 1.5rem;
    font-size: 0.95rem;
}

.threat-pager a {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

/* Large text on a phone (Android text scaling: 375px at 32px text is 11.7em):
   the two titles' longest words side by side outgrew the row, so they stack.
   An em query scales with the reader's text size, so at default text it only
   matches below 256px and nothing moves anywhere else. */
@media (max-width: 16em) {
    .threat-pager {
        flex-wrap: wrap;
    }
}

.threat-pager a[rel="next"] {
    margin-left: auto;
    text-align: right;
}

/* The scenario sentence, read on its own page. The catalog marks its second
   half as <small> -- secondary detail in the homepage matrix pop-up -- but here
   it is one sentence, and a size change mid-clause read as a typesetting slip
   (22 pages; it also wrapped onto its own line on phones). Same size as the
   sentence it finishes. The steps' bracketed asides keep their smaller type:
   those are parentheticals, which is what small type is for. */
#scenario p small {
    font-size: inherit;
}
