/* ============================================================================
 * RobotChallenge 2026 — Sistema visual "Pista"
 * Tokens compartidos + componentes. Referencia: docs/diseno/revision-diseno.html
 * ============================================================================ */

:root {
    /* Paleta "marino" (afiches 2024–2026, ver docs/diseno/paleta-afiches.md): un color por función.
       La paleta anterior (grafito + ámbar) sigue disponible con la clase .paleta-grafito (abajo). */
    --pista: #0b253a;          /* fondo: azul marino del afiche */
    --tawara: #ffffff;
    --arranque: #c8102e;       /* rojo de marca: fondos de botones (texto blanco 5.9:1) */
    --arranque-hover: #a50d26;
    --arranque-texto: #ff5a6e; /* rojo usado COMO TEXTO sobre fondo oscuro (5.2:1 sobre --pista) */
    --chispa: #2ccdf3;         /* cian del título: en vivo / ronda actual / foco */
    --acero: #8fa3b5;
    --grafito: #12324d;
    --borde-oscuro: #1d4260;
    --texto-fuerte: #fff;      /* titulos y datos sobre --pista */
    --texto-suave: #d5dde5;    /* parrafos sobre --pista */
    --anillo: #163a57;         /* circulo del dohyo decorativo */
    --borde-fuerte: #2a5576;   /* bordes que deben notarse (tarjetas de llave) */
    --tinta: #0b253a;          /* texto sobre paneles SIEMPRE blancos (Mi Cuenta, formularios): no cambia con el tema */
    --pista-rgb: 11, 37, 58;   /* para rgba(var(--pista-rgb), .7) */
    --velo-rgb: 11, 37, 58;    /* velo sobre fotos con texto blanco encima: no cambia con el tema */
    --texto-suave-light: #3b414b;  /* parrafos dentro de .pista-light */
    --borde-light: #cfd2d6;        /* bordes dentro de .pista-light */

    /* Tipografía */
    --hf: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
    --bf: "Figtree", "Segoe UI", system-ui, sans-serif;

    /* Medidas */
    --r-s: 6px;
    --r-m: 14px;
    --r-l: 28px;
    --max: 1120px;
    --ease: cubic-bezier(.22, .8, .24, 1);

    /* Nombres antiguos que aún usan los plugins (rc-teams.css, rc-tournaments.css) */
    --red: var(--arranque);
    --red2: var(--arranque);
    --ink: var(--pista);
    --ink2: var(--grafito);
    --mute: #5a6372;
    --line: #e4e6eb;
    --paper: #f3f4f7;
}

/* Tema "fondo blanco": se activa con <html data-theme="invertido"> (ver functions.php §6).
   No es el opuesto del oscuro: todo va sobre blanco, las tarjetas en gris muy claro y el texto en tinta.
   El rojo de marca no cambia. */
:root[data-theme="invertido"] {
    color-scheme: light;
    --pista: #ffffff;          /* fondo de pagina y de bloques */
    --grafito: #f3f4f7;        /* tarjetas, celdas, miniaturas */
    --tawara: #0b253a;         /* texto principal (marino) */
    --texto-fuerte: #0b253a;   /* titulos */
    --texto-suave: #3b414b;    /* parrafos */
    --acero: #5a6372;          /* texto secundario, etiquetas */
    --borde-oscuro: #e4e6eb;   /* separadores */
    --borde-fuerte: #c3c8cf;
    --anillo: #eceef1;
    --pista-rgb: 255, 255, 255;
    --chispa: #0b6f91;         /* cian oscurecido: el cian del afiche sobre blanco no se lee (1.9:1); este 5.7:1 */
    --arranque-texto: #c8102e;
    --texto-suave-light: #3b414b;
    --borde-light: #e4e6eb;
}

/* Paleta anterior "grafito" (gris + ámbar), guardada para páginas futuras.
   Uso: class="paleta-grafito" en el contenedor del bloque. Solo cambia los tokens dentro de él.
   Documentación: docs/diseno/paleta-pista-grafito.md */
