/* Live donations ticker — a floating, cycling feed of the latest donations.
   White rounded cards with a navy "gem" avatar and a green "NEW" badge; cards
   pop in with a lively spring and the gem sparkles, to make the page feel alive.
   Driven by live-donations.js. pointer-events disabled on the container so the
   feed never blocks the donate flow underneath. */

.live-donations {
    position: fixed;
    top: 110px;            /* clears the sticky top nav (56px) + breathing room */
    right: 16px;
    z-index: 1040;         /* above sticky nav bars / page chrome; below Bootstrap modals (1055) */
    width: 340px;
    max-width: calc(100vw - 32px);
    /* Cap the height to the viewport and scroll internally so the cards never
       push the closing-countdown off-screen — the timer stays reachable. */
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;        /* Firefox: hide scrollbar, still scrollable */
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 4px;          /* room for card shadows inside the scroll area */
    pointer-events: auto;  /* must receive wheel/touch to scroll the feed */
    transition: opacity 0.5s ease;
}

.live-donations::-webkit-scrollbar {   /* Chrome/Safari: hide scrollbar */
    width: 0;
    height: 0;
}

/* Faded out after the live burst has played for a few seconds. */
.live-donations--dismissed {
    opacity: 0;
}

.live-donation-card {
    pointer-events: auto;
    direction: rtl;        /* gem on the right, text reads right-to-left */
    display: flex;
    align-items: center;
    gap: 14px;
    background: #ffffff;
    color: #1d3a5f;
    border-radius: 16px;
    padding: 16px 18px;
    box-shadow: 0 10px 30px rgba(13, 32, 58, 0.22);
    position: relative;
    opacity: 0;
    transform: translateX(120%) scale(0.9);
    transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.4s ease;
}

/* Visible state (added by JS on the next frame after insertion). */
.live-donation-card.is-in {
    opacity: 1;
    transform: translateX(0) scale(1);
}

/* Leaving state (added by JS before removal). */
.live-donation-card.is-out {
    opacity: 0;
    transform: translateX(120%) scale(0.9);
}

/* Navy circular "gem" avatar that sits on the right edge of the card. */
.live-donation-card__avatar {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.4rem;
    background: linear-gradient(145deg, #2c5a8c, #1d3a5f 55%, #16314f);
    box-shadow: 0 6px 16px rgba(13, 32, 58, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.25);
    animation: ld-gem-pulse 2.4s ease-in-out infinite;
}

@keyframes ld-gem-pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 6px 16px rgba(13, 32, 58, 0.35), inset 0 1px 2px rgba(255, 255, 255, 0.25); }
    50%      { transform: scale(1.07); box-shadow: 0 8px 22px rgba(31, 86, 140, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.35); }
}

.live-donation-card__avatar .bi { filter: drop-shadow(0 0 4px rgba(120, 190, 255, 0.6)); }

/* Handshake icon inside the avatar. */
.live-donation-card__avatar .ld-handshake {
    width: 30px;
    height: 30px;
    filter: drop-shadow(0 0 4px rgba(120, 190, 255, 0.5));
}

.live-donation-card__body {
    text-align: right;
    min-width: 0;
    flex: 1;
}

.live-donation-card__name {
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.2;
    color: #2a4a73;
    word-break: break-word;
}

.live-donation-card__amount {
    font-weight: 800;
    font-size: 1.55rem;
    line-height: 1.15;
    margin-top: 2px;
    color: #1d3a5f;
    white-space: nowrap;
}

.live-donation-card__note {
    font-size: 0.8rem;
    font-style: italic;
    color: #5b7a9c;
    opacity: 0.95;
    margin-top: 3px;
    word-break: break-word;
}

/* Green "NEW" badge for donations that arrived since the user last saw the feed. */
.live-donation-card--new .live-donation-card__badge {
    position: absolute;
    top: -10px;
    left: 14px;            /* RTL: the "start-opposite" corner, matching the mockup */
    background: #5fa516;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.02em;
    padding: 4px 12px;
    border-radius: 999px;
    box-shadow: 0 4px 10px rgba(95, 165, 22, 0.45);
    animation: ld-badge-pop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    white-space: nowrap;
}

/* Hide the badge element entirely when the donation isn't new. */
.live-donation-card:not(.live-donation-card--new) .live-donation-card__badge {
    display: none;
}

@keyframes ld-badge-pop {
    0%   { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Countdown bubble: "the window will close in N seconds", with a gold arc that
   shrinks as time runs out. */
.live-donations__countdown {
    pointer-events: auto;
    align-self: center;
    margin-top: 4px;
}

/* Register the arc angle so it can smoothly tween between countdown ticks. */
@property --ld-cd-deg {
    syntax: '<angle>';
    inherits: false;
    initial-value: 360deg;
}

.ld-cd-ring {
    --ld-cd-deg: 360deg;
    width: 104px;
    height: 104px;
    border-radius: 50%;
    padding: 6px;
    background:
        conic-gradient(#e9b949 var(--ld-cd-deg), rgba(255, 255, 255, 0.18) 0) border-box;
    box-shadow: 0 8px 22px rgba(13, 32, 58, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: --ld-cd-deg 0.1s linear;
}

.ld-cd-inner {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: #1d3a5f;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 6px;
}

.ld-cd-top {
    font-size: 0.6rem;
    line-height: 1.05;
    opacity: 0.85;
    max-width: 80px;
}

.ld-cd-num {
    font-size: 1.7rem;
    font-weight: 800;
    line-height: 1;
    color: #e9b949;
}

.ld-cd-unit {
    font-size: 0.62rem;
    opacity: 0.85;
}

/* Tablet: slightly smaller. */
@media (max-width: 991.98px) {
    .live-donations {
        width: 290px;
        top: 96px;
    }
    .live-donation-card { padding: 13px 15px; }
    .live-donation-card__avatar { width: 50px; height: 50px; font-size: 1.25rem; }
    .live-donation-card__amount { font-size: 1.35rem; }
}

/* Phones: dock to the bottom so it doesn't cover the hero/content, and shrink.
   JS also limits the visible count by available height. */
@media (max-width: 575.98px) {
    .live-donations {
        top: auto;
        bottom: 84px;       /* above the sticky mobile donate bar */
        right: 8px;
        left: 8px;
        width: auto;
        max-width: none;
        max-height: 60vh;   /* keep it to the lower screen; scrolls if taller */
        gap: 10px;
    }
    .live-donation-card { padding: 10px 13px; }
    .live-donation-card__avatar { width: 44px; height: 44px; font-size: 1.1rem; }
    .live-donation-card__amount { font-size: 1.2rem; }
    .live-donation-card__note { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    .live-donation-card {
        transition: opacity 0.3s ease;
        transform: none;
    }
    .live-donation-card.is-in { transform: none; }
    .live-donation-card.is-out { transform: none; }
    .live-donation-card__avatar { animation: none; }
    .live-donation-card--new .live-donation-card__badge { animation: none; }
}
