/* ============================================================
   YARD.STORE — MOBILE FIXES  v2
   Link AFTER style.css, product-page-tweaks.css, drawer-tweaks.css
   ============================================================ */


/* ============================================================
   FIX 1 — index.html: trust strip 3-col → stack on mobile
   ============================================================ */
@media (max-width: 768px) {
  .trust-cols {
    grid-template-columns: 1fr !important;
  }
  .trust-cols > div {
    border-left: none !important;
    border-right: none !important;
    padding-left: 0 !important;
    border-bottom: 1px solid var(--line);
  }
  .trust-cols > div:last-child {
    border-bottom: none;
    padding-left: 0 !important;
  }
}


/* ============================================================
   FIX 2 — index.html: category grid (Одяг) hardcoded 3-col
   ============================================================ */
@media (max-width: 768px) {
  .cat-grid {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
}
@media (max-width: 480px) {
  .cat-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}


/* ============================================================
   FIX 3 — index.html: Знижки section hardcoded 3-col
   ============================================================ */
@media (max-width: 768px) {
  .sale-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}
@media (max-width: 480px) {
  .sale-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}


/* ============================================================
   FIX 4 — index.html: Accessories wide banner aspect 21/6
   ============================================================ */
@media (max-width: 768px) {
  .cat-card[aria-label*="Аксесуари"] {
    aspect-ratio: 16/7 !important;
    min-height: 160px;
  }
  .cat-card[aria-label*="Аксесуари"] h2 {
    font-size: clamp(1.25rem, 6vw, 2rem) !important;
    margin-bottom: 14px !important;
  }
  .cat-card[aria-label*="Аксесуари"] span {
    font-size: 0.625rem !important;
    padding: 9px 16px !important;
  }
}


/* ============================================================
   FIX 5 — index.html: brand strip — smaller text, wrap nicely
   ============================================================ */
@media (max-width: 768px) {
  /* The brand strip uses inline flex with gap:40px — override */
  .section--sm [style*="gap:40px"] {
    gap: 0 !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    padding-block: 0 !important;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .section--sm [style*="gap:40px"] a {
    font-size: clamp(16px, 5vw, 22px) !important;
    padding: 18px var(--gutter) !important;
    border-bottom: 1px solid var(--line);
    letter-spacing: 0.02em !important;
  }
  /* Remove double bottom border on last two items */
  .section--sm [style*="gap:40px"] a:nth-child(3),
  .section--sm [style*="gap:40px"] a:nth-child(4) {
    border-bottom: none !important;
  }
  /* Right-column items get a left border */
  .section--sm [style*="gap:40px"] a:nth-child(even) {
    border-left: 1px solid var(--line);
  }
}


/* ============================================================
   FIX 6 — product.html: image viewer on mobile
   ============================================================ */
@media (max-width: 768px) {
  #img-viewer {
    flex-direction: column !important;
  }
  #img-viewer > div:first-child {
    display: none !important;
  }
  #img-viewer > div:nth-child(2) {
    flex: 1 !important;
    width: 100% !important;
  }
  #img-viewer button[onclick="viewerNav(-1)"],
  #img-viewer button[onclick="viewerNav(1)"] {
    width: 36px !important;
    height: 36px !important;
    font-size: 16px !important;
  }
}


/* ============================================================
   FIX 7 — product.html: actions row wrap on small screens
   ============================================================ */
@media (max-width: 480px) {
  .product-info__actions {
    flex-wrap: wrap !important;
  }
  .qty-stepper {
    width: 100% !important;
    order: -1;
  }
  .product-info__actions .btn--primary {
    flex: 1 !important;
  }
  #btn-save {
    flex-shrink: 0 !important;
  }
}


/* ============================================================
   FIX 8 — product.html: sticky bar safe-area (iPhone notch)
   ============================================================ */
@media (max-width: 768px) {
  .product-sticky-bar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
  }
}


/* ============================================================
   FIX 9 — All pages: footer on mobile
   ============================================================ */
