/* ==========================================================================
   20-COMPARE  --  side-by-side model comparison (Lane B, 2026-08-14)

   Owns: the per-card Compare picker on /products/, the sticky selection bar,
   and the modal comparison table. Nothing here touches main.css.

   Everything is inert until compare.js adds .js-compare to the html element,
   so a visitor without JS sees the ordinary catalog with no dead controls.
   Visual language is the site's own: crimson #E01A2B (var(--ir)), IBM Plex
   Mono eyebrows, hairline borders, square corners.
   ========================================================================== */

/* -- 1. Per-card picker ---------------------------------------------------- */

.cmpitem { position: relative; }

/* Hidden by default: no JS, no control. */
.cmpitem__pick { display: none; }
.js-compare .cmpitem__pick {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

/* The real checkbox stays in the accessibility tree and keeps keyboard
   semantics; the label is the visible target. */
.cmppick__box {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.cmppick {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  padding: 7px 13px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  font-family: var(--ff-mono);
  font-size: .68rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-45);
  transition: border-color var(--t-fast), color var(--t-fast), background var(--t-fast);
}
.cmppick:hover { border-color: var(--line-2); color: var(--ink); }

/* Square tick box, drawn rather than imported. */
.cmppick__mark {
  position: relative;
  flex: 0 0 auto;
  width: 13px; height: 13px;
  border: 1px solid var(--line-2);
  background: #fff;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.cmppick__mark::after {
  content: "";
  position: absolute;
  left: 3px; top: 0;
  width: 4px; height: 8px;
  border: solid #fff;
  border-width: 0 1.6px 1.6px 0;
  transform: rotate(43deg) scale(0);
  transform-origin: center;
  transition: transform var(--t-fast) var(--ease-snap);
}

.cmppick__box:checked + .cmppick {
  border-color: var(--ir);
  color: var(--ir);
  background: rgba(224, 26, 43, .045);
}
.cmppick__box:checked + .cmppick .cmppick__mark { background: var(--ir); border-color: var(--ir); }
.cmppick__box:checked + .cmppick .cmppick__mark::after { transform: rotate(43deg) scale(1); }
.cmppick__box:focus-visible + .cmppick { outline: 2px solid var(--ir); outline-offset: 2px; }

/* A picked card is marked on the card itself, not only on its control. */
.js-compare .cmpitem.is-picked .prow { border-color: var(--ir); box-shadow: inset 3px 0 0 var(--ir), var(--sh-1); }

/* One-line explainer above the list; JS-only, so it is never shown to a
   reader who cannot use it. */
.cmpintro { display: none; }
.js-compare .cmpintro {
  display: block;
  margin: 14px 0 0;
  font-family: var(--ff-mono);
  font-size: .7rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--ink-45);
}
.cmpintro b { color: var(--ir); font-weight: 500; }


/* -- 2. Sticky selection bar ---------------------------------------------- */

/* main.css puts a 52px .mobar (WhatsApp / Request a quote) at bottom:0 under
   760px. The compare bar stacks on top of it rather than burying its own
   action buttons underneath it. --cmpbar-bottom carries that offset into every
   rule that has to clear the fixed chrome. */
:root { --cmpbar-bottom: 0px; }
@media (max-width: 760px) { :root { --cmpbar-bottom: 52px; } }

.cmpbar {
  position: fixed;
  left: 0; right: 0; bottom: var(--cmpbar-bottom, 0px);
  /* Above the WhatsApp bubble (z-index 90 in main.css), which otherwise sits
     on top of the primary action. The bubble is lifted clear of the bar below
     rather than hidden -- it is the site's only always-on contact route. */
  z-index: 95;
  background: var(--ink);
  color: #fff;
  border-top: 1px solid rgba(255, 255, 255, .12);
  box-shadow: 0 -18px 40px -22px rgba(16, 24, 32, .8);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom, 0px));
}
.cmpbar[hidden] { display: none; }

