/* # Comparison section
 *
 * Loaded only by components/comparison_section.php, through customweb_render_style_in_place().
 * Colours come from the section colour scheme variables that customweb_color_scheme_inline_style()
 * sets on the section, plus --cmp-band, which the component sets to a dark scheme colour.
 * Tints are mixed from the scheme with color-mix(); each has a hex fallback for the default
 * scheme first, for browsers without color-mix().
 *
 * Below 800px, comparison.js reveals the toggle buttons and adds .cmp--tabbed, and only the
 * current card shows. Without the script every card stays visible, stacked.
 */

.cmp--section {
  --cmp-strip: #F2F8FC;
  --cmp-strip: color-mix(in srgb, var(--sectioncs-accents) 5%, var(--sectioncs-bg));
  --cmp-tag: #E3EFFA;
  --cmp-tag: color-mix(in srgb, var(--sectioncs-accents) 11%, var(--sectioncs-bg));
  --cmp-label: #5C5C5C;
  --cmp-label: color-mix(in srgb, var(--sectioncs-text) 72%, var(--sectioncs-bg));
  --cmp-tag-line: #BBBBBB;
  --cmp-tag-line: color-mix(in srgb, var(--sectioncs-text) 30%, var(--sectioncs-bg));
  --cmp-band-link: #A6CEEE;
  --cmp-band-link: color-mix(in srgb, var(--sectioncs-accents) 35%, #ffffff);
}

.cmp--section.cmp--joins-next {
  padding-bottom: 1.5rem;
}

.cmp--tabs {
  display: none;
}

.cmp--grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-gap: 1.5rem;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.cmp--card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--sectioncs-outline);
  border-radius: 0.5rem;
  background-color: var(--sectioncs-bg);
  color: var(--sectioncs-text);
}

.cmp--media {
  height: 11.25rem;
  background-color: var(--cmp-strip);
}

.cmp--img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.cmp--band {
  padding: 0.875rem 1rem 1rem;
  background-color: var(--cmp-band);
  color: #ffffff;
}

.cmp--name {
  margin: 0;
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.25;
  color: #ffffff;
}

/* The phone design shows the name only; the button at the bottom of the card goes to the same page. */

.cmp--band-link {
  display: none;
}

.cmp--arrow {
  margin-left: 0.3em;
}

.cmp--band-link:hover {
  text-decoration: underline;
}

.cmp--facts {
  flex-grow: 1;
  margin: 0;
  padding: 0.25rem 1rem 0;
}

.cmp--row {
  padding: 0.75rem 0;
  border-top: 1px solid var(--sectioncs-outline);
}

.cmp--label {
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.4;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--cmp-label);
}

.cmp--value {
  margin: 0.25rem 0 0;
  font-size: 1rem;
  line-height: 1.45;
}

.cmp--value-tags {
  margin-top: 0.5rem;
}

.cmp--tag {
  display: inline-flex;
  align-items: center;
  grid-gap: 0.375rem;
  gap: 0.375rem;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--cmp-tag-line);
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.35;
}

.cmp--tag-highlight {
  border-color: var(--cmp-tag);
  background-color: var(--cmp-tag);
  color: var(--cmp-band);
  font-weight: 600;
}

.cmp--tag-icon {
  flex-shrink: 0;
}

.cmp--strip {
  padding: 1rem;
  border-top: 1px solid var(--sectioncs-outline);
  background-color: var(--cmp-strip);
}

.cmp--button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.5rem 1rem;
  border: 1px solid var(--sectioncs-accents);
  border-radius: 0.25rem;
  background-color: var(--sectioncs-bg);
  color: var(--sectioncs-accents);
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  text-decoration: none;
  transition: color 0.1s, border-color 0.1s;
}

.cmp--button:hover {
  border-color: var(--cmp-band);
  color: var(--cmp-band);
}

/* Phone and tablet portrait: one card at a time once the script has run. */

@media (max-width: 799.98px) {
  .cmp--tabs:not([hidden]) {
    display: grid;
    grid-template-columns: repeat(var(--cmp-cols, 3), minmax(0, 1fr));
    grid-gap: 0.5rem;
    gap: 0.5rem;
  }

  .cmp--tab {
    min-height: 3rem;
    padding: 0.5rem 0.25rem;
    border: 1px solid var(--sectioncs-outline);
    border-radius: 0.25rem;
    background-color: var(--sectioncs-bg);
    color: var(--cmp-band);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25;
    cursor: pointer;
  }

  .cmp--tab[aria-pressed="true"] {
    border-color: var(--cmp-band);
    background-color: var(--cmp-band);
    color: #ffffff;
    font-weight: 600;
  }

  .cmp--intro + .cmp--tabs:not([hidden]) {
    margin-top: 1.5rem;
  }

  .cmp--tabs:not([hidden]) + .cmp--grid {
    margin-top: 0.75rem;
  }

  .cmp--tabbed .cmp--card:not(.cmp--current) {
    display: none;
  }
}

/* Desktop: cards side by side, rows aligned across cards. */

@media (min-width: 800px) {
  .cmp--section.cmp--joins-next {
    padding-bottom: 2.25rem;
  }

  .cmp--grid {
    grid-template-columns: repeat(var(--cmp-cols, 3), minmax(0, 1fr));
    margin-top: 2.5rem;
  }

  .cmp--media {
    height: 11.875rem;
  }

  .cmp--band {
    padding: 1.125rem 1.5rem 1.25rem;
  }

  .cmp--name {
    font-size: 1.375rem;
  }

  .cmp--band-link {
    display: inline-flex;
    align-items: center;
    min-height: 1.5rem;
    margin-top: 0.375rem;
    color: var(--cmp-band-link);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
  }

  .cmp--facts {
    padding: 0.25rem 1.5rem 0;
  }

  .cmp--row {
    min-height: 5.25rem;
    padding: 0.875rem 0;
  }

  .cmp--value {
    margin-top: 0.375rem;
    font-size: 1.0625rem;
  }

  .cmp--value-tags {
    margin-top: 0.5rem;
  }

  .cmp--strip {
    padding: 1.25rem 1.5rem;
  }
}

/* Four columns are too narrow below 1080px: two by two. */

@media (min-width: 800px) and (max-width: 1079.98px) {
  .cmp--cols-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Every card spans the same grid rows, so a long value in one card moves that row in all of them. */

@supports (grid-template-rows: subgrid) {
  @media (min-width: 800px) {
    .cmp--card {
      display: grid;
      grid-row: span var(--cmp-span);
      grid-template-rows: subgrid;
      grid-row-gap: 0;
      row-gap: 0;
    }

    .cmp--facts {
      display: grid;
      grid-row: span var(--cmp-rows);
      grid-template-rows: subgrid;
      grid-row-gap: 0;
      row-gap: 0;
    }
  }
}
