/* EL JUEGO DETRÁS DEL JUEGO — V5 MOBILE BACKDROP VISIBILITY FIX
   Visual-only correction. No copy, layout markup, interaction or desktop styling changes.
   1) Make the photographic plate sticky in normal flow rather than sticky inside an absolute-sized wrapper.
   2) Keep mobile photos visible beneath legible, scoped dark scrims.
*/
@media (max-width: 800px) {
  /* An absolutely positioned ancestor made the original sticky child unreliable
     as long editorial chapters scrolled. Move the sticky behavior to the plate. */
  main > section.has-cinema-environment > .cinema-environment {
    position: sticky;
    top: 0;
    left: auto;
    right: auto;
    bottom: auto;
    width: 100%;
    height: 100svh;
    margin-bottom: -100svh;
    z-index: 0;
    overflow: hidden;
    pointer-events: none;
    opacity: 1;
  }
  .has-cinema-environment .cinema-environment__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    min-height: 0;
    background-image:
      linear-gradient(180deg,
        rgba(4, 11, 8, .58) 0%,
        rgba(5, 12, 9, .36) 27%,
        rgba(5, 12, 9, .42) 63%,
        rgba(4, 10, 8, .76) 100%),
      linear-gradient(90deg, rgba(5, 12, 9, .50) 0%, rgba(5, 12, 9, .20) 60%, rgba(5, 12, 9, .14) 100%),
      var(--cinema-image);
    background-repeat: no-repeat;
    background-size: cover;
    background-position: var(--cinema-mobile-position, center center);
    box-shadow: inset 0 0 45px rgba(0,0,0,.12);
  }
  .has-cinema-environment .cinema-environment__image::before {
    background: linear-gradient(180deg, rgba(5,11,9,.27), transparent 18%, transparent 74%, rgba(5,11,9,.46));
  }
  .has-cinema-environment .cinema-environment__texture {
    opacity: .26;
  }
  /* Each section already supplies its own mobile image via --cinema-image in cinema-v3.css.
     Avoid blackening that image with the former 80–96% opacity tones. */
  #pilares .mindset-core__intro h2,
  #temario .syllabus__heading h2,
  #laboratorio .ev-lab__intro h2,
  #marco .framework__heading h2,
  #decision .decision__heading h2,
  #libro .book-index__heading h2,
  #autor .author__heading h2,
  #novedades .signup__heading h2 {
    text-shadow: 0 4px 20px rgba(0,0,0,.82), 0 9px 45px rgba(0,0,0,.55);
  }

  /* Section two uses physical <picture> elements, not the generic v3 layer. */
  #perspectiva .story-v4__opening-photo img {
    object-position: 59% center;
    filter: saturate(.98) contrast(1.05) brightness(1.12);
  }
  #perspectiva .story-v4__opening-shade {
    background:
      linear-gradient(180deg, rgba(5,11,9,.67) 0%, rgba(5,11,9,.48) 30%, rgba(5,11,9,.68) 100%),
      linear-gradient(90deg, rgba(5,11,9,.44), transparent 88%);
  }
  #perspectiva .story-v4__revelation-photo {
    background:
      linear-gradient(180deg, rgba(7,16,13,.64), rgba(7,16,13,.53) 56%, rgba(7,16,13,.76)),
      url('assets/story-v4/medianoche-mobile.webp') 56% center / cover no-repeat;
  }
  /* Narrative photos need to stand in the available negative space above each card's copy. */
  #perspectiva .story-v4__moment-shade {
    background: linear-gradient(0deg, rgba(4,11,9,.97) 0%, rgba(4,11,9,.83) 27%, rgba(4,11,9,.24) 64%, rgba(4,11,9,.02) 100%);
  }
  #perspectiva .story-v4__moment--after .story-v4__moment-shade {
    background: linear-gradient(0deg, rgba(4,10,9,.96) 0%, rgba(4,10,9,.80) 27%, rgba(4,10,9,.28) 67%, rgba(4,10,9,.02) 100%);
  }
  /* Opening hero has a dedicated photo, but its old mobile glass plate was almost opaque. */
  #inicio .hero__grain {
    background:
      linear-gradient(180deg, rgba(5,11,9,.71) 0%, rgba(6,11,10,.73) 40%, rgba(6,12,10,.66) 65%, rgba(5,10,9,.38) 100%),
      linear-gradient(90deg, rgba(5,10,8,.49), rgba(5,10,8,.13) 75%);
  }
  #inicio .hero-photo {opacity:.95;filter:brightness(1.09);}
}
@media (max-width: 800px) and (prefers-reduced-motion: reduce) {
  main > section.has-cinema-environment > .cinema-environment {
    position: sticky;
  }
  .has-cinema-environment .cinema-environment__image {
    position: absolute;
    inset: 0;
    height: 100%;
  }
}

/* Progressive enhancement: without JS the section still has its own photograph,
   although the sticky photographic layer (added by cinema-v3.js) is unavailable. */
@media (max-width: 800px) {
  main > section:is(#pilares,#temario,#laboratorio,#marco,#decision,#libro,#riesgo,#fragmento,#autor,#novedades):not(.has-cinema-environment),
  main > section.faq:not(.has-cinema-environment) {
    background-image:
      linear-gradient(180deg,rgba(4,11,8,.80),rgba(5,12,9,.52) 36%,rgba(5,12,9,.82)),
      var(--cinema-image);
    background-repeat:no-repeat;
    background-size:cover;
    background-position:center center;
  }
}
