﻿/* Trang trí theo sự kiện – sự kiện khai ở wwwroot/data/su-kien.json (SuKienTrangTri, Services/SuKienService); xem thử: ?su-kien=<key>.
   Dùng ở: trang đăng nhập (vùng thương hiệu – Login + SuKienHoaTiet), appbar (hoa văn rất mờ – MainLayout),
   Tổng quan (băng chào – Controls/Commons/SuKienBanner).
   Màu ở tệp này là MÀU CỐ ĐỊNH của từng dịp (đỏ Tết, sao vàng…) – không theo chế độ sáng / tối nên không đặt trong app.css (app.css chỉ token).
   Thêm hoa tiết mới: một khối biến (--kd-ev-img hình hạt / biểu tượng, --kd-hero-a/-b nền) cho .kd-ev--<tên>, kiểu hạt riêng nếu cần,
   rồi thêm tên vào SuKienTrangTri.HoaTietCoSan. */

/* ───── Biến theo hoa tiết (áp cho .kd-login--x, .kd-event--x, .kd-event-icon--x, .kd-appbar--x, .kd-event-banner--x) ───── */
:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--hoa-mai, .kd-event--hoa-mai, .kd-event-icon--hoa-mai, .kd-appbar--hoa-mai, .kd-event-banner--hoa-mai) {
    --kd-hero-a: #9b1515;
    --kd-hero-b: #e65100;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cg fill='%23FFD54F'%3E%3Cellipse cx='12' cy='6.2' rx='3.4' ry='5'/%3E%3Cellipse cx='12' cy='6.2' rx='3.4' ry='5' transform='rotate(72 12 12)'/%3E%3Cellipse cx='12' cy='6.2' rx='3.4' ry='5' transform='rotate(144 12 12)'/%3E%3Cellipse cx='12' cy='6.2' rx='3.4' ry='5' transform='rotate(216 12 12)'/%3E%3Cellipse cx='12' cy='6.2' rx='3.4' ry='5' transform='rotate(288 12 12)'/%3E%3C/g%3E%3Ccircle cx='12' cy='12' r='2.6' fill='%23F57F17'/%3E%3C/svg%3E");
}

:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--hoa-tri-an, .kd-event--hoa-tri-an, .kd-event-icon--hoa-tri-an, .kd-appbar--hoa-tri-an, .kd-event-banner--hoa-tri-an) {
    --kd-hero-a: #7b0d45;
    --kd-hero-b: #c2185b;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2C6.5 7 6.5 15.5 12 22C17.5 15.5 17.5 7 12 2Z' fill='%23F8BBD0'/%3E%3Cpath d='M12 4v16' stroke='%23F48FB1' stroke-width='1'/%3E%3C/svg%3E");
}

:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--tuyet, .kd-event--tuyet, .kd-event-icon--tuyet, .kd-appbar--tuyet, .kd-event-banner--tuyet) {
    --kd-hero-a: #0b3d2e;
    --kd-hero-b: #8e1b1b;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23FFFFFF' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M12 2v20M3.3 7l17.4 10M3.3 17L20.7 7M12 2l-2 2M12 2l2 2M12 22l-2-2M12 22l2-2'/%3E%3C/svg%3E");
}

:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--phao-hoa, .kd-event--phao-hoa, .kd-event-icon--phao-hoa, .kd-appbar--phao-hoa, .kd-event-banner--phao-hoa) {
    --kd-hero-a: #0f1546;
    --kd-hero-b: #4a148c;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' stroke='%23FFD54F' stroke-width='1.6' stroke-linecap='round'%3E%3Cpath d='M12 2v4M12 18v4M2 12h4M18 12h4M4.9 4.9l2.8 2.8M16.3 16.3l2.8 2.8M4.9 19.1l2.8-2.8M16.3 7.7l2.8-2.8'/%3E%3C/svg%3E");
}

:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--co-sao, .kd-event--co-sao, .kd-event-icon--co-sao, .kd-appbar--co-sao, .kd-event-banner--co-sao) {
    --kd-hero-a: #a3141a;
    --kd-hero-b: #d32f2f;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 2l2.9 6.9 7.1.6-5.4 4.7 1.7 7-6.3-3.9-6.3 3.9 1.7-7L2 9.5l7.1-.6z' fill='%23FFEB3B'/%3E%3C/svg%3E");
}

:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--den-long, .kd-event--den-long, .kd-event-icon--den-long, .kd-appbar--den-long, .kd-event-banner--den-long) {
    --kd-hero-a: #2a1260;
    --kd-hero-b: #d84315;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 64'%3E%3Cline x1='20' y1='0' x2='20' y2='10' stroke='%23FFE082' stroke-width='1.5'/%3E%3Crect x='14' y='10' width='12' height='4' rx='1' fill='%23FFB300'/%3E%3Cellipse cx='20' cy='32' rx='16' ry='18' fill='%23E53935'/%3E%3Cpath d='M20 14v36M10 20c4 8 4 16 0 24M30 20c-4 8-4 16 0 24' stroke='%23FFB300' stroke-width='1.2' fill='none'/%3E%3Crect x='14' y='49' width='12' height='4' rx='1' fill='%23FFB300'/%3E%3Cline x1='20' y1='53' x2='20' y2='64' stroke='%23FFB300' stroke-width='1.5'/%3E%3C/svg%3E");
}

:is(.kd-login, .kd-event, .kd-event-icon, .kd-appbar, .kd-event-banner):is(.kd-login--an-toan, .kd-event--an-toan, .kd-event-icon--an-toan, .kd-appbar--an-toan, .kd-event-banner--an-toan) {
    --kd-hero-a: #124d1a;
    --kd-hero-b: #2e7d32;
    --kd-ev-img: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='46' fill='%23FFFFFF'/%3E%3Cpath d='M38 16h24v22h22v24H62v22H38V62H16V38h22z' fill='%2343A047'/%3E%3C/svg%3E");
}

/* ───── Lớp hạt (SuKienHoaTiet): khung chung ───── */
.kd-event {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    pointer-events: none;
}

.kd-event__mark {
    position: absolute;
    right: -6%;
    bottom: -8%;
    width: 46%;
    aspect-ratio: 1;
    background: var(--kd-ev-img) center / contain no-repeat;
    opacity: .16;
}

.kd-event__p {
    position: absolute;
    left: var(--x);
    top: -8%;
    width: var(--size);
    height: var(--size);
    background: var(--kd-ev-img) center / contain no-repeat;
    animation: kd-event-fall var(--dur) linear var(--delay) infinite;
    will-change: transform;
}

@keyframes kd-event-fall {
    from { transform: translate3d(0, 0, 0) rotate(0deg); }
    to { transform: translate3d(var(--drift), calc(100vh + 60px), 0) rotate(300deg); }
}

@keyframes kd-event-twinkle {
    0%, 100% { opacity: .2; transform: scale(.7); }
    50% { opacity: 1; transform: scale(1.1); }
}

@keyframes kd-event-burst {
    0% { opacity: 0; transform: scale(.1); }
    15% { opacity: 1; }
    70% { opacity: .9; }
    100% { opacity: 0; transform: scale(1.6); }
}

@keyframes kd-event-swing {
    0%, 100% { transform: rotate(-6deg); }
    50% { transform: rotate(6deg); }
}

/* ───── Kiểu hạt riêng ───── */
.kd-event--tuyet .kd-event__p {
    width: calc(var(--size) * .55);
    height: calc(var(--size) * .55);
    border-radius: 50%;
    background: radial-gradient(circle, rgb(255 255 255 / 95%) 0 40%, rgb(255 255 255 / 0%) 70%);
    animation-duration: calc(var(--dur) * 1.4);
}

