/*
 * tech-storefront — home page styles
 *
 * Surface: front-page.php (Balanced + Regular + Light only).
 * Port of pages-shop.jsx L7–230 (HomePage). Refined/power/dark/density
 * variants are intentionally NOT ported — add no qualified selectors for
 * those modes here.
 */

/* ------------------------------------------------------------------
 * Layout containers
 * ------------------------------------------------------------------ */

.home-main { font-family: var(--font-sans); }

.home-main .wrap {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
}
.home-main .wrap-narrow {
  max-width: 640px;
}

/* ------------------------------------------------------------------
 * Buttons (global primitives — used across home, shop, PDP, wishlist,
 * cart/checkout, contact, services, OOS modal, mobile drawer, etc.)
 *
 * T-118: dropped .home-main scope. .btn.primary is the product-card
 * quick-add button (parts/product-card.php) and renders on every
 * product surface, not just the home page. cart.css / shop.css ship
 * their own higher-specificity contextual overrides where needed.
 * ------------------------------------------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.65rem 1.1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn.primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn.primary:hover { background: var(--accent); border-color: var(--accent); text-decoration: none; }
.btn.sm { padding: 0.45rem 0.85rem; font-size: 0.875rem; }
.btn svg.tech-icon { width: 14px; height: 14px; }

/* Inputs stay home-scoped — cart.css / account.css ship their own .input
 * variants under .cart-wrap / .my-account parents. */
.home-main .input {
  display: block;
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  font: inherit;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.home-main .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ------------------------------------------------------------------
 * Section primitives
 * ------------------------------------------------------------------ */

.section    { padding: 2.5rem 0; }
.section-sm { padding: 1.5rem 0; }

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.section-head h2 {
  margin: 0;
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.section-head .eyebrow { margin-bottom: 0.4rem; }

.more {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color 160ms ease, gap 160ms ease;
}
.more:hover { color: var(--brand); gap: 0.55rem; text-decoration: none; }
.more svg.tech-icon { width: 14px; height: 14px; }

/* Eyebrow tone modifiers (base .eyebrow lives in misc.css) */
.eyebrow-coral { color: var(--brand); }
.eyebrow-teal  { color: var(--accent); }
.eyebrow-sale  { color: #c4421b; }

/* ------------------------------------------------------------------
 * Home welcome (hero)
 * ------------------------------------------------------------------ */

.home-welcome {
  padding: 2.5rem 0 1rem;
  background: linear-gradient(180deg, var(--paper-2) 0%, var(--paper) 100%);
  border-bottom: 1px solid var(--line);
}
.home-welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.25rem;
}
.home-welcome .eyebrow { margin: 0; }
.home-h {
  font-family: var(--font-sans);
  font-size: clamp(2rem, 4vw + 1rem, 3.25rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
  color: var(--ink);
  max-width: 22ch;
}

.hero-search {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 640px;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.hero-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow);
}
.hero-search svg.tech-icon {
  color: var(--ink-3);
  flex: 0 0 auto;
}
.hero-search .search-field {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  outline: none;
  min-width: 0;
  padding: 0.4rem 0;
}
.hero-search .search-field::placeholder { color: var(--ink-3); }
.hero-search .btn {
  border-radius: 999px;
  padding: 0.55rem 1.25rem;
  flex: 0 0 auto;
}
.balanced-search { /* explicit selector parity with prototype */ }

/* ------------------------------------------------------------------
 * Category grid (4x2 — featured categories)
 * ------------------------------------------------------------------ */

/* T-131: compact "Browse featured" tiles — horizontal layout, ~3x shorter */

.cat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

@media (max-width: 1100px) {
  .cat-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* T-133: 2 columns at ≤900px (was 760px) — tablet portrait + phone */
@media (max-width: 900px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 8px;
  }
}

/* T-211: stay 2-col on every mobile width — never collapse to 1-col */
@media (max-width: 440px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
  }
}

/* T-211: at very narrow widths, tile content shrinks proportionally rather than dropping to 1-col */
@media (max-width: 360px) {
  .cat-grid {
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
  }

  .cat-card {
    height: 72px;
    padding: 0 8px;
    gap: 8px;
  }

  .cat-card .cat-img {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
  }

  .cat-card .glyph {
    font-size: 24px;
  }

  .cat-card .cat-body h3 {
    font-size: 12px;
  }

  .cat-card .cat-body .count {
    font-size: 11px;
  }
}

.cat-card {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  height: 92px;
  padding: 0 16px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
  overflow: hidden;
}

.cat-card:hover {
  border-color: var(--brand);
  background: var(--paper-2);
}

/* Image / glyph area — small fixed-size square on the left */
.cat-card .cat-img {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--paper-2);
}

