/* =========================================================
   VA CFU Criteria Lookup
   Aesthetic: Editorial Utilitarian — precise, authoritative,
   scannable. Warm paper tones against sharp navy accents.
   ========================================================= */

:root {
    --navy: #031D5B;
    --navy-mid: #003676;
    --navy-light: #1A4D8C;
    --navy-10: rgba(3, 29, 91, 0.06);
    --navy-06: rgba(3, 29, 91, 0.04);
    --paper: #F8F7F4;
    --paper-warm: #F5F3EE;
    --ink: #1a1a2e;
    --ink-mid: #3d3d56;
    --ink-light: #6e6e82;
    --rule: #D5D3CD;
    --rule-light: #E8E6E0;
    --red: #C53030;
    --red-bg: #FED7D7;
    --green-bg: #C6F6D5;
    --yellow-bg: #FEFCBF;
    --radius: 6px;
    --radius-sm: 3px;
    --shadow-sm: 0 1px 2px rgba(3, 29, 91, 0.06);
    --shadow-md: 0 4px 12px rgba(3, 29, 91, 0.08);
    --shadow-lg: 0 8px 30px rgba(3, 29, 91, 0.1);
    --font-display: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    --max-width: 1080px;
}

/* ---- Reset & Base ---- */

*, *::before, *::after { box-sizing: border-box; }

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: 1rem;
    line-height: 1.65;
    color: var(--ink);
    background: var(--paper);
    margin: 0;
}

/* ---- Site Header ---- */

.site-header {
    background: var(--navy);
    border-bottom: 3px solid var(--navy-mid);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.85rem 2rem;
    display: flex;
    align-items: baseline;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-brand {
    color: #fff;
    text-decoration: none;
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.header-brand:visited { color: #fff; }
.header-brand:hover { color: #fff; }

.header-accent {
    color: var(--red);
    font-weight: 900;
}

.header-subtitle {
    color: rgba(255, 255, 255, 0.55);
    font-family: var(--font-display);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 600;
}

/* ---- Site Footer ---- */

.site-footer {
    background: var(--navy);
    color: rgba(255, 255, 255, 0.5);
    font-family: var(--font-display);
    font-size: 0.75rem;
    letter-spacing: 0.02em;
    padding: 1.2rem 0;
    margin-top: 3rem;
}

.footer-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.footer-sep { opacity: 0.4; }

/* ---- Page Container ---- */

.page-container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 2rem 2rem;
}

/* ---- Controls (Search + Sort) ---- */

.controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    padding: 1rem 0 0.5rem;
    flex-wrap: wrap;
}

.search-wrap {
    position: relative;
    flex: 1 1 260px;
    max-width: 440px;
}

.search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ink-light);
    pointer-events: none;
}

#search-input {
    width: 100%;
    padding: 0.6rem 0.85rem 0.6rem 2.5rem;
    border: 1.5px solid var(--rule);
    border-radius: var(--radius);
    font-family: var(--font-display);
    font-size: 0.9rem;
    background: #fff;
    color: var(--ink);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--navy-mid);
    box-shadow: 0 0 0 3px var(--navy-10);
}

#search-input::placeholder { color: var(--ink-light); }

.sort-group {
    display: flex;
    gap: 0;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1.5px solid var(--rule);
}

.sort-btn {
    padding: 0.55rem 1.1rem;
    border: none;
    background: #fff;
    cursor: pointer;
    font-family: var(--font-display);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: var(--ink-mid);
    transition: background 0.15s ease, color 0.15s ease;
}

.sort-btn + .sort-btn { border-left: 1.5px solid var(--rule); }

.sort-btn:hover { background: var(--navy-06); }

.sort-btn.active {
    background: var(--navy);
    color: #fff;
}

/* ---- Drug Table ---- */

.table-wrap {
    margin-top: 0.75rem;
    border: 1.5px solid var(--rule);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
    box-shadow: var(--shadow-md);
}

#drug-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

#drug-table thead { background: var(--paper-warm); }

