/* ==========================================================================
   components.css - product cards, grids, rails, toasts, pagination
   ========================================================================== */

/* --- grid ------------------------------------------------------------------ */

.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: var(--gap);
}

/* --- product card ---------------------------------------------------------- */

.card {
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease),
              border-color .18s var(--ease);
}
.card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-3px);
  border-color: #CFE0E3;
}

.card__media {
  position: relative;
  display: block;
  aspect-ratio: 1 / 1;
  padding: 16px;
  background: var(--surface);
}
.card__media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform .3s var(--ease);
}
.card:hover .card__media img { transform: scale(1.045); }
.card__media img.is-placeholder { object-fit: cover; opacity: .8; }

/* discount badge, pinned top-left as on the reference site */
.card__badge {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
  padding: 4px 9px;
  background: var(--price);
  color: #fff;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.3;
  direction: ltr;
  box-shadow: 0 1px 4px rgba(232, 66, 46, .35);
}

.card__ribbon {
  position: absolute;
  inset-inline: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  padding: 7px 10px;
  background: rgba(30, 42, 46, .74);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

.card--out .card__media img { opacity: .55; filter: grayscale(.35); }

.card__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  flex: 1 1 auto;
}

.card__title {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.5;
  /* keep every card the same height regardless of name length */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: calc(2 * 1.5 * 14px);
}
.card__title a { color: var(--ink); }
.card__title a:hover { color: var(--teal); }

.card__prices {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}
.card__old { color: var(--muted); font-size: 13px; text-decoration: line-through; }
.card__price { color: var(--price); font-size: 15.5px; font-weight: 700; }

.card__cta { margin-top: 2px; }

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

.card--skeleton { pointer-events: none; }
.card--skeleton:hover { transform: none; box-shadow: var(--shadow-sm); }

.sk {
  background: linear-gradient(90deg, #EDF1F2 25%, #E2E8EA 37%, #EDF1F2 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.3s ease-in-out infinite;
  border-radius: 4px;
}
.sk--media { aspect-ratio: 1 / 1; border-radius: 0; }
.sk--line { height: 13px; }
.sk--short { width: 55%; }
.sk--btn { height: 36px; border-radius: var(--radius); margin-top: 4px; }

@keyframes sk-shimmer {
  0%   { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* --- stars ----------------------------------------------------------------- */

.stars { display: inline-flex; gap: 1px; line-height: 1; font-size: 13px; }
.stars__star { color: #D6DEE0; }
.stars__star.is-on { color: var(--star); }

/* --- section heading ------------------------------------------------------- */

.section-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

/* centred variant: a thin rule on both sides of the title */
.section-head--center { justify-content: center; }
.section-head--center::before,
.section-head--center::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--border);
}
.section-head--center .section-head__title { flex: 0 0 auto; }

.section-head__title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
}

/* right-aligned variant: title first, "more" link pushed to the far side */
.section-head--start .section-head__title { margin-inline-end: auto; }

.section-head__more {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--teal-dark);
}
.section-head__more:hover { color: var(--teal); }

/* --- compact rail ---------------------------------------------------------- */

.rail__row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.rail__row:last-child { border-bottom: 0; }

.rail__thumb {
  flex: 0 0 64px;
  width: 64px;
  height: 64px;
  padding: 4px;
  background: var(--surface);
  border-radius: 6px;
}
.rail__thumb img { width: 100%; height: 100%; object-fit: contain; }

.rail__body { min-width: 0; display: flex; flex-direction: column; gap: 4px; }

.rail__title {
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rail__title:hover { color: var(--teal); }

.rail__prices { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rail__prices .card__price { font-size: 14px; }

/* --- breadcrumb ------------------------------------------------------------ */

.crumbs { margin-bottom: 16px; font-size: 13px; color: var(--muted); }
.crumbs ol { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.crumbs li { display: flex; align-items: center; gap: 6px; }
.crumbs li + li::before { content: "›"; color: var(--border); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--teal); }
.crumbs [aria-current="page"] { color: var(--ink); font-weight: 600; }

/* --- pagination ------------------------------------------------------------ */

.pager {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 32px;
}

.pager__btn {
  min-width: 38px;
  height: 38px;
  padding-inline: 10px;
  display: grid;
  place-items: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 14px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: background .15s var(--ease), color .15s var(--ease),
              border-color .15s var(--ease);
}
.pager__btn:hover { border-color: var(--teal); color: var(--teal-dark); }
.pager__btn.is-active {
  background: var(--teal);
  border-color: var(--teal);
  color: #fff;
}
.pager__btn--arrow { font-size: 18px; line-height: 1; }
.pager__gap { color: var(--muted); padding-inline: 2px; }

/* --- quantity stepper ------------------------------------------------------ */

.qty {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg);
}

.qty__btn {
  width: 34px;
  height: 38px;
  display: grid;
  place-items: center;
  font-size: 17px;
  font-weight: 700;
  color: var(--ink-soft);
  transition: background .13s var(--ease), color .13s var(--ease);
}
.qty__btn:hover { background: var(--surface); color: var(--teal-dark); }

.qty__input {
  width: 48px;
  height: 38px;
  border: 0;
  border-inline: 1px solid var(--border);
  text-align: center;
  font-weight: 700;
  background: var(--bg);
  -moz-appearance: textfield;
}
.qty__input::-webkit-outer-spin-button,
.qty__input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.qty__input:focus { outline: none; background: var(--surface); }

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

.toast-host {
  position: fixed;
  bottom: 20px;
  inset-inline-start: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(400px, calc(100vw - 40px));
  padding: 12px 14px;
  background: var(--ink);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  pointer-events: auto;
  /* slides in from the left edge, which is the "outside" in RTL */
  transform: translateX(-120%);
  opacity: 0;
  transition: transform .28s var(--ease), opacity .28s var(--ease);
}
.toast.is-in { transform: translateX(0); opacity: 1; }

.toast__text {
  flex: 1 1 auto;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.toast__link {
  flex: 0 0 auto;
  color: var(--teal-light);
  font-weight: 700;
  white-space: nowrap;
  text-decoration: underline;
}
.toast__link:hover { color: #fff; }

.toast__close {
  flex: 0 0 auto;
  width: 24px; height: 24px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #9FB0B6;
  font-size: 20px;
  line-height: 1;
}
.toast__close:hover { background: rgba(255, 255, 255, .14); color: #fff; }

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

.empty {
  padding: 56px 20px;
  text-align: center;
  background: var(--surface);
  border-radius: var(--radius-lg);
}
.empty__icon { font-size: 44px; margin-bottom: 12px; }
.empty__title { font-size: 20px; margin-bottom: 8px; }
.empty__text { color: var(--muted); margin-bottom: 20px; }
