@layer tokens, base, components, sections, page, utility;

/* ============================================================
   PPCBud — sticky actions + responsive system (v5.3)

   Breakpoints, and why these:
     ≤ 640px   phone      one column, app bar, drawer nav
     641–1024  tablet     two columns, drawer nav (portrait iPad
                          is 768px wide and cannot fit six nav
                          items plus a logo and a CTA)
     ≥ 1025px  desktop    full nav, multi-column grids
     ≥ 1440px  large      wider measure, larger display type
   ============================================================ */

@layer components {

  /* ---------------------------------------------- WhatsApp float */
  .pb-wa {
    position: fixed;
    right: 18px;
    bottom: 18px;
    z-index: 80;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    height: 56px;
    padding: 0 20px 0 16px;
    border-radius: 999px;
    background: #25D366;
    color: #06301A;
    text-decoration: none;
    font-family: var(--pb-font-display);
    font-weight: 700;
    font-size: 15px;
    box-shadow: 0 6px 20px rgba(6,48,26,.28);
    transition: transform .18s ease, box-shadow .18s ease;
  }
  .pb-wa:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 26px rgba(6,48,26,.34);
    color: #06301A;
  }
  .pb-wa svg { width: 26px; height: 26px; flex: none; }

  /* WhatsApp green is fixed by their brand guidelines, so the label
     takes dark ink: white on #25D366 measures 2.1:1 and fails. */

  /* ------------------------------------------- mobile app bar */
  .pb-appbar {
    display: none;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 90;
    background: rgba(255,255,255,.97);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--pb-line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .pb-appbar-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 9px 4px 8px;
    text-decoration: none;
    color: var(--pb-slate);
    font-family: var(--pb-font-body);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .01em;
    min-height: 56px;
    position: relative;
  }
  .pb-appbar-item svg { width: 22px; height: 22px; }
  .pb-appbar-item.is-active { color: var(--pb-navy); }
  .pb-appbar-item.is-active::before {
    content: "";
    position: absolute;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 26px; height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--pb-brand);
  }
  .pb-appbar-item:active { background: var(--pb-mist); }
}

@layer utility {

  /* ============================================================
     PHONE  ≤ 640px
     ============================================================ */
  @media (max-width: 640px) {
    .pb-wrap { padding: 0 18px; }

    h1 { font-size: clamp(30px, 8.4vw, 40px); line-height: 1.06; }
    h2 { font-size: clamp(24px, 6.4vw, 30px); }
    h3 { font-size: 17px; }
    body { font-size: 15.5px; }

    .pb-sec { padding: 52px 0; }
    .pb-sec-tight { padding: 30px 0; }
    .pb-page-hero { padding: 44px 0 40px; }
    .pb-lead { font-size: 16.5px; }
    .pb-sec-intro { font-size: 15.5px; margin-bottom: 24px; }

    .pb-card-grid { gap: 12px; }
    .pb-card-grid-2, .pb-card-grid-3,
    .pb-card-grid-4, .pb-card-grid-5 { grid-template-columns: 1fr; }
    .pb-card { padding: 20px; }

    .pb-stat-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .pb-stat { padding: 18px; }
    .pb-stat-value { font-size: 28px; }

    .pb-loc-cta-row { flex-direction: column; align-items: stretch; }
    .pb-loc-cta-row .pb-btn { text-align: center; }

    .pb-price-card { padding: 24px; }
    .pb-price { font-size: 34px; }

    .pb-city-grid { grid-template-columns: 1fr 1fr; gap: 4px 16px; }
    .pb-markets { grid-template-columns: 1fr 1fr; }

    /* Tables cannot reflow, so they scroll rather than overflow. */
    .pb-compare { display: block; overflow-x: auto; white-space: nowrap; }
    .pb-compare th, .pb-compare td { padding: 12px 14px; }

    .pb-footer { padding: 46px 0 26px; }
    .pb-footer-grid { grid-template-columns: 1fr 1fr; gap: 26px; }
    .pb-footer-brand { grid-column: 1 / -1; }
    .pb-cta-band { padding: 52px 0; }

    /* App bar visible; content and floats clear it. */
    .pb-appbar { display: flex; }
    body { padding-bottom: calc(58px + env(safe-area-inset-bottom)); }
    .pb-wa {
      bottom: calc(70px + env(safe-area-inset-bottom));
      right: 14px;
      height: 50px;
      padding: 0 16px 0 13px;
    }
    .pb-wa-label { display: none; }
    .pb-wa { padding: 0; width: 50px; justify-content: center; }
  }

  /* ============================================================
     TABLET  641–1024px
     Portrait iPad is 768px: too narrow for six nav items plus a
     logo and a CTA, so the drawer stays until 1025px.
     ============================================================ */
  @media (min-width: 641px) and (max-width: 1024px) {
    .pb-wrap { padding: 0 28px; }
    .pb-sec { padding: 64px 0; }
    .pb-page-hero { padding: 60px 0 52px; }

    .pb-card-grid-3, .pb-card-grid-4, .pb-card-grid-5 { grid-template-columns: 1fr 1fr; }
    .pb-stat-grid { grid-template-columns: repeat(2, 1fr); }
    .pb-markets { grid-template-columns: repeat(3, 1fr); }
    .pb-footer-grid { grid-template-columns: 1fr 1fr 1fr; }
    .pb-footer-brand { grid-column: 1 / -1; }
    .pb-two-col { grid-template-columns: 1fr; gap: 30px; }
  }

  /* Drawer replaces the horizontal nav below 1025px. */
  @media (max-width: 1024px) {
    .pb-nav-links { display: none; }
    .pb-nav-cta { display: none; }
    .pb-nav-toggle { display: inline-flex; }
    .pb-nav-inner { padding: 11px 18px; gap: 14px; }
    .pb-brand-logo, .pb-nav-logo .custom-logo { height: 30px; }
  }

  @media (min-width: 1025px) {
    .pb-nav-drawer { display: none !important; }
  }

  /* ============================================================
     LARGE DESKTOP  ≥ 1440px
     ============================================================ */
  @media (min-width: 1440px) {
    .pb-wrap { max-width: 1280px; }
    .pb-sec { padding: 96px 0; }
    h1 { font-size: clamp(52px, 4.4vw, 66px); }
  }

  /* Touch targets: 44px minimum on anything without a hover cursor. */
  @media (hover: none) {
    .pb-menu a, .pb-drawer-menu a, .pb-btn, .pb-appbar-item { min-height: 44px; }
    .pb-card:hover { border-color: var(--pb-line); box-shadow: none; }
    .pb-btn:hover, .pb-wa:hover, .pb-market:hover { transform: none; }
  }

  /* Printing: strip the floats and the sticky chrome. */
  @media print {
    .pb-nav, .pb-appbar, .pb-wa, .pb-cta-band, .pb-footer { display: none !important; }
    .pb-sec { padding: 18px 0; border-top: 1px solid #ddd; }
    body { padding-bottom: 0; }
  }

  @media (prefers-reduced-motion: reduce) {
    .pb-wa, .pb-burger i { transition: none; }
  }
}
