/* CONAMUR · iPhone Safari reliability layer
   Progressive enhancement: content stays readable even if JS animation cannot run. */

@supports (-webkit-touch-callout: none) {
  @media (max-width: 700px) {
    html { -webkit-text-size-adjust: 100%; }
    body.page-home { overflow-x: hidden; }

    /* Safari fallback: never leave copy invisible if animation JS fails. */
    body.page-home .home-title .line > span,
    body.page-home .manifesto-line,
    body.page-home .manifesto-side,
    body.page-home .manifesto-side p,
    body.page-home .identity-line,
    body.page-home .identity-caption,
    body.page-home .detail-copy,
    body.page-home .detail-challenge,
    body.page-home .detail-notes {
      opacity: 1 !important;
      transform: none !important;
      filter: none !important;
      -webkit-filter: none !important;
    }

    /* Keep spacing stable on the real iPhone viewport. */
    body.page-home .home-intro {
      min-height: 100vh !important;
      min-height: -webkit-fill-available !important;
    }
    body.page-home .home-manifesto,
    body.page-home .identity-scene,
    body.page-home .detail-scene {
      min-height: auto !important;
    }

    /* Once the Safari-safe controller is alive, it owns these animations. */
    body.page-home.safari-motion-ready .home-title .line > span,
    body.page-home.safari-motion-ready .manifesto-line,
    body.page-home.safari-motion-ready .manifesto-side p,
    body.page-home.safari-motion-ready .identity-line,
    body.page-home.safari-motion-ready .identity-caption,
    body.page-home.safari-motion-ready .detail-copy,
    body.page-home.safari-motion-ready .detail-challenge {
      will-change: transform, opacity;
    }

    /* Manifesto: preserve readable rhythm, no sticky overlap. */
    body.page-home.safari-mobile-safe .home-manifesto {
      padding: 28px 20px 44px !important;
      overflow: hidden !important;
    }
    body.page-home.safari-mobile-safe .home-manifesto .manifesto-grid {
      position: static !important;
      height: auto !important;
      min-height: 0 !important;
      margin: 12vh 0 0 !important;
      display: flex !important;
      flex-direction: column !important;
      gap: 28px !important;
      overflow: visible !important;
    }
    body.page-home.safari-mobile-safe .manifesto-copy {
      margin: 0 !important;
      width: 100% !important;
    }
    body.page-home.safari-mobile-safe .manifesto-side {
      display: block !important;
      width: 100% !important;
      max-width: 32ch !important;
      margin: 0 !important;
      padding: 0 !important;
      font-size: 15px !important;
      line-height: 1.5 !important;
    }
    body.page-home.safari-mobile-safe .manifesto-side p {
      margin: 0 0 15px !important;
    }
    body.page-home.safari-mobile-safe .manifesto-side p:last-child { margin-bottom: 0 !important; }

    /* Identity: stars stay above the background and below copy. */
    body.page-home.safari-mobile-safe .identity-sticky {
      position: relative !important;
      min-height: 86vh !important;
      overflow: hidden !important;
    }
    body.page-home.safari-mobile-safe .identity-stars-mobile {
      display: block !important;
      position: absolute !important;
      inset: 0 !important;
      z-index: 1 !important;
      pointer-events: none !important;
    }
    body.page-home.safari-mobile-safe .identity-stars-mobile .star {
      display: block !important;
      position: absolute !important;
      width: 12px !important;
      height: 12px !important;
      opacity: .55 !important;
      transform: translate(-50%,-50%) rotate(0deg) !important;
      animation: safariStar 2.35s ease-in-out infinite !important;
    }
    body.page-home.safari-mobile-safe .identity-stars-mobile .star::before,
    body.page-home.safari-mobile-safe .identity-stars-mobile .star::after {
      content: "" !important;
      position: absolute !important;
      left: 50% !important;
      top: 50% !important;
      background: var(--accent) !important;
      transform: translate(-50%,-50%) !important;
    }
    body.page-home.safari-mobile-safe .identity-stars-mobile .star::before { width: 1.5px !important; height: 100% !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .star::after { width: 100% !important; height: 1.5px !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .s1 { left: 12%; top: 24%; animation-delay: -.15s !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .s2 { left: 31%; top: 45%; animation-delay: -.7s !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .s3 { left: 53%; top: 22%; animation-delay: -1.1s !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .s4 { left: 71%; top: 48%; animation-delay: -.38s !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .s5 { left: 86%; top: 29%; animation-delay: -1.45s !important; }
    body.page-home.safari-mobile-safe .identity-stars-mobile .s6 { left: 43%; top: 68%; animation-delay: -.95s !important; }
    body.page-home.safari-mobile-safe .identity-small,
    body.page-home.safari-mobile-safe .identity-words,
    body.page-home.safari-mobile-safe .identity-caption { position: relative !important; z-index: 2 !important; }
    @keyframes safariStar {
      0%,100% { opacity: .18; transform: translate(-50%,-50%) scale(.55) rotate(0deg); }
      46% { opacity: .9; transform: translate(-50%,-50%) scale(1.25) rotate(45deg); }
      65% { opacity: .35; transform: translate(-50%,-50%) scale(.8) rotate(70deg); }
    }

    /* Detail game: range must actually receive horizontal touch gestures. */
    body.page-home.safari-mobile-safe .detail-challenge,
    body.page-home.safari-mobile-safe .detail-kerning-game {
      display: block !important;
      width: 100% !important;
      pointer-events: auto !important;
    }
    body.page-home.safari-mobile-safe .kerning-control {
      position: relative !important;
      z-index: 40 !important;
      display: block !important;
      width: 100% !important;
      padding: 10px 0 !important;
      touch-action: none !important;
      -webkit-user-select: none !important;
      user-select: none !important;
    }
    body.page-home.safari-mobile-safe .kerning-range {
      -webkit-appearance: none !important;
      appearance: none !important;
      display: block !important;
      width: 100% !important;
      height: 36px !important;
      margin: 0 !important;
      padding: 0 !important;
      border: 0 !important;
      background: transparent !important;
      opacity: 1 !important;
      pointer-events: auto !important;
      touch-action: none !important;
    }
    body.page-home.safari-mobile-safe .kerning-range::-webkit-slider-runnable-track {
      height: 2px !important;
      background: rgba(17,17,15,.42) !important;
      border: 0 !important;
    }
    body.page-home.safari-mobile-safe .kerning-range::-webkit-slider-thumb {
      -webkit-appearance: none !important;
      appearance: none !important;
      width: 24px !important;
      height: 24px !important;
      margin-top: -11px !important;
      border: 0 !important;
      border-radius: 50% !important;
      background: var(--ink) !important;
      box-shadow: 0 0 0 6px rgba(242,240,234,.35) !important;
    }

    /* Keep the detail explanation readable even before the game is solved. */
    body.page-home.safari-mobile-safe .detail-notes {
      display: block !important;
      position: relative !important;
      width: 100% !important;
      max-width: 32ch !important;
      margin: 24px 0 0 !important;
      padding: 0 0 34px !important;
      font-size: 15px !important;
      line-height: 1.5 !important;
    }
  }
}

/* ===== 15/09 · Safari móvil: ritmo de Detalles + navegación contextual ===== */
@supports (-webkit-touch-callout: none) {
  @media (max-width:700px) {
    /* Evita el gran vacío de la sección rosa y fuerza el texto a participar en la composición. */
    body.page-home.mobile-home-final.safari-mobile-safe .detail-scene {
      min-height: 0 !important;
      height: auto !important;
      padding: 28px 20px 38px !important;
      display: flex !important;
      flex-direction: column !important;
      justify-content: flex-start !important;
      align-items: flex-start !important;
      gap: 0 !important;
      overflow: hidden !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-scene > .section-index {
      margin: 0 0 54px !important;
      position: static !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-copy {
      position: static !important;
      width: 100% !important;
      margin: 0 !important;
      padding: 0 !important;
      opacity: 1 !important;
      transform: none !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-copy .accent-copy {
      margin: 12px 0 0 !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-notes {
      display: block !important;
      position: static !important;
      left: auto !important;
      right: auto !important;
      bottom: auto !important;
      width: 100% !important;
      max-width: 31ch !important;
      margin: 30px 0 0 !important;
      padding: 0 !important;
      opacity: 1 !important;
      transform: none !important;
      filter: none !important;
      -webkit-filter: none !important;
      clip-path: none !important;
      background: transparent !important;
      font-size: 15px !important;
      line-height: 1.5 !important;
      color: var(--ink) !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-notes p {
      margin: 0 0 14px !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-notes p:last-child {
      margin-bottom: 0 !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-final {
      margin-top: 20px !important;
      font-size: 22px !important;
      line-height: 1.08 !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .detail-kerning-game {
      margin: 40px 0 0 !important;
      opacity: 1 !important;
      transform: none !important;
    }
    body.page-home.mobile-home-final.safari-mobile-safe .kerning-stage {
      margin-top: 14px !important;
    }

    /* Safari: el color del menú lo controla JS según la sección que pasa por debajo. */
    body.page-home.safari-mobile-safe .site-header {
      mix-blend-mode: normal !important;
      color: var(--ink) !important;
    }
    body.page-home.safari-mobile-safe .site-nav a {
      mix-blend-mode: normal !important;
      transition: color .22s ease !important;
      -webkit-transition: color .22s ease !important;
    }
    body.page-home.safari-mobile-safe .site-header.safari-header-light .site-nav a {
      color: var(--ink) !important;
    }
    body.page-home.safari-mobile-safe .site-header.safari-header-dark .site-nav a,
    body.page-home.safari-mobile-safe .site-header.safari-header-accent .site-nav a {
      color: #fff !important;
    }
  }
}

/* ===== Safari iPhone · CTA final estable ===== */
@supports (-webkit-touch-callout: none){
  @media(max-width:700px){
    body.page-home.safari-mobile-safe .home-nav{
      padding-left:20px!important;
      padding-right:20px!important;
      overflow:visible!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links{
      width:100%!important;
      overflow:visible!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .home-route{
      display:grid!important;
      grid-template-columns:minmax(0,1fr) 88px!important;
      align-items:center!important;
      column-gap:12px!important;
      min-height:108px!important;
      padding:18px 14px!important;
      overflow:hidden!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .home-route>span{
      min-width:0!important;
      width:auto!important;
      max-width:100%!important;
      padding:0!important;
      margin:0!important;
      font-size:clamp(28px,7.5vw,35px)!important;
      line-height:.94!important;
      letter-spacing:-.025em!important;
      white-space:nowrap!important;
      transform:none!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .route-talk>span{
      padding-left:.09em!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .home-route i{
      width:88px!important;
      min-width:88px!important;
      height:54px!important;
      padding:0!important;
      margin:0!important;
      display:flex!important;
      flex-direction:column!important;
      align-items:flex-end!important;
      justify-content:center!important;
      gap:10px!important;
      position:relative!important;
      z-index:4!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .home-route i b{
      display:block!important;
      min-height:11px!important;
      font-size:9px!important;
      line-height:1!important;
      white-space:nowrap!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .home-route i em{
      font-size:10px!important;
      line-height:1!important;
      white-space:nowrap!important;
    }
    body.page-home.safari-mobile-safe .home-nav-links .home-route.mobile-active{
      padding-left:14px!important;
      padding-right:14px!important;
    }
  }
}

@media(max-width:700px){
  body.page-home.safari-mobile-safe .identity-words{font-size:clamp(56px,15.8vw,68px)!important;line-height:.88!important;letter-spacing:-.045em!important}
}


/* 16/09 · abanico de color seguro para Safari móvil */
@media(max-width:700px){
  body.page-home.safari-mobile-safe .identity-swatch-fan{display:block!important;opacity:1!important;visibility:visible!important}
  body.page-home.safari-mobile-safe .identity-swatch-fan .swatch-card{opacity:1!important;visibility:visible!important;-webkit-transform-origin:50% 90%!important}
}
