:root {
    --fondo: rgb(173, 216, 230);
    --panel: rgb(135, 206, 250);
    --texto: rgb(0, 0, 0);
    --verde: rgb(0, 0, 0);
    --verde-oscuro: rgb(40, 40, 40);
    --rojo: rgb(200, 30, 30);
    --dorado: rgb(0, 70, 150);
}

[data-theme="dark"] {
    --fondo: rgb(0, 0, 0);
    --panel: rgb(15, 20, 26);
    --texto: rgb(173, 216, 230);
    --verde: rgb(135, 206, 250);
    --verde-oscuro: rgb(100, 170, 215);
    --rojo: rgb(255, 85, 85);
    --dorado: rgb(224, 247, 255);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    background: var(--fondo);
    color: var(--texto);
    font-family: system-ui, sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    transition: background-color 0.3s ease, color 0.3s ease;
}

img, video, iframe, table { max-width: 100%; }

.cabecera {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--panel);
    border-bottom: 3px solid var(--verde);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.logo {
    color: var(--verde);
    font-size: 1.4rem;
    font-weight: bold;
    text-decoration: none;
    white-space: nowrap;
    margin-right: auto;
}

.menu-navegacion {
    order: 2;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
}

.menu-navegacion a {
    color: var(--texto);
    text-decoration: none;
    margin-left: 1.2rem;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
}

.menu-navegacion a:hover,
.menu-navegacion a.activo {
    background: var(--verde);
    color: var(--fondo);
}

.usuario-tag { margin-left: 1.2rem; font-weight: bold; }
.nav-admin { color: var(--dorado) !important; }
.nav-salir { color: var(--rojo) !important; }
.idioma-codigo { opacity: 0.7; }

.btn-theme-toggle {
    background: transparent;
    border: 1px solid var(--verde);
    color: var(--texto);
    border-radius: 4px;
    padding: 0.25rem 0.6rem;
    margin-left: 1.2rem;
    font-size: 1rem;
    cursor: pointer;
}
.btn-theme-toggle:hover { background: var(--verde); color: var(--fondo); }

.cabecera-acciones-movil {
    order: 3;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.menu-check { position: absolute; opacity: 0; pointer-events: none; }
.hamburguesa { display: none; }
.menu-fondo { display: none; }

.contenedor {
    flex: 1;
    max-width: 900px;
    width: 100%;
    margin: 2rem auto;
    padding: 0 1rem;
}

h1 { margin-bottom: 1rem; color: var(--verde); }

.hero { text-align: center; padding: 3rem 1rem; }
.hero p { margin: 1rem 0 1.5rem; font-size: 1.2rem; }

.boton {
    display: inline-block;
    background: var(--verde);
    color: var(--fondo);
    padding: 0.7rem 1.5rem;
    border-radius: 6px;
    font-weight: bold;
    text-decoration: none;
}
.boton:hover { background: var(--verde-oscuro); color: var(--texto); }

.tarjetas { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.tarjeta { background: var(--panel); padding: 1.5rem; border-radius: 8px; border-left: 4px solid var(--verde); }
.tarjeta h2 { margin-bottom: 0.5rem; }

.markdown, .normas-contenido { background: var(--panel); padding: 1.5rem; border-radius: 8px; overflow-wrap: anywhere; }
.markdown p, .normas-contenido p { margin-bottom: 0.8rem; }
.markdown h2, .markdown h3,
.normas-contenido h2, .normas-contenido h3 { margin: 1rem 0 0.5rem; color: var(--verde); }
.markdown ul, .markdown ol,
.normas-contenido ul, .normas-contenido ol { margin: 0 0 0.8rem 1.5rem; }
.markdown li, .normas-contenido li { font-size: 1.15rem; margin-bottom: 0.5rem; }
.markdown a, .normas-contenido a { color: var(--verde); }
.markdown img, .normas-contenido img { max-width: 100%; border-radius: 8px; }
.markdown pre, .normas-contenido pre {
    background: rgb(17, 17, 17);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}
.markdown code, .normas-contenido code { color: rgb(135, 206, 250); font-family: monospace; }

.btn-copiar {
    background: var(--verde);
    color: var(--fondo);
    border: none;
    border-radius: 6px;
    padding: 0.15rem 0.8rem;
    margin-left: 0.5rem;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
}
.btn-copiar:hover { background: var(--verde-oscuro); color: var(--texto); }

.normas-contenido { border-left: 4px solid var(--verde); }

.anuncio {
    display: flow-root;
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--verde);
    font-size: 1.15rem;
    line-height: 1.65;
}
.anuncio h2, .anuncio h3 { margin-top: 0; font-size: 1.6rem; }
.anuncio img,
.anuncio video,
.anuncio iframe {
    float: left;
    width: 140px;
    max-width: 100%;
    border-radius: 8px;
    margin: 0 1.5rem 0.9rem 0;
}
.anuncio iframe { aspect-ratio: 16 / 9; height: auto; border: 0; }

.anuncio:nth-child(even) img,
.anuncio:nth-child(even) video,
.anuncio:nth-child(even) iframe {
    float: right;
    margin: 0 0 1rem 1.2rem;
}

.redes {
    background: var(--panel);
    padding: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid var(--verde);
}
.redes h1, .redes h2, .redes h3 { color: var(--verde); margin: 0 0 1rem; }
.redes p { margin-bottom: 1rem; }
.redes ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.8rem;
}
.redes li { margin: 0; }
.redes li a {
    display: block;
    text-align: center;
    background: var(--fondo);
    color: var(--texto);
    text-decoration: none;
    font-weight: bold;
    font-size: 1.1rem;
    padding: 0.9rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--verde);
    transition: background 0.15s, color 0.15s, transform 0.15s;
}
.redes li a:hover {
    background: var(--verde);
    color: var(--fondo);
    transform: translateY(-3px);
}

