/*
 * BiohackDir — Global Mobile Stylesheet
 * File: wp-content/themes/biohackdir/assets/css/mobile.css
 * Enqueued via functions.php — applies to every page.
 *
 * Structure:
 *  1. Hamburger button + mobile nav drawer
 *  2. Bottom tab bar (phones only)
 *  3. Core typography and spacing
 *  4. Touch targets and iOS fixes
 *  5. Grids and layout collapses
 *  6. Component-specific overrides
 *  7. Safe area insets (iPhone notch / Dynamic Island)
 */

/* ══════════════════════════════════════════════════════
   1. HAMBURGER BUTTON + MOBILE NAV DRAWER
   ══════════════════════════════════════════════════════ */

/* The hamburger button is injected into .bd-nav-inner
   via wp_footer JavaScript — hidden on desktop */
.bd-hamburger {
  display: none;
  flex-shrink: 0;
}

.bd-hamburger button {
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid var(--line-2, #2A323D);
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  padding: 0;
  transition: border-color 0.15s;
}

.bd-hamburger button:hover {
  border-color: var(--teal-line, rgba(29,158,117,0.35));
}

.bd-hamburger button span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--ink-2, #A8B0BA);
  border-radius: 2px;
  transition: all 0.2s ease;
  transform-origin: center;
}

/* Animate to X when open */
.bd-hamburger.open button span:nth-child(1) {
  transform: translateY(6.5px) rotate(45deg);
}
.bd-hamburger.open button span:nth-child(2) {
  opacity: 0;
  transform: scaleX(0);
}
.bd-hamburger.open button span:nth-child(3) {
  transform: translateY(-6.5px) rotate(-45deg);
}

/* Mobile nav drawer — slides down from nav */
.bd-mobile-nav {
  display: none;
  position: fixed;
  top: 72px; /* height of sticky nav */
  left: 0;
  right: 0;
  z-index: 99;
  background: rgba(11, 14, 18, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line, #1E242E);
  padding: 8px 20px 16px;
  transform: translateY(-8px);
  opacity: 0;
  transition: opacity 0.18s ease, transform 0.18s ease;
  pointer-events: none;
}

.bd-mobile-nav.open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

.bd-mobile-nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line, #1E242E);
}

.bd-mobile-nav-links a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  color: var(--ink-2, #A8B0BA);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  border-radius: 10px;
  transition: all 0.15s;
}

.bd-mobile-nav-links a:hover,
.bd-mobile-nav-links a.active {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink, #E7ECEF);
}

.bd-mobile-nav-links a svg {
  width: 16px;
  height: 16px;
  stroke: var(--ink-3, #6D7682);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}

.bd-mobile-nav-cta {
  display: flex;
  gap: 8px;
}

.bd-mobile-nav-cta a {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 14px;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  font-family: 'Inter', system-ui, sans-serif;
  transition: all 0.15s;
}

.bd-mobile-nav-cta .cta-primary {
  background: var(--teal, #1D9E75);
  color: #04130D;
  box-shadow: 0 0 0 1px rgba(37,196,144,0.4), 0 4px 14px -4px rgba(29,158,117,0.5);
}

.bd-mobile-nav-cta .cta-secondary {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line-2, #2A323D);
  color: var(--ink-2, #A8B0BA);
}

/* ══════════════════════════════════════════════════════
   2. BOTTOM TAB BAR (phones ≤ 600px only)
   ══════════════════════════════════════════════════════ */

#bd-tab-bar {
  display: none; /* shown only at ≤600px via media query */
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: rgba(11, 14, 18, 0.96);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line, #1E242E);
  /* Safe area for iPhone home bar */
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#bd-tab-bar nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: 56px;
}

#bd-tab-bar a {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--ink-3, #6D7682);
  font-size: 10px;
  font-family: 'JetBrains Mono', monospace;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 500;
  transition: color 0.15s;
  padding: 0 4px;
  position: relative;
}

#bd-tab-bar a svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.15s;
}

#bd-tab-bar a:hover,
#bd-tab-bar a.active {
  color: var(--teal-2, #25C490);
}

#bd-tab-bar a.active::after {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: var(--teal-2, #25C490);
  border-radius: 0 0 2px 2px;
}

