/* ============================================================
   MENÚ MÓVIL MODERNO (solo ≤ 768px) — versiones A (dock) y B (fullscreen)
   Usa las variables del tema (colores del menú + modo noche).
   ============================================================ */
.tsothm-mm {
    display: none;
    --tsothm-mm-bg: var(--tso-color-nav-bg, #000);
    --tsothm-mm-fg: var(--tso-color-nav-text, #fff);
    --tsothm-mm-accent: var(--tso-color-accent, #d6993a);
    --tsothm-mm-accent-fg: var(--tso-color-accent-contrast, #fff);
}

@media screen and (max-width: 768px) {
    .tsothm-mm {
        display: block;
    }

    /* Se oculta la barra horizontal antigua solo cuando el menú nuevo está activo. */
    body.tsothm-mm-on .main-navigation {
        display: none;
    }

    /* Espacio para que el botón flotante no tape el final de la página. */
    body.tsothm-mm-on #page-wrapper {
        padding-bottom: 90px;
    }
}

body.tsothm-mm-locked {
    overflow: hidden;
}

.tsothm-mm__toggle,
.tsothm-mm__close,
.tsothm-mm__sub-toggle {
    border: 0;
    margin: 0;
    cursor: pointer;
    font: inherit;
    color: var(--tsothm-mm-fg);
    background: var(--tsothm-mm-bg);
    -webkit-tap-highlight-color: transparent;
}

.tsothm-mm__toggle {
    position: fixed;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

.tsothm-mm__toggle:focus-visible,
.tsothm-mm__close:focus-visible,
.tsothm-mm__sub-toggle:focus-visible,
.tsothm-mm__list a:focus-visible {
    outline: 2px solid var(--tsothm-mm-accent);
    outline-offset: 2px;
}

.tsothm-mm__burger {
    display: grid;
    gap: 4px;
    width: 20px;
}

.tsothm-mm__burger i {
    display: block;
    height: 2px;
    border-radius: 2px;
    background: currentColor;
}

.tsothm-mm__toggle-label {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.tsothm-mm__backdrop {
    position: fixed;
    inset: 0;
    z-index: 9991;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tsothm-mm__backdrop:not([hidden]) {
    display: block;
}

.tsothm-mm.is-open .tsothm-mm__backdrop {
    opacity: 1;
}

.tsothm-mm__panel {
    position: fixed;
    z-index: 9992;
    background: var(--tsothm-mm-bg);
    color: var(--tsothm-mm-fg);
    visibility: hidden;
}

.tsothm-mm.is-open .tsothm-mm__panel {
    visibility: visible;
}

.tsothm-mm__close {
    position: absolute;
    top: 14px;
    right: 14px;
    z-index: 2;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: rgba(255, 255, 255, 0.14);
}

/* ---------- Lista ---------- */
.tsothm-mm__list,
.tsothm-mm__list .sub-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tsothm-mm__list a {
    display: block;
    color: inherit;
    font-family: var(--tso-font-nav, var(--tso-font-body, Arial, Helvetica, sans-serif));
    text-decoration: none;
}

.tsothm-mm__list li.menu-item-has-children {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 8px;
}

.tsothm-mm__list li.menu-item-has-children > a {
    flex: 1 1 0;
    min-width: 0;
}

.tsothm-mm__sub-toggle {
    position: relative;
    flex: 0 0 52px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.1);
}

.tsothm-mm__sub-toggle::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 9px;
    height: 9px;
    margin: -7px 0 0 -5px;
    border: solid currentColor;
    border-width: 0 2.5px 2.5px 0;
    transform: rotate(45deg);
    transition: transform 0.25s ease;
}

.tsothm-mm__list li.is-sub-open > .tsothm-mm__sub-toggle::before {
    transform: rotate(-135deg);
    margin-top: -2px;
}

.tsothm-mm__list .sub-menu {
    display: none;
    flex: 1 0 100%;
}

.tsothm-mm__list li.is-sub-open > .sub-menu {
    display: grid;
    gap: 6px;
}

.tsothm-mm__list .sub-menu a {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.06);
}

.tsothm-mm__list .current-menu-item > a,
.tsothm-mm__list .current-menu-ancestor > a {
    color: inherit;
    font-weight: 700;
}

/* ---------- Versión A: botón flotante + panel inferior ---------- */
.tsothm-mm--dock .tsothm-mm__toggle {
    left: 50%;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateX(-50%);
    padding: 14px 28px;
    border-radius: 999px;
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.tsothm-mm--dock .tsothm-mm__toggle:active {
    transform: translateX(-50%) scale(0.96);
}

.tsothm-mm--dock.is-open .tsothm-mm__toggle {
    opacity: 0;
    pointer-events: none;
}

.tsothm-mm--dock .tsothm-mm__panel {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 80vh;
    overflow-y: auto;
    padding: 64px 18px calc(24px + env(safe-area-inset-bottom, 0px));
    border-radius: 28px 28px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.35s;
}

.tsothm-mm--dock .tsothm-mm__panel::before {
    content: "";
    position: absolute;
    top: 12px;
    left: 50%;
    width: 42px;
    height: 5px;
    margin-left: -21px;
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.3);
}

.tsothm-mm--dock.is-open .tsothm-mm__panel {
    transform: none;
    transition-delay: 0s;
}

.tsothm-mm--dock .tsothm-mm__list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.tsothm-mm--dock .tsothm-mm__list > li.menu-item-has-children {
    grid-column: 1 / -1;
}

.tsothm-mm--dock .tsothm-mm__list > li > a {
    padding: 18px 14px;
    border-radius: 16px;
    text-align: center;
    font-weight: 700;
    font-size: 1rem;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.tsothm-mm--dock .tsothm-mm__list > li.current-menu-item > a,
.tsothm-mm--dock .tsothm-mm__list > li.current-menu-ancestor > a {
    background: rgba(255, 255, 255, 0.14);
    color: inherit;
    border-color: rgba(255, 255, 255, 0.35);
}

/* ---------- Versión B: pantalla completa ---------- */
.tsothm-mm--fullscreen .tsothm-mm__toggle {
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    padding: 0;
    border-radius: 50%;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.tsothm-mm--fullscreen .tsothm-mm__toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.tsothm-mm--fullscreen.is-open .tsothm-mm__toggle {
    opacity: 0;
    pointer-events: none;
}

.tsothm-mm--fullscreen .tsothm-mm__backdrop {
    display: none !important;
}

.tsothm-mm--fullscreen .tsothm-mm__panel {
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
    padding: 80px 32px 48px;
    clip-path: circle(0 at calc(100% - 45px) calc(100% - 45px));
    transition: clip-path 0.55s cubic-bezier(0.7, 0, 0.2, 1), visibility 0s linear 0.55s;
}

.tsothm-mm--fullscreen.is-open .tsothm-mm__panel {
    clip-path: circle(150% at calc(100% - 45px) calc(100% - 45px));
    transition-delay: 0s;
}

.tsothm-mm--fullscreen .tsothm-mm__list > li > a {
    padding: 10px 0;
    font-size: clamp(1.7rem, 8.5vw, 2.5rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.01em;
}

.tsothm-mm--fullscreen .tsothm-mm__sub-toggle {
    flex-basis: 44px;
    align-self: center;
    height: 44px;
    border-radius: 50%;
}

.tsothm-mm--fullscreen .tsothm-mm__list > li {
    opacity: 0;
    transform: translateY(24px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li {
    opacity: 1;
    transform: none;
}

.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(1) { transition-delay: 0.2s; }
.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(2) { transition-delay: 0.26s; }
.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(3) { transition-delay: 0.32s; }
.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(4) { transition-delay: 0.38s; }
.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(5) { transition-delay: 0.44s; }
.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(6) { transition-delay: 0.5s; }
.tsothm-mm--fullscreen.is-open .tsothm-mm__list > li:nth-child(n+7) { transition-delay: 0.56s; }

.tsothm-mm__toggle[hidden] {
    display: none;
}

/* ---------- Versión C: barra de pestañas inferior ---------- */
.tsothm-mm--tabbar .tsothm-mm__tabs {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    display: flex;
    align-items: stretch;
    padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: var(--tsothm-mm-bg);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 -6px 24px rgba(0, 0, 0, 0.25);
}

.tsothm-mm__tab {
    position: relative;
    flex: 1 1 0;
    min-width: 0;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    color: var(--tsothm-mm-fg);
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
    text-decoration: none;
    opacity: 0.75;
    transition: opacity 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.tsothm-mm__tab::before {
    content: "";
    position: absolute;
    top: 0;
    left: 22%;
    right: 22%;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--tsothm-mm-accent);
    transform: scaleX(0);
    transition: transform 0.25s ease;
}

.tsothm-mm__tab.is-current {
    color: var(--tsothm-mm-accent);
    opacity: 1;
}

.tsothm-mm__tab.is-current::before {
    transform: scaleX(1);
}

.tsothm-mm__tab:focus-visible {
    outline: 2px solid var(--tsothm-mm-accent);
    outline-offset: -4px;
}

.tsothm-mm--tabbar .tsothm-mm__toggle {
    position: static;
    flex: 1 1 0;
    min-width: 0;
    min-height: 60px;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    padding: 0 4px;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    font-size: 12.5px;
}

.tsothm-mm--tabbar .tsothm-mm__burger {
    gap: 3px;
}

.tsothm-mm--tabbar .tsothm-mm__panel {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 75vh;
    overflow-y: auto;
    padding: 64px 0 calc(16px + env(safe-area-inset-bottom, 0px));
    border-radius: 24px 24px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.4);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.35s;
}

.tsothm-mm--tabbar.is-open .tsothm-mm__panel {
    transform: none;
    transition-delay: 0s;
}

.tsothm-mm--tabbar .tsothm-mm__list > li > a {
    padding: 16px 24px;
    font-size: 1.05rem;
    font-weight: 600;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.tsothm-mm--tabbar .tsothm-mm__list > li.current-menu-item > a,
.tsothm-mm--tabbar .tsothm-mm__list > li.current-menu-ancestor > a {
    box-shadow: inset 4px 0 0 rgba(255, 255, 255, 0.55);
}

.tsothm-mm--tabbar .tsothm-mm__list li.menu-item-has-children {
    gap: 0;
}

.tsothm-mm--tabbar .tsothm-mm__sub-toggle {
    flex-basis: 60px;
    border-radius: 0;
    background: transparent;
    border-top: 1px solid rgba(255, 255, 255, 0.09);
}

.tsothm-mm--tabbar .tsothm-mm__list .sub-menu a {
    padding: 13px 24px 13px 44px;
    border-radius: 0;
    background: rgba(255, 255, 255, 0.05);
}

/* ---------- Versión D: panel lateral con pestaña en el borde ---------- */
.tsothm-mm--drawer .tsothm-mm__toggle {
    top: 50%;
    right: 0;
    width: 40px;
    height: 88px;
    padding: 0;
    justify-content: center;
    border-radius: 18px 0 0 18px;
    box-shadow: -4px 6px 20px rgba(0, 0, 0, 0.3);
    transform: translateY(-50%);
    transition: opacity 0.2s ease;
}

.tsothm-mm--drawer .tsothm-mm__toggle-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
}

.tsothm-mm--drawer.is-open .tsothm-mm__toggle {
    opacity: 0;
    pointer-events: none;
}

.tsothm-mm--drawer .tsothm-mm__panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: min(84vw, 340px);
    overflow-y: auto;
    padding: 76px 22px 28px;
    border-radius: 28px 0 0 28px;
    box-shadow: -12px 0 40px rgba(0, 0, 0, 0.4);
    transform: translateX(100%);
    transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0s linear 0.35s;
}

.tsothm-mm--drawer.is-open .tsothm-mm__panel {
    transform: none;
    transition-delay: 0s;
}

.tsothm-mm--drawer .tsothm-mm__list {
    counter-reset: tsothm-mm;
}

.tsothm-mm--drawer .tsothm-mm__list > li {
    counter-increment: tsothm-mm;
}

.tsothm-mm--drawer .tsothm-mm__list > li {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tsothm-mm--drawer .tsothm-mm__list > li > a {
    display: flex;
    align-items: baseline;
    gap: 14px;
    padding: 14px 4px;
    font-size: 1.3rem;
    font-weight: 700;
    line-height: 1.2;
}

.tsothm-mm--drawer .tsothm-mm__list > li > a::before {
    content: counter(tsothm-mm, decimal-leading-zero);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: var(--tsothm-mm-accent);
}

.tsothm-mm--drawer .tsothm-mm__list li.menu-item-has-children {
    gap: 0 8px;
}

.tsothm-mm--drawer .tsothm-mm__sub-toggle {
    flex-basis: 44px;
    margin: 8px 0;
    border-radius: 12px;
}

.tsothm-mm--drawer .tsothm-mm__list .sub-menu {
    margin-bottom: 8px;
}

@media screen and (max-width: 768px) {
    /* Las versiones sin barra fija abajo no necesitan el margen extra. */
    body.tsothm-mm-style-drawer #page-wrapper {
        padding-bottom: 10px;
    }

    body.tsothm-mm-style-tabbar #page-wrapper {
        padding-bottom: 80px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tsothm-mm *,
    .tsothm-mm *::before {
        transition-duration: 0.01ms !important;
        transition-delay: 0s !important;
    }
}
