/* =====================================================================
   CANS ONLINE — Fase 4: rankings de rachas por app y nombre preferido (26 oct 2026)
   Lo usan views/rankings.js, views/group-rankings.js y views/name-pick.js.
   Movimiento reducido: app.css ya acorta todas las animaciones.
   ===================================================================== */
@keyframes rk-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes rk-pop { 0% { opacity: 0; transform: scale(.4); } 70% { opacity: 1; transform: scale(1.12); } 100% { transform: scale(1); } }
@keyframes rk-swap { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
@keyframes rk-glow { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 131, 0, 0); } 50% { box-shadow: 0 0 0 6px rgba(255, 131, 0, .25); } }

.rank-flame { fill: #ff8300; }
.rank-flame-in { fill: #ffc83d; }
.rank-streak { display: inline-flex; align-items: center; gap: 3px; font-weight: 900; color: var(--flame-ink, #b35400); }
.rank-streak.cold .rank-flame { fill: var(--border-strong); }
.rank-badge { width: 32px; height: 32px; flex: 0 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 14px; font-weight: 900; background: var(--brand-soft); color: var(--brand); }
.rank-badge.medal { background: var(--medal); color: #2b1500; }
.rank-name { flex: 1; min-width: 0; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rank-swap { display: flex; flex-direction: column; gap: 16px; animation: rk-swap .3s var(--ease) both; }

/* ------------------------------------------------------------ alumno */
.rank-tabs, .rank-kids { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.rank-tab, .rank-kid { min-height: 48px; border-radius: 14px; border: 2px solid var(--border); border-bottom-width: 4px; background: var(--bg-elev); color: var(--text); font: inherit; font-weight: 900; cursor: pointer; transition: transform .1s ease-out, background-color .15s, border-color .15s; }
.rank-tab:active, .rank-kid:active { transform: translateY(3px); }
.rank-tab.on, .rank-kid.on { background: var(--brand-soft); border-color: color-mix(in srgb, var(--brand) 35%, transparent); color: var(--brand); }
.rank-kid { display: flex; align-items: center; gap: 10px; padding: 8px 12px; text-align: left; }
.rank-kid .avatar { box-shadow: 0 0 0 2px var(--bg-elev), 0 0 0 5px var(--sec, var(--border-strong)); }
.rank-kid-text { display: flex; flex-direction: column; min-width: 0; }
.rank-kid-text small { font-size: 12px; color: var(--text-2); font-weight: 700; }

.rank-hero { position: relative; overflow: hidden; isolation: isolate; display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 22px; background: #0c3292; color: #fff; border-bottom: 6px solid var(--hero-sec, #071e5c); animation: rk-rise .45s var(--ease) both; }
.rank-hero .cans-pattern { opacity: .1; }
.rank-medal { width: 82px; height: 82px; flex: 0 0 auto; border-radius: 50%; background: #fff; color: #0c3292; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; animation: rk-pop .55s var(--ease) .15s both; }
.rank-medal small { font-size: 11px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.rank-medal strong { font-size: 34px; font-weight: 900; font-variant-numeric: tabular-nums; }
.rank-medal.small { width: 72px; height: 72px; background: #0c3292; color: #fff; border-bottom: 5px solid var(--hero-sec, #071e5c); }
.rank-medal.small strong { font-size: 28px; }
.rank-hero-text { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rank-hero-text strong { font-size: 20px; font-weight: 900; }
.rank-hero-text span { font-weight: 700; }
.rank-hero .rank-hero-text span { color: rgba(255, 255, 255, .88); }
.rank-strip { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 16px; background: var(--warn-soft); color: var(--warn); font-weight: 800; }
.rank-strip svg { flex: 0 0 auto; }

.rank-list { gap: 2px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 14px; border: 2px solid transparent; animation: rk-rise .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 50ms + 150ms); }
.rank-row.me { background: var(--warn-soft); border-color: #ff8300; animation: rk-rise .4s var(--ease) both, rk-glow 2s ease-in-out 1.2s infinite; animation-delay: calc(var(--i, 0) * 50ms + 150ms), 1.2s; }
.rank-gap { text-align: center; font-size: 22px; font-weight: 900; color: var(--text-3); line-height: 1; }

/* ------------------------------------------------------------ familia */
.rank-parent { border-bottom-color: var(--hero-sec, var(--border)); }
.rank-parent-main { display: flex; align-items: center; gap: 14px; }
.rank-explain { border-radius: 20px; background: var(--brand-soft); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.rank-explain strong { color: var(--brand); font-size: 16px; }
.rank-explain p { font-weight: 700; line-height: 1.45; }
.rank-tip { display: flex; gap: 10px; align-items: flex-start; animation: rk-rise .4s var(--ease) both; animation-delay: calc(var(--i, 0) * 70ms + 100ms); }
.rank-tip > span { width: 28px; height: 28px; flex: 0 0 auto; border-radius: 50%; background: #ff8300; color: #2b1500; display: grid; place-items: center; font-weight: 900; }
.rank-tip p { font-weight: 700; line-height: 1.4; }

/* ------------------------------------------------------------ docente: filtros y top general */
.rank-group .page-tools { align-items: center; }
.rank-filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.rank-app-chip { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 900; }
.rank-hls { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; margin-bottom: 16px; }
.rank-hl { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 20px; background: var(--bg-elev); border: 2px solid var(--border); border-bottom-width: 5px; animation: rk-rise .45s var(--ease) both; }
.rank-hl > div { display: flex; flex-direction: column; min-width: 0; }
.rank-hl small { font-size: 12px; font-weight: 900; letter-spacing: .06em; text-transform: uppercase; }
.rank-hl strong { font-size: 20px; font-weight: 900; }
.rank-hl span { font-size: 14px; font-weight: 700; color: var(--text-2); }
.rank-hl .avatar { animation: rk-pop .5s var(--ease) .2s both; }
.rank-hl.longest small { color: var(--flame-ink, #b35400); } .rank-hl.longest .avatar { box-shadow: 0 0 0 3px var(--bg-elev), 0 0 0 6px #ffc83d; }
.rank-hl.most small { color: #0049d4; } .rank-hl.most .avatar { box-shadow: 0 0 0 3px var(--bg-elev), 0 0 0 6px #00b4ff; }
.rank-hl.evolved small { color: var(--ok); } .rank-hl.evolved .avatar { box-shadow: 0 0 0 3px var(--bg-elev), 0 0 0 6px #1f8a3e; }
.rank-hl-empty { width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center; background: var(--bg-sunken); }
.rank-table { gap: 0; padding: 0 0 12px; overflow: hidden; }
.rank-table > .muted { padding: 10px 18px 0; }
.rank-tr { display: grid; grid-template-columns: 56px minmax(0, 1fr) 90px 120px 100px 110px; gap: 8px; align-items: center; padding: 8px 18px; border-top: 2px solid var(--border); font-weight: 800; animation: rk-rise .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 35ms); }
.rank-tr.head { border-top: 0; background: var(--bg-sunken); font-size: 12px; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; color: var(--text-2); animation: none; }
.rank-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rank-idle { font-size: 12px; font-weight: 900; padding: 3px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); white-space: nowrap; }
.rank-trend.up { color: var(--ok); } .rank-trend.down { color: #c2410c; }
@media (max-width: 640px) {
  .rank-tr { grid-template-columns: 44px minmax(0, 1fr) 70px; padding: 8px 12px; }
  .rank-idle { display: none; }
}

/* ------------------------------------------------------------ docente: Top 10 para proyectar */
.r10-stage { position: relative; overflow: hidden; isolation: isolate; border-radius: 26px; background: #0c3292; color: #fff; padding: 26px 28px 30px; display: flex; flex-direction: column; gap: 18px; }
.r10-stage:fullscreen { border-radius: 0; padding: 40px 48px; justify-content: center; }
.r10-stage .cans-pattern { opacity: .1; }
.r10-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.r10-head h2 { font-size: clamp(28px, 4vw, 42px); font-weight: 900; color: #fff; margin-top: 6px; }
.r10-head p { color: rgba(255, 255, 255, .85); font-weight: 800; }
.r10-full { color: #fff; background: rgba(255, 255, 255, .14); }
.r10-full:hover { background: rgba(255, 255, 255, .24); color: #fff; }
.r10-body { display: grid; grid-template-columns: minmax(0, 640px) minmax(0, 1fr); gap: 32px; align-items: center; }
.r10-list { position: relative; }
.r10-slot { position: absolute; left: 0; right: 0; top: 0; height: 58px; transition: transform 1.5s cubic-bezier(.34, 1.25, .64, 1); }
.r10-card { height: 58px; box-sizing: border-box; display: flex; align-items: center; gap: 12px; padding: 0 16px 0 10px; border-radius: 18px; background: #fff; border-bottom: 5px solid #c9d3ef; color: #1f2a44; }
.r10-card .rank-badge { width: 40px; height: 40px; font-size: 19px; background: #eef2fb; color: #0c3292; }
.r10-card .rank-badge.medal { background: var(--medal); color: #2b1500; animation: rk-pop .45s var(--ease) both; }
.r10-card .avatar { box-shadow: 0 0 0 3px #fff, 0 0 0 5px #00b4ff; }
.r10-name { flex: 1; min-width: 0; font-size: 21px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r10-streak { display: inline-flex; align-items: center; gap: 4px; min-width: 78px; justify-content: flex-end; }
.r10-num { font-size: 26px; font-weight: 900; color: #b35400; font-variant-numeric: tabular-nums; }
.r10-arrow { display: inline-grid; }
.r10-arrow.up path { fill: #1f8a3e; } .r10-arrow.down path { fill: #d9480f; }
.r10-arrow svg { animation: rk-pop .5s var(--ease) both; }
/* El que sube crece (zoom) mientras corre; el que baja se encoge un poco */
@keyframes r10-zoom-up { 0% { transform: scale(1); } 35% { transform: scale(1.12); box-shadow: 0 18px 40px rgba(0, 0, 0, .35); } 100% { transform: scale(1); } }
@keyframes r10-zoom-down { 0% { transform: scale(1); } 40% { transform: scale(.95); opacity: .8; } 100% { transform: scale(1); opacity: 1; } }
.r10-slot.up { z-index: 3; }
.r10-slot.up .r10-card { animation: r10-zoom-up 1.5s ease-in-out both; }
.r10-slot.down .r10-card { animation: r10-zoom-down 1.5s ease-in-out both; }

.r10-side { position: relative; min-height: 420px; display: flex; align-items: center; justify-content: center; }
.r10-start { display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; animation: rk-rise .45s var(--ease) both; }
.r10-start p { font-size: 20px; font-weight: 800; color: rgba(255, 255, 255, .92); max-width: 320px; }
@keyframes r10-pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
.r10-go { min-height: 70px; padding: 0 36px; font-size: 24px; border-radius: 22px; box-shadow: 0 7px 0 #b35400; animation: r10-pulse 1.6s ease-in-out infinite; }
.r10-go:active { transform: translateY(7px); box-shadow: 0 0 0 #b35400; animation: none; }
.btn3d.light { background: #fff; color: #0c3292; box-shadow: 0 5px 0 #c9d3ef; }
.btn3d.light:active { box-shadow: 0 0 0 #c9d3ef; }
.r10-podium-wrap { position: relative; width: 100%; display: flex; flex-direction: column; align-items: center; gap: 22px; }
.r10-podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; width: 100%; min-height: 430px; }
@keyframes r10-rise { from { transform: translateY(120%); opacity: 0; } to { transform: none; opacity: 1; } }
.r10-col { flex: 1; max-width: 170px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.r10-col.c3 { animation: r10-rise .7s cubic-bezier(.34, 1.3, .64, 1) .1s both; }
.r10-col.c2 { animation: r10-rise .7s cubic-bezier(.34, 1.3, .64, 1) .45s both; }
.r10-col.c1 { animation: r10-rise .8s cubic-bezier(.34, 1.3, .64, 1) .85s both; }
.r10-col .avatar { box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--medal); }
.r10-col strong { font-size: 21px; font-weight: 900; color: #fff; }
.r10-col > span:not(.avatar) { font-size: 16px; font-weight: 800; color: #ffd27a; }
.r10-col .avatar { background: #eef2fb; color: #0c3292; }
.r10-step { width: 100%; border-radius: 18px 18px 0 0; background: var(--medal); color: #2b1500; font-size: 46px; font-weight: 900; display: flex; justify-content: center; padding-top: 10px; box-sizing: border-box; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .12); }
.r10-crown path { fill: #ffc83d; stroke: #b35400; stroke-width: 2.5; stroke-linejoin: round; }
.r10-crown { animation: rk-pop .6s var(--ease) 1.5s both; }
.r10-again { min-height: 50px; padding: 0 28px; }
.r10-podium-wrap .cel-confetti { top: 20%; }
@media (max-width: 900px) {
  .r10-body { grid-template-columns: 1fr; }
  .r10-side { min-height: 0; }
  .r10-name { font-size: 18px; }
}

/* ------------------------------------------------------------ alumno: ¿cómo quieres que te llamen? */
.name-overlay { position: fixed; inset: 0; z-index: 2100; isolation: isolate; overflow: auto; background: #0c3292; display: flex; align-items: center; justify-content: center; padding: 24px 16px; animation: cel-in .25s ease both; }
.name-overlay.out { animation: cel-out .25s ease both; }
.name-overlay .cans-pattern { opacity: .12; }
.name-card { width: min(420px, 100%); background: var(--bg-elev); color: var(--text); border-radius: 26px; border-bottom: 6px solid #00b4ff; padding: 24px 20px; display: flex; flex-direction: column; align-items: stretch; gap: 14px; text-align: center; animation: rk-rise .45s var(--ease) both; }
.name-card h2 { font-size: 24px; font-weight: 900; }
.name-card p { font-weight: 700; color: var(--text-2); }
.name-card small { font-weight: 700; color: var(--text-2); }
.name-avatar { align-self: center; width: 84px; height: 84px; border-radius: 50%; display: grid; place-items: center; font-size: 30px; font-weight: 900; background: var(--brand-soft); color: var(--brand); box-shadow: 0 0 0 4px var(--bg-elev), 0 0 0 8px #00b4ff; }
.name-avatar.pop { animation: rk-pop .4s var(--ease) both; }
.name-note { background: var(--warn-soft); color: var(--warn) !important; border-radius: 12px; padding: 8px 10px; }
.name-opts { display: flex; flex-direction: column; gap: 10px; }
.name-opt { display: flex; align-items: center; justify-content: space-between; min-height: 58px; padding: 0 18px; border-radius: 16px; border: 2px solid var(--border); border-bottom-width: 5px; background: var(--bg-elev); color: var(--text); font: inherit; font-size: 20px; font-weight: 900; cursor: pointer; transition: transform .1s ease-out, border-color .15s, background-color .15s; }
.name-opt:active { transform: translateY(3px); }
.name-opt[aria-checked="true"] { border-color: var(--brand); background: var(--brand-soft); }
.name-dot { width: 26px; height: 26px; border-radius: 50%; border: 3px solid var(--border-strong); box-sizing: border-box; }
.name-opt[aria-checked="true"] .name-dot { border-color: var(--brand); background: var(--brand-solid); box-shadow: inset 0 0 0 4px var(--bg-elev); }
.name-preview strong { color: var(--brand); font-size: 18px; }
.name-send { width: 100%; }
.name-later { align-self: center; }
.name-clock { align-self: center; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; background: var(--warn-soft); color: #b35400; }

/* ---------- Rachas: apps con su portada arriba (alumno) ---------- */
.rank-tabs { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.rank-tab { display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 8px 12px 8px 8px; text-align: left; transition: transform .1s ease-out, border-color .15s, background .15s; }
.rank-tab-img { flex: none; width: 46px; height: 46px; border-radius: 12px; object-fit: cover; background: var(--bg-sunken); display: grid; place-items: center; }
.rank-tab-img.ph { background: color-mix(in srgb, #ff8a00 16%, var(--bg-elev)); }
.rank-tab-name { min-width: 0; font-weight: 900; line-height: 1.2; overflow-wrap: anywhere; }
.rank-tab.on { border-color: #ff8a00; border-bottom-color: #d96f00; background: color-mix(in srgb, #ff8a00 12%, var(--bg-elev)); color: var(--text); }
.rank-tab.on .rank-tab-img { box-shadow: 0 0 0 3px var(--bg-elev), 0 0 0 5px #ff8a00; }

/* ---------- Top 10: modo presentación (llena la pantalla en cualquier equipo) ---------- */
.r10-stage.is-max { position: fixed; inset: 0; z-index: 2000; border-radius: 0; padding: clamp(20px, 4vw, 48px); justify-content: center; overflow: auto; }
html.r10-lock, html.r10-lock body { overflow: hidden; }
.r10-full { width: 48px; height: 48px; flex: none; }

/* ---------- Top 10: chispas de fuego en lugar de confeti ---------- */
.r10-glow { position: absolute; left: 50%; bottom: 8%; width: 70%; height: 60%; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(255, 176, 32, .45), rgba(255, 120, 0, .12) 60%, transparent); opacity: 0; animation: r10-glow 1.2s ease-out 1.3s forwards; pointer-events: none; }
@keyframes r10-glow { to { opacity: 1; } }
.r10-ember { position: absolute; bottom: 18%; width: var(--sz, 7px); height: var(--sz, 7px); border-radius: 50%; background: radial-gradient(circle, #fff6c2 0 30%, #ffb020 55%, rgba(255, 106, 0, 0) 75%); opacity: 0; pointer-events: none; animation: r10-ember 3s ease-out infinite; }
@keyframes r10-ember { 0% { opacity: 0; transform: translate(0, 0) scale(.6); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(var(--drift, 0), -260px) scale(1.15); } }
@media (prefers-reduced-motion: reduce) { .r10-ember, .r10-glow { animation: none; } }