/* ══════════════════════════════════════════════════════
   3. CORE TYPOGRAPHY AND SPACING
   ══════════════════════════════════════════════════════ */

@media (max-width: 900px) {
  .wrap,
  .wrap-mid,
  .wrap-narrow {
    padding: 0 20px !important;
  }

  /* Hero headings */
  h1.bd-hero-head,
  .tx-hero h1,
  .city-hero h1,
  .claim-hero h1,
  .about-hero h1,
  .contact-hero h2,
  .pricing-hero h1,
  .e404-title {
    font-size: clamp(26px, 7vw, 40px) !important;
    letter-spacing: -0.02em !important;
  }

  /* Section headings */
  .bd-sec-title,
  .section-header h2,
  .expect-head h2,
  .faq-head h2,
  .what-left h2,
  .clinics-head-left h2,
  .related-title,
  .bd-cta-title,
  .next-head h2 {
    font-size: clamp(22px, 5vw, 32px) !important;
  }

  /* Hero sublines */
  .bd-hero-sub,
  .tx-hero-sub,
  .city-hero-sub,
  .pricing-hero-sub,
  .claim-hero-sub,
  .contact-hero-sub {
    font-size: 15px !important;
  }

  /* Section padding */
  .bd-block,
  .what-section,
  .expect-section,
  .clinics-section,
  .faq-section,
  .related-section,
  .cta-section,
  .how-section,
  .editorial-section,
  .mission-section,
  .contact-main,
  .tx-hero,
  .city-hero,
  .claim-hero,
  .about-hero,
  .pricing-grid-section,
  .compare-section,
  .city-body,
  .response-section,
  .next-section {
    padding-top: 52px !important;
    padding-bottom: 52px !important;
  }

  /* Hero sections */
  .bd-hero,
  .claim-hero,
  .about-hero,
  .contact-hero,
  .pricing-hero,
  .tx-hero,
  .city-hero {
    padding-top: 52px !important;
    padding-bottom: 44px !important;
  }

  /* CTA banner */
  .bd-cta,
  .cta-inner {
    padding: 36px 28px !important;
    grid-template-columns: 1fr !important;
  }

  .bd-cta-sub {
    max-width: 100% !important;
  }

  .bd-cta-buttons,
  .cta-btns {
    flex-direction: row !important;
    flex-wrap: wrap !important;
    min-width: unset !important;
  }

  .bd-cta-buttons .bd-btn,
  .cta-btns .bd-btn {
    flex: 1 1 140px !important;
    min-width: 140px !important;
  }

  /* Section header stacks */
  .bd-sec-head,
  .clinics-head,
  .related-head,
  .similar-head,
  .listings-head {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
  }
}

/* Tight phones */
@media (max-width: 480px) {
  h1.bd-hero-head,
  .tx-hero h1,
  .city-hero h1 {
    font-size: clamp(24px, 8vw, 34px) !important;
  }
}

/* ══════════════════════════════════════════════════════
   4. TOUCH TARGETS AND iOS FIXES
   ══════════════════════════════════════════════════════ */

/* iOS auto-zoom fix — prevents the page from zooming
   when an input with font-size < 16px is focused */
@media (max-width: 900px) {
  input[type="text"],
  input[type="email"],
  input[type="tel"],
  input[type="url"],
  input[type="search"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important; /* must be ≥16px to prevent iOS zoom */
  }
}

/* Minimum 44px tap target on all interactive elements */
@media (max-width: 900px) {
  .bd-btn,
  .form-submit,
  .btn-submit,
  .ds-btn,
  .tx-search-btn,
  .city-search-btn,
  .e404-search-btn,
  .bd-search-btn,
  .faq-btn,
  .how-tab,
  .filter-link,
  .browse-item,
  .bd-quick-tag,
  .tx-pill,
  .nav-item,
  .bd-mobile-nav-links a {
    min-height: 44px !important;
  }

  .filter-link {
    padding: 10px 10px !important;
  }
}

