/* ==========================================================================
   TEMA "GLASS" — PORTADA EN MÓVIL (MAQUETA)
   Se carga después de styles/glass.css y solo actúa por debajo de 768 px.
   Idea: menos scroll vertical. Lo que antes eran listas apiladas pasa a
   deslizarse en horizontal, y la navegación baja a una barra inferior.
   Necesita js/glass-mobile.js para la barra, "leer más" y los botones.
   ========================================================================== */

.m-tabbar,
.m-more,
.m-seg,
.m-actions {
    display: none;
}

@media (max-width: 768px) {
    :root {
        --m-gutter: 16px;
        --m-tabbar-h: 62px;
    }

    html {
        scroll-padding-top: 76px;
    }

    body {
        padding-bottom: calc(var(--m-tabbar-h) + 28px + env(safe-area-inset-bottom));
    }

    .container {
        padding: 0 var(--m-gutter);
    }

    /* Carriles horizontales: de borde a borde, con imán y sin barra visible */
    .timeline,
    .timeline-content.active,
    #services .grid-container,
    .clinic-locations,
    .hero-credentials {
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .timeline::-webkit-scrollbar,
    .timeline-content.active::-webkit-scrollbar,
    #services .grid-container::-webkit-scrollbar,
    .clinic-locations::-webkit-scrollbar,
    .hero-credentials::-webkit-scrollbar {
        display: none;
    }

    /* --- HERO: retrato a pantalla completa, texto abajo --- */
    .hero-section {
        box-sizing: border-box;
        min-height: 100vh;
        min-height: 100svh;
        align-items: flex-end;
        padding: 0 20px calc(var(--m-tabbar-h) + 44px + env(safe-area-inset-bottom));
        border-radius: 0 0 34px 34px;
        background-image:
            linear-gradient(180deg, rgba(10, 14, 25, .2) 0%, rgba(10, 14, 25, .9) 100%),
            url('/images/web/portada-endodoncia.webp');
    }

    .hero-portrait {
        width: 100%;
    }

    .hero-portrait img {
        object-position: 50% 0;
        -webkit-mask-image: linear-gradient(to bottom, #000 42%, rgba(0, 0, 0, .4) 72%, transparent 98%);
        mask-image: linear-gradient(to bottom, #000 42%, rgba(0, 0, 0, .4) 72%, transparent 98%);
    }

    .hero-section::after {
        content: '';
        position: absolute;
        left: 0;
        right: 0;
        bottom: 0;
        height: 64%;
        z-index: 1;
        pointer-events: none;
        background: linear-gradient(to top, rgba(8, 12, 22, .97) 20%, rgba(8, 12, 22, .62) 58%, transparent);
    }

    .hero-content {
        width: 100%;
        text-align: left;
    }

    .hero-eyebrow {
        font-size: .95rem;
        margin-bottom: .35rem;
        color: rgba(255, 255, 255, .78);
    }

    .hero-content h1 {
        font-size: min(10.2vw, 3.3rem);
        letter-spacing: -.04em;
        line-height: 1;
        margin: 0 0 .6rem;
        white-space: nowrap;
    }

    .hero-content > p:not(.hero-eyebrow) {
        font-size: 1.12rem;
        line-height: 1.35;
    }

    .hero-credentials {
        flex-wrap: nowrap;
        gap: .4rem;
        margin: 1.15rem -20px 0;
        padding: 0 20px;
        overflow-x: auto;
    }

    .hero-credentials span {
        flex: 0 0 auto;
        font-size: .74rem;
        padding: 5px 13px;
    }

    .hero-section .cta-button {
        display: block;
        box-sizing: border-box;
        width: 100%;
        text-align: center;
        font-size: 1.06rem;
        padding: 16px 20px;
        margin-top: 1.35rem;
    }

    /* --- SECCIONES: títulos a la izquierda, como en una app --- */
    .content-section {
        padding: 2.1rem 0 .6rem;
        text-align: left;
    }

    .section-eyebrow,
    .section-title,
    .section-subtitle {
        text-align: left;
    }

    .section-eyebrow {
        font-size: .92rem;
        margin-bottom: .15rem;
    }

    .section-title {
        font-size: clamp(1.7rem, 7.6vw, 2.1rem);
        margin-bottom: 1.1rem;
    }

    .section-title + .section-subtitle {
        margin-top: -.7rem;
    }

    .section-subtitle {
        font-size: 1rem;
        margin: 0 0 1.2rem;
    }

    /* --- SOBRE MÍ: ficha compacta --- */
    #about .container {
        display: grid;
        grid-template-columns: 76px 1fr;
        column-gap: 14px;
        align-items: center;
        grid-template-areas:
            "pic eyebrow"
            "pic title"
            "sub sub"
            "text text"
            "more more"
            "social social";
    }

    #about .profile-pic-container {
        grid-area: pic;
        width: 76px;
        height: 76px;
        margin: 0;
    }

    #about .profile-pic-front,
    #about .profile-pic-back {
        border-width: 3px;
    }

    #about .section-eyebrow {
        grid-area: eyebrow;
        align-self: end;
        margin: 0;
    }

    #about .section-title {
        grid-area: title;
        align-self: start;
        margin: 0;
        font-size: clamp(1.45rem, 6.6vw, 1.8rem);
    }

    #about .section-subtitle {
        grid-area: sub;
        margin: 1rem 0 0;
        font-size: .98rem;
    }

    #about .container > p[data-lang-key="aboutText"] {
        grid-area: text;
        margin: .8rem 0 0;
        font-size: 1rem;
        line-height: 1.6;
    }

    #about .container > p[data-lang-key="aboutText"].m-clamp {
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 4;
        line-clamp: 4;
        overflow: hidden;
    }

    .m-more {
        grid-area: more;
        display: inline-flex;
        justify-self: start;
        align-items: center;
        gap: .3rem;
        margin: .55rem 0 0;
        padding: 6px 0;
        font: 500 .95rem var(--font-main);
        color: var(--g-blue);
        background: none;
        border: 0;
        cursor: pointer;
    }

    #about .social-links {
        grid-area: social;
        justify-content: flex-start;
        gap: .5rem;
        margin-top: 1rem;
    }

    #about .social-links a {
        width: 44px;
        height: 44px;
    }

    /* --- TRAYECTORIA: años en píldoras + una sola hoja con los hitos en lista --- */
    .timeline-wrapper {
        width: auto;
        margin: 0;
        padding: 0;
    }

    .timeline {
        flex-direction: row;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        margin: 0 calc(var(--m-gutter) * -1);
        padding: 4px var(--m-gutter);
        overflow-x: auto;
    }

    .timeline::before {
        display: none;
    }

    .timeline-item,
    .timeline-item:last-child {
        display: block;
        flex: 0 0 auto;
        width: auto;
        margin: 0;
        padding: 9px 17px;
        border-radius: 999px;
        background: var(--glass-fill-strong);
        border: 1px solid var(--glass-edge);
        background-clip: padding-box;
        box-shadow: 0 0 0 .5px rgba(15, 23, 42, .07), 0 4px 12px -6px rgba(15, 23, 42, .2);
        transition: background-color .25s var(--ease), box-shadow .25s var(--ease);
    }

    .timeline-dot {
        display: none;
    }

    .timeline-date {
        margin: 0;
        font-size: .95rem;
        font-weight: 500;
        color: var(--g-ink-2);
    }

    .timeline-item.active {
        background: var(--g-blue);
        border-color: transparent;
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px rgba(0, 113, 227, .7);
    }

    .timeline-item.active .timeline-date {
        color: #fff;
        font-weight: 600;
    }

    /* Una hoja para todo el año: nunca hay hitos "con caja" y "sin caja" */
    .timeline-content-box {
        min-height: 0;
        margin-top: .9rem;
        padding: .15rem 1.2rem;
        border-radius: 26px;
        background: var(--glass-fill-strong);
    }

    .timeline-event,
    .timeline-event + .timeline-event {
        position: relative;
        margin: 0;
        padding: 1rem 1.9rem 1rem 0;
    }

    .timeline-event + .timeline-event {
        border-top: 1px solid var(--glass-hairline);
    }

    /* Signo + / − a la derecha: indica que el hito se despliega al tocarlo */
    .timeline-event::after {
        content: '+';
        position: absolute;
        top: .85rem;
        right: 0;
        font-size: 1.35rem;
        font-weight: 300;
        line-height: 1.2;
        color: var(--g-blue);
    }

    .timeline-event.m-open::after {
        content: '\2212';
    }

    .timeline-content h3 {
        font-size: 1.03rem;
        line-height: 1.3;
        margin-bottom: 0;
    }

    .timeline-content p {
        margin-top: .35rem;
        font-size: .93rem;
        line-height: 1.5;
    }

    .timeline-event:not(.m-open) p {
        display: none;
    }

    .timeline-event.has-thumb {
        gap: .8rem;
    }

    .tl-thumb {
        width: 54px;
        height: 54px;
        border-radius: 14px;
    }

    /* --- SERVICIOS: carrusel de tarjetas altas --- */
    #services .grid-container {
        display: flex;
        gap: 12px;
        margin: 0 calc(var(--m-gutter) * -1);
        padding: 4px var(--m-gutter) 24px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding-left: var(--m-gutter);
    }

    #services .grid-item,
    #services .grid-item:first-child,
    #services .grid-item:last-child {
        flex: 0 0 78%;
        height: min(118vw, 440px);
        scroll-snap-align: start;
    }

    #services .grid-item:hover {
        transform: none;
    }

    #services .grid-item:first-child h3 {
        font-size: 1.15rem;
    }

    /* --- CASOS --- */
    #cases {
        margin: .9rem 8px;
        padding: 2.2rem 0 1.4rem;
    }

    #cases .section-title {
        margin-bottom: .9rem;
    }

    #cases .carousel-card {
        width: 76vw;
    }

    /* --- OPINIONES: citas sin caja, separadas por una línea fina --- */
    .testi-grid {
        --testi-gap: 0px;
    }

    .testi-grid.is-marquee {
        padding: 4px 0 18px;
        margin: 0 calc(var(--m-gutter) * -1);
    }

    .testi-track {
        animation-duration: 96s;
    }

    .testi-grid.is-marquee .testi-card:nth-child(n) {
        width: 80vw;
        padding: .2rem 1.5rem .3rem;
        background: none;
        border: 0;
        border-left: 1px solid rgba(15, 23, 42, .12);
        border-radius: 0;
        box-shadow: none;
    }

    .is-marquee .testi-quote {
        margin: .8rem 0 1.1rem;
        font-size: 1.2rem;
        line-height: 1.4;
        letter-spacing: -.012em;
    }

    .is-marquee .testi-card::before {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }

    .is-marquee .testi-card {
        grid-template-columns: 38px 1fr auto;
    }

    .is-marquee .testi-source-tag {
        background: none;
        padding: 0;
    }

    .testi-source-link {
        margin-top: .4rem;
        text-align: left;
    }

    /* --- FAQ: lista abierta con líneas, sin tarjetas --- */
    .faq-list {
        gap: 0;
        border-top: 1px solid rgba(15, 23, 42, .12);
    }

    .faq-item,
    .faq-item[open] {
        background: none;
        border: 0;
        border-bottom: 1px solid rgba(15, 23, 42, .12);
        border-radius: 0;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .faq-item summary {
        font-size: 1.02rem;
        padding: 1.05rem 0;
    }

    .faq-answer {
        padding: 0 1.6rem 1.15rem 0;
    }

    .faq-more {
        text-align: left;
        margin-top: 1.1rem;
    }

    /* --- CONTACTO: selector de clínica, mapa grande y datos sin caja;
           el formulario es la única hoja de la sección --- */
    .contact-grid {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .clinic-locations {
        order: -1;
        margin: 0 0 1.6rem;
    }

    .m-seg {
        display: flex;
        gap: 2px;
        padding: 4px;
        margin: 0 0 1rem;
        border-radius: 16px;
        background: rgba(118, 118, 128, .16);
        box-shadow: inset 0 1px 2px rgba(15, 23, 42, .06);
    }

    .m-seg button {
        flex: 1;
        min-width: 0;
        padding: .6rem .5rem;
        border: 0;
        border-radius: 12px;
        font: 500 .95rem var(--font-main);
        color: var(--g-ink-2);
        background: transparent;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background-color .25s var(--ease), color .25s var(--ease), box-shadow .25s var(--ease);
    }

    .m-seg button[aria-selected="true"] {
        font-weight: 600;
        color: var(--g-ink);
        background: rgba(255, 255, 255, .95);
        box-shadow: 0 0 0 .5px rgba(15, 23, 42, .06), 0 3px 8px rgba(15, 23, 42, .14);
    }

    .clinic-location,
    .clinic-location:last-child {
        display: flex;
        flex-direction: column;
        margin: 0 0 1.4rem;
        padding: 0;
        background: none;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    /* Con el selector solo se ve la clínica elegida */
    body.m-app .clinic-location:not(.m-on) {
        display: none;
    }

    body.m-app .clinic-location {
        margin-bottom: 0;
    }

    .map-container {
        order: -1;
        margin: 0 0 1rem;
        padding: 0;
    }

    .map-container iframe {
        height: 210px;
        border-radius: 26px;
        box-shadow: 0 0 0 1px rgba(255, 255, 255, .8), 0 18px 40px -18px rgba(15, 23, 42, .4);
    }

    .clinic-location h3 {
        font-size: 1.25rem;
        margin-bottom: .2rem;
    }

    .clinic-location p {
        margin-bottom: .9rem;
        font-size: .95rem;
        line-height: 1.5;
    }

    .m-actions {
        display: flex;
        gap: 8px;
        margin: 0;
    }

    .m-actions a {
        flex: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: .4rem;
        padding: 12px 10px;
        border-radius: 999px;
        font-size: .95rem;
        font-weight: 500;
        text-decoration: none;
        color: var(--g-blue);
        background: rgba(0, 113, 227, .1);
    }

    .m-actions a:first-child {
        color: #fff;
        background: var(--g-blue);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px rgba(0, 113, 227, .7);
    }

    .m-actions svg {
        width: 17px;
        height: 17px;
        flex: 0 0 auto;
    }

    .contact-form-container {
        padding: 1.3rem;
    }

    .contact-form .cta-button {
        align-self: stretch;
        text-align: center;
    }

    /* --- PIE --- */
    .main-footer {
        padding: 1.4rem 0 1rem;
        margin-top: 1.6rem;
    }

    /* --- BARRA INFERIOR --- */
    .m-tabbar {
        position: fixed;
        z-index: 990;
        left: 50%;
        bottom: calc(12px + env(safe-area-inset-bottom));
        transform: translateX(-50%);
        display: flex;
        align-items: center;
        gap: 2px;
        box-sizing: border-box;
        height: var(--m-tabbar-h);
        max-width: calc(100vw - 20px);
        padding: 6px;
        border-radius: 999px;
        background: linear-gradient(180deg, rgba(255, 255, 255, .93), rgba(255, 255, 255, .85));
        border: 1px solid var(--glass-edge);
        background-clip: padding-box;
        -webkit-backdrop-filter: blur(30px) saturate(180%);
        backdrop-filter: blur(30px) saturate(180%);
        box-shadow:
            0 0 0 .5px rgba(15, 23, 42, .1),
            0 18px 40px -14px rgba(15, 23, 42, .45),
            inset 0 1px 0 rgba(255, 255, 255, .95);
        transition: transform .35s var(--ease), opacity .35s var(--ease);
    }

    /* Con el menú abierto la barra se aparta */
    .main-header.mobile-open ~ .m-tabbar {
        opacity: 0;
        pointer-events: none;
        transform: translate(-50%, 24px);
    }

    .m-tabbar a {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 0;
        height: 100%;
        min-width: 50px;
        padding: 0 14px;
        box-sizing: border-box;
        border-radius: 999px;
        color: var(--g-ink-3);
        text-decoration: none;
        -webkit-tap-highlight-color: transparent;
        transition: background-color .3s var(--ease), color .3s var(--ease), gap .3s var(--ease);
    }

    .m-tabbar svg {
        width: 23px;
        height: 23px;
        flex: 0 0 auto;
    }

    /* Solo la pestaña activa enseña su nombre */
    .m-tabbar span {
        max-width: 0;
        overflow: hidden;
        white-space: nowrap;
        font-size: .86rem;
        font-weight: 600;
        letter-spacing: -.01em;
        opacity: 0;
        transition: max-width .35s var(--ease), opacity .25s var(--ease);
    }

    .m-tabbar a.is-active {
        gap: 7px;
        color: #fff;
        background: var(--g-blue);
        box-shadow: inset 0 1px 0 rgba(255, 255, 255, .35), 0 8px 18px -8px rgba(0, 113, 227, .8);
    }

    .m-tabbar a.is-active span {
        max-width: 9.5rem;
        opacity: 1;
    }

    /* El aviso de cookies se coloca por encima de la barra */
    body.m-app #cookie-banner {
        bottom: calc(var(--m-tabbar-h) + 22px + env(safe-area-inset-bottom)) !important;
    }
}

@media (max-width: 768px) and (prefers-reduced-motion: reduce) {
    .m-tabbar,
    .m-tabbar a,
    .m-tabbar span {
        transition: none;
    }
}
