/* Mobile-only fixes (<= 480px). Desktop is untouched. */

@media (max-width: 480px) {
  /* 1. Menu button moves from the top-right corner to the top-left corner.
        --padding-xs is used because .button-round redefines --padding locally. */
  #Header > nav .Header__toggle {
    position: absolute;
    top: var(--padding-xs);
    left: var(--padding-xs);
    margin-left: 0;
  }

  /* 2. Brand logo stays pinned to the top of the header from the first paint.
        The huge "deco" logo that used to float in the middle of the hero is disabled. */
  #Header > .logo,
  body.--mode-logo #Header > .logo {
    position: absolute;
    top: var(--padding-xs);
    left: 50%;
    width: 8.5rem;
    opacity: 1;
    transform: translateX(-50%);
  }

  #HeaderLogo {
    display: none !important;
  }

  /* Keep the CTA on the right and let the header shrink to its content. */
  #Header {
    justify-content: flex-end;
    padding-top: var(--padding);
    background: rgba(0, 0, 0, 0.34);
    -webkit-backdrop-filter: blur(16px) saturate(120%);
    backdrop-filter: blur(16px) saturate(120%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.14);
  }

  /* Keep the mobile booking and menu controls crisp white against the dark glass. */
  #Header > nav .header__whatsapp.button-round.--outline,
  #Header > nav .Header__toggle.button-round.--outline {
    --color: #fff !important;
    --border-color: #fff !important;
    color: #fff !important;
  }

  #Header > nav {
    margin-left: auto;
  }

  /* 3. Hero: the portrait video must render in place even when the reveal
        animation never runs on touch devices (template default is translateY(250%)). */
  .widget-landing > .content > .holder {
    transform: none !important;
    -webkit-transform: none !important;
  }

  /* 4. Statement block: one screen tall with the text centred (template layout) and
        the fade-out disabled, because on mobile it faded ~300px before the section
        ended and left an empty screen behind.
        The gap to the gallery (margin of #opiniones) lives in assets/css/opiniones.css. */
  section.block-highlight-text.--title:has(+ #opiniones) {
    --scroll-height: var(--height);
    margin-bottom: 128px;
  }

  /* 5. Espacio entre categorías y pasos (reducido al 66%, padding-bottom pasa de 300px a 100px) */
  .td-categories {
    padding-bottom: 100px !important;
  }

  /* 6. Espacio hacia EVALUACIÓN PERSONALIZADA (reducido al 70%, margin-top pasa de 550px a 165px) */
  #Slider__Horizontal13 #cta-evaluacion {
    margin-top: 165px !important;
  }

  /* 7. Títulos de la sección de servicios (móvil): 40px el de sección y 34px los
        tratamientos destacados, ambos centrados respecto de la pantalla. */
  .widget-services .intro .__title {
    font-size: 40px;
    line-height: 0.9;
    text-align: center;
  }

  .widget-services .service-card .name.__title {
    font-size: 34px !important;
    line-height: 0.9;
    text-align: center;
  }

  /* 8. CTA del bloque Método: +5px sobre los 12px base (queda en 17px). */
  .block-title-image-text-link a.metodo-cta {
    font-size: 17px;
  }

  /* 9. Bloque Método: media línea extra entre el título y el párrafo (solo móvil). */
  section.block-title-image-text-link:has(a.metodo-cta) .text h2 {
    margin-bottom: 12px;
  }

  /* The Results panel's bottom spacing combines with the gallery padding to
     create the requested 100px visible gap after the heading. */
  .block-title-text-image:has(.galeria-titulo) {
    margin-bottom: 1px !important;
  }

  .block-title-text-image:has(.galeria-titulo) + .block-highlight-projects-mobile {
    margin-top: 0 !important;
  }

  /* The before/after gallery-to-next-section gap is 160px on mobile. */
  .block-highlight-projects-mobile {
    margin-bottom: 160px !important;
  }

  /* Remove the next section's top margin so adjacent margins do not collapse unpredictably. */
  .block-highlight-projects-mobile + .block-title-2-images-text-link {
    margin-top: 0 !important;
  }

  /* Links default to touch-action: manipulation, which prevents a horizontal
     swipe that begins on a card from scrolling its native overflow container. */
  .block-highlight-projects-mobile .content {
    touch-action: pan-x pan-y;
  }

  .block-highlight-projects-mobile .project {
    touch-action: pan-x pan-y;
  }

  .block-title-2-images-text-link:has(.intro h2.__title:only-child) {
    margin-top: 0 !important;
  }

  /* The published source renders the preceding before/after carousel as .as-slider. */
  section.as-slider {
    margin-bottom: 160px !important;
  }

  section.as-slider + section.block-text-steps-title-image {
    margin-top: 160px !important;
  }

  /* The FAQ section follows the Blog card section by 160px. */
  section.block-title-2-images-text-link + section.block-title-2-images-text-link:has(.label) {
    margin-top: 160px !important;
  }

  /* The moving ribbon uses a 15s base animation; doubling it slows the mobile loop. */
  .block-text-scroll .basic-marquee {
    --animation: 30s;
  }

  /* Blog article headlines use the requested 17px / 900 mobile treatment. */
  section.block-title-2-images-text-link:has(.intro h2.__title:only-child) .intro .text p > span[style*="font-size:1.2em"] {
    font-size: 17px !important;
    font-weight: 900 !important;
  }

  /* Set FAQ questions above their answers rather than inline in the answer paragraph. */
  section.block-title-2-images-text-link:has(.label) .intro .text strong {
    font-weight: 700 !important;
  }

  section.block-title-2-images-text-link:has(.label) .intro .text p {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  section.block-title-2-images-text-link:has(.label) .intro .text strong {
    font-size: 17px !important;
  }

  /* Improve contrast and enlarge the overlaid video CTA on mobile. */
  section.block-media-fullscreen > div:first-child h2,
  section.block-media-fullscreen > div:first-child a {
    color: #fff !important;
  }

  section.block-media-fullscreen > div:first-child a {
    font-size: calc(1em + 5px) !important;
  }

  /* The final contact highlight reserves 200vh for desktop scroll choreography.
     On mobile, keep it to one viewport and leave a 200px gap before the footer. */
  article > section.block-highlight-text.--title:last-child {
    --scroll-height: var(--height);
    margin-top: 60px;
    margin-bottom: 200px;
  }

  /* Add separation below the footer logo and center the practice descriptor. */
  #Footer > .logo {
    margin-bottom: 15px;
  }

  #Footer > .bottom > .left > div {
    text-align: center;
  }

  /* The gallery normally adds top padding before its heading; net it out so the visible
     fade-edge-to-heading gap remains exactly 160px. */
  section.block-text-steps-title-image + section.mosaic-gallery {
    margin-top: calc(160px - clamp(2rem, 4vh, 3rem)) !important;
    padding-top: clamp(2rem, 4vh, 3rem) !important;
  }
}

