/* =========================================================
   Event Fundraising — Public Page CSS
   ========================================================= */
@import url("../variables.css");

.ef-wrap {
    max-width: 960px;
    margin: 0 auto;
    min-height: 70vh;
}

/* ---- Header ---- */
.ef-hero {
    text-align: center;
    padding: 48px 0 28px;
}
.ef-hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(220, 53, 69, 0.08);
    color: #dc3545;
    font-weight: 900;
    font-size: 14px;
    padding: 8px 20px;
    border-radius: var(--radius-pill);
    animation: pulse-badge 2s infinite;
}
.ef-hero-badge .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #dc3545;
    animation: blink 1.2s infinite;
}
@keyframes blink {
    0%,
    100% {
        opacity: 1;
    }
    50% {
        opacity: 0.2;
    }
}
@keyframes pulse-badge {
    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.3);
    }
    50% {
        box-shadow: 0 0 0 14px rgba(220, 53, 69, 0);
    }
}

.ef-hero-title {
    font-weight: 1000;
    font-size: clamp(2rem, 5vw, 3rem);
    color: var(--brand-green);
    margin: 16px 0 8px;
    letter-spacing: -0.03em;
}
.ef-hero-desc {
    color: var(--muted);
    font-weight: 700;
    font-size: 1.15rem;
    max-width: 60ch;
    margin: 0 auto;
}

/* ---- Leaderboard ---- */
.ef-board {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: visible;
    box-shadow: var(--shadow);
    transition: box-shadow 0.3s ease;
    position: relative;
}
.ef-board.board-pulse {
    box-shadow:
        0 0 0 4px rgba(39, 114, 69, 0.25),
        var(--shadow);
}
.ef-board-header {
    padding: 22px 28px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--line);
    background: var(--table-head-bg);
    border-radius: var(--radius) var(--radius) 0 0;
}
.ef-board-title {
    font-weight: 1000;
    font-size: 1.4rem;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 10px;
}
.ef-board-total {
    font-weight: 900;
    font-size: 1rem;
    color: var(--muted);
}
.ef-board-total span {
    color: var(--brand-green);
    font-weight: 1000;
    font-size: 1.3rem;
}

/* ---- Each Row ---- */
.ef-row {
    display: grid;
    grid-template-columns: 72px 1fr auto;
    padding: 20px 28px;
    align-items: center;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    transition: all 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    overflow: visible;
}
.ef-row:last-child {
    border-bottom: none;
}
.ef-row:hover {
    background: rgba(39, 114, 69, 0.03);
}

/* Rank badge */
.ef-row .rank {
    font-weight: 1000;
    font-size: 1.5rem;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--line);
    flex-shrink: 0;
}

