/* Decoración de Halloween para el login y la página de inicio.
   Todo es pointer-events:none salvo el botón de ocultar, el fantasmita y el aviso. */

/* ---------- Capa que se mueve con la página (guirnalda, telarañas, araña) ---------- */
.hwd-root {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 0;
    z-index: 900;
    overflow: visible;
    pointer-events: none;
}

.hwd-garland {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 64px;
    overflow: hidden;
    white-space: nowrap;
    font-size: 0;
}

.hwd-seg {
    position: relative;
    display: inline-block;
    height: 64px;
    vertical-align: top;
}

.hwd-swag {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 28px;
}
.hwd-swag path { stroke: #4a3a68; stroke-width: 2; fill: none; }

/* Cada farolillo cuelga del punto más bajo del festón y se balancea */
.hwd-lamp {
    position: absolute;
    left: 50%;
    top: 13px;
    width: 0;
    height: 0;
    transform-origin: 0 0;
    animation: hwdSway 3.6s ease-in-out infinite alternate;
    animation-delay: var(--hwd-d, 0s);
}
.hwd-lamp::before {
    content: '';
    position: absolute;
    left: -0.5px;
    top: 0;
    width: 1px;
    height: 8px;
    background: #5a4a78;
}
.hwd-lamp-body {
    position: absolute;
    left: -15px;
    top: 7px;
    width: 30px;
}
.hwd-lamp-body::before {
    content: '';
    position: absolute;
    inset: -16px;
    border-radius: 50%;
    background: radial-gradient(circle, var(--hwd-glow, rgba(255, 150, 40, 0.7)) 0%, transparent 65%);
    animation: hwdFlicker 2.8s ease-in-out infinite;
    animation-delay: var(--hwd-d, 0s);
}
.hwd-lamp-body svg { position: relative; display: block; width: 100%; height: auto; }
.hwd-lamp.is-ghost { --hwd-glow: rgba(160, 200, 255, 0.55); }
.hwd-lamp.is-bat { --hwd-glow: rgba(150, 90, 230, 0.4); }

/* En el inicio se dejan libres las esquinas (logo y acciones de la cabecera) */
.hwd-home .hwd-garland { left: 120px; width: calc(100% - 240px); }
.hwd-home .hwd-web { width: min(8vw, 100px); }
.hwd-home .hwd-spider { display: none; }

/* Telarañas en las esquinas */
.hwd-web {
    position: absolute;
    top: 0;
    width: min(20vw, 170px);
    aspect-ratio: 1;
    opacity: 0.5;
    stroke: #6f6f8f;
}
.hwd-web svg { display: block; width: 100%; height: 100%; }
.hwd-web-l { left: 0; }
.hwd-web-r { right: 0; transform: scaleX(-1); }

/* Araña que sube y baja por su hilo */
.hwd-spider {
    position: absolute;
    top: 6px;
    right: min(20vw, 178px);
    width: 26px;
    animation: hwdSpider 7s ease-in-out infinite;
}
.hwd-spider::before {
    content: '';
    position: absolute;
    left: 50%;
    bottom: 100%;
    width: 1px;
    height: 140px;
    background: #8a8aa6;
}
.hwd-spider svg { display: block; width: 100%; height: auto; }

/* ---------- Capa fija (login: cementerio y niebla; murciélagos en ambas) ---------- */
.hwd-fixed {
    position: fixed;
    inset: 0;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
}

.hwd-tint {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse at 50% 112%, rgba(255, 120, 20, 0.16), transparent 55%),
        radial-gradient(ellipse at 50% -12%, rgba(96, 38, 158, 0.14), transparent 55%);
}

.hwd-fogline {
    position: absolute;
    left: -10%;
    right: -10%;
    bottom: 0;
    height: 30vh;
    filter: blur(12px);
    background:
        radial-gradient(ellipse at 28% 100%, rgba(120, 70, 190, 0.2), transparent 60%),
        radial-gradient(ellipse at 74% 100%, rgba(255, 140, 40, 0.14), transparent 60%);
    animation: hwdFog 12s ease-in-out infinite alternate;
}

