/* Constellation tree. All illustration styles stay local to this component. */
.christmas-tree {
    --christmas-tree-ink: var(--christmas-tree-theme, #368ee0);
    --christmas-tree-soft: var(--christmas-tree-theme, #368ee0);
    --christmas-tree-gold: #ad7a16;
    --christmas-tree-float-distance: -8px;
    flex: 0 0 clamp(150px, 18vw, 240px);
    width: clamp(150px, 18vw, 240px);
    max-width: 100%;
    text-align: center;
    pointer-events: none;
}

.christmas-tree__art {
    position: relative;
    isolation: isolate;
}

.christmas-tree__art::before {
    content: "";
    position: absolute;
    z-index: -1;
    inset: -10%;
    border-radius: 50%;
    background: radial-gradient(ellipse, var(--christmas-tree-theme, #368ee0), transparent 68%);
    opacity: .12;
}

.christmas-tree__svg {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
    animation: christmas-tree-float 5s ease-in-out infinite;
}

.christmas-tree__svg path {
    color: var(--christmas-tree-ink);
    fill: currentColor;
    stroke: currentColor;
    stroke-width: .12;
    transform-box: fill-box;
    transform-origin: center;
    transform: scale(var(--christmas-star-scale, 1));
    animation: christmas-tree-reveal 650ms cubic-bezier(.2, .65, .3, 1) both;
    animation-delay: calc((88 - var(--no, 0)) * 10ms);
}

.christmas-tree__svg path:nth-of-type(4n) {
    color: var(--christmas-tree-soft);
}

.christmas-tree__svg path:nth-of-type(9n) {
    color: var(--christmas-tree-gold);
}

/* A few staggered lights keep the silhouette steady while the tree stays alive. */
.christmas-tree__svg path:nth-of-type(5n),
.christmas-tree__svg .christmas-tree__topper {
    animation-name: christmas-tree-reveal, christmas-tree-twinkle;
    animation-duration: 650ms, 3.6s;
    animation-timing-function: cubic-bezier(.2, .65, .3, 1), ease-in-out;
    animation-iteration-count: 1, infinite;
    animation-fill-mode: both, none;
    animation-delay: calc((88 - var(--no, 0)) * 10ms), calc(1.6s + var(--no, 0) * 20ms);
}

.christmas-tree__svg .christmas-tree__topper {
    --christmas-star-scale: 1.8;
    color: var(--christmas-tree-gold);
    animation-name: christmas-tree-reveal, christmas-tree-topper-pulse;
    animation-duration: 650ms, 3s;
    animation-delay: 0s, 1.6s;
}

.christmas-tree__caption {
    margin-top: 12px;
}

.christmas-tree__greeting {
    margin: 0 0 6px;
    color: inherit;
    font-size: 24px;
    font-weight: 400;
    line-height: 1.2;
    letter-spacing: -.5px;
}

.christmas-tree__message {
    max-width: 220px;
    margin: 0 auto;
    color: inherit;
    font-size: 13px;
    line-height: 1.5;
}

.christmas-tree__motion-toggle {
    margin-top: 8px;
    padding: 4px 8px;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 12px;
    text-decoration: underline;
    text-underline-offset: 3px;
    cursor: pointer;
    pointer-events: auto;
}

/* Stopping motion also finishes the entrance so no stars stay hidden. */
.christmas-tree[data-motion="paused"] .christmas-tree__svg,
.christmas-tree[data-motion="paused"] .christmas-tree__svg path {
    animation: none;
}

@media (pointer: coarse) {
    .christmas-tree__motion-toggle {
        min-height: 44px;
    }
}

@supports (color: color-mix(in srgb, #000, #fff)) {
    .christmas-tree {
        --christmas-tree-ink: color-mix(in srgb, var(--christmas-tree-theme, #368ee0) 78%, #17334d);
        --christmas-tree-soft: color-mix(in srgb, var(--christmas-tree-theme, #368ee0) 38%, #fff);
    }
}

/* Normal flow keeps the decoration clear of the form at every screen height. */
.login #user_login.login-festive {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: clamp(24px, 3vw, 48px);
    box-sizing: border-box;
    min-height: 100vh;
    padding: clamp(24px, 5vh, 64px) 24px;
}

.login #user_login.login-festive > .wrapper {
    position: relative;
    top: auto;
    left: auto;
    flex: 0 1 800px;
    width: 800px;
    min-width: 0;
    max-width: 100%;
    height: auto;
    margin: 0 !important; /* Overrides the legacy mobile wrapper margin. */
}

@keyframes christmas-tree-reveal {
    from {
        opacity: 0;
        transform: translateY(6px) scale(.6);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(var(--christmas-star-scale, 1));
    }
}

@keyframes christmas-tree-float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(var(--christmas-tree-float-distance));
    }
}

@keyframes christmas-tree-twinkle {
    0%, 65%, 100% {
        opacity: .45;
        transform: scale(.9);
    }
    32% {
        opacity: 1;
        transform: scale(1.15);
    }
}

@keyframes christmas-tree-topper-pulse {
    0%, 100% {
        opacity: .8;
        transform: scale(var(--christmas-star-scale, 1));
    }
    50% {
        opacity: 1;
        transform: scale(2.2);
    }
}

@media (max-width: 991px) {
    .login #user_login.login-festive {
        flex-direction: column;
        gap: 20px;
        min-height: 100vh;
        padding: 24px 16px 32px;
    }

    .login #user_login.login-festive > .wrapper {
        flex: none;
    }

    .christmas-tree {
        --christmas-tree-float-distance: -4px;
        display: flex;
        flex: none;
        align-items: center;
        justify-content: center;
        gap: 16px;
        width: auto;
        text-align: left;
    }

    .christmas-tree__art {
        flex: 0 0 88px;
        width: 88px;
    }

    .christmas-tree__caption {
        margin-top: 0;
    }

    .christmas-tree__greeting {
        font-size: 21px;
    }
}

@media (max-width: 767px) {
    .login #user_login.login-festive > .wrapper {
        width: 400px;
    }
}

@media (max-width: 359px) {
    .christmas-tree__art {
        flex-basis: 68px;
        width: 68px;
    }

    .christmas-tree__greeting {
        font-size: 19px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .christmas-tree:not([data-motion="playing"]) .christmas-tree__svg,
    .christmas-tree:not([data-motion="playing"]) .christmas-tree__svg path {
        animation: none;
    }
}

@media print {
    .christmas-tree {
        display: none;
    }
}