.cmpbar__row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}
.cmpbar__status {
  margin: 0;
  flex: 0 0 auto;
  font-size: .66rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #98A4B0;
}
.cmpbar__status b { color: #fff; font-weight: 500; }
.cmpbar__status.is-warn { color: #FF8D97; }

.cmpbar__chips {
  list-style: none;
  margin: 0; padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1 1 240px;
  min-width: 0;
}
.cmpchip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 5px 4px 10px;
  border: 1px solid rgba(255, 255, 255, .2);
  border-radius: var(--radius);
  font-family: var(--ff-mono);
  font-size: .68rem;
  letter-spacing: .06em;
  color: #fff;
  max-width: 100%;
}
.cmpchip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmpchip__x {
  flex: 0 0 auto;
  width: 18px; height: 18px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 0;
  background: rgba(255, 255, 255, .1);
  color: #fff;
  font: inherit;
  font-size: .8rem;
  line-height: 1;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background var(--t-fast), color var(--t-fast);
}
.cmpchip__x:hover { background: var(--ir); }
.cmpchip__x:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

.cmpbar__acts { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; margin-left: auto; }
.cmpbar__acts .btn[disabled] { opacity: .45; cursor: not-allowed; transform: none; box-shadow: none; }

/* Keep the last catalog row, the footer and the chat bubble clear of the fixed
   bar. compare.js measures the bar and publishes --cmpbar-h, so this stays
   correct when the bar wraps to two or three lines on a narrow screen. */
.js-compare.has-cmpbar body { padding-bottom: calc(var(--cmpbar-h, 96px) + var(--cmpbar-bottom, 0px) + 16px); }
.js-compare.has-cmpbar { scroll-padding-bottom: calc(var(--cmpbar-h, 96px) + var(--cmpbar-bottom, 0px) + 24px); }
.js-compare.has-cmpbar .wabub { bottom: calc(var(--cmpbar-h, 96px) + var(--cmpbar-bottom, 0px) + 16px); }


/* -- 3. Comparison dialog -------------------------------------------------- */

.cmpdlg {
  width: min(1200px, calc(100vw - 24px));
  max-width: 100%;
  max-height: min(88vh, 900px);
  padding: 0;
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
.cmpdlg::backdrop { background: rgba(11, 18, 32, .62); }
.cmpdlg:not([open]) { display: none; }

/* Column layout so only the table body scrolls. */
.cmpdlg__inner { display: flex; flex-direction: column; max-height: inherit; }

.cmpdlg__head {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 16px clamp(14px, 2.4vw, 26px);
  border-bottom: 1px solid var(--line);
  background: #fff;
}
.cmpdlg__title {
  margin: 0;
  font-family: var(--ff-display);
  font-weight: 800;
  font-size: 1.02rem;
  text-transform: uppercase;
  letter-spacing: -.01em;
  flex: 1 1 auto;
  min-width: 0;
}
.cmpdlg__eyebrow {
  display: block;
  font-family: var(--ff-mono);
  font-weight: 400;
  font-size: .62rem;
  letter-spacing: .16em;
  color: var(--ir);
  margin-bottom: 4px;
}

.cmpdiff {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  cursor: pointer;
  font-family: var(--ff-mono);
  font-size: .66rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-70);
}
.cmpdiff input { width: 15px; height: 15px; accent-color: var(--ir); cursor: pointer; }

.cmpdlg__x {
  flex: 0 0 auto;
  width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: var(--radius);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  transition: border-color var(--t-fast), color var(--t-fast);
}
.cmpdlg__x:hover { border-color: var(--ir); color: var(--ir); }
.cmpdlg__x:focus-visible { outline: 2px solid var(--ir); outline-offset: 2px; }

/* The single scroll container: vertical for rows, horizontal for columns.
   Nothing inside is allowed to widen the page. */
.cmpdlg__scroll {
  flex: 1 1 auto;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #fff;
}

/* table-layout:fixed keeps the columns even; min-width:100% lets them share
   the slack when two models are compared on a wide screen, instead of leaving
   the right third of the dialog empty. */
.cmptable {
  border-collapse: separate;
  border-spacing: 0;
  font-size: .82rem;
  table-layout: fixed;
  min-width: 100%;
}
.cmptable th, .cmptable td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
  overflow-wrap: anywhere;
  word-break: normal;
}

