/* ==========================================================================
   Halloween (October only) — cobwebs, hanging spider, bat, jumpscare overlay.
   Markup: Components/Shared/{SeasonalEffects,Cobweb,HangingSpider}.razor,
   Login.razor (card webs); behaviour: wwwroot/js/halloween.js.
   Everything decorative is pointer-events:none — it must never block a click.
   ========================================================================== */

:root {
    --vk-web: rgba(70, 70, 84, 0.34);
    --vk-spider: #1d1b24;
    --vk-bat: #2a2433;
}
[data-theme="dark"] {
    --vk-web: rgba(226, 226, 238, 0.26);
    --vk-spider: #0c0b10;
    --vk-bat: #0e0c13;
}

.vk-cobweb { color: var(--vk-web); display: block; }

/* ---- Staff platform layer: viewport corners ---------------------------- */
/* Above the sticky top bar (9999) so the webs drape over its corners; still
   click-through, and the jumpscare overlay sits far above. */
.vk-halloween-layer {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10000;
    overflow: hidden;
}
.vk-web-corner { position: absolute; }
.vk-web-tl { top: 0; left: 0; }
.vk-web-tr { top: 0; right: 0; }
.vk-web-bl { bottom: 0; left: 0; opacity: 0.7; }

.vk-spider {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--vk-spider);
    transform-origin: top center;
    animation: vk-spider-bob 6s ease-in-out infinite;
}
.vk-spider-thread {
    width: 1px;
    height: var(--thread, 70px);
    background: var(--vk-web);
}
.vk-spider-body { margin-top: -3px; }
.vk-spider-tr { top: 0; right: 92px; }

@keyframes vk-spider-bob {
    0%, 100% { transform: translateY(0) rotate(0deg); }
    30% { transform: translateY(14px) rotate(3deg); }
    55% { transform: translateY(6px) rotate(-2deg); }
    75% { transform: translateY(18px) rotate(1deg); }
}

/* Bats: the outer div flies the path, the wings flap around the shoulders,
   the body bobs a little against each beat. */
.vk-bat {
    position: absolute;
    top: 18%;
    left: -70px;
    color: var(--vk-bat);
    opacity: 0;
    animation: vk-bat-fly 46s linear infinite 8s;
}
.vk-bat svg { display: block; overflow: visible; }
.vk-bat-wing {
    transform-box: fill-box;
    animation: vk-bat-flap 0.26s ease-in-out infinite alternate;
}
.vk-bat-wing-l { transform-origin: 100% 60%; }
.vk-bat-wing-r { transform-origin: 0% 60%; animation-name: vk-bat-flap-r; }
.vk-bat-body {
    transform-box: fill-box;
    transform-origin: 50% 50%;
    animation: vk-bat-bob 0.26s ease-in-out infinite alternate;
}
@keyframes vk-bat-flap {
    from { transform: rotate(-28deg) scaleY(1); }
    to { transform: rotate(32deg) scaleY(0.7); }
}
@keyframes vk-bat-flap-r {
    from { transform: rotate(28deg) scaleY(1); }
    to { transform: rotate(-32deg) scaleY(0.7); }
}
@keyframes vk-bat-bob {
    from { transform: translateY(1.5px); }
    to { transform: translateY(-1.5px); }
}
@keyframes vk-bat-fly {
    0% { transform: translate(0, 0) rotate(4deg); opacity: 0; }
    1% { opacity: 0.9; }
    3% { transform: translate(28vw, -5vh) rotate(-6deg); }
    5% { transform: translate(55vw, 3vh) rotate(5deg); }
    7% { transform: translate(82vw, -6vh) rotate(-4deg); }
    9% { transform: translate(112vw, 0) rotate(3deg); opacity: 0.9; }
    9.5%, 100% { transform: translate(112vw, 0); opacity: 0; }
}
/* second, smaller bat: higher, later, on its own rhythm */
.vk-bat--2 { top: 9%; animation-duration: 58s; animation-delay: 27s; }
.vk-bat--2 .vk-bat-wing, .vk-bat--2 .vk-bat-body { animation-duration: 0.21s; }