/* Top 3 special ranks */
.ef-row.top-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.06), transparent);
}
.ef-row.top-1 .rank {
    background: linear-gradient(135deg, #ffd700, #ffa500);
    color: #fff;
    font-size: 1.8rem;
    width: 58px;
    height: 58px;
    box-shadow: 0 6px 24px rgba(255, 215, 0, 0.4);
    animation: goldPulse 3s ease-in-out infinite;
}
@keyframes goldPulse {
    0%,
    100% {
        box-shadow: 0 6px 24px rgba(255, 215, 0, 0.4);
    }
    50% {
        box-shadow: 0 6px 32px rgba(255, 215, 0, 0.6);
    }
}

.ef-row.top-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.05), transparent);
}
.ef-row.top-2 .rank {
    background: linear-gradient(135deg, #c0c0c0, #a8a8a8);
    color: #fff;
    font-size: 1.6rem;
    width: 54px;
    height: 54px;
    box-shadow: 0 4px 18px rgba(192, 192, 192, 0.35);
}

.ef-row.top-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.04), transparent);
}
.ef-row.top-3 .rank {
    background: linear-gradient(135deg, #cd7f32, #b8690e);
    color: #fff;
    font-size: 1.5rem;
    width: 52px;
    height: 52px;
    box-shadow: 0 4px 16px rgba(205, 127, 50, 0.3);
}

/* Name */
.ef-row .info {
    min-width: 0;
}
.ef-row .name {
    font-weight: 800;
    font-size: 1.2rem;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}
/* Top 3 bigger names */
.ef-row.top-1 .name {
    font-size: 1.6rem;
    font-weight: 1000;
    background: linear-gradient(90deg, #b8860b, #daa520);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.ef-row.top-2 .name {
    font-size: 1.4rem;
    font-weight: 900;
    color: #6b6b6b;
}
.ef-row.top-3 .name {
    font-size: 1.3rem;
    font-weight: 900;
    color: #8b6914;
}

/* Amount */
.ef-row .amount {
    font-weight: 1000;
    font-size: 1.3rem;
    color: var(--brand-green);
    text-align: right;
    white-space: nowrap;
    letter-spacing: -0.01em;
}
.ef-row.top-1 .amount {
    font-size: 1.8rem;
    background: linear-gradient(90deg, var(--brand-green), #2ea35f);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.ef-row.top-2 .amount {
    font-size: 1.5rem;
}
.ef-row.top-3 .amount {
    font-size: 1.4rem;
}

/* ---- Animations ---- */
/* New entry fly-in */
.ef-row.anim-enter {
    animation: rowEnter 1s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}
@keyframes rowEnter {
    0% {
        opacity: 0;
        transform: translateX(-60px) scale(0.92);
    }
    50% {
        opacity: 1;
        transform: translateX(8px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* Glow sweep for new donations */
.ef-row.anim-glow::before {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(39, 114, 69, 0.15) 30%,
        rgba(255, 215, 0, 0.12) 50%,
        rgba(39, 114, 69, 0.15) 70%,
        transparent 100%
    );
    animation: rowGlow 2s ease-out forwards;
}
@keyframes rowGlow {
    0% {
        opacity: 1;
        transform: translateX(-100%);
    }
    100% {
        opacity: 0;
        transform: translateX(100%);
    }
}

/* Rank shift */
.ef-row.anim-shift {
    animation: rowShift 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rowShift {
    0% {
        transform: translateY(-20px);
        opacity: 0.5;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Crown burst for new top donor */
.ef-row.anim-crown {
    z-index: 10;
}
.ef-row.anim-crown::after {
    content: "👑";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3.5rem;
    animation: crownBurst 2.5s ease-out forwards;
    pointer-events: none;
    z-index: 100;
    filter: drop-shadow(0 6px 20px rgba(255, 215, 0, 0.7));
}
@keyframes crownBurst {
    0% {
        opacity: 0;
        transform: translateX(-50%) scale(0) translateY(20px);
    }
    15% {
        opacity: 1;
        transform: translateX(-50%) scale(1.6) translateY(-30px);
    }
    30% {
        opacity: 1;
        transform: translateX(-50%) scale(1.2) translateY(-40px);
    }
    50% {
        opacity: 1;
        transform: translateX(-50%) scale(1.3) translateY(-50px);
    }
    70% {
        opacity: 0.8;
        transform: translateX(-50%) scale(1.1) translateY(-65px);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) scale(0.9) translateY(-90px);
    }
}

/* Board pulse on new donation */
.ef-board.board-pulse {
    animation: boardPulse 0.8s ease;
}
@keyframes boardPulse {
    0% {
        box-shadow:
            0 0 0 0 rgba(39, 114, 69, 0.3),
            var(--shadow);
    }
    50% {
        box-shadow:
            0 0 0 8px rgba(39, 114, 69, 0.1),
            var(--shadow);
    }
    100% {
        box-shadow:
            0 0 0 0 rgba(39, 114, 69, 0),
            var(--shadow);
    }
}

/* ---- Floating Popup (live-stream style) ---- */
.ef-float-popup {
    position: fixed;
    top: 90px;
    right: 30px;
    z-index: 9999;
    background: var(--card);
    border: 2px solid var(--brand-green);
    border-radius: var(--radius);
    padding: 20px 28px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
    display: flex;
    align-items: center;
    gap: 16px;
    animation: popupIn 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
    max-width: 420px;
}
.ef-float-popup.is-top {
    border-color: #ffd700;
    box-shadow: 0 24px 64px rgba(255, 215, 0, 0.2);
}
.ef-float-popup.out {
    animation: popupOut 0.5s ease-in forwards;
}

@keyframes popupIn {
    0% {
        opacity: 0;
        transform: translateX(120%) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}
@keyframes popupOut {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(140%);
    }
}

.ef-float-popup .popup-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-green), var(--brand-gold));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    flex-shrink: 0;
    animation: popIconBounce 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}
.ef-float-popup.is-top .popup-icon {
    background: linear-gradient(135deg, #ffd700, #ffa500);
}
@keyframes popIconBounce {
    0% {
        transform: scale(0) rotate(-30deg);
    }
    50% {
        transform: scale(1.3) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0);
    }
}

.ef-float-popup .popup-text {
    display: flex;
    flex-direction: column;
}
.ef-float-popup .popup-name {
    font-weight: 900;
    color: var(--ink);
    font-size: 1.1rem;
}
.ef-float-popup .popup-amount {
    font-weight: 1000;
    color: var(--brand-green);
    font-size: 1.5rem;
    letter-spacing: -0.02em;
}

/* Confetti */
.ef-confetti {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 99999;
    overflow: hidden;
}
.ef-confetti .particle {
    position: absolute;
    animation: confettiFall var(--dur) linear forwards;
    opacity: 0;
}
@keyframes confettiFall {
    0% {
        opacity: 1;
        transform: translateY(-20px) rotate(0deg) scale(1);
    }
    50% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translateY(100vh) rotate(1080deg) scale(0.5);
    }
}

/* Empty state */
.ef-empty {
    text-align: center;
    padding: 80px 20px;
    color: var(--muted);
    font-weight: 800;
    font-size: 1.1rem;
}
.ef-empty i {
    font-size: 3.5rem;
    opacity: 0.25;
    display: block;
    margin-bottom: 14px;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
    .ef-row {
        grid-template-columns: 56px 1fr auto;
        padding: 16px 16px;
        gap: 12px;
    }
    .ef-row .rank {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }
    .ef-row.top-1 .rank {
        width: 48px;
        height: 48px;
        font-size: 1.4rem;
    }
    .ef-row .name {
        font-size: 1rem;
    }
    .ef-row.top-1 .name {
        font-size: 1.25rem;
    }
    .ef-row .amount {
        font-size: 1.1rem;
    }
    .ef-row.top-1 .amount {
        font-size: 1.35rem;
    }
    .ef-board-header {
        padding: 16px;
    }
    .ef-float-popup {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* ---- Dark mode ---- */
[data-theme="dark"] .ef-board {
    background: rgba(26, 32, 48, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
}
[data-theme="dark"] .ef-float-popup {
    background: #1a2030;
    border-color: var(--brand-green);
}
[data-theme="dark"] .ef-row.top-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.04), transparent);
}
[data-theme="dark"] .ef-row.top-1 .name {
    background: linear-gradient(90deg, #ffd700, #ffc107);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
[data-theme="dark"] .ef-row.top-2 .name {
    color: #c0c0c0;
}
[data-theme="dark"] .ef-row.top-3 .name {
    color: #cd9b5a;
}

/* RTL */
[dir="rtl"] .ef-row .amount {
    text-align: left;
}
[dir="rtl"] .ef-float-popup {
    right: auto;
    left: 30px;
    animation-name: popupInRtl;
}
[dir="rtl"] .ef-float-popup.out {
    animation-name: popupOutRtl;
}
@keyframes popupInRtl {
    0% {
        opacity: 0;
        transform: translateX(-120%) scale(0.85);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}
@keyframes popupOutRtl {
    0% {
        opacity: 1;
        transform: translateX(0);
    }
    100% {
        opacity: 0;
        transform: translateX(-140%);
    }
}
