/* =================================================================
   «MÍRALO POR DENTRO» (solo portada: lista de page.php en head.php)
   Carrusel de páginas del temario (A4 en vertical) con scroll-snap,
   flechas y contador, y el visor a pantalla completa de pordentro.js
   (sin librerías), con el botón del tema gratis abajo.
   ================================================================= */

.mx-sec {
    position: relative;
    background: var(--opogc-white-off);
}

/* Destino de los enlaces viejos a #metodo, con hueco para la cabecera fija. */
.mx-ancla {
    position: absolute;
    top: -80px;
}

.mx-head {
    max-width: 760px;
    margin-inline: auto;
}

/* Titular con los efectos de «Parte de situación» (mismo tamaño, metal,
   brillo y subrayado que se dibuja). .ps-metal, .ps-ul y las animaciones
   ps-sube / ps-brillo están en 95-parte.css, que también va en la portada. */
.mx-title {
    --ps-verde: #1E9E5A;
    font-family: var(--opogc-font-title);
    font-size: 46px;
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -0.03em;
    color: #0D1411;
    margin: 0.5rem 0 0;
    text-wrap: balance;
}
.mx-t1,
.mx-t2wrap { display: block; }
.mx-t2 {
    display: inline-block;
    color: var(--ps-verde);
}

.mx-sub {
    margin: 1.1rem auto 0;
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--opogc-text-soft);
}

@media (max-width: 720px) {
    .mx-title { font-size: clamp(2.1rem, 10vw, 2.875rem); }
}

/* Estado inicial (.mx--armado, lo pone pordentro.js) y entrada, una vez:
   sube, cruza el brillo del metal y se dibuja el subrayado. */
.mx--armado .mx-fx { opacity: 0; translate: 0 22px; }
.mx--armado .mx-fx.is-in {
    animation: ps-sube 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both;
    animation-delay: var(--d, 0s);
}
.mx--armado .mx-t1.is-in {
    animation: ps-sube 0.8s cubic-bezier(0.2, 0.7, 0.2, 1) both, ps-brillo 1.4s ease-in-out both;
    animation-delay: var(--d, 0s), calc(var(--d, 0s) + 0.55s);
}
.mx--armado .mx-t2wrap.is-in .mx-t2 { animation: ps-brillo 1.4s ease-in-out 0.85s both; }
.mx--armado .mx-title .ps-ul:not(.is-in) { scale: 0 1; }

/* ---------- Pestañas (solo si hay capturas además del temario) ---------- */

.mx-tabs {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: max-content;
    max-width: 100%;
    margin: 1.75rem auto 0;
    padding: 4px;
    background: var(--opogc-white);
    border: 1px solid var(--opogc-border);
    border-radius: var(--opogc-radius-pill);
    overflow-x: auto;
    scrollbar-width: none;
}
.mx-tabs::-webkit-scrollbar { display: none; }

.mx-tab {
    flex-shrink: 0;
    padding: 0.5rem 1.1rem;
    border: 0;
    border-radius: var(--opogc-radius-pill);
    background: transparent;
    font-family: var(--opogc-font-body);
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--opogc-text-soft);
    cursor: pointer;
    transition: background var(--opogc-transition), color var(--opogc-transition);
}
.mx-tab[aria-selected="true"] {
    background: var(--opogc-green-deep);
    color: #fff;
}
.mx-tab:focus-visible {
    outline: 2px solid var(--opogc-green-pastel);
    outline-offset: 2px;
}

/* ---------- Carrusel ----------
   Tarjetas verticales en proporción A4 (1 : 1,414) con la página entera
   (contain: una imagen con otra proporción no se deforma, queda con margen).
   Móvil: una y un trozo de la siguiente; tablet: dos; escritorio: tres o cuatro. */

.mx-panel { margin-top: 2rem; }
.mx-panel[hidden] { display: none; }

.mx-carrusel {
    --mx-hueco: 14px;
    position: relative;
}

