/* Videos: carga visual fluida y sin pantallas blancas */
[data-videos-section],
[data-public-videos],
[data-companies-section],
[data-public-companies],
[data-promotion-feature],
[data-sidebar-promotions],
[data-results-grid],
[data-instagram-grid],
[data-testimonials],
[data-home-highlight] {
  overflow-anchor: none;
}

/* El bloque destacado antiguo ya no se utiliza: las promociones activas se
   presentan como tarjetas fijas en la cuadrícula inferior. */
#promociones [data-promotion-feature][hidden] {
  display: none !important;
}

[data-public-videos] .video-frame {
  position: relative;
  overflow: hidden;
  background: linear-gradient(145deg, #dce7e8, #f4f7f7);
}

/* Geometría estable mientras el contenido público llega desde Supabase. */
.content-shell {
  pointer-events: none;
}

.content-shell-media,
.content-shell-line,
.content-shell-copy > span {
  display: block;
  background: linear-gradient(110deg, rgba(94, 157, 164, 0.1), rgba(255, 255, 255, 0.7), rgba(94, 157, 164, 0.1));
}

.content-shell-line,
.content-shell-copy > span {
  height: 0.9rem;
  margin: 14px 18px 0;
  border-radius: 999px;
}

.content-shell-line.is-short,
.content-shell-copy > span:last-child {
  width: 58%;
}

.content-shell-copy > span {
  width: 70%;
  margin-inline: 0;
}

.content-shell-copy {
  display: grid;
  align-content: center;
  gap: 16px;
  padding: clamp(24px, 3vw, 44px);
}

.companies-grid .company-card.content-shell {
  display: grid;
  place-items: center;
}

.companies-grid .company-card.content-shell .content-shell-media {
  width: 78%;
  height: 42%;
  border-radius: 10px;
}

.content-shell-copy > span {
  margin: 0;
}

[data-public-videos] .video-loading-indicator {
  position: absolute;
  inset: 0;
  z-index: 2;

  display: grid;
  place-items: center;

  background: linear-gradient(
    145deg,
    rgba(220, 231, 232, 0.96),
    rgba(244, 247, 247, 0.96)
  );

  opacity: 1;
  visibility: visible;
  pointer-events: none;

  transition:
    opacity 240ms ease,
    visibility 240ms ease;
}

[data-public-videos] .video-loading-indicator > span {
  width: 34px;
  height: 34px;

  border: 3px solid rgba(58, 121, 128, 0.22);
  border-top-color: #3a7980;
  border-radius: 50%;

  animation: video-loading-spin 0.8s linear infinite;
}

[data-public-videos] .video-card.is-media-ready .video-loading-indicator {
  opacity: 0;
  visibility: hidden;
}

[data-public-videos] video,
[data-public-videos] iframe {
  display: block;
  width: 100%;
  height: 100%;

  border: 0;
  background: transparent;
  object-fit: cover;
  object-position: center;

  opacity: 0;
  transition: opacity 320ms ease;
}

/* El brillo acompaña el cursor únicamente cuando existe puntero preciso. */
@media (hover: hover) and (pointer: fine) {
  body.public-site .site-main {
    background:
      radial-gradient(14rem circle at var(--cursor-x, 50%) var(--cursor-y, 20%), rgba(94, 157, 164, 0.075), transparent 72%),
      linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0)) !important;
  }
}

@media (hover: none), (pointer: coarse) {
  body.public-site .site-main {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0)) !important;
  }

  body.public-site .site-main::before,
  body.public-site .site-main::after {
    opacity: 0.14 !important;
    transform: none !important;
  }
}

[data-public-videos] .video-card.is-media-ready video,
[data-public-videos] .video-card.is-media-ready iframe {
  opacity: 1;
}

[data-public-videos] .video-poster,
[data-public-videos] .video-play-button {
  display: none;
}

