/*
 * Christmas dress for the storefront, loaded by theme-assets only while SeasonTheme is "christmas".
 * Colours come from the --xm-* and recoloured tokens in ui-core.css (:root[data-season="christmas"]);
 * this file only draws the decorations, unlayered so they sit over the layered shop rules:
 *   .xm-sky ......... fixed sky behind the page: the login's sun and moon (.sky-orb, ui-core.css), stars, a faint aurora
 *                     at night and the video author's mountains under snow (x-shop.scene-land, --land-* tokens)
 *   .xm-sleigh ...... Santa's sleigh and reindeer crossing the moon at night with a trail of gold sparkles
 *                     (x-shop.season-sleigh; season/sleigh.png is a silhouette used as a mask)
 *   .season-snow .... the canvas the snow falls on, over the page (season-snow.js)
 *   .season-vines ... at night, the video author's growing vine round the home banner and the login card, strung with
 *                     fairy lights, baubles, two hanging stars and poinsettias (x-shop.season-vines, season-vines.js;
 *                     season/xmas-vines.svg)
 *   snow caps ....... snow lying along the top of the "Nạp tiền" box and of the logo and title icons (season/snow-cap.svg),
 *                     and on the phone's bottom bar
 *   floating gift ... the round "Quà" button becomes a wrapped present with snow on its lid (season/xmas-gift.svg)
 *   footer .......... a row of snowy pines on top of .footer-dark (season/pines.png, a mask), a bank of snow along its
 *                     edge (.xm-ground) and the decorated tree standing in it (.xm-tree, season/xmas-tree.png)
 * Anything that moves only runs with <html data-season-fx> (the season.effects setting) and never under
 * prefers-reduced-motion.
 */

:root[data-season="christmas"] {
    --footer-bg: var(--xm-footer);
    --footer-box: var(--xm-footer-box);
}

::selection { background: color-mix(in srgb, var(--primary) 28%, transparent); }

/* ---------- Sky ---------- */
.xm-sky { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
    --orb-size: 64px; --orb-right: 9%; --orb-top: calc(var(--sticky-top) + 34px);
    background:
        radial-gradient(1.4px 1.4px at 8% 22%, var(--xm-star) 98%, transparent),
        radial-gradient(1px 1px at 23% 12%, var(--xm-star) 98%, transparent),
        radial-gradient(1.6px 1.6px at 37% 30%, var(--xm-star) 98%, transparent),
        radial-gradient(1px 1px at 52% 16%, var(--xm-star) 98%, transparent),
        radial-gradient(1.3px 1.3px at 64% 34%, var(--xm-star) 98%, transparent),
        radial-gradient(1px 1px at 71% 9%, var(--xm-star) 98%, transparent),
        radial-gradient(1.5px 1.5px at 93% 41%, var(--xm-star) 98%, transparent),
        radial-gradient(1px 1px at 15% 47%, var(--xm-star) 98%, transparent),
        radial-gradient(1.2px 1.2px at 46% 55%, var(--xm-star) 98%, transparent),
        radial-gradient(1px 1px at 83% 26%, var(--xm-star) 98%, transparent),
        radial-gradient(420px 320px at 88% 12%, var(--xm-moon), transparent 70%);
}
/* A faint green and teal aurora drifting over the night (transparent by day). */
.xm-sky::before { content: ''; position: absolute; left: -10%; right: -10%; top: 4%; height: 46vh;
    background: radial-gradient(48% 42% at 30% 40%, var(--xm-aurora), transparent 72%), radial-gradient(40% 36% at 66% 28%, color-mix(in srgb, var(--xm-aurora) 70%, transparent), transparent 70%); filter: blur(6px); }
.xm-sky .scene-land { --land-w: max(118vw, 162vh); }
@media (min-width: 768px) { .xm-sky { --orb-size: 92px; --orb-right: 6%; } }

/* ---------- Santa's sleigh ---------- */
/* It rides a track as wide as the sky that the graphics card slides across (translate, in % of the track), from beyond the
   left edge over the face of the moon and out on the right, rising a little as it goes; then the sky is empty a while.
   Only at night. */
.xm-sleigh { --moon-right: var(--orb-right); --moon-top: var(--orb-top); --moon-size: var(--orb-size); --sleigh-w: 128px;
    position: absolute; z-index: 1; left: 0; width: 100%; top: calc(var(--moon-top) + var(--moon-size) * .5 - var(--sleigh-w) * .2);
    translate: -30% 0; opacity: 0; transition: opacity .5s ease; pointer-events: none; }
