/* chronicle.css — Cronaca delle Ombre: overlay pergamena al momento del sonno */

@import url('https://fonts.googleapis.com/css2?family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

/* ── Overlay base ──────────────────────────────────────────────────────────── */
#chronicle-overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(4, 3, 2, 0.72);
    animation: chronicle-fade-in 0.9s ease forwards;
}

#chronicle-overlay.visible {
    display: flex;
}

#chronicle-overlay.fading-out {
    animation: chronicle-fade-out 1.4s ease forwards;
}

@keyframes chronicle-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes chronicle-fade-out {
    0%   { opacity: 1; filter: blur(0px); }
    60%  { opacity: 0.6; filter: blur(3px); }
    100% { opacity: 0; filter: blur(8px); }
}

/* ── Pergamena ─────────────────────────────────────────────────────────────── */
#chronicle-scroll {
    position: relative;
    width: 300px;
    overflow: hidden;
    padding: 28px 24px 22px;
    box-sizing: border-box;

    background-color: #c8a96e;
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.65' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix type='saturate' values='0'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.12'/%3E%3C/svg%3E");

    border-radius: 3px;
    box-shadow:
        0 0 0 2px #8a6630,
        0 0 0 4px #5a3e18,
        0 8px 32px rgba(0,0,0,0.7),
        inset 0 0 40px rgba(80,40,0,0.18);
}

/* Bordi arrotolati superiore e inferiore */
#chronicle-scroll::before,
#chronicle-scroll::after {
    content: '';
    display: block;
    position: absolute;
    left: -4px; right: -4px;
    height: 14px;
    background: linear-gradient(to bottom, #7a5228, #b8884a);
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.5);
    z-index: 2;
}
#chronicle-scroll::before { top: -5px; }
#chronicle-scroll::after  { bottom: -5px; }

/* ── Testo ─────────────────────────────────────────────────────────────────── */
#chronicle-text {
    position: relative;
    z-index: 1;
    font-family: 'Crimson Text', 'Georgia', serif;
    font-size: 13.5px;
    line-height: 1.65;
    color: #2a1800;
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
    min-height: 60px;
    max-height: min(340px, 55vh);
    overflow-y: auto;
}

/* Cursore lampeggiante durante il typewriter */
#chronicle-cursor {
    display: inline-block;
    width: 1px;
    height: 1.1em;
    background: #5a3010;
    vertical-align: text-bottom;
    margin-left: 1px;
    animation: chronicle-blink 0.85s step-end infinite;
}

@keyframes chronicle-blink {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0; }
}

/* ── Pulsante svegliati ────────────────────────────────────────────────────── */
#chronicle-wake-btn {
    display: none;
    margin-top: 14px;
    width: 100%;
    padding: 6px 0;
    background: transparent;
    border: 1px solid #7a5228;
    border-radius: 2px;
    color: #5a3010;
    font-family: 'Crimson Text', serif;
    font-size: 12px;
    font-style: italic;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    position: relative;
    z-index: 3;
}

#chronicle-wake-btn:hover {
    background: rgba(90,48,16,0.12);
    color: #2a1000;
}
