/* Stylesheet: Foundation, shared controls and legacy component rules.
 * Cascade order is intentional: later component/responsive refinements win.
 * Keep selectors, declaration order and breakpoints in place when editing.
 * Shared palette: --brand and --brand-dark in archive.css; fallbacks retained.
 */

:root {
    --ink: #1f2933;
    --muted: #5f6c7b;
    --line: #d9e2ec;
    --paper: #ffffff;
    --soft: #f4f7f9;
    --brand: #28536b;
    --brand-dark: #17384b;
    --donate: #8a3b12;
    --success: #276749;
    --error: #a61b1b;
    --mark: #fff2a8;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    background: var(--soft);
    font-family: Arial, Helvetica, sans-serif;
    line-height: 1.5;
}

a {
    color: var(--brand);
}

.site-header,
.site-footer,
.page-shell {
    width: min(980px, calc(100% - 32px));
    margin: 0 auto;
}

.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    padding: 24px 0 16px;
}

.site-title {
    color: var(--ink);
    font-size: 22px;
    font-weight: 700;
    text-decoration: none;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

.button,
button {
    border: 0;
    border-radius: 6px;
    background: var(--brand);
    color: #fff;
    cursor: pointer;
    display: inline-block;
    font: inherit;
    font-weight: 700;
    padding: 11px 16px;
    text-decoration: none;
}

.button:hover,
button:hover {
    background: var(--brand-dark);
}

.button-donate {
    background: var(--donate);
}

.button-danger {
    background: var(--error);
}

.button-danger:hover,
.button-danger:focus-visible {
    background: #7d1515;
}

.admin-activity-pagination {
    flex-wrap: wrap;
}

.button-secondary {
    background: #52606d;
}

.admin-heading a.admin-export-button {
    flex: 0 0 auto;
    align-self: flex-start;
    white-space: nowrap;
    font-size: 13px;
    font-weight: 500;
    padding: 9px 13px;
}

.page-shell {
    padding: 18px 0 40px;
}

.search-panel,
.admin-panel {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 28px;
}

.eyebrow {
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .08em;
    margin: 0 0 6px;
    text-transform: uppercase;
}

h1,
h2,
h3,
p {
    margin-top: 0;
}

.search-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    margin-top: 18px;
}

.browse-filter {
    align-items: end;
    display: grid;
    grid-template-columns: minmax(130px, 180px) minmax(130px, 180px) auto auto;
    gap: 12px;
    margin-top: 18px;
}

.browse-filter label {
    display: block;
    font-weight: 700;
    margin-bottom: 6px;
}

.clear-link {
    font-weight: 700;
    padding: 11px 0;
}

input[type="search"],
input[type="text"],
input[type="password"],
input[type="number"],
input[type="file"] {
    border: 1px solid #bcccdc;
    border-radius: 6px;
    font: inherit;
    padding: 11px 12px;
    width: 100%;
}

.search-help,
.muted {
    color: var(--muted);
    margin-bottom: 0;
}

.support-strip {
    align-items: center;
    background: #fff8ea;
    border: 1px solid #f3d7a0;
    border-radius: 8px;
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: 18px;
    margin: 18px 0;
    padding: 20px 24px;
}

.support-strip .icon-wrapper img {
    display: block;
    width: 56px;
    height: 56px;
    max-width: 100%;
    object-fit: contain;
}

.support-strip .desc-wrapper {
    min-width: 0;
}

