/* ==========================================================================
   FIDES IN REALITY — WRITINGS
   Stage 6.2
   ========================================================================== */


/* ==========================================================================
   1. WRITINGS HERO
   ========================================================================== */

.writing-hero {
    text-align: center;
    padding: 64px 20px;
    background: linear-gradient(145deg, #06131d, #102b3a);
    color: #fff;
}

.writing-hero h1 {
    margin: 8px 0;
    font: clamp(44px, 7vw, 76px) / 1 Georgia, serif;
}

.writing-hero > p:last-child {
    max-width: 650px;
    margin: 14px auto 0;
    color: #e8dfd1;
    font: 18px / 1.7 Georgia, serif;
}


/* ==========================================================================
   2. PAGE CONTAINERS
   ========================================================================== */

.writing-page,
.reading-page {
    width: min(1120px, calc(100% - 36px));
    margin: auto;
    padding: 60px 0 90px;
}

.reading-page {
    max-width: 920px;
}


/* ==========================================================================
   3. SEARCH & FILTER BAR
   ========================================================================== */

.writing-filter {
    display: grid;
    grid-template-columns: 1fr 220px auto;
    gap: 10px;
    margin-bottom: 36px;
    overflow: visible;
}

.writing-filter input,
.writing-filter select,
.writing-filter button {
    padding: 12px;
    border: 1px solid #d3c8b8;
    background: #fff;
    font: inherit;
}

.writing-filter button {
    background: var(--navy);
    color: #fff;
}


/* ==========================================================================
   4. REAL-TIME HANGING SEARCH
   ========================================================================== */

.writing-live-search {
    position: relative;
    min-width: 0;
}

.writing-live-search > input {
    width: 100%;
    box-sizing: border-box;
}

.writing-search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;

    width: min(680px, calc(100vw - 40px));
    max-height: min(68vh, 560px);

    overflow: auto;

    background: #fff;
    border: 1px solid #d9cfbf;
    box-shadow: 0 22px 55px rgba(6, 19, 29, 0.22);

    z-index: 850;
    text-align: left;
}

.writing-search-result {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) 24px;
    gap: 13px;
    align-items: center;

    padding: 12px;

    border-bottom: 1px solid #eee7dc;

    text-decoration: none;
    color: #201d19;

    transition:
        background 0.15s ease,
        transform 0.15s ease;
}

.writing-search-result:last-child {
    border-bottom: 0;
}

.writing-search-result:hover,
.writing-search-result.is-active {
    background: #f7f2e9;
}


/* Search result image */

.writing-search-image {
    width: 64px;
    height: 64px;

    display: grid;
    place-items: center;

    overflow: hidden;

    background: #f0ebe2;

    font: 28px Georgia, serif;
    color: #a07b2c;
}

.writing-search-image img {
    width: 100%;
    height: 100%;

    display: block;
    object-fit: contain;
}


/* Search result text */

.writing-search-copy {
    min-width: 0;

    display: grid;
    gap: 3px;
}

.writing-search-copy small {
    color: #9a7428;

    text-transform: uppercase;
    letter-spacing: 0.08em;

    font-size: 10px;
}

.writing-search-copy strong {
    font: 20px / 1.15 Georgia, serif;
    color: #0b2533;
}

.writing-search-copy em {
    overflow: hidden;

    color: #665f55;

    font-size: 12px;
    font-style: normal;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.writing-search-copy > span {
    overflow: hidden;

    color: #746c61;

    font-size: 12px;

    white-space: nowrap;
    text-overflow: ellipsis;
}

.writing-search-arrow {
    color: #a17b2c;
    font-size: 20px;
}

.writing-search-loading,
.writing-search-empty {
    padding: 22px;

    color: #6d655a;
    text-align: center;
}


/* ==========================================================================
   5. WRITINGS GRID
   ========================================================================== */

.writing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 28px;
}

.writing-card {
    background: #fff;
    border: 1px solid #e5ded3;
}

.writing-cover {
    display: block;

    aspect-ratio: 4 / 3;

    overflow: hidden;

    background: #f1ece4;
}

.writing-cover img,
.reading-cover img {
    width: 100%;
    height: 100%;

    display: block;

    object-fit: contain;
}

