/*
 * Christmas decorations (seasonal add-on). Loaded by Views/Shared/_Christmas.cshtml.
 * Decorations are visible only while <html> has the "xmas-on" class (set by christmas.js).
 */

.xmas-hat,
.xmas-lights,
.xmas-snow {
    display: none;
    pointer-events: none;
    user-select: none;
}

/* Santa hat on the logo */
html.xmas-on .xmas-hat {
    display: block;
    position: absolute;
    margin: 0;
    transform: rotate(-12deg);
    transform-origin: 50% 100%;
    z-index: 1;
    pointer-events: auto;
}

html.xmas-on .xmas-hat svg {
    display: block;
    width: 100%;
    height: auto;
    margin: 0;
    overflow: visible;
}

/* String of lights: wire plus two layers of bulbs that twinkle in turns */
html.xmas-on .xmas-lights {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 18px;
    z-index: 90;
    overflow: hidden;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='24'%3E%3Cpath d='M0 3Q30 14 60 3Q90 14 120 3' fill='none' stroke='%23374a3c' stroke-width='1.6'/%3E%3C/svg%3E") repeat-x 0 0 / 90px 18px;
}

html.xmas-on .xmas-lights--nav {
    top: 100%;
    z-index: auto;
}

/* Room for the lights that hang below the fixed navigation bar */
html.xmas-on .navigation ~ .content {
    margin-top: 96px;
}

.xmas-lights__bulbs {
    position: absolute;
    inset: 0;
    background-repeat: repeat-x;
    background-size: 90px 18px;
    animation: xmas-twinkle 1.8s ease-in-out infinite;
}

.xmas-lights__bulbs--a {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='24'%3E%3Cg%3E%3Crect x='13.5' y='6' width='3' height='4' rx='.8' fill='%232b3a2f'/%3E%3Ccircle cx='15' cy='14' r='9' fill='%23e53935' fill-opacity='.2'/%3E%3Cpath d='M15 9.5c-3 0-4 3.5-4 5.5s1.5 4 4 4 4-2 4-4-1-5.500-4-5.500z' fill='%23e53935'/%3E%3C/g%3E%3Cg%3E%3Crect x='73.5' y='6' width='3' height='4' rx='.8' fill='%232b3a2f'/%3E%3Ccircle cx='75' cy='14' r='9' fill='%2343a047' fill-opacity='.2'/%3E%3Cpath d='M75 9.5c-3 0-4 3.5-4 5.5s1.5 4 4 4 4-2 4-4-1-5.500-4-5.500z' fill='%2343a047'/%3E%3C/g%3E%3C/svg%3E");
}

.xmas-lights__bulbs--b {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='24'%3E%3Cg%3E%3Crect x='43.5' y='6' width='3' height='4' rx='.8' fill='%232b3a2f'/%3E%3Ccircle cx='45' cy='14' r='9' fill='%23ffb300' fill-opacity='.2'/%3E%3Cpath d='M45 9.5c-3 0-4 3.5-4 5.5s1.5 4 4 4 4-2 4-4-1-5.500-4-5.500z' fill='%23ffb300'/%3E%3C/g%3E%3Cg%3E%3Crect x='103.5' y='6' width='3' height='4' rx='.8' fill='%232b3a2f'/%3E%3Ccircle cx='105' cy='14' r='9' fill='%231e88e5' fill-opacity='.2'/%3E%3Cpath d='M105 9.5c-3 0-4 3.5-4 5.5s1.5 4 4 4 4-2 4-4-1-5.500-4-5.500z' fill='%231e88e5'/%3E%3C/g%3E%3C/svg%3E");
    animation-delay: -0.9s;
}

@keyframes xmas-twinkle {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

/* Snowfall canvas: below the navigation bars and modals, never receives input */
html.xmas-on .xmas-snow {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 50;
}

/* Easter-egg flurry: above the navigation bars (z-index 100/999), below modals and the toggle */
.xmas-burst {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1020;
    pointer-events: none;
}

/* Snow ground behind the footer (main layout only): the same hills that stand under the trees on the Hours page */
html.xmas-on footer.footer {
    position: relative;
}

html.xmas-on footer.footer::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: -1;
    height: 90px;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 1200 90' preserveAspectRatio='none'%3E%3Cpath d='M0 40C150 10 300 20 450 38S750 18 900 36 1100 28 1200 34V90H0z' fill='%23e7f0f7' stroke='%23cbdce8' vector-effect='non-scaling-stroke'/%3E%3Cpath d='M0 62C170 40 340 56 520 60S850 44 1000 58 1150 52 1200 56V90H0z' fill='%23f6fafd' stroke='%23cbdce8' vector-effect='non-scaling-stroke'/%3E%3C/svg%3E") center bottom / 100% 100% no-repeat;
}

