/* =========================================================
   KEROCHE BREWERIES — MOBILE OPTIMIZATION LAYER
   Add-on stylesheet. Loads AFTER the main stylesheet/inline
   styles so its rules win. Uses only the brand's existing
   CSS custom properties (--gold, --forest, --glass, etc.)
   defined in :root — nothing new to configure.
   Scope: all rules below are wrapped in @media (max-width:
   768px) unless commented otherwise, so desktop is untouched.
   ========================================================= */

/* ---------------------------------------------------------
   1. COMPACT ACCORDIONS (booking packages / any data-dense list)
   Structure expected (see HTML pattern in the deploy notes):

   <div class="pkg-accordion">
     <button class="pkg-accordion-trigger" aria-expanded="false">
       <span class="pkg-accordion-icon">🏭</span>
       <span class="pkg-accordion-heading">
         <span class="pkg-name">Brewery Tour</span>
         <span class="pkg-price">KES 300 <small>/ student</small></span>
       </span>
       <span class="pkg-accordion-chevron">⌄</span>
     </button>
     <div class="pkg-accordion-panel">
       <div class="pkg-accordion-inner">
         ...pkg-desc, pkg-meta, pkg-btn...
       </div>
     </div>
   </div>
--------------------------------------------------------- */
.pkg-accordion {
  background: var(--glass);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  overflow: hidden;
  backdrop-filter: blur(12px);
}
/* Desktop default: render exactly like the original static package
   card — trigger button becomes non-interactive header, chevron
   hidden, panel always fully open (no animation needed). */
.pkg-accordion-trigger {
  width: 100%;
  display: flex;
  align-items: flex-start;
  flex-direction: column;
  gap: 0;
  background: none;
  border: none;
  text-align: left;
  padding: 2rem 2rem 0;
  cursor: default;
  pointer-events: none; /* inert on desktop; re-enabled on mobile below */
  -webkit-tap-highlight-color: transparent;
}
.pkg-accordion-icon { font-size: 2.5rem; margin-bottom: 1rem; }
.pkg-accordion-heading { display: contents; } /* let pkg-name/pkg-price lay out as in the original card */
.pkg-accordion-chevron { display: none; }
.pkg-accordion-panel { display: grid; grid-template-rows: 1fr; }
.pkg-accordion-inner { overflow: visible; padding: 0 2rem 2rem; }

@media (max-width: 768px) {
  .pkg-accordion { margin-bottom: 0.9rem; }
  .pkg-accordion-trigger {
    flex-direction: row;
    align-items: center;
    gap: 0.9rem;
    padding: 1.1rem 1.2rem;
    cursor: pointer;
    pointer-events: auto;
    min-height: 56px; /* touch target */
  }
  .pkg-accordion-icon { font-size: 1.5rem; margin-bottom: 0; flex-shrink: 0; }
  .pkg-accordion-heading {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    flex: 1;
    min-width: 0;
  }
  .pkg-accordion-heading .pkg-name { font-size: 1rem; margin: 0; }
  .pkg-accordion-heading .pkg-price { font-size: 0.85rem; margin: 0; }
  .pkg-accordion-chevron {
    display: block;
    flex-shrink: 0;
    color: var(--gold);
    font-size: 1.1rem;
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .pkg-accordion.open .pkg-accordion-chevron { transform: rotate(180deg); }
  .pkg-accordion.open .pkg-accordion-trigger { border-bottom: 1px solid var(--border); }

  /* Smooth height animation via the grid 0fr -> 1fr technique —
     no JavaScript height-measuring required, animates cleanly
     regardless of content length. */
  .pkg-accordion-panel {
    grid-template-rows: 0fr;
    transition: grid-template-rows 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .pkg-accordion.open .pkg-accordion-panel { grid-template-rows: 1fr; }
  .pkg-accordion-inner { overflow: hidden; min-height: 0; padding: 0 1.2rem; }
  .pkg-accordion.open .pkg-accordion-inner { padding: 0.9rem 1.2rem 1.3rem; }
  .pkg-accordion-inner .pkg-desc { font-size: 0.85rem; color: var(--dim); line-height: 1.7; margin-bottom: 1rem; }
  .pkg-accordion-inner .pkg-meta { font-size: 0.72rem; color: var(--dim2); margin-bottom: 1.1rem; }
  .pkg-accordion-inner .pkg-btn { width: 100%; min-height: 48px; }
}

/* ---------------------------------------------------------
   2. HORIZONTALLY SWIPEABLE PRODUCT CAROUSEL
   Applies to any element with .products-grid or #products-grid
   — no HTML changes needed, this is CSS-only.
--------------------------------------------------------- */
@media (max-width: 768px) {
  .products-grid,
  #products-grid {
    display: flex;
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 1rem;
    margin-top: 1.5rem;
    padding: 0.25rem 1.25rem 1rem;
    scroll-snap-type: x mandatory;
    scroll-padding-left: 1.25rem;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;      /* Firefox */
    -ms-overflow-style: none;   /* old Edge/IE */
  }
  .products-grid::-webkit-scrollbar,
  #products-grid::-webkit-scrollbar {
    display: none;              /* Chrome/Safari */
  }
  .products-grid > *,
  #products-grid > * {
    flex: 0 0 80%;              /* shows ~80% of the next card as a peek */
    max-width: 320px;
    scroll-snap-align: start;
  }
  /* Small screens: show a touch more of the next card */
  @media (max-width: 420px) {
    .products-grid > *,
    #products-grid > * {
      flex-basis: 84%;
    }
  }
}

