/**
 * Mobile layout — match muthnabi.ibnameer.com
 * Hero: text → controls → card stack in one viewport-height band.
 * Loads after home-snappy / home-hero so overrides win on extract.
 */

html {
  scroll-behavior: auto !important;
  -webkit-overflow-scrolling: touch;
}

body {
  overscroll-behavior-y: auto;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  /* Keep hero card fly-out even when OS "reduce motion" is on */
  html body.page-home #home-hero-slider .hero-stack-card.is-flying-next,
  html body.page-home #home-hero-slider .hero-stack-card.is-flying-prev,
  html body.page-home #home-hero-slider .hero-stack-card.is-front.is-flying-next,
  html body.page-home #home-hero-slider .hero-stack-card.is-front.is-flying-prev {
    transition: transform 0.35s ease, opacity 0.28s ease !important;
  }
}

/* --- Hero: ibnameer mobile column (never image-first grid) --- */
@media (max-width: 899px) {
  html body.page-home #home-hero-slider {
    height: calc(100svh - var(--header-h, 70px)) !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow: hidden !important;
    padding: 0.75rem 0 !important;
    align-items: center !important;
  }

  html body.page-home #home-hero-slider .hero-slider-inner,
  html body.page-home #home-hero-slider .container.hero-slider-inner {
    display: flex !important;
    flex-direction: column !important;
    grid-template-areas: none !important;
    grid-template-columns: none !important;
    align-items: stretch !important;
    height: 100% !important;
    width: 100% !important;
    max-width: 1280px !important;
    gap: 0.75rem !important;
    padding-inline: clamp(1rem, 4vw, 1.25rem) !important;
    min-height: 0 !important;
  }

  html body.page-home #home-hero-slider .hero-text-rail {
    flex: 0 0 auto !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    order: 1 !important;
  }

  html body.page-home #home-hero-slider .hero-visual {
    flex: 1 1 auto !important;
    min-height: 8rem !important;
    min-width: 0 !important;
    order: 2 !important;
    display: flex !important;
    overflow: visible !important;
    position: relative !important;
  }

  html body.page-home #home-hero-slider .hero-slide {
    display: none !important;
  }

  html body.page-home #home-hero-slider .hero-slide.active {
    display: block !important;
    position: relative !important;
    inset: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    pointer-events: auto !important;
  }

  html body.page-home #home-hero-slider .hero-content,
  html body.page-home #home-hero-slider .hero-lede,
  html body.page-home #home-hero-slider .hero-follow {
    display: block !important;
    max-width: none !important;
  }

  html body.page-home #home-hero-slider .hero-content p {
    display: -webkit-box !important;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-width: none !important;
  }

  html body.page-home #home-hero-slider .hero-button {
    width: auto !important;
    min-width: 0 !important;
  }

  html body.page-home #home-hero-slider .slider-controls {
    position: static !important;
    left: auto !important;
    right: auto !important;
    bottom: auto !important;
    transform: none !important;
    justify-content: flex-start !important;
    margin-top: 0.45rem !important;
    gap: 0.6rem !important;
  }

  html body.page-home #home-hero-slider .slider-button {
    width: 30px !important;
    height: 30px !important;
    min-width: 30px !important;
    font-size: 0.8rem !important;
  }

  html body.page-home #home-hero-slider .slide-number {
    font-size: 0.7rem !important;
  }

  html body.page-home #home-hero-slider .hero-card-stack {
    flex: 1 1 auto !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    max-height: none !important;
    aspect-ratio: auto !important;
  }

  html body.page-home #home-hero-slider .hero-stack-card {
    width: min(300px, 82vw) !important;
  }
}

/* Kill legacy home-hero.css grid reorder on tablet */
@media (min-width: 900px) and (max-width: 1199px) {
  html body.page-home #home-hero-slider .hero-slider-inner,
  html body.page-home #home-hero-slider .container.hero-slider-inner {
    display: flex !important;
    flex-direction: row !important;
    grid-template-areas: none !important;
    grid-template-columns: none !important;
    width: min(100% - 2rem, 1280px) !important;
    padding-inline: clamp(1rem, 3vw, 1.5rem) !important;
  }

  html body.page-home #home-hero-slider .hero-slide.active,
  html body.page-home #home-hero-slider .hero-content,
  html body.page-home #home-hero-slider .hero-text-rail {
    display: flex !important;
    flex-direction: column !important;
  }

  html body.page-home #home-hero-slider .hero-slide.active {
    display: block !important;
  }
}

