/* ============================================================
   BRINDAVAN BEARINGS — Responsive Stylesheet
   Breakpoints: 1200px, 1024px, 768px, 480px
   ============================================================ */

/* ============================================================
   LARGE DESKTOP (1200px+)
   ============================================================ */
@media (min-width: 1200px) {
  .container { padding: 0 24px; }
}

/* ============================================================
   TABLET LANDSCAPE / SMALL DESKTOP (max 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  :root { --section-py: 64px; }

  .nav { display: none; }
  .hamburger { display: flex; }
  .header-actions .btn { display: none; }

  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }

  .brand-logos { grid-template-columns: repeat(4, 1fr); }
  .industries-grid { grid-template-columns: repeat(4, 1fr); }

  .products-layout { grid-template-columns: 220px 1fr; gap: 24px; }

  .cta-banner { flex-direction: column; text-align: center; padding: 40px 32px; }
  .cta-banner::before { width: 100%; height: 4px; top: 0; left: 0; }
  .cta-banner .btn-group { justify-content: center; }

  .bearing-rings { width: 400px; height: 400px; right: -100px; opacity: 0.04; }

  .theme-switcher { display: none; }
}

/* ============================================================
   TABLET PORTRAIT (max 768px)
   ============================================================ */
@media (max-width: 768px) {
  :root { --section-py: 52px; }

  h1 { font-size: 2rem; }
  h2 { font-size: 1.7rem; }
  h3 { font-size: 1.2rem; }

  .container { padding: 0 16px; }

  /* Grid adjustments */
  .grid-2 { grid-template-columns: 1fr; gap: 24px; }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
  /* Let grid/flex children shrink below their content's intrinsic width
     so long unbreakable names never force horizontal page overflow. */
  .grid-2 > *, .grid-3 > *, .grid-4 > * { min-width: 0; }

  /* Hero */
  .hero { padding: 100px 0 60px; min-height: auto; }
  .hero p { font-size: 1rem; }

  /* Stats: compact 2x2 grid of separated cards */
  .stats-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-top: 32px;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    overflow: visible;
  }
  .stat-item {
    padding: 14px 10px;
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    background: var(--clr-bg-card);
    box-shadow: var(--shadow-sm);
  }
  .stat-num { font-size: 1.5rem; margin-bottom: 2px; }
  .stat-label { font-size: 0.7rem; }
  .bearing-rings { display: none; }

  /* Stat cards grid (about page): stay compact 2x2, don't stack */
  .stats-cards-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 12px !important; }
  .stats-cards-grid .card { padding: 18px 10px !important; }
  .stats-cards-grid .stat-num { font-size: 1.5rem; }
  .stats-cards-grid .stat-label { font-size: 0.7rem; }

  /* Products */
  .products-layout { grid-template-columns: 1fr; }
  .filter-sidebar { display: none; }
  .filter-sidebar.mobile-open {
    display: block;
    position: fixed; inset: 0; z-index: 1050;
    overflow-y: auto; border-radius: 0;
    top: 0; padding: 64px 20px 88px;
    -webkit-overflow-scrolling: touch;
  }
  /* Close (X) button — only visible while the sidebar is open on mobile */
  .filter-close-btn {
    display: none;
    position: absolute;
    top: 14px; right: 16px;
    align-items: center; gap: 6px;
    padding: 8px 14px;
    background: var(--clr-bg-3);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-full);
    font-size: 0.85rem; font-weight: 600;
    color: var(--clr-text);
  }
  .filter-sidebar.mobile-open .filter-close-btn { display: inline-flex; }
  /* Sticky "Show results" bar pinned to the bottom of the open sidebar */
  .filter-sidebar.mobile-open .filter-apply-bar {
    display: block;
    position: fixed; left: 0; right: 0; bottom: 0;
    padding: 12px 16px;
    background: var(--clr-bg-card);
    border-top: 1px solid var(--clr-border);
    box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
  }
  .filter-mobile-btn {
    display: flex !important;
    align-items: center; gap: 8px;
    padding: 10px 16px;
    background: var(--clr-bg-card);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius);
    font-size: 0.88rem;
    color: var(--clr-text-muted);
    cursor: pointer;
    margin-bottom: 16px;
  }

  /* About */
  .about-snap .grid-2 { gap: 32px; }
  .about-snap-media { margin-top: 8px; }
  .about-snap-media img { max-height: 300px; }
  .about-media-badge { left: 12px; bottom: -14px; padding: 12px 18px; }
  .about-media-num { font-size: 1.6rem; }

  /* Precision band — disable parallax on mobile (iOS jank) */
  .precision-band { background-attachment: scroll; padding: 64px 0; }
  .precision-band-inner { max-width: 100%; }

  /* Brands grid */
  .brand-logos { grid-template-columns: repeat(3, 1fr); }
  .brands-grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .brand-logo-placeholder { font-size: 1.1rem; overflow: hidden; text-overflow: ellipsis; }

  /* Industries */
  .industries-grid { grid-template-columns: repeat(3, 1fr); }

  /* Cart panel */
  .cart-panel { width: 100vw; }

  /* Footer — stack to a single column, keep everything left-aligned */
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; text-align: left; align-items: flex-start; gap: 8px; }
  .footer-brand .logo { justify-content: flex-start; }
  .footer-brand p { text-align: left; margin-left: 0; margin-right: 0; }
  .footer-social { justify-content: flex-start; }
  .footer-col { text-align: left; }
  .footer-col ul li a { justify-content: flex-start; }
  .footer-contact-item { justify-content: flex-start; }

  /* Product detail */
  .product-detail-grid { grid-template-columns: 1fr; }

  /* CTA banner */
  .cta-banner { padding: 32px 24px; }
  .cta-banner-text h2 { font-size: 1.5rem; }

  /* Floating buttons adjust */
  .floating-buttons { bottom: 20px; right: 16px; }
  .float-btn { width: 46px; height: 46px; font-size: 1.15rem; }
  .float-btn .tooltip { display: none; }

  /* Theme switcher hidden on mobile */
  .theme-switcher { display: none; }

  /* Inquiry cart inline */
  .inline-form-row { flex-direction: column; align-items: stretch; }

  /* Section header */
  .section-header { margin-bottom: 36px; }
  .section-header h2 { font-size: 1.6rem; }
}

