/* ============================================================
   4Tex Spare Parts Shop — shop.css
   Shop-specific components: category tiles, product grid/cards,
   filters, toolbar, pagination, product detail, cart drawer,
   account/checkout placeholders.
   ============================================================ */

/* ---- Category tiles (shop overview) ------------------------ */
.cat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: clamp(1rem, 2vw, 1.75rem); }
.cat-tile {
  position: relative; display: flex; flex-direction: column; gap: .9rem;
  padding: clamp(1.75rem, 3vw, 2.25rem); background: #fff;
  border: 2px solid var(--border-strong); border-radius: var(--radius);
  overflow: hidden; isolation: isolate;
  transition: border-color .3s var(--ease), transform .3s var(--ease), box-shadow .3s var(--ease), background .3s var(--ease);
}
.cat-tile::before {
  content: ""; position: absolute; inset: auto 0 0 auto; width: 40px; height: 40px;
  background: linear-gradient(135deg, transparent 45%, var(--nav-blue) 45%);
  opacity: .9; pointer-events: none; transition: width .35s var(--ease), height .35s var(--ease);
}
.cat-tile:hover, .cat-tile:focus-visible {
  border-color: var(--nav-blue); transform: translateY(-5px);
  box-shadow: 0 16px 36px rgba(0,90,156,.16); background: rgba(0,90,156,.03);
}
.cat-tile:hover::before, .cat-tile:focus-visible::before { width: 58px; height: 58px; }
.cat-tile__icon {
  width: 48px; height: 48px; border-radius: 12px; color: #fff;
  background: linear-gradient(135deg, var(--navy-600), var(--navy-800));
  display: grid; place-items: center;
}
.cat-tile__icon svg { width: 22px; height: 22px; }
.cat-tile__name { font-family: var(--font-black); font-weight: 900; color: var(--text-strong);
  font-size: clamp(1.1rem, 1rem + .5vw, 1.4rem); line-height: 1.2; }
.cat-tile__desc { font-size: .9rem; color: var(--text-muted); }
.cat-tile__meta { display: flex; align-items: center; gap: .5rem; margin-top: auto; padding-top: .6rem;
  font-family: var(--font-display); font-weight: 700; font-size: .78rem; letter-spacing: .08em;
  text-transform: uppercase; color: var(--nav-blue); }
.cat-tile__meta .arrow { width: 14px; height: 14px; transition: transform .3s var(--ease); }
.cat-tile:hover .cat-tile__meta .arrow { transform: translateX(4px); }

.subcat-row { display: flex; flex-wrap: wrap; gap: .6rem; }
.subcat-chip {
  display: inline-flex; align-items: center; gap: .4rem; padding: .55rem 1.05rem;
  border-radius: 100px; border: 1px solid var(--border-strong); background: #fff;
  font-family: var(--font-display); font-weight: 600; font-size: .82rem; color: var(--text-muted);
  transition: color .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
}
.subcat-chip:hover, .subcat-chip.is-active { color: var(--nav-blue); border-color: var(--nav-blue); background: rgba(0,90,156,.06); }
.subcat-chip__count { color: var(--grey-400); font-size: .76rem; }

/* ---- Shop layout: sidebar + content ------------------------ */
.shop-layout { display: grid; grid-template-columns: 260px 1fr; gap: var(--sp-5); align-items: start; }

/* ---- Filter sidebar ------------------------------------------ */
.filters { position: sticky; top: calc(var(--header-h) + 24px); display: flex; flex-direction: column; gap: var(--sp-4); }
.filter-group { border-bottom: 1px solid var(--border); padding-bottom: var(--sp-3); }
.filter-group:last-child { border-bottom: none; }
.filter-group h4 { font-size: .78rem; font-family: var(--font-mono); font-weight: 900;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-strong); margin-bottom: .9rem; }
.filter-list { display: flex; flex-direction: column; gap: .55rem; }
.filter-option { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--text-muted);
  cursor: pointer; }
.filter-option input { width: 16px; height: 16px; accent-color: var(--nav-blue); flex-shrink: 0; }
.filter-option:hover { color: var(--text); }
.filter-option__count { margin-left: auto; color: var(--grey-400); font-size: .8rem; }
.filter-clear { font-size: .82rem; color: var(--nav-blue); font-family: var(--font-display); font-weight: 600; }
.filters__close { display: none; }

