/* =====================================================================
   LỄ VINH DANH — TỐI ƯU CHO TV (NGANG) VÀ ĐIỆN THOẠI (DỌC)
   File này nạp SAU fix-ceremony.css nên ghi đè các phần cần thiết.
   Class do app.js gắn lên #ceremonyOverlay:
     cer-tv / cer-phone  : bố cục ngang (TV) hoặc dọc (điện thoại)
     cer-light / cer-full: hiệu ứng nhẹ (mượt) hoặc đầy đủ (nặng)
     cer-blur            : bật kính mờ (nặng, mặc định tắt)
   ===================================================================== */

#ceremonyOverlay {
    height: 100vh;
    height: 100dvh;
}

/* ---------- Khung nội dung: luôn vừa màn hình, không tràn ---------- */
#ceremonyOverlay .ceremony-content {
    min-height: 100%;
    min-height: 100dvh;
    box-sizing: border-box;
    padding: 56px 16px 72px;
    overflow: hidden;
}

/* ---------- Sân khấu: 2 bục cạnh nhau, không lòi ra ngoài ---------- */
.ceremony-stage {
    width: 100%;
    max-width: min(960px, 96vw);
    height: auto;
    min-height: 0;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(12px, 2.5vw, 32px);
}
.ceremony-stage > * {
    min-width: 0;
    box-sizing: border-box;
}

/* Thẻ: co theo khung, không tràn sang bục bên cạnh */
.glass-card {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    margin-top: 0;
}
.glass-card.rank-1 {
    flex: 1 1 44%;
    max-width: 48%;
}
.glass-card.rank-2 {
    flex: 1 1 32%;
    max-width: 36%;
    opacity: 1;
}
/* Đồng hạng 1: nhiều người thì thẻ rộng hơn */
.glass-card.rank-1.has-tie {
    flex-basis: 56%;
    max-width: 60%;
}

/* Người trong thẻ: tự xuống dòng, co chữ, không đè nhau */
.person-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: clamp(8px, 1.5vw, 18px);
    width: 100%;
    min-width: 0;
}
.person-item {
    min-width: 0;
    max-width: 100%;
    flex: 0 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.g-name {
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
    line-height: 1.15;
    font-size: clamp(13px, 1.8vw, 22px);
    text-align: center;
}
.g-avatar {
    width: clamp(44px, 6vw, 80px);
    height: clamp(44px, 6vw, 80px);
}
.g-score {
    font-size: clamp(14px, 2vw, 26px);
}
.g-badge {
    font-size: clamp(10px, 1.2vw, 14px);
}

/* ---------- Hiệu ứng nhẹ (mặc định): bỏ kính mờ và chuyển động nặng ---------- */
#ceremonyOverlay.cer-light .glass-card {
    background: rgba(20, 24, 40, 0.82);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    transform: none;
    transition: opacity 0.5s ease;
}
#ceremonyOverlay.cer-light .glass-card:not(.appear) {
    opacity: 0;
}
#ceremonyOverlay.cer-light .glass-card.appear {
    opacity: 1;
}
/* Làm mờ kiểu blur(80px) rất nặng: thay bằng đốm mờ đơn giản */
#ceremonyOverlay.cer-light .orb {
    filter: none;
    opacity: 0.12;
    animation: none;
}
/* Kính mờ chỉ khi bật cấu hình blur */
#ceremonyOverlay.cer-blur .glass-card {
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

/* ---------- Ngang (TV) ---------- */
#ceremonyOverlay.cer-tv .ceremony-stage {
    max-height: 62vh;
    max-width: min(1000px, 94vw);
}
#ceremonyOverlay.cer-tv .ceremony-laaa {
    font-size: clamp(56px, 9vw, 130px);
    margin-bottom: 36px;
}
#ceremonyOverlay.cer-tv .g-name {
    font-size: clamp(16px, 1.9vw, 30px);
}

