/* ============================================
   STEAM COFFEE CO — Mobile Optimisations
   Added by Pocket — progressive enhancement layer.
   All rules here are either:
     (a) Mobile-only fixes that don't affect desktop, or
     (b) Corrections to inline styles that were missing mobile breakpoints.
   Desktop layout is fully preserved.
   ============================================ */

/* ---- Safe-area insets (iPhone notch / home bar) ---- */
body {
  padding-bottom: env(safe-area-inset-bottom, 0);
  overflow-x: hidden;
}

/* Toast: lift above iPhone home bar */
.toast {
  bottom: max(var(--space-6), calc(env(safe-area-inset-bottom, 0px) + var(--space-4)));
}

/* ---- Craft strip: 3-column grid → 1-column on small screens ---- */
/* Overrides inline style on index.html craft strip wrapper */
.craft-strip__grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5);
  max-width: 720px;
  margin: 0 auto;
}

@media (min-width: 480px) {
  .craft-strip__grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-6);
  }
}

/* ---- Announcement bar: tighter on small screens ---- */
@media (max-width: 479px) {
  #announcement-bar {
    padding: var(--space-2) 3rem var(--space-2) var(--space-4);
    font-size: 0.75rem;
  }
}

/* ---- Mobile menu: slide-in transition ---- */
#mobile-menu {
  overflow: hidden;
  max-height: 0;
  transition: max-height var(--transition-base);
  display: block !important; /* override display:none — use max-height instead */
}

#mobile-menu.open {
  max-height: 400px;
}

/* ---- Mobile nav: active page indicator ---- */
.mobile-nav a.active {
  color: var(--color-forest);
  background: rgba(45, 74, 45, 0.06);
}

/* ---- Shop page: filter bar horizontal scroll on small screens ---- */
@media (max-width: 639px) {
  .filter-section {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .filter-section::-webkit-scrollbar {
    display: none;
  }

  .filter-row {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: var(--space-4);
    min-width: min-content;
    align-items: flex-start;
  }

  .filter-group {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 2px; /* prevent clipping */
  }

  .filter-group::-webkit-scrollbar {
    display: none;
  }

  .filter-divider {
    display: none;
  }
}

/* ---- Product detail: full-width add-to-cart row on small screens ---- */
@media (max-width: 479px) {
  .product-detail__add-row {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-3);
  }

  .product-detail__add-row .btn--primary {
    width: 100%;
    text-align: center;
  }

  .qty-control {
    align-self: flex-start;
  }
}

/* ---- Cart item: tighter on very small screens ---- */
@media (max-width: 479px) {
  .cart-item {
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
  }

  .cart-item__controls {
    grid-column: 2;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .cart-item__image {
    width: 56px;
    height: 56px;
    grid-row: 1 / 3;
  }
}

/* ---- Hero: reduce top padding on small screens ---- */
@media (max-width: 479px) {
  .hero {
    min-height: auto;
    padding: 0;
  }

  .hero__title {
    font-size: clamp(2rem, 7vw, 2.75rem);
  }

  .hero__subtitle {
    font-size: var(--text-base);
    margin-bottom: var(--space-4);
  }

  .hero__actions {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .hero__actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ---- Sections: reduce vertical padding on mobile ---- */
@media (max-width: 767px) {
  .section {
    padding: var(--space-7) 0;
  }

  .featured-section .section-heading {
    margin-bottom: var(--space-5);
  }
}

/* ---- Hero image: subtle parallax on scroll ---- */
.hero__image-col {
  will-change: transform;
  transition: transform 0.1s linear;
}

/* ---- Shop page: filter buttons not clipped on mobile ---- */
@media (max-width: 639px) {
  .shop-header {
    padding: var(--space-5) 0 var(--space-4);
  }

  .shop-header h1 {
    font-size: var(--text-2xl);
  }

  .filter-section {
    padding: var(--space-4) 0;
  }

  .filter-group {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .filter-chip {
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
    min-height: 36px;
  }
}

/* ---- About teaser: image first on mobile ---- */
@media (max-width: 767px) {
  .about-teaser .two-col {
    grid-template-columns: 1fr;
  }
}

/* ---- Quantity control: larger tap area on mobile ---- */
@media (max-width: 767px) {
  .qty-btn {
    width: 44px;
    height: 44px;
  }
}

/* ---- Weight options: wrap cleanly on mobile ---- */
@media (max-width: 479px) {
  .weight-options {
    flex-wrap: wrap;
  }

  .weight-option {
    flex: 1;
    min-width: 80px;
    text-align: center;
  }
}

/* ---- Tab buttons: full-width scroll on mobile ---- */
@media (max-width: 639px) {
  .product-tabs__nav {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    flex-wrap: nowrap;
  }

  .product-tabs__nav::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    white-space: nowrap;
    flex-shrink: 0;
  }
}

/* ---- Footer: stack tightly on mobile ---- */
@media (max-width: 767px) {
  #site-footer {
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
  }
}

/* ---- Modal: full-screen on small screens ---- */
@media (max-width: 479px) {
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: var(--space-6) var(--space-5);
    padding-bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    max-width: 100%;
    width: 100%;
  }
}

/* ---- Prevent 300ms tap delay on all interactive elements ---- */
a, button, input, select, textarea, label {
  touch-action: manipulation;
}
