/* ==========================================================
   TERROR LAYER (permanent) - Los Libros de Efrén
   The dark modal, blood drips, blinking eyes and warning line
   for books in the Terror / Horror genre. Not tied to the season.
   Everything is scoped to #bookModal.tr-modal, which terror.js
   adds only when the open book is Terror.
   ========================================================== */

#bookModal.tr-modal .modal-content {
    background: #050407;
    color: #eadfcb;
    box-shadow: 0 0 0 3px rgba(140, 60, 200, 0.6), 0 25px 60px rgba(60, 10, 100, 0.55);
}
#bookModal.tr-modal .modal-sticky-header {
    background: #050407;
    border-bottom: 3px solid #8b0a14;
}
#bookModal.tr-modal .modal-scrollable-body { padding-top: 44px; } /* room for the drips */
#bookModal.tr-modal #m-title {
    color: #f1e9d8;
    text-shadow: 0 0 14px rgba(190, 20, 40, 0.55);
}
#bookModal.tr-modal #m-author,
#bookModal.tr-modal #m-isbn { color: #b9a9c9 !important; }
#bookModal.tr-modal #m-desc { color: #d8cdbd; }
#bookModal.tr-modal #m-desc strong { color: #E8751A !important; }
#bookModal.tr-modal #m-price { color: #f1e9d8; }
#bookModal.tr-modal .btn-close-custom { background: #1c1420; color: #f1e9d8; }
#bookModal.tr-modal .btn-close-custom:hover { background: #2e2036; }
#bookModal.tr-modal .share-btn { border-color: #f1e9d8; color: #f1e9d8; }
#bookModal.tr-modal .share-btn:hover { background: #f1e9d8; color: #050407; }
#bookModal.tr-modal #m-add-btn { background: #8b0a14; border-color: #8b0a14; color: #f1e9d8; }
#bookModal.tr-modal #m-add-btn:hover:not(:disabled) { background: #b31220; border-color: #b31220; }
#bookModal.tr-modal #m-img {
    box-shadow: 0 0 0 3px rgba(150, 70, 210, 0.7), 0 0 32px rgba(120, 40, 170, 0.55) !important;
}

/* Flickering vignette over the whole modal */
#bookModal.tr-modal .modal-content::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1050;
    background: radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 40%, rgba(0, 0, 0, 0.7) 100%);
    animation: trFlicker 6s steps(1) infinite;
}
@keyframes trFlicker {
    0%, 100% { opacity: 1; }
    92% { opacity: 0.55; }
    94% { opacity: 1; }
    96% { opacity: 0.4; }
    98% { opacity: 1; }
}

/* Blood dripping from the header */
.tr-drips {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 0;
    pointer-events: none;
    display: none;
}
#bookModal.tr-modal .tr-drips { display: block; }
.tr-drip {
    position: absolute;
    top: 0;
    width: 7px;
    height: 0;
    background: #8b0a14;
    border-radius: 0 0 4px 4px;
}
.tr-drip::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: -2px;
    width: 11px;
    height: 11px;
    border-radius: 50%;
    background: #8b0a14;
}
#bookModal.tr-modal.show .tr-drip {
    animation: trDripGrow 3.5s cubic-bezier(0.3, 0.1, 0.3, 1) forwards;
}
@keyframes trDripGrow {
    from { height: 0; }
    to   { height: var(--h); }
}

/* Random warning line */
.tr-warning {
    display: block;
    width: fit-content;
    max-width: 100%;
    margin: 6px 0 12px;
    padding: 4px 12px;
    border: 1px dashed rgba(232, 117, 26, 0.7);
    border-radius: 20px;
    background: rgba(232, 117, 26, 0.08);
    color: #E8751A;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* Two eyes that blink in the corner now and then */
.tr-eyes {
    position: absolute;
    bottom: 12px;
    left: 14px;
    display: none;
    gap: 7px;
    opacity: 0;
    pointer-events: none;
    z-index: 1061;
}
#bookModal.tr-modal .tr-eyes { display: flex; }
.tr-eyes span {
    width: 9px;
    height: 5px;
    border-radius: 50%;
    background: #ffd34d;
    box-shadow: 0 0 9px 3px rgba(255, 190, 40, 0.85);
}
#bookModal.tr-modal.show .tr-eyes { animation: trEyes 8s ease-in-out infinite; }
/* 8 s cycle: hidden until ~1.9 s after the modal opens, open + two blinks, gone by ~6 s, repeat */
@keyframes trEyes {
    0%, 20%   { opacity: 0; transform: scaleY(1); }
    24%       { opacity: 1; transform: scaleY(1); }
    35%       { transform: scaleY(1); }
    37%       { transform: scaleY(0.1); }
    40%       { transform: scaleY(1); }
    60%       { opacity: 1; transform: scaleY(1); }
    62%       { transform: scaleY(0.1); }
    65%       { transform: scaleY(1); }
    72%       { opacity: 1; }
    76%, 100% { opacity: 0; }
}

/* Reduced motion: static vignette, drips fully grown, eyes visible but not blinking */
@media (prefers-reduced-motion: reduce) {
    #bookModal.tr-modal .modal-content::after,
    #bookModal.tr-modal.show .tr-eyes,
    #bookModal.tr-modal.show .tr-drip {
        animation: none !important;
    }
    #bookModal.tr-modal.show .tr-drip { height: var(--h); }
    #bookModal.tr-modal .tr-eyes { opacity: 1; }
}