/* The fixed navigation wrapper includes the nav's bottom margin: a transparent strip that would swallow clicks
   meant for the page under the light string. Only the nav bar itself takes input. */
html.xmas-on .navigation {
    pointer-events: none;
}

html.xmas-on .navigation nav {
    pointer-events: auto;
}

/* Holly on the login form corner */
html.xmas-on .main-container form {
    position: relative;
}

html.xmas-on .main-container form::before {
    content: "";
    position: absolute;
    top: -20px;
    left: -6px;
    width: 56px;
    height: 44px;
    pointer-events: none;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='56' height='44' viewBox='0 0 56 44'%3E%3Cpath d='M28 24C20 10 6 10 3 18c-1 6 10 10 25 6z' fill='%232e7d32'/%3E%3Cpath d='M28 24c8-14 22-14 25-6 1 6-10 10-25 6z' fill='%23388e3c'/%3E%3Ccircle cx='24' cy='27' r='5' fill='%23c62828'/%3E%3Ccircle cx='32' cy='28' r='5' fill='%23d32f2f'/%3E%3Ccircle cx='28' cy='33' r='5' fill='%23b71c1c'/%3E%3C/svg%3E") no-repeat 0 0 / contain;
}

/* Loading overlay: the spinner becomes a turning snowflake (the sr-only "Loading..." text stays) */
html.xmas-on #load-spinner {
    border: 0;
    border-radius: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cg id='a'%3E%3Cpath d='M12 2v20M8.6 4.8 12 8l3.4-3.2M8.6 19.2 12 16l3.4 3.2'/%3E%3C/g%3E%3Cg transform='rotate(60 12 12)'%3E%3Cpath d='M12 2v20M8.6 4.8 12 8l3.4-3.2M8.6 19.2 12 16l3.4 3.2'/%3E%3C/g%3E%3Cg transform='rotate(120 12 12)'%3E%3Cpath d='M12 2v20M8.6 4.8 12 8l3.4-3.2M8.6 19.2 12 16l3.4 3.2'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
    animation: xmas-spin 2.4s linear infinite;
}

@keyframes xmas-spin {
    to { transform: rotate(360deg); }
}

@keyframes xmas-pulse {
    0%, 100% { opacity: 0.45; }
    50% { opacity: 1; }
}

/* Toggle button, bottom-right corner. Selectors are specific enough to beat the global button rules of login.css. */
button.xmas-toggle {
    position: fixed;
    right: max(16px, env(safe-area-inset-right));
    bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 2px solid var(--main-color, #1f556d);
    border-radius: 50%;
    background: #fff;
    color: var(--main-color, #1f556d);
    font-size: 16px;
    opacity: 1;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
    transition: transform 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}

button.xmas-toggle[aria-pressed="true"] {
    background: var(--main-color, #1f556d);
    color: #fff;
}

button.xmas-toggle:hover {
    opacity: 1;
    transform: translateY(-2px);
}

button.xmas-toggle:active {
    transform: translateY(0);
}

button.xmas-toggle:focus-visible {
    outline: 3px solid #ffbf47;
    outline-offset: 2px;
}

/* A slash, so the "off" state does not depend on colour alone */
button.xmas-toggle[aria-pressed="false"]::after {
    content: "";
    position: absolute;
    width: 30px;
    height: 2px;
    border-radius: 1px;
    background: currentColor;
    transform: rotate(-45deg);
}

@media (prefers-reduced-motion: reduce) {
    .xmas-lights__bulbs {
        animation: none;
    }

    html.xmas-on #load-spinner {
        animation: xmas-pulse 1.6s ease-in-out infinite;
    }

    button.xmas-toggle {
        transition: none;
    }
}

@media (forced-colors: active) {
    button.xmas-toggle {
        border-color: ButtonText;
    }
}

@media print {
    .xmas-hat,
    .xmas-lights,
    .xmas-snow,
    button.xmas-toggle,
    footer.footer::before,
    .main-container form::before {
        display: none !important;
    }
}
