:root {
    --midnight-ink: #0B0E2A;
    --twilight-indigo: #1A1F4E;
    --aurora-green: #2DD4A8;
    --aurora-rose: #E8476F;
    --aurora-violet: #8B5CF6;
    --parchment-cream: #F5F0E8;
    --aged-vellum: #D4C9B0;
    --forest-shadow: #1C3A2E;
    --gold-leaf: #C9A84C;
    --deep-carmine: #8B1A1A;
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    background: var(--midnight-ink);
    color: var(--parchment-cream);
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.2vw, 1.15rem);
    line-height: 1.75;
    letter-spacing: 0.01em;
    overflow-x: hidden;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

::selection {
    background: rgba(139, 92, 246, 0.25);
}

/* Sidebar Navigation */
.sidebar-nav {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3rem;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2rem;
}

.sidebar-link {
    writing-mode: vertical-rl;
    text-orientation: mixed;
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    color: var(--aged-vellum);
    text-decoration: none;
    opacity: 0.4;
    transition: opacity 300ms ease, color 300ms ease;
}

.sidebar-link:hover {
    opacity: 1;
    color: var(--aurora-green);
}

/* Aurora Background */
.aurora-bg {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, var(--aurora-violet), var(--aurora-green), var(--aurora-rose), var(--gold-leaf));
    background-size: 400% 400%;
    animation: auroraShift 20s ease infinite;
    opacity: 0.12;
    z-index: 0;
}

.aurora-interstitial { opacity: 0.18; }
.aurora-intense { opacity: 0.35; animation-duration: 10s; }

@keyframes auroraShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Chapter Base */
.chapter {
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    padding: clamp(4rem, 8vw, 8rem);
    padding-left: 4rem;
}

.interstitial {
    min-height: 40vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aurora-chapter {
    min-height: 50vh;
}

/* Chapter Reveal */
.chapter-reveal {
    opacity: 0;
    transform: translateY(2rem);
    transition: opacity 800ms ease-out, transform 800ms ease-out;
}

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

/* Ghost Letterforms */
.ghost-letter {
    position: absolute;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: 50vw;
    color: var(--parchment-cream);
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
    top: 10%;
    left: 10%;
    transform: rotate(-8deg);
    line-height: 1;
}

.ghost-letter-alt {
    left: auto;
    right: 5%;
    transform: rotate(12deg);
}

/* Vine Paths */
.vine-path {
    stroke-dasharray: 1000;
    stroke-dashoffset: 1000;
    transition: stroke-dashoffset 1.5s ease-out;
}

.chapter.vines-drawn .vine-path,
.chapter-reveal.visible .vine-path {
    stroke-dashoffset: 0;
}

.vine-glow {
    filter: drop-shadow(0 0 4px rgba(45, 212, 168, 0.2));
}

/* Cartouche */
.cartouche {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.vine-spiral {
    position: absolute;
    width: 60vw;
    max-width: 600px;
    height: 60vw;
    max-height: 600px;
    opacity: 0.5;
    z-index: 0;
}

.cartouche-content {
    position: relative;
    z-index: 2;
}

.cartouche-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 300;
    font-size: clamp(3rem, 8vw, 8rem);
    letter-spacing: -0.02em;
    line-height: 1.15;
    color: var(--parchment-cream);
}

.fleuron-down {
    font-size: 1.5rem;
    color: var(--gold-leaf);
    opacity: 0.5;
    margin-top: 2rem;
    animation: fleuron-pulse 4s ease-in-out infinite;
}

@keyframes fleuron-pulse {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.7; }
}

/* Editorial Grid */
.editorial-grid {
    display: grid;
    gap: 2rem;
    position: relative;
    z-index: 2;
    max-width: 1000px;
    margin: 0 auto;
}

.editorial-odd {
    grid-template-columns: 1fr 0.55fr;
}

.editorial-even {
    grid-template-columns: 0.55fr 1fr;
}