:root[data-theme="dark"] .xm-sleigh { opacity: 1; }
.xm-sleigh-ride { display: block; width: var(--sleigh-w); position: relative; }
.xm-sleigh-art { display: block; width: 100%; aspect-ratio: 3 / 1; background: var(--xm-sleigh);
    -webkit-mask: url(season/sleigh.png) center / contain no-repeat; mask: url(season/sleigh.png) center / contain no-repeat;
    filter: drop-shadow(0 0 .8px var(--xm-sleigh-rim)); }
/* The gold dust it leaves behind. */
.xm-sleigh-ride::before { content: ''; position: absolute; right: 88%; top: 52%; width: 120px; height: 18px;
    background: radial-gradient(circle 1.4px, var(--xm-sparkle) 90%, transparent) 0 0 / 14px 9px, radial-gradient(circle 1px, var(--xm-sparkle) 90%, transparent) 7px 5px / 18px 11px;
    -webkit-mask: linear-gradient(90deg, transparent, #000); mask: linear-gradient(90deg, transparent, #000); opacity: .85; }
@media (max-width: 640px) { .xm-sleigh { --sleigh-w: 96px; } .xm-sleigh-ride::before { width: 80px; } }

/* ---------- Snow ---------- */
/* Over the page but under the header, the menus and the dialogs; it never catches a tap. */
.season-snow { position: fixed; z-index: 990; inset: 0; width: 100%; height: 100%; pointer-events: none; opacity: 0; transition: opacity 1.2s ease; }
.season-snow.is-falling { opacity: 1; }

/* ---------- The vine of lights round the home banner and the login card (season-vines.js) ---------- */
/* Drawn round its target with this margin (--vines-x / --vines-y) so the baubles and stars hang just outside it; the
   baubles at --vines-pumpkin of their size (smaller round the wide home banner). On a layer of its own, so its growing and
   its twinkling repaint only the frame. It stops at the screen's sides (season-vines.js) and clips there, so nothing pushes
   the page wider than the phone. */
.season-vines { --vines-x: 44px; --vines-y: 42px; --vines-pumpkin: 1; position: absolute; z-index: 3; pointer-events: none; will-change: transform; overflow-x: clip; }
.season-vines > svg { display: block; width: 100%; height: 100%; overflow: visible; }
@media (max-width: 640px) { .season-vines { --vines-x: 27px; --vines-y: 25px; } }
html:has(.season-vines) body { overflow-x: clip; }
.hero:has(> .season-vines) { position: relative; }
.hero > .season-vines { --vines-pumpkin: .6; }
@media (max-width: 640px) { .hero > .season-vines { --vines-pumpkin: .75; } }
.season-vines .leaf-reaction { transform-box: view-box; transform-origin: 0 0; }

/* ---------- Snow on the title icons ---------- */
/* A little drift lying on the top of the logo and of the icon chip in front of each title, inside its rounded corners. */
:is(.logo-mark, .section-title > i, .deposit-box > h2 > i, .quick-icon, .mk-land-icon, .page-hero-icon, .block-icon) { position: relative; }
:is(.logo-mark, .section-title > i, .deposit-box > h2 > i, .quick-icon, .mk-land-icon, .page-hero-icon, .block-icon)::after {
    content: ''; position: absolute; z-index: 1; left: 0; right: 0; top: 0; height: 30%; pointer-events: none;
    border-top-left-radius: inherit; border-top-right-radius: inherit;
    background: url(season/snow-cap.svg) 0 0 / 100% 100% no-repeat; }
/* A category's icon and a page header's icon are drawn by the image or emoji tile inside .block-icon and .page-hero-icon,
   so the wrapper takes that tile's corners. */
.block-icon { border-radius: 14px; }
.page-hero-icon { border-radius: 17px; }
.page-hero-icon:has(> img.is-card) { border-radius: 12px; }
@media (min-width: 768px) {
    .block-icon { border-radius: 15px; }
    .page-hero-icon { border-radius: 21px; }
}

/* ---------- Snow on the top-up box ---------- */
/* A drift lying inside the top edge of the "Nạp tiền" box, rounded with its corners. */
.deposit-box { position: relative; }
.deposit-box::before {
    content: ''; position: absolute; z-index: 2; left: 0; right: 0; top: 0; height: 12px; pointer-events: none;
    border-top-left-radius: inherit; border-top-right-radius: inherit;
    background: url(season/snow-cap.svg) 0 0 / 120px 100% repeat-x; }
/* By day the box is as white as the snow, so the drift piles up above its top edge like snow on a roof: lumpy on top,
   shaded ice blue underneath with a crisp blue-grey outline (season/snow-cap-day.svg), rounded off at the corners.
   The box's overflow is opened for it (its only wide row, the telco cards, scrolls by itself). */
:root:not([data-theme="dark"]) .deposit-box { overflow: visible; }
:root:not([data-theme="dark"]) .deposit-box::before { top: -8px; height: 23px; left: -2px; right: -2px;
    border-radius: 20px 20px 0 0 / 14px 14px 0 0; background-image: url(season/snow-cap-day.svg);
    filter: drop-shadow(0 2px 2px color-mix(in srgb, var(--xm-flake-rim) 55%, transparent)); }
/* The box's send button is baked gingerbread gold with snow lying along its top like the box's own drift
   and a glint of light running across it every few seconds. The box's icon takes the same warm tone. */
.deposit-box > h2 > i { background: var(--xm-ginger-soft); color: var(--xm-ginger-ink); }
.deposit-box .btn-block {
    --sheen: rgba(255, 240, 215, .35);
    padding-top: 4px; border-color: color-mix(in srgb, var(--xm-ginger-ink) 60%, transparent); color: var(--xm-flake); text-shadow: 0 1px 1px rgba(80, 36, 6, .4);
    background: url(season/snow-cap.svg) 0 0 / 120px 10px repeat-x,
        linear-gradient(105deg, transparent 35%, rgba(255, 248, 230, .5) 50%, transparent 65%) -200% 0 / 50% 100% no-repeat,
        var(--xm-ginger);
    box-shadow: 0 6px 16px var(--xm-ginger-glow), inset 0 -2px 0 rgba(90, 40, 8, .22); }
.deposit-box .btn-block:hover { box-shadow: 0 10px 24px var(--xm-ginger-glow), inset 0 -2px 0 rgba(90, 40, 8, .22); }
@media (prefers-reduced-motion: no-preference) { .deposit-box .btn-block { animation: xm-ginger-glint 5s ease-in-out 1s infinite; } }
@keyframes xm-ginger-glint { 0% { background-position: 0 0, -200% 0, 0 0; } 22%, 100% { background-position: 0 0, 300% 0, 0 0; } }
/* On the phone's bottom bar, the bank of snow from the footer's edge. */
.bottom-nav::before, .footer-dark > .xm-ground {
    background: radial-gradient(ellipse 30px 7px at 50% 100%, var(--xm-ground) 96%, transparent) 0 0 / 52px 8px repeat-x, radial-gradient(ellipse 22px 6px at 50% 100%, var(--xm-ground) 96%, transparent) 26px 1px / 44px 7px repeat-x, linear-gradient(var(--xm-ground), var(--xm-ground)) 0 7px / 100% 5px no-repeat;
    filter: drop-shadow(0 1px 1px rgba(0, 0, 0, .25)); }
.bottom-nav::before { content: ''; position: absolute; left: 0; right: 0; top: -8px; height: 12px; pointer-events: none; }

/* ---------- Dialogs (deposit methods, card, bank, gifts) ---------- */
.dlg { border: 1px solid color-mix(in srgb, var(--primary) 24%, var(--border)); }
.dlg-head h3 { display: flex; align-items: center; gap: 8px; }
.dlg-head h3::before { content: ''; flex: none; width: 24px; height: 24px; background: url(season/gift.png) center / contain no-repeat; }

/* ---------- The floating gift ---------- */
/* Without an image of the owner's own (event.button_image), the "Quà" button is the present itself (season/xmas-gift.svg,
   snow on its lid, gold bow) standing on its shadow, no round badge; a gold sparkle twinkles by its bow, and now and then
   the present hops and shakes. */
.gift-fab:not(.has-image) { width: 68px; height: 68px; border: 0; border-radius: 0; background: none; box-shadow: none; }
.gift-fab:not(.has-image) > i { width: 100%; height: 100%; font-size: 0; text-shadow: none; transform-origin: 50% 92%;
    background: url(season/xmas-gift.svg) center / contain no-repeat; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .28)); }