.cat-card.tone-coral .cat-img { background: rgba(236, 110, 77, 0.12); }
.cat-card.tone-teal  .cat-img { background: rgba(77, 170, 167, 0.12); }
.cat-card.tone-amber .cat-img { background: rgba(244, 185, 78, 0.18); }

.cat-card .glyph {
  font-size: 32px;
  line-height: 1;
}

/* Body — text right of the icon */
.cat-card .cat-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cat-card .cat-body h3,
.cat-card h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cat-card .cat-body .count,
.cat-card .count {
  font-size: 12px;
  color: var(--ink-3);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.cat-card .cat-body .count svg,
.cat-card .count svg {
  width: 12px;
  height: 12px;
  color: var(--accent);
}

/* Hide blurb text in compact mode to save vertical space */
.cat-card .cat-body .blurb {
  display: none;
}

/* Mobile: even tighter — 80px tall */
@media (max-width: 760px) {
  .cat-card {
    height: 80px;
    padding: 0 12px;
    gap: 10px;
  }
  .cat-card .cat-img {
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
  }
  .cat-card .glyph {
    font-size: 28px;
  }
  .cat-card .cat-body h3 {
    font-size: 13px;
  }
}

/* ------------------------------------------------------------------
 * Brand row (5x2 — popular brands)
 * ------------------------------------------------------------------ */

.brand-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}
.brand-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 80px;
  padding: 0.75rem 1rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 0.9375rem;
  text-align: center;
  transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}
.brand-tile:hover {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--shadow);
  text-decoration: none;
}
.brand-tile img {
  max-height: 48px;
  width: auto;
  object-fit: contain;
}

/* ------------------------------------------------------------------
 * Product carousel
 * ------------------------------------------------------------------ */

.product-carousel {
  position: relative;
}
.carousel-track {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-padding: 1rem;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.5rem;
  scrollbar-width: thin;
}
.carousel-track::-webkit-scrollbar { height: 6px; }
.carousel-track::-webkit-scrollbar-thumb {
  background: var(--line-2);
  border-radius: 999px;
}
.carousel-track > .product-card {
  flex: 0 0 240px;
  scroll-snap-align: start;
}
.carousel-btn {
  position: absolute;
  top: 38%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  color: var(--ink-2);
  z-index: 2;
  transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.carousel-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.carousel-btn[hidden] { display: none; }
.carousel-btn-prev { left: -0.5rem; }
.carousel-btn-next { right: -0.5rem; }

/* ------------------------------------------------------------------
 * Product card
 * ------------------------------------------------------------------ */

.product-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  gap: 0.5rem;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.product-card:hover {
  border-color: var(--ink-3);
  box-shadow: var(--shadow);
}
.product-card.is-oos { opacity: 0.85; }

.card-link {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: var(--ink);
  text-decoration: none;
}
.card-link:hover { text-decoration: none; }

.card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 180px;
  background: var(--paper-2);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin: 0 0 8px 0;
}
.card-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.card-img-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--paper-2);
  color: var(--ink-3);
}
.card-img-placeholder svg {
  width: 40px;
  height: 40px;
  opacity: 0.5;
}
.card-brand {
  font-size: 0.6875rem;
  letter-spacing: 0.08em;
  color: var(--ink-3);
  font-weight: 600;
}
.card-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-price {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
}
.card-price del { color: var(--ink-3); font-weight: 400; margin-right: 0.4rem; }
.card-price ins { text-decoration: none; color: var(--brand); }