.footer-brand form [type="email"] {
  min-width: 0 !important;
}
@media (max-width: 768px) {
  .footer-main {
    grid-template-columns: 1fr 1fr !important;
    padding: 32px var(--gutter) 24px !important;
    gap: 20px !important;
  }
  .footer-brand {
    grid-column: 1 / -1;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
  }
  .footer-logo {
    font-size: 1.125rem !important;
  }
  .footer-tagline {
    font-size: 0.8125rem;
    line-height: 1.5;
    margin-top: 8px;
    margin-bottom: 12px;
  }
  .footer-social {
    gap: 8px !important;
  }
  .footer-brand form {
    display: none;
  }
  .footer-col__link {
    font-size: 0.8125rem;
  }
  .footer-col__links {
    gap: 8px;
  }
  .footer-col__title {
    margin-bottom: 10px;
  }
}


/* ============================================================
   FIX 10 — All pages: hide keyboard hint on touch
   ============================================================ */
@media (pointer: coarse) {
  .search-overlay__hint {
    display: none;
  }
}


/* ============================================================
   FIX 11 — cart.html: tighter layout on mobile
   ============================================================ */
@media (max-width: 768px) {
  .cart-summary {
    padding: 24px var(--gutter) !important;
  }
  .cart-item {
    gap: 12px !important;
  }
  .cart-item .qty-stepper {
    width: 80px !important;
  }
}


/* ============================================================
   FIX 12 — product.html: gallery gap
   ============================================================ */
@media (max-width: 768px) {
  .product__gallery {
    gap: 2px !important;
  }
}


/* ============================================================
   FIX 13 — Mobile menu: accordion labels + heart on touch
   ============================================================ */
.mobile-menu__group-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  padding: 16px var(--gutter) !important;
  font-size: 0.75rem !important;
  font-weight: 500 !important;
  color: var(--ink) !important;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.mobile-menu__group-label::after {
  content: '+';
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--ink-mute);
  flex-shrink: 0;
  margin-left: 12px;
}
.mobile-menu__group-label.is-open {
  border-bottom-color: transparent;
}
.mobile-menu__group-label.is-open::after {
  content: '−';
  color: var(--ink);
}
.mobile-menu__link {
  min-height: 52px;
  display: flex !important;
  align-items: center;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
}
.mobile-menu__link:first-of-type {
  border-top: 4px solid var(--line);
  margin-top: 8px;
}
.mobile-menu__link--sale {
  font-weight: 500 !important;
  letter-spacing: 0.08em !important;
}
@media (pointer: coarse) {
  .product-card__heart {
    opacity: 0.7 !important;
    transform: scale(1) !important;
  }
}


/* ============================================================
   FIX 14 — catalog.html: filter bar right padding affordance
   ============================================================ */
@media (max-width: 768px) {
  .filter-bar {
    position: relative;
  }
  .filter-btn:last-of-type {
    padding-right: 24px !important;
  }
}


/* ============================================================
   FIX 15 — index.html: hero height — too tall on mobile
   Constrain height so CTA is visible above the fold
   ============================================================ */
@media (max-width: 768px) {
  .hero {
    min-height: 0 !important;
    height: 72vw !important; /* ~280px at 390px wide — shows headline + both CTAs */
    max-height: 420px;
  }
  .hero__title {
    font-size: clamp(1.75rem, 9vw, 2.5rem) !important;
    margin-bottom: 16px !important;
  }
  .hero__eyebrow {
    margin-bottom: 10px !important;
    font-size: 0.5625rem !important;
  }
  .hero__content {
    padding: 0 var(--gutter) !important;
  }
  /* CTA buttons: full-width stack */
  .hero__actions [style*="display:flex"] {
    flex-direction: column !important;
    gap: 8px !important;
  }
  .hero__actions .btn--lg {
    width: 100% !important;
    justify-content: center !important;
    height: 48px !important;
    font-size: 0.6875rem !important;
  }
}


/* ============================================================
   FIX 16 — index.html: Новинки grid — force 2-col on mobile
   .product-grid defaults to 4-col; on mobile it should be 2-col
   ============================================================ */
@media (max-width: 768px) {
  /* Homepage Новинки and Знижки grids */
  .section .product-grid {
    grid-template-columns: 1fr 1fr !important;
  }
}


/* ============================================================
   FIX 17 — index.html: section vertical spacing — too large
   .section has generous padding; tighten on mobile
   ============================================================ */
@media (max-width: 768px) {
  .section {
    padding-top: 32px !important;
    padding-bottom: 32px !important;
  }
  .section-head {
    margin-bottom: 16px !important;
  }
  .section-head__title {
    font-size: 1.125rem !important;
  }
}


/* ============================================================
   FIX 18 — index.html: Instagram section — collapse on mobile
   The 2-col grid with placeholder squares wastes huge space.
   Stack text over a compact placeholder grid.
   ============================================================ */
