/**
 * @file
 * Comparison table styles: sticky tier headers, category rows with a title and
 * description, zebra-striped feature rows, and red or grey tick marks.
 */

.ln-comparison {
  /* 0: css/layout.css supplies the gap between sections. Kept as a token so a
     one-off placement can still carry its own padding. */
  --ln-comparison-padding-block: 0;
  --ln-comparison-padding-inline: var(--ln-container-gutter, 15px);

  /**
   * Narrower than --ln-container-max on purpose: 1090px is the comp width, and
   * four columns stretched to 1440 read as a wall of whitespace.
   *
   * Because of that, the gutter stays on this root rather than moving onto
   * .ln-comparison__inner the way the 1440px sections do — inside the inner it
   * would come out of the 1090 and leave the table 30px narrow.
   */
  --ln-comparison-max-width: 1090px;

  --ln-comparison-fg: #1c1c1c;
  /* Kept in step with .ln-accordion__heading and the Text block's h2. */
  --ln-comparison-heading-fg: #1c1c1c;
  /* Category titles: deliberately distinct from the near-black used elsewhere. */
  --ln-comparison-group-fg: #051b2c;
  --ln-comparison-tier-fg: #1c1c1c;
  --ln-comparison-muted: #63666a;
  --ln-comparison-stripe: #f4f4f3;
  /* Transparent: the Layout Builder section paints the background. */
  --ln-comparison-bg: transparent;

  /* Translucent and blurred, so rows read as passing beneath the tier row while
     the section itself stays opaque. */
  --ln-comparison-head-bg: rgb(255 255 255 / 80%);
  --ln-comparison-head-backdrop: blur(8px);

  --ln-comparison-mark: #cf0000;
  --ln-comparison-mark-excluded: #c6c6c6;

  --ln-comparison-font: Outfit, sans-serif;

  /* Tokens, because the expand caret's height is derived from them. */
  --ln-comparison-group-title-size: 24px;
  --ln-comparison-group-title-leading: 1.3;

  /* 1, so the subhead sits tight under the title. There is no leading at all, so
     a translated description that wraps to two lines will sit flush. */
  --ln-comparison-group-description-leading: 1;

  /* Restated on the paragraph too — see .ln-comparison__group-description p. */
  --ln-comparison-group-description-weight: 500;

  --ln-comparison-toggle-gap: 12px;
  --ln-comparison-caret-size: 14px;

  /* Derived from what the caret occupies inside the toggle, so the first column
     tracks the caret size and gap instead of falling out of alignment. */
  --ln-comparison-feature-indent: calc(
    var(--ln-comparison-cell-padding-inline) +
    var(--ln-comparison-caret-size) +
    var(--ln-comparison-toggle-gap)
  );

  --ln-comparison-feature-width: 40.7%;
  --ln-comparison-cell-padding-block: 14px;
  --ln-comparison-cell-padding-inline: 14px;

  /* Offset for the sticky tier row, so it pins below the sticky site header.
     Nothing defines --ln-site-header-height yet; the fallback is the header's 60px. */
  --ln-comparison-sticky-top: var(--ln-site-header-height, 60px);

  /* Above table content, but must stay below the site header. */
  --ln-comparison-head-z: 2;

  box-sizing: border-box;
  padding-block: var(--ln-comparison-padding-block);
  padding-inline: var(--ln-comparison-padding-inline);
  background-color: var(--ln-comparison-bg);
  color: var(--ln-comparison-fg);
  font-family: var(--ln-comparison-font);
}

.ln-comparison *,
.ln-comparison *::before,
.ln-comparison *::after {
  box-sizing: inherit;
}

.ln-comparison__inner {
  max-width: var(--ln-comparison-max-width);
  margin-inline: auto;
}

/* Centred to match the accordion heading; category headings stay left-aligned. */
.ln-comparison__heading {
  margin: 0 0 2rem;
  font-size: clamp(2rem, 3.5vw, 48px);
  font-weight: 500;
  line-height: 1.3;
  text-align: center;
  text-wrap: balance;
  color: var(--ln-comparison-heading-fg);
}

/**
 * .ln-comparison__scroll is a plain wrapper now — no overflow, no focus ring.
 *
 * If scrolling is ever reinstated: a scroll container's min-content contribution
 * is zero, but its max-content contribution is its full content width.
 */
.ln-comparison__table {
  /* No min-width, on purpose: with no scroll container a legibility floor could
     only overflow the section. */
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

/**
 * Sticky tier row, set on the cells — thead and tr are not reliable containers.
 *
 * Sticky and horizontal scroll cannot coexist: overflow-x: auto makes an element
 * a scroll container on BOTH axes per spec, and any ancestor with non-visible
 * overflow breaks sticky silently. `top` reads --ln-site-header-height.
 */
.ln-comparison__head th {
  position: sticky;
  top: var(--ln-comparison-sticky-top);
  z-index: var(--ln-comparison-head-z);
  /* Symmetric: pinned and translucent, an uneven inset reads as a lopsided band. */
  padding: 0.75rem var(--ln-comparison-cell-padding-inline);
  background-color: var(--ln-comparison-head-bg);

  /* -webkit- prefix for Safari before 18; elsewhere the translucent fill stands alone. */
  -webkit-backdrop-filter: var(--ln-comparison-head-backdrop);
  backdrop-filter: var(--ln-comparison-head-backdrop);
  font-size: 24px;
  font-weight: 600;
  color: var(--ln-comparison-tier-fg);
}

/* Solid tier row and no blur when the OS asks for reduced transparency. */
@media (prefers-reduced-transparency: reduce) {
  .ln-comparison {
    --ln-comparison-head-bg: #ffffff;
    --ln-comparison-head-backdrop: none;
  }
}

.ln-comparison__corner {
  width: var(--ln-comparison-feature-width);
}

.ln-comparison__tier {
  text-align: center;
}

.ln-comparison__group-cell {
  padding: 2.5rem 0 0.5rem;
  font-weight: 400;
}

/* Caret first, then the title and description as one column. */
.ln-comparison__toggle {
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: var(--ln-comparison-toggle-gap);
  width: 100%;
  padding: 0 var(--ln-comparison-cell-padding-inline) 1rem;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

/* Class doubled to outrank Site Studio's global button rules, which would give a
   disclosure control a brand-red CTA hover fill. */
.ln-comparison__toggle.ln-comparison__toggle:hover,
.ln-comparison__toggle.ln-comparison__toggle:focus,
.ln-comparison__toggle.ln-comparison__toggle:active {
  border: 0;
  background: none;
  box-shadow: none;
  color: inherit;
  text-decoration: none;
}

.ln-comparison__toggle:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 2px;
}

/* Title and description as one flex item, so both indent past the caret. */
.ln-comparison__group-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 16px;
  min-inline-size: 0;
}