/* Age card: stacked full-width whenever the window is tablet/phone size */
@media (max-width: 1024px) {
  html body.page-home #home-life-journey .life-page,
  html body.page-home #home-life-journey .container.life-page {
    width: min(100% - 2rem, var(--container, 1160px)) !important;
    max-width: var(--container, 1160px) !important;
    margin-inline: auto !important;
    padding-inline: clamp(1rem, 4vw, 1.25rem) !important;
    box-sizing: border-box !important;
  }

  html body.page-home #home-life-journey .story-card {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto !important;
    width: 100% !important;
    min-height: 0 !important;
    border-radius: 18px;
  }

  html body.page-home #home-life-journey .image-side,
  html body.page-home #home-life-journey .text-side {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  html body.page-home #home-life-journey .image-side {
    min-height: 0 !important;
    aspect-ratio: 16 / 10;
  }

  html body.page-home #home-life-journey .image-side img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  html body.page-home #home-life-journey .text-side {
    padding: 1.05rem 1.15rem 1.2rem !important;
    box-sizing: border-box !important;
  }
}

/* --- Homepage sections: ibnameer padding + topics grid --- */
@media (max-width: 899px) {
  body.page-home .container {
    width: min(100% - 2rem, var(--container, 1160px));
    margin-inline: auto;
    padding-inline: clamp(1rem, 4vw, 1.25rem);
    box-sizing: border-box;
  }

  body.page-home .home-band {
    padding: 1.75rem 0;
  }

  body.page-home .home-band-topics {
    padding: 1.75rem 0 1.5rem;
  }

  body.page-home .home-band-soft,
  body.page-home .home-band-path {
    padding: 1.5rem 0;
  }

  body.page-home #home-life-journey,
  body.page-home .prophet-stories {
    padding-block: 1.5rem !important;
  }

  body.page-home .section-head,
  body.page-home .section-head-center {
    margin-bottom: 1.35rem;
    padding-inline: 0.15rem;
    box-sizing: border-box;
  }

  body.page-home .home-band-topics .section-head-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    width: 100%;
    max-width: 100%;
    padding-inline: 0.25rem;
  }

  body.page-home .home-band-topics .section-head-center h2,
  body.page-home .home-band-topics .section-head-center p,
  body.page-home .home-band-topics .section-eyebrow {
    max-width: none !important;
    width: 100%;
    box-sizing: border-box;
    padding-inline: 0.35rem;
  }

  body.page-home .topics-mosaic {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem;
  }

  body.page-home .topics-mosaic .home-ref-card {
    border-radius: 18px;
  }

  body.page-home .topics-mosaic .home-ref-card-body {
    padding: 0.55rem 0.65rem 0.6rem;
  }

  body.page-home .topics-mosaic .home-ref-card-title {
    font-size: 0.82rem;
    line-height: 1.25;
  }

  body.page-home .preview-grid,
  body.page-home .card-grid,
  body.page-home .library-teaser-grid,
  body.page-home .home-articles-grid {
    gap: 0.85rem;
  }

  body.page-home .home-band-cta .cta-panel {
    padding: clamp(1.15rem, 4vw, 1.5rem) !important;
    border-radius: 22px !important;
  }

  body.page-home #home-life-journey .page-heading {
    margin-bottom: 1rem;
  }

  body.page-home #home-life-journey .story-card {
    display: grid !important;
    grid-template-columns: 1fr !important;
    grid-template-rows: auto auto !important;
    width: 100% !important;
    min-height: 0 !important;
    border-radius: 18px;
  }

  body.page-home #home-life-journey .image-side,
  body.page-home #home-life-journey .text-side {
    grid-column: 1 / -1 !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
  }

  body.page-home #home-life-journey .image-side {
    min-height: 0 !important;
    aspect-ratio: 16 / 10;
  }

  body.page-home #home-life-journey .image-side img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  body.page-home #home-life-journey .text-side {
    padding: 1.05rem 1.15rem 1.2rem !important;
    box-sizing: border-box !important;
  }

  body.page-home #home-life-journey .text-side h2 {
    margin-top: 0.65rem;
    font-size: clamp(1.05rem, 4.5vw, 1.35rem);
    line-height: 1.3;
  }

  body.page-home #home-life-journey .text-side p {
    margin-top: 0.65rem;
    font-size: 0.92rem;
    line-height: 1.65;
  }

  body.page-home #home-life-journey .read-button {
    margin-top: 0.85rem;
    padding: 0.65rem 0.95rem;
    font-size: 0.88rem;
    border-radius: 12px;
  }

  body.page-home #home-life-journey .image-age {
    left: 1rem;
    bottom: 1rem;
    font-size: 2rem;
  }

  body.page-home #home-life-journey .image-age span {
    font-size: 0.65rem;
  }

  body.page-home #home-life-journey .life-slider-controls {
    margin-top: 0.85rem;
    gap: 0.6rem;
  }

  body.page-home #home-life-journey .arrow-button {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 0.8rem;
  }

  body.page-home #home-life-journey .progress-line {
    height: 3px;
  }

  body.page-home #home-life-journey .age-navigation {
    margin-top: 0.75rem;
    gap: 0.45rem;
    padding: 0.15rem 0 0.35rem;
  }

  body.page-home #home-life-journey .age-button {
    flex: 0 0 2.15rem;
    height: 2rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 700;
  }

  body.page-home #home-life-journey .bottom-note {
    margin-top: 0.65rem;
    font-size: 0.82rem;
    line-height: 1.5;
  }

  body.page-home .hadith-slider-stage {
    padding-inline: clamp(2.25rem, 10vw, 3rem);
  }

  body.page-home .quote-block-soft {
    padding: 1.5rem 1.15rem;
  }

  /* Hadith: one image card on mobile; quote card stays in DOM for desktop */
  html body.page-home #home-prophet-stories .section-label,
  html body.page-home #home-prophet-stories .story-content > h2,
  html body.page-home #home-prophet-stories .quote-card {
    display: none !important;
  }

  html body.page-home #home-prophet-stories .story-container {
    display: grid !important;
    grid-template-columns: 1fr !important;
    gap: 0.85rem !important;
  }

  html body.page-home #home-prophet-stories .image-column {
    max-width: none !important;
    width: 100% !important;
    justify-self: stretch !important;
    padding-bottom: 0 !important;
    order: -1;
  }

  html body.page-home #home-prophet-stories .image-card {
    height: min(26rem, 62vw) !important;
    border-radius: 22px !important;
  }

  html body.page-home #home-prophet-stories .image-information,
  html body.page-home #home-prophet-stories .image-badge {
    display: none !important;
  }

  html body.page-home #home-prophet-stories .image-quote {
    display: block !important;
    top: auto !important;
    bottom: 1.2rem !important;
    left: 1.1rem !important;
    right: 1.1rem !important;
    font-size: clamp(1.05rem, 4.6vw, 1.35rem) !important;
    line-height: 1.4 !important;
  }

  html body.page-home #home-prophet-stories .progress-dots {
    flex-wrap: wrap;
    overflow-x: auto;
    max-width: 100%;
  }
}

@media (max-width: 380px) {
  body.page-home .topics-mosaic {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* --- Article page mobile --- */
@media (max-width: 899px) {
  body.article-editorial .article-ed-header {
    padding: 1.75rem clamp(1rem, 4vw, 1.25rem) 1.35rem;
  }

  body.article-editorial .article-ed-header h1 {
    font-size: clamp(1.75rem, 7.5vw, 2.35rem);
    line-height: 1.28;
  }

  body.article-editorial .article-page--editorial .article-body {
    padding-inline: clamp(1rem, 4.5vw, 1.25rem);
    line-height: 1.82;
  }

  body.article-editorial .article-page--editorial .article-body h2 {
    font-size: clamp(1.25rem, 5vw, 1.55rem);
    margin-top: 2rem;
    padding-inline-start: 0.85rem;
  }

  body.article-editorial .article-ed-nav,
  body.article-editorial .article-page--editorial .article-comments {
    padding-inline: clamp(1rem, 4vw, 1.25rem);
  }
}