/* Optional scroll-position dots — add a
   <div class="carousel-dots" data-for="products-grid"></div>
   right after the grid and mobile-enhancements.js will populate it. */
.carousel-dots {
  display: none;
}
@media (max-width: 768px) {
  .carousel-dots {
    display: flex;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.9rem;
  }
  .carousel-dots span {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--border);
    transition: var(--transition);
  }
  .carousel-dots span.active {
    background: var(--gold);
    width: 18px;
    border-radius: 999px;
  }
}

/* ---------------------------------------------------------
   3. MOBILE TYPOGRAPHY & TOUCH ACCESSIBILITY
--------------------------------------------------------- */
@media (max-width: 768px) {
  /* --- Typography scale-down ---
     Note: .section-title already uses clamp(2.8rem, 7vw, 6.5rem),
     which is fluid, but it can still run large on tall narrow
     phones — these caps make sure it never overwraps awkwardly. */
  h1, .section-title       { font-size: clamp(2rem, 9vw, 2.8rem) !important; line-height: 1.05 !important; }
  h2, .pkg-name, .product-card-name, .job-name { font-size: 1.15rem !important; line-height: 1.3 !important; }
  h3, .why-title, .feature-title { font-size: 1rem !important; line-height: 1.35 !important; }
  .section-desc, .pkg-desc, .product-card-desc { font-size: 0.85rem !important; line-height: 1.65 !important; }

  /* --- Tap targets: minimum 48px on every interactive element --- */
  a, button,
  .btn-primary, .btn-outline,
  .nav-links a, .mobile-menu a,
  .category-tab, .footer-links a,
  .social-btn, input[type="submit"] {
    min-height: 48px;
  }
  .btn-primary, .btn-outline {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.9rem 1.8rem;
  }
  .mobile-menu a {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
  }
  .category-tab { padding: 0.8rem 1.3rem; }
  a[href^="tel:"] {
    display: inline-flex;
    align-items: center;
    min-height: 48px;
    padding: 0.4rem 0;
  }
  /* form inputs also get comfortable thumb-sized hit areas */
  input, select, textarea { min-height: 48px; font-size: 16px; } /* 16px prevents iOS auto-zoom on focus */
  textarea { min-height: 120px; }

  /* --- Section/edge padding: 100px desktop margins -> 40px/16px mobile --- */
  section { padding: 2.5rem 1rem !important; }
  .section-inner { padding: 0 1rem; }
  .hero-content { padding: 0 1rem !important; }
  .about-split, .contact-grid { padding: 0 0.25rem; }
  footer { padding: 2.5rem 1rem 1.5rem !important; }
  .why-grid, .stats-row { gap: 1rem !important; }
}