/* Phones: smaller webs, no bottom web, spider closer to the corner. */
@media (max-width: 767.98px) {
    .vk-web-tl { width: 90px; height: 90px; }
    .vk-web-tr { width: 110px; height: 110px; }
    .vk-spider-tr { right: 54px; }
    .vk-spider-tr .vk-spider-thread { height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
    .vk-spider, .vk-bat, .vk-bat-wing, .vk-bat-body { animation: none; }
    .vk-bat { display: none; }
}

/* ---- Login card ---------------------------------------------------------- */
.login-webs { position: absolute; inset: 0; pointer-events: none; z-index: 2; border-radius: inherit; overflow: hidden; }
.login-webs .vk-cobweb { position: absolute; }
.login-webs .lw-tl { top: -1px; left: -1px; }
.login-webs .lw-br { bottom: -1px; right: -1px; }
.login-webs .vk-spider { left: 46px; top: 0; }
/* the login card is dark — webs a touch brighter there */
.login-card .vk-cobweb { color: rgba(235, 235, 245, 0.22); }
.login-card .vk-spider { color: #0b0a0f; }
.login-card .vk-spider-thread { background: rgba(235, 235, 245, 0.3); }

.login-container .vk-cobweb.lc-corner { position: fixed; pointer-events: none; color: rgba(235, 235, 245, 0.14); }
.login-container .lc-tl { top: 0; left: 0; }
.login-container .lc-tr { top: 0; right: 0; }

/* Pumpkin glow on the login card */
.seasonal-decoration.halloween { animation: vk-pumpkin-glow 3.2s ease-in-out infinite; }
@keyframes vk-pumpkin-glow {
    0%, 100% { filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)) drop-shadow(0 0 6px rgba(255,140,0,0.25)); }
    50% { filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)) drop-shadow(0 0 18px rgba(255,140,0,0.65)); }
}
@media (prefers-reduced-motion: reduce) {
    .seasonal-decoration.halloween { animation: none; }
}

/* ---- Haunting: lights flicker + a ghost loops the screen (halloween.js) ------
   The dim layer is click-through so work is never blocked. The flicker plan (opacity
   steps) is driven from halloween.js: dips >= 360 ms apart (< 3 flashes per second),
   darkest ~0.7 (low contrast). */
.vk-haunt {
    position: fixed;
    inset: 0;
    z-index: 2147483640;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 50% 45%, rgba(12, 6, 26, 0.72) 0%, rgba(2, 1, 6, 0.97) 70%);
    opacity: 0;
}
.vk-haunt.is-leaving { opacity: 0; transition: opacity 0.8s ease; }

/* glitch band: a thin slice that shows for ~0.1 s on some dark snaps */
.vk-glitch {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgba(160, 255, 230, 0.35), rgba(255, 80, 160, 0.3), transparent);
    mix-blend-mode: screen;
    opacity: 0;
}
.vk-glitch.on { opacity: 1; }

/* ghost: outer = flight path around the screen, inner = bob/wobble */
.vk-ghost {
    position: fixed;
    left: 0;
    top: 0;
    width: clamp(120px, 16vw, 220px);
    z-index: 2147483645;
    cursor: pointer;
    will-change: transform;
    animation: vk-ghost-fade 1.1s ease-in-out both;
}
@keyframes vk-ghost-fade { from { opacity: 0; } to { opacity: .95; } }
.vk-ghost svg { transform-origin: 50% 8%; }
.vk-ghost svg { width: 100%; height: auto; display: block; overflow: visible; }
.vk-ghost-bob { animation: vk-ghost-bob 1.6s ease-in-out infinite; }
/* mouth: scaled from halloween.js by the moan recording's syllables (shut "w" -> wide "O") */
.vk-ghost .vkg-mouth { transform-box: fill-box; transform-origin: 50% 30%; transform: scale(.75, .45); transition: transform 30ms linear; }