/* ============================================================
   MOBILE (max 480px)
   ============================================================ */
@media (max-width: 480px) {
  :root { --section-py: 44px; }

  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.4rem; }

  .container { padding: 0 12px; }

  /* Single column grids */
  .grid-3, .grid-4 { grid-template-columns: 1fr; }

  /* Hero */
  .hero { padding: 90px 0 48px; }
  .hero-badge { font-size: 0.72rem; }
  .hero h1 { font-size: 1.75rem; }
  /* Buttons: side by side on one row */
  .btn-group { flex-direction: row; gap: 10px; }
  .btn-group .btn { flex: 1; width: auto; justify-content: center; padding-left: 12px; padding-right: 12px; }

  /* Stats: keep tidy 2x2 grid, tighter spacing */
  .stats-bar { gap: 8px; margin-top: 28px; }
  .stat-item { padding: 12px 8px; }
  .stat-num { font-size: 1.35rem; }
  .stat-label { font-size: 0.65rem; letter-spacing: 0.3px; }

  /* Stat cards grid (about page): tighter on small phones */
  .stats-cards-grid { gap: 10px !important; }
  .stats-cards-grid .card { padding: 16px 8px !important; }
  .stats-cards-grid .stat-num { font-size: 1.35rem; }
  .stats-cards-grid .stat-label { font-size: 0.65rem; }

  /* Products grid */
  .products-grid { grid-template-columns: 1fr !important; }

  /* Brand logos */
  .brand-logos { grid-template-columns: repeat(2, 1fr); }

  /* Industries */
  .industries-grid { grid-template-columns: repeat(2, 1fr); }

  /* Contact */
  .contact-info-card { flex-direction: column; gap: 10px; }

  /* Footer (centering handled in the ≤768px block above) */
  .footer-brand p { margin-bottom: 16px; }

  /* Cart panel */
  .cart-panel { width: 100vw; }
  .modal { padding: 24px 16px; }

  /* Why cards */
  .why-card { padding: 24px 20px; }

  /* CTA */
  .cta-banner { padding: 28px 20px; }

  /* Breadcrumb */
  .breadcrumb { font-size: 0.75rem; flex-wrap: wrap; }

  /* Timeline */
  .timeline { padding-left: 24px; }

  /* Page hero */
  .page-hero { padding: 100px 0 48px; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  #header, #footer, .floating-buttons, .theme-switcher,
  .back-to-top, .cart-panel, .modal-overlay { display: none !important; }
  body { background: white; color: black; }
  .container { max-width: 100%; }
}

/* ============================================================
   UTILITY: Filter mobile button (hidden by default, shown on mobile)
   ============================================================ */
.filter-mobile-btn { display: none; }