/* Body Text */
.body-text {
    color: var(--parchment-cream);
    max-width: 680px;
}

.body-text + .body-text {
    text-indent: 2em;
}

.body-first {
    text-indent: 0;
}

/* Drop Cap */
.drop-cap-wrapper {
    float: left;
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: clamp(4rem, 8vw, 7rem);
    line-height: 0.8;
    color: var(--aurora-rose);
    margin-right: 0.5rem;
    margin-top: 0.1em;
    text-shadow: 2px 2px 0 rgba(11, 14, 42, 0.3);
}

.margin-drop {
    color: var(--aurora-violet);
}

/* Sidebar */
.editorial-sidebar {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-top: 2rem;
}

.vine-border {
    width: 40px;
    height: auto;
    margin: 0 auto;
}

.sidebar-quote {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 1.1rem;
    line-height: 1.5;
    color: var(--aurora-green);
    border-left: 2px solid rgba(45, 212, 168, 0.3);
    padding-left: 1rem;
}

.sidebar-annotation {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--aged-vellum);
    opacity: 0.7;
}

/* Wax Seal */
.wax-seal {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 35%, #B02020, var(--deep-carmine), #601010);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3rem auto 0;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.wax-seal span {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 700;
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.3);
}

.wax-seal-final {
    margin-top: 2rem;
    width: 4rem;
    height: 4rem;
}

.wax-seal-final span {
    font-size: 1.4rem;
}

/* Interstitial */
.tessellation-overlay {
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M30 5 Q40 15 30 25 Q20 15 30 5Z' fill='none' stroke='%23C9A84C' stroke-width='0.5' opacity='0.15'/%3E%3C/svg%3E");
    opacity: 0.3;
    z-index: 0;
}

.interstitial-text {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 400;
    font-style: italic;
    font-size: clamp(1.4rem, 3vw, 2.5rem);
    color: var(--parchment-cream);
    text-align: center;
    max-width: 25ch;
    position: relative;
    z-index: 2;
}

/* Marginalia Chapter */
.editorial-imagery {
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-composition {
    width: 100%;
    max-width: 500px;
    height: auto;
}

.editorial-margin {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.margin-text {
    font-family: 'Lora', serif;
    font-size: 0.95rem;
    line-height: 1.6;
    color: var(--aged-vellum);
}

.margin-text + .margin-text {
    text-indent: 2em;
}

/* Aurora Vines */
.aurora-vines {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Colophon */
.colophon-chapter {
    min-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--midnight-ink);
}

.colophon-content {
    text-align: center;
    max-width: 42rem;
    position: relative;
    z-index: 2;
}

.vine-rule {
    width: 200px;
    height: 30px;
    margin: 1.5rem auto;
    display: block;
}

.colophon-title {
    font-family: 'Cormorant Garamond', serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 4vw, 3rem);
    letter-spacing: -0.02em;
    color: var(--parchment-cream);
    margin-bottom: 1.5rem;
}

.colophon-text {
    font-family: 'EB Garamond', serif;
    font-style: italic;
    font-size: 1rem;
    line-height: 1.7;
    color: var(--aged-vellum);
    max-width: 45ch;
    margin: 0 auto 1rem;
}

.colophon-ornaments {
    font-size: 1.5rem;
    color: var(--gold-leaf);
    margin: 1.5rem 0;
    opacity: 0.6;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar-nav { display: none; }

    .chapter {
        padding: 3rem 1.5rem;
    }

    .editorial-odd,
    .editorial-even {
        grid-template-columns: 1fr;
    }

    .ghost-letter { font-size: 80vw; opacity: 0.02; }

    .vine-spiral { width: 80vw; height: 80vw; }

    .media-composition { max-width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .aurora-bg { animation: none; }
    .fleuron-down { animation: none; opacity: 0.5; }

    .chapter-reveal {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .vine-path {
        stroke-dashoffset: 0;
        transition: none;
    }
}