.hwd-grave {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: clamp(90px, 16vh, 170px);
}
.hwd-grave svg { display: block; width: 100%; height: 100%; }

.hwd-ghost {
    position: absolute;
    left: 2%;
    bottom: 24%;
    width: 56px;
    opacity: 0.6;
    cursor: pointer;
    pointer-events: auto;
    animation: hwdGhostBob 5s ease-in-out infinite;
}
.hwd-ghost svg { display: block; width: 100%; height: auto; filter: drop-shadow(0 0 8px rgba(150, 190, 255, 0.7)); }
.hwd-bubble {
    position: absolute;
    left: 50%;
    bottom: 100%;
    padding: 4px 10px;
    border-radius: 12px;
    background: #fff;
    color: #2a1150;
    font: 700 13px/1.2 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    transform: translateX(-50%);
    animation: hwdBubble 1.6s ease-out both;
}

.hwd-bat {
    position: absolute;
    left: 0;
    width: 34px;
    fill: #24123a;
    pointer-events: none;
    filter: drop-shadow(0 0 5px rgba(255, 140, 40, 0.6));
}
.hwd-bat svg { display: block; width: 100%; animation: hwdFlap 0.3s ease-in-out infinite; }

/* ---------- Botón para ocultar/mostrar y aviso de bienvenida ---------- */
.hwd-toggle {
    position: fixed;
    left: 24px;
    bottom: 92px;
    z-index: 9998;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.88);
    font-size: 17px;
    line-height: 1;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.hwd-toggle:hover { opacity: 1; transform: scale(1.08); }
.hwd-toggle.is-off { opacity: 0.4; filter: grayscale(1); }

.hwd-greet {
    position: fixed;
    left: 14px;
    bottom: 140px;
    z-index: 9998;
    max-width: min(340px, calc(100vw - 28px));
    padding: 14px 34px 12px 16px;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, #2a1150 0%, #6a1b9a 60%, #f26a0d 145%);
    box-shadow: 0 10px 30px rgba(42, 17, 80, 0.4);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    animation: hwdGreetIn 0.5s ease both;
}
.hwd-greet-title { margin: 0 0 4px; font-size: 1rem; font-weight: 700; }
.hwd-greet-text { margin: 0; font-size: 0.85rem; line-height: 1.4; opacity: 0.95; }
.hwd-greet-off {
    margin-top: 8px;
    padding: 0;
    border: none;
    background: none;
    color: #ffd9a8;
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
}
.hwd-greet-close {
    position: absolute;
    top: 6px;
    right: 8px;
    width: 24px;
    height: 24px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.hwd-greet-close:hover { background: rgba(255, 255, 255, 0.18); }
.hwd-greet.is-leaving { animation: hwdGreetOut 0.3s ease both; }

@keyframes hwdSway { from { transform: rotate(-5deg); } to { transform: rotate(5deg); } }
@keyframes hwdFlicker { 0%, 100% { opacity: 1; } 40% { opacity: 0.7; } 65% { opacity: 0.92; } }
@keyframes hwdSpider { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(52px); } }
@keyframes hwdFog { from { transform: translateX(-4%); } to { transform: translateX(4%); } }
@keyframes hwdGhostBob {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50% { transform: translateY(-14px) rotate(3deg); }
}
@keyframes hwdBubble {
    0% { opacity: 0; transform: translate(-50%, 6px) scale(0.8); }
    15% { opacity: 1; transform: translate(-50%, 0) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -6px); }
}
@keyframes hwdFlap { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.45); } }
@keyframes hwdGreetIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }
@keyframes hwdGreetOut { from { opacity: 1; } to { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1100px) {
    .hwd-ghost { display: none; }
}

@media (max-width: 600px) {
    .hwd-spider { display: none; }
}

/* Sin movimiento para quien lo tiene desactivado en el sistema */
@media (prefers-reduced-motion: reduce) {
    .hwd-lamp,
    .hwd-lamp-body::before,
    .hwd-spider,
    .hwd-fogline,
    .hwd-ghost,
    .hwd-bat svg,
    .hwd-greet {
        animation: none;
    }
}