/* ============================================================
   STICKY CATEGORY BAR on scroll
   ============================================================ */
.category-bar-sticky {
  position: sticky;
  top: 68px;
  z-index: 100;
  background: var(--clr-bg);
  padding: 0 0 1px;
  border-bottom: 1px solid var(--clr-border);
}

/* ============================================================
   PRODUCTS GRID responsive overrides
   ============================================================ */
.products-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
@media (max-width: 900px) {
  .products-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .products-grid { grid-template-columns: 1fr; }
}

/* ============================================================
   CATEGORY PAGES: hero smaller on mobile
   ============================================================ */
@media (max-width: 768px) {
  .page-hero { padding: 100px 0 48px; }
  .page-hero h1 { font-size: 1.6rem; }
}

/* ============================================================
   HEADER: height adjustments
   ============================================================ */
@media (max-width: 768px) {
  .header-inner { padding: 12px 0; }
  .logo-lockup { height: 52px; }
  /* Tighter white plate so the artwork keeps its size on small screens. */
  #header.over-dark:not(.scrolled) .logo-lockup,
  [data-theme="gold-navy"] .logo-lockup,
  #footer .logo-lockup { padding: 4px 9px; border-radius: 9px; }
}
@media (max-width: 420px) {
  .logo-lockup { height: 44px; }
  #header.over-dark:not(.scrolled) .logo-lockup,
  [data-theme="gold-navy"] .logo-lockup,
  #footer .logo-lockup { padding: 3px 7px; border-radius: 8px; }
}

/* ============================================================
   TIMELINE: mobile condensed
   ============================================================ */
@media (max-width: 768px) {
  .timeline-entry { padding-bottom: 32px; }
  .timeline-entry h3 { font-size: 0.95rem; }
}

/* ============================================================
   BRANDS: 4→2 col on tablet
   ============================================================ */
@media (max-width: 900px) {
  .brand-logos { grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 600px) {
  .brand-logos { grid-template-columns: repeat(3, 1fr); }
}

/* ============================================================
   FILTER APPLY BAR — hidden by default (only shown when the
   mobile sidebar is open, see the max-768 block above)
   ============================================================ */
.filter-apply-bar { display: none; }

/* ============================================================
   PRODUCT DETAIL — stack & shrink on mobile
   ============================================================ */
@media (max-width: 768px) {
  .product-detail-header { padding: 100px 0 40px; }
  .product-meta h1 { font-size: 1.5rem; }
  .product-img-box { height: 240px; font-size: 4rem; }
  .inline-form-row { flex-direction: column; align-items: stretch; gap: 12px; }
  .inline-form-row .btn { width: 100%; justify-content: center; }
  .product-cta { padding: 28px 20px; }
}

/* ============================================================
   TABLES — allow horizontal scroll instead of overflow on small
   screens (spec tables on product detail pages)
   ============================================================ */
@media (max-width: 640px) {
  .specs-table { display: block; overflow-x: auto; white-space: nowrap; -webkit-overflow-scrolling: touch; }
}

/* ============================================================
   TOUCH TARGETS & SMOOTH SCROLLING on small screens
   ============================================================ */
@media (max-width: 768px) {
  .category-bar { -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; }
  .cat-pill { scroll-snap-align: start; padding: 9px 18px; }
  /* Comfortable minimum tap size for icon buttons */
  .cart-btn, .hamburger, .cart-close-btn, .qty-btn { min-width: 40px; min-height: 40px; }
  .qty-btn { min-width: 32px; min-height: 32px; }
  /* Full-width primary actions read better on phones */
  .cta-banner .btn-group { width: 100%; }
  .cta-banner .btn-group .btn { flex: 1; justify-content: center; }
}

/* ============================================================
   SAFE-AREA padding for notched phones (floating UI + menu)
   ============================================================ */
@supports (padding: max(0px)) {
  .floating-buttons { right: max(16px, env(safe-area-inset-right)); bottom: max(20px, env(safe-area-inset-bottom)); }
  .mobile-menu { padding-bottom: max(40px, env(safe-area-inset-bottom)); }
}

/* ============================================================
   PREVENT accidental horizontal overflow from wide inline content
   ============================================================ */
@media (max-width: 480px) {
  .series, .product-meta .series-box { word-break: break-word; white-space: normal; }
  .highlight-box { font-size: 0.84rem; }
  .cta-banner-text h2 { font-size: 1.35rem; }
}

/* ============================================================
   RESPECT reduced-motion preferences
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .ring { display: none; }
}
