/* ─────────────────────────────────────────────────────────────────────────
   Rank-up modal — "Subiste de rango"
   Premium PURPL styling with an animated Bronce → Plata badge morph.
   Built on top of the shared .me-modal / PurplSupportModal system.
   ───────────────────────────────────────────────────────────────────────── */

:root {
    --rankup-purple: #3d15ce;
    --rankup-purple-light: #9046ea;
    --rankup-gradient: linear-gradient(135deg, #3d15ce 0%, #9046ea 100%);
}

/* Blurred + darkened page backdrop, strong focus on the dialog. */
.me-modal--rankup {
    z-index: 1200;
}

.me-modal--rankup .me-modal__backdrop {
    background: rgba(17, 24, 27, 0.55);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    /* Fixed + large-viewport height para que el blur cubra toda la pantalla
       aunque la barra dinámica del navegador móvil se muestre u oculte. */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    height: 100vh;   /* fallback navegadores viejos */
    height: 100lvh;  /* siempre la altura máxima del viewport */
}

.me-modal--rankup .me-modal__dialog {
    max-width: 420px;
    padding: 32px 28px 26px;
    text-align: center;
    overflow: hidden;
    background:
        radial-gradient(140% 90% at 50% -10%, rgba(144, 70, 234, 0.16) 0%, rgba(144, 70, 234, 0) 58%),
        #ffffff;
    border: 1px solid rgba(144, 70, 234, 0.14);
    box-shadow:
        0 32px 90px rgba(24, 8, 66, 0.34),
        0 0 0 1px rgba(61, 21, 206, 0.04) inset;
}

/* Soft ambient aura behind the badge */
.rankup-aura {
    position: absolute;
    top: -60px;
    left: 50%;
    width: 340px;
    height: 340px;
    transform: translateX(-50%);
    pointer-events: none;
    background: radial-gradient(circle at 50% 40%, rgba(144, 70, 234, 0.18) 0%, rgba(144, 70, 234, 0) 62%);
    opacity: 0;
    transition: opacity 0.6s ease;
}

.me-modal--rankup.me-modal--open .rankup-aura {
    opacity: 1;
}

/* ── Badge stage ─────────────────────────────────────────────────────────── */
.rankup-stage {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    margin: 28px auto 22px;
    perspective: 700px;
}

.rankup-badge {
    position: relative;
    width: 108px;
    height: 108px;
    border-radius: 28px;
    transform-style: preserve-3d;
    transform: rotateY(0deg) scale(1);
    box-shadow: 0 12px 30px rgba(24, 24, 27, 0.16);
    transition: box-shadow 1.4s ease;
    will-change: transform, box-shadow;
}

/* Two stacked metallic fills; the "to" fill fades in over the "from" fill. */
.rankup-badge__fill {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
}

.rankup-badge__fill::after {
    /* fine brushed-metal sheen */
    content: "";
    position: absolute;
    inset: 0;
    background:
        linear-gradient(115deg, rgba(255, 255, 255, 0.55) 0%, rgba(255, 255, 255, 0) 34%),
        linear-gradient(300deg, rgba(0, 0, 0, 0.18) 0%, rgba(0, 0, 0, 0) 46%);
    mix-blend-mode: soft-light;
}

.rankup-badge__fill--to {
    opacity: 0;
    transition: opacity 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rankup-stage.is-morphing .rankup-badge__fill--to {
    opacity: 1;
}

/* Metallic gradients per tier (misma lógica: 145deg, 4 paradas) */
/* Nuevo — gris lavanda neutro, mate (sin highlight blanco). Claramente inferior a Plata. */
.rankup-fill--nuevo    { background: linear-gradient(145deg, #b9bac6 0%, #9a9bab 42%, #838496 68%, #adaebb 100%); }
/* Bronce — cobre metálico cálido (más cobrizo, menos naranja) con reflejo suave. */
.rankup-fill--bronce   { background: linear-gradient(145deg, #e9b591 0%, #c47a52 34%, #8c4a2b 64%, #d1926b 100%); }
/* Plata — plata fría y brillante: reflejos blancos, sombras azuladas. */
.rankup-fill--plata    { background: linear-gradient(145deg, #ffffff 0%, #d6e0ea 30%, #93a6bd 64%, #f4f8fc 100%); }
/* Oro — dorado metálico cálido y premium (menos amarillo saturado, menos plástico). */
.rankup-fill--oro      { background: linear-gradient(145deg, #fff4b0 0%, #f3ce4c 34%, #c69a1c 64%, #ffe680 100%); }
/* Platino — blanco metálico muy limpio con cian sutil (sombras neutras, no hielo/agua). */
.rankup-fill--platino  { background: linear-gradient(145deg, #ffffff 0%, #edf3f4 30%, #cfd8d9 63%, #f4fbfc 100%); }
/* Diamante — cristal lavanda con reflejos blancos, violeta y azul eléctrico (rango máximo). */
.rankup-fill--diamante { background: linear-gradient(145deg, #fbf7ff 0%, #cbb8f5 30%, #8a63e0 60%, #b9c4ff 100%); }

/* Emblem — unique icon per tier. Two stacked layers: the "to" icon crossfades
   in over the "from" icon (color is fixed per tier, set inline in JS). */
.rankup-badge__emblem {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.28));
}

.rankup-badge__emblem svg {
    width: 52px;
    height: 52px;
}

.rankup-badge__emblem--from {
    opacity: 1;
    transition: opacity 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rankup-badge__emblem--to {
    opacity: 0;
    transition: opacity 1.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.rankup-stage.is-morphing .rankup-badge__emblem--from {
    opacity: 0;
}

.rankup-stage.is-morphing .rankup-badge__emblem--to {
    opacity: 1;
}

/* Metallic light sweep across the badge */
.rankup-badge__sweep {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    overflow: hidden;
    z-index: 3;
    pointer-events: none;
}

.rankup-badge__sweep::before {
    content: "";
    position: absolute;
    top: -30%;
    left: -60%;
    width: 45%;
    height: 160%;
    transform: rotate(18deg) translateX(-140%);
    background: linear-gradient(
        90deg,
        rgba(255, 255, 255, 0) 0%,
        rgba(255, 255, 255, 0.15) 30%,
        rgba(255, 255, 255, 0.92) 50%,
        rgba(255, 255, 255, 0.15) 70%,
        rgba(255, 255, 255, 0) 100%
    );
    opacity: 0;
}

.rankup-stage.is-morphing .rankup-badge__sweep::before {
    animation: rankupSweep 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.1s 1;
}

/* Soft glow halo — sits in the stage (not the badge) so it stays flat while
   the badge does its 3D rotation. */
.rankup-badge__glow {
    position: absolute;
    top: -16px;
    left: 50%;
    width: 140px;
    height: 140px;
    transform: translateX(-50%) scale(0.85);
    border-radius: 50%;
    z-index: 0;
    background: radial-gradient(circle at 50% 50%, rgba(144, 70, 234, 0.55) 0%, rgba(144, 70, 234, 0) 70%);
    opacity: 0;
    pointer-events: none;
}

.rankup-stage.is-morphing .rankup-badge__glow {
    animation: rankupGlow 1.6s ease-out 0.35s 1;
}

/* Minimal metallic particles — centered over the badge */
.rankup-particles {
    position: absolute;
    top: -20px;
    left: 50%;
    width: 148px;
    height: 148px;
    transform: translateX(-50%);
    z-index: 1;
    pointer-events: none;
}

.rankup-particle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff, #cbb4f2);
    box-shadow: 0 0 6px rgba(203, 180, 242, 0.9);
    opacity: 0;
    will-change: transform, opacity;
}

.rankup-stage.is-morphing .rankup-particle {
    animation: rankupParticle 1.4s ease-out forwards;
}

/* stagger + directions (kept subtle: 7 particles) */
.rankup-particle:nth-child(1) { --px: -46px; --py: -30px; animation-delay: 0.5s; }
.rankup-particle:nth-child(2) { --px: 40px;  --py: -40px; animation-delay: 0.62s; width: 4px; height: 4px; }
.rankup-particle:nth-child(3) { --px: 54px;  --py: 8px;   animation-delay: 0.74s; }
.rankup-particle:nth-child(4) { --px: -52px; --py: 14px;  animation-delay: 0.68s; width: 4px; height: 4px; }
.rankup-particle:nth-child(5) { --px: -24px; --py: -50px; animation-delay: 0.82s; width: 3px; height: 3px; }
.rankup-particle:nth-child(6) { --px: 26px;  --py: 46px;  animation-delay: 0.76s; }
.rankup-particle:nth-child(7) { --px: 0px;   --py: -58px; animation-delay: 0.88s; width: 3px; height: 3px; }

/* 3D rotation + scale settle applied to the badge during morph */
.rankup-stage.is-morphing .rankup-badge {
    animation: rankupMorph 2.4s cubic-bezier(0.34, 1.2, 0.4, 1) 1;
}

/* ── Tier name labels (Bronce → Plata crossfade) ─────────────────────────── */
.rankup-labels {
    position: relative;
    height: 22px;
    margin-top: 16px;
    width: 100%;
}

.rankup-label {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #71717a;
}

.rankup-label--from {
    opacity: 1;
    transform: translateY(0);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

.rankup-label--to {
    opacity: 0;
    transform: translateY(8px);
    color: var(--rankup-purple);
    transition: opacity 0.7s ease 0.35s, transform 0.7s ease 0.35s;
}

.rankup-stage.is-morphing .rankup-label--from {
    opacity: 0;
    transform: translateY(-8px);
}

.rankup-stage.is-morphing .rankup-label--to {
    opacity: 1;
    transform: translateY(0);
}

/* ── Copy ────────────────────────────────────────────────────────────────── */
.rankup-eyebrow {
    margin: 0 0 6px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--rankup-purple-light);
}

.rankup-title {
    margin: 0 0 8px;
    font-size: 25px;
    line-height: 1.15;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #18181b;
}

.rankup-title strong {
    background: var(--rankup-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: var(--rankup-purple);
}

.rankup-commission {
    margin: 0 auto 22px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 999px;
    background: #f4f4f5;
    border: 1px solid #e4e4e7;
    font-size: 13.5px;
    font-weight: 600;
    color: #52525b;
}

.rankup-commission__old {
    color: #a1a1aa;
    text-decoration: line-through;
    font-weight: 600;
}

.rankup-commission__new {
    color: var(--rankup-purple);
    font-weight: 800;
}

.rankup-commission__arrow {
    color: #b8a3ea;
}

/* ── Actions + next-rank progress ───────────────────────────────────────── */
.rankup-cta {
    width: 100%;
    padding: 13px 18px;
    font-size: 15px;
    font-weight: 700;
    border-radius: 12px;
}

.rankup-cta:focus {
    outline: none;
}

.rankup-cta:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(144, 70, 234, 0.35);
}

.rankup-next {
    margin: 18px auto 0;
}

.rankup-next__card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    border-radius: 16px;
    background: #f7f5fd;
    border: 1px solid #eceaf7;
    text-align: left;
}

.rankup-next__row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.rankup-next__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
    border-radius: 12px;
    background: #ebe5fb;
    color: var(--rankup-purple);
}

.rankup-next__icon svg {
    width: 24px;
    height: 24px;
}

.rankup-next__head {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.rankup-next__title {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.rankup-next__eyebrow {
    font-size: 11px;
    font-weight: 600;
    line-height: 1;
    color: #71717a;
    white-space: nowrap;
}

.rankup-next__rank {
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1;
    color: var(--rankup-purple);
    white-space: nowrap;
}

.rankup-next__rank-fee {
    font-size: 12.5px;
    font-weight: 600;
    color: #71717a;
}

.rankup-next__bar {
    height: 10px;
    border-radius: 999px;
    background: #e7e1f6;
    overflow: hidden;
}

.rankup-next__fill {
    display: block;
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: var(--rankup-gradient);
    transition: width 1.2s cubic-bezier(0.4, 0, 0.2, 1) 0.5s;
}

.rankup-next__hint {
    margin: 0;
    font-size: 12px;
    line-height: 1.45;
    color: #71717a;
    text-align: center;
    white-space: nowrap;
}

.rankup-next__hint strong {
    color: #3f3f46;
    font-weight: 700;
}

.rankup-next__accent {
    color: var(--rankup-purple) !important;
    font-weight: 800;
}

/* Variante rango máximo (Diamante) */
.rankup-next__head--max {
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 3px;
}

.rankup-next__title--max {
    margin: 0;
    color: var(--rankup-purple);
    font-weight: 800;
}

.rankup-next__hint--max {
    text-align: left;
    white-space: normal;
    font-size: 11.5px;
    line-height: 1.35;
}

.rankup-next__zero {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    text-align: right;
}

.rankup-next__zero-num {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
    color: var(--rankup-purple);
}

.rankup-next__zero-label {
    margin-top: 3px;
    max-width: 78px;
    font-size: 11px;
    line-height: 1.25;
    color: #71717a;
}

/* ── Keyframes ──────────────────────────────────────────────────────────── */
@keyframes rankupSweep {
    0%   { transform: rotate(18deg) translateX(-140%); opacity: 0; }
    12%  { opacity: 1; }
    88%  { opacity: 1; }
    100% { transform: rotate(18deg) translateX(360%); opacity: 0; }
}

@keyframes rankupGlow {
    0%   { opacity: 0; transform: translateX(-50%) scale(0.8); }
    40%  { opacity: 1; transform: translateX(-50%) scale(1.06); }
    100% { opacity: 0; transform: translateX(-50%) scale(1.16); }
}

@keyframes rankupParticle {
    0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.4); }
    20%  { opacity: 1; }
    100% { opacity: 0; transform: translate(calc(-50% + var(--px)), calc(-50% + var(--py))) scale(0.9); }
}

@keyframes rankupMorph {
    0%   { transform: rotateY(0deg) scale(1); }
    30%  { transform: rotateY(-24deg) scale(1.01); }
    62%  { transform: rotateY(196deg) scale(1.02); }
    82%  { transform: rotateY(360deg) scale(1.02); }
    100% { transform: rotateY(360deg) scale(1); }
}

/* ── Reduced motion: no morph, show final state instantly ───────────────── */
@media (prefers-reduced-motion: reduce) {
    .rankup-badge,
    .rankup-stage.is-morphing .rankup-badge,
    .rankup-badge__fill--to,
    .rankup-badge__emblem--from,
    .rankup-badge__emblem--to,
    .rankup-label--from,
    .rankup-label--to,
    .rankup-next__fill {
        animation: none !important;
        transition: none !important;
    }

    .rankup-badge__sweep::before,
    .rankup-badge__glow,
    .rankup-particle {
        animation: none !important;
        opacity: 0 !important;
    }
}

@media (max-width: 639px) {
    .me-modal--rankup .me-modal__dialog {
        max-width: 100%;
        padding: 28px 20px 22px;
    }
}