/* Row header: the parameter name, pinned to the left edge while columns scroll. */
.cmptable tbody th[scope="row"] {
  position: sticky;
  left: 0;
  z-index: 2;
  width: 132px;
  min-width: 132px;
  background: var(--paper-2);
  border-right: 1px solid var(--line);
  font-family: var(--ff-mono);
  font-weight: 400;
  font-size: .66rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--ink-70);
}

/* Column header: model identity + its remove control. */
.cmptable thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--ink);
  color: #fff;
  border-bottom: 2px solid var(--ir);
  width: 190px;
  min-width: 190px;
}
.cmptable thead th.cmptable__corner {
  left: 0;
  z-index: 4;
  width: 132px;
  min-width: 132px;
  font-family: var(--ff-mono);
  font-weight: 400;
  font-size: .62rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #98A4B0;
}

/* Thumbnail and remove button share the top line; the identity block then gets
   the whole column, so LRF3000A1 never breaks into "LRF3000A / 1". */
.cmphead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 8px;
}
.cmphead__img {
  grid-column: 1; grid-row: 1;
  width: 42px; height: 42px;
  object-fit: contain;
  background: #fff;
  padding: 3px;
  border-radius: var(--radius);
}
.cmphead__txt { grid-column: 1 / -1; grid-row: 2; min-width: 0; }
.cmphead__name {
  display: block;
  font-family: var(--ff-display);
  font-weight: 800;
  font-size: .86rem;
  text-transform: uppercase;
  letter-spacing: -.01em;
  line-height: 1.15;
  /* A model number is one token: break it and it stops being a model number. */
  overflow-wrap: normal;
  word-break: keep-all;
}
.cmphead__series {
  display: block;
  margin-top: 3px;
  font-family: var(--ff-mono);
  font-weight: 400;
  font-size: .58rem;
  letter-spacing: .06em;
  color: #98A4B0;
  overflow-wrap: anywhere;
}
.cmphead__link {
  display: inline-block;
  margin-top: 6px;
  font-family: var(--ff-mono);
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: #fff;
  border-bottom: 1px solid var(--ir);
  text-decoration: none;
}
.cmphead__link:hover { color: var(--ir); }
.cmphead__x {
  grid-column: 3; grid-row: 1;
  justify-self: end;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255, 255, 255, .26);
  background: transparent;
  color: #fff;
  border-radius: var(--radius);
  font: inherit;
  font-size: .8rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.cmphead__x:hover { background: var(--ir); border-color: var(--ir); }
.cmphead__x:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* Group heading rows. The cell spans every column and does NOT stick; its
   label does, so the heading stays readable at the left edge while the model
   columns scroll underneath it. */
.cmptable .cmpgroup th {
  background: var(--tint);
  border-top: 1px solid var(--line-2);
  border-bottom: 1px solid var(--line);
  font-family: var(--ff-mono);
  font-weight: 400;
  font-size: .62rem;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink);
  width: auto;
  min-width: 0;
}
.cmpgroup__t { position: sticky; left: 0; display: inline-block; max-width: 100%; }
.cmptable .cmpgroup th i { font-style: normal; color: var(--ink-45); letter-spacing: .06em; text-transform: none; }

.cmptable td {
  font-family: var(--ff-mono);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  background: #fff;
}
.cmptable td.is-none { color: var(--ink-45); }

/* Rows where every selected model prints the same value are pushed back so the
   differences read first. Rows that differ get the crimson rail. */
