/* ============================================
   Rironbusou - Fairycore Intellectual Library
   ============================================ */

:root {
    /* Color Palette */
    --dark-navy: #2A2F42;
    --very-dark-navy: #1A1E2E;
    --slate-blue: #2C3B4A;
    --soft-blue: #B8D4E3;
    --cream: #F5F0E8;
    --sky-blue: #7BA7C9;
    --deep-purple: #5C4A6B;
    --lavender: #C8B8D0;

    /* Typography */
    --font-display: "Playfair Display", serif;
    --font-body: "EB Garamond", serif;
    --font-dancing: "Dancing Script", cursive;
}

/* ============================================
   Global Styles
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: linear-gradient(135deg, var(--dark-navy) 0%, var(--slate-blue) 50%, var(--deep-purple) 100%);
    color: var(--cream);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ============================================
   Opening Overlay & Animation
   ============================================ */

.opening-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--very-dark-navy) 0%, var(--dark-navy) 50%, var(--slate-blue) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 3.5s ease-out;
}

.opening-overlay.fade-out {
    opacity: 0;
    pointer-events: none;
}

.opening-content {
    text-align: center;
    position: relative;
}

.opening-title {
    font-family: var(--font-dancing);
    font-size: clamp(2rem, 6vw, 4rem);
    color: var(--lavender);
    margin-bottom: 2rem;
    opacity: 0;
    animation: fadeInTitle 1.5s ease-out forwards;
    text-shadow: 0 4px 20px rgba(200, 184, 208, 0.3);
    font-weight: 700;
    letter-spacing: 2px;
}

.opening-subtitle {
    font-family: var(--font-body);
    font-size: clamp(0.9rem, 2vw, 1.3rem);
    color: var(--soft-blue);
    font-style: italic;
    opacity: 0;
    animation: fadeInSubtitle 1s ease-out forwards;
    animation-delay: 1.5s;
    text-shadow: 0 2px 10px rgba(184, 212, 227, 0.2);
    letter-spacing: 1px;
}

@keyframes fadeInTitle {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInSubtitle {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Fairy dust particles */
.fairy-dust-container {
    position: absolute;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.fairy-dust {
    position: absolute;
    width: 4px;
    height: 4px;
    background: radial-gradient(circle, var(--lavender) 0%, rgba(200, 184, 208, 0) 70%);
    border-radius: 50%;
    opacity: 0.6;
}

/* ============================================
   Masonry Grid Layout
   ============================================ */

.masonry-container {
    column-count: 3;
    column-gap: 24px;
    padding: 48px;
    max-width: 1400px;
    margin: 0 auto;
    opacity: 0;
    animation: fadeInGrid 1s ease-out forwards;
    animation-delay: 3.5s;
}

@keyframes fadeInGrid {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   Manuscript Pages
   ============================================ */

.manuscript-page {
    background: var(--cream);
    color: var(--dark-navy);
    padding: 32px;
    margin-bottom: 24px;
    border-radius: 4px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    break-inside: avoid;
    position: relative;
    opacity: 0;
    animation: fadeInPage 0.6s ease-out forwards;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.manuscript-page:nth-child(1) { animation-delay: 3.5s; }
.manuscript-page:nth-child(2) { animation-delay: 3.62s; }
.manuscript-page:nth-child(3) { animation-delay: 3.74s; }
.manuscript-page:nth-child(4) { animation-delay: 3.86s; }
.manuscript-page:nth-child(5) { animation-delay: 3.98s; }
.manuscript-page:nth-child(6) { animation-delay: 4.1s; }
.manuscript-page:nth-child(7) { animation-delay: 4.22s; }
.manuscript-page:nth-child(8) { animation-delay: 4.34s; }
.manuscript-page:nth-child(9) { animation-delay: 4.46s; }

@keyframes fadeInPage {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.manuscript-page:hover {
    transform: translateY(-8px);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.manuscript-page.tall {
    min-height: 500px;
}

/* Ornament SVGs */
.ornament {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    display: block;
    color: var(--lavender);
    stroke: var(--lavender);
    fill: none;
}

/* Page Title */
.page-title {
    font-family: var(--font-display);
    font-size: clamp(1.5rem, 3vw, 2.2rem);
    font-weight: 700;
    color: var(--dark-navy);
    margin-bottom: 16px;
    text-align: center;
    line-height: 1.2;
    letter-spacing: 0.5px;
}

/* Page Content */
.page-content {
    font-size: 1rem;
    line-height: 1.8;
    color: var(--dark-navy);
    margin-bottom: 16px;
    text-align: justify;
}

/* Page Quote */
.page-quote {
    font-family: var(--font-body);
    font-size: 1rem;
    font-style: italic;
    color: var(--deep-purple);
    padding: 16px 0;
    border-left: 3px solid var(--sky-blue);
    padding-left: 16px;
    margin-top: 20px;
    line-height: 1.6;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    .masonry-container {
        column-count: 2;
        padding: 32px;
    }

    .page-title {
        font-size: clamp(1.3rem, 2.5vw, 1.8rem);
    }
}

@media (max-width: 768px) {
    .masonry-container {
        column-count: 1;
        padding: 24px;
    }

    .manuscript-page {
        padding: 24px;
        margin-bottom: 20px;
    }

    .page-content {
        text-align: left;
    }

    .page-title {
        font-size: clamp(1.2rem, 2vw, 1.6rem);
    }
}

@media (max-width: 480px) {
    .masonry-container {
        padding: 16px;
    }

    .manuscript-page {
        padding: 16px;
        margin-bottom: 16px;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .page-content {
        font-size: 0.95rem;
    }

    .page-quote {
        font-size: 0.9rem;
        padding-left: 12px;
        border-left-width: 2px;
    }

    .opening-title {
        font-size: 2rem;
    }

    .opening-subtitle {
        font-size: 0.85rem;
    }
}

/* ============================================
   Discovery & Hover Effects
   ============================================ */

.manuscript-page {
    cursor: pointer;
}

.manuscript-page .page-title {
    transition: color 0.3s ease;
}

.manuscript-page:hover .page-title {
    color: var(--sky-blue);
}

.page-quote {
    transition: border-color 0.3s ease, color 0.3s ease;
}

.manuscript-page:hover .page-quote {
    border-color: var(--deep-purple);
    color: var(--lavender);
}

/* ============================================
   Accessibility & Print
   ============================================ */

@media print {
    .opening-overlay {
        display: none;
    }

    .masonry-container {
        column-count: 1;
    }
}

/* Smooth scrolling support */
@supports (scroll-behavior: smooth) {
    html {
        scroll-behavior: smooth;
    }
}
