/*
 * =========================================================
 * CODBIO HUB HOME — POLICY & GOVERNANCE
 * Updated 2026-08-16
 *
 * Purpose:
 * Home-native presentation for the catalogue-driven policy
 * and governance subsystem.
 *
 * Design:
 * Editorial CodBio Hub identity using restrained navy/green,
 * serif display typography, thin rules, generous whitespace,
 * compact metadata, searchable policy controls, sticky TOC,
 * disclosures, deep-link actions and responsive navigation.
 *
 * Architecture:
 * Presentation only. Policy catalogue, Markdown loading,
 * filtering, routing and pagination are handled separately.
 * =========================================================
 */


/* =========================================================
   PAGE
========================================================= */

.policy-page {
    padding-block: clamp(48px, 7vw, 96px);
    color: var(--ink);
}


/* =========================================================
   HERO
========================================================= */

.policy-hero {
    padding: clamp(22px, 4vw, 46px) 0 clamp(34px, 5vw, 58px);
    border: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.policy-hero h1 {
    max-width: 780px;
    margin: 0.18em 0;
    font-size: clamp(3rem, 6.5vw, 5.4rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.policy-hero > p:last-of-type {
    max-width: 680px;
    color: var(--muted);
    font-size: clamp(1rem, 1.5vw, 1.2rem);
    line-height: 1.7;
}


/* =========================================================
   COLLECTION METADATA
========================================================= */

.policy-metadata {
    display: flex;
    flex-wrap: wrap;
    gap: 0;
    margin: 30px 0 0;
}

.policy-metadata div {
    min-width: auto;
    padding: 0 20px;
    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;
    background: transparent;
}

.policy-metadata div:first-child {
    padding-left: 0;
    border-left: 0;
}

.policy-metadata dt {
    color: var(--muted);
    font-size: 0.61rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.policy-metadata dd {
    margin: 5px 0 0;
    font-size: 0.88rem;
    font-weight: 750;
}


/* =========================================================
   SEARCH & FILTER TOOLS
========================================================= */

.policy-tools {
    display: grid;
    grid-template-columns:
        minmax(240px, 1.5fr)
        repeat(2, minmax(170px, 0.7fr));
    gap: 16px;

    margin: 32px 0 38px;
    padding: 20px 0 22px;

    border: 0;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    border-radius: 0;

    background: transparent;
    box-shadow: none;
}

.policy-tools label {
    display: block;
    margin-bottom: 7px;

    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
}

.policy-tools input,
.policy-tools select {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;

    border: 1px solid var(--line);
    border-radius: 4px;

    background: rgba(255, 255, 255, 0.82);
    color: var(--ink);
    font: inherit;
}

.policy-tools input:focus,
.policy-tools select:focus {
    border-color: var(--accent);
    outline: 3px solid rgba(37, 108, 78, 0.2);
}

.policy-actions {
    grid-column: 1 / -1;

    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.policy-actions button,
.policy-pagination button,
.policy-section-actions button,
.policy-section-actions a {
    min-height: 40px;
    padding: 9px 12px;

    border: 1px solid var(--line);
    border-radius: 4px;

    background: #fff;
    color: var(--ink);

    font: inherit;
    font-size: 0.82rem;
    font-weight: 750;
    text-decoration: none;

    cursor: pointer;
}

.policy-tools > [data-policy-status] {
    grid-column: 1 / -1;

    min-height: 1.2em;
    margin: 0;

    color: var(--muted);
    font-size: 0.82rem;
}


/* =========================================================
   POLICY LAYOUT
========================================================= */

.policy-layout {
    display: grid;
    grid-template-columns: minmax(210px, 260px) minmax(0, 920px);
    justify-content: center;
    gap: clamp(28px, 5vw, 66px);
}


/* =========================================================
   TABLE OF CONTENTS
========================================================= */

.policy-toc > div {
    position: sticky;
    top: 100px;

    padding: 4px 0 4px 18px;
    border-left: 1px solid var(--line);
}

.policy-toc h2 {
    margin: 0 0 16px;

    font-size: 0.66rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}

.policy-toc nav {
    display: grid;

    max-height: calc(100vh - 160px);
    overflow: auto;
}

.policy-toc a {
    padding: 6px 0;

    border-radius: 0;

    color: var(--muted);
    font-size: 0.82rem;
    line-height: 1.3;
    text-decoration: none;
}

.policy-toc a:hover,
.policy-toc a.is-active {
    background: transparent;
    color: var(--ink);
}

.policy-toc a.is-active {
    font-weight: 700;
}


/* =========================================================
   POLICY DOCUMENT
========================================================= */

.policy-document {
    min-width: 0;
}

.policy-loading,
.policy-error {
    padding: 34px;

    border: 1px solid var(--line);
    border-radius: 5px;

    background: #fff;
    text-align: center;
}


/* =========================================================
   POLICY DISCLOSURES
========================================================= */

.policy-section {
    margin-bottom: 12px;

    border: 1px solid var(--line);
    border-radius: 5px;

    background: rgba(255, 255, 255, 0.94);
    box-shadow: none;

    overflow: hidden;
    scroll-margin-top: 100px;
}

.policy-section[hidden] {
    display: none;
}

.policy-section[open] {
    border-left: 3px solid var(--accent);
}

.policy-section:focus {
    outline: 3px solid rgba(37, 108, 78, 0.25);
    outline-offset: 3px;
}


/* =========================================================
   DISCLOSURE SUMMARY
========================================================= */

.policy-section summary {
    display: grid;
    grid-template-columns: 34px 1fr auto;
    align-items: center;
    gap: 12px;

    padding: 17px 18px;

    font-weight: 800;

    cursor: pointer;
    list-style: none;
}

.policy-section summary::-webkit-details-marker {
    display: none;
}

.policy-section summary > span:first-child {
    display: block;

    width: auto;
    height: auto;

    border-radius: 0;

    background: transparent;
    color: var(--accent);

    font-size: 0.67rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    line-height: 1;
}

.policy-section summary > span[role="heading"] {
    font-size: 1rem;
}

.policy-section summary > b {
    font-size: 1.05rem;
    transition: transform 0.2s ease;
}

.policy-section[open] summary > b {
    transform: rotate(45deg);
}

/* =========================================================
   SEARCH MATCHES
========================================================= */

.policy-search-hit {
    padding: 0.05em 0.16em;

    border-radius: 2px;

    background: rgba(29, 139, 103, 0.15);
    color: var(--ink);

    font-weight: 700;

    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
/* =========================================================
   POLICY BODY
========================================================= */

.policy-section-body {
    padding: 4px 24px 28px 52px;

    color: var(--muted);
    line-height: 1.75;
}

.policy-section-body h3,
.policy-section-body h4 {
    margin-top: 1.6em;

    color: var(--ink);
    line-height: 1.25;
}

.policy-section-body p,
.policy-section-body li {
    max-width: 760px;
}

.policy-section-body a {
    color: var(--accent);
    text-underline-offset: 3px;
}


/* =========================================================
   DOCUMENT METADATA
========================================================= */

.policy-section-body > dl {
    display: flex;
    flex-wrap: wrap;
    gap: 0;

    margin: 0 0 28px;
    padding: 12px 0;

    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.policy-section-body > dl div {
    min-width: auto;
    padding: 0 14px;

    border: 0;
    border-left: 1px solid var(--line);
    border-radius: 0;

    background: transparent;
}

.policy-section-body > dl div:first-child {
    padding-left: 0;
    border-left: 0;
}

.policy-section-body dt {
    color: var(--muted);

    font-size: 0.58rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.policy-section-body dd {
    margin: 4px 0 0;

    font-size: 0.83rem;
    font-weight: 700;
}


/* =========================================================
   DOCUMENT ACTIONS
========================================================= */

.policy-section-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;

    margin-top: 26px;
    padding-top: 14px;

    border-top: 1px solid var(--line);
}

.policy-section-actions nav {
    display: flex;
    gap: 8px;
}


/* =========================================================
   PAGINATION
========================================================= */

.policy-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;

    margin: 34px auto 0;

    font-size: 0.84rem;
}

/*
 * Explicitly preserve the router's filtered hidden state.
 */
.policy-pagination[hidden] {
    display: none;
}

.policy-pagination button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 900px) {

    .policy-tools {
        grid-template-columns: 1fr 1fr;
    }

    .policy-search {
        grid-column: 1 / -1;
    }

    .policy-layout {
        grid-template-columns: 1fr;
    }

    .policy-toc > div {
        position: static;

        padding: 0 0 18px;

        border-left: 0;
        border-bottom: 1px solid var(--line);
    }

    .policy-toc nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));

        max-height: none;
    }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 620px) {

    .policy-page {
        padding-block: 32px;
    }

    .policy-hero {
        padding: 20px 0 34px;
        border-radius: 0;
    }

    .policy-tools {
        grid-template-columns: 1fr;
    }

    .policy-search,
    .policy-actions,
    .policy-tools > [data-policy-status] {
        grid-column: auto;
    }

    .policy-actions > * {
        flex: 1 1 135px;
    }

    .policy-metadata {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
    }

    .policy-metadata div,
    .policy-metadata div:first-child {
        padding: 0 10px;
        border-left: 1px solid var(--line);
    }

    .policy-metadata div:first-child {
        padding-left: 0;
        border-left: 0;
    }

    .policy-toc nav {
        grid-template-columns: 1fr;
    }

    .policy-section summary {
        grid-template-columns: 28px 1fr auto;
        padding: 15px 12px;
    }

    .policy-section-body {
        padding: 2px 16px 22px 40px;
    }

    .policy-section-body > dl {
        display: grid;
        grid-template-columns: 1fr 1fr;
    }

    .policy-section-body > dl div,
    .policy-section-body > dl div:first-child {
        padding: 8px 10px;

        border-left: 0;
        border-bottom: 1px solid var(--line);
    }

    .policy-section-actions,
    .policy-section-actions nav {
        align-items: stretch;
        flex-direction: column;
    }

    .policy-pagination {
        gap: 8px;
    }

    .policy-pagination button {
        padding: 8px;
    }
}


/* =========================================================
   PRINT
========================================================= */

@media print {

    .site-header,
    .site-footer,
    .policy-tools,
    .policy-toc,
    .policy-pagination,
    .policy-section-actions {
        display: none !important;
    }

    .policy-page {
        padding: 0;
    }

    .policy-layout {
        display: block;
    }

    .policy-section {
        display: block !important;

        break-inside: avoid;
        box-shadow: none;
    }

    .policy-section[open] .policy-section-body,
    .policy-section-body {
        display: block !important;
    }
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .policy-section summary > b {
        transition: none;
    }
}