.mx-pista {
    display: flex;
    gap: var(--mx-hueco);
    margin: 0;
    padding: 4px 0 14px;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.mx-pista::-webkit-scrollbar { display: none; }
.mx-pista:focus { outline: none; }
.mx-pista:focus-visible {
    outline: 2px solid var(--opogc-green-pastel);
    outline-offset: 4px;
    border-radius: 16px;
}

.mx-card {
    flex: 0 0 calc((100% - var(--mx-hueco)) / 1.28); /* una y un trozo de la siguiente */
    min-width: 0;
    margin: 0;
    scroll-snap-align: start;
}

.mx-card__fig { margin: 0; }

.mx-card__link {
    position: relative;
    display: block;
    aspect-ratio: 1 / 1.4142;
    overflow: hidden;
    border-radius: 10px;
    border: 1px solid var(--opogc-border);
    background: #fff;
    box-shadow: 0 10px 28px -18px rgba(15, 23, 42, 0.35);
    transition: transform var(--opogc-transition), box-shadow var(--opogc-transition);
}

.mx-card__link img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: contain;
}

/* Las capturas de la app: enteras, sobre el fondo suave. */
.mx-card--captura .mx-card__link { background: var(--opogc-surface-alt); }

.mx-card__link:focus-visible {
    outline: 3px solid var(--opogc-green-pastel);
    outline-offset: 3px;
}

.mx-card__lupa {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
    color: var(--opogc-green-deep);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
    transition: transform var(--opogc-transition);
}
.mx-card__lupa svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.mx-card__pie {
    margin: 0.65rem 2px 0;
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.35;
    color: var(--opogc-text);
}
.mx-card__tema {
    display: block;
    margin-bottom: 2px;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--opogc-green-mid);
}

@media (hover: hover) {
    .mx-card__link:hover {
        transform: translateY(-3px);
        box-shadow: 0 18px 36px -20px rgba(15, 23, 42, 0.45);
    }
    .mx-card__link:hover .mx-card__lupa { transform: scale(1.08); }
}

/* Flechas y contador, bajo la pista (los enseña pordentro.js). */
.mx-ctrl {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    margin-top: 6px;
}
.mx-ctrl[hidden] { display: none; }

.mx-cont {
    min-width: 7ch;
    font-size: 0.95rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    text-align: center;
    color: var(--opogc-text-soft);
}

.mx-flecha {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid var(--opogc-border);
    border-radius: 50%;
    background: var(--opogc-white);
    color: var(--opogc-green-deep);
    box-shadow: var(--opogc-shadow-sm);
    cursor: pointer;
    transition: opacity var(--opogc-transition), transform var(--opogc-transition);
}
.mx-flecha svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.mx-flecha:focus-visible {
    outline: 2px solid var(--opogc-green-pastel);
    outline-offset: 2px;
}
.mx-flecha:disabled {
    opacity: 0.35;
    cursor: default;
}
@media (hover: hover) {
    .mx-flecha:not(:disabled):hover { transform: scale(1.06); }
}

/* Móvil: la pista llega al borde de la pantalla y la siguiente asoma por la
   derecha. 1rem = el margen de .opogc-wrap a este ancho (17-theme.css); el
   scroll-padding en px, que en % iría sobre la pista y la pegaría al borde. */
@media (max-width: 720px) {
    .mx-pista {
        margin-inline: -1rem;
        padding-inline: 1rem;
        scroll-padding-inline: 1rem;
    }
}

@media (min-width: 721px) {
    .mx-carrusel { --mx-hueco: 18px; }
    .mx-card { flex-basis: calc((100% - var(--mx-hueco)) / 2); }
}

@media (min-width: 1025px) {
    .mx-carrusel { --mx-hueco: 20px; }
    .mx-card { flex-basis: calc((100% - 2 * var(--mx-hueco)) / 3); }
}

@media (min-width: 1200px) {
    .mx-card { flex-basis: calc((100% - 3 * var(--mx-hueco)) / 4); }
}

/* ---------- Visor a pantalla completa (pordentro.js) ----------
   Hijo del <body> y por encima de todo (cabecera, barras fijas, botones y
   aviso de cookies); mientras está abierto la página no hace scroll. */

html.mx-vw-on,
html.mx-vw-on body { overflow: hidden; }
html.mx-vw-on .cm-stk { visibility: hidden; }

