/* ============================================
   logical.day — Chrome Pastoral Codex
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    background-color: #e8e8ec;
    color: #2a2a32;
    font-family: 'Lora', Georgia, serif;
    font-weight: 400;
    line-height: 1.72;
    font-size: clamp(1rem, 1.6vw, 1.15rem);
    overflow-x: hidden;
}

/* --- Book Cover (Opening Animation) --- */
#book-cover {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    z-index: 1000;
    display: flex;
    pointer-events: none;
}

#book-cover .cover-left,
#book-cover .cover-right {
    width: 50%;
    height: 100%;
    background: #c0c2c8;
    background-image:
        repeating-linear-gradient(90deg, #d8d8de 0px, #d8d8de 0.5px, transparent 0.5px, transparent 3px),
        radial-gradient(ellipse at 60% 40%, rgba(232,232,236,0.4) 0%, transparent 70%);
    display: flex;
    align-items: center;
    overflow: hidden;
    transition: transform 1.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

#book-cover .cover-left {
    justify-content: flex-end;
    padding-right: 0;
}

#book-cover .cover-right {
    justify-content: flex-start;
    padding-left: 0;
}

#book-cover .cover-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8, #a0a0a0, #d4d4d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow: none;
    white-space: nowrap;
}

#book-cover .cover-left .cover-title {
    clip-path: inset(0 0 0 0);
    transform: translateX(50%);
}

#book-cover .cover-right .cover-title {
    clip-path: inset(0 0 0 0);
    transform: translateX(-50%);
}

#book-cover.opening .cover-left {
    transform: translateX(-100%);
}

#book-cover.opening .cover-right {
    transform: translateX(100%);
}

#book-cover.hidden {
    display: none;
}

/* --- Main Codex Layout --- */
#codex {
    opacity: 0;
    transition: opacity 0.6s ease-out 0.8s;
}

#codex.visible {
    opacity: 1;
}

.codex-page {
    display: grid;
    grid-template-columns: 1fr minmax(0, 640px) 1fr;
    min-height: 100vh;
    padding: 80px 24px;
    position: relative;
}

.codex-page .page-content {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* --- Frontispiece --- */
#frontispiece {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

#frontispiece .page-content {
    text-align: center;
}

.frontispiece-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: clamp(2.8rem, 6vw, 5.2rem);
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8, #a0a0a0, #d4d4d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    text-shadow:
        1px -1px 0 rgba(255,255,255,0.3),
        -1px 1px 0 rgba(0,0,0,0.15);
    margin-bottom: 1.5rem;
}

.daily-proposition {
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.2rem);
    color: #6b6b7a;
    max-width: 480px;
    margin: 0 auto 2rem;
    line-height: 1.7;
}

.chapter-divider {
    width: 280px;
    height: 30px;
    margin-top: 1rem;
}

/* --- Table of Contents --- */
#table-of-contents {
    background-color: #c0c2c8;
    min-height: 100vh;
}

#table-of-contents .page-content {
    width: 100%;
    max-width: 640px;
    margin: 0 auto;
}

.toc-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    width: 100%;
    margin-top: 2rem;
}

.toc-entry {
    display: flex;
    align-items: baseline;
    padding: 0.9rem 0;
    text-decoration: none;
    color: #2a2a32;
    transition: transform 0.3s ease-out;
    cursor: pointer;
}

.toc-entry:hover {
    transform: scale(1.03);
}

.toc-entry:hover .toc-leader {
    border-bottom-width: 2px;
}

.toc-numeral {
    font-family: 'Anybody', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #3d3d4a;
    min-width: 2.5rem;
}

.toc-title {
    font-family: 'Anybody', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    white-space: nowrap;
}

.toc-leader {
    flex: 1;
    border-bottom: 1px dotted #d4a574;
    margin: 0 0.75rem;
    min-width: 2rem;
    align-self: center;
    transition: border-bottom-width 0.3s ease-out;
}

.toc-page {
    font-family: 'Anybody', sans-serif;
    font-weight: 500;
    font-size: 0.75rem;
    letter-spacing: 0.12em;
    color: #6b6b7a;
}

/* --- Chapter Sections --- */
.chapter-section {
    background-color: #f5f0e8;
    position: relative;
}

.chapter-section .page-content {
    position: relative;
    text-align: left;
    align-items: flex-start;
}

.chapter-number-watermark {
    position: absolute;
    top: -20px;
    left: -10px;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: 8rem;
    color: #3d3d4a;
    opacity: 0.06;
    line-height: 1;
    pointer-events: none;
    z-index: 0;
}

/* --- Chapter Vignette SVGs --- */
.chapter-vignette {
    width: 120px;
    height: 60px;
    margin: 0 auto 1.5rem;
    display: block;
}

.vignette-path {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1s ease-out;
}

.chapter-reveal.revealed .vignette-path {
    stroke-dashoffset: 0;
}

/* --- Chapter Headings --- */
.chapter-heading {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: clamp(1.8rem, 3.5vw, 2.8rem);
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8, #a0a0a0, #d4d4d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 2rem;
    width: 100%;
}

#table-of-contents .chapter-heading {
    text-align: center;
    width: 100%;
}

/* --- Chapter Body --- */
.chapter-body {
    margin-bottom: 1.5rem;
    text-align: justify;
    text-justify: inter-word;
    width: 100%;
}