.galeria {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
}
.galeria a {
    display: block;
    overflow: hidden;
    border-radius: 8px;
    border: 2px solid var(--verde);
    background: var(--panel);
}
.galeria img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 10;
    object-fit: cover;
    transition: transform 0.2s;
}
.galeria a:hover img { transform: scale(1.05); }

.error-pagina { text-align: center; padding: 3rem 1rem; }
.error-codigo {
    font-size: 6rem;
    font-weight: bold;
    line-height: 1;
    color: var(--verde);
    margin-bottom: 0.5rem;
}
.error-pagina p { margin: 0.5rem 0 1.5rem; font-size: 1.15rem; }

.pie {
    text-align: center;
    padding: 1.5rem;
    background: var(--panel);
    border-top: 3px solid var(--verde);
    font-size: 0.85rem;
    opacity: 0.8;
}
.pie-enlaces { margin-top: 0.4rem; }
.pie-enlaces a { color: var(--verde); text-decoration: none; }
.pie-enlaces a:hover { text-decoration: underline; }

.idioma-drawer-check { position: absolute; opacity: 0; pointer-events: none; }

.btn-idioma-trigger {
    background: transparent;
    border: 1px solid var(--verde);
    color: var(--texto);
    padding: 0.35rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    white-space: nowrap;
    user-select: none;
    transition: all 0.2s ease;
}
.btn-idioma-trigger:hover { background: var(--verde); color: var(--fondo); }

.idioma-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.idioma-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 280px;
    max-width: 80vw;
    background: var(--panel);
    border-left: 2px solid var(--verde);
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.4);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    transform: translateX(110%);
    visibility: hidden;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.3s;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.idioma-drawer-check:checked ~ .idioma-drawer { transform: translateX(0); visibility: visible; }
.idioma-drawer-check:checked ~ .idioma-overlay { opacity: 1; visibility: visible; }

.idioma-drawer-header {
    padding: 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--verde);
}
.idioma-drawer-header h3 { margin: 0; font-size: 1.1rem; color: var(--verde); }

.btn-cerrar-drawer {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    color: var(--texto);
    font-size: 1.4rem;
    cursor: pointer;
    border-radius: 4px;
}
.btn-cerrar-drawer:hover { color: var(--rojo); }

.idioma-drawer-body {
    padding: 1rem;
    overflow-y: auto;
    overscroll-behavior: contain;
    flex-grow: 1;
}
.idioma-drawer-body::-webkit-scrollbar { width: 6px; }
.idioma-drawer-body::-webkit-scrollbar-thumb { background: var(--verde); border-radius: 3px; }
.idioma-drawer-body::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }

.idioma-drawer-lista {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.idioma-drawer-lista a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    padding: 0.75rem 1rem;
    border-radius: 6px;
    color: var(--texto);
    text-decoration: none;
    font-size: 0.95rem;
    background: var(--fondo);
    border: 1px solid var(--verde);
    transition: background 0.15s ease, color 0.15s ease;
}
.idioma-drawer-lista a:hover,
.idioma-drawer-lista a.activo {
    background: var(--verde);
    color: var(--fondo);
}
.idioma-drawer-lista a.activo { font-weight: bold; }