@media (max-width: 480px) {
  /* Booking and close stay at opposite top corners of the open mobile menu. */
  #Sidemenu .sidemenu__contact__header {
    display: flex;
    justify-content: space-between;
    left: 0;
    padding: var(--padding-xs);
    position: absolute;
    right: 0;
    top: 0;
    width: 100%;
    z-index: 5;
  }

  /* Keep the long serif navigation labels inside the narrow left column. */
  #Sidemenu .sidemenu__nav > .list li {
    font-size: clamp(1.45rem, 5.4vw, 1.75rem) !important;
    line-height: 0.9;
  }

  /* The booking action already has its own top-left button. */
  #Sidemenu .sidemenu__nav > .list li:last-child {
    display: none;
  }

  /* Center only the contact block; the logo and legal links stay at the bottom. */
  #Sidemenu .sidemenu__contact > .contact {
    margin-block: auto;
  }

  #Sidemenu .sidemenu__nav > .list li a,
  #Sidemenu .sidemenu__nav > .list li a > span > span {
    height: 0.9em;
  }

  /* Give the slideshow one consistent horizontal frame for every photo. */
  #Sidemenu .sidemenu__slider figure {
    aspect-ratio: 16 / 9;
    overflow: hidden;
  }

  #Sidemenu .sidemenu__slider figure img {
    height: 100%;
    object-fit: cover;
    width: 100%;
  }

  /* On the phone layout the slider is the overlay column, so preserve an
     actual image frame instead of letting its source dimensions dominate it. */
  #Sidemenu .sidemenu__slider {
    bottom: 0;
    display: flex;
    left: 50%;
    position: absolute;
    right: auto;
    top: 0;
    transform: translateX(-50%);
    width: 30%;
    z-index: 2;
  }

  #Sidemenu .sidemenu__slider .__holder {
    height: 100%;
    width: 100%;
  }

  #Sidemenu .sidemenu__slider figure {
    aspect-ratio: 16 / 9;
    height: auto;
    width: 100%;
  }
}

/* Some pages have local drawer rules. Restore the same horizontal image rail
   there without changing how their navigation and contact sections flow. */
@media (max-width: 768px) {
  #Sidemenu .sidemenu__slider {
    display: flex !important;
  }

  #Sidemenu .sidemenu__slider figure {
    aspect-ratio: 16 / 9;
    overflow: hidden;
  }

  #Sidemenu .sidemenu__slider figure img {
    height: 100%;
    object-fit: cover;
    width: 100%;
  }
}

/* The speaker page uses a vertically stacked mobile drawer. Keep its menu
   gallery in that flow as a swipeable strip instead of hiding/overlaying it. */
@media (max-width: 768px) {
  body.body #Sidemenu .sidemenu__slider {
    bottom: auto !important;
    display: block !important;
    flex: 0 0 104px !important;
    height: 104px !important;
    left: auto !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    position: relative !important;
    right: auto !important;
    top: auto !important;
    transform: none !important;
    width: 100% !important;
    z-index: 3 !important;
  }

  body.body #Sidemenu .sidemenu__slider .__holder {
    display: flex !important;
    gap: 10px !important;
    height: 100% !important;
    min-width: 100% !important;
    position: relative !important;
    transform: none !important;
    width: max-content !important;
  }

  body.body #Sidemenu .sidemenu__slider li {
    flex: 0 0 166px !important;
    height: 100% !important;
    left: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    position: relative !important;
    right: auto !important;
    transform: none !important;
    width: 166px !important;
  }

  body.body #Sidemenu .sidemenu__slider li[style] {
    left: auto !important;
    right: auto !important;
    transform: none !important;
  }

  body.body #Sidemenu .sidemenu__slider li figure {
    aspect-ratio: 16 / 9 !important;
    height: 100% !important;
    padding-top: 0 !important;
    position: relative !important;
    width: 100% !important;
  }

  body.body #Sidemenu .sidemenu__slider li figure img {
    height: 100% !important;
    inset: 0 !important;
    object-fit: cover !important;
    position: absolute !important;
    transform: none !important;
    transform-origin: center center !important;
    width: 100% !important;
  }

  body.body #Sidemenu .sidemenu__slider li figure img[style] {
    transform: none !important;
    transform-origin: center center !important;
  }
}
