/* ============================================================
   Laptop / desktop visibility failsafe
   Fixes blank content (AOS opacity-0), header hide gaps (769–992px),
   and ensures main UI is always readable on laptop viewports.
   Loads LAST after all theme skins.
   ============================================================ */

/* ---------- 1) Never leave content invisible (AOS / reveal) ---------- */
html:not(.aos-ready) [data-aos],
html.aos-failed [data-aos],
body.ipa-force-visible [data-aos],
body.ipa-force-visible .prompt-card,
body.ipa-force-visible .blog-card {
  opacity: 1 !important;
  transform: none !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

/* After AOS boots, still unstick any orphaned nodes that never animated */
[data-aos].aos-animate,
.prompt-card.aos-animate,
.blog-card.aos-animate {
  opacity: 1 !important;
  visibility: visible !important;
}

/* Hard guarantee for primary page regions */
#main-content,
main.site-main,
main#main-content,
.hero,
.ipa-hero,
.masonry-grid,
.ipa-prompt-grid,
.blog-grid,
.container,
.prompt-card,
.blog-card,
.category-slider-section,
.ipa-toolbar {
  visibility: visible !important;
  opacity: 1 !important;
}

/* Cards may animate in — only force visibility if stuck (no aos-animate after load) */
html.aos-ready .prompt-card[data-aos]:not(.aos-animate),
html.aos-ready .blog-card[data-aos]:not(.aos-animate) {
  /* safety after paint: still show if observer never fired */
  animation: ipa-fade-in 0.01s linear 1.2s forwards;
}

@keyframes ipa-fade-in {
  to {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Prefer always-readable cards on laptop (animation is progressive) */
@media (min-width: 768px) {
  #main-content [data-aos],
  .prompt-card[data-aos],
  .hero [data-aos],
  .ipa-hero [data-aos],
  .premium-pill[data-aos],
  .category-slider-section[data-aos],
  .ipa-toolbar[data-aos],
  .micro-section[data-aos],
  .ipa-micro-section[data-aos],
  .blog-card[data-aos],
  .apex-feature-strip[data-aos],
  .neu-feature-strip[data-aos],
  .au-bento-card,
  .au-stat-card,
  .au-quote,
  .au-price-card {
    opacity: 1 !important;
    transform: none !important;
    visibility: visible !important;
  }
}

/* ---------- 2) Header: show desktop chrome on ALL laptop widths ---------- */
/* Breakpoint gap used to hide both mobile + advanced between ~769–992 in some layers */
@media (min-width: 768px) {
  .advanced-header,
  #ipaAdvancedHeader,
  body .advanced-header {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
    pointer-events: none !important; /* container only; children re-enable */
    z-index: 1000 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
  }

  .advanced-header .ah-container,
  .advanced-header .ah-brand,
  .advanced-header .ah-nav,
  .advanced-header .ah-actions {
    pointer-events: auto !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  .mobile-header-modern,
  .mobile-header,
  #ipaMobileHeader,
  .mobile-bottom-nav {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* Room under fixed desktop header — body never double-pads */
  body,
  body.ipa-neu,
  body.ipa-aurora,
  body.ipa-premium-light,
  body.ipa-apex,
  body.ipa-nebula {
    padding-top: 0 !important;
  }

  /* Clear floating header with comfortable gap under bar */
  #main-content,
  main#main-content,
  main.site-main,
  main.ipa-gallery-hero {
    padding-top: 112px !important;
    min-height: 40vh !important;
    position: relative !important;
    z-index: 2 !important;
  }

  /* Single / breadcrumb: same offset so nothing slides under the header */
  main.ipa-single-prompt,
  main.container.ipa-single-prompt,
  main#main-content.ipa-single-prompt,
  .ipa-single-prompt {
    padding-top: 112px !important;
  }

  .ipa-single-prompt .breadcrumb,
  main.ipa-single-prompt .breadcrumb {
    margin-top: 0 !important;
    position: relative !important;
    z-index: 1 !important;
  }

  /* Category slider / filter strip stays below header */
  .category-slider-section,
  .ipa-category-slider,
  .category-slider-wrapper {
    position: relative !important;
    z-index: 1 !important;
    margin-top: 0 !important;
  }

  /* Hero: no extra top air — main already clears the header */
  .hero.ipa-hero,
  .ipa-hero,
  section.hero,
  .au-hero,
  .blog-hero {
    padding-top: 8px !important;
    padding-bottom: 28px !important;
    margin-top: 0 !important;
    opacity: 1 !important;
    visibility: visible !important;
  }

  .stats-wrapper {
    margin-top: 0 !important;
    margin-bottom: 14px !important;
  }
}

/* Phone only — keep mobile chrome; tight gap under floating header */
@media (max-width: 767px) {
  .advanced-header,
  #ipaAdvancedHeader {
    display: none !important;
  }

  .mobile-header-modern,
  .mobile-header,
  #ipaMobileHeader {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  body,
  body.ipa-neu,
  body.ipa-premium-light {
    padding-top: 0 !important;
  }

  body.admin-bar {
    padding-top: 46px !important;
  }

  #main-content,
  main#main-content,
  main.site-main,
  main.ipa-gallery-hero,
  main.ipa-single-prompt,
  main.container.ipa-single-prompt,
  .ipa-single-prompt {
    padding-top: calc(84px + env(safe-area-inset-top, 0px)) !important;
  }

  .hero.ipa-hero,
  .ipa-hero,
  section.hero,
  .blog-hero {
    padding-top: 10px !important;
    margin-top: 0 !important;
  }

  .ipa-single-prompt .breadcrumb,
  main.ipa-single-prompt .breadcrumb {
    margin-top: 4px !important;
    margin-bottom: 12px !important;
  }
}

/* ---------- 3) Readable text (prevent dark-on-dark / light-on-light) ---------- */
/* Soft UI light skins */
body.ipa-neu .card-title,
body.ipa-neu .ipa-brand-name,
body.ipa-neu h1,
body.ipa-neu h2,
body.ipa-neu h3 {
  color: #1E1B2E !important;
  opacity: 1 !important;
}

body.ipa-neu .hero-subtitle,
body.ipa-neu .prompt-text,
body.ipa-neu .card-meta {
  color: #6B6480 !important;
  opacity: 1 !important;
  -webkit-text-fill-color: unset !important;
}

/* Aurora dark skin */
body.ipa-aurora .hero-title,
body.ipa-aurora .card-title,
body.ipa-aurora h1,
body.ipa-aurora h2,
body.ipa-aurora .ipa-brand-name {
  color: #F8FAFC !important;
  -webkit-text-fill-color: unset !important;
  opacity: 1 !important;
}

body.ipa-aurora .ipa-brand-name,
body.ipa-aurora .ah-brand .ipa-brand-name {
  color: #F8FAFC !important;
}

/* Gradient text must not vanish if clip fails */
.cm-grad-text,
.neu-accent-text,
.au-grad-text,
.fx-grad-text {
  opacity: 1 !important;
  visibility: visible !important;
}

/* ---------- 4) Grid never collapses to zero columns on laptop ---------- */
@media (min-width: 768px) and (max-width: 1200px) {
  .masonry-grid,
  .ipa-prompt-grid,
  body.ipa-layout-grid2 .masonry-grid,
  body.ipa-layout-grid3 .masonry-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)) !important;
    gap: 18px !important;
    opacity: 1 !important;
    visibility: visible !important;
    min-height: 120px !important;
  }
}

@media (min-width: 1201px) {
  .masonry-grid,
  .ipa-prompt-grid {
    display: grid !important;
    visibility: visible !important;
    opacity: 1 !important;
  }
}

/* ---------- 5) Kill full-viewport blockers ---------- */
.au-aurora-layer,
.ipa-mesh-stage,
.hero-bg-shapes {
  pointer-events: none !important;
}

/* Overlays must not cover the page when closed */
.menu-overlay-popup[hidden],
.ipa-cmd-overlay[hidden],
.ipa-fav-overlay[hidden],
.custom-sort-modal[hidden],
#ipaSortBackdrop[style*="display:none"] {
  display: none !important;
  pointer-events: none !important;
}