.paleta-grafito {
    --pista: #0d1117;
    --tawara: #f4f5f2;
    --chispa: #ffb020;
    --acero: #8b93a1;
    --grafito: #1b212b;
    --borde-oscuro: #2c333e;
    --texto-fuerte: #fff;
    --texto-suave: #d5d8dd;
    --anillo: #252c37;
    --borde-fuerte: #3a4250;
    --tinta: #0d1117;
    --pista-rgb: 13, 17, 23;
    --velo-rgb: 13, 17, 23;
    --arranque-texto: #ff4d63;
}
:root[data-theme="invertido"] .paleta-grafito {
    --pista: #ffffff;
    --grafito: #f3f4f7;
    --tawara: #0d1117;
    --texto-fuerte: #0d1117;
    --texto-suave: #3b414b;
    --acero: #5a6372;
    --borde-oscuro: #e4e6eb;
    --borde-fuerte: #c3c8cf;
    --anillo: #eceef1;
    --pista-rgb: 255, 255, 255;
    --chispa: #b86e00;
    --arranque-texto: #c8102e;
}
/* Astra pone color a todo h1–h6 (--ast-global-color-2, azul #0F172A) y a body/p (--ast-global-color-3).
   Dentro de nuestros bloques "Pista" se redirigen a los tokens, así los textos sin clase siguen el tema.
   Solo en estos contenedores: fuera de ellos el fondo de Astra es blanco y sus colores sirven. */
.pista, .rch, .rc-torneo-wrap, .ev, .rc-cuenta-header, .rc-cuenta-guest, .wp-block-tabs, .paleta-grafito,
body .rc:not(:has(.rc-cuenta-panel, .rc-cuenta-guest)) {
    --ast-global-color-2: var(--texto-fuerte);
    --ast-global-color-3: var(--texto-suave);
}

/* Dentro de una sección clara los títulos sin clase van oscuros (si no, heredan el blanco de .pista) */
.pista-light { --ast-global-color-2: var(--pista); --ast-global-color-3: var(--texto-suave-light); }
:root[data-theme="invertido"] .pista-light { --ast-global-color-2: var(--texto-fuerte); }
/* Las secciones claras no se vuelven oscuras: pasan a gris muy claro */
:root[data-theme="invertido"] .pista-light { background: var(--grafito); color: var(--tawara); }
/* Cajas que en oscuro se distinguen por su fondo: en blanco se marcan con un borde */
:root[data-theme="invertido"] .rc-cuenta-guest,
:root[data-theme="invertido"] .rc-torneo-wrap { border: 2px solid var(--tinta); }

/* ── Estados de torneo ── */
.rc-badge {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .3rem .75rem;
    border-radius: var(--r-s);
    font: 600 .85rem var(--bf);
    background: var(--grafito);
    color: var(--tawara);
}
.rc-badge--en-curso { background: var(--chispa); color: var(--pista); }
.rc-badge--en-curso::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pista-pulse 1.6s infinite;
}
.rc-badge--finalizado { background: transparent; color: var(--acero); box-shadow: inset 0 0 0 1px var(--borde-oscuro); }

@keyframes pista-pulse { 50% { opacity: .25; } }

/* ============================================================================
 * Componentes "pista-" para páginas nuevas (categorías, inicio, eventos)
 * ============================================================================ */

.pista {
    font-family: var(--bf);
    color: var(--tawara);
    background: var(--pista);
}
.pista :focus-visible { outline: 3px solid var(--chispa); outline-offset: 3px; }
.pista-wrap { max-width: var(--max); margin: 0 auto; padding: 0 clamp(1rem, 4vw, 2.5rem); }
.pista-sec { padding: clamp(3rem, 8vw, 6rem) 0; }
.pista-light { background: var(--tawara); color: var(--pista); }

/* Escala tipográfica 1.25 */
.pista-display { font-family: var(--hf); font-weight: 800; font-size: clamp(3rem, 1.5rem + 7vw, 7.5rem); line-height: .92; letter-spacing: -.035em; margin: 0; }
.pista-h1 { font-family: var(--hf); font-weight: 800; font-size: clamp(2.2rem, 1.4rem + 3vw, 3.6rem); line-height: 1; letter-spacing: -.025em; margin: 0; }
.pista-h2 { font-family: var(--hf); font-weight: 700; font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.3rem); line-height: 1.1; letter-spacing: -.015em; margin: 0; }
.pista-h3 { font-family: var(--hf); font-weight: 700; font-size: 1.35rem; line-height: 1.2; margin: 0; }
.pista-body { font-size: 1.0625rem; max-width: 62ch; color: var(--texto-suave); margin: 0; }
.pista-light .pista-body { color: var(--texto-suave-light); }
.pista-small { font-size: .875rem; color: var(--acero); }