/* --- Drop Caps --- */
.drop-cap {
    float: left;
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 900;
    font-size: 4.5rem;
    line-height: 0.75;
    padding-right: 0.12em;
    padding-top: 0.08em;
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8, #a0a0a0, #d4d4d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    transition: transform 0.3s ease-out;
    cursor: default;
}

.drop-cap:hover {
    transform: scale(1.12);
}

/* --- Section Dividers --- */
.section-divider {
    width: 100%;
    max-width: 400px;
    height: 20px;
    margin: 2rem auto 0;
    display: block;
}

.divider-vine {
    stroke-dasharray: 600;
    stroke-dashoffset: 600;
    transition: stroke-dashoffset 1.2s ease-out;
}

.chapter-reveal.revealed .divider-vine {
    stroke-dashoffset: 0;
}

/* --- Margin Content --- */
.margin-left,
.margin-right {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
}

.margin-annotation {
    position: sticky;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.margin-note {
    font-family: 'Courier Prime', 'Courier New', monospace;
    font-size: 0.8rem;
    line-height: 1.5;
    color: #8a8a9e;
    transform: rotate(-1deg);
    max-width: 180px;
    text-align: center;
}

.botanical-margin {
    width: 120px;
    height: auto;
    transition: transform 0.4s ease-out;
}

.botanical-margin:hover {
    transform: scale(1.08);
}

.botanical-margin:hover .vignette-path {
    stroke: #a8b4a0;
    transition: stroke 0.4s ease-out;
}

/* --- Colophon --- */
#colophon {
    background-color: #e8e8ec;
    min-height: 80vh;
}

#colophon .page-content {
    text-align: center;
    align-items: center;
}

.colophon-device {
    width: 80px;
    height: 80px;
    margin-bottom: 2rem;
}

.colophon-title {
    font-family: 'Playfair Display', Georgia, serif;
    font-weight: 700;
    font-size: 1.6rem;
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8, #a0a0a0, #d4d4d4);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 2.5rem;
}

.colophon-content {
    max-width: 400px;
}

.colophon-entry {
    display: flex;
    flex-direction: column;
    margin-bottom: 1.5rem;
}

.colophon-label {
    font-family: 'Anybody', sans-serif;
    font-weight: 500;
    font-size: 0.7rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #6b6b7a;
    margin-bottom: 0.3rem;
}

.colophon-value {
    font-family: 'Lora', Georgia, serif;
    font-style: italic;
    font-size: 0.95rem;
    color: #3d3d4a;
}

.colophon-finis {
    font-size: 2rem;
    color: #c0c2c8;
    margin-top: 2rem;
}

/* --- Folio Page Number --- */
#folio-number {
    position: fixed;
    bottom: 24px;
    right: 32px;
    z-index: 100;
    cursor: default;
    transition: transform 0.3s ease-out;
}

#folio-number:hover {
    transform: scale(1.15);
}

#folio-number:hover .folio-tooltip {
    opacity: 1;
    transform: translateX(-110%) translateY(0);
}

.folio-text {
    font-family: 'Anybody', sans-serif;
    font-weight: 300;
    font-size: 0.85rem;
    letter-spacing: 0.08em;
    color: #6b6b7a;
}

.folio-tooltip {
    position: absolute;
    right: 100%;
    top: 50%;
    transform: translateX(-100%) translateY(-50%);
    white-space: nowrap;
    font-family: 'Courier Prime', monospace;
    font-size: 0.7rem;
    color: #8a8a9e;
    padding-right: 8px;
    opacity: 0;
    transition: opacity 0.3s ease-out, transform 0.3s ease-out;
    pointer-events: none;
}

/* --- Chapter Reveal Animation --- */
.chapter-reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.chapter-reveal.revealed {
    opacity: 1;
    transform: translateY(0);
}

/* --- Mercury Pooling Divider (between cover sections) --- */
@keyframes mercuryMorph {
    0% { border-radius: 50% 20% 50% 20%; }
    25% { border-radius: 20% 50% 20% 50%; }
    50% { border-radius: 40% 30% 60% 20%; }
    75% { border-radius: 30% 60% 20% 40%; }
    100% { border-radius: 50% 20% 50% 20%; }
}

/* --- Responsive: < 1024px --- */
@media (max-width: 1024px) {
    .margin-left,
    .margin-right {
        display: none;
    }

    .codex-page {
        grid-template-columns: 1fr minmax(0, 640px) 1fr;
    }

    .chapter-section {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .chapter-section .page-content {
        max-width: 640px;
        padding: 0 24px;
    }
}

/* --- Responsive: < 768px --- */
@media (max-width: 768px) {
    .codex-page {
        grid-template-columns: 1fr;
        padding: 60px 24px;
    }

    .codex-page .page-content {
        grid-column: 1;
    }

    .chapter-number-watermark {
        font-size: 5rem;
    }

    .drop-cap {
        font-size: 3rem;
    }

    #folio-number {
        bottom: auto;
        top: 12px;
        right: 50%;
        transform: translateX(50%);
    }

    #folio-number:hover {
        transform: translateX(50%) scale(1.15);
    }

    #folio-number:hover .folio-tooltip {
        transform: translateX(-110%) translateY(0);
    }

    .chapter-vignette {
        width: 80px;
        height: 40px;
    }
}

/* --- Responsive: < 480px --- */
@media (max-width: 480px) {
    .frontispiece-title {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .chapter-heading {
        font-size: clamp(1.4rem, 5vw, 1.8rem);
    }

    .chapter-body {
        text-align: left;
    }
}
