/* ═══════════ Love Letter Scroll — Aged Paper ═══════════ */
.scroll-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: 2rem;
}

.scroll-parchment {
    position: relative;
    width: 92%;
    max-width: 580px;
    max-height: 82vh;
    overflow-y: auto;
    overflow-x: hidden;
    border-radius: 3px;

    /* Layered aged paper — warm, uneven, lived-in */
    background:
        /* top-edge darkening (shadow from a fold) */
        linear-gradient(180deg,
            rgba(160, 120, 60, 0.12) 0%,
            transparent 8%
        ),
        /* bottom-edge darkening */
        linear-gradient(0deg,
            rgba(140, 105, 50, 0.10) 0%,
            transparent 6%
        ),
        /* left-edge foxing (age discoloration) */
        linear-gradient(90deg,
            rgba(170, 130, 70, 0.09) 0%,
            transparent 12%
        ),
        /* right-edge foxing */
        linear-gradient(270deg,
            rgba(165, 125, 65, 0.07) 0%,
            transparent 10%
        ),
        /* warm center-to-edge vignette */
        radial-gradient(ellipse at 45% 40%,
            #f7eed8 0%,
            #f2e4c6 30%,
            #ecdab0 60%,
            #e5d1a3 80%,
            #ddc898 100%
        );

    box-shadow:
        /* main drop shadow */
        0 6px 40px rgba(0, 0, 0, 0.45),
        0 2px 12px rgba(0, 0, 0, 0.2),
        /* inner warmth glow */
        inset 0 0 80px rgba(180, 140, 70, 0.06),
        /* edge definition */
        inset 0 1px 0 rgba(255, 245, 220, 0.5),
        inset 0 -1px 0 rgba(140, 105, 50, 0.15),
        inset 1px 0 0 rgba(255, 245, 220, 0.3),
        inset -1px 0 0 rgba(140, 105, 50, 0.1);

    /* Start collapsed, will animate open */
    clip-path: inset(0 0 100% 0);
    transition: clip-path 8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.scroll-parchment.unrolling {
    clip-path: inset(0 0 0% 0);
}

/* Scrollbar styling for the parchment */
.scroll-parchment::-webkit-scrollbar { width: 4px; }
.scroll-parchment::-webkit-scrollbar-track { background: rgba(180, 140, 70, 0.08); }
.scroll-parchment::-webkit-scrollbar-thumb { background: rgba(160, 120, 60, 0.25); border-radius: 2px; }

/* ── Paper grain / fiber texture ── */
.paper-grain {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: 0.45;
    mix-blend-mode: multiply;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='5' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.35'/%3E%3C/svg%3E");
}

/* ── Coffee / tea stain marks ── */
.paper-stain {
    position: absolute;
    pointer-events: none;
    z-index: 0;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 3s ease-in 4s;
}

.scroll-parchment.unrolling .paper-stain {
    opacity: 1;
}

.paper-stain-1 {
    width: 90px;
    height: 80px;
    bottom: 12%;
    left: 6%;
    background: radial-gradient(ellipse at center,
        rgba(165, 120, 60, 0.09) 0%,
        rgba(165, 120, 60, 0.05) 40%,
        rgba(165, 120, 60, 0.02) 65%,
        transparent 100%
    );
    transform: rotate(-15deg);
}

.paper-stain-2 {
    width: 60px;
    height: 55px;
    top: 18%;
    right: 28%;
    background: radial-gradient(ellipse at center,
        rgba(150, 110, 55, 0.07) 0%,
        rgba(150, 110, 55, 0.03) 50%,
        transparent 100%
    );
    transform: rotate(25deg);
}

/* ── Fold crease line ── */
.paper-fold {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 1px;
    pointer-events: none;
    z-index: 0;
    background: linear-gradient(180deg,
        transparent 0%,
        rgba(140, 105, 50, 0.06) 15%,
        rgba(140, 105, 50, 0.10) 50%,
        rgba(140, 105, 50, 0.06) 85%,
        transparent 100%
    );
    box-shadow:
        -1px 0 0 rgba(255, 245, 220, 0.15),
        1px 0 0 rgba(140, 105, 50, 0.04);
}

/* ═══════ Pinned Photo ═══════ */
.scroll-pinned-photo {
    position: absolute;
    top: 14px;
    right: 18px;
    z-index: 3;
    width: 110px;
    /* Start hidden, animated in by JS */
    opacity: 0;
    transform-origin: 80% 8px;
    transform: rotate(-5deg) translateY(-40px);
}

.scroll-pinned-photo.swing-in {
    animation: photoSwingIn 1.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes photoSwingIn {
    0% {
        opacity: 0;
        transform: rotate(-25deg) translateY(-60px) scale(0.7);
    }
    30% {
        opacity: 1;
        transform: rotate(6deg) translateY(4px) scale(1.02);
    }
    55% {
        transform: rotate(-4deg) translateY(-2px) scale(1);
    }
    75% {
        transform: rotate(2deg) translateY(1px);
    }
    100% {
        opacity: 1;
        transform: rotate(-4deg) translateY(0);
    }
}

/* Landed state — stays visible, gentle sway */
.scroll-pinned-photo.landed {
    opacity: 1;
    transform: rotate(-4deg);
    animation: photoIdleSway 5s ease-in-out infinite;
}

@keyframes photoIdleSway {
    0%, 100% { transform: rotate(-4deg); }
    35% { transform: rotate(-2deg); }
    65% { transform: rotate(-5deg); }
}

/* The push pin */
.pin {
    position: absolute;
    top: -6px;
    right: 16px;
    z-index: 5;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%,
        #e85050 0%,
        #c93030 50%,
        #a02020 100%
    );
    box-shadow:
        0 2px 6px rgba(0, 0, 0, 0.35),
        inset 0 -2px 3px rgba(0, 0, 0, 0.2),
        inset 0 1px 2px rgba(255, 150, 150, 0.4);
}
/* Pin highlight */
.pin::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 4px;
    width: 5px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 200, 200, 0.5);
}
/* Pin needle shadow on paper */
.pin::before {
    content: '';
    position: absolute;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 8px;
    background: linear-gradient(180deg,
        rgba(80, 80, 80, 0.25) 0%,
        transparent 100%
    );
    border-radius: 0 0 2px 2px;
}