.gift-fab:not(.has-image)::after { z-index: 1; inset: 2px 0 auto auto; width: 16px; height: 16px; border-radius: 0; scale: 1;
    background: url(season/xmas-star.svg) center / contain no-repeat; animation: none; }
.gift-fab:not(.has-image) > .gift-fab-tag { bottom: -12px; }
.gift-fab[disabled] > i { animation: none; }

/* ---------- Footer ---------- */
.footer-dark { position: relative; margin-top: 64px; }
/* A warm glow over the pines, the tree's lights on the snow. */
.footer-dark::before { content: ''; position: absolute; left: 0; right: 0; bottom: 100%; height: 90px; pointer-events: none;
    background: radial-gradient(40% 100% at 80% 100%, var(--xm-glow), transparent 72%), radial-gradient(50% 90% at 25% 100%, color-mix(in srgb, var(--xm-moon) 80%, transparent), transparent 72%); }
.footer-dark::after { content: ''; position: absolute; left: 0; right: 0; bottom: calc(100% - 1px); height: 52px; pointer-events: none; background: var(--xm-pine);
    -webkit-mask: url(season/pines.png) 0 100% / 520px 52px repeat-x; mask: url(season/pines.png) 0 100% / 520px 52px repeat-x; }
.footer-dark > .xm-ground { position: absolute; z-index: 1; left: 0; right: 0; top: -7px; height: 12px; pointer-events: none; }
.footer-dark > .xm-tree { position: absolute; z-index: 2; bottom: calc(100% - 4px); right: 14%; width: 56px; pointer-events: none; }
.xm-tree img { display: block; width: 100%; height: auto; filter: drop-shadow(0 3px 4px rgba(0, 0, 0, .35)); }
/* The star on top glows; with effects on it twinkles. */
.xm-tree::before { content: ''; position: absolute; left: 50%; top: -6px; width: 26px; height: 26px; margin-left: -13px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--xm-gold) 70%, transparent), transparent 68%); }
@media (min-width: 768px) {
    .footer-dark { margin-top: 84px; }
    .footer-dark::after { height: 72px; -webkit-mask-size: 720px 72px; mask-size: 720px 72px; }
    .footer-dark > .xm-tree { width: 76px; right: 16%; }
}

