/*
 * ─────────────────────────────────────────────────────────────
 *  COMPONENTS-MOBILE.CSS  —  web-starter-kit v2
 *  Comprehensive responsive overrides for all components.
 *  Breakpoints: 960px / 720px / 520px / 400px
 *
 *  Load order: AFTER components.css, motion.css, BEFORE client-theme.css
 * ─────────────────────────────────────────────────────────────
 */


/* ═══════════════════════════════════════════════════════════
 *  960px — TABLET LANDSCAPE / SMALL DESKTOP
 *  Multi-col grids drop to 2-col, hero scales down
 * ═══════════════════════════════════════════════════════════ */
@media (max-width: 960px) {

  /* ── Hero Full ── */
  .hero-full__heading {
    font-size: var(--step-5);
  }

  /* ── Hero Split ── */
  .hero-split {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .hero-split__image-col {
    aspect-ratio: 16 / 9;
    position: relative;
    height: auto;
    min-height: 280px;
  }

  .hero-split__image-col img {
    position: static;
    width: 100%;
    height: 100%;
    max-height: 420px;
  }

  .hero-split__content-col {
    padding: var(--space-3xl) var(--container-pad);
  }

  /* ── Feature grid: 3→2 ── */
  .features__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  /* Last feature item gets full width if 3 items */
  .features__grid .feature-item:last-child:nth-child(odd) {
    grid-column: 1 / -1;
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  .feature-item:nth-child(2) {
    border-right: none;
  }

  /* ── Card grid: 3→2 ── */
  .card-grid__grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .card-grid__grid--4col {
    grid-template-columns: repeat(2, 1fr);
  }

  .card--featured {
    grid-column: 1 / -1;
  }

  .card--featured .card__image-wrap {
    aspect-ratio: 16 / 7;
  }

  /* ── Gallery: 12-col→ responsive ── */
  .gallery__grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .gallery__item--feature {
    grid-column: span 6;
    grid-row: auto;
  }

  .gallery__item--tall,
  .gallery__item--wide {
    grid-column: span 3;
    grid-row: auto;
  }

  .gallery__item--small {
    grid-column: span 2;
  }

  .gallery__item--half {
    grid-column: span 3;
  }

  /* ── Story: 55/45 → 1col ── */
  .story__inner,
  .story--reversed .story__inner {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .story__image-col,
  .story--reversed .story__image-col {
    order: 1;
    position: relative;
    min-height: 320px;
    max-height: 480px;
  }

  .story__content-col,
  .story--reversed .story__content-col {
    order: 2;
    padding: var(--space-3xl) var(--container-pad);
  }

  /* ── Testimonials: 3→2 ── */
  .testimonials__row {
    grid-template-columns: repeat(2, 1fr);
  }

  /* With auto-fit minmax layout, cards wrap naturally — no forced span needed */

  /* ── Footer: 4→2 ── */
  .site-footer__grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--space-2xl);
  }

}


/* ═══════════════════════════════════════════════════════════
 *  720px — TABLET PORTRAIT
 *  Most grids to single column, hero type scales further
 * ═══════════════════════════════════════════════════════════ */
@media (max-width: 720px) {

  /* ── Hero Full ── */
  .hero-full__heading {
    font-size: var(--step-4);
    max-width: 20ch;
  }

  .hero-full__sub {
    font-size: var(--step-0);
  }

  .hero-full__actions {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-s);
  }

  .hero-full__actions .btn {
    width: 100%;
    justify-content: center;
  }

  .hero-full__scroll {
    display: none; /* hide scroll indicator at small sizes */
  }

  /* ── Hero Split ── */
  .hero-split__heading {
    font-size: var(--step-3);
  }

  /* ── Feature grid: 2→1 ── */
  .features__grid {
    grid-template-columns: 1fr;
  }

  .feature-item:not(:last-child) {
    border-right: none;
    border-bottom: 1px solid var(--rule);
  }

  .features__grid .feature-item:last-child:nth-child(odd) {
    grid-column: auto;
  }

  /* ── Card grid: any→1 ── */
  .card-grid__grid,
  .card-grid__grid--4col,
  .card-grid__grid--2col {
    grid-template-columns: 1fr;
  }

  .card--featured {
    grid-column: auto;
  }

  .card--featured .card__image-wrap {
    aspect-ratio: 4 / 3;
  }

  /* ── Gallery: compact 2-col ── */
  .gallery__grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-xs);
  }

  .gallery__item--feature,
  .gallery__item--tall,
  .gallery__item--wide,
  .gallery__item--small,
  .gallery__item--half {
    grid-column: span 1;
    grid-row: auto;
  }

  /* Feature stays full-width */
  .gallery__item--feature {
    grid-column: 1 / -1;
  }

  /* aspect-ratio on .gallery__item handles sizing */

  /* ── Testimonials: 2→1 ── */
  .testimonials__row {
    /* auto-fit minmax(280px,1fr) already handles single-col at narrow widths */
    max-width: 520px;
    margin-inline: auto;
  }



  /* ── Story image taller ── */
  .story__image-col {
    min-height: 260px;
    max-height: 360px;
  }

  /* ── CTA Band ── */
  .cta-band__heading {
    font-size: var(--step-3);
  }

  .cta-band__actions {
    flex-direction: column;
    align-items: center;
  }

  .cta-band__actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Footer: 2→1 ── */
  .site-footer__grid {
    grid-template-columns: 1fr;
    gap: var(--space-xl);
  }

  .site-footer__bottom {
    flex-direction: column;
    text-align: center;
    gap: var(--space-s);
  }

  .site-footer__legal {
    justify-content: center;
    flex-wrap: wrap;
  }

  /* ── Section header ── */
  .section-header__heading {
    font-size: var(--step-3);
  }

}


