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

:root {
    --ultraviolet-ink: #1a0f2a;
    --aged-vellum: #faf6ed;
    --synthetic-coral: #e8725c;
    --electric-teal: #2dd4a8;
    --pale-indigo: #8b7ec8;
    --warm-charcoal: #2c2438;
    --muted-teal: #5b8a8a;
    --diluted-coral: #f4c4b8;
    --neon-orchid: #c77dff;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-size: clamp(1rem, 1.8vw, 1.15rem);
    line-height: 1.72;
    letter-spacing: 0.01em;
    color: var(--warm-charcoal);
    background: var(--ultraviolet-ink);
    overflow-x: hidden;
}

/* === Cover Section === */
.cover {
    position: relative;
    width: 100%;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ultraviolet-ink);
    overflow: hidden;
}

.cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 50% at 30% 40%, rgba(232, 114, 92, 0.2) 0%, transparent 70%),
        radial-gradient(ellipse 40% 60% at 70% 60%, rgba(244, 196, 184, 0.33) 0%, transparent 60%),
        radial-gradient(ellipse 50% 40% at 50% 30%, rgba(139, 126, 200, 0.13) 0%, transparent 65%),
        radial-gradient(ellipse 80% 80% at 20% 80%, rgba(45, 212, 168, 0.08) 0%, transparent 50%);
    animation: coverBloom 3s ease-out forwards;
}

@keyframes coverBloom {
    from { opacity: 0; transform: scale(0.85); }
    to { opacity: 1; transform: scale(1); }
}

.cover::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20vh;
    background: linear-gradient(to bottom, transparent, var(--ultraviolet-ink));
    pointer-events: none;
}

.cover-content {
    text-align: center;
    z-index: 1;
}

.cover-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(4rem, 10vw, 8rem);
    color: var(--aged-vellum);
    text-shadow: 0 0 40px var(--neon-orchid);
    letter-spacing: 0.02em;
    line-height: 1.15;
}

.cover-subtitle {
    font-family: 'Lora', serif;
    font-weight: 400;
    font-style: italic;
    font-size: 1.2rem;
    color: var(--diluted-coral);
    margin-top: 1rem;
}

/* === Main Body === */
.manuscript-body {
    position: relative;
    margin-left: 8vw;
    margin-right: 7vw;
    padding-top: 6rem;
    padding-bottom: 4rem;
}

/* === Marginal Notes === */
.marginal-notes {
    position: fixed;
    left: 1.5vw;
    top: 0;
    height: 100%;
    width: 5vw;
    pointer-events: none;
    z-index: 10;
}

.margin-note {
    position: absolute;
    font-family: 'Kalam', cursive;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--muted-teal);
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    opacity: 0.7;
}

/* === Chapter Sections === */
.chapter {
    margin-bottom: 6rem;
    opacity: 0;
    transform: scale(0.8);
    transition: opacity 0.8s ease, transform 0.8s ease;
}

.chapter.visible {
    opacity: 1;
    transform: scale(1);
}

.chapter-header {
    margin-bottom: 1.5rem;
}

.chapter-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: clamp(1.6rem, 3vw, 2.8rem);
    color: var(--aged-vellum);
    letter-spacing: 0.02em;
    line-height: 1.15;
    position: relative;
}

.chapter-title::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--diluted-coral);
    top: -10px;
    left: -15px;
}

.chapter-title::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--pale-indigo);
    top: -5px;
    right: 20%;
}

.scholarly-ornament {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.5rem;
}

.scholarly-ornament::before,
.scholarly-ornament::after {
    content: '';
    flex: 1;
    height: 1px;
    background: linear-gradient(to right, transparent, var(--pale-indigo), transparent);
}

.fleuron {
    color: var(--pale-indigo);
    font-size: 1.2rem;
}

.chapter-intro {
    max-width: 55ch;
    color: var(--diluted-coral);
    margin-bottom: 2.5rem;
    font-size: 1rem;
    opacity: 0.9;
}

/* === Card Grid === */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2.4rem;
}

.card-grid.has-focus .card:not(.focused) {
    opacity: 0.5;
    filter: blur(1.5px);
}

/* === Cards === */
.card {
    background: var(--aged-vellum);
    border-radius: 4px;
    box-shadow: 0 2px 24px rgba(26, 15, 42, 0.12);
    overflow: hidden;
    position: relative;
    transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
                opacity 0.4s ease,
                filter 0.4s ease;
    animation: cardEntrance 0.6s ease forwards;
    animation-delay: calc(var(--stagger-index) * 100ms);
    opacity: 0;
}

.chapter.visible .card {
    opacity: 1;
}

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

.card:hover,
.card.focused {
    transform: scale(1.06);
    z-index: 5;
}

.card-header {
    height: 100px;
    position: relative;
}

.card-wash-top {
    background: linear-gradient(to bottom, rgba(244, 196, 184, 0.5) 0%, rgba(244, 196, 184, 0) 70%);
}

.card-wash-right {
    background: linear-gradient(to left, rgba(244, 196, 184, 0.5) 0%, rgba(244, 196, 184, 0) 70%);
}

.card-wash-bottom {
    background: linear-gradient(to top, rgba(244, 196, 184, 0.5) 0%, rgba(244, 196, 184, 0) 70%);
}

.card-wash-left {
    background: linear-gradient(to right, rgba(244, 196, 184, 0.5) 0%, rgba(244, 196, 184, 0) 70%);
}

.card-body {
    padding: 1.5rem;
}

.card-title {
    font-family: 'Caveat', cursive;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--warm-charcoal);
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

.card-text {
    font-size: 0.95rem;
    color: var(--warm-charcoal);
    line-height: 1.65;
    margin-bottom: 1rem;
    max-width: 62ch;
}

.card-annotation {
    font-family: 'Kalam', cursive;
    font-weight: 300;
    font-size: 0.8rem;
    color: var(--muted-teal);
    display: block;
}

/* Page fold */
.page-fold {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 24px 24px 0;
    border-color: transparent var(--ultraviolet-ink) transparent transparent;
    opacity: 0.15;
}

/* === Footer === */
.manuscript-footer {
    text-align: center;
    padding: 3rem 2rem;
    border-top: 1px solid rgba(139, 126, 200, 0.2);
    margin: 0 8vw;
}

.footer-text {
    font-family: 'Kalam', cursive;
    font-weight: 300;
    font-size: 0.9rem;
    color: var(--muted-teal);
}

/* === Responsive === */
@media (max-width: 768px) {
    .manuscript-body {
        margin-left: 5vw;
        margin-right: 5vw;
    }

    .marginal-notes {
        display: none;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .manuscript-footer {
        margin: 0 5vw;
    }
}