@keyframes vk-ghost-path {
    0%   { transform: translate(-25vw, 60vh) rotate(-8deg) scale(.8); opacity: 0; }
    10%  { opacity: .95; }
    25%  { transform: translate(30vw, 18vh) rotate(6deg) scale(1); }
    45%  { transform: translate(68vw, 48vh) rotate(-6deg) scale(1.15); }
    62%  { transform: translate(40vw, 62vh) rotate(4deg) scale(1.3); }
    80%  { transform: translate(14vw, 26vh) rotate(-4deg) scale(1.05); opacity: .95; }
    100% { transform: translate(55vw, -45vh) rotate(8deg) scale(.7); opacity: 0; }
}
@keyframes vk-ghost-path-r {
    0%   { transform: translate(110vw, 55vh) rotate(8deg) scale(.8); opacity: 0; }
    10%  { opacity: .95; }
    25%  { transform: translate(55vw, 16vh) rotate(-6deg) scale(1); }
    45%  { transform: translate(14vw, 46vh) rotate(6deg) scale(1.15); }
    62%  { transform: translate(44vw, 62vh) rotate(-4deg) scale(1.3); }
    80%  { transform: translate(70vw, 24vh) rotate(4deg) scale(1.05); opacity: .95; }
    100% { transform: translate(30vw, -45vh) rotate(-8deg) scale(.7); opacity: 0; }
}
@keyframes vk-ghost-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}
@keyframes vk-ghost-arm { from { transform: rotate(-10deg); } to { transform: rotate(14deg); } }
@keyframes vk-ghost-arm-r { from { transform: rotate(10deg); } to { transform: rotate(-14deg); } }
/* veil behind the ghost: the page goes soft, cold and desaturated; harder during bursts */
.vk-ghost-veil {
    position: fixed;
    inset: 0;
    z-index: 2147483640;
    pointer-events: none;
    background: rgba(10, 14, 30, 0.18);
    -webkit-backdrop-filter: blur(2.5px) saturate(.55) brightness(.82);
    backdrop-filter: blur(2.5px) saturate(.55) brightness(.82);
    opacity: 0;
    animation: vk-veil-in 1.5s ease-in both;
}
.vk-ghost-veil.is-glitching {
    -webkit-backdrop-filter: blur(6px) saturate(.25) brightness(.7) hue-rotate(-25deg);
    backdrop-filter: blur(6px) saturate(.25) brightness(.7) hue-rotate(-25deg);
}
.vk-ghost-veil.is-leaving { animation: none; opacity: 0; transition: opacity 0.8s ease; }
@keyframes vk-veil-in { from { opacity: 0; } to { opacity: 1; } }

/* background glitch: the whole page (not the ghost — it lives outside .page) is torn into
   horizontal bands with an RGB split by the SVG filter halloween.js injects; only on during
   90–320 ms bursts, re-seeded every ~45 ms so it jumps instead of easing. */
.vk-page-glitch { filter: url(#vk-glitch-filter); }

.vk-ghost.is-leaving { animation: none; opacity: 0; transition: opacity 0.8s ease; }

.vk-scare-note {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100vw - 32px);
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    background: #1b1622;
    color: #f5f3f7;
    font: 500 0.85rem/1.3 'Inter', Roboto, sans-serif;
    box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}
.vk-scare-note button {
    border: 1px solid rgba(255,255,255,0.25);
    background: transparent;
    color: inherit;
    border-radius: 999px;
    padding: 0.2rem 0.7rem;
    font: inherit;
    font-size: 0.78rem;
    cursor: pointer;
}
.vk-scare-note button:hover { background: rgba(255,255,255,0.1); }
