/* =========================================================
   RANKING — hoja depurada, organizada y comentada
   ---------------------------------------------------------
   ✔ Se eliminaron duplicados y se unificaron reglas.
   ✔ Loader parametrizable con variables (--loader-url/size).
   ✔ Se mantuvo buen contraste en .placa-name (texto oscuro).
   ========================================================= */

/* Suavizado de scroll en toda la página */
html {
    scroll-behavior: smooth;
}

/* ===== Scope aislado del componente de ranking ===== */
.ranking {
    /* Variables locales (no afectan al resto del sitio) */
    --ink: #0f1d3a;
    --orange-1: #ff8a00;
    --orange-2: #ff5e00;
    --yellow: #ffd84d;
    --card: #ffffff;
    --shadow: 0 12px 32px rgba(22, 114, 255, 0.16);

    /* Loader (ajusta a tu gusto) */
    --loader-url: url('../assets/fast.gif');
    /* Cambia a twemoji si quieres */
    /* Ejemplo alternativo: url('https://cdn.jsdelivr.net/gh/twitter/twemoji@14.0.2/assets/svg/1f986.svg') */
    --loader-size: 220px;

    max-width: 1100px;
    margin: 0 auto;
    padding: 28px 18px 60px;
    font-family: Poppins, system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
    color: var(--ink);
}

/* =========================================================
   HERO
   ========================================================= */
.ranking .ranking-hero {
    padding: 0 0 22px;
    margin-top: 30px;
}

.ranking .ranking-hero__inner {
    text-align: center;
}

.ranking .ranking-hero__title {
    margin: 0 0 6px;
    font-weight: 800;
    font-size: clamp(28px, 3.4vw, 42px);
    line-height: 1.15;
}

.ranking .ranking-hero__underline {
    width: 160px;
    height: 6px;
    margin: 8px auto 0;
    border-radius: 10px;
    background: linear-gradient(90deg, var(--orange-1), var(--orange-2));
    box-shadow: 0 8px 18px rgba(255, 94, 0, 0.35);
}

.ranking .ranking-hero__lead {
    max-width: 760px;
    margin: 10px auto 0;
    opacity: 0.9;
}

/* =========================================================
   PODIO (tarjetas top 3)
   ========================================================= */
.ranking .podio {
    display: flex;
    justify-content: center;
    align-items: center;
    /* centra loader */
    gap: 22px;
    flex-wrap: wrap;
    margin: 34px 0 44px;
    min-height: 320px;
    /* área estable mientras hay loader */
}

.ranking .stage {
    position: relative;
    max-width: 330px;
    text-align: center;
    background: var(--card);
    border-radius: 22px;
    padding: 24px 16px 18px;
    box-shadow: var(--shadow);
    transition: transform 0.22s ease;
}

.ranking .stage:hover {
    transform: translateY(-4px);
}

/* Orden visual escritorio: 2°, 1°, 3° */
.ranking .stage[data-podium="2"] {
    order: 1;
}

.ranking .stage[data-podium="1"] {
    order: 2;
    margin-bottom: 50px;
}

.ranking .stage[data-podium="3"] {
    order: 3;
}

/* Móvil: 1°, 2°, 3° */
@media (max-width: 900px) {
    .ranking .stage {
        max-width: 420px;
    }

    .ranking .stage[data-podium="1"] {
        order: 1;
        margin-bottom: 0;
    }

    .ranking .stage[data-podium="2"] {
        order: 2;
        margin-top: 65px;
    }

    .ranking .stage[data-podium="3"] {
        order: 3;
        margin-top: 65px;
    }
}

/* Badge de medalla */
.ranking .medal {
    position: absolute;
    top: 12px;
    left: 12px;
    padding: 6px 10px;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--orange-1), var(--orange-2));
    color: #fff;
    font-weight: 800;
}

/* Avatar/Foto del participante */
.ranking .foto {
    width: 190px;
    height: 190px;
    border-radius: 18px;
    margin: -80px auto 8px;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: center;
}

/* Placas: nombre + conteo */
.ranking .placas {
    display: grid;
    grid-template-columns: 1fr 130px;
    gap: 12px;
    margin-top: 12px;
}

.ranking .placa {
    white-space: nowrap;
    background: linear-gradient(180deg, #fff, #f7f7f7);
    border: 1px solid #eef3ff;
    border-radius: 14px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    padding: 10px 12px;
    font-size: 22px;
}

/* Mejor contraste (texto oscuro sobre amarillo) */
.ranking .placa-name {
    color: #ffffff;
    /* Cambia a #ffffff si prefieres texto blanco */
    background: linear-gradient(180deg, var(--yellow), #ffc933);
}

.ranking .placa--patos {
    border-color: #ffd24a;
}

/* =========================================================
   BOARD / TABLA DE RANKING
   ========================================================= */
.ranking .board {
    background: var(--card);
    border-radius: 22px;
    box-shadow: var(--shadow);
    padding: 18px;
}

.ranking .board__title {
    margin: 0 0 12px;
    font-weight: 800;
}

.ranking .board__tablewrap {
    width: 100%;
}

.ranking .board__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px;
}

.ranking .board__table thead th {
    text-align: left;
    opacity: 0.7;
    font-size: 0.95rem;
    padding: 8px 14px;
}

.ranking .board__table tbody tr {
    background: #fff;
    border: 1px solid #eef3ff;
    border-radius: 14px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.04);
    /* Fallback cómodo si haces scrollIntoView({block:'end'}) */
    scroll-margin-block-end: 120px;
    /* aire extra bajo el elemento */
}