/* ---------- 6) Thumbnails: show FULL image (no crop) — Image 1 & 2 ---------- */
.blog-card-visual,
.ipa-gallery-hero .blog-card-visual,
.more-blog-card .blog-card-visual,
.more-posts-wrapper .blog-card-visual {
  height: auto !important;
  max-height: none !important;
  aspect-ratio: auto !important;
  overflow: hidden !important;
  background: #EEF2F7 !important;
}

.blog-card-visual a,
.ipa-gallery-hero .blog-card-visual a,
.more-blog-card .blog-card-visual a {
  display: block !important;
  width: 100% !important;
  line-height: 0 !important;
}

.blog-card-visual img,
.blog-card-visual a img,
.ipa-gallery-hero .blog-card-visual img,
.ipa-gallery-hero .blog-card-visual a img,
.more-blog-card .blog-card-visual img,
.more-posts-wrapper .blog-card-visual img,
.blog-card img {
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  object-fit: contain !important;
  object-position: center top !important;
  display: block !important;
}

/* Soft hover scale without cropping (use transform only) */
@media (hover: hover) and (pointer: fine) {
  .blog-card:hover .blog-card-visual img,
  .blog-card:hover .blog-card-visual a img,
  .more-blog-card:hover .blog-card-visual img {
    transform: scale(1.03) !important;
  }
}