.card-badge {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  padding: 0.2rem 0.55rem;
  font-size: 0.625rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 999px;
  z-index: 1;
}
.badge-sale { background: var(--brand); color: #fff; }
.badge-oos  { background: var(--ink-3); color: #fff; }

.card-wish {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink-3);
  z-index: 1;
  transition: color 160ms ease, border-color 160ms ease, background-color 160ms ease;
}
.card-wish:hover,
.card-wish.is-active {
  color: var(--brand);
  border-color: var(--brand);
  background: var(--brand-soft);
}

.card-add { margin: 0; }
.card-add-btn { width: 100%; }

.btn-notify {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem;
  border: 1px dashed var(--line-2);
  background: var(--paper-2);
  color: var(--ink-2);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease;
}
.btn-notify:hover { border-color: var(--accent); color: var(--accent); }
.btn-notify svg.tech-icon { width: 14px; height: 14px; }

/* ------------------------------------------------------------------
 * Newsletter card
 * ------------------------------------------------------------------ */

.newsletter-card {
  text-align: center;
  padding: 2.25rem 1.5rem;
  background: var(--paper-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}
.newsletter-card h2 {
  font-family: var(--font-sans);
  font-size: 1.75rem;
  font-weight: 600;
  margin: 0;
}
.newsletter-card .soft { margin: 0 0 0.5rem; }
.newsletter-form {
  display: flex;
  gap: 0.5rem;
  width: 100%;
  max-width: 460px;
  margin-top: 0.5rem;
}
.newsletter-form .input { flex: 1; }
.newsletter-msg {
  margin: 0.25rem 0 0;
  font-size: 0.875rem;
  font-weight: 600;
}
.newsletter-msg.ok  { color: var(--accent); }
.newsletter-msg.err { color: #c4421b; }

/* ------------------------------------------------------------------
 * Mobile breakpoints
 * ------------------------------------------------------------------ */

@media (max-width: 900px) {
  .section          { padding: 2rem 0; }
  .section-head h2  { font-size: 1.5rem; }
  /* T-133: .cat-grid now handled by the dedicated T-133 block above (≤900px 2-col, ≤440px 1-col) */
  .brand-row        { grid-template-columns: repeat(4, 1fr); }
  .carousel-track > .product-card { flex-basis: 200px; }
  .carousel-btn { display: none; }
  .home-welcome { padding: 2rem 0 0.5rem; }
}

@media (max-width: 520px) {
  /* T-133: .cat-grid 1-col threshold moved to ≤440px (see T-133 block above) */
  .brand-row        { grid-template-columns: repeat(2, 1fr); }
  .carousel-track > .product-card { flex-basis: 170px; }
  .newsletter-form  { flex-direction: column; }
  .hero-search .btn span { display: none; }
}

/* T-130 / T-203: card title — 12.5px + hyphens auto so short titles like
 * "Cervical Massager" no longer truncate to "Cervica…" inside narrow cards. */
.product-card .card-title,
ul.products li.product .card-title,
.prod-grid .product-card .card-title {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
  line-height: 1.35;
  min-height: 2.7em;
  max-height: 2.7em;
  margin: 0 0 6px 0;
  font-weight: 500;
  color: var(--ink);
  word-break: break-word;
  hyphens: auto;
}

/* ------------------------------------------------------------------
 * T-127: uniform product-card heights — stretch each card to row
 * height, reserve brand-line space when missing, anchor action
 * button to card bottom. Pairs with grid-auto-rows: 1fr in shop.css.
 * T-203: min-height lowered 380→300 — short-content cards (no image
 * + short title) were padding ~80px of empty white between price and
 * action button.
 * ------------------------------------------------------------------ */
.product-card {
  height: 100%;
  min-height: 300px;
}

.product-card .card-link {
  flex: 1;
  min-height: 0;
}

.product-card .card-link:not(:has(> .card-brand)) > .card-title::before {
  content: "";
  display: block;
  height: 14px;
}

.product-card .card-add,
.product-card .card-add-btn,
.product-card .card-select-options,
.product-card .ajax_add_to_cart,
.product-card .btn-notify {
  margin-top: auto;
}

/* ------------------------------------------------------------------
 * T-203: tighter brand/price/link spacing — reduce empty space inside
 * cards with short content so the action button doesn't sit ~80px
 * below the price on no-image / short-title products.
 * ------------------------------------------------------------------ */
.product-card .card-brand {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-3);
  margin: 0 0 4px 0;
  height: 14px;
  line-height: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-card .card-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 10px 0;
  min-height: auto;
  line-height: 1.25;
}

.product-card .card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-decoration: none;
  color: inherit;
  min-height: 0;
  gap: 0;
}