.writing-card-copy {
    padding: 24px;
}

.writing-card-copy small {
    color: #98701e;

    text-transform: uppercase;
    letter-spacing: 0.12em;
}

.writing-card h2 {
    font: 20px / 1.15 Georgia, serif;
}

.writing-card h2 a,
.read-link {
    color: var(--navy);
    text-decoration: none;
}

.writing-card p {
    color: #655e55;
    line-height: 1.65;
}

.read-link {
    color: #80601b;

    text-decoration: underline;
    text-underline-offset: 4px;
}


/* ==========================================================================
   6. THREE-LINE EXCERPT
   ========================================================================== */

.writing-excerpt-wrap {
    margin: 0 0 12px;
}

.writing-excerpt {
    display: -webkit-box;

    margin-bottom: 7px !important;

    overflow: hidden;

    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.writing-excerpt.is-expanded {
    display: block;

    overflow: visible;

    -webkit-line-clamp: unset;
    line-clamp: unset;
}

.excerpt-toggle,
.reading-toggle {
    padding: 0;
    border: 0;
    background: transparent;
    color: #80601b;
    font: inherit;
    text-decoration: underline;
    text-underline-offset: 4px;
    cursor: pointer;
}


/* ==========================================================================
   7. READING PAGE NAVIGATION
   ========================================================================== */

.reading-nav {
    display: flex;
    justify-content: space-between;
    gap: 16px;

    padding-bottom: 16px;

    border-bottom: 1px solid #ded6c9;
}

.reading-nav a,
.reading-nav button {
    border: 0;
    background: none;

    color: #80601b;

    font: inherit;

    cursor: pointer;
}


/* ==========================================================================
   8. READING HEADER
   ========================================================================== */

.reading-header {
    padding: 48px 0 32px;
    text-align: center;
}

.reading-header h1 {
    margin: 8px 0;

    color: var(--navy);

    font: clamp(44px, 7vw, 76px) / 1.05 Georgia, serif;
}

.reading-subtitle {
    color: #675f55;
    font: 22px Georgia, serif;
}

.reading-meta {
    color: #877e73;
}


/* ==========================================================================
   9. READING COVER
   ========================================================================== */

.reading-cover {
    max-width: 760px;

    aspect-ratio: 4 / 3;

    margin: 0 auto 42px;

    overflow: hidden;

    background: #f1ece4;
}


/* ==========================================================================
   10. ARTICLE BODY
   ========================================================================== */

.reading-text-wrap {
    max-width: 760px;
    margin: auto;
}

.reading-body {
    max-width: 760px;

    margin: auto;

    color: #312e2a;

    font: 19px / 1.9 Georgia, serif;
}


/* Collapsed article */

.reading-body-collapsible {
    position: relative;

    max-height: 17.1em;

    overflow: hidden;
}

.reading-body-collapsible:not(.is-expanded)::after {
    content: "";

    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;

    height: 4em;

    background: linear-gradient(
        to bottom,
        rgba(255, 255, 255, 0),
        #fff
    );
}

.reading-body-collapsible.is-expanded {
    max-height: none;
    overflow: visible;
}

.reading-toggle {
    margin-top: 14px;
}


/* ==========================================================================
   11. INLINE PDF VIEWER
   ========================================================================== */

.inline-pdf {
    max-width: 860px;
    margin: 50px auto 0;
}

.inline-pdf-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;

    margin-bottom: 12px;
}

.inline-pdf-head h2 {
    margin: 0;

    color: var(--navy);

    font: 30px Georgia, serif;
}

.inline-pdf-head a {
    color: #80601b;
}

.pdf-object {
    display: block;

    width: 100%;
    height: min(78vh, 900px);
    min-height: 560px;

    border: 1px solid #d8cfc1;

    background: #f3efe8;
}

.pdf-object p {
    padding: 25px;
}

.pdf-mobile-note {
    color: #756d62;

    font-size: 12px;
    line-height: 1.5;
}


/* ==========================================================================
   12. READING ACTIONS
   ========================================================================== */

.reading-actions {
    max-width: 760px;

    display: flex;
    flex-wrap: wrap;
    gap: 12px;

    margin: 42px auto 0;
}

