/* Compare page (product/compare). Loaded only on this page via $this->document->addStyle().
   --col and --label are set by the inline script in compare.twig; the values below are fallbacks. */

.as-cmp {
  --label: 160px;
  --col: 220px;
  position: relative;
}

/* Tools: "only differences" switch and pager */
.as-cmp__tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.as-cmp__switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--as-ink);
  cursor: pointer;
  user-select: none;
}
.as-cmp__switch input { position: absolute; opacity: 0; pointer-events: none; }
.as-cmp__switch-track {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  border-radius: 999px;
  background: #c9d4de;
  transition: background 0.15s ease;
}
.as-cmp__switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s ease;
}
.as-cmp__switch input:checked + .as-cmp__switch-track { background: var(--as-accent); }
.as-cmp__switch input:checked + .as-cmp__switch-track::after { transform: translateX(16px); }
.as-cmp__switch input:focus-visible + .as-cmp__switch-track { outline: 2px solid var(--as-accent); outline-offset: 2px; }

.as-cmp__pager {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--as-muted);
  font-variant-numeric: tabular-nums;
}
.as-cmp__pager[hidden] { display: none !important; }
.as-cmp__pager button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--as-line);
  background: #fff;
  color: var(--as-brand);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  display: grid;
  place-items: center;
  padding: 0;
}
.as-cmp__pager button:disabled { opacity: 0.35; cursor: default; }

/* Table */
.as-cmp__scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  border: 1px solid var(--as-line);
  border-radius: 14px;
  background: #fff;
}
.as-cmp__table {
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  width: calc(var(--label) + var(--col) * var(--n));
  margin: 0;
}
.as-cmp__col-label { width: var(--label); }
.as-cmp__col-car { width: var(--col); }
.as-cmp__table th,
.as-cmp__table td { vertical-align: top; text-align: left; }

.as-cmp__label {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #f7fafc;
  color: var(--as-brand);
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0.8rem 0.9rem;
  border-top: 1px solid #e8eef4;
}
.as-cmp__cars .as-cmp__label { background: #fff; border-top: 0; }

/* Car card in the header */
.as-cmp__car { padding: 0; }
.as-cmp__card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.9rem 0.85rem 1rem;
}
.as-cmp__img {
  display: block;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  background: #eef2f6;
}
.as-cmp__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.as-cmp__name {
  color: var(--as-brand);
  font-weight: 700;
  font-size: 0.95rem;
  line-height: 1.25;
  text-decoration: none;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
}
.as-cmp__name:hover { color: var(--as-accent); }
.as-cmp__price {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--as-ink);
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}
.as-cmp__lead {
  display: block;
  text-align: center;
  background: var(--as-cta);
  color: #fff !important;
  border-radius: 10px;
  padding: 0.5rem 0.4rem;
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
}
.as-cmp__lead:hover { background: var(--as-cta-hover); }
.as-cmp__remove {
  position: absolute;
  top: 1.3rem;
  right: 1.25rem;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--as-brand);
  box-shadow: 0 2px 8px rgba(14, 21, 28, 0.15);
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

/* Values */
.as-cmp__label-row { display: none; }
.as-cmp__values td {
  padding: 0.8rem 0.85rem;
  border-top: 1px solid #e8eef4;
  font-weight: 600;
  color: var(--as-ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.as-cmp__values td.is-empty { color: #9aa5b1; font-weight: 500; }
.as-cmp__best {
  display: table;
  margin-top: 0.3rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--as-ok);
  background: var(--as-ok-bg);
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
}

/* Rows that differ are tinted, as before; not needed when only differences are shown */
.as-cmp tbody.is-diff .as-cmp__values td { background: #eef8f7; }
.as-cmp tbody.is-diff .as-cmp__label { background: #e4f3f1; }
.as-cmp.is-only-diff tbody.is-same { display: none; }
.as-cmp.is-only-diff tbody.is-diff .as-cmp__values td { background: #fff; }
.as-cmp.is-only-diff tbody.is-diff .as-cmp__label { background: #f7fafc; }
.as-cmp__hidden-note { display: none; margin: 0.6rem 0 0; font-size: 0.85rem; color: var(--as-muted); }
.as-cmp.is-only-diff .as-cmp__hidden-note { display: block; }

/* Mini header: phones only */
.as-cmp__mini { display: none; }

@media (max-width: 767.98px) {
  .as-cmp__scroll {
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }
  .as-cmp__scroll::-webkit-scrollbar { display: none; }
  .as-cmp__car { scroll-snap-align: start; }

  /* labels move into a full-width line above the values */
  /* label cells stay in the table (so columns do not shift) but take no space */
  .as-cmp__label { position: static; visibility: hidden; padding: 0; border: 0; font-size: 0; overflow: hidden; }
  .as-cmp__col-label { width: 0; }
  .as-cmp__label-row { display: table-row; }
  .as-cmp__label-row th {
    padding: 0.75rem 0.75rem 0.1rem;
    border-top: 1px solid #e8eef4;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--as-muted);
  }
  .as-cmp__label-row th span { position: sticky; left: 0.75rem; display: inline-block; }
  .as-cmp__values td { border-top: 0; padding: 0.15rem 0.75rem 0.75rem; font-size: 0.95rem; }
  .as-cmp tbody.is-diff .as-cmp__values td,
  .as-cmp tbody.is-diff .as-cmp__label-row th { background: #fff; }

  .as-cmp__card { padding: 0.75rem 0.75rem 0.85rem; }
  .as-cmp__name { font-size: 0.9rem; }
  .as-cmp__remove { top: 1.1rem; right: 1.1rem; width: 28px; height: 28px; }

  .as-cmp__mini {
    display: block;
    position: sticky;
    top: 0;
    z-index: 5;
    height: 0;
  }
  .as-cmp__mini-box {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    background: rgba(255, 255, 255, 0.97);
    border: 1px solid var(--as-line);
    border-radius: 0 0 12px 12px;
    box-shadow: 0 6px 16px rgba(14, 21, 28, 0.1);
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.18s ease, opacity 0.18s ease;
  }
  .as-cmp__mini.is-on .as-cmp__mini-box { transform: none; opacity: 1; }
  .as-cmp__mini-x { overflow: hidden; }
  .as-cmp__mini-row { display: flex; width: calc(var(--col) * var(--n)); }
  .as-cmp__mini-car {
    flex: none;
    width: var(--col);
    padding: 0.45rem 0.75rem;
    display: flex;
    flex-direction: column;
    min-width: 0;
  }
  .as-cmp__mini-car b {
    font-size: 0.78rem;
    color: var(--as-brand);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .as-cmp__mini-car span { font-size: 0.82rem; font-weight: 800; font-variant-numeric: tabular-nums; }
}

@media (prefers-reduced-motion: reduce) {
  .as-cmp__switch-track,
  .as-cmp__switch-track::after,
  .as-cmp__mini-box { transition: none; }
}