/* ---------- 7) Gallery / blog card design polish — Image 2 ---------- */
.blog-card,
.ipa-gallery-hero .blog-card,
.more-blog-card {
  display: flex !important;
  flex-direction: column !important;
  overflow: hidden !important;
  border-radius: 20px !important;
  background: #fff !important;
}

.blog-card-content {
  flex: 1 1 auto !important;
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  padding: 18px 18px 16px !important;
}

.blog-meta-info {
  display: flex !important;
  flex-wrap: wrap !important;
  align-items: center !important;
  gap: 8px 12px !important;
  font-size: 12px !important;
  color: #64748B !important;
}

.blog-card-title {
  display: -webkit-box !important;
  -webkit-line-clamp: 2 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  line-height: 1.35 !important;
}

.blog-card-excerpt {
  display: -webkit-box !important;
  -webkit-line-clamp: 3 !important;
  -webkit-box-orient: vertical !important;
  overflow: hidden !important;
  color: #64748B !important;
  font-size: 13.5px !important;
  line-height: 1.55 !important;
  margin: 0 !important;
}

.blog-card-footer {
  margin-top: auto !important;
  padding-top: 14px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 10px !important;
}

/* Explore More grid cards */
.more-posts-wrapper .blog-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)) !important;
  gap: 24px !important;
}

.more-blog-card .blog-card-visual {
  margin: 0 !important;
  border-radius: 20px 20px 0 0 !important;
  box-shadow: none !important;
}

/* ---------- 8) Premium pill icon always visible — Image 5 ---------- */
.premium-pill .pp-icon,
.pp-icon {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  border-radius: 50% !important;
  background: linear-gradient(145deg, #7BA3C9, #5B8AB8) !important;
  color: #fff !important;
  flex-shrink: 0 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.premium-pill .pp-icon i,
.pp-icon i,
.pp-icon .fa-solid,
.pp-icon .fas {
  color: #fff !important;
  font-size: 14px !important;
  line-height: 1 !important;
  display: inline-block !important;
  opacity: 1 !important;
  visibility: visible !important;
  -webkit-text-fill-color: #fff !important;
}