.scroll-photo {
    width: 100%;
    display: block;
    border-radius: 2px;
    object-fit: cover;
    aspect-ratio: 3 / 4;
    /* Photo with white border like a printed snapshot */
    border: 4px solid rgba(255, 252, 245, 0.95);
    box-shadow:
        0 3px 12px rgba(0, 0, 0, 0.25),
        0 1px 4px rgba(0, 0, 0, 0.15);
    filter: saturate(0.9) contrast(1.05);
}

/* ═══════ Letter Content ═══════ */
.scroll-content {
    position: relative;
    z-index: 1;
    padding: 2.2rem 2.8rem 2rem;
    /* Leave room for pinned photo */
    padding-right: 145px;
}

.scroll-date {
    font-family: var(--font-body);
    font-size: 0.72rem;
    font-weight: 300;
    color: rgba(90, 65, 35, 0.45);
    letter-spacing: 0.5px;
    margin-bottom: 1.8rem;
    opacity: 0;
    transition: opacity 1.5s ease-in;
}

.scroll-greeting {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.6rem;
    color: #3a2818;
    margin-bottom: 1rem;
    opacity: 0;
    transition: opacity 1.8s ease-in;
}

.scroll-text {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.35rem;
    line-height: 2.3;
    color: #3a2818;
    opacity: 0;
    transition: opacity 2.5s ease-in;
    /* Simulate ink that bled slightly into paper fibers */
    text-shadow: 0 0 0.5px rgba(40, 25, 10, 0.2);
}

.scroll-closing {
    font-family: var(--font-heading);
    font-style: italic;
    font-size: 1.4rem;
    color: #3a2818;
    margin-top: 1.8rem;
    margin-bottom: 0.3rem;
    opacity: 0;
    transition: opacity 1.8s ease-in;
}

.scroll-signature {
    font-size: 1.8rem;
    color: #c04040;
    opacity: 0;
    transition: opacity 1.5s ease-in;
    filter: drop-shadow(0 0 2px rgba(192, 64, 64, 0.3));
}

/* Visible states triggered by JS */
.scroll-date.visible,
.scroll-greeting.visible,
.scroll-text.visible,
.scroll-closing.visible,
.scroll-signature.visible {
    opacity: 1;
}

/* ═══════ Continue Button ═══════ */
.scroll-continue-btn {
    margin-top: 2rem;
    opacity: 0;
    transition: opacity 1.5s ease-in;
}
.scroll-continue-btn.show {
    opacity: 1;
}

/* ═══════ Responsive ═══════ */
@media (max-width: 768px) {
    .scroll-content {
        padding: 1.8rem 1.6rem 1.5rem;
        padding-right: 120px;
    }
    .scroll-pinned-photo {
        width: 85px;
        top: 12px;
        right: 14px;
    }
    .scroll-text {
        font-size: 1.15rem;
        line-height: 2.1;
    }
    .scroll-greeting, .scroll-closing {
        font-size: 1.35rem;
    }
    .scroll-photo {
        border-width: 3px;
    }
    .pin {
        width: 14px;
        height: 14px;
        right: 12px;
    }
}

@media (max-width: 480px) {
    .scroll-content {
        padding: 1.2rem 1rem 1.2rem;
        padding-right: 100px;
    }
    .scroll-pinned-photo {
        width: 72px;
        top: 10px;
        right: 10px;
    }
    .scroll-text {
        font-size: 0.95rem;
        line-height: 1.9;
    }
    .scroll-greeting, .scroll-closing {
        font-size: 1.15rem;
    }
    .scroll-date {
        font-size: 0.65rem;
    }
}
