/* ══ MOBILE & DEVICE SUPPORT ══ */
/* ══ GLOBAL DEVICE SUPPORT ADDITIONS ══ */

/* ── iPhone notch / Dynamic Island safe area support ── */
:root {
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left:   env(safe-area-inset-left, 0px);
  --safe-right:  env(safe-area-inset-right, 0px);
}
header {
  padding-top: var(--safe-top);
  height: calc(70px + var(--safe-top));
}
@media (max-width: 560px) {
  header { height: calc(60px + var(--safe-top)); }
  .mobile-nav { top: calc(60px + var(--safe-top)); }
}
.mobile-nav { top: calc(70px + var(--safe-top)); }
footer, .footer-bottom, .cp-footer-bottom, .np-footer-bottom, .footer-bottom-about {
  padding-bottom: calc(16px + var(--safe-bottom));
}

/* ── Prevent sticky hover on touch devices (all overlays) ── */
@media (hover: none) and (pointer: coarse) {
  .show-card-light:hover,
  .show-card-dark:hover,
  .show-card-past:hover { transform: none; }
  .cards-container:hover .cards-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
  .cards-container:hover .side-panel { width: 0; pointer-events: none; }
  .btn-primary:hover, .btn-secondary:hover { transform: none; }
  nav a:hover { background: transparent; }
  .actor-card:hover .card-inner { transform: none; }
  .tl-card:hover { transform: none; }
  #about-page-overlay .glass-card:hover { transform: none; }
  #bb-page-overlay .glass-card:hover { transform: none; }
}

/* ── Very small phones (320px) ── */
@media (max-width: 320px) {
  .hero-tagline h1 { font-size: 20px; }
  .logo-circle { width: 90px; height: 90px; }
  .hero-cta { flex-direction: column; align-items: center; }
  .btn-primary, .btn-secondary { width: 100%; justify-content: center; }
  .header-logo-text { display: none; }
  nav a { padding: 6px 10px; font-size: 10px; letter-spacing: 0.1em; }
  .cards-grid { grid-template-columns: 1fr; }
}

/* ── Landscape phone fix — all overlay pages ── */
@media (max-width: 812px) and (orientation: landscape) and (max-height: 500px) {
  #actors-page-overlay .hero,
  #about-page-overlay .hero-about,
  #contact-page-overlay .cp-hero,
  #news-page-overlay .np-hero,
  #bb-page-overlay .hero { min-height: auto; padding-top: 60px; padding-bottom: 40px; }

  #actors-page-overlay .hero-title,
  #about-page-overlay .hero-title-about { font-size: clamp(28px, 5vw, 44px); }

  #contact-page-overlay .cp-hero-title { font-size: clamp(26px, 5vw, 40px); }

  .hero-content { padding: 20px 24px 40px; gap: 20px; flex-direction: row; }
  .logo-circle { width: 100px; height: 100px; }

  /* Splash landscape */
  #splash-top { flex: 0 0 55%; }
  #splash-bottom { padding-top: 40px; padding-bottom: 10px; }
  .splash-device-wrap { max-width: 60vw; }
}

/* ── Tablet portrait (768–1024px) ── */
@media (min-width: 768px) and (max-width: 1023px) {
  .hero-content { padding: 40px 40px 80px; gap: 28px; }
  .cards-container { padding: 0 30px; }
  .cards-grid { grid-template-columns: repeat(2, 1fr); }
  .past-grid { grid-template-columns: repeat(2, 1fr); }
  #contact-page-overlay .cp-contacts-grid { grid-template-columns: 1fr 1fr; padding: 0 24px; }
  #contact-page-overlay .cp-visit-grid { grid-template-columns: 1fr; padding: 0 24px; }
  #about-page-overlay .ab-timeline { padding: 0 20px; }
  #about-page-overlay .tl-content { max-width: calc(50% - 30px); }
}

/* ── Large desktop (1440px+) ── */
@media (min-width: 1440px) {
  .hero-content { padding: 80px 80px 140px; }
  .cards-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Reduce motion — respect user accessibility preference ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .aurora-blob { animation: none; }
  .logo-glow-ring { animation: none; }
  .logo-glow-ring2 { animation: none; }
  .fade-in { opacity: 1; transform: none; transition: none; }
}

/* ── GPU compositing hint for overlay pages ── */
#actors-page-overlay,
#about-page-overlay,
#contact-page-overlay,
#news-page-overlay,
#bb-page-overlay {
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* ── News page responsive additions ── */
@media (max-width: 767px) {
  #news-page-overlay .np-hero { min-height: 50vh; padding-top: 60px; }
  #news-page-overlay .np-container { padding: 0 16px; }
  #news-page-overlay .np-item { flex-wrap: wrap; gap: 12px; }
  #news-page-overlay .np-photo { width: 60px; height: 60px; flex-shrink: 0; }
  #news-page-overlay .np-title { font-size: 15px; }
  #news-page-overlay .np-preview { font-size: 13px; overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; line-clamp: 2; }
  #news-page-overlay footer { grid-template-columns: 1fr; padding: 32px 20px; gap: 20px; }
  #news-page-overlay .np-footer-bottom { flex-direction: column; gap: 4px; text-align: center; font-size: 12px; padding: 12px 16px; }
}
@media (max-width: 480px) {
  #news-page-overlay .np-hero-title { font-size: clamp(2rem, 8vw, 3rem); }
  #np-modal-box { border-radius: 16px; padding: 20px; }
}