.reading-actions a,
.reading-actions button {
    padding: 11px 18px;

    border: 1px solid var(--gold);
    background: var(--navy);

    color: #fff;

    font: inherit;
    text-decoration: none;

    cursor: pointer;
}


/* ==========================================================================
   13. TAGS
   ========================================================================== */

.writing-tags {
    max-width: 760px;

    display: flex;
    flex-wrap: wrap;
    gap: 8px;

    margin: 28px auto;
}

.writing-tags span {
    padding: 7px 10px;

    background: #eee8dc;

    font-size: 12px;
}


/* ==========================================================================
   14. COPYRIGHT
   ========================================================================== */

.writing-copyright {
    margin-top: 55px;

    color: #82796d;

    font-size: 12px;
    text-align: center;
}


/* ==========================================================================
   15. EMPTY STATE
   ========================================================================== */

.writing-public-empty {
    grid-column: 1 / -1;

    padding: 60px;

    background: #fff;

    text-align: center;
}


/* ==========================================================================
   16. MOBILE
   ========================================================================== */

@media (max-width: 700px) {

    .writing-page,
    .reading-page {
        width: min(100% - 28px, 1120px);
    }

    .writing-filter {
        grid-template-columns: 1fr;
    }

    .reading-nav {
        flex-wrap: wrap;
    }

    .reading-body-collapsible {
        max-height: 15.2em;
    }

    .inline-pdf-head {
        align-items: flex-start;
    }

    .pdf-object {
        height: 70vh;
        min-height: 460px;
    }


    /* --------------------------------------------------------------
       Mobile realtime search dropdown
       -------------------------------------------------------------- */

    .writing-search-dropdown {
        position: fixed;

        top: auto;
        right: 14px;
        left: 14px;

        width: auto;
        max-height: 55vh;

        margin-top: 8px;
    }

    .writing-search-result {
        grid-template-columns: 52px minmax(0, 1fr) 20px;
    }

    .writing-search-image {
        width: 52px;
        height: 52px;
    }

    .writing-search-copy strong {
        font-size: 17px;
    }
}



/* ==========================================================================
   Stage 6.3 — Self-hosted PDF.js Reader
   ========================================================================== */

.fir-pdf-reader {
    overflow: hidden;
    border: 1px solid #d8cfc1;
    background: #e9e4dc;
}

.fir-pdf-toolbar {
    position: sticky;
    top: 0;
    z-index: 2;

    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;

    padding: 10px 12px;
    border-bottom: 1px solid #d8cfc1;
    background: #fff;
}

.fir-pdf-page-controls,
.fir-pdf-zoom-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.fir-pdf-toolbar button {
    min-width: 38px;
    min-height: 38px;
    padding: 7px 10px;

    border: 1px solid #d4c8b5;
    background: #fff;
    color: var(--navy);

    font: inherit;
    cursor: pointer;
}

.fir-pdf-toolbar button:hover:not(:disabled) {
    background: #f5efe5;
}

.fir-pdf-toolbar button:disabled {
    opacity: 0.4;
    cursor: default;
}

.fir-pdf-page-status,
.fir-pdf-zoom-value {
    color: #5f584e;
    font-size: 13px;
    white-space: nowrap;
}

.fir-pdf-stage {
    min-height: 520px;
    max-height: 78vh;
    padding: 12px;

    overflow: auto;
    text-align: center;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.fir-pdf-canvas {
    display: block;
    max-width: none;
    margin: 0 auto;

    background: #fff;
    box-shadow: 0 4px 18px rgba(6, 19, 29, 0.16);
}

.fir-pdf-loading,
.fir-pdf-error {
    padding: 70px 20px;
    color: #655e55;
    text-align: center;
}

.fir-pdf-error a {
    color: #80601b;
}

@media (max-width: 700px) {
    .fir-pdf-toolbar {
        position: static;
        flex-direction: column;
        align-items: stretch;
    }

    .fir-pdf-page-controls,
    .fir-pdf-zoom-controls {
        justify-content: center;
    }

    .fir-pdf-stage {
        min-height: 430px;
        max-height: 70vh;
        padding: 8px;
    }

    .fir-pdf-toolbar button {
        min-height: 42px;
    }
}
