/* ==========================================================================
   safety.css — page-specific styles for /safety/ and /safety/{slug}/
   All values from tokens.css custom properties.
   Load order: tokens.css, fonts.css, base.css, blocks.css, safety.css
   ========================================================================== */


/* --------------------------------------------------------------------------
   Emergency band layout
   The .col inside band--emergency is already flex (base.css section 12).
   .safety-emg-text grows to fill the middle slot between the octagon mark
   and the call button; wraps below the mark on narrow viewports.
   -------------------------------------------------------------------------- */
.safety-emg-text {
    flex: 1 1 auto;
    min-width: min(20rem, 100%);
}

/* The danger strip above the title on non-emergency safety pages:
   squeeze the paragraph margin so the compact band--danger padding (space-3)
   is not swallowed by the default bottom-margin on <p>. */
.safety-strip-p {
    margin: 0;
}


/* --------------------------------------------------------------------------
   Safety index: topic list items inside the grid
   -------------------------------------------------------------------------- */
.safety-topic {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4) 0;
    border-top: var(--border-hairline) solid var(--c-line);
    text-decoration: none;
    color: var(--_ink);
    transition: color var(--motion-fast) var(--motion-ease);
}

/* First item in each grid cell column loses the top rule */
.grid > li:nth-child(-n+2) .safety-topic,
.grid--3 > li:nth-child(-n+3) .safety-topic {
    border-top: 0;
}

.safety-topic__icon {
    flex: none;
    width: 2.5rem;
    height: 2.5rem;
    display: grid;
    place-items: center;
    background: var(--c-surface-sunk);
    border-radius: var(--radius-md);
    font-size: 1.2rem;
    color: var(--_heading);
    transition: background var(--motion-fast) var(--motion-ease);
}

/* Contrast (ink) cluster: rules and icon tiles take the band ink instead of light surfaces. */
.band--ink .safety-topic { border-top-color: color-mix(in srgb, var(--_ink) 18%, transparent); }
.band--ink .safety-topic__icon { background: color-mix(in srgb, var(--_ink) 10%, transparent); color: var(--_label); }

.safety-topic__body {
    min-width: 0;
}

.safety-topic__name {
    display: block;
    font-family: var(--role-title-family);
    font-weight: var(--role-title-weight);
    font-size: var(--fs-title);
    line-height: var(--lh-tight);
    color: var(--_heading);
    margin: 0 0 var(--space-1);
}

a.safety-topic:hover .safety-topic__name {
    text-decoration: underline;
    text-underline-offset: 0.18em;
}

.safety-topic__tagline {
    display: block;
    font-size: var(--fs-small);
    line-height: var(--lh-title);
    color: var(--_muted);
    margin: 0;
}


/* --------------------------------------------------------------------------
   Safety index: cluster heading row
   -------------------------------------------------------------------------- */
.safety-cluster__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.safety-cluster__count {
    font-size: var(--fs-caption);
    color: var(--_muted);
    white-space: nowrap;
}

/* .grid already drops list style and padding; the list margin goes here, not inline. */
.safety-cluster-grid { margin: 0; }


/* --------------------------------------------------------------------------
   Safety index: cluster description
   -------------------------------------------------------------------------- */
.safety-cluster__desc {
    margin: 0 0 var(--space-5);
    font-size: var(--fs-small);
    color: var(--_muted);
    line-height: var(--lh-title);
}


/* --------------------------------------------------------------------------
   Related reading list on detail pages
   -------------------------------------------------------------------------- */
.safety-related-list {
    list-style: none;
    padding: 0;
    margin: var(--space-4) 0 0;
}

.safety-related-list li {
    padding: var(--space-2) 0;
}


/* --------------------------------------------------------------------------
   Phone adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
    /* On narrow screens the grid collapses to 1 col, so every item is first */
    .grid > li:nth-child(-n+2) .safety-topic,
    .grid--3 > li:nth-child(-n+3) .safety-topic {
        border-top: var(--border-hairline) solid var(--c-line);
    }
    .band--ink .grid > li:nth-child(-n+2) .safety-topic,
    .band--ink .grid--3 > li:nth-child(-n+3) .safety-topic {
        border-top-color: color-mix(in srgb, var(--_ink) 18%, transparent);
    }
    .grid > li:first-child .safety-topic {
        border-top: 0;
    }

    /* Safety cluster grids: force 1-col on phone so odd-count clusters
       (e.g. 5 items in grid--3 → 2-col → last-row orphan) never leave orphans.
       Safety topics read well as a single-column list on narrow screens. */
    .safety-cluster-grid {
        --_cols: 1;
    }
}