/* ══════════════════════════════════════════════════════
   5. GRIDS AND LAYOUT COLLAPSES
   ══════════════════════════════════════════════════════ */

/* ── Tablet (≤ 960px) ── */
@media (max-width: 960px) {

  /* Treatment tiles: 4-col → 2-col */
  .bd-tiles {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* City grid: 5-col → 2-col */
  .bd-city-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Clinic cards: 3-col → 2-col */
  .bd-clinics,
  .clinics-section .directorist-listings-grid,
  .clinics-section .atbdp-lists,
  .city-listings .directorist-listings-grid,
  .city-listings .atbdp-lists,
  .similar-section .directorist-listings-grid,
  .similar-section .atbdp-lists {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* How it works cards: 3-col → 1-col */
  .bd-steps,
  .how-panel,
  .next-steps {
    grid-template-columns: 1fr !important;
  }

  /* Stats: 4-col → 2-col */
  .bd-trust-grid {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Trust stat borders */
  .bd-trust-stat:nth-child(2) { border-right: none !important; }
  .bd-trust-stat:nth-child(4) { border-right: none !important; }

  /* Pricing cards: 3-col → 1-col centered */
  .pricing-grid {
    grid-template-columns: 1fr !important;
    max-width: 480px !important;
    margin: 0 auto !important;
  }
  .tier.pop { order: -1 !important; }

  /* Compare table: hide on tablet, show scroll hint */
  .compare-table { font-size: 13px !important; }
  .compare-section { overflow-x: auto; }

  /* FAQ grid: 2-col → 1-col */
  .faq-grid { grid-template-columns: 1fr !important; }

  /* Response time: 3-col → 1-col */
  .response-grid { grid-template-columns: 1fr !important; }

  /* Expect cards: 3-col → 2-col */
  .expect-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* Related treatments: 4-col → 2-col */
  .related-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* What is section: 2-col → 1-col */
  .what-grid { grid-template-columns: 1fr !important; }

  /* Hero inner: 2-col → 1-col */
  .tx-hero-inner,
  .city-hero-inner,
  .about-hero-inner {
    grid-template-columns: 1fr !important;
    gap: 36px !important;
  }

  /* Mission: 2-col → 1-col */
  .mission-grid,
  .editorial-inner {
    grid-template-columns: 1fr !important;
  }

  /* City layout: 2-col → 1-col */
  .city-layout,
  .contact-grid,
  .claim-grid {
    grid-template-columns: 1fr !important;
  }

  /* Sidebar becomes static */
  .city-sidebar,
  .listing-sidebar,
  .contact-form-card,
  .claim-form-card {
    position: static !important;
  }

  /* Single listing: 2-col → 1-col */
  .listing-layout { grid-template-columns: 1fr !important; }

  /* Dashboard: 2-col → 1-col */
  .portal-wrap { grid-template-columns: 1fr !important; }
  .portal-sidebar {
    position: static !important;
    height: auto !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    padding: 12px 16px !important;
  }
  .sidebar-plan { display: none !important; }
  .sidebar-section-label { display: none !important; }
  .nav-item { font-size: 13px !important; padding: 8px 10px !important; }

  /* Edit listing: 2-col → 1-col */
  .edit-wrap { grid-template-columns: 1fr !important; padding: 20px !important; }
  .edit-sidebar { position: static !important; }

  /* Form rows: 2-col → 1-col */
  .form-row,
  .form-row-2 {
    grid-template-columns: 1fr !important;
  }

  /* Footer: 4-col → 2-col */
  .bd-footer-grid,
  .bd-footer .bd-footer-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 32px !important;
  }

  /* Stats hero grids */
  .tx-stats,
  .city-stats,
  .about-stats {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Upgrade grid */
  .upgrade-grid { grid-template-columns: 1fr !important; }

  /* Quick actions: 3-col → 2-col */
  .quick-actions { grid-template-columns: repeat(2, 1fr) !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* 404 quick links */
  .e404-quick-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .e404-browse-row { grid-template-columns: 1fr !important; gap: 24px !important; }
}

/* ── Phone (≤ 600px) ── */
@media (max-width: 600px) {

  /* Everything goes to 1-col */
  .bd-tiles,
  .expect-grid,
  .related-grid,
  .bd-clinics,
  .bd-steps,
  .clinics-section .directorist-listings-grid,
  .clinics-section .atbdp-lists,
  .city-listings .directorist-listings-grid,
  .city-listings .atbdp-lists,
  .similar-section .directorist-listings-grid,
  .similar-section .atbdp-lists {
    grid-template-columns: 1fr !important;
  }

  /* City grid stays 2-col on phones — works well */
  .bd-city-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px !important;
  }

  /* Trust bar: 2-col → 1-col with borders */
  .bd-trust-grid { grid-template-columns: 1fr !important; }
  .bd-trust-stat {
    border-right: none !important;
    border-bottom: 1px solid var(--line) !important;
  }
  .bd-trust-stat:last-child { border-bottom: none !important; }

  /* Footer: all 1-col */
  .bd-footer-grid {
    grid-template-columns: 1fr !important;
    gap: 28px !important;
  }

  /* 404 page */
  .e404-quick-grid { grid-template-columns: 1fr 1fr !important; }

  /* Stats grids */
  .stats-grid { grid-template-columns: 1fr !important; }
  .quick-actions { grid-template-columns: 1fr !important; }

  /* Next steps */
  .next-steps { grid-template-columns: 1fr 1fr !important; }
  .next-steps::before { display: none !important; }
}

/* ══════════════════════════════════════════════════════
   6. COMPONENT-SPECIFIC OVERRIDES
   ══════════════════════════════════════════════════════ */

/* ── Nav ── */
@media (max-width: 900px) {
  .bd-nav-links { display: none !important; }
  .bd-hamburger { display: flex !important; }

  /* Tighten nav on mobile */
  .bd-nav-inner { height: 60px !important; }
  .bd-mobile-nav { top: 60px !important; }

  /* Hide desktop sign-in link — it's in the drawer */
  .bd-nav .bd-signin { display: none !important; }
}

/* ── Search bars → stack vertically ── */
@media (max-width: 900px) {
  .bd-search,
  .dir-search-bar,
  .tx-search,
  .city-search,
  .e404-search {
    grid-template-columns: 1fr !important;
    gap: 6px !important;
  }

  .bd-sf.divider,
  .dsf.div,
  .txsf.div,
  .csf.div {
    border-right: none !important;
    border-bottom: 1px solid var(--line) !important;
    border-radius: 8px 8px 0 0 !important;
  }

  .bd-search-btn,
  .ds-btn,
  .tx-search-btn,
  .city-search-btn,
  .e404-search-btn {
    justify-content: center !important;
    min-height: 48px !important;
    border-radius: 0 0 8px 8px !important;
  }
}

/* ── Pricing tier cards ── */
@media (max-width: 900px) {
  .tier { padding: 28px 22px 24px !important; }
  .uc-price, .tier-price .amt { font-size: 36px !important; }
}

/* ── Compare table ── */
@media (max-width: 900px) {
  .compare-section { overflow-x: auto !important; }
  .compare-table { min-width: 560px !important; }
  .compare-table thead th,
  .compare-table tbody td { padding: 10px 12px !important; }
}

/* ── Hero stat grids ── */
@media (max-width: 900px) {
  .tx-stat-num,
  .city-stat-num,
  .about-stat-num { font-size: 28px !important; }
}

/* ── Clinic cards ── */
@media (max-width: 600px) {
  .bd-clinic-name { font-size: 18px !important; }
  .bd-clinic-image { height: 140px !important; }
}

/* ── Single listing ── */
@media (max-width: 900px) {
  .clinic-name { font-size: 26px !important; }
  .listing-hero { height: 200px !important; }
  .hours-grid { grid-template-columns: 1fr !important; }
}

/* ── About / contact ── */
@media (max-width: 900px) {
  .about-hero-btns { flex-direction: column !important; }
  .about-hero-btns .bd-btn { width: 100% !important; justify-content: center !important; }
  .contact-channels { gap: 8px !important; }
}

/* ── FAQ accordion ── */
@media (max-width: 900px) {
  .faq-btn { padding: 16px 18px !important; }
  .faq-q { font-size: 14px !important; }
  .faq-body { padding: 0 18px 16px !important; }
}

/* ── How-it-works tabs ── */
@media (max-width: 900px) {
  .how-tabs { gap: 4px !important; }
  .how-tab { font-size: 13px !important; padding: 8px 12px !important; }
  .how-panel { grid-template-columns: 1fr !important; }
}

/* ── Legal pages ── */
@media (max-width: 900px) {
  .legal-toc { display: none !important; }
  .legal-layout { grid-template-columns: 1fr !important; }
  .doc-section h2 { font-size: 18px !important; }
}

/* ── Claim listing preview ── */
@media (max-width: 600px) {
  .preview-cards { grid-template-columns: 1fr 1fr !important; }
}

/* ── Portal dashboard ── */
@media (max-width: 600px) {
  .portal-sidebar { gap: 2px !important; }
  .nav-item span:not(svg) { display: none !important; }
  .portal-main { padding: 16px !important; }
}

/* ── Directorist output ── */
@media (max-width: 900px) {
  /* Force Directorist to respect our grid overrides */
  [class*="directorist-listing"],
  [class*="atbdp-listing"],
  .directorist-archive-wrapper .atbdp-listing-item {
    width: 100% !important;
    float: none !important;
  }
}

/* ── Footer ── */
@media (max-width: 900px) {
  .bd-foot-bottom {
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 12px !important;
    font-size: 11px !important;
  }

  .bd-foot-bottom .links {
    flex-wrap: wrap !important;
    gap: 14px !important;
  }
}

/* ══════════════════════════════════════════════════════
   7. SAFE AREA INSETS (iPhone notch / Dynamic Island)
   ══════════════════════════════════════════════════════ */

/* Add padding to the bottom of the page so content
   isn't hidden behind the bottom tab bar + home bar */
@media (max-width: 600px) {
  .bd-footer,
  .portal-main,
  .edit-wrap {
    /* 56px tab bar + 12px gap + env safe area */
    padding-bottom: calc(
      56px + 12px + env(safe-area-inset-bottom, 0px)
    ) !important;
  }

  /* Sticky elements should not overlap home indicator */
  .bd-nav,
  .portal-nav {
    padding-top: env(safe-area-inset-top, 0px);
  }
}

/* Left/right safe areas for landscape orientation */
@media (max-width: 900px) {
  .wrap,
  .wrap-mid,
  .wrap-narrow {
    padding-left: max(20px, env(safe-area-inset-left, 20px)) !important;
    padding-right: max(20px, env(safe-area-inset-right, 20px)) !important;
  }
}

/* ══════════════════════════════════════════════════════
   8. SHOW BOTTOM TAB BAR ON PHONES ONLY
   ══════════════════════════════════════════════════════ */

@media (max-width: 600px) {
  #bd-tab-bar {
    display: block !important;
  }
}

/* ══════════════════════════════════════════════════════
   9. REDUCED MOTION — disable all transitions
   ══════════════════════════════════════════════════════ */

@media (prefers-reduced-motion: reduce) {
  .bd-mobile-nav,
  .bd-hamburger button span,
  .bd-tile,
  .bd-city,
  .expect-card,
  .related-card,
  .qa-card,
  #bd-glow {
    transition: none !important;
    animation: none !important;
  }
}