/* Hero inmersivo con anillo de dohyo */
.pista-hero { position: relative; min-height: 92vh; display: grid; align-items: end; padding: 5rem 0 4rem; isolation: isolate; overflow: hidden; }
.pista-hero .pista-ring { position: absolute; inset: auto -18vw -45vw auto; width: 115vw; max-width: 1500px; z-index: -1; pointer-events: none; }
.pista-ring circle { fill: none; stroke: var(--anillo); stroke-width: 14; }
.pista-ring line { stroke: var(--arranque); stroke-width: 14; }
.pista-when { display: flex; flex-wrap: wrap; gap: .5rem 2rem; margin-top: 2rem; }
.pista-when span { display: block; color: var(--acero); }
.pista-when b { display: block; font-family: var(--hf); font-size: 1.6rem; color: var(--texto-fuerte); }

/* Botones: solo dos */
.pista-btn { display: inline-flex; align-items: center; gap: .5rem; padding: .9rem 1.5rem; border-radius: var(--r-s); font: 600 1rem var(--bf); text-decoration: none; border: 2px solid transparent; cursor: pointer; transition: background .2s var(--ease), color .2s var(--ease); }
.pista-btn--pri { background: var(--arranque); color: #fff; }
.pista-btn--pri:hover { background: var(--arranque-hover); color: #fff; }
.pista-btn--sec { border-color: currentColor; color: inherit; background: transparent; }
.pista-btn--sec:hover { background: var(--tawara); color: var(--pista); }

/* Ficha rápida */
.pista-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); border-top: 2px solid currentColor; }
.pista-fact { padding: 1.25rem 1.25rem 1.5rem 0; }
.pista-fact b { display: block; font-family: var(--hf); font-size: clamp(2rem, 1.5rem + 1.5vw, 2.8rem); font-weight: 800; letter-spacing: -.02em; line-height: 1; }
.pista-fact span { color: var(--acero); font-size: .95rem; }

/* Foto + texto */
.pista-split { display: grid; grid-template-columns: 1.1fr 1fr; gap: clamp(1.5rem, 4vw, 3.5rem); align-items: center; }
.pista-photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--r-l); background: var(--grafito); }

/* Aviso de regla clave */
.pista-rule { display: grid; grid-template-columns: auto 1fr; gap: 1rem; align-items: center; padding: 1.25rem 1.5rem; border-radius: var(--r-m); background: var(--arranque); color: #fff; font-size: 1.15rem; font-weight: 600; }
.pista-rule svg { width: 28px; height: 28px; }

/* Acordeón */
.pista details { border-bottom: 1px solid var(--borde-oscuro); }
.pista-light details { border-color: var(--borde-light); }
.pista summary { list-style: none; display: flex; justify-content: space-between; align-items: center; padding: 1.1rem 0; cursor: pointer; font-family: var(--hf); font-size: 1.25rem; font-weight: 700; }
.pista summary::-webkit-details-marker { display: none; }
.pista summary::after { content: ""; width: 12px; height: 12px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .25s var(--ease); }
.pista details[open] summary::after { transform: rotate(-135deg); }
.pista details > :not(summary) { margin: 0 0 1.25rem; max-width: 62ch; }

/* Revelado al hacer scroll (rc-motion.js añade .is-in) */
.pista-reveal { opacity: 0; transform: translateY(28px); transition: opacity .9s var(--ease), transform .9s var(--ease); }
.pista-reveal.is-in { opacity: 1; transform: none; }

/* Lenis */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: hidden; }

@media (max-width: 1024px) {
    .pista-split { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .pista-reveal { opacity: 1; transform: none; transition: none; }
    .rc-badge--en-curso::before { animation: none; }
}

/* El botón de cambio de tema vive en el plugin robotchallenge-theme-toggle. */
