/* CLUTCHMX — responsive global (mobile-first, pre-producción) */

:root {
    --bp-xs: 360px;
    --bp-sm: 480px;
    --bp-md: 768px;
    --bp-lg: 900px;
    --bp-xl: 1024px;
    --bp-2xl: 1366px;

    --page-pad-x: 16px;
    --touch-min: 44px;
    --nav-height: 56px;

    /* Espaciado inferior de página: safe-area + respiro mínimo */
    --page-end-spacing: 16px;
    --page-end-inset: calc(var(--page-end-spacing) + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
    :root { --page-pad-x: 24px; }
}

@media (min-width: 1024px) {
    :root { --page-pad-x: 32px; }
}

/* Sin scroll horizontal global */
html {
    overflow-x: clip;
    max-width: 100%;
}

body {
    overflow-x: clip;
    max-width: 100%;
    min-width: 0;
}

.app-container,
.main-content,
.admin-body,
.admin-main,
.sa-shell,
.la-page {
    min-width: 0;
    max-width: 100%;
}

.main-content {
    padding-inline: var(--page-pad-x);
    box-sizing: border-box;
}

@media (max-width: 768px) {
    :root {
        --page-end-spacing: 12px;
    }

    /*
     * Contenedores raíz: un solo respiro inferior (sustituye 48–80px legacy + bottom nav fantasma).
     * !important solo vence shorthand padding: … 72px en hojas de página antiguas.
     */
    .rnk-page,
    .nws-page,
    .ligas-body,
    .jug-body,
    .about-page,
    .privacy-consent-page,
    .ctx-page,
    .ajp-page,
    .ux-app-dash,
    .sp-page,
    .lv-content {
        padding-bottom: var(--page-end-inset) !important;
    }
}

/* Touch targets mínimos en móvil (excluye puntos de carrusel — deben ser círculos pequeños) */
@media (max-width: 900px) {
    button:not(.home-hero-dot):not(.sev-hero-carousel__dot),
    .nav-link,
    .sa-btn,
    .la-btn,
    .gpg-btn,
    .pwa-install__btn,
    .pwa-update__btn {
        min-height: var(--touch-min);
    }

    .nav-link {
        display: inline-flex;
        align-items: center;
        padding: 10px 4px;
    }
}

/* Tablas admin → scroll contenido, no página */
.clutch-table-wrap,
.gpg-table-wrap,
.la-table-wrap,
.sa-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

@media (max-width: 900px) {
    .gpg-table-wrap,
    .sa-table-wrap {
        display: none;
    }
}

/* Modales / drawers seguros en viewport */
.la-drawer,
.nav-mobile-drawer,
.sa-sidebar {
    max-height: 100dvh;
    max-height: 100vh;
}

/* Imágenes: reservar espacio, sin deformar */
img:not([width]):not(.clutch-no-aspect) {
    height: auto;
    max-width: 100%;
}

.header-logo,
.footer-logo,
.nav-brand-logo,
.nav-drawer-brand-logo,
.site-pub-footer__logo {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.footer-logo,
.site-pub-footer__logo {
    width: 40px;
    height: 40px;
}

.nav-drawer-brand-logo {
    width: 36px;
    height: 36px;
}

/* MainLayout — drawer móvil (no scroll horizontal en nav) */
.main-header {
    --nav-height: 56px;
}

.main-header__top {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    max-width: min(1540px, calc(100% - var(--page-pad-x) * 2));
    margin: 0 auto;
    padding: max(10px, env(safe-area-inset-top, 0px)) var(--page-pad-x) 6px;
    box-sizing: border-box;
    min-height: 52px;
}

.main-header .header-content {
    display: contents;
}

@media (max-width: 900px) {
    .main-header__top {
        gap: 8px;
        min-height: 40px;
        padding: max(6px, env(safe-area-inset-top, 0px)) var(--page-pad-x) 4px;
    }

    .main-header .header-logo {
        width: 26px;
        height: 26px;
    }

    .main-header .header-title {
        font-size: 0.78rem;
        letter-spacing: 0.02em;
    }

    .main-header .header-nav {
        display: none;
        position: fixed;
        top: var(--nav-height);
        right: 0;
        bottom: 0;
        width: min(320px, 100vw);
        max-width: 100%;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 12px var(--page-pad-x) calc(24px + env(safe-area-inset-bottom, 0px));
        background: rgba(8, 8, 16, 0.98);
        border-left: 1px solid rgba(100, 255, 154, 0.12);
        z-index: 5100;
        box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
    }

    .main-header .header-nav.main-header-nav--open {
        display: flex;
    }

    .main-header .header-nav .nav-link {
        padding: 14px 8px;
        font-size: 1rem;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        white-space: normal;
    }

    .main-header .header-search--mobile {
        padding: 2px var(--page-pad-x) 8px;
        max-width: 100%;
    }

    /* Top bar + búsqueda compacta (antes ~52+58) */
    .main-header {
        --nav-height: calc(40px + 46px);
    }

    .main-header-hamburger {
        display: flex;
        margin-left: auto;
    }

    /* Detalle liga: footer compacto dentro del viewport (sin hueco negro) */
    .app-container--league-detail .main-footer--league {
        min-height: 0;
    }
}

/* SiteLayout — shell compacta en /liga/… (CSS global: no scoped) */
.site-shell {
    display: contents;
}

@media (max-width: 900px) {
    /* Un solo scroll vertical: el shell no fija altura ni crea scroll interno. */
    .site-shell--league-detail {
        --league-footer-budget: 48px;
        display: block;
        height: auto;
        max-height: none;
        overflow: visible;
        min-height: 0;
    }

    .site-shell--league-detail > .lv-page {
        height: auto !important;
        max-height: none !important;
    }

    .site-shell--league-detail > .site-pub-footer--league {
        max-height: calc(var(--league-footer-budget, 72px) + env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }
}

@media (min-width: 901px) {
    .main-header-hamburger,
    .main-header-overlay {
        display: none !important;
    }
}

.main-header-hamburger {
    display: none;
}

.main-header-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 5050;
    backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
    body {
        padding-bottom: 0;
    }
}

/* Skeletons sin CLS */
.clutch-skeleton {
    min-height: 48px;
    contain: layout style;
}
