/**
 * XSHIELD1 — Tools & Accessories Shop
 * ---------------------------------------------------------------------------
 * Scoped to page-custom-shop-tools.php only (see xshield1_tools_shop_enqueue_
 * assets() in inc/shop/shop-tools.php). Simple product grid — no fitment UI,
 * no filter/sort bar, no category tabs.
 */

.xs-tools-shop {
  padding-block: var(--xs-space-7) var(--xs-space-9);
}

.xs-tools-shop__title {
  margin: 0 0 var(--xs-space-6);
  font-size: var(--xs-fs-2xl);
  font-weight: var(--xs-fw-bold);
  letter-spacing: var(--xs-ls-wide);
  text-transform: uppercase;
}

.xs-tools-shop__empty {
  color: var(--xs-color-text-muted);
}

/* ---------------------------------------------------------------------------
 * Grid
 * ------------------------------------------------------------------------ */
.xs-tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--xs-space-6) var(--xs-space-5);
}

.xs-tool-card {
  display: flex;
  flex-direction: column;
}

/* ---------------------------------------------------------------------------
 * Image — simple zoom on hover, clipped by the wrapper's overflow:hidden.
 * Also the positioning context for .xs-tool-card__info below: the image's
 * aspect-ratio box has a fixed height that nothing inside it can change,
 * so the overlay expanding/collapsing can never push price/Add-to-Cart
 * (both in normal flow *after* this element) up or down.
 * ------------------------------------------------------------------------ */
.xs-tool-card__image {
  position: relative;
  overflow: hidden;
  aspect-ratio: 3 / 4;
  margin-bottom: var(--xs-space-3);
  background-color: var(--xs-color-surface);
}

.xs-tool-card__image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--xs-duration-slow) var(--xs-ease-standard);
}

.xs-tool-card:hover .xs-tool-card__image img {
  transform: scale(1.06);
}

/* ---------------------------------------------------------------------------
 * Name + description overlay (v0.1.65)
 * ---------------------------------------------------------------------------
 * Pinned to the bottom of .xs-tool-card__image (transparent-background
 * product photos, so overlaying text never hides anything meaningful).
 * Collapsed by default; hovering (desktop/pointer devices only — guarded
 * below so a tap on touch screens can't get "stuck" hovered) previews the
 * full description, and click/tap toggles .is-expanded to hold it open
 * regardless of hover, via assets/js/shop-tools.js.
 *
 * max-height: 100% + overflow-y: auto here is the hard safety cap — even
 * an unusually long description can only ever grow up to this box's own
 * height (fixed by the image's aspect-ratio above) and then scrolls
 * internally, never past it. Applied to every card uniformly regardless
 * of description length, per request.
 * ------------------------------------------------------------------------ */
.xs-tool-card__info {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--xs-space-3) var(--xs-space-3) var(--xs-space-2);
  background: linear-gradient(
    to top,
    rgba(255, 255, 255, 0.97) 60%,
    rgba(255, 255, 255, 0.82) 85%,
    rgba(255, 255, 255, 0) 100%
  );
  cursor: pointer;
}

.xs-tool-card__info--static {
  cursor: default;
}

.xs-tool-card__info:focus-visible {
  outline: 2px solid var(--xs-color-brand);
  outline-offset: -2px;
}

/* ---- Name — same thin red underline sweep as the primary nav
   (.xs-nav__list a::after in header-footer.css). ---- */
.xs-tool-card__name {
  position: relative;
  display: inline-block;
  width: fit-content;
  margin: 0 0 var(--xs-space-1);
  font-weight: var(--xs-fw-semibold);
  font-size: var(--xs-fs-base);
  color: var(--xs-color-text);
}

.xs-tool-card__name::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -2px;
  height: 2px;
  background-color: var(--xs-color-brand);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform var(--xs-duration-fast) var(--xs-ease-standard);
}

.xs-tool-card:hover .xs-tool-card__name::after,
.xs-tool-card:focus-within .xs-tool-card__name::after {
  transform: scaleX(1);
}

.xs-tool-card__desc {
  margin: 0;
  font-size: var(--xs-fs-sm);
  line-height: var(--xs-lh-snug);
  color: var(--xs-color-text-muted);

  /* Collapsed: clipped to ~2 lines (in em, so it tracks this element's
     own font-size/line-height rather than a guessed pixel value).
     Expanded (hover-preview or .is-expanded below): a generous fixed
     ceiling well beyond any real product description — the actual reveal
     is however tall the text really is; .xs-tool-card__info's own
     max-height:100%/overflow-y:auto above is what actually prevents
     overflow past the image, this value just has to be "big enough". */
  max-height: 2.7em;
  overflow: hidden;
  transition: max-height var(--xs-duration-slow) var(--xs-ease-standard);
}

@media (hover: hover) and (pointer: fine) {
  .xs-tool-card__image:hover .xs-tool-card__desc {
    max-height: 20em;
  }

  .xs-tool-card__image:hover .xs-tool-card__toggle-icon {
    transform: rotate(180deg);
  }
}

.xs-tool-card__info.is-expanded .xs-tool-card__desc {
  max-height: 20em;
}

.xs-tool-card__info.is-expanded .xs-tool-card__toggle-icon {
  transform: rotate(180deg);
}

/* Hidden by default — assets/js/shop-tools.js measures each description
   against its actual collapsed height and only adds .is-truncated (which
   reveals this) when there's genuinely more text than what's already
   showing. If JS never runs, the chevron simply never appears; the
   hover-preview/click-to-pin behavior it hints at also depends on that
   same script, so there's nothing it would be promising and failing to
   deliver on. */
.xs-tool-card__toggle-icon {
  display: none;
  width: 14px;
  height: 14px;
  margin: var(--xs-space-1) auto 0;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23666' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transition: transform var(--xs-duration-fast) var(--xs-ease-standard);
}

.xs-tool-card__info.is-truncated .xs-tool-card__toggle-icon {
  display: block;
}

.xs-tool-card__price {
  margin: 0 0 var(--xs-space-4);
  font-size: var(--xs-fs-sm);
  color: var(--xs-color-text-muted);
}

.xs-tool-card__form {
  display: flex;
  gap: var(--xs-space-2);
  margin-top: auto;
}

.xs-tool-card__qty {
  width: 4.5rem;
  padding: var(--xs-space-2);
  border: var(--xs-border-width) solid var(--xs-color-border);
  border-radius: 0;
  text-align: center;
  font-size: var(--xs-fs-sm);
  font-weight: var(--xs-fw-semibold);
  color: var(--xs-color-text);
}

.xs-tool-card__qty:focus {
  outline: none;
  border-color: var(--xs-color-focus-ring);
}

.xs-tool-card__cta {
  flex: 1;
}
