/* ══════════════════════════════════════════════════════════════════════════
   ax-mobile.css — phone & small-tablet layout fixes (≤768px only).

   Loaded on every page by build-seo.js (injectExtras), after the site's own
   stylesheet. Desktop is untouched: every rule lives inside a max-width
   media query.

   Why so many !important / [style*=…] selectors: most of the desktop layout
   is written as inline style="…" attributes in the page markup, and inline
   styles beat normal stylesheet rules. assets/ax-site.css uses the same
   technique. Two elements (brand stats, product badges) carry !important in
   their inline style, which nothing can beat, so those are switched from
   grid to flex instead, which makes their column setting irrelevant.
   ══════════════════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {

  /* ── 1. Footer: 4 inline columns pushed "For Brands" off-screen on every
         page, making the whole site wider than the phone. ─────────────── */
  .footer-top {
    grid-template-columns: 1fr 1fr !important;
    gap: 28px 20px !important;
  }
  .footer-top > :first-child { grid-column: 1 / -1; }
  .footer-links a { display: inline-block; padding: 4px 0; }
  .footer-legal a { display: inline-block; padding: 6px 4px; }

  /* ── 2/3. Login & sign-up popups: one column, form at full width.
         The site's own rules use #regModal #loginForm / #regFields
         selectors with !important, so these match that specificity. ── */
  #regModal #loginForm .reg-account-grid,
  #regModal #regFields > .reg-account-grid,
  #regModal .reg-account-grid {
    grid-template-columns: 1fr !important;
    min-height: 0 !important;
  }
  #regModal .reg-picker-panel { padding: 22px 20px !important; }
  #regModal #regFields .po03-form-panel { padding: 20px 20px 24px !important; }
  /* Sign-up: keep the title and "Already have an account? Log in",
     drop the long marketing column that squeezed the form. */
  #regModal #regFields .reg-account-grid .reg-brand-panel { padding: 22px 20px 0 !important; }
  #regModal .reg-brand-panel .reg-brand-desc,
  #regModal .reg-brand-panel .reg-brand-sketch,
  #regModal .reg-brand-panel .reg-brand-divider,
  #regModal .reg-brand-panel .reg-features { display: none !important; }
  #regModal .reg-brand-panel .reg-brand-title { font-size: 26px !important; margin-bottom: 6px !important; }
  #regModal #regFields .reg-brand-panel .reg-picker-signin { margin-top: 0 !important; padding-top: 6px !important; }
  /* Password + confirm side by side were too narrow for the eye icon. */
  #regModal .po03-field-row-2:has(input[type="password"]) { grid-template-columns: 1fr !important; }
  /* Trust strip under the form: 2×2, compact. */
  #regModal .reg-trust-strip,
  #regModal #loginForm .reg-trust-strip {
    grid-template-columns: 1fr 1fr !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    padding: 4px 16px 12px !important;
  }
  #regModal .reg-trust-strip .reg-trust-item,
  #regModal #loginForm .reg-trust-strip .reg-trust-item { padding: 12px 8px 4px 0 !important; }
  /* LinkedIn / Google: two equal buttons across the full width. */
  .ax-social { width: 100% !important; }
  .ax-social > div:first-child,
  .ax-social [class*="row"] { width: 100% !important; }
  .ax-social button,
  .ax-social a { flex: 1 1 0 !important; min-width: 0 !important; min-height: 44px; }

  /* ── 4. Home hero: stats box below the text instead of squeezed beside it. */
  .hero { flex-direction: column !important; }
  .hero-content { width: 100% !important; box-sizing: border-box; }
  .hero-stats-row {
    position: relative !important;
    width: auto !important;
    max-width: none !important;
    margin: 0 20px 32px !important;
    grid-template-columns: 1fr 1fr !important;
    align-self: stretch;
  }
  .hero-stat-l { font-size: 10px !important; letter-spacing: .6px !important; }

  /* ── 5. Slider arrows: top-right corner, clear of the slide heading. ── */
  .slider-arrows {
    top: 14px !important;
    bottom: auto !important;
    height: auto !important;
    transform: none !important;
    justify-content: flex-end !important;
    gap: 8px;
    padding: 0 14px !important;
    pointer-events: none;
  }
  .slider-arrow { pointer-events: auto; }

  /* ── 6. "How ArchSpex works": one step per row. ────────────────────── */
  .how-grid { grid-template-columns: 1fr !important; }

  /* ── 7. "List your brand" banner: phone margins, nothing spills out. ─ */
  .cta-band {
    margin: 0 16px 40px !important;
    padding: 28px 20px !important;
    grid-template-columns: 1fr !important;
  }
  .cta-content, .cta-form { width: auto !important; min-width: 0 !important; }
  .cta-title { font-size: 24px !important; }
  .cta-stats { flex-wrap: wrap !important; gap: 16px 22px !important; }

  /* ── 8. Workspace section: phone padding, picture fits its column. ─── */
  .ws-cream { padding: 26px 18px !important; }
  .ws-benefits { padding: 24px 20px !important; }
  .ws-hero { grid-template-columns: 1fr !important; gap: 24px !important; }
  .ws-visual { width: 100% !important; min-height: 0 !important; }
  .ws-hero-img { min-height: 0 !important; height: auto !important; aspect-ratio: 4 / 3; border-radius: 14px; }
  /* The white fade that blends the picture into the text on desktop covered
     the whole picture on a phone, leaving an empty white block. */
  .ws-visual .ws-overlay { display: none !important; }

  /* ── 9. Pages with a filter sidebar (Brands, Projects, Professionals,
         Resources): stack it above the results, full width, not sticky. */
  [id^="page-"] > div:has(> .pg-sidebar) { flex-direction: column !important; }
  .pg-sidebar {
    width: 100% !important;
    flex-shrink: 1 !important;
    box-sizing: border-box;
    position: relative !important;
    top: auto !important;
    max-height: none !important;
    overflow: visible !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border) !important;
    /* Filter groups side by side: about half the height. */
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0 18px;
    align-items: start;
  }
  .pg-sidebar > :not(.filter-section) { grid-column: 1 / -1; }
  .pg-sidebar > .filter-divider { display: none; }
  .pg-sidebar > .filter-section { min-width: 0; margin-bottom: 18px; }
  [id^="page-"] div[style*="padding:28px 36px"] { padding: 20px 16px 40px !important; }

  /* ── 10. Brand page: stats wrap (3 per row), buttons full width. ───── */
  .bp3-stats {
    display: flex !important;
    flex-wrap: wrap !important;
    width: auto !important;
  }
  .bp3-stat { flex: 1 1 33.33% !important; min-width: 0 !important; box-sizing: border-box; }
  .bp3-stat-lbl { font-size: 10px !important; }
  .bp3-stat-val { font-size: 12px !important; }
  .bp3-cta {
    flex-direction: column !important;
    align-items: stretch !important;
    width: 100% !important;
  }
  .bp3-btn-primary, .bp3-btn-outline { width: 100% !important; justify-content: center; min-height: 44px; }
  .bp3-iconrow { justify-content: center !important; }
  .bp3-iconrow > * { min-height: 40px; }

  /* ── 11. Product page: badges wrap (3 per row), tabs scroll in place. */
  /* The product page injects "#page-product .pp-badges{display:grid…!important}"
     at runtime, so these selectors are deliberately more specific. */
  #page-product #ppBadges.pp-badges {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 8px !important;
  }
  #page-product #ppBadges .pp-badge { flex: 1 1 calc(33.33% - 8px) !important; min-width: 0 !important; }
  .pp-tabs-nav { overflow-x: auto !important; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .pp-tabs-nav > * { flex-shrink: 0 !important; white-space: nowrap; }

  /* ── 12. For Brands: phone-sized heading, one column, phone padding. ── */
  #page-forbrands h1 { font-size: 34px !important; line-height: 1.15 !important; }
  #page-forbrands h2[style*="font-size:36px"] { font-size: 28px !important; }
  #page-forbrands [style*="padding:72px 48px"] { padding: 48px 16px !important; }
  #page-forbrands [style*="grid-template-columns:1.35fr 1fr"],
  #page-forbrands [style*="grid-template-columns:repeat(2,1fr)"] {
    grid-template-columns: 1fr !important;
    gap: 20px !important;
  }
  #page-forbrands [style*="margin-left:-34px"] { margin-left: 0 !important; }
  #page-forbrands [style*="padding:36px"] { padding: 22px !important; }

  /* ── 12b. Category row (All Products · Structure · Envelope · …): on a
         phone only 4 of the 8 fitted and the rest needed a sideways swipe
         nobody would guess. Now a 4 × 2 grid, everything visible at once.
         It no longer sticks to the top while scrolling, since two rows would
         take too much of a phone screen. ─────────────────────────────────── */
  .cat-strip { position: relative !important; top: auto !important; }
  .cat-strip-inner {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 6px !important;
    padding: 8px 12px !important;
    overflow: visible !important;
    white-space: normal !important;
  }
  .cat-strip-inner > .cat-sep { display: none !important; }
  .cat-strip-inner > .cat-dropdown-wrap { min-width: 0; display: flex !important; }
  .cat-strip-inner .cat-pill {
    width: 100%;
    min-height: 38px;
    padding: 6px 4px !important;
    font-size: 11px !important;
    line-height: 1.2;
    white-space: normal !important;
    text-align: center;
    display: flex !important;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border) !important;
    border-radius: 8px;
    background: #fff;
  }
  .cat-strip-inner .cat-pill.active {
    background: var(--navy) !important;
    border-color: var(--navy) !important;
    color: #fff !important;
  }
  .cat-strip-inner .cat-pill-directory .pd-pill-ic { display: none !important; }

  /* ── 13. Side menu never wider than the screen (✕ stays visible). ──── */
  .side-menu { width: min(300px, 100vw) !important; max-width: 100vw; }

  /* ── 14. Readability & tap targets. ────────────────────────────────── */
  .side-section-label,
  .filter-section-title,
  .ad-tag,
  .sort-label-mini,
  .hero-pill-text { font-size: 10px !important; }
  .sort-dd-cur, .ad-btn { font-size: 11px !important; }
  .sort-dd-btn { min-height: 36px; }
  .pg-sidebar button { min-height: 32px; }
  .prod-card .btn-sm-navy,
  .prod-card .btn-sm-outline,
  .prod-card button,
  [class*="brand-card"] button,
  [class*="brand-card"] a[class*="btn"] { min-height: 40px !important; }
}