/* ══ MOBILE PERFORMANCE OPTIMIZATIONS (max-width: 768px) ══ */

/* ══════════════════════════════════════════════════════════
   UNIVERSAL MOBILE NAV — однаковий стиль на ВСІХ сторінках
═══════════════════════════════════════════════════════════ */
.ab-mobile-nav, .np-mobile-nav, .bb-mobile-nav, .cp-mobile-nav,
#abMobileNav, #npMobileNav, #bbMobileNav,
#contact-page-overlay .mobile-nav,
#actors-page-overlay .mobile-nav, #actorsMobileNav {
  background: rgba(238,240,245,0.97) !important;
  border-bottom: 1px solid rgba(255,255,255,0.7) !important;
  padding: 20px !important;
  gap: 8px !important;
  box-shadow: 0 8px 30px rgba(80,80,120,0.12) !important;
}
.ab-mobile-nav a, .np-mobile-nav a, .bb-mobile-nav a, .cp-mobile-nav a,
#abMobileNav a, #npMobileNav a, #bbMobileNav a,
#contact-page-overlay .mobile-nav a,
#actors-page-overlay .mobile-nav a, #actorsMobileNav a {
  font-family: 'Nunito', sans-serif !important;
  font-size: 16px !important;
  font-weight: 600 !important;
  letter-spacing: normal !important;
  text-transform: none !important;
  color: #3d3560 !important;
  padding: 12px 18px !important;
  border-radius: 14px !important;
  background: rgba(255,255,255,0.4) !important;
  border: 1px solid rgba(255,255,255,0.6) !important;
  text-decoration: none !important;
  display: block !important;
  transition: all 0.3s !important;
}
.ab-mobile-nav a:hover, .np-mobile-nav a:hover, .bb-mobile-nav a:hover, .cp-mobile-nav a:hover,
#abMobileNav a:hover, #npMobileNav a:hover, #bbMobileNav a:hover,
#contact-page-overlay .mobile-nav a:hover,
#actors-page-overlay .mobile-nav a:hover, #actorsMobileNav a:hover {
  background: rgba(91,63,160,0.1) !important;
  color: #5b3fa0 !important;
}
.ab-mobile-nav a.active, .np-mobile-nav a.active, .bb-mobile-nav a.active, .cp-mobile-nav a.active,
#abMobileNav a.active, #npMobileNav a.active, #bbMobileNav a.active,
#contact-page-overlay .mobile-nav a.active,
#actors-page-overlay .mobile-nav a.active, #actorsMobileNav a.active {
  color: #5b3fa0 !important;
  background: rgba(91,63,160,0.08) !important;
}
.ab-burger, .np-burger, .bb-burger,
#about-page-overlay .burger, #contact-page-overlay .burger,
#bb-page-overlay .burger {
  flex-direction: column !important;
  gap: 5px !important;
  cursor: pointer !important;
  padding: 8px !important;
  border-radius: 10px !important;
  background: rgba(255,255,255,0.35) !important;
  border: 1px solid rgba(200,200,220,0.5) !important;
}
.ab-burger span, .np-burger span, .bb-burger span,
#about-page-overlay .burger span, #contact-page-overlay .burger span,
#bb-page-overlay .burger span {
  width: 22px !important;
  height: 2px !important;
  background: #3d3560 !important;
  border-radius: 2px !important;
  display: block !important;
}

