/* ============================================
   layer-2.report — Fairycore Research Chronicle
   Palette:
     Midnight Blue:   #1A2744
     Aged Parchment:  #F4EDE4
     Warm Umber:      #3A3028
     Faded Ink:       #7A6B5A
     Botanical Gold:  #C4A882
     Forest Moss:     #5A7A5A
     Pressed Rose:    #9A5A6A
     Deep Parchment:  #EDE4D8
   ============================================ */

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

html {
    scroll-behavior: smooth;
    overflow-x: hidden;
}

body {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.3vw, 1.15rem);
    line-height: 1.85;
    letter-spacing: 0.01em;
    color: #3A3028;
    background-color: #F4EDE4;
    overflow-x: hidden;
    position: relative;
}

/* Paper grain texture overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='0.03'/%3E%3C/svg%3E");
    opacity: 0.4;
}

/* --- Vine Progress Indicator --- */
#vine-progress {
    position: fixed;
    left: 20px;
    top: 0;
    width: 40px;
    height: 100vh;
    z-index: 100;
    pointer-events: none;
}

#vine-svg {
    width: 40px;
    height: 100%;
}

#vine-path {
    stroke: #5A7A5A;
    stroke-dasharray: 2200;
    stroke-dashoffset: 2200;
    transition: stroke-dashoffset 0.1s ease-out;
}

#vine-seed {
    transition: opacity 0.5s ease;
}

.vine-leaf path,
.vine-leaf line {
    transition: opacity 0.5s ease;
}

/* --- Manuscript Pages --- */
.manuscript-page {
    min-height: 90vh;
    padding: 8vh 5vw;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    background: linear-gradient(180deg, #F4EDE4 0%, #EDE4D8 100%);
    box-shadow:
        0 1px 0 rgba(196, 168, 130, 0.15),
        0 -1px 0 rgba(196, 168, 130, 0.1),
        inset 0 0 80px rgba(196, 168, 130, 0.08);
}

/* Paper vignette on section edges */
.manuscript-page::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    background: radial-gradient(ellipse at center, transparent 60%, rgba(196, 168, 130, 0.06) 100%);
}

/* Title section — full viewport */
#section-title {
    min-height: 100vh;
}