.kd-event--phao-hoa .kd-event__p {
    top: var(--y);
    width: calc(var(--size) * 6);
    height: calc(var(--size) * 6);
    border-radius: 50%;
    background: repeating-conic-gradient(var(--kd-fw, #FFD54F) 0 5deg, transparent 5deg 24deg);
    -webkit-mask: radial-gradient(circle, transparent 38%, #000 40% 62%, transparent 64%);
    mask: radial-gradient(circle, transparent 38%, #000 40% 62%, transparent 64%);
    animation: kd-event-burst 3.2s ease-out var(--delay) infinite;
}

    .kd-event--phao-hoa .kd-event__p:nth-child(3n) { --kd-fw: #80DEEA; }
    .kd-event--phao-hoa .kd-event__p:nth-child(3n+1) { --kd-fw: #F48FB1; }

.kd-event--phao-hoa .kd-event__mark { display: none; }

.kd-event--co-sao .kd-event__p {
    top: var(--y);
    animation: kd-event-twinkle 2.6s ease-in-out var(--delay) infinite;
}

.kd-event--co-sao .kd-event__mark { opacity: .22; }

.kd-event--hoa-tri-an .kd-event__mark {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 48'%3E%3Cpath d='M32 10C24 4 12 4 4 6v34c8-2 20-2 28 4c8-6 20-6 28-4V6c-8-2-20-2-28 4z' fill='none' stroke='%23FFFFFF' stroke-width='2.5' stroke-linejoin='round'/%3E%3Cpath d='M32 10v34M10 14c5-1 11-1 16 2M10 21c5-1 11-1 16 2M38 16c5-3 11-3 16-2M38 23c5-3 11-3 16-2' fill='none' stroke='%23FFFFFF' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
    opacity: .18;
}

.kd-event--den-long .kd-event__p {
    top: 0;
    left: calc(42% + var(--x) * .55); /* treo ở nửa phải – không đè logo / tên */
    width: calc(var(--size) * 3);
    height: calc(var(--size) * 4.8);
    transform-origin: 50% 0;
    animation: kd-event-swing 3.4s ease-in-out var(--delay) infinite;
}

.kd-event--den-long .kd-event__mark {
    right: 6%;
    top: 8%;
    bottom: auto;
    width: 26%;
    border-radius: 50%;
    background: radial-gradient(circle at 40% 40%, #FFF8E1, #FFE082 60%, rgb(255 224 130 / 0%) 72%);
    opacity: .5;
}

.kd-event--an-toan .kd-event__mark {
    right: 4%;
    bottom: 6%;
    width: 38%;
    opacity: .2;
}

/* ───── Biểu tượng nhỏ (băng chào) ───── */
.kd-event-icon {
    display: inline-block;
    flex: none;
    width: 16px;
    height: 16px;
    background: var(--kd-ev-img) center / contain no-repeat;
}

/* ───── Appbar trong ứng dụng (MainLayout): hoa văn rất mờ phía phải – màu thương hiệu giữ nguyên ───── */
.kd-appbar--event::after {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--kd-ev-img) 0 0 / 22px 22px space;
    opacity: .10;
    -webkit-mask: linear-gradient(90deg, transparent 35%, #000 75%);
    mask: linear-gradient(90deg, transparent 35%, #000 75%);
    pointer-events: none;
}


/* ───── Băng chào trên Tổng quan (SuKienBanner) ───── */
.kd-event-banner {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 72px;
    overflow: hidden;
    padding: 12px 16px;
    border-radius: 10px;
    background: linear-gradient(120deg, var(--kd-hero-a), var(--kd-hero-b));
    color: #fff;
}

.kd-event-banner .kd-event__mark {
    width: 140px;
    right: 48px;
    bottom: -30px;
}

.kd-event-banner__icon {
    position: relative;
    z-index: 2;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgb(255 255 255 / 16%);
    display: grid;
    place-items: center;
}

    .kd-event-banner__icon .kd-event-icon {
        width: 22px;
        height: 22px;
    }

.kd-event-banner__text {
    position: relative;
    z-index: 2;
    flex: 1 1 auto;
    min-width: 0;
}

.kd-event-banner__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.kd-event-banner__sub {
    font-size: 13px;
    opacity: .9;
}

.kd-event-banner__close {
    position: relative;
    z-index: 2;
    color: #fff !important;
}

/* Chấm màu hoa tiết trong lưới Quản trị › Trang trí sự kiện */
.kd-event-banner.kd-event-swatch {
    display: grid;
    place-items: center;
    width: 28px;
    min-height: 28px;
    height: 28px;
    padding: 0;
    border-radius: 50%;
}

.kd-admin-hint {
    margin: 8px 2px;
    font-size: 12px;
    opacity: .8;
}

/* Hạt nhỏ hơn trên điện thoại (dải thương hiệu thấp) */
@media (max-width: 959.98px) {
    .kd-event__p { width: calc(var(--size) * .7); height: calc(var(--size) * .7); }
    .kd-event--den-long .kd-event__p { width: calc(var(--size) * 1.8); height: calc(var(--size) * 2.9); }
    .kd-event__mark { width: 34%; }
}

/* Người dùng bật giảm chuyển động: hạt đứng yên tại chỗ */
@media (prefers-reduced-motion: reduce) {
    .kd-event__p {
        top: var(--y);
        animation: none !important;
        opacity: .7;
    }
}