@media (max-width: 768px) {

  /* ══ MOBILE: Kill ALL infinite GPU animations across ALL overlay pages ══
     Safari on iOS cannot handle concurrent GPU layers from multiple overlay pages.
     All pages are in DOM simultaneously. Kill everything not visible. */

  /* ── Main page background animations ── */
  .aurora-blob,
  .rec-orb,
  .logo-glow-ring,
  .logo-glow-ring2,
  .iphone-glow,
  .iphone-wrap {
    animation: none !important;
    will-change: auto !important;
    transform: none !important;
  }

  /* ── Actors page ── */
  .actors-page .aurora-blob {
    animation: none !important;
    will-change: auto !important;
    transform: none !important;
  }

  /* ── CRITICAL: actors-orb мають inline styles — перебиваємо через клас ── */
  /* filter:blur(70px) × 3 = ~200MB VRAM → OOM краш при зумі на iOS Safari */
  #actors-page-overlay .actors-orb {
    display: none !important;
  }

  /* ── CRITICAL: troupe-photo-bg — приховати розмитий фон-дублікат.
     filter:none зробив його видимим як звичайне фото (дублікат).
     Замість цього — ховаємо елемент, фон блоку (#000) залишається. ── */
  #actors-page-overlay .troupe-photo-bg {
    display: none !important;
  }

  /* ── CRITICAL: actor cards — прибрати GPU compositing layer з КОЖНОЇ картки ── */
  /* will-change:transform на 30–50 картках = десятки compositing layers → OOM ── */
  /* Важливо: НЕ чіпаємо transform — він потрібен для анімації появи карток ── */
  #actors-page-overlay .actor-card {
    will-change: auto !important;
  }

  /* ── About page: orbit rings, dots, timeline glow ── */
  #about-page-overlay .logo-orbit,
  #about-page-overlay .logo-orbit2,
  #about-page-overlay .logo-orbit3,
  #about-page-overlay .aurora-blob,
  #about-page-overlay .eyebrow-dot,
  #about-page-overlay .tl-dot {
    animation: none !important;
    will-change: auto !important;
    transform: none !important;
  }
  /* Keep tl-dot visible but static */
  #about-page-overlay .tl-dot {
    opacity: 1 !important;
  }

  /* ── Contact page: aurora blobs, particles ── */
  #contact-page-overlay .cp-ab,
  #contact-page-overlay .cp-particle,
  #contact-page-overlay .aurora-blob {
    animation: none !important;
    will-change: auto !important;
    transform: none !important;
  }

  /* ── BB page: any orbs ── */
  #bb-page-overlay .aurora-blob,
  #bb-page-overlay .rec-orb {
    animation: none !important;
    will-change: auto !important;
    transform: none !important;
  }

  /* ── Cards: shimmer animation (runs on every visible card) ── */
  .btn-details-light {
    animation: none !important;
    background: rgba(201,169,110,0.15) !important;
  }

  /* ── Actors: star twinkle (CSS-based) ── */
  #actors-page-overlay .star-twinkle,
  #actors-page-overlay [style*="starTwinkle"] {
    animation: none !important;
  }

  /* ── Header sticky, mobile-nav absolute ── */
  header {
    position: sticky !important;
  }
  .mobile-nav {
    position: absolute !important;
  }
  /* ── Overlay pages mobile-nav must be sticky (not absolute) ── */
  #contact-page-overlay .cp-mobile-nav,
  #about-page-overlay .ab-mobile-nav,
  #news-page-overlay .np-mobile-nav {
    position: sticky !important;
  }

  /* ── Kill blur filters on aurora/orb elements (GPU layer each) ── */
  .aurora-blob,
  .rec-orb,
  .logo-glow-ring,
  #about-page-overlay .logo-orbit,
  #contact-page-overlay .cp-ab {
    filter: none !important;
  }

  /* ── GSAP: prevent orb animations from being applied on mobile ── */
  #about-page-overlay .np-orb-1,
  #about-page-overlay .np-orb-2,
  #news-page-overlay .np-orb-1,
  #news-page-overlay .np-orb-2 {
    animation: none !important;
    transform: none !important;
    will-change: auto !important;
  }

  /* ── Actors page: particles, dots, title shimmer ── */
  .actors-page .hero-eyebrow-dot,
  .actors-page .particle,
  #actors-page-overlay .troupe-badge-dot {
    animation: none !important;
  }
  .actors-page .particle { display: none !important; }
  .actors-page .star { animation: none !important; opacity: 0.4 !important; }

  /* ── About page: all remaining infinite animations ── */
  #about-page-overlay .logo-orbit2,
  #about-page-overlay .logo-orbit3,
  #about-page-overlay .stage-glow {
    animation: none !important;
    will-change: auto !important;
  }
  #about-page-overlay .logo-orbit,
  #about-page-overlay .logo-orbit2,
  #about-page-overlay .logo-orbit3 {
    filter: none !important;
    opacity: 0 !important;
  }

  /* ── Contact page: all particles, dots, badge, pin ── */
  #contact-page-overlay .cp-particle,
  #contact-page-overlay .cp-eyebrow-dot,
  #contact-page-overlay .cp-hours-dot,
  #contact-page-overlay .cp-map-dot,
  #contact-page-overlay .cp-apple-pin-shadow,
  #contact-page-overlay .cp-map-overlay-badge {
    animation: none !important;
    will-change: auto !important;
  }
  #contact-page-overlay .cp-apple-pin-wrap { animation: none !important; }
  #contact-page-overlay .cp-particle { display: none !important; }

  /* ── News page: dots ── */
  #news-page-overlay .np-eyebrow-dot,
  #news-page-overlay .np-hbar-dot {
    animation: none !important;
  }

  /* ── BB page: dots ── */
  #bb-page-overlay .eyebrow-dot {
    animation: none !important;
  }

  /* ── Global: splash shimmer (runs during splash then element is hidden) ── */
  .splash-video-cell::before { animation: none !important; }

  /* ── Global: card shimmer ── */
  .shimmer::after { animation: none !important; }
  .section-loading-spin { animation: spinLoad 1.2s linear infinite; } /* keep but slow down */

  /* ── Remove all will-change globally on mobile (saves GPU memory) ── */
  * { will-change: auto !important; }
  /* Re-allow only for active scroll containers */
  #actors-page-overlay,
  #about-page-overlay,
  #contact-page-overlay,
  #news-page-overlay,
  #bb-page-overlay { will-change: auto !important; }

}