/* Ajustes exclusivos para celular */
@media (max-width: 760px) {
  /* Los contenedores remotos conservan el alto final mientras muestran el
     shell. Al reemplazarse por datos reales no hay contenido anterior que
     pueda reanclar la lectura vertical en Safari o Chrome móvil. */
  #servicios:has(.content-shell) {
    min-height: clamp(534px, calc(15vw + 480px), 540px);
  }

  section:has([data-results-grid] .content-shell) {
    min-height: clamp(1328px, calc(275vw + 337px), 1523px);
  }

  section:has([data-featured-products] .content-shell) {
    min-height: clamp(528px, calc(36vw + 402px), 546px);
  }

  #servicios .service-row[data-home-services] .content-shell-media {
    width: 100%;
    height: 150px;
    margin: 0;
  }

  #servicios .service-row[data-home-services] .content-shell-line {
    margin-inline: 18px;
  }

  .promo-admin-section .promo-band > .content-shell-media {
    min-height: 0;
    aspect-ratio: 16 / 10;
  }

  .promo-month-grid .side-promo-card.content-shell {
    display: block;
    min-height: 500px;
  }

  .promo-month-grid .side-promo-card.content-shell .side-promo-media {
    width: 100%;
    aspect-ratio: 16 / 10;
  }

  .result-grid .result-tile.content-shell .result-visual {
    width: 100%;
    aspect-ratio: 1 / 1;
  }

  .testimonials-section .testimonial-layout {
    min-height: 450px;
  }

  .product-strip .product-card.content-shell .card-media {
    width: 100%;
    aspect-ratio: 16 / 10;
  }

  [data-videos-section] {
    padding-inline: 0 !important;
    overflow-anchor: none;
  }

  [data-public-videos].is-mobile-video-single {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 18px;

    width: 100% !important;
    max-width: none !important;

    margin: 0 auto !important;
    padding: 0 clamp(18px, 6vw, 28px) !important;

    overflow: visible !important;
    overflow-anchor: none;
  }

  [data-public-videos].is-mobile-video-single .video-card {
    width: min(82vw, 340px) !important;
    margin: 0 auto !important;

    border: 0 !important;
    border-radius: 18px !important;

    background: #e8eeee !important;
    box-shadow: 0 12px 30px rgba(18, 51, 51, 0.12) !important;

    transform: none !important;
    overflow: hidden !important;
    overflow-anchor: none;
    touch-action: pan-y;
  }

  [data-public-videos].is-mobile-video-single .video-frame,
  [data-public-videos].is-mobile-video-single video,
  [data-public-videos].is-mobile-video-single iframe {
    overflow-anchor: none;
  }

  [data-public-videos].is-mobile-video-single .video-card[hidden] {
    display: none !important;
  }

  [data-public-videos].is-mobile-video-single .video-card-placeholder {
    pointer-events: none;
  }

  [data-public-videos].is-mobile-video-single .video-frame {
    width: 100% !important;
    aspect-ratio: 9 / 16 !important;

    border-radius: inherit !important;
    background: linear-gradient(
      145deg,
      #dce7e8,
      #f4f7f7
    ) !important;

    overflow: hidden !important;
    isolation: isolate;
  }

  [data-public-videos].is-mobile-video-single video,
  [data-public-videos].is-mobile-video-single iframe {
    position: absolute;
    inset: 0;

    width: 100% !important;
    height: 100% !important;

    object-fit: cover;
  }

  /* El gesto vertical siempre pertenece a la página. Los videos se inician
     desde la tarjeta y no necesitan controles embebidos en esta vista. */
  [data-public-videos].is-mobile-video-single video,
  [data-public-videos].is-mobile-video-single iframe {
    pointer-events: none;
  }

  [data-public-videos].is-mobile-video-single .video-poster {
    position: absolute;
    inset: 0;
    z-index: 3;

    display: grid;
    place-items: center;
    overflow: hidden;

    background: linear-gradient(145deg, #7caaa9, #365f63);
    cursor: pointer;
    opacity: 1;
    visibility: visible;
    transition: opacity 180ms ease, visibility 180ms ease;
  }

  [data-public-videos].is-mobile-video-single .video-poster::after {
    position: absolute;
    inset: 0;
    content: "";
    background: linear-gradient(180deg, rgba(9, 35, 37, 0.04), rgba(9, 35, 37, 0.3));
    pointer-events: none;
  }

  [data-public-videos].is-mobile-video-single .video-poster img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
  }

  [data-public-videos].is-mobile-video-single .video-poster.is-fallback > span {
    color: rgba(255, 255, 255, 0.86);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
  }

  [data-public-videos].is-mobile-video-single .video-play-button {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    display: grid;
    width: 64px;
    height: 64px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.82);
    border-radius: 50%;
    place-items: center;
    background: rgba(15, 49, 51, 0.68);
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.2);
  }

  [data-public-videos].is-mobile-video-single .video-play-button > span {
    width: 0;
    height: 0;
    margin-left: 4px;
    border-top: 10px solid transparent;
    border-bottom: 10px solid transparent;
    border-left: 15px solid #ffffff;
  }

  [data-public-videos].is-mobile-video-single .video-card.is-preview-ready .video-poster.is-fallback {
    background: transparent;
  }

  [data-public-videos].is-mobile-video-single .video-card.is-preview-ready .video-poster.is-fallback::after,
  [data-public-videos].is-mobile-video-single .video-card.is-preview-ready .video-poster.is-fallback > span {
    display: none;
  }

  [data-public-videos].is-mobile-video-single .video-card.is-user-started .video-poster {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
  }

  [data-public-videos].is-mobile-video-single .video-card.is-user-started .video-loading-indicator {
    z-index: 4;
  }

  [data-public-videos].is-mobile-video-single .video-card:not(.is-user-started) .video-loading-indicator {
    display: none;
  }

  [data-public-videos] .video-mobile-dots,
  [data-public-videos] .video-mobile-dot {
    display: none !important;
  }

  /* Evita saltos verticales en Productos y Servicios */
  [data-featured-products].is-product-carousel,
  [data-home-services].is-service-carousel {
    overflow-anchor: none;
    overscroll-behavior-x: contain;
    overscroll-behavior-y: none;
  }

  [data-featured-products] .product-marquee-track,
  [data-home-services] .service-marquee-track,
  [data-featured-products] .product-card,
  [data-home-services] .service-card {
    overflow-anchor: none;
  }

  [data-featured-products] img,
  [data-home-services] img {
    display: block;
  }

  [data-promotion-feature] img,
  [data-sidebar-promotions] img,
  [data-results-grid] img,
  [data-instagram-grid] img {
    display: block;
  }

  /* En móvil, las fotografías conservan su proporción durante el scroll. */
  .hero-image.reveal-on-scroll,
  .hero-image.reveal-on-scroll.is-visible,
  .clinic-photo.reveal-on-scroll,
  .clinic-photo.reveal-on-scroll.is-visible {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
    will-change: auto !important;
  }

  .hero-image img,
  .clinic-photo img {
    display: block;
    transform: none !important;
    animation: none !important;
    transition: none !important;
    will-change: auto !important;
    object-fit: cover !important;
  }

  /* Mobile content stays visible once painted. Re-entering a section must not
     replay blur/scale reveals while the person scrolls back and forth. */
  .reveal-on-scroll,
  .reveal-on-scroll.is-visible {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
    animation: none !important;
    will-change: auto !important;
  }
}

@keyframes video-loading-spin {
  to {
    transform: rotate(360deg);
  }
}

@media (prefers-reduced-motion: reduce) {
  [data-public-videos] .video-loading-indicator > span {
    animation: none;
  }

  [data-public-videos] video,
  [data-public-videos] iframe {
    transition: none;
  }
}
