/* ---------------------------------------------------------------------------
   JoTrack device store — listing page.

   Layered on top of site.css and uses ITS tokens only (--bg-card, --border,
   --accent, …) so the store follows the light/dark toggle for free. Everything
   is scoped under .store-page: NEVER write a bare .card rule in this project,
   because CMS Kit wraps page content in <abp-card> and a loose selector paints
   the whole page. Logical properties throughout so RTL mirrors itself.
--------------------------------------------------------------------------- */

.store-page {
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  gap: 40px;
  max-width: 1208px;
  margin: 0 auto;
  padding: 40px 24px 88px;
  align-items: start;
}

/* ------------------------------------------------------------- toolbar --- */

.store-toolbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.store-search {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 260px;
  max-width: 420px;
}

.store-search input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 10px 14px;
}

.store-search input:focus-visible,
.store-sort select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.store-sort {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.92rem;
  color: var(--text-dim);
  white-space: nowrap;
}

.store-sort select {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 9px 12px;
}

.store-count {
  font-size: 0.9rem;
  color: var(--text-dim);
}

.store-icon {
  width: 17px;
  height: 17px;
  flex: none;
  color: var(--text-dim);
}

/* -------------------------------------------------------------- filters --- */

.store-filters {
  position: sticky;
  top: calc(var(--header-h) + 16px);
}

.store-filters-head {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  font-size: 1.05rem;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.facet-group {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}

.facet-group > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  list-style: none;
  font-weight: 650;
  font-size: 0.97rem;
  padding: 14px 0;
  color: var(--text);
}

.facet-group > summary::-webkit-details-marker { display: none; }

.facet-group > summary::after {
  content: "";
  width: 9px;
  height: 9px;
  border-inline-end: 2px solid var(--text-dim);
  border-block-end: 2px solid var(--text-dim);
  transform: rotate(-135deg);
  transition: transform 0.2s ease;
  margin-block-start: 4px;
}

.facet-group:not([open]) > summary::after { transform: rotate(45deg); margin-block-start: -3px; }

.facet-list {
  list-style: none;
  margin: 0;
  padding: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.facet-option {
  display: flex;
  align-items: center;
  gap: 11px;
  cursor: pointer;
  font-size: 0.93rem;
  color: var(--text-dim);
  line-height: 1.35;
}

.facet-option:hover { color: var(--text); }

.facet-option input {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--accent);
  cursor: pointer;
  margin: 0;
}

.facet-option.is-on { color: var(--text); font-weight: 600; }

.facet-count { margin-inline-start: auto; font-size: 0.82rem; opacity: 0.65; }

.store-filter-actions {
  display: flex;
  gap: 10px;
  padding-block-start: 18px;
}

/* --------------------------------------------------------------- cards --- */

.store-results { min-width: 0; }

.store-section + .store-section { margin-block-start: 48px; }

.store-section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0 0 20px;
}

.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(258px, 1fr));
  gap: 26px;
}

.device-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* The image sits on its own tinted panel, the way manufacturers present
   hardware — product photography is usually on white and needs a ground. */
.device-shot {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 14px;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  overflow: hidden;
}

.device-shot img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transition: opacity .45s ease, transform .35s ease;
}

.device-card:hover .device-shot img { transform: scale(1.05); }

