/* ==========================================================================
   porownanie.css — strona porównania. Tokeny z global.css (:root).
   Mobile-first. Jedyny "mocny" element to wyróżnienie najlepszej wartości
   (akcent + pasek proporcji); reszta celowo spokojna.
   ========================================================================== */

.cmp-page{
  --cmp-label-w: 190px;
  --cmp-best-bg: rgba(101, 149, 202, .10);
  --cmp-bar-bg: #eceae4;
  --cmp-bar-fill: #bcc6d2;
}

/* ---------- Nagłówek strony ---------- */

.cmp-hero{
  background: var(--main-color);
  color: #fff;
  padding: 24px 0 28px;
}
.cmp-hero__title{
  font-size: 23px;
  line-height: 1.2;
  color: #fff;
  margin: 0 0 8px;
  text-wrap: balance;
}
.cmp-hero__lead{
  margin: 0;
  font-size: 14.5px;
  color: #cdd8e4;
  max-width: 70ch;
}
@media (min-width: 900px){
  .cmp-hero{ padding: 36px 0 40px; }
  .cmp-hero__title{ font-size: 30px; }
  .cmp-hero__lead{ font-size: 16px; }
}

/* ---------- Sekcje / panel (ten sam wygląd co .section__panel na głównej) ---------- */

.cmp-section{ padding-top: 20px; }
.cmp-panel{
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: clip;
}
.cmp-panel__heading{
  font-size: 17px;
  color: #fff;
  background: var(--main-color);
  padding: 16px 20px;
  margin: 0;
}

.cmp-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease;
}
.cmp-btn:hover{ background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.cmp-btn--ghost{ background: transparent; color: var(--accent-dark); }
.cmp-btn--ghost:hover{ background: var(--cmp-best-bg); color: var(--accent-dark); }

.cmp-page a:focus-visible,
.cmp-page button:focus-visible,
.cmp-switch input:focus-visible + .cmp-switch__track{
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 699px){
  .cmp-hide-mobile{ display: none !important; }
}

/* ---------- Pasek narzędzi ---------- */

.cmp-toolbar{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
.cmp-switch{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}
.cmp-switch input{ position: absolute; opacity: 0; width: 1px; height: 1px; }
.cmp-switch__track{
  position: relative;
  flex: 0 0 auto;
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: #cfd3da;
  transition: background-color .2s ease;
}
.cmp-switch__track::after{
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,.25);
  transition: transform .2s ease;
}
.cmp-switch input:checked + .cmp-switch__track{ background: var(--accent); }
.cmp-switch input:checked + .cmp-switch__track::after{ transform: translateX(16px); }

.cmp-toolbar__add{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent-dark);
}
.cmp-toolbar__add svg{ width: 16px; height: 16px; }
.cmp-toolbar__add:hover{ color: var(--main-color); }

/* ==========================================================================
   TABELA — mobile: każdy wiersz to grid, etykieta nad wartościami
   (dzięki temu 3 auta mieszczą się w 360px bez przewijania w bok).
   ========================================================================== */

.cmp-scroll{ position: relative; }

.cmp-table{
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}
.cmp-table colgroup{ display: none; }
.cmp-table,
.cmp-table thead,
.cmp-table tbody,
.cmp-table tfoot{ display: block; }
.cmp-table tr{
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
}
.cmp-corner{ display: none; }

/* Nagłówki aut */
.cmp-car{
  position: relative;
  padding: 12px 6px 14px;
  text-align: left;
  font-weight: 400;
  vertical-align: top;
  min-width: 0;
}
.cmp-car:first-of-type{ padding-left: 12px; }
.cmp-car:last-child{ padding-right: 12px; }