/* ═══════════════════════════════════════════════════════════
 *  520px — LARGE MOBILE
 *  Generous tap targets, comfortable single-column reading
 * ═══════════════════════════════════════════════════════════ */
@media (max-width: 520px) {

  /* ── Container padding increases at very small sizes ── */
  :root {
    --container-pad: clamp(1rem, 5vw, 1.5rem);
  }

  /* ── Hero Full ── */
  .hero-full__heading {
    font-size: var(--step-4);
  }

  .hero-full__content {
    padding-block-end: var(--space-3xl);
  }

  /* ── Hero Split ── */
  .hero-split__image-col {
    aspect-ratio: 4 / 3;
    max-height: 300px;
  }

  .hero-split__content-col {
    padding: var(--space-2xl) var(--container-pad);
  }

  .hero-split__heading {
    font-size: var(--step-3);
  }

  .hero-split__actions {
    flex-direction: column;
  }

  .hero-split__actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Card ── */
  .card__body {
    padding: var(--space-m);
  }

  .card__title {
    font-size: var(--step-1);
  }

  /* ── Testimonials ── */
  .testimonial-card {
    padding: var(--space-xl);
  }

  .testimonial-card__quote {
    font-size: var(--step-0);
  }

  /* ── Story ── */
  .story__heading {
    font-size: var(--step-3);
  }

  .story__stats {
    gap: var(--space-xl);
  }

  /* ── Gallery ── */
  .gallery__grid {
    grid-template-columns: 1fr;
  }

  .gallery__item--feature {
    grid-column: auto;
  }

  /* ── Footer newsletter ── */
  .site-footer__newsletter-form {
    flex-direction: column;
  }

  .site-footer__newsletter-form .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Buttons: generous tap target ── */
  .btn, .btn-outline {
    min-height: 48px;  /* WCAG 2.5.8 touch target */
  }

  /* ── Section header ── */
  .section-header__heading {
    font-size: var(--step-3);
    max-width: 20ch;
  }

  /* ── CTA Band ── */
  .cta-band {
    padding-block: var(--space-3xl);
  }

}


/* ═══════════════════════════════════════════════════════════
 *  400px — SMALL MOBILE (e.g. iPhone SE, Galaxy A series)
 *  Final adjustments: no horizontal overflow, type minimum
 * ═══════════════════════════════════════════════════════════ */
@media (max-width: 400px) {

  /* Hard clamp — prevent any horizontal overflow */
  body { overflow-x: hidden; }

  /* ── Hero ── */
  .hero-full__heading {
    font-size: var(--step-3);
  }

  .hero-full__sub {
    font-size: var(--step--1);
  }

  /* ── Buttons: full-width stacked ── */
  .hero-full__actions,
  .hero-split__actions,
  .cta-band__actions {
    flex-direction: column;
    width: 100%;
  }

  .hero-full__actions .btn,
  .hero-split__actions .btn,
  .cta-band__actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Nav logo smaller ── */
  .site-nav__logo {
    font-size: var(--step-1);
  }

  /* ── Story stats: wrap ── */
  .story__stats {
    flex-direction: column;
    gap: var(--space-l);
  }

  /* ── Footer social spaced out ── */
  .site-footer__social {
    gap: var(--space-l);
  }

  .site-footer__social a {
    width: 44px;
    height: 44px;
  }

  /* ── Section header ── */
  .section-header__heading {
    font-size: var(--step-2);
  }

  /* ── Mobile menu links — slightly smaller on tiny screens ── */
  .mobile-menu__link {
    font-size: var(--step-3);
  }

}


/* ═══════════════════════════════════════════════════════════
 *  PREVENT HORIZONTAL SCROLL GLOBALLY
 *  Any component that could cause horizontal scroll
 * ═══════════════════════════════════════════════════════════ */
.hero-full,
.hero-split,
.gallery,
.story,
.cta-band,
.site-footer {
  overflow-x: hidden;
}

/* Ensure images never cause horizontal scroll */
img {
  max-width: 100%;
  height: auto;
}