/* ---------- Dọc (điện thoại) ---------- */
#ceremonyOverlay.cer-phone .ceremony-laaa {
    font-size: clamp(40px, 15vw, 84px);
    margin-bottom: 24px;
}
#ceremonyOverlay.cer-phone .ceremony-stage {
    max-height: 56dvh;
    gap: 10px;
}
#ceremonyOverlay.cer-phone .glass-card.rank-1 {
    flex-basis: 52%;
    max-width: 54%;
}
#ceremonyOverlay.cer-phone .glass-card.rank-2 {
    flex-basis: 40%;
    max-width: 42%;
}
#ceremonyOverlay.cer-phone .glass-card.rank-1.has-tie {
    flex-basis: 62%;
    max-width: 64%;
}
#ceremonyOverlay.cer-phone .g-name {
    font-size: clamp(13px, 4vw, 17px);
}
#ceremonyOverlay.cer-phone .g-avatar {
    width: 52px;
    height: 52px;
}

/* Màn hình hẹp đứng: giữ bục không quá nhỏ */
@media (max-width: 380px) {
    #ceremonyOverlay .ceremony-content {
        padding: 52px 10px 64px;
    }
    .ceremony-stage {
        gap: 8px;
    }
}

/* Người dùng bật "giảm chuyển động": tắt hẳn hiệu ứng lặp */
@media (prefers-reduced-motion: reduce) {
    #ceremonyOverlay .orb,
    #ceremonyOverlay .ceremony-laaa,
    #ceremonyOverlay .glowing-orbs {
        animation: none !important;
    }
    #ceremonyOverlay * {
        transition-duration: 0.01s !important;
    }
}

/* =====================================================================
   NHÃN TOP 1 / TOP 2 TRÊN THẺ (lễ vinh danh và bục trang chủ)
   ===================================================================== */
.g-rank {
    font-weight: 900;
    font-size: clamp(12px, 1.4vw, 18px);
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
    padding: 4px 14px;
    border-radius: 999px;
    background: rgba(255,255,255,0.15);
    color: #fff;
}
.glass-card.rank-1 .g-rank { background: #f59e0b; color: #1f2937; }
.glass-card.rank-2 .g-rank { background: #94a3b8; color: #111827; }

/* =====================================================================
   BỤC VINH DANH TRÊN TRANG CHỦ: nền sáng, chữ tối (sửa lỗi chữ trắng trên nền trắng)
   Chỉ áp dụng trong #podium-container, không ảnh hưởng lễ vinh danh.
   ===================================================================== */
#podium-container .glass-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    opacity: 1;
    transform: none;
    color: #0f172a;
}
#podium-container .g-name { color: #0f172a; }
#podium-container .g-score { color: #0f172a; }
#podium-container .g-rank { background: #0f172a; color: #ffffff; }
#podium-container .glass-card.rank-1 .g-rank { background: #f59e0b; color: #1f2937; }
#podium-container .glass-card.rank-2 .g-rank { background: #94a3b8; color: #111827; }

/* =====================================================================
   BỤC VINH DANH TRANG CHỦ — THIẾT KẾ MỚI (avatar, tên, điểm lấy từ dữ liệu)
   Chỉ áp dụng trong #podium-container.
   ===================================================================== */
#podium-container .pod-wrap {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: clamp(10px, 3vw, 20px);
    padding: 36px 8px 8px;
    margin-top: 8px;
}
/* Quầng sáng dưới bục */
#podium-container .pod-wrap::before {
    content: "";
    position: absolute;
    left: 50%; bottom: -10px;
    width: 90%; height: 40px;
    transform: translateX(-50%);
    background: radial-gradient(ellipse at center, rgba(245,163,0,.22), transparent 70%);
    pointer-events: none;
}

#podium-container .pod-step {
    --h: 150px; --d: .3s; --accent: #8e9aa8; --light: #cfd8e3; --glow: rgba(142,154,168,.35); --speed: 1.6s;
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    max-width: 190px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    order: var(--o);
    animation: pod-rise .7s cubic-bezier(.2,.8,.2,1) both;
    animation-delay: var(--d);
}
#podium-container .pod-r1 {
    --h: 196px; --d: .15s; --accent: #f5a300; --light: #ffd166; --glow: rgba(245,163,0,.40); --speed: 1.2s;
    max-width: 210px;
}
#podium-container .pod-tie {
    flex: 1.5 1 0;
    max-width: 280px;
}

/* Vương miện trên top 1 */
#podium-container .pod-crown {
    font-size: clamp(22px, 4vw, 30px);
    line-height: 1;
    margin-bottom: 2px;
    animation: pod-bob 2.4s ease-in-out infinite;
}

