/*
 * ─────────────────────────────────────────────────────────────
 *  COMPONENTS-MOBILE.CSS  —  web-starter-kit v2
 *  Comprehensive responsive overrides for all components.
 *  Breakpoints: 960px / 720px / 560px / 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 → 6-col; uniform aspect-ratio per cell ── */
  .gallery__grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .gallery__item--feature {
    grid-column: span 6;
    grid-row: auto;
    /* feature spans full width — keep wide aspect */
    aspect-ratio: 16 / 9;
  }

  .gallery__item--tall,
  .gallery__item--wide {
    grid-column: span 3;
    grid-row: auto;
    aspect-ratio: 4 / 3;   /* uniform cell height — no skyscraper tall items */
  }

  .gallery__item--small {
    grid-column: span 2;
    aspect-ratio: 4 / 3;
  }

  .gallery__item--half {
    grid-column: span 3;
    aspect-ratio: 4 / 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);
  }

  /* ── 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;
  }

  /* Keep subtitle comfortable — don't let it go below step-1 here */
  .hero-full__sub {
    font-size: var(--step-1);
    color: rgba(255,255,255,0.95);  /* strong contrast over darker overlay */
  }

  .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, all cells 4/3 ── */
  .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;
    aspect-ratio: 4 / 3;   /* uniform cells — no mixed heights */
  }

  /* Feature gets full width + wider aspect */
  .gallery__item--feature {
    grid-column: 1 / -1;
    aspect-ratio: 16 / 9;
  }

  /* ── Testimonials: force single column — no skyscraper cards ── */
  .testimonials__row {
    grid-template-columns: 1fr;
    max-width: 560px;
    margin-inline: auto;
  }

  .testimonial-card {
    height: auto;    /* content-driven height, no skyscraper */
    min-height: 0;
  }

  /* ── 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);
  }

}


/* ═══════════════════════════════════════════════════════════
 *  560px — MOBILE (review/testimonial card breakpoint)
 *  Force single-column full-width cards with balanced padding
 * ═══════════════════════════════════════════════════════════ */
@media (max-width: 560px) {

  /* ── Testimonials: single-column, full-width, height = content ── */
  .testimonials__row {
    grid-template-columns: 1fr;
    max-width: none;       /* allow full container width */
    padding-inline: 0;     /* container-pad applied by parent */
  }

  .testimonial-card {
    padding: var(--space-l) var(--space-l) var(--space-m);
    height: auto;          /* NO skyscraper — height fits content */
    min-height: 0;
  }

  /* Allow the full quote to show on mobile (no clamp cutoff) */
  .testimonial-card__quote {
    -webkit-line-clamp: unset;
    line-clamp: unset;
    overflow: visible;
    display: block;
    font-size: var(--step-0);
  }

}


/* ═══════════════════════════════════════════════════════════
 *  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);
  }

  /* Comfortable subtitle minimum — clearly legible over dark overlay */
  .hero-full__sub {
    font-size: var(--step-0);
    color: rgba(255,255,255,0.95);
  }

  .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);
  }

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

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

  /* ── Gallery: single column, all cells uniform 4/3 ── */
  .gallery__grid {
    grid-template-columns: 1fr;
    gap: var(--space-s);
  }

  .gallery__item--feature,
  .gallery__item--tall,
  .gallery__item--wide,
  .gallery__item--small,
  .gallery__item--half {
    grid-column: auto;
    aspect-ratio: 4 / 3;
  }

  /* ── 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);
  }

  /* Never go below step-0 — legibility is non-negotiable on small screens */
  .hero-full__sub {
    font-size: var(--step-0);
    color: rgba(255,255,255,0.95);
  }

  /* ── 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;
}

/* === MASONRY GALLERY responsive (appended override) === */
@media (max-width: 900px) { .gallery__grid { column-count: 2 !important; } }
@media (max-width: 560px) { .gallery__grid { column-count: 1 !important; } }