th {
    text-align: left;
    padding: 0.7rem 1rem;
    font-family: var(--font-display);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    border-bottom: 2px solid var(--rule);
}

th.col-expand {
    width: 2.5rem;
    border-bottom: 2px solid var(--rule);
}

td {
    padding: 0.55rem 1rem;
    border-bottom: 1px solid var(--rule-light);
    font-size: 0.92rem;
    vertical-align: middle;
}

td.drug-expand-cell {
    width: 2.5rem;
    padding-left: 1rem;
}

.chevron {
    color: var(--navy-mid);
    font-size: 0.65rem;
    display: inline-block;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

tr.drug-row { cursor: pointer; transition: background 0.1s ease; }

tr.drug-row:hover { background: var(--navy-06); }

.drug-name a {
    color: var(--ink);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.15s ease;
}

.drug-name a:hover {
    color: var(--navy-mid);
}

.new-badge {
    display: inline-block;
    background: var(--red);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.15rem 0.35rem;
    border-radius: var(--radius-sm);
    margin-left: 0.2rem;
    vertical-align: middle;
    line-height: 1.3;
}

.brand-names {
    color: var(--ink-light);
    font-size: 0.85rem;
}

.last-updated {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    color: var(--ink-light);
    letter-spacing: -0.02em;
}

/* ---- Expand Row ---- */

tr.expand-row { display: none; }

tr.expand-row.visible { display: table-row; }

.expand-inner {
    margin: 0.5rem 0 0.5rem 0.5rem;
    padding: 1rem 1.5rem;
    border-left: 3px solid var(--navy-mid);
    background: var(--navy-06);
    border-radius: 0 var(--radius) var(--radius) 0;
}

tr.expand-row td {
    padding: 0.5rem 1rem 1rem;
    border-bottom: 1px solid var(--rule-light);
    background: transparent;
}

.summary-bullets {
    line-height: 1.75;
    font-size: 0.9rem;
    color: var(--ink);
    margin-bottom: 0.4rem;
}

.summary-bullets .criteria-group {
    margin-bottom: 0.75rem;
}

.summary-bullets .criteria-group:last-child {
    margin-bottom: 0;
}

.summary-bullets h4 {
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--navy-mid);
    margin: 0 0 0.35rem;
    padding-bottom: 0.2rem;
    border-bottom: 1px solid var(--rule-light);
}

.summary-bullets ul {
    list-style: none;
    margin: 0;
    padding: 0;
}

.summary-bullets li {
    position: relative;
    padding: 0.2rem 0 0.2rem 1.1rem;
    font-size: 0.88rem;
    line-height: 1.65;
    color: var(--ink);
}

.summary-bullets li::before {
    content: "";
    position: absolute;
    left: 0.25rem;
    top: 0.65rem;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--navy-mid);
}

.summary-bullets li strong {
    color: var(--ink);
    font-weight: 600;
}

.summary-bullets p {
    font-size: 0.88rem;
    line-height: 1.65;
    margin: 0.2rem 0;
}

.detail-link {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--navy-mid);
    text-decoration: none;
    margin-top: 0.5rem;
    transition: color 0.15s ease;
}

.detail-link:hover { color: var(--navy-light); text-decoration: underline; }

/* ---- Detail Page ---- */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-family: var(--font-display);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--navy-mid);
    text-decoration: none;
    padding: 1.5rem 0 0.5rem;
    transition: color 0.15s ease;
}

.back-link:hover { color: var(--navy-light); }

.detail-page {
    max-width: 800px;
}

.detail-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--rule);
}

.detail-header h1 {
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--navy);
}

/* ---- Metadata Card ---- */

.metadata-card {
    background: #fff;
    border: 1.5px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.metadata {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.4rem 1.5rem;
    margin: 0;
}

.meta-row { display: contents; }

.metadata dt {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-light);
    padding: 0.3rem 0;
    align-self: start;
}

.metadata dd {
    font-size: 0.95rem;
    color: var(--ink);
    padding: 0.3rem 0;
    margin: 0;
}

