/* ==========================================================================
   Responsive layouts
   Breakpoints: 1180 (laptop), 960 (tablet landscape), 768 (tablet), 560 (mobile)
   ========================================================================== */

@media (max-width: 1180px) {
  .product-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .rail { grid-auto-columns: calc((100% - 3 * 20px) / 4); }
  .footer-grid { grid-template-columns: 1.4fr repeat(3, 1fr); gap: 28px; }
}

@media (max-width: 960px) {
  :root { --header-h: 66px; }

  /* Header: nav collapses into the slide-out menu */
  .header-inner { grid-template-columns: auto 1fr auto; }
  .main-nav { display: none; }
  .menu-btn { display: inline-grid; }
  .brand { justify-self: start; flex-shrink: 0; min-width: 0; }
  .header-actions { flex-shrink: 0; }
  .header-actions .icon-btn { flex-shrink: 0; }

  /* Hero stacks: artwork first gets too tall, so keep copy first with smaller art */
  .promo-banner {
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 12px 16px;
  }
  /* flex-basis must be 100% (not the base `flex: 1` = 0%), otherwise the text column never wraps onto its
     own row and is squeezed into whatever width the pill and button leave, i.e. one character per line. */
  .promo-banner__body {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
  }
  .promo-banner__ticker {
    white-space: normal;
    text-overflow: unset;
    flex-wrap: wrap;
    gap: 4px 8px;
    font-size: 0.85rem;
    line-height: 1.4;
  }
  .promo-banner__cta {
    order: 2;
  }
  /* The bullet only separates headline and text on one line; stacked on its own row it is just a stray dot. */
  .promo-banner__sep { display: none; }

  .hero-grid { grid-template-columns: 1fr; min-height: 0; gap: 8px; }
  .hero-art { justify-self: center; max-width: 520px; width: 92%; }

  /* :nth-child(n) matches the specificity of the desktop span rules so these resets win. */
  .category-grid,
  .category-grid[data-count] { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-auto-rows: 190px; }
  .category-grid[data-count] .category-tile:nth-child(n) { grid-column: auto; grid-row: auto; }
  /* Odd counts: the first tile spans the full row so no cell is left empty. */
  .category-grid[data-count='3'] .category-tile:first-child,
  .category-grid[data-count='5'] .category-tile:first-child,
  .category-grid[data-count='7'] .category-tile:first-child,
  .category-grid[data-count='9'] .category-tile:first-child,
  .category-grid[data-count='11'] .category-tile:first-child { grid-column: 1 / -1; }
  .category-grid[data-count='1'] { grid-template-columns: 1fr; }

  .quality { grid-template-columns: 1fr; }
  .quality-art { max-width: 640px; }

  .faq { grid-template-columns: 1fr; }

  .pdp { grid-template-columns: 1fr; }
  .pdp-media { position: relative; top: 0; max-width: 620px; width: 100%; margin-inline: auto; }

  .cart-layout, .checkout-layout, .order-layout { grid-template-columns: 1fr; }
  .summary-card { position: static; }
  /* On checkout the summary goes first so the total is visible before the form. */
  .checkout-layout .summary-card { order: -1; }

  .footer-grid { grid-template-columns: repeat(3, 1fr); }
  .footer-brand { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .product-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rail { grid-auto-columns: 46%; gap: 14px; }

  .section-head { flex-direction: column; align-items: flex-start; gap: 12px; }
  .rail-controls { display: none; }

  .shop-toolbar { position: static; }
  .shop-toolbar .search-field { max-width: none; flex-basis: 100%; }
  .shop-toolbar .select { flex: 1; min-width: 0; }
  .shop-toolbar__count { margin-left: 0; }

  .form-grid { grid-template-columns: 1fr; }

  .marquee { transform: none; margin-inline: 0; }
}

@media (max-width: 560px) {
  body { font-size: 15.5px; }

  .header-actions { gap: 2px; }
  .cart-btn { padding-inline: 12px; }
  .cart-btn__label { display: none; }
  .brand-logo { height: 54px; }

  .hero-title { font-size: clamp(2.5rem, 11.5vw, 3.2rem); }
  .hero-ctas .btn { flex: 1 1 100%; }
  .hero-art { width: 100%; }

  .category-grid,
  .category-grid[data-count] { grid-template-columns: 1fr; grid-auto-rows: 150px; }
  .category-grid[data-count] .category-tile:nth-child(n) { grid-column: auto; grid-row: auto; }
  .category-tile__img,
  .category-tile:first-child .category-tile__img { height: 72%; top: 14%; right: 6%; }

  .quality-list { grid-template-columns: 1fr; gap: 20px; }

  .product-grid { gap: 12px; }
  .product-card__media { margin: 6px 6px 0; padding: 12%; }
  .product-card__body { padding: 10px 10px 12px 12px; gap: 2px; }
  .product-card__name { font-size: 0.925rem; }
  .product-card__add { width: 36px; height: 36px; top: 8px; right: 8px; }
  .product-card__prices .price { font-size: 1.1rem; }
  .rail { grid-auto-columns: 64%; }

  .pdp-actions { grid-template-columns: 1fr; }
  .pdp-actions .stepper { justify-self: start; }

  .cart-line { grid-template-columns: 64px minmax(0, 1fr); }
  .cart-line__thumb { width: 64px; height: 64px; }
  .cart-line__total { grid-column: 2; padding-top: 0; }

  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-bottom { flex-direction: column; }

  .toast-region { bottom: 16px; }

  .modal__actions .btn { flex: 1; }
}

/* Hover-only effects shouldn't stick on touch devices. */
@media (hover: none) {
  .product-card:hover { transform: none; box-shadow: none; border-color: var(--color-line); }
  .product-card:hover .product-card__media img { transform: none; }
  .btn:hover { transform: none; box-shadow: none; }
  .category-tile:hover { transform: none; box-shadow: none; }
}

@media (min-width: 769px) and (max-width: 960px) {
  .product-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rail { grid-auto-columns: calc((100% - 2 * 20px) / 3); }
}

@media (max-width: 960px) {
  .custom-layout { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .cs-flow { gap: 8px 18px; font-size: 0.9rem; }
  .cs-drop { min-height: 180px; }
  .cs-sizes { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .account-btn { padding-inline: 12px; }
  .account-btn__label { display: none; }
}

@media (max-width: 768px) {
  .product-card__wish { width: 34px; height: 34px; top: 8px; left: 8px; }
  .mega-banner { min-height: auto; padding: 40px 18px; }
  .mega-sticker { opacity: 0.45; }
  .mega-sticker--1 { top: 2%; left: -10px; width: 85px; }
  .mega-sticker--2 { top: 3%; right: -10px; width: 80px; }
  .mega-sticker--3 { bottom: 4%; left: -10px; width: 75px; }
  .mega-sticker--4 { bottom: 3%; right: -10px; width: 80px; }
  .mega-banner__actions { flex-direction: column; width: 100%; }
  .mega-banner__cta-primary,
  .mega-banner__cta-secondary { width: 100%; justify-content: center; }
  .mega-banner__perks { flex-direction: column; gap: 8px; align-items: center; }
}

@media (max-width: 480px) {
  .mega-sticker { opacity: 0.28; }
}


/* Touch devices: grow the hit area of small round card buttons to ~44px without changing how they look. */
@media (pointer: coarse) {
  .product-card__wish, .product-card__add { position: absolute; }
  .product-card__wish::after, .product-card__add::after { content: ''; position: absolute; inset: -5px; }
}

/* Small phones: slimmer banner chrome so the label and button share one row where they fit. */
@media (max-width: 400px) {
  .promo-banner { padding: 12px 14px; gap: 8px 10px; }
  .promo-banner__pill { padding: 6px 10px; font-size: 0.75rem; }
  .promo-banner__cta { padding-inline: 12px; font-size: 0.8125rem; }
}

/* Long button labels (for example "Select state and city to continue") wrap instead of making the checkout wider than a 360px phone. */
@media (max-width: 420px) {
  .checkout-form .btn { white-space: normal; text-align: center; line-height: 1.25; }
}
