/* ─────────────────────────────────────────────────────────────────────────
   Design code coverage (template-parts/sections/code-coverage.php) —
   page-specific layout only. Boxes are the shared .surface, labels the
   shared .eyebrow / .badge, controls the shared .form-field / .form-input /
   .form-select.

   Code explorer, laid out like the wiki manuals: a sticky box on the left
   with the search and every code (grouped by area, red top rule like the
   wiki sidebar box), the selected code's sheet on the right. Below 1024px
   the two stack and the list becomes a select (set up by the script).
   ───────────────────────────────────────────────────────────────────────── */

/* The script hides sheets, codes and groups with [hidden]; the flex/grid
   layouts below would otherwise override it. */
.dcs-coverage [hidden] {
    display: none;
}

.dcs-explorer {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 3fr);
    gap: var(--space-xl);
    align-items: start;
}

/* ── Left: search + code list ── */
.dcs-explorer__nav {
    position: sticky;
    top: calc(var(--header-height) + var(--space-md));
    max-height: calc(100vh - var(--header-height) - var(--space-xl));
    overflow-y: auto;
    border-top: 2px solid var(--red);
}

.dcs-coverage .eyebrow {
    margin-bottom: 0;
}

.dcs-nav__group {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.dcs-nav__list {
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    list-style: none;
}

/* A rail on the left of the list; the selected code takes it in red. */
.dcs-nav__item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    border-left: 2px solid var(--gray-200);
    font-family: var(--font-display);
    font-weight: 600;
    color: var(--black);
    text-decoration: none;
    transition: color 0.2s, border-color 0.2s;
}

.dcs-nav__item:hover {
    color: var(--red);
}

.dcs-nav__item[aria-current="true"] {
    border-left-color: var(--red);
    color: var(--red);
    font-weight: 700;
}

.dcs-nav__count {
    flex-shrink: 0;
    font-family: var(--font-body);
    font-weight: 400;
    font-size: var(--fs-caption);
    color: var(--color-black);
}

/* ── Right: one sheet per code ── */
.dcs-explorer__detail {
    gap: var(--space-xl);
}

.dcs-code {
    gap: var(--space-xl);
    padding: var(--space-2xl);
    border-top: 2px solid var(--red);
    scroll-margin-top: calc(var(--header-height) + var(--space-md));
}

/* Each component that uses the code, under a rule. */
.dcs-use {
    padding-top: var(--space-xl);
    border-top: 1px solid var(--gray-200);
}

.dcs-use__head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-md);
}

.dcs-use__head h4 {
    font-size: var(--fs-subheading);
}

.dcs-label {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--fs-body);
    color: var(--black);
}

/* Design checks: name and clause count on a ruled line, in columns. */
.dcs-checks {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    column-gap: var(--space-xl);
    margin: 0;
    padding: 0;
    list-style: none;
}

.dcs-checks li {
    display: flex;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--gray-200);
}

.dcs-checks__count {
    flex-shrink: 0;
    font-family: var(--font-display);
    font-weight: 600;
}

/* Clause details: the site's table look (dark head, red rule), always open. */
.dcs-clauses {
    overflow-x: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
}

.dcs-clauses table {
    width: 100%;
    border-collapse: collapse;
}

.dcs-clauses th {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 2px solid var(--red);
    background-color: var(--dark);
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--white);
    text-align: left;
}

.dcs-clauses td {
    padding: var(--space-sm) var(--space-md);
    border-bottom: 1px solid var(--gray-200);
    color: var(--color-black);
    vertical-align: top;
}

.dcs-clauses tr:last-child td {
    border-bottom: 0;
}

/* Clause numbers keep to one line; the description takes the rest. */
.dcs-clauses td:first-child {
    width: 1%;
    font-family: var(--font-display);
    font-weight: 600;
    white-space: nowrap;
}

/* ── Other published fields: "Label value" pairs that wrap along a line ── */
.dcs-fields {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs) var(--space-lg);
}

.dcs-fields > div {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.dcs-fields dt {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--black);
}

.dcs-fields dd {
    margin: 0;
    color: var(--color-black);
    overflow-wrap: anywhere;  /* source paths have no spaces to break at */
}

@media (min-width: 1025px) {
    .dcs-coverage .dcs-explorer__picker {
        display: none;
    }
}

@media (max-width: 1240px) {
    .dcs-checks {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1024px) {
    .dcs-explorer {
        grid-template-columns: minmax(0, 1fr);
    }

    .dcs-explorer__nav {
        position: static;
        max-height: none;
        overflow: visible;
    }

    /* With the script, the select replaces the list. */
    .dcs-coverage.is-ready .dcs-nav {
        display: none;
    }
}

@media (max-width: 640px) {
    .dcs-code {
        padding: var(--space-lg);
    }

    .dcs-checks {
        grid-template-columns: minmax(0, 1fr);
    }

    .dcs-use__head {
        flex-direction: column;
    }
}