.badge {
    display: inline-block;
    font-family: var(--font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 0.18rem 0.55rem;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
}

.badge-pa-f { background: var(--yellow-bg); color: #975A16; }
.badge-nf { background: #FED7D7; color: #9B2C2C; }
.badge-b { background: var(--green-bg); color: #276749; }
.badge-rx { background: #E2E8F0; color: #4A5568; }

/* ---- Clinical Summary ---- */

.clinical-summary {
    margin-bottom: 2rem;
}

.clinical-summary h2 {
    font-family: var(--font-display);
    font-size: 1.1rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--navy);
    border-bottom: 2px solid var(--navy-mid);
    padding-bottom: 0.4rem;
    margin: 0 0 1rem;
}

.clinical-summary .summary-bullets .criteria-group {
    background: #fff;
    border: 1px solid var(--rule-light);
    border-radius: var(--radius);
    padding: 0.85rem 1.2rem;
    margin-bottom: 1rem;
}

.clinical-summary .summary-bullets h4 {
    font-size: 0.85rem;
    margin: 0 0 0.4rem;
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--rule-light);
}

.clinical-summary .summary-bullets li {
    padding: 0.25rem 0 0.25rem 1.1rem;
    font-size: 0.92rem;
}

.doc-heading {
    font-family: var(--font-display);
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--ink-mid);
    margin: 1.25rem 0 0.5rem;
    padding-left: 0.75rem;
    border-left: 3px solid var(--navy-mid);
}

.no-summary {
    color: var(--ink-light);
    font-style: italic;
    font-size: 0.92rem;
    padding: 0.5rem 0;
}

/* ---- PDF Downloads ---- */

.pdf-downloads {
    background: #fff;
    border: 1.5px solid var(--rule);
    border-radius: var(--radius);
    padding: 1.25rem 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

.pdf-downloads h2 {
    font-family: var(--font-display);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--ink-light);
    margin: 0 0 0.75rem;
}

.download-links { display: flex; flex-wrap: wrap; gap: 0.6rem; }

.pdf-download {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1.2rem;
    background: var(--navy);
    color: #fff;
    font-family: var(--font-display);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: var(--radius);
    letter-spacing: 0.02em;
    transition: background 0.15s ease, transform 0.1s ease;
}

.pdf-download:hover {
    background: var(--navy-light);
    color: #fff;
    transform: translateY(-1px);
}

.pdf-download:active { transform: translateY(0); }

.download-icon { flex-shrink: 0; }

/* ---- Mobile Responsive ---- */

@media (max-width: 640px) {
    .header-inner { padding: 0.7rem 1rem; }
    .header-brand { font-size: 1.1rem; }
    .header-subtitle { display: none; }
    .page-container { padding: 0 0.75rem 1rem; }
    .controls { gap: 0.5rem; }
    .search-wrap { flex: 1 1 100%; max-width: 100%; }
    .sort-btn { padding: 0.45rem 0.75rem; font-size: 0.72rem; }

    #drug-table { table-layout: auto; }

    colgroup, .col-expand, th.col-expand, td.drug-expand-cell { display: none; }

    th, td { padding: 0.45rem 0.6rem; }
    th { font-size: 0.62rem; }
    td { font-size: 0.85rem; }

    .drug-name { display: flex; flex-direction: column; gap: 0.15rem; }
    .drug-name a { width: fit-content; }
    .drug-name .new-badge { align-self: flex-start; width: fit-content; }
    .brand-names { font-size: 0.78rem; }
    .last-updated { font-size: 0.72rem; white-space: nowrap; }

    th:nth-child(3), td:nth-child(3) { display: none; }

    .drug-name .brand-names-inline {
        display: block;
    }

    .expand-inner { padding: 0.75rem 1rem; margin-left: 0; }

    .metadata { grid-template-columns: 1fr; gap: 0.2rem; }
    .detail-header h1 { font-size: 1.5rem; }
    .download-links { flex-direction: column; }
    .pdf-download { justify-content: center; }

    .footer-inner { padding: 0 1rem; }
}

@media (min-width: 641px) {
    .brand-names-inline { display: none; }
}

/* ---- Screen-reader only ---- */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}