.cmp-car__media{
  position: relative;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
  margin-bottom: 8px;
}
.cmp-car__media img{
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.cmp-car__remove{
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  transition: background-color .2s ease;
}
.cmp-car__remove svg{ width: 14px; height: 14px; }
.cmp-car__remove:hover{ background: #b0413e; color: #fff; }

.cmp-car__name{
  display: block;
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cmp-car__name:hover{ color: var(--accent-dark); }
.cmp-car__sub{
  display: block;
  margin-top: 3px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.3;
}
.cmp-car__price{
  display: block;
  margin-top: 6px;
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-dark);
}

/* Nagłówek grupy (zwijany) */
.cmp-group__head th{
  grid-column: 1 / -1;
  padding: 0;
  text-align: left;
  background: var(--paper);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}
.cmp-group__toggle{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  background: none;
  border: 0;
  font: inherit;
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--main-color);
  text-align: left;
  cursor: pointer;
}
.cmp-group__toggle svg{ width: 16px; height: 16px; flex: 0 0 auto; transition: transform .2s ease; }
.cmp-group.is-collapsed .cmp-group__toggle svg{ transform: rotate(-90deg); }
.cmp-group.is-collapsed .cmp-row{ display: none; }

/* Wiersz */
.cmp-row{ border-bottom: 1px solid var(--line); }
.cmp-row:last-child{ border-bottom: 0; }

.cmp-label{
  grid-column: 1 / -1;
  padding: 10px 12px 2px;
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.cmp-label__hint{
  display: block;
  font-weight: 400;
  font-size: 11.5px;
  color: #8a909b;
}

.cmp-cell{
  padding: 4px 6px 10px;
  vertical-align: top;
  min-width: 0;
  font-size: 14px;
}
.cmp-cell:nth-child(2){ padding-left: 12px; }
.cmp-cell:last-child{ padding-right: 12px; }

.cmp-val{
  display: block;
  font-weight: 600;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.cmp-short{
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.3;
}

/* Stany: najlepszy (akcent) / najgorszy (wyciszony, NIE czerwony) / brak danych */
.cmp-cell.is-best{
  background: var(--cmp-best-bg);
  box-shadow: inset 0 3px 0 var(--accent);
}
.cmp-cell.is-best .cmp-val{ color: var(--accent-dark); font-weight: 700; }
.cmp-cell.is-worst .cmp-val{ color: var(--ink-soft); font-weight: 400; }
.cmp-cell.is-na .cmp-val{ color: #9aa1ab; font-weight: 400; font-size: 13px; }

/* Pasek proporcji */
.cmp-bar{
  position: relative;
  display: block;
  height: 5px;
  margin-top: 7px;
  border-radius: 3px;
  background: var(--cmp-bar-bg);
  overflow: hidden;
}
.cmp-bar::after{
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--w);
  border-radius: 3px;
  background: var(--cmp-bar-fill);
}
.cmp-cell.is-best .cmp-bar::after{ background: var(--accent); }

/* Miernik 1–5 (zamiast 18 obrazków PNG) */
.cmp-meter{
  display: inline-flex;
  gap: 3px;
  margin-top: 4px;
  vertical-align: middle;
}
.cmp-meter i{
  width: 12px;
  height: 6px;
  border-radius: 2px;
  background: var(--cmp-bar-bg);
}
.cmp-meter i.on{ background: var(--cmp-bar-fill); }
.cmp-cell.is-best .cmp-meter i.on{ background: var(--accent); }

/* "Pokaż tylko różnice" */
.cmp-table.is-diff .cmp-row[data-same]{ display: none; }
.cmp-table.is-diff .cmp-group:not(:has(.cmp-row:not([data-same]))){ display: none; }

/* Stopka tabeli */
.cmp-footrow td{
  padding: 14px 6px 16px;
  border-top: 1px solid var(--line);
}
.cmp-footrow td:nth-child(2){ padding-left: 12px; }
.cmp-footrow td:last-child{ padding-right: 12px; }
.cmp-footrow .cmp-btn{ width: 100%; font-size: 13.5px; padding: 8px 6px; }

/* ---------- Mobile + 4 auta: przewijanie w bok, etykiety przyklejone ---------- */
@media (max-width: 699px){
  .cmp-scroll[data-n="4"]{
    overflow-x: auto;
    scroll-snap-type: x proximity;
    -webkit-overflow-scrolling: touch;
  }
  .cmp-scroll[data-n="4"] .cmp-table{ width: 133.34%; }
  .cmp-scroll[data-n="4"] .cmp-car{ scroll-snap-align: start; }
  .cmp-scroll[data-n="4"] .cmp-label,
  .cmp-scroll[data-n="4"] .cmp-group__toggle{
    position: sticky;
    left: 0;
    justify-self: start;
    width: auto;
    max-width: 75vw;
  }
  .cmp-scroll[data-n="4"] .cmp-group__head th{ display: flex; }
}

/* ==========================================================================
   Desktop: prawdziwa tabela z kolumną etykiet
   ========================================================================== */
@media (min-width: 700px){
  .cmp-table{ display: table; table-layout: fixed; }
  .cmp-table colgroup{ display: table-column-group; }
  .cmp-table thead{ display: table-header-group; }
  .cmp-table tbody{ display: table-row-group; }
  .cmp-table tfoot{ display: table-footer-group; }
  .cmp-table tr{ display: table-row; }
  /* stany is-diff / is-collapsed mają wyższą specyficzność, więc nadal działają */

  .cmp-col-label{ width: var(--cmp-label-w); }
  .cmp-corner{ display: table-cell; }

  .cmp-car{ padding: 16px 10px 16px; }
  .cmp-car:first-of-type{ padding-left: 10px; }
  .cmp-car:last-child{ padding-right: 16px; }
  .cmp-car__name{ font-size: 18px; }
  .cmp-car__sub{ font-size: 13px; }
  .cmp-car__price{ font-size: 21px; }
  .cmp-car__remove{ top: 8px; right: 8px; width: 28px; height: 28px; }

  .cmp-label{
    padding: 12px 12px 12px 20px;
    font-size: 14px;
    font-weight: 400;
    color: var(--ink-soft);
    vertical-align: top;
  }
  .cmp-cell,
  .cmp-cell:nth-child(2){ padding: 12px 10px; font-size: 15px; }
  .cmp-cell:last-child{ padding-right: 16px; }
  .cmp-cell.is-best{ box-shadow: inset 3px 0 0 var(--accent); }

  .cmp-group__toggle{ padding: 12px 20px; font-size: 17px; }

  .cmp-row:hover .cmp-label,
  .cmp-row:hover .cmp-cell:not(.is-best){ background: #fbfaf8; }

  .cmp-footrow td,
  .cmp-footrow td:nth-child(2){ padding: 16px 10px 20px; }
  .cmp-footrow .cmp-btn{ width: auto; padding: 8px 14px; }
}

/* ---------- Pasek przy przewijaniu (fixed = poza przepływem, bez CLS) ---------- */

.cmp-mini{
  position: fixed;
  top: var(--cmp-top, 56px);
  left: 0;
  width: 100%;
  z-index: 90;
  overflow: hidden;
  background: var(--main-color-dark);
  color: #fff;
  box-shadow: 0 4px 10px rgba(0,0,0,.2);
  transform: translateY(-120%);
  visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
}
.cmp-mini.is-visible{
  transform: none;
  visibility: visible;
  transition: transform .2s ease, visibility 0s;
}
.cmp-mini__inner{
  display: grid;
  grid-template-columns: repeat(var(--n), minmax(0, 1fr));
  will-change: transform;
}
.cmp-mini__spacer{ display: none; }
.cmp-mini__car{
  padding: 8px 6px;
  min-width: 0;
  line-height: 1.2;
}
.cmp-mini__car:first-of-type{ padding-left: 12px; }
.cmp-mini__name{
  display: block;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmp-mini__price{
  display: block;
  font-size: 12px;
  color: #a9c3e2;
}
@media (min-width: 700px){
  .cmp-mini__inner{ grid-template-columns: var(--cmp-label-w) repeat(var(--n), minmax(0, 1fr)); }
  .cmp-mini__spacer{ display: block; }
  .cmp-mini__car,
  .cmp-mini__car:first-of-type{ padding: 10px; }
  .cmp-mini__name{ font-size: 15px; }
  .cmp-mini__price{ font-size: 13px; }
}

/* ---------- Mocne strony ---------- */

.cmp-wins{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
}
@media (min-width: 700px){
  .cmp-wins{ grid-template-columns: repeat(var(--n), minmax(0, 1fr)); padding: 20px; gap: 16px; }
}
.cmp-win{
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.cmp-win.is-leader{
  border-color: var(--accent);
  box-shadow: inset 0 3px 0 var(--accent);
}
.cmp-win__name{ font-size: 16px; margin: 0 0 4px; }
.cmp-win__count{ margin: 0 0 10px; font-size: 13.5px; color: var(--ink-soft); }
.cmp-win__count strong{ font-size: 18px; color: var(--accent-dark); }
.cmp-win__list{
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cmp-win__list li{
  font-size: 12.5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--paper);
  border: 1px solid var(--line);
}

/* ---------- Propozycje ---------- */

.cmp-sugg-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
}
.cmp-sugg{
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
  align-items: start;
}
.cmp-sugg__media{
  display: block;
  aspect-ratio: 3 / 2;
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
}
.cmp-sugg__media img{ width: 100%; height: 100%; object-fit: cover; }
.cmp-sugg__name{ font-size: 15px; line-height: 1.25; margin: 0 0 2px; }
.cmp-sugg__name a:hover{ color: var(--accent-dark); }
.cmp-sugg__sub{ margin: 0; font-size: 12.5px; color: var(--ink-soft); }
.cmp-sugg__price{
  margin: 4px 0 8px;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 16px;
  color: var(--accent-dark);
}
.cmp-sugg .cmp-btn{ font-size: 13.5px; padding: 7px 12px; }

@media (min-width: 700px){
  .cmp-sugg-grid{ grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 20px; padding: 20px; }
  .cmp-sugg{ grid-template-columns: 1fr; gap: 10px; }
  .cmp-sugg .cmp-btn{ width: 100%; }
}

/* ---------- Pusty stan ---------- */

.cmp-empty{ padding: 24px 20px; }
.cmp-empty__title{ font-size: 21px; margin: 0 0 8px; }
.cmp-empty__text{ margin: 0 0 16px; color: var(--ink-soft); max-width: 65ch; }
.cmp-empty__actions{ display: flex; flex-wrap: wrap; gap: 10px; }
.cmp-empty--compact{ padding: 16px 20px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.cmp-empty--compact .cmp-empty__text{ margin: 0; }

@media (prefers-reduced-motion: reduce){
  .cmp-mini,
  .cmp-mini.is-visible,
  .cmp-switch__track,
  .cmp-switch__track::after,
  .cmp-group__toggle svg{ transition: none; }
}