.cmptable tr.is-same th[scope="row"], .cmptable tr.is-same td { color: var(--ink-45); background: #FCFDFE; }
.cmptable tr.is-same th[scope="row"] { background: var(--paper-2); }
.cmptable tr.is-diff th[scope="row"] { box-shadow: inset 3px 0 0 var(--ir); color: var(--ink); }
.cmptable tr.is-diff td { color: var(--ink); font-weight: 500; }
.cmptable tr.is-diff td.is-hi { background: rgba(224, 26, 43, .05); }

/* "Only differences" filter. */
.cmptable.is-diffonly tr.is-same { display: none; }

.cmpdlg__foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 14px clamp(14px, 2.4vw, 26px);
  border-top: 1px solid var(--line);
  background: var(--paper);
}
.cmpshare { display: flex; align-items: center; gap: 8px; flex: 1 1 320px; min-width: 0; }
.cmpshare__label {
  flex: 0 0 auto;
  font-family: var(--ff-mono);
  font-size: .62rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ink-45);
}
/* One click selects the whole link, so Copy has a manual fallback that needs
   no clipboard permission. It wraps rather than scrolls: a scrolling box would
   clip its own text at 360px. */
.cmpshare__url {
  flex: 1 1 auto;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-family: var(--ff-mono);
  font-size: .68rem;
  line-height: 1.45;
  color: var(--ink-70);
  overflow-wrap: anywhere;
  user-select: all;
  -webkit-user-select: all;
}
.cmpshare__url:focus-visible { outline: 2px solid var(--ir); outline-offset: 1px; }
.cmpdlg__note {
  flex: 1 1 100%;
  margin: 0;
  font-size: .72rem;
  line-height: 1.5;
  color: var(--ink-45);
}
.cmpsay { display: block; margin-top: 4px; font-family: var(--ff-mono); font-size: .64rem; color: var(--ir); }


/* -- 4. Narrow screens ----------------------------------------------------- */
/* At 360px the bar stacks and the table scrolls inside .cmpdlg__scroll; the
   page itself never gains a horizontal scrollbar. */
@media (max-width: 640px) {
  .cmpbar { padding-top: 10px; }
  .cmpbar__row { gap: 8px 12px; }
  .cmpbar__acts { margin-left: 0; width: 100%; }
  .cmpbar__acts .btn { flex: 1 1 auto; justify-content: center; }
  /* Chips scroll sideways instead of wrapping: on a phone the bar already
     stacks on the .mobar, so every extra line it grows is screen the catalog
     loses. A scroll container also keeps it out of the overflow sweep. */
  .cmpbar__chips { flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .cmpchip { flex: 0 0 auto; }
  .cmpchip__name { max-width: 128px; }

  .cmpdlg { width: 100vw; max-width: 100vw; max-height: 100vh; height: 100vh; border: 0; border-radius: 0; }
  .cmpdlg__inner { max-height: 100vh; height: 100vh; }
  .cmptable thead th { width: 168px; min-width: 168px; }
  .cmptable tbody th[scope="row"], .cmptable thead th.cmptable__corner { width: 104px; min-width: 104px; }
  .cmptable th, .cmptable td { padding: 9px 10px; font-size: .76rem; }
  .cmpdlg__foot { gap: 8px; }
  .cmpshare { flex: 1 1 100%; }
}


/* -- 5. Reduced motion ----------------------------------------------------- */
/* main.css already kills every transition with !important under this query;
   these rules pin the states that are otherwise reached by a transform. */
@media (prefers-reduced-motion: reduce) {
  .cmppick__mark::after { transform: rotate(43deg) scale(0); }
  .cmppick__box:checked + .cmppick .cmppick__mark::after { transform: rotate(43deg) scale(1); }
  .cmpbar { box-shadow: none; }
}


/* -- 6. Print -------------------------------------------------------------- */
@media print {
  .cmpbar, .cmpitem__pick, .cmpintro { display: none !important; }
}