/* ---- Toolbar (result count + sort) ---------------------------- */
.shop-toolbar { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3);
  margin-bottom: var(--sp-4); padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.shop-toolbar__count { font-size: .92rem; color: var(--text-muted); }
.shop-toolbar__count strong { color: var(--text-strong); }
.shop-toolbar__right { display: flex; align-items: center; gap: .8rem; }
.sort-select {
  padding: .6rem .9rem; border: 1px solid var(--border-strong); border-radius: var(--radius);
  font-size: .86rem; color: var(--text); background: #fff;
}
.filter-toggle { display: none; }

/* ---- Product grid & card --------------------------------------- */
.product-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); }
.product-card {
  display: flex; flex-direction: column; height: 100%; background: #fff;
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
  transition: transform .3s var(--ease), box-shadow .3s var(--ease), border-color .3s var(--ease);
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.product-card__media { position: relative; aspect-ratio: 1/1; background: #fff; overflow: hidden; }
.product-card__media img { width: 100%; height: 100%; object-fit: cover; display: block;
  transition: transform .5s var(--ease); }
.product-card:hover .product-card__media img { transform: scale(1.05); }
.product-card__badges { position: absolute; top: .7rem; left: .7rem; display: flex; flex-direction: column; gap: .4rem; }
.product-card__cat { position: absolute; top: .7rem; right: .7rem; }
.product-card__body { display: flex; flex-direction: column; gap: .4rem; padding: 1.1rem 1.25rem 1.3rem; flex: 1; }
.product-card__eyebrow { font-family: var(--font-display); font-size: .72rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--nav-blue); }
.product-card__name { font-family: var(--font-display); font-weight: 700; font-size: 1rem;
  color: var(--text-strong); line-height: 1.35; }
.product-card__sku { font-family: var(--font-mono); font-size: .7rem; color: var(--grey-400); letter-spacing: .03em; }
.product-card__desc { font-size: .85rem; color: var(--text-muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.product-card__footer { display: flex; align-items: center; justify-content: flex-end; gap: .75rem;
  margin-top: auto; padding-top: .8rem; }
.product-card__cart {
  width: 42px; height: 42px; border-radius: var(--radius); flex-shrink: 0;
  background: var(--navy-800); color: #fff; display: grid; place-items: center;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.product-card__cart:hover { background: var(--navy-700); transform: translateY(-2px); }
.product-card__cart svg { width: 18px; height: 18px; }

.empty-state { display: flex; flex-direction: column; align-items: center; gap: .6rem;
  text-align: center; padding: var(--sp-7) var(--sp-3); color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; color: var(--grey-400); margin-bottom: .4rem; }
.empty-state h3 { color: var(--text-strong); }
.empty-state p { margin-bottom: .6rem; max-width: 32ch; }
.empty-state .btn { margin-top: .6rem; }

/* ---- No-photo placeholder: faint 4Tex mark instead of a broken-image icon ---- */
.no-photo { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.no-photo__mark {
  width: 52%; height: 52%;
  background: var(--grey-400);
  opacity: .4;
  -webkit-mask: var(--logo-src) no-repeat center / contain;
          mask: var(--logo-src) no-repeat center / contain;
}
:root[data-theme="dark"] .no-photo__mark { background: var(--grey-400); opacity: .3; }
.search-results__thumb .no-photo__mark { width: 60%; height: 60%; }

/* ---- Pagination -------------------------------------------------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: .4rem; margin-top: var(--sp-6); }
.pagination a, .pagination span {
  min-width: 40px; height: 40px; padding: 0 .5rem; display: grid; place-items: center;
  border-radius: var(--radius); font-family: var(--font-display); font-weight: 600; font-size: .88rem;
  color: var(--text-muted); border: 1px solid transparent;
}
.pagination a:hover { border-color: var(--border-strong); color: var(--nav-blue); }
.pagination .is-active { background: var(--navy-800); color: #fff; }

/* ---- Live search dropdown -------------------------------------- */
.search-results {
  position: absolute; top: calc(100% + 10px); right: 0; width: min(420px, 92vw);
  max-height: 70vh; overflow-y: auto; background: #fff; border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg); box-shadow: 0 18px 44px rgba(0,0,0,.14), 0 2px 8px rgba(0,0,0,.06);
  opacity: 0; visibility: hidden; transform: translateY(6px); z-index: 120;
  transition: opacity .2s var(--ease), transform .2s var(--ease), visibility 0s linear .2s;
}
.search-results.is-open { opacity: 1; visibility: visible; transform: none;
  transition: opacity .2s var(--ease), transform .2s var(--ease); }
.search-results__item { display: flex; align-items: center; gap: .9rem; padding: .8rem 1rem;
  border-bottom: 1px solid var(--border); }
.search-results__item:last-child { border-bottom: none; }
.search-results__item:hover { background: var(--bg-alt); }
.search-results__thumb { width: 46px; height: 46px; border-radius: 8px; background: #fff;
  border: 1px solid var(--border); flex-shrink: 0; display: grid; place-items: center; overflow: hidden; }
.search-results__thumb img { width: 100%; height: 100%; object-fit: cover; }
.search-results__name { font-size: .88rem; font-weight: 600; color: var(--text-strong); line-height: 1.3; }
.search-results__cat { font-size: .74rem; color: var(--text-muted); }
.search-results__empty, .search-results__footer { padding: 1.1rem; text-align: center; font-size: .86rem; color: var(--text-muted); }
.search-results__footer a { font-weight: 600; }
mark { background: rgba(0,90,156,.16); color: inherit; border-radius: 3px; padding: 0 .1em; }

/* ---- Cart drawer (placeholder — ready for backend wiring) ------- */
.cart-drawer {
  position: fixed; inset: 0 0 0 auto; width: min(420px, 92vw); background: #fff;
  z-index: 200; box-shadow: -18px 0 50px rgba(0,0,0,.18);
  transform: translateX(100%); transition: transform .35s var(--ease);
  display: flex; flex-direction: column;
}
.cart-drawer.is-open { transform: translateX(0); }
.cart-drawer__head { display: flex; align-items: center; justify-content: space-between;
  padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border); }
.cart-drawer__head h3 { font-size: 1.1rem; }
.cart-drawer__close { width: 38px; height: 38px; border-radius: 100px; display: grid; place-items: center;
  color: var(--text-muted); }
.cart-drawer__close:hover { color: var(--nav-blue); background: var(--bg-alt); }
.cart-drawer__body { flex: 1; overflow-y: auto; padding: var(--sp-4); display: flex; flex-direction: column;
  align-items: center; justify-content: center; text-align: center; gap: var(--sp-2); }
.cart-drawer__body svg { width: 56px; height: 56px; color: var(--grey-400); }
.cart-drawer__body p { color: var(--text-muted); max-width: 30ch; }
.cart-drawer__foot { padding: var(--sp-4); border-top: 1px solid var(--border); }

/* ---- Quantity stepper -------------------------------------------- */
.qty-stepper { display: inline-flex; align-items: center; border: 1px solid var(--border-strong);
  border-radius: var(--radius); overflow: hidden; }
.qty-stepper button { width: 38px; height: 38px; display: grid; place-items: center; color: var(--text-muted); }
.qty-stepper button:hover { color: var(--nav-blue); background: var(--bg-alt); }
.qty-stepper input { width: 46px; height: 38px; text-align: center; border: none; border-left: 1px solid var(--border-strong);
  border-right: 1px solid var(--border-strong); color: var(--text-strong); }
.qty-stepper--sm button { width: 30px; height: 30px; }
.qty-stepper--sm input { width: 36px; height: 30px; font-size: .85rem; }

/* ---- Add-to-inquiry button ---------------------------------------- */
.add-to-cart-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .55rem; height: 42px; padding: 0 1rem;
  border-radius: var(--radius); background: var(--navy-800); color: #fff;
  font-family: var(--font-display); font-weight: 600; font-size: .82rem;
  transition: background .25s var(--ease), transform .25s var(--ease);
}
.add-to-cart-btn:hover { background: var(--navy-700); transform: translateY(-2px); }
.add-to-cart-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.add-to-cart-btn.is-added { background: #2b6a43; }
.product-card__cart.add-to-cart-btn { width: 42px; height: 42px; padding: 0; }

/* ---- Inquiry list (cart drawer + cart page) ------------------------ */
.cart-list { display: flex; flex-direction: column; gap: 1rem; }
.cart-line { display: flex; gap: .85rem; }
.cart-line__thumb { width: 58px; height: 58px; border-radius: var(--radius); background: #fff;
  border: 1px solid var(--border); flex-shrink: 0; display: grid; place-items: center; overflow: hidden; }
.cart-line__thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-line__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: .3rem; }
.cart-line__name { font-size: .9rem; font-weight: 600; color: var(--text-strong); line-height: 1.35; }
.cart-line__sku { font-family: var(--font-mono); font-size: .68rem; color: var(--grey-400); letter-spacing: .03em; }
.cart-line__row { display: flex; align-items: center; justify-content: space-between; gap: .75rem; margin-top: .25rem; }
.cart-line__remove { width: 32px; height: 32px; border-radius: var(--radius); display: grid; place-items: center; color: var(--grey-400); }
.cart-line__remove:hover { color: #b23; background: var(--bg-alt); }
.cart-line__remove svg { width: 16px; height: 16px; }

.cart-drawer__body { align-items: stretch; text-align: left; padding: var(--sp-3) var(--sp-4); gap: 0; }
.cart-drawer__body .empty-state { padding: var(--sp-6) var(--sp-2); }
.cart-drawer .cart-list { padding-bottom: var(--sp-3); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); }
.cart-drawer [data-cart-form-wrap] .form-field { margin-bottom: .75rem; }
.cart-drawer [data-cart-form-wrap] .form-field input { padding: .6rem .8rem; font-size: .88rem; }

.cart-page-layout { display: grid; grid-template-columns: minmax(0,1.4fr) minmax(0,1fr); gap: clamp(2rem,4vw,3.5rem); align-items: start; }
.cart-page-layout .cart-list { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-3); background: #fff; }
.cart-summary { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--sp-4); background: #fff; position: sticky; top: calc(var(--header-h) + 24px); }
.cart-summary h3 { margin-bottom: .3rem; }
.cart-summary__meta { font-size: .86rem; color: var(--text-muted); margin-bottom: var(--sp-3); }

.form-status--info { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border-strong);
  padding: var(--sp-2); border-radius: var(--radius); font-size: .86rem; margin-top: var(--sp-3); display: none; }
.form-status--info.is-visible { display: block; }

/* Product photos keep a white mount even in dark mode (see tokens.css note). */
:root[data-theme="dark"] .cart-page-layout .cart-list,
:root[data-theme="dark"] .cart-summary { background: #121A25; }

/* ---- Product detail ---------------------------------------------- */
.product-detail { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: clamp(2rem,5vw,4rem); }
.product-gallery__main { aspect-ratio: 1/1; margin-bottom: var(--sp-2); }
.product-gallery__thumbs { display: flex; gap: .6rem; flex-wrap: wrap; }
.product-gallery__thumb { width: 68px; height: 68px; border-radius: var(--radius); background: #fff;
  border: 2px solid var(--border); overflow: hidden; }
.product-gallery__thumb.is-active { border-color: var(--nav-blue); }
.product-gallery__thumb img { width: 100%; height: 100%; object-fit: cover; }

.product-info__cat { font-family: var(--font-display); font-size: .8rem; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase; color: var(--nav-blue); }
.product-info h1 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.3rem); margin: .5rem 0 .6rem; }
.product-info__sku { font-family: var(--font-mono); font-size: .78rem; color: var(--grey-400); margin-bottom: var(--sp-3); }
.product-info__price { font-family: var(--font-black); font-size: clamp(1.5rem, 1.2rem + .8vw, 2rem);
  color: var(--navy-800); margin-bottom: var(--sp-2); }
.product-info__desc { color: var(--text-muted); line-height: 1.7; margin-bottom: var(--sp-4); }
.product-info__actions { display: flex; align-items: center; gap: 1rem; margin-bottom: var(--sp-4); flex-wrap: wrap; }
.product-info__meta { display: flex; flex-direction: column; gap: .5rem; font-size: .88rem; color: var(--text-muted);
  padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.product-info__meta strong { color: var(--text-strong); }

/* ---- Placeholder notice (login/checkout/cart not yet wired) ------ */
.notice {
  display: flex; gap: .8rem; align-items: flex-start; padding: 1rem 1.2rem;
  border: 1px dashed var(--border-strong); border-radius: var(--radius);
  background: var(--bg-alt); font-size: .86rem; color: var(--text-muted);
}
.notice svg { width: 20px; height: 20px; flex-shrink: 0; color: var(--nav-blue); margin-top: .1rem; }
.notice strong { color: var(--text-strong); }

/* ---- Coming-soon page (account / checkout) ----------------------- */
.stub-page { max-width: 40rem; margin-inline: auto; text-align: center; padding-block: var(--sp-6); }
.stub-page__icon { width: 76px; height: 76px; margin: 0 auto var(--sp-3); border-radius: 20px;
  background: linear-gradient(135deg, var(--navy-600), var(--navy-800)); color: #fff;
  display: grid; place-items: center; }
.stub-page__icon svg { width: 34px; height: 34px; }

/* ============================================================
   DARK MODE overrides
   ============================================================ */
:root[data-theme="dark"] .cat-tile { background: #121A25; }
:root[data-theme="dark"] .cat-tile:hover { background: rgba(79,163,227,.06); box-shadow: 0 16px 36px rgba(0,0,0,.5); }
:root[data-theme="dark"] .subcat-chip { background: #121A25; }
:root[data-theme="dark"] .sort-select { background: #121A25; color: #F3F6FA; border-color: #2C3848; }
:root[data-theme="dark"] .product-card { background: #121A25; }
/* Product photos keep a white mount even in dark mode (see tokens.css note). */
:root[data-theme="dark"] .search-results { background: #121A25; border-color: #2C3848; box-shadow: 0 18px 44px rgba(0,0,0,.55); }
:root[data-theme="dark"] .search-results__item:hover { background: #0E141D; }
:root[data-theme="dark"] .search-results__thumb { background: #0E141D; }
:root[data-theme="dark"] .cart-drawer { background: #0D1219; box-shadow: -18px 0 50px rgba(0,0,0,.5); }
:root[data-theme="dark"] .cart-drawer__head, :root[data-theme="dark"] .cart-drawer__foot { border-color: #1D2734; }
:root[data-theme="dark"] .qty-stepper, :root[data-theme="dark"] .qty-stepper input { border-color: #2C3848; }
:root[data-theme="dark"] .notice { background: #10161F; }
:root[data-theme="dark"] mark { background: rgba(79,163,227,.28); }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 1200px) {
  .cat-grid { grid-template-columns: repeat(2, 1fr); }
  .product-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 992px) {
  /* minmax(0, 1fr) not bare 1fr — a plain 1fr track's minimum size defaults
     to its content's min-content width, so a single wide product image/name
     could blow the whole grid past the viewport on phones. minmax(0, 1fr)
     lets the track actually shrink to the available width. */
  .shop-layout { grid-template-columns: minmax(0, 1fr); }
  .filters {
    position: fixed; inset: 0 auto 0 0; width: min(320px, 88vw); z-index: 150;
    background: #fff; padding: var(--sp-4); padding-top: calc(var(--sp-3) + 38px + var(--sp-2));
    overflow-y: auto;
    transform: translateX(-100%); transition: transform .3s var(--ease);
    box-shadow: 18px 0 50px rgba(0,0,0,.16);
  }
  .filters.is-open { transform: translateX(0); }
  .filter-toggle { display: inline-flex; }
  .filters__close {
    display: grid; place-items: center; width: 38px; height: 38px;
    border-radius: 100px; color: var(--text-muted);
    position: absolute; top: var(--sp-3); right: var(--sp-3);
  }
  .filters__close:hover { color: var(--nav-blue); background: var(--bg-alt); }
  .header-search__input { width: 130px; }
  .header-search__input:focus { width: 180px; }
}
:root[data-theme="dark"] .filters { background: #0D1219; }
@media (max-width: 768px) {
  .product-detail { grid-template-columns: 1fr; }
  .cart-page-layout { grid-template-columns: 1fr; }
  .cart-summary { position: static; }
}
@media (max-width: 640px) {
  .cat-grid { grid-template-columns: minmax(0, 1fr); }
  /* Phones: one product per row (stacked) — the two-up layout was too
     cramped and clipped card content on narrow screens. minmax(0, 1fr)
     (not bare 1fr) so the track can actually shrink to fit — see the
     min-width note on .shop-layout above. */
  .product-grid { grid-template-columns: minmax(0, 1fr); gap: var(--sp-3); }
  .shop-toolbar { flex-direction: column; align-items: flex-start; }
  .header-search__input { width: 100px; }
}