@media (max-width: 768px) {
  .insta-inner {
    grid-template-columns: 1fr !important;
    gap: 24px !important;
  }
  /* Compact the whole instagram section */
  .insta-inner + * ,
  section[style*="background:var(--bg-strip)"] {
    padding-top: 40px !important;
    padding-bottom: 40px !important;
  }
  /* Make placeholder image grid smaller */
  .insta-inner [style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr 1fr !important;
    gap: 3px !important;
  }
  .insta-inner [style*="aspect-ratio:1"] {
    aspect-ratio: 1 !important;
  }
  /* CTA button full-width */
  .insta-inner a[style*="border:1px solid"] {
    width: 100% !important;
    justify-content: center !important;
    text-align: center !important;
  }
}


/* ============================================================
   FIX 19 — index.html: cat-card text inside category cards
   Text labels get cramped at 2-col on small screens
   ============================================================ */
@media (max-width: 480px) {
  .cat-grid .cat-card [style*="font-size:1.25rem"] {
    font-size: 0.9375rem !important;
    line-height: 1.2 !important;
  }
  .cat-grid .cat-card [style*="padding:20px"] {
    padding: 12px !important;
  }
}

/* FIX 20 — hero buttons */
.hero__btn--primary { background:#fff !important; color:#0a0a0a !important; border:1px solid #fff !important; }
.hero__btn--ghost   { background:transparent !important; color:#fff !important; border:1px solid rgba(255,255,255,0.5) !important; }
@media (max-width:768px) {
  .hero__btns { display:flex; gap:8px; flex-direction:row !important; }
  .hero__btns .btn--lg { flex:1 !important; height:48px !important; font-size:0.625rem !important; padding:0 12px !important; justify-content:center !important; white-space:nowrap; }
}

/* FIX 21 — trust strip compact */
@media (max-width:768px) {
  .trust-item { padding:14px 0 !important; gap:12px !important; }
  .trust-item svg { width:20px !important; height:20px !important; }
  .trust-item p:last-child { font-size:0.8125rem !important; }
}

/* ============================================================
   FIX 23 — Trust strip: hide on mobile
   ============================================================ */
@media (max-width: 768px) {
  .trust-strip-section {
    display: none !important;
  }
}


/* ============================================================
   FIX 22 — Mobile hero: shorter height, text visible
   Desktop layout unchanged
   ============================================================ */
.hero__cta-mobile { display: none; }

@media (max-width: 768px) {
  /* Hide boxy desktop buttons on mobile */
  .hero__btns { display: none !important; }

  /* Show minimal CTA */
  .hero__cta-mobile {
    display: inline-block !important;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    letter-spacing: 0.04em;
    color: #fff;
    text-decoration: none;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.6);
  }

  /* SHORTER hero — fits in viewport with text + CTA visible */
  .hero {
    height: auto !important;
    min-height: 0 !important;
    aspect-ratio: 3/4 !important;
    max-height: 75vh !important;
  }

  /* Position content at bottom-center (Carhartt-style) */
  .hero__content {
    position: absolute !important;
    bottom: 32px !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    transform: none !important;
    padding: 0 var(--gutter) !important;
    text-align: center;
  }
  .hero__eyebrow {
    text-align: center;
    margin-bottom: 10px !important;
    color: rgba(255,255,255,0.7) !important;
    font-size: 0.625rem !important;
  }
  .hero__title {
    font-size: clamp(1.875rem, 8vw, 2.5rem) !important;
    margin-bottom: 18px !important;
    text-align: center;
    line-height: 1.1 !important;
  }
  .hero__actions {
    display: flex;
    justify-content: center;
  }
}

/* ============================================================
   FIX 24 — product.html mobile: swipeable image carousel
   Stronger selectors to beat inline <style> in product.html
   ============================================================ */
@media (max-width: 768px) {
  body .product__gallery,
  main .product__gallery,
  .product-detail .product__gallery {
    display: flex !important;
    grid-template-columns: none !important;
    overflow-x: auto !important;
    overflow-y: hidden !important;
    scroll-snap-type: x mandatory !important;
    scroll-behavior: smooth !important;
    gap: 0 !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    width: 100% !important;
  }
  body .product__gallery::-webkit-scrollbar,
  main .product__gallery::-webkit-scrollbar { display: none; }

  body .product__gallery .gallery__main,
  main .product__gallery .gallery__main,
  .product-detail .product__gallery .gallery__main {
    flex: 0 0 100% !important;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    scroll-snap-align: center !important;
    scroll-snap-stop: always !important;
    aspect-ratio: 3/4 !important;
    height: auto !important;
  }
}

/* ============================================================
   FIX 25 — Product page mobile: edge-to-edge images, Carhartt style
   ============================================================ */
@media (max-width: 768px) {
  /* Hide desktop breadcrumb */
  #product-breadcrumb-section {
    display: none !important;
  }

  /* Kill all wrapping container padding around gallery so it's truly edge-to-edge */
  .product-page-main .container,
  #product-section .container {
    padding-left: 0 !important;
    padding-right: 0 !important;
    max-width: 100% !important;
  }
  .product-detail {
    grid-template-columns: 1fr !important;
    gap: 0 !important;
  }

  /* Image counter overlay (5/6 style) */
  .product__gallery {
    position: relative !important;
  }
  .gallery-counter {
    position: absolute;
    bottom: 16px;
    right: 16px;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 6px 12px;
    border-radius: 999px;
    z-index: 2;
    pointer-events: none;
  }

  /* Info panel gets normal gutter padding */
  .product-info {
    padding: 24px var(--gutter) 40px !important;
  }

  /* Bigger, bolder price */
  .product-info__price {
    font-size: 1.375rem !important;
    font-weight: 600 !important;
    margin-bottom: 24px !important;
  }

  /* Size buttons: bigger tap targets */
  .size-btn {
    min-width: 56px !important;
    height: 48px !important;
    font-size: 0.8125rem !important;
  }

  /* Solid black add-to-cart when enabled */
  .product-info__actions .btn--primary:not(:disabled) {
    background: var(--ink) !important;
    color: var(--bg-elev) !important;
    border-color: var(--ink) !important;
  }
  .product-info__actions .btn--primary:disabled {
    opacity: 0.35;
    cursor: not-allowed;
  }

  /* Smaller heart */
  #btn-save {
    width: 48px !important;
    height: 48px !important;
    border: 1px solid var(--line) !important;
    background: var(--bg-elev) !important;
    flex-shrink: 0;
  }
}