/* --- Page Content Column (65% max-width) --- */
.page-content {
    max-width: 65%;
    width: 100%;
    margin: 0 auto;
    position: relative;
    z-index: 2;
    opacity: 0;
    transform: translateY(60px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.manuscript-page.revealed .page-content {
    opacity: 1;
    transform: translateY(0);
}

/* Title section is always visible (animated by JS) */
#section-title .page-content {
    opacity: 1;
    transform: translateY(0);
}

/* --- Title Block --- */
.title-block {
    text-align: center;
    padding: 4vh 0;
}

.main-title {
    font-family: 'Cormorant Garamond', 'Georgia', serif;
    font-weight: 600;
    font-size: clamp(2.5rem, 5vw, 4.5rem);
    letter-spacing: 0.08em;
    font-variant: small-caps;
    color: #1A2744;
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.main-title .letter {
    display: inline-block;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.main-title .letter.visible {
    opacity: 1;
    transform: translateY(0);
}

.main-title .letter-space {
    display: inline-block;
    width: 0.3em;
}

.subtitle {
    font-family: 'Crimson Pro', Georgia, serif;
    font-weight: 300;
    font-style: italic;
    font-size: clamp(1.1rem, 1.8vw, 1.4rem);
    color: #7A6B5A;
    opacity: 0;
    transition: opacity 1s ease 0.5s;
    letter-spacing: 0.02em;
}

.subtitle.visible {
    opacity: 1;
}

/* --- Chapter Headings --- */
.chapter-heading {
    margin-bottom: 2.5rem;
    text-align: center;
    position: relative;
}

.chapter-number {
    display: block;
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 400;
    font-size: 1rem;
    color: #C4A882;
    letter-spacing: 0.15em;
    margin-bottom: 0.5rem;
}

.chapter-heading h2 {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-weight: 600;
    font-size: clamp(2rem, 4vw, 3.5rem);
    letter-spacing: 0.02em;
    font-variant: small-caps;
    color: #1A2744;
    line-height: 1.2;
}

/* --- Body Text --- */
.body-text {
    margin-bottom: 2rem;
}

.body-text p {
    margin-bottom: 1.5rem;
    text-align: justify;
    hyphens: auto;
}

.body-text em {
    font-style: italic;
    color: #9A5A6A;
}

/* --- Botanical Illustrations --- */
.botanical-illustration {
    margin: 2.5rem auto;
    max-width: 420px;
    opacity: 0.9;
}

.botanical-illustration svg {
    width: 100%;
    height: auto;
}

.illust-label {
    font-family: 'Cormorant Garamond', Georgia, serif;
    font-size: 11px;
    font-style: italic;
    fill: #7A6B5A;
    letter-spacing: 0.03em;
}

.illust-annotation {
    font-family: 'Caveat', cursive;
    font-size: 11px;
    fill: #7A6B5A;
}

/* --- Ornamental Rules (Section Dividers) --- */
.ornamental-rule {
    max-width: 500px;
    margin: 0 auto;
    padding: 1rem 0;
    text-align: center;
    position: relative;
    z-index: 2;
}

.ornamental-rule svg {
    width: 100%;
    max-width: 500px;
    height: auto;
}

/* Divider line-draw animation */
.section-divider .ornament-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease;
}

.section-divider.drawn .ornament-line {
    stroke-dashoffset: 0;
}

/* Opening rule — draws after title animation */
.opening-rule {
    margin-top: 2rem;
}

.opening-rule svg {
    max-width: 400px;
}

.opening-rule .ornament-line {
    stroke-dasharray: 500;
    stroke-dashoffset: 500;
    transition: stroke-dashoffset 1.5s ease 1.8s;
}

.opening-rule.drawn .ornament-line {
    stroke-dashoffset: 0;
}

/* --- Closing Ornament --- */
.closing-ornament {
    margin: 3rem auto 1rem;
    text-align: center;
    max-width: 200px;
}

.closing-ornament svg {
    width: 100%;
    height: auto;
}

/* --- Margin Annotations --- */
.margin-annotation {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    max-width: 160px;
    opacity: 0;
    transition: opacity 0.6s ease;
    z-index: 2;
}

.margin-annotation.visible {
    opacity: 1;
}

.left-annotation {
    left: 3vw;
}

.right-annotation {
    right: 3vw;
}

.annotation-text {
    font-family: 'Caveat', cursive;
    font-weight: 400;
    font-size: 0.95rem;
    color: #7A6B5A;
    line-height: 1.5;
    display: block;
}

/* --- Margin Fauna --- */
.margin-fauna {
    position: absolute;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.8s ease;
}

.manuscript-page.revealed .margin-fauna {
    opacity: 0.6;
}

.margin-fauna svg {
    width: 36px;
    height: 36px;
}

.right-fauna {
    right: 4vw;
    bottom: 15vh;
}

.left-fauna {
    left: 4vw;
    top: 20vh;
}

/* Moth flutter animation */
.fauna-flutter .fauna-moth {
    animation: flutter 4s ease-in-out infinite;
}

@keyframes flutter {
    0%, 100% { transform: rotate(0deg) translateY(0); }
    25% { transform: rotate(3deg) translateY(-3px); }
    50% { transform: rotate(-2deg) translateY(1px); }
    75% { transform: rotate(4deg) translateY(-2px); }
}

/* Beetle crawl animation */
.fauna-crawl .fauna-beetle {
    animation: crawl 8s ease-in-out infinite;
}

@keyframes crawl {
    0%, 100% { transform: translateX(0) translateY(0); }
    25% { transform: translateX(3px) translateY(-1px); }
    50% { transform: translateX(5px) translateY(0); }
    75% { transform: translateX(2px) translateY(1px); }
}

/* Microbe float animation */
.fauna-float .fauna-microbe {
    animation: microFloat 6s ease-in-out infinite;
}

@keyframes microFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    33% { transform: translateY(-5px) rotate(10deg); }
    66% { transform: translateY(3px) rotate(-5deg); }
}

/* --- Reveal Ornament (section dividers, fade in) --- */
.reveal-ornament {
    opacity: 0;
    transition: opacity 0.8s ease;
}

.reveal-ornament.drawn {
    opacity: 1;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
    .page-content {
        max-width: 80%;
    }

    .margin-annotation {
        display: none;
    }

    .margin-fauna {
        display: none;
    }

    #vine-progress {
        left: 8px;
    }
}

@media (max-width: 768px) {
    .page-content {
        max-width: 90%;
    }

    .manuscript-page {
        padding: 6vh 4vw;
        min-height: 80vh;
    }

    #vine-progress {
        display: none;
    }

    .body-text p {
        text-align: left;
        hyphens: none;
    }

    .botanical-illustration {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    .page-content {
        max-width: 95%;
    }

    .manuscript-page {
        padding: 4vh 3vw;
        min-height: auto;
    }

    .main-title {
        letter-spacing: 0.04em;
    }
}

/* --- Selection styling --- */
::selection {
    background: rgba(196, 168, 130, 0.3);
    color: #1A2744;
}

/* --- Scrollbar styling --- */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #EDE4D8;
}

::-webkit-scrollbar-thumb {
    background: #C4A882;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #7A6B5A;
}