.ranking .board__table tbody td {
    padding: 13px 14px;
}

.ranking .board__table tbody tr td:first-child {
    border-top-left-radius: 14px;
    border-bottom-left-radius: 14px;
}

.ranking .board__table tbody tr td:last-child {
    border-top-right-radius: 14px;
    border-bottom-right-radius: 14px;
}

.ranking .pos {
    font-weight: 700;
}

.ranking .name {
    font-weight: 700;
}

.ranking .count {
    font-weight: 800;
}

/* =========================================================
   LOADER (estado de carga)
   ========================================================= */
.ranking .loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.ranking .loader.hidden {
    opacity: 0;
    pointer-events: none;
}

.ranking .loader-duck {
    width: var(--loader-size);
    height: var(--loader-size);
    background: var(--loader-url) center/contain no-repeat;
    animation: ranking-bob 1.1s ease-in-out infinite;
    filter: drop-shadow(0 6px 14px rgba(22, 114, 255, 0.22));
}

.ranking .loader-text {
    opacity: 0.8;
    font-weight: 600;
}

.ranking .retry {
    border: 0;
    border-radius: 999px;
    padding: 10px 16px;
    background: linear-gradient(90deg, var(--orange-1), var(--orange-2));
    color: #fff;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 16px rgba(255, 94, 0, 0.25);
}

/* Animación flotante común (loader y decorativos) */
@keyframes ranking-bob {
    0% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }

    100% {
        transform: translateY(0);
    }
}

/* =========================================================
   ANIMACIONES DE APARICIÓN
   ========================================================= */
.ranking .stage.is-hidden {
    opacity: 0;
    transform: translateY(16px) scale(0.96);
}

.ranking .stage.in {
    opacity: 1;
    transform: translateY(0) scale(1);
    transition: opacity 0.5s ease, transform 0.5s cubic-bezier(.2, .9, .2, 1);
}

/* Filas: se insertan con 'row-pre' y pasan a 'row-in' */
.ranking .board__table tbody tr.row-pre {
    opacity: 0;
    transform: translateY(8px);
}

.ranking .board__table tbody tr.row-in {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* =========================================================
   MENSAJE MOTIVACIONAL (dinámico)
   ========================================================= */
.ranking .ranking-note {
    position: relative;
    margin-top: 80px;
    text-align: center;
}

.ranking .note-line {
    margin: 0.25rem 0;
    color: var(--ink);
    line-height: 1.2;
    letter-spacing: -0.01em;
    font-weight: 700;
    font-size: clamp(18px, 2.2vw, 24px);
}

.ranking .note-line--lead {
    font-size: clamp(22px, 3vw, 28px);
    font-weight: 800;
}

.ranking .note-line--cta {
    font-size: clamp(20px, 2.6vw, 26px);
}

/* Acentos en degradado con brillo sutil */
.ranking .accent {
    background: linear-gradient(90deg, var(--orange-1), var(--orange-2));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    background-size: 200% 100%;
    animation: ranking-accent-sheen 5s linear infinite;
}

/* Patito decorativo con bob sutil */
.ranking .ranking-note::after {
    content: "";
    position: absolute;
    right: -6px;
    top: -10px;
    width: 56px;
    height: 56px;
    background: url('../assets/adoptado.webp') center/contain no-repeat;
    filter: drop-shadow(0 8px 16px rgba(22, 114, 255, 0.18));
    animation: ranking-duck-bob 1.4s ease-in-out infinite;
    opacity: 0.95;
}

/* Móvil: patito arriba y centrado */
@media (max-width: 900px) {

    /* centramos el texto también */
    .ranking .ranking-note {
        text-align: center;
    }

    /* ocultamos el ::after original (esquina) */
    .ranking .ranking-note::after {
        content: none !important;
    }

    /* pintamos el patito encima del texto */
    .ranking .ranking-note::before {
        content: "";
        display: block;
        width: clamp(56px, 18vw, 84px);
        height: clamp(0px, 18vw, 84px);
        margin: 0 auto 12px;
        /* centrado + separación del texto */
        background: url('../assets/adoptado.webp') center/contain no-repeat;
        filter: drop-shadow(0 8px 16px rgba(22, 114, 255, .18));
        animation: ranking-duck-bob 1.4s ease-in-out infinite;
        opacity: .95;
    }

    .ranking .ranking-note {
        margin-top: 25px;
    }
}

@keyframes ranking-accent-sheen {
    0% {
        background-position: 0% 50%;
    }

    100% {
        background-position: 200% 50%;
    }
}

@keyframes ranking-duck-bob {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* =========================================================
   ACCESIBILIDAD: REDUCIR MOVIMIENTO
   ========================================================= */
@media (prefers-reduced-motion: reduce) {
    .ranking * {
        animation: none !important;
        transition: none !important;
    }

    .ranking .accent,
    .ranking .ranking-note::after {
        animation: none !important;
    }
}

/* Deja aire arriba cuando hacemos scroll hacia cada tarjeta del podio en móvil */
@media (max-width: 900px) {
  .ranking .stage { scroll-margin-top: 400px; } /* ajusta 56px si tienes header fijo más alto/bajo */
}