.ln-comparison__group-title {
  font-size: var(--ln-comparison-group-title-size);
  font-weight: 600;
  line-height: var(--ln-comparison-group-title-leading);
  color: var(--ln-comparison-group-fg);
}

/* Weight set here rather than left to <strong> tags in translated content. */
.ln-comparison__group-description {
  font-size: 16px;
  font-weight: var(--ln-comparison-group-description-weight);
  line-height: var(--ln-comparison-group-description-leading);
  color: var(--ln-comparison-muted);
}

/**
 * Restated on the paragraph, not inherited: Site Studio sets line-height on p
 * globally, and a rule on the element beats any inherited value from an ancestor.
 */
.ln-comparison__group-description p {
  font-weight: var(--ln-comparison-group-description-weight);
  line-height: var(--ln-comparison-group-description-leading);
}

/**
 * Descendant selectors, not child ones: field_description renders as
 * span > div > p, so `>` matches the div and leaves the paragraph's margin.
 */
.ln-comparison__group-description :first-child {
  margin-top: 0;
}

.ln-comparison__group-description :last-child {
  margin-bottom: 0;
}

/* One title line tall, so the caret centres on the heading, not on the button. */
.ln-comparison__toggle-icon {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  block-size: calc(
    var(--ln-comparison-group-title-size) *
    var(--ln-comparison-group-title-leading)
  );
  color: var(--ln-comparison-mark);
  transition: transform 0.15s ease-in-out;
}

.ln-comparison__toggle-icon svg {
  display: block;
  width: var(--ln-comparison-caret-size);
  height: auto;
}

.ln-comparison__toggle[aria-expanded='true'] .ln-comparison__toggle-icon {
  transform: rotate(180deg);
}

/* vertical-align is explicit: Site Studio's global table styles set cells to top. */
.ln-comparison__feature,
.ln-comparison__cell {
  padding: var(--ln-comparison-cell-padding-block) var(--ln-comparison-cell-padding-inline);
  vertical-align: middle;
  font-size: 16px;
  font-weight: 400;
  line-height: 1.5;
}

/* Muted grey and indented to sit under the group titles; tier columns stay centred. */
.ln-comparison__feature {
  padding-inline-start: var(--ln-comparison-feature-indent);
  font-weight: 400;
  color: var(--ln-comparison-muted);
}

.ln-comparison__cell {
  text-align: center;
  white-space: nowrap;
}

.ln-comparison__value {
  font-weight: 600;
  color: var(--ln-comparison-fg);
}

/* Zebra striping runs within each category. */
.ln-comparison__group-rows .ln-comparison__row:nth-child(even) > * {
  background-color: var(--ln-comparison-stripe);
}

.ln-comparison__mark {
  display: inline-flex;
  color: var(--ln-comparison-mark);
}

.ln-comparison__mark--excluded {
  color: var(--ln-comparison-mark-excluded);
}

.ln-comparison__mark svg {
  display: block;
}

/**
 * The media queries live at the end deliberately: a media query adds no
 * specificity, so an override placed above what it overrides loses on source order.
 */
@media (prefers-reduced-motion: reduce) {
  .ln-comparison__toggle-icon {
    transition: none;
  }
}

@media (max-width: 48rem) {
  .ln-comparison {
    --ln-comparison-padding-block: 0;

    /* The token, not the property on .ln-comparison__group-title, so the caret's
       height tracks the smaller title. */
    --ln-comparison-group-title-size: 20px;

    /* Less for the feature column on purpose: it can wrap over as many lines as
       it likes, and a one-word tier header cannot. */
    --ln-comparison-feature-width: 34%;

    /* The cheapest place to find room. Narrows the derived caret indent too. */
    --ln-comparison-cell-padding-inline: 6px;
  }

  /* Fixed, so width: 100% is binding — under auto layout a table is never
     narrower than its min-content width and `width` is only a suggestion. */
  .ln-comparison__table {
    table-layout: fixed;
  }

  .ln-comparison__head th {
    font-size: 14px;
  }

  .ln-comparison__feature,
  .ln-comparison__cell {
    font-size: 14px;
  }

  /* Safety valves: a fixed column cannot grow to fit, so long words must wrap. */
  .ln-comparison__feature {
    overflow-wrap: break-word;
  }

  .ln-comparison__cell {
    white-space: normal;
  }
}