/* Danh sách người (nhiều người nếu đồng hạng) */
#podium-container .pod-people {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    gap: 10px 8px;
    width: 100%;
}
#podium-container .pod-person {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}
#podium-container .pod-tie .pod-person {
    width: 46%;
}

#podium-container .pod-avatar {
    width: clamp(52px, 7vw, 64px);
    height: clamp(52px, 7vw, 64px);
    border-radius: 50%;
    border: 3px solid var(--accent);
    background: #f1f4f8;
    display: grid;
    place-items: center;
    font-weight: 800;
    color: #334155;
    overflow: hidden;
    margin-bottom: 8px;
    box-shadow: 0 0 12px var(--glow);
    animation: pod-pulse var(--speed) ease-in-out infinite;
}
#podium-container .pod-r1 .pod-avatar {
    width: clamp(60px, 8vw, 80px);
    height: clamp(60px, 8vw, 80px);
}
#podium-container .pod-avatar img { width: 100%; height: 100%; object-fit: cover; }

#podium-container .pod-name {
    font-weight: 700;
    font-size: clamp(13px, 3.6vw, 16px);
    line-height: 1.2;
    color: #0f172a;
    overflow-wrap: anywhere;
    word-break: break-word;
    max-width: 100%;
}
#podium-container .pod-score {
    font-weight: 800;
    font-size: clamp(15px, 4vw, 19px);
    color: #0f172a;
    margin-top: 2px;
}
#podium-container .pod-score span { font-size: .75em; margin-left: 1px; color: #64748b; }

#podium-container .pod-badge {
    margin: 6px 0 0;
    font-size: .72rem;
    font-weight: 800;
    letter-spacing: .5px;
    padding: 3px 12px;
    border-radius: 999px;
    background: #fff3cd;
    color: #8a5a00;
}
#podium-container .pod-badge-silver {
    background: #e2e8f0;
    color: #334155;
}

/* Bục */
#podium-container .pod-block {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: var(--h);
    margin-top: 12px;
    border-radius: 12px 12px 4px 4px;
    background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #000));
    box-shadow: 0 0 14px var(--glow), 0 6px 12px rgba(0,0,0,.12);
}
#podium-container .pod-block::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, transparent, var(--light), transparent);
    opacity: .18;
    animation: pod-shine 3.5s ease-in-out infinite;
    pointer-events: none;
}
#podium-container .pod-num {
    position: absolute;
    top: 10px; left: 0; right: 0;
    z-index: 2;
    text-align: center;
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 0 8px var(--glow);
}
#podium-container .pod-chevs { position: absolute; inset: 0; pointer-events: none; }
#podium-container .pod-chev {
    position: absolute;
    left: 0; bottom: 0;
    width: 100%; height: 22px;
    opacity: 0;
    animation: pod-climb var(--speed) linear infinite;
    will-change: transform, opacity;
}
#podium-container .pod-chev path {
    fill: none;
    stroke: var(--light);
    stroke-width: 6;
    stroke-linecap: round;
    stroke-linejoin: round;
}
#podium-container .pod-chev:nth-child(1) { animation-delay: 0s; }
#podium-container .pod-chev:nth-child(2) { animation-delay: calc(var(--speed) / 3 * -1); }
#podium-container .pod-chev:nth-child(3) { animation-delay: calc(var(--speed) / 3 * -2); }

@keyframes pod-climb {
    0%   { transform: translateY(40px);  opacity: 0; }
    15%  { opacity: .9; }
    85%  { opacity: .9; }
    100% { transform: translateY(-140px); opacity: 0; }
}
@keyframes pod-shine {
    0%, 100% { transform: translateX(-100%); }
    50%      { transform: translateX(100%); }
}
@keyframes pod-rise {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: none; }
}
@keyframes pod-pulse {
    0%, 100% { box-shadow: 0 0 8px var(--glow); }
    50%      { box-shadow: 0 0 18px var(--glow); }
}
@keyframes pod-bob {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
    #podium-container .pod-step,
    #podium-container .pod-chev,
    #podium-container .pod-block::before,
    #podium-container .pod-avatar,
    #podium-container .pod-crown {
        animation: none !important;
    }
    #podium-container .pod-chev { opacity: .5; }
}
