/* ==========================================================================
   Compare page (templates/compare.html, static/js/pages/compare.js)
   Builds on the tokens and components of app.css. --sel is the colour of one
   selection (charts.seriesColor), set inline by compare.js.
   ========================================================================== */

/* selection cards and the add slot share one grid */

.cmp-picks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
  gap: var(--s-3);
  align-items: stretch;
}

.cmp-picks__list {
  display: contents;
  list-style: none;
}

.cmp-pick {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: var(--s-2);
  min-width: 0;
  padding: var(--s-4);
  padding-top: calc(var(--s-4) + 2px);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  animation: cmp-in 0.25s ease both;
}

.cmp-pick::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--sel, var(--data));
}

.cmp-pick__top {
  display: flex;
  align-items: flex-start;
  gap: var(--s-2);
}

.cmp-pick__badge {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 26px;
  height: 26px;
  margin-top: 1px;
  border-radius: 50%;
  background: var(--sel, var(--data));
  color: #fff;
  font-size: var(--fs-s);
  font-weight: 750;
}

.cmp-pick__name {
  flex: 1;
  min-width: 0;
  font-size: var(--fs-l);
  font-weight: 650;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.cmp-pick__remove {
  margin: -6px -8px 0 0;
}

.cmp-pick__n {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 4px;
  color: var(--text-2);
  font-size: var(--fs-s);
}

.cmp-pick__n strong {
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 750;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.cmp-pick__n .skeleton--text {
  width: 60%;
}

.cmp-pick__share {
  flex-basis: 100%;
  color: var(--text-3);
}

.cmp-pick__err {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-basis: 100%;
  margin-bottom: var(--s-2);
  color: var(--bad);
}

.cmp-pick__open {
  align-self: flex-start;
  gap: 4px;
  margin-top: auto;
}

/* the add slot */

.cmp-add {
  gap: var(--s-3);
  border-style: dashed;
  border-color: var(--border-strong);
  background: var(--surface-2);
}

.cmp-add.is-full {
  opacity: 0.7;
}

.cmp-add__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s-2);
}

.cmp-add .search__input {
  width: 100%;
}

.cmp-add__quick {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2);
}

.cmp-add__canton {
  display: flex;
  flex: 1 1 200px;
  flex-wrap: wrap; /* the button moves below when the list would get too narrow to read */
  gap: var(--s-2);
  min-width: 0;
}

.cmp-select {
  flex: 1 1 8.5rem;
  min-width: 0;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--border-control);
  border-radius: var(--r-s);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.cmp-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-2);
  font-size: var(--fs-s);
  cursor: pointer;
}

.cmp-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.cmp-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--s-2);
  margin-top: var(--s-3);
}

/* empty state */

.cmp-empty {
  display: grid;
  gap: var(--s-5);
  margin-top: var(--s-6);
  padding: var(--s-6) var(--s-4);
  border: 1px solid var(--border);
  border-radius: var(--r-l);
  background: var(--surface);
  text-align: center;
}

.cmp-empty__intro {
  display: grid;
  justify-items: center;
  gap: var(--s-2);
  color: var(--text-3);
}

.cmp-empty__title {
  color: var(--text);
  font-size: var(--fs-xl);
  font-weight: 700;
}

.cmp-empty__text {
  max-width: 52ch;
  color: var(--text-2);
}

.cmp-examples {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: var(--s-3);
  max-width: 900px;
  margin: 0 auto;
  padding: 0;
  list-style: none;
  text-align: left;
}

.cmp-example {
  display: grid;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: var(--s-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-m);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s ease, transform 0.12s ease, background-color 0.12s ease;
}

.cmp-example:hover {
  border-color: var(--text-3);
  background: var(--surface);
  transform: translateY(-1px);
}

.cmp-example__title {
  font-weight: 700;
}

.cmp-example__text {
  color: var(--text-3);
  font-size: var(--fs-s);
}

.cmp-example__dots {
  display: flex;
  gap: 4px;
  margin-top: var(--s-1);
}

/* names with their selection colour */

.cmp-dot {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sel, var(--data));
}

.cmp-name {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.cmp-name .cmp-dot {
  transform: translateY(-1px);
}

/* results */

.cmp-results {
  transition: opacity 0.18s ease;
}

.cmp-results.is-refreshing {
  opacity: 0.55;
}

/* key numbers table */

.cmp-table-wrap {
  position: relative; /* hidden helper texts in the cells scroll with the table */
  overflow-x: auto;
  margin: calc(var(--s-1) * -1);
  padding: var(--s-1);
}

.cmp-table {
  min-width: 480px;
  font-size: var(--fs-m);
}

.cmp-table th,
.cmp-table td {
  white-space: normal;
  vertical-align: top;
}

.cmp-table thead th {
  position: static;
  min-width: 120px;
  background: transparent;
  color: var(--text);
  font-size: var(--fs-s);
  letter-spacing: 0;
  text-transform: none;
  text-align: right;
  vertical-align: bottom;
  border-bottom: 2px solid var(--border-strong);
}

.cmp-table thead .cmp-name {
  justify-content: flex-end;
}

.cmp-table thead th.cmp-table__corner {
  min-width: 0;
}

.cmp-table tbody th {
  color: var(--text-2);
  font-weight: 600;
  white-space: nowrap;
}

.cmp-table td.num {
  text-align: right;
}

.cmp-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.cmp-cell__v {
  font-weight: 600;
}

.cmp-cell__sub {
  display: block;
  color: var(--text-3);
  font-size: var(--fs-xs);
}

.cmp-table td.is-best {
  background: var(--surface-2);
}

.cmp-table td.is-best .cmp-cell__v {
  font-weight: 750;
}

.cmp-best {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
}

/* fuel / drive / gearbox / colour mixes */

.cmp-mix {
  display: grid;
  gap: var(--s-3);
}

.cmp-mixrow {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.cmp-mixrow > .cmp-name {
  font-size: var(--fs-s);
}

.cmp-mixrow__bar {
  min-width: 0;
}

@media (min-width: 1100px) {
  .cmp-mix-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* small multiples */

.cmp-maps,
.cmp-tops {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
  gap: var(--s-4);
  align-items: start;
}

.cmp-map {
  margin: 0;
}

.cmp-map__title,
.cmp-top__title {
  font-size: var(--fs-m);
}

.cmp-top .card__sub {
  margin-top: calc(var(--s-2) * -1);
}

@keyframes cmp-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cmp-pick {
    animation: none;
  }

  .cmp-example:hover {
    transform: none;
  }
}

/* longer German texts: header cards, key-number headers and notes wrap cleanly */

.cmp-name,
.cmp-cell__sub,
.cmp-pick__share,
.cmp-example__title,
.cmp-example__text {
  overflow-wrap: anywhere;
  -webkit-hyphens: auto;
  hyphens: auto;
}

@media (max-width: 480px) {
  .cmp-add__canton .cmp-select {
    flex-basis: 100%;
  }

  .cmp-table tbody th {
    white-space: normal;
  }
}