/* ============================================================
   FIX 26 — Remove sticky bottom bar on mobile
   The inline add-to-cart button is enough, and forces user to
   actually pick a size before buying
   ============================================================ */
@media (max-width: 768px) {
  .product-sticky-bar {
    display: none !important;
  }
  body {
    padding-bottom: 0 !important;
  }
}

/* FIX 27 — Search input must be clickable + visible */
.search-overlay {
  pointer-events: none;
}
.search-overlay.is-open {
  pointer-events: auto !important;
}
.search-overlay.is-open .search-input,
.search-overlay.is-open .search-form,
.search-overlay.is-open .search-overlay__close {
  pointer-events: auto !important;
  position: relative;
  z-index: 10;
}
.search-overlay .search-input {
  cursor: text !important;
  color: var(--ink) !important;
  caret-color: var(--ink) !important;
  -webkit-user-select: text !important;
  user-select: text !important;
}

/* FIX 28 — Search input MUST be visible and typable */
.search-overlay {
  background: rgba(245, 243, 239, 0.99) !important;
}
.search-overlay .search-input {
  color: #000 !important;
  caret-color: #000 !important;
  font-size: 1.5rem !important;
  border-bottom: 2px solid #000 !important;
  background: transparent !important;
}
.search-overlay .search-input::placeholder {
  color: #8a8a86 !important;
  opacity: 1 !important;
}
.search-overlay,
.search-overlay * {
  pointer-events: auto;
}
.search-overlay:not(.is-open) {
  pointer-events: none;
}

/* ─────────────────────────────────────────
   iOS safe area — extend black top-strip into the notch
───────────────────────────────────────── */
@supports (padding-top: env(safe-area-inset-top)) {
  @media (max-width: 1024px) {
    .top-strip {
      height: calc(var(--strip-h) + env(safe-area-inset-top, 0px));
      padding-top: env(safe-area-inset-top, 0px);
    }
    .site-header {
      top: calc(var(--strip-h) + env(safe-area-inset-top, 0px));
    }
    body {
      padding-top: calc(var(--header-total) + env(safe-area-inset-top, 0px));
    }
  }
}
