/* ==============================================
   Foundry Labs Responsive Overhaul — WU-1 Global
   Global responsive patches only
   ============================================== */

/* G-01: Safe-area padding for mobile nav and drawer — only at ≤768px */
@media (max-width: 768px) {
  .site-nav,
  nav[aria-label="Main navigation"] {
    padding-top: max(var(--space-3), env(safe-area-inset-top));
    padding-right: max(var(--page-gutter), env(safe-area-inset-right));
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
    padding-left: max(var(--page-gutter), env(safe-area-inset-left));
    height: auto;
    min-height: calc(var(--nav-height) + env(safe-area-inset-top) + env(safe-area-inset-bottom));
  }

  .nav-drawer {
    padding-top: max(var(--space-5), env(safe-area-inset-top));
    padding-right: max(var(--space-5), env(safe-area-inset-right));
    padding-bottom: max(var(--space-5), env(safe-area-inset-bottom));
    padding-left: max(var(--space-5), env(safe-area-inset-left));
  }
}

/* G-05: Prevent chip and tag rows from overflowing on mobile */
@media (max-width: 768px) {
  .tag-row,
  .chip-row,
  .filter-tags,
  .exp-card-tags {
    flex-wrap: wrap;
  }
}

@media (max-width: 768px) {
  /* G-02: Morph hamburger into close icon when drawer is open */
  .nav-hamburger > span {
    transition: transform 0.24s ease, opacity 0.2s ease;
    transform-origin: center;
  }

  body.nav-open .nav-hamburger > span:nth-child(1),
  body.nav-drawer-open .nav-hamburger > span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  body.nav-open .nav-hamburger > span:nth-child(2),
  body.nav-drawer-open .nav-hamburger > span:nth-child(2) {
    opacity: 0;
  }

  body.nav-open .nav-hamburger > span:nth-child(3),
  body.nav-drawer-open .nav-hamburger > span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  /* G-03: Ensure mobile button targets meet 44px minimum */
  .btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* G-08: Reduce section spacing globally on mobile — sections should
     feel tighter so users can glimpse next/prev content */
  .hero {
    min-height: clamp(420px, 60vh, 560px);
    padding-bottom: var(--space-7);
  }

  .carousel-section,
  .frontier-section,
  .bento-section {
    padding-block: var(--space-7);
  }

  .page-header {
    padding-top: calc(var(--nav-height) + var(--space-7));
    padding-bottom: var(--space-7);
  }

  .innovations-layout {
    padding-bottom: var(--space-7);
    gap: var(--space-5);
  }

  /* G-09: Body uses fluid --text-base (clamp 14→16px). No mobile body-size
     override needed — the token system handles viewport scaling. */

  /* G-10: Tighten h2 section headings */
  h2 {
    margin-bottom: var(--space-4);
  }

  /* G-11: Hero & sectional hero text — center-aligned with 32px inline padding */
  .hero,
  .hero-content,
  .page-header,
  .page-header-inner,
  .about-hero,
  .community-hero,
  .stories-hero,
  .bio-hero {
    text-align: center;
    padding-inline: 32px;
  }

  .hero h1,
  .page-header h1,
  .about-hero h1,
  .community-hero h1,
  .stories-hero h1,
  .bio-hero h1,
  .bio-hero-title {
    text-align: center;
    /* Match design's mobile hero token override (cap 52px, not 38px). */
    font-size: clamp(36px, 10vw, 52px);
    line-height: 1.05;
  }

  .hero-sub,
  .page-header .hero-sub,
  .about-hero .hero-sub,
  .community-hero .hero-sub,
  .bio-hero-desc {
    text-align: center;
    /* Hero-sub inherits fluid --text-xl (clamp 18→24px); no font-size
       override here — only centering + auto inline margin behavior. */
    margin-inline: auto;
  }

  .hero-actions,
  .community-hero-actions {
    justify-content: center;
    flex-wrap: wrap;
  }
}

@media (max-width: 480px) {
  /* G-04: Redesign footer as single-column flat list on mobile */
  footer {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .footer-brand,
  .footer-col,
  .footer-bottom {
    grid-column: 1 / -1;
  }

  .footer-brand {
    margin-bottom: var(--space-5);
  }

  /* Column headers — distinct via weight and brighter shade only */
  .footer-col h5 {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: capitalize;
    color: rgba(255,255,255,0.95);
    padding: 0 0 8px 0;
    margin: 0 0 4px 0;
  }

  /* Links appear as flat list under header */
  .footer-col a {
    display: block;
    padding: 8px 0;
    margin: 0;
    font-size: 14px;
    color: rgba(255,255,255,0.60);
    border-bottom: none;
    min-height: 36px;
    line-height: 20px;
  }

  .footer-col a:last-child {
    border-bottom: none;
    margin-bottom: var(--space-5);
  }

  .footer-col a:hover {
    color: var(--text-2);
    background: rgba(255,255,255,0.03);
  }

  .footer-bottom {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
    margin-top: var(--space-4);
  }

  .footer-bottom a {
    display: inline-flex;
    padding-block: 6px;
  }

  /* G-07: Scale large text tokens down for small screens */
  :root {
    --text-hero: clamp(36px, 10vw, 52px);
    --text-4xl: clamp(32px, 8vw, 40px);
    --text-3xl: clamp(28px, 6vw, 36px);
    --text-2xl: clamp(24px, 5vw, 28px);
  }
}

@media (max-width: 360px) {
  /* G-06: Page gutter holds at the global 20px floor (set in style.css :root
     mobile cascades). Previous 16px override was creating an inconsistent
     "tighter at the bottom" feel — user wants 20px uniformly across mobile. */
  :root {
    --page-gutter: 20px;
  }
}