.support-strip .desc-wrapper strong {
    display: block;
    margin-bottom: 5px;
    color: var(--brand, #28536b);
    font: 700 17px/1.4 'Montagu Slab', Georgia, serif;
}

.support-strip .desc-wrapper span {
    display: block;
    color: #594214;
    font-size: 13px;
    line-height: 1.65;
}

.support-strip .options-wrapper a {
    display: inline-block;
    padding: 11px 17px;
    border-radius: 6px;
    background: var(--brand, #28536b);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.5;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
}

.support-strip .options-wrapper a:hover {
    background: var(--brand-dark, #17384b);
}

.support-strip .options-wrapper a:focus-visible {
    outline: 3px solid #d9a13c;
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .support-strip {
        grid-template-columns: 44px minmax(0, 1fr);
        gap: 12px 14px;
        padding: 18px 16px;
    }

    .support-strip .icon-wrapper {
        align-self: start;
    }

    .support-strip .icon-wrapper img {
        width: 44px;
        height: 44px;
    }

    .support-strip .options-wrapper {
        grid-column: 2;
    }

    .support-strip .options-wrapper a {
        max-width: 100%;
        white-space: normal;
    }

}

.results-header h2 {
    font-size: 20px;
    margin: 24px 0 12px;
}

.browse-summary {
    align-items: center;
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.browse-summary h2 {
    margin-bottom: 12px;
}

.table-wrap {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow-x: auto;
}

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

.archive-table th,
.archive-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 14px;
    text-align: left;
    vertical-align: top;
}

.archive-table th {
    background: #edf2f7;
    font-size: 14px;
}

.archive-table tr:last-child td {
    border-bottom: 0;
}

.archive-table a {
    font-weight: 700;
}

.pagination {
    align-items: center;
    display: flex;
    gap: 14px;
    justify-content: center;
    margin: 22px 0 0;
}

.pagination a {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 6px;
    font-weight: 700;
    padding: 9px 13px;
    text-decoration: none;
}

.result {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 14px;
    padding: 20px;
}

.result h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.article-title {
    color: var(--muted);
    font-style: italic;
}

.snippet {
    margin-bottom: 14px;
}

mark {
    background: var(--mark);
    border-radius: 3px;
    padding: 0 2px;
}

.result-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 14px;
    font-weight: 700;
}

.viewer-page .viewer-header {
    display: block;
    width: min(1100px, 100%);
    margin: 0 auto 20px;
    padding: 4px 12px 18px;
    border-bottom: 1px solid var(--line);
}

.viewer-breadcrumbs {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 6px 8px;
    margin-bottom: 12px;
    color: var(--muted);
    font-size: 12px;
    overflow-wrap: anywhere;
}

.viewer-breadcrumbs a {
    text-decoration: none;
}

.viewer-breadcrumbs a:hover {
    text-decoration: underline;
}

.viewer-toolbar {
    align-items: center;
    display: flex;
    gap: 16px;
    justify-content: space-between;
    flex-wrap: wrap;
}

.viewer-page .viewer-header h1 {
    color: var(--brand-dark);
    font-family: Georgia, 'Times New Roman', serif;
    font-size: clamp(18px, 2vw, 24px);
    line-height: 1.3;
    margin: 0 0 14px;
    overflow-wrap: anywhere;
}

.viewer-page .viewer-pub-title {
    font-style: italic;
    display: block;
    color: var(--brand, #28536b);
    font-family: 'Montagu Slab';
}

.viewer-page-details {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 14px;
    color: var(--muted);
    font-size: 14px;
    margin: 0;
}

.viewer-page-label {
    background: #edf2f7;
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 3px 9px;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 12px;
}

.viewer-search-label strong {
    color: var(--brand-dark);
    font-weight: 600;
}

.viewer-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-weight: 700;
}

.viewer-page .viewer-actions a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: 5px;
    background: var(--paper);
    color: var(--brand-dark);
    padding: 9px 12px;
    font-size: 12px;
    text-decoration: none;
}

.viewer-page .viewer-actions a:hover,
.viewer-page .viewer-actions a:focus-visible {
    background: #edf2f7;
    border-color: var(--brand);
}

.viewer-page {
    margin-left: calc(50% - 50vw + 16px);
    width: calc(100vw - 32px);
}

.viewer-page .issue-purchase {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 14px 24px;
    background: #fff8ea;
    border: 1px solid #f3d7a0;
    border-radius: 8px;
    width: fit-content;
    max-width: 100%;
    margin: 24px auto;
    padding: 20px 24px;
}

.viewer-page .issue-purchase-description {
    flex: 0 1 420px;
    min-width: 0;
    width: auto;
    max-width: none;
}

.viewer-page .issue-purchase-description strong,
.viewer-page .issue-purchase-description span {
    display: block;
}

.viewer-page .issue-purchase-description span {
    color: #594214;
    margin-top: 4px;
}

.viewer-page .issue-purchase-actions {
    flex: 0 1 auto;
    width: auto;
    max-width: 100%;
}

.viewer-page .issue-purchase a.issue-purchase-button {
    background: var(--brand, #28536b);
    color: #fff;
    text-align: center;
    text-decoration: none;
}

.viewer-page .issue-purchase a.issue-purchase-button:hover,
.viewer-page .issue-purchase a.issue-purchase-button:focus-visible {
    background: var(--brand-dark, #17384b);
}

.pdf-frame {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: block;
    height: calc(100vh - 170px);
    min-height: 720px;
    width: 100%;
    box-shadow: 0 4px 20px rgb(23 56 75 / 6%);
}

/* Keep the existing stacked viewer on phones and tablets. */
@media (min-width: 1000px) {
    .viewer-page {
        display: grid;
        grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
        grid-template-rows: auto 1fr;
        gap: 0 24px;
        align-items: start;
        isolation: isolate;
    }

    /* One shared card behind the details and purchase panel. */
    .viewer-page::before {
        content: '';
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: stretch;
        background: var(--paper);
        border: 1px solid var(--line);
        border-radius: 10px;
        z-index: -1;
    }

    .viewer-page .viewer-header {
        grid-column: 1;
        grid-row: 1;
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 24px;
        border: 0;
    }

    .viewer-page .viewer-header h1 {
        font-size: 23px;
        margin-bottom: 20px;
    }

    .viewer-page .viewer-toolbar {
        align-items: stretch;
        flex-direction: column;
        gap: 20px;
        padding-top: 20px;
        border-top: 1px solid var(--line);
    }

    .viewer-page .viewer-page-details {
        align-items: flex-start;
        flex-direction: column;
    }

    .viewer-page .viewer-actions {
        flex-direction: column;
    }

    .viewer-page .viewer-actions a {
        background: #edf2f7;
        padding: 12px;
    }

    .viewer-page > .pdf-frame,
    .viewer-page > .notice-error {
        grid-column: 2;
        grid-row: 1 / 3;
        min-width: 0;
    }

    .viewer-page > .pdf-frame {
        height: max(620px, calc(100vh - 210px));
        min-height: 620px;
    }

    .viewer-page .issue-purchase {
        grid-column: 1;
        grid-row: 2;
        align-self: start;
        display: block;
        width: auto;
        margin: 0 24px 24px;
        padding: 16px;
    }

    .viewer-page .issue-purchase-description {
        font-size: 13px;
    }

    .viewer-page .issue-purchase-actions {
        margin-top: 12px;
    }

    .viewer-page .issue-purchase-button {
        width: 100%;
        padding: 10px 8px;
        font-size: 13px;
    }

}

.notice {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin: 18px 0;
    padding: 14px 16px;
}

.notice-success {
    border-color: #9ae6b4;
    color: var(--success);
}

.notice-error {
    border-color: #feb2b2;
    color: var(--error);
}

.notice-warning {
    border-color: #f6c56f;
    color: #6f4d00;
}

.stacked-form {
    display: grid;
    gap: 10px;
    margin-top: 20px;
}

.stacked-form label {
    font-weight: 700;
    margin-top: 8px;
}

.stacked-form button {
    justify-self: start;
    margin-top: 12px;
}

.admin-heading {
    align-items: start;
    display: flex;
    justify-content: space-between;
    gap: 18px;
}

.admin-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-weight: 700;
}

.check-row {
    align-items: start;
    display: flex;
    gap: 10px;
    line-height: 1.4;
}

.check-row input {
    margin-top: 4px;
    width: auto;
}

.admin-log {
    margin-top: 28px;
}

.admin-log h2 {
    font-size: 20px;
}

.health-groups {
    display: grid;
    gap: 22px;
    margin-top: 22px;
}

.health-group h2 {
    font-size: 20px;
    margin-bottom: 10px;
}

.health-table th:first-child,
.health-table td:first-child {
    width: 150px;
}

.health-status {
    border-radius: 999px;
    display: inline-block;
    font-size: 13px;
    font-weight: 700;
    padding: 5px 9px;
}

.health-ok {
    background: #e3fcec;
    color: #276749;
}

.health-warning {
    background: #fff4d6;
    color: #6f4d00;
}

.health-error {
    background: #ffe3e3;
    color: #a61b1b;
}

.modal-backdrop {
    align-items: center;
    background: rgba(18, 32, 44, .72);
    display: flex;
    inset: 0;
    justify-content: center;
    padding: 20px;
    position: fixed;
    z-index: 10;
}

.agreement-modal {
    background: var(--paper);
    border-radius: 8px;
    box-shadow: 0 18px 60px rgba(0, 0, 0, .28);
    max-width: 560px;
    padding: 28px;
}

.agreement-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.site-footer {
    color: var(--muted);
    font-size: 14px;
    padding: 0 0 30px;
}

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

@media (max-width: 680px) {
    .site-header,
    .admin-heading,
    .admin-links,
    .search-form,
    .browse-filter,
    .browse-summary,
    .viewer-header {
        display: block;
    }

    .site-nav {
        display: flex;
        margin-top: 14px;
    }

    .admin-links {
        margin-top: 14px;
    }

    .search-form button,
    .browse-filter button {
        margin-top: 10px;
        width: 100%;
    }

    .clear-link {
        display: inline-block;
        padding-bottom: 0;
    }

    .search-panel,
    .admin-panel {
        padding: 20px;
    }

    .viewer-page {
        margin-left: calc(50% - 50vw + 10px);
        width: calc(100vw - 20px);
    }

    .pdf-frame {
        height: calc(100vh - 155px);
        min-height: 520px;
    }

}

.maintenance-admin-banner {
    padding: 12px 20px;
    background: #fff3d6;
    border-bottom: 1px solid #e6cb91;
    color: #654c20;
    font: 13px/1.6 Arial,sans-serif;
    text-align: center;
}

.maintenance-admin-banner a {
    color: inherit;
    font-weight: 700;
    margin-left: 8px;
}