.device-badge,
.device-flag {
  position: absolute;
  top: 12px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.device-badge {
  inset-inline-start: 14px;
  color: var(--text-dim);
  font-size: 1.02rem;
}

.device-flag {
  inset-inline-end: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 4px 10px;
  color: var(--text);
  font-size: 0.74rem;
}

.device-kind {
  font-size: 0.83rem;
  color: var(--text-dim);
  margin: 16px 0 3px;
}

.device-name {
  font-size: 1.32rem;
  font-weight: 700;
  margin: 0 0 12px;
  line-height: 1.2;
}

.device-points {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.device-points li {
  position: relative;
  padding-inline-start: 16px;
  font-size: 0.92rem;
  color: var(--text-dim);
  line-height: 1.45;
}

.device-points li::before {
  content: "";
  position: absolute;
  inset-inline-start: 0;
  top: 0.55em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

.device-foot { margin-top: auto; padding-block-start: 6px; }

/* site.css paints every <p> --text-dim; the price is the loudest thing on the
   card, so it claims --text back explicitly. */
.device-price {
  font-size: 1.34rem;
  font-weight: 800;
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.device-price.is-quote { font-size: 1rem; font-weight: 600; color: var(--text-dim); }

.device-stock { font-size: 0.84rem; color: var(--text-dim); margin: 0 0 12px; }
.device-stock.is-out { color: #d1495b; }

.device-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.device-qty {
  width: 62px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 9px 8px;
  text-align: center;
}

.device-datasheet { font-size: 0.88rem; font-weight: 600; }

/* --------------------------------------------------------------- empty --- */

.store-empty {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 56px 24px;
  text-align: center;
  color: var(--text-dim);
}

/* ----------------------------------------------------------- responsive --- */

@media (max-width: 980px) {
  .store-page { grid-template-columns: 1fr; gap: 26px; }
  .store-filters { position: static; }
  .store-filters-inner { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 28px; }
}

@media (max-width: 560px) {
  .store-page { padding-inline: 18px; }
  .store-grid { grid-template-columns: 1fr; }
  .store-toolbar { gap: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .device-shot img,
  .facet-group > summary::after { transition: none; }
  .device-card:hover .device-shot img { transform: none; }
}

/* ===========================================================================
   Motion and loading feedback.

   The page is server-rendered, so "loading" here means the gap between
   submitting a filter and the new page painting. Rather than a white flash,
   the results shimmer in place and a progress bar runs along the top — the
   page tells you it heard you.

   Everything below is enhancement: without JavaScript the cards are simply
   visible, the forms still post, and nothing depends on these classes.
   =========================================================================== */

/* --- card entrance ------------------------------------------------------- */

/* Only applied once JS confirms it can animate, so a no-JS visitor never
   gets stuck looking at opacity:0 cards. */
.js-motion .device-card {
  opacity: 0;
  transform: translateY(14px);
}

.js-motion .device-card.is-in {
  opacity: 1;
  transform: none;
  transition: opacity .5s cubic-bezier(.22, .61, .36, 1),
              transform .5s cubic-bezier(.22, .61, .36, 1);
  transition-delay: calc(var(--i, 0) * 45ms);
}

.device-card { transition: transform .28s cubic-bezier(.22,.61,.36,1); }
.device-card:hover { transform: translateY(-4px); }

.device-shot {
  transition: border-color .28s ease, box-shadow .28s ease;
}

.device-card:hover .device-shot {
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  box-shadow: 0 14px 34px -18px color-mix(in srgb, var(--accent) 70%, transparent);
}

/* --- image fade-in ------------------------------------------------------- */

/* Product shots decode at different moments; fading each one in as it lands
   reads as deliberate, where popping in reads as broken. */
/* Scoped to .js-motion, which only the listing script adds. The rule used to
   apply everywhere, so any page that includes this stylesheet WITHOUT that
   script — the detail page and its related-product cards — held every product
   image at opacity 0 forever, because nothing was there to mark them loaded. */
.js-motion .device-shot img { opacity: 0; }
.js-motion .device-shot img.is-loaded { opacity: 1; }

/* --- top progress bar ---------------------------------------------------- */

.store-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  height: 3px;
  width: 0;
  background: var(--grad, linear-gradient(90deg, var(--accent), var(--accent-2, var(--accent-deep))));
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 70%, transparent);
  z-index: 2000;
  opacity: 0;
  pointer-events: none;
}

.store-progress.is-running {
  opacity: 1;
  width: 92%;
  transition: width 9s cubic-bezier(.05,.7,.1,1);
}

.store-progress.is-done {
  opacity: 0;
  width: 100%;
  transition: width .2s ease, opacity .35s ease .15s;
}

/* --- results skeleton ---------------------------------------------------- */

.store-results { position: relative; }

.store-skeleton { display: none; }

.store-results.is-loading > .store-section,
.store-results.is-loading > .store-empty { display: none; }

.store-results.is-loading > .store-skeleton { display: block; }

.skel-title {
  height: 20px;
  width: 160px;
  border-radius: 6px;
  margin-bottom: 20px;
}

.skel-card { display: flex; flex-direction: column; gap: 11px; }

.skel-shot {
  aspect-ratio: 4 / 3;
  border-radius: 14px;
  border: 1px solid var(--border);
}
.skel-line { height: 11px; border-radius: 5px; }
.skel-line.w-40 { width: 40%; }
.skel-line.w-70 { width: 70%; }
.skel-line.w-90 { width: 90%; }
.skel-line.tall { height: 21px; width: 55%; margin-top: 6px; }

/* Mixed against TRANSPARENT, not --bg-raised. Mixing into the raised colour
   produced near-white blocks in the light theme — the placeholders were there
   but invisible, so the grid read as empty boxes. Alpha tints of --text-dim
   land at the same visible strength on either ground. */
.skel-title,
.skel-shot,
.skel-line {
  background-color: color-mix(in srgb, var(--text-dim) 20%, transparent);
  background-image: linear-gradient(
    100deg,
    transparent 25%,
    color-mix(in srgb, var(--text-dim) 26%, transparent) 45%,
    color-mix(in srgb, var(--text-dim) 26%, transparent) 55%,
    transparent 75%
  );
  background-size: 240% 100%;
  background-repeat: no-repeat;
  animation: store-shimmer 1.5s ease-in-out infinite;
}

@keyframes store-shimmer {
  from { background-position: 160% 0; }
  to   { background-position: -60% 0; }
}

/* --- active filter chips ------------------------------------------------- */

.filter-chips {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-block-start: -14px;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--accent-wash, var(--bg-raised));
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  border-radius: 999px;
  padding: 5px 8px 5px 13px;
  font-size: .85rem;
  color: var(--text);
  text-decoration: none;
  transition: border-color .2s, transform .2s;
}

.filter-chip:hover { border-color: var(--accent); transform: translateY(-1px); }

.filter-chip .x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 22%, transparent);
  font-size: 13px;
  line-height: 1;
}

.filter-chip-group { opacity: .62; }

.filter-chip.is-clear {
  background: transparent;
  border-style: dashed;
  border-color: var(--border);
  padding-inline: 13px;
  color: var(--text-dim);
}

/* --- add-to-cart feedback ------------------------------------------------ */

.btn.is-busy { pointer-events: none; opacity: .72; }

.btn.is-added {
  background: var(--ok-accent, #12a37a) !important;
  box-shadow: none !important;
}

.cart-link.is-bumped { animation: cart-bump .5s cubic-bezier(.3,1.4,.5,1); }

@keyframes cart-bump {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.22); }
  100% { transform: scale(1); }
}