.mx-vw {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 100vw; /* también sobre el hueco de la barra de scroll (html: scrollbar-gutter: stable, 46-comunes.css) */
    z-index: 2147483000;
    display: none;
    grid-template-columns: minmax(0, 1fr); /* el pie largo no la ensancha */
    grid-template-rows: auto minmax(0, 1fr) auto;
    background: rgba(9, 14, 11, 0.97);
    color: #fff;
    font-family: var(--opogc-font-body);
    touch-action: none;
    overscroll-behavior: contain;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.mx-vw.is-on { display: grid; }
.mx-vw:focus { outline: none; }

.mx-vw__top {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 56px;
    padding: max(6px, env(safe-area-inset-top, 0px)) 8px 6px 16px;
}

.mx-vw__info {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
}
.mx-vw__cont {
    flex-shrink: 0;
    font-size: 15px;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}
.mx-vw__pie {
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
    color: rgba(255, 255, 255, 0.72);
}

.mx-vw__tools {
    display: flex;
    flex-shrink: 0;
    gap: 4px;
}

.mx-vw__btn,
.mx-vw__nav {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    cursor: pointer;
    transition: background-color 0.15s, opacity 0.15s;
}
.mx-vw__btn svg,
.mx-vw__nav svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}
.mx-vw__btn:disabled,
.mx-vw__nav:disabled {
    opacity: 0.3;
    cursor: default;
}
.mx-vw__btn:focus-visible,
.mx-vw__nav:focus-visible,
.mx-vw__tema:focus-visible {
    outline: 2px solid #8EE0B0;
    outline-offset: 2px;
}
@media (hover: hover) {
    .mx-vw__btn:not(:disabled):hover,
    .mx-vw__nav:not(:disabled):hover { background: rgba(255, 255, 255, 0.2); }
}

.mx-vw__stage {
    position: relative;
    overflow: hidden;
    touch-action: none;
}
.mx-vw.is-zoom .mx-vw__stage { cursor: grab; }
.mx-vw.is-zoom .mx-vw__stage:active { cursor: grabbing; }

/* Ancho y alto los pone pordentro.js con la misma escala: proporción exacta. */
.mx-vw__img {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    max-width: none;
    max-height: none;
    margin: 0;
    background: #fff;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    -webkit-user-drag: none;
    transition: opacity 0.18s ease;
}
.mx-vw__img.is-lista { opacity: 1; }
.mx-vw__img.is-anim { transition: width 0.22s ease, height 0.22s ease, transform 0.22s ease, opacity 0.18s ease; }

.mx-vw__error {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    margin: 0;
    padding: 24px;
    text-align: center;
    color: rgba(255, 255, 255, 0.8);
}
.mx-vw__error[hidden] { display: none; }

.mx-vw__bot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 60px;
    padding: 6px 12px max(8px, env(safe-area-inset-bottom, 0px));
}

.mx-vw__cta {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin: 0;
}
.mx-vw__cta-t {
    display: none;
    font-family: var(--opogc-font-title);
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}
.mx-vw__tema {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 18px;
    border-radius: var(--opogc-radius-pill);
    background: #fff;
    color: var(--opogc-green-deep);
    font-size: 14px;
    font-weight: 800;
    white-space: nowrap;
    text-decoration: none;
}

@media (min-width: 768px) {
    .mx-vw__bot { justify-content: center; }
    .mx-vw__nav {
        position: absolute;
        top: 50%;
        width: 52px;
        height: 52px;
        translate: 0 -50%;
    }
    .mx-vw__nav--prev { left: 12px; }
    .mx-vw__nav--next { right: 12px; }
}
@media (min-width: 900px) {
    .mx-vw__cta-t { display: block; }
}

@media (prefers-reduced-motion: reduce) {
    .mx-pista { scroll-behavior: auto; }
    .mx-card__link,
    .mx-card__lupa,
    .mx-flecha,
    .mx-vw__btn,
    .mx-vw__nav,
    .mx-vw__img,
    .mx-vw__img.is-anim { transition: none; }
    .mx-card__link:hover { transform: none; }
    .mx-title *,
    .mx-title *::before,
    .mx-title *::after {
        animation: none !important;
        transition: none !important;
    }
}