@media (max-width: 900px) {
    .cabecera {
        padding: 0.5rem 1rem;
        padding-top: calc(0.5rem + env(safe-area-inset-top));
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
    }

    .logo { font-size: 1.15rem; }

    .btn-idioma-trigger,
    .hamburguesa,
    .btn-theme-toggle {
        min-height: 44px;
        min-width: 44px;
    }

    .hamburguesa {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 1.7rem;
        cursor: pointer;
        user-select: none;
        border: 1px solid var(--verde);
        border-radius: 4px;
    }

    .menu-fondo {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease, visibility 0.3s ease;
        z-index: 110;
    }

    .menu-navegacion {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: min(80vw, 320px);
        flex-direction: column;
        flex-wrap: nowrap;
        align-items: stretch;
        gap: 0.3rem;
        padding: calc(1rem + env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
        overflow-y: auto;
        overscroll-behavior: contain;
        background: var(--panel);
        border-left: 2px solid var(--verde);
        box-shadow: -8px 0 24px rgba(0, 0, 0, 0.35);
        transform: translateX(110%);
        visibility: hidden;
        transition: transform 0.3s ease, visibility 0.3s;
        z-index: 120;
    }

    .menu-navegacion a,
    .usuario-tag {
        display: flex;
        align-items: center;
        min-height: 48px;
        margin: 0;
        padding: 0 0.9rem;
        border-radius: 10px;
        font-size: 1.05rem;
    }

    .btn-theme-toggle {
        align-self: flex-start;
        margin: 0.5rem 0 0;
    }

    .menu-check:checked ~ .menu-fondo { opacity: 1; visibility: visible; }
    .menu-check:checked ~ .menu-navegacion { transform: translateX(0); visibility: visible; }

    body:has(.menu-check:checked),
    body:has(.idioma-drawer-check:checked) { overflow: hidden; }

    .contenedor {
        margin: 1rem auto;
        padding-left: calc(1rem + env(safe-area-inset-left));
        padding-right: calc(1rem + env(safe-area-inset-right));
    }

    h1 { font-size: clamp(1.5rem, 7vw, 2rem); }

    .hero { padding: 2rem 0.5rem; }
    .hero p { font-size: 1.05rem; }

    .boton { display: block; text-align: center; padding: 0.9rem 1rem; }

    .markdown, .normas-contenido, .redes, .tarjeta { padding: 1rem; }
    .markdown li, .normas-contenido li { font-size: 1.05rem; }

    .anuncio { font-size: 1.05rem; }
    .anuncio h2, .anuncio h3 { font-size: 1.35rem; }
    .anuncio img,
    .anuncio video,
    .anuncio iframe,
    .anuncio:nth-child(even) img,
    .anuncio:nth-child(even) video,
    .anuncio:nth-child(even) iframe {
        float: none;
        display: block;
        width: 100%;
        margin: 0 0 0.8rem;
    }

    .galeria { grid-template-columns: repeat(2, 1fr); gap: 0.6rem; }

    .redes ul { grid-template-columns: 1fr; }
    .redes li a { min-height: 48px; }

    .error-codigo { font-size: 4.5rem; }

    input, select, textarea, button { font-size: 16px; }

    .pie {
        padding: 1.2rem 1rem calc(1.2rem + env(safe-area-inset-bottom));
    }
    .pie-enlaces a { display: inline-block; padding: 0.5rem 0.3rem; }
}

@media (max-width: 400px) {
    .galeria { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
}

/* ==========================================
   ESTILOS FAQ / DESPLEGABLES (details / summary)
   ========================================== */

.contenido details {
    background: var(--panel);
    border-radius: 8px;
    border-left: 4px solid var(--verde);
    margin-bottom: 0.8rem;
    padding: 1rem 1.2rem;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.contenido details:hover {
    background: var(--panel);
    filter: brightness(0.97);
}

[data-theme="dark"] .contenido details:hover {
    filter: brightness(1.15);
}

.contenido summary {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--texto);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    user-select: none;
}

/* Ocultar el indicador desplegable estándar del navegador */
.contenido summary::-webkit-details-marker {
    display: none;
}

/* Icono/Flecha a la izquierda */
.contenido summary::before {
    content: "❯";
    font-size: 0.85rem;
    color: var(--verde);
    transition: transform 0.2s ease;
    display: inline-block;
}

/* Rotación de la flecha cuando se abre */
.contenido details[open] summary::before {
    transform: rotate(90deg);
}

/* Separador cuando está abierto el desplegable */
.contenido details[open] summary {
    margin-bottom: 0.8rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .contenido details[open] summary {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

/* Contenido / Respuesta dentro del desplegable */
.contenido details p {
    margin: 0;
    color: var(--texto);
    line-height: 1.6;
}

.contenido details ul,
.contenido details ol {
    margin: 0.5rem 0 0 1.5rem;
    color: var(--texto);
}