/* --- toast --------------------------------------------------------------- */

.store-toasts {
  position: fixed;
  inset-block-end: 22px;
  inset-inline-end: 22px;
  z-index: 2100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.store-toast {
  display: flex;
  align-items: center;
  gap: 11px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: 12px;
  padding: 13px 18px;
  box-shadow: 0 18px 44px -20px rgba(0, 0, 0, .55);
  color: var(--text);
  font-size: .93rem;
  max-width: 340px;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(14px);
  transition: opacity .3s ease, transform .3s cubic-bezier(.22,.61,.36,1);
}

.store-toast.is-in { opacity: 1; transform: none; }

.store-toast a { font-weight: 650; white-space: nowrap; }

.store-toast .tick {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 21px;
  height: 21px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
  color: #04222e;
  font-size: 12px;
  font-weight: 700;
}

@media (max-width: 560px) {
  .store-toasts { inset-inline: 16px; inset-block-end: 16px; }
  .store-toast { max-width: none; }
}

/* --- respect the setting ------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
  .js-motion .device-card,
  .js-motion .device-card.is-in { opacity: 1; transform: none; transition: none; }
  .device-card:hover { transform: none; }
  .device-shot img { opacity: 1; transition: none; }
  .skel-title, .skel-shot, .skel-line { animation: none; }
  .store-progress, .cart-link.is-bumped { animation: none; transition: none; }
  .store-toast { transition: none; opacity: 1; transform: none; }
}