/* ---------- Login / register (layouts.auth) ---------- */
.auth-shell { box-shadow: var(--auth-glass-shadow), 0 0 0 1px color-mix(in srgb, var(--primary) 18%, transparent); }

/* ---------- Motion (season.effects) ---------- */
@media (prefers-reduced-motion: no-preference) {
    [data-season-fx] .xm-tree::before { animation: xm-star 2.6s ease-in-out infinite; }
    [data-season-fx] .gift-fab:not(.has-image) { animation: none; }
    [data-season-fx] .gift-fab:not(.has-image) > i { animation: xm-gift-hop 3.2s ease-in-out infinite; }
    [data-season-fx] .gift-fab:not(.has-image)::after { animation: xm-twinkle 1.6s ease-in-out infinite; }
    /* The lights chase in three groups like a real string, switching rather than fading, so the frame is repainted only
       when one switches. */
    :root[data-theme="dark"][data-season-fx] .season-vines-bead { animation: xm-chase 1.8s steps(1, end) calc(var(--bead) * -.6s) infinite; }
    :root[data-theme="dark"][data-season-fx] .season-vines .xm-bulb { animation: xm-chase 1.8s steps(1, end) var(--twinkle, 0s) infinite; }
    [data-season-fx] .xm-sky::before { animation: xm-aurora 30s ease-in-out infinite alternate; }
    :root[data-theme="dark"][data-season-fx] .xm-sleigh { animation: xm-sleigh-ride 26s linear -6s infinite; }
    :root[data-theme="dark"][data-season-fx] .xm-sleigh-ride { animation: xm-sleigh-bob 2.4s ease-in-out infinite; }
    :root[data-theme="dark"][data-season-fx] .xm-sleigh-ride::before { animation: xm-sparkle .9s steps(3) infinite; }
}
@media (prefers-reduced-motion: reduce) {
    .xm-sleigh { display: none; }
    .season-snow { display: none; }
}

@keyframes xm-chase { 0% { opacity: 1; } 66% { opacity: .4; } }
@keyframes xm-twinkle { 0%, 100% { opacity: .35; scale: .55; rotate: 0deg; } 50% { opacity: 1; scale: 1; rotate: 45deg; } }
@keyframes xm-gift-hop { 0%, 72%, 100% { transform: none; } 77% { transform: translateY(-5px) rotate(-9deg); } 82% { transform: translateY(-2px) rotate(8deg); } 87% { transform: translateY(0) rotate(-5deg); } 92% { transform: scale(1.06, .94); } }
@keyframes xm-star { 0%, 100% { opacity: .55; scale: .85; } 50% { opacity: 1; scale: 1.15; } }
@keyframes xm-aurora { from { transform: translateX(-5%) skewX(-6deg); opacity: .7; } to { transform: translateX(5%) skewX(6deg); opacity: 1; } }
/* Across the sky in the first 40% of the loop, then nothing until it comes round again. */
@keyframes xm-sleigh-ride { 0% { translate: -30% 0; } 40%, 100% { translate: 115% -40px; } }
@keyframes xm-sleigh-bob { 0%, 100% { transform: translateY(0) rotate(-3deg); } 50% { transform: translateY(-6px) rotate(-1deg); } }
@keyframes xm-sparkle { 0% { background-position: 0 0, 7px 5px; } 100% { background-position: -14px 3px, -11px 8px; } }
