/* ==========================================================================
   ANTIHORIZN landing page, pipeline: the inside of the bill of materials stage.
   Built by assets/js/pipeline/parts.js, which sets every opacity and
   transform from the scroll clock; nothing here animates on its own.
   Everything is scoped under the stage's layer and sized from the layer
   (container units), so it holds from a 1280 x 720 window to 1920 x 1080.
     B1  Frame and measures
     B2  The library band
     B3  The search: need, filters, short list, match
     B4  The table
     B5  Narrow layers
   ========================================================================== */

/* --- B1. Frame and measures ------------------------------------------------ */

.pl__layer[data-stage="parts"] .plp {
  position: absolute;
  inset: 0;
  container-type: size;
  color: var(--on-dark);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
  text-align: left;
}
.plp__in {
  /* The search takes a fixed share of the height (the library band and the
     tier under it); the table's 19 rows (head, 16 lines, a foot two rows
     deep) share what is left. */
  --band: clamp(56px, calc(22cqh - 75px), 100px);
  --tier: clamp(112px, 21.3cqh, 180px);
  --gap: clamp(8px, 2.4cqh, 22px);
  --row: min(30px, calc((100cqh - var(--band) - var(--tier) - var(--gap)) / 19));
  /* Table type: half a row, and never so large that the longest description
     (about 20.5em) runs into the package column. */
  --fs: clamp(9px, min(calc(var(--row) * 0.5), calc((100cqw - 2 * var(--pad)) / 66.6)), 12.5px);
  --lab: clamp(9.5px, calc(var(--row) * 0.42), 11px);
  --pad: clamp(10px, 1.85cqh, 16px);
  --srow: clamp(16px, 2.9cqh, 24px);
  --c1: 22%;                        /* the need column; the band's counter sits over it */
  --hair: rgba(244, 244, 245, 0.075);
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-rows: auto auto;
  align-content: center;
  row-gap: var(--gap);
  font-size: var(--fs);
  line-height: 1.2;
  letter-spacing: -0.004em;
}
.plp [hidden] { display: none; }
.plp ul { margin: 0; padding: 0; list-style: none; }
.plp p { margin: 0; }
.plp i, .plp b { font-style: normal; font-weight: inherit; }

/* A value shown twice, resting colour under and the hot colour over: the
   script fades the hot colour in and out, so a colour change costs only opacity. */
.plp__w, .plp__y { display: block; }
.plp__y { position: absolute; left: 0; top: 0; color: var(--hot); opacity: 0; }

.plp__lab {
  display: block;
  font-size: var(--lab);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--pl-dimmer);
}
.plp__lab[data-b] { position: absolute; left: var(--pad); top: var(--pad); opacity: 0; }

.plp__search { border: 1px solid var(--pl-line); min-height: 0; }

/* --- B2. The library band --------------------------------------------------- */

.plp__band {
  display: grid;
  grid-template-columns: var(--c1) minmax(0, 1fr);
  height: var(--band);
  border-bottom: 1px solid var(--pl-line);
}
.plp__tally { position: relative; display: flex; flex-direction: column; justify-content: space-between; padding: var(--pad); padding-bottom: calc(var(--pad) - 3px); min-width: 0; }
.plp__count {
  position: relative;
  font-family: var(--display);
  font-size: clamp(26px, calc(9cqh - 26px), 46px);
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.plp__lib { display: flex; flex-direction: column; padding: var(--pad); padding-bottom: calc(var(--pad) - 2px); min-width: 0; border-left: 1px solid var(--pl-line); }
.plp__field { display: block; flex: 1 1 0; width: 100%; min-height: 0; }
.plp__rule {
  position: relative;
  display: flex;
  justify-content: space-between;
  margin-top: 3px;
  font-size: var(--lab);
  line-height: 1;
  white-space: nowrap;
  color: var(--pl-dimmer);
}
.plp__at {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  font-family: var(--mono);
  letter-spacing: 0;
  color: var(--hot);
  opacity: 0;
}

/* --- B3. The search: need, filters, short list, match ------------------------ */

.plp__tier { --cols: var(--c1) 23% 33% minmax(0, 1fr); position: relative; height: var(--tier); }
.plp__cols, .plp__set {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: var(--cols);
}
.plp__col { position: relative; padding: var(--pad); min-width: 0; }
.plp__col + .plp__col { border-left: 1px solid var(--pl-line); }
.plp__c {
  position: relative;
  min-width: 0;
  padding: calc(var(--pad) + var(--lab) + clamp(7px, 1.4cqh, 13px)) var(--pad) var(--pad);
}

/* The need, as the studio states it. */
.plp__ref {
  position: absolute;
  top: var(--pad);
  right: var(--pad);
  font-family: var(--mono);
  font-size: var(--lab);
  line-height: 1;
  letter-spacing: 0;
  color: var(--pl-dim);
}
.plp__need {
  font-size: clamp(13px, 2.15cqh, 17px);
  font-weight: 500;
  line-height: 1.3;
  letter-spacing: -0.012em;
  text-wrap: pretty;
}
.plp__off { color: transparent; }
.plp__caret { position: relative; display: inline-block; width: 0; height: 1em; vertical-align: -0.14em; }
.plp__caret::after { content: ""; position: absolute; left: 1px; top: 0; bottom: 0; width: 2px; background: var(--hot); }
.plp__note {
  margin-top: clamp(5px, 1.1cqh, 11px);
  font-size: var(--fs);
  line-height: 1.4;
  color: var(--pl-dim);
  text-wrap: pretty;
}
.plp__lamp { display: inline-block; width: 0.5em; height: 0.5em; margin-right: 0.5em; vertical-align: 0.12em; background: var(--hot); }

/* The filters, each with the number of parts it leaves. */
.plp__filters li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  height: var(--srow);
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
  color: var(--pl-dim);
}
.plp__filters li:last-child { border-bottom: 0; color: var(--on-dark); }
.plp__filters b { font-weight: 500; color: var(--on-dark); }

/* The short list: struck out with a reason, or picked. */
.plp__cand {
  display: flex;
  align-items: center;
  height: var(--srow);
  white-space: nowrap;
}
.plp__mk { flex: none; width: 5px; height: 5px; margin-right: 9px; background: var(--hot); opacity: 0; }
.plp__name, .plp__pick {
  position: relative;
  display: block;
  font-family: var(--mono);
  font-size: 0.9em;
  letter-spacing: 0;
}
.plp__name--text { font-family: var(--sans); font-size: 1em; letter-spacing: -0.004em; }
.plp__strike {
  position: absolute;
  left: -2px; right: -2px; top: 50%;
  height: 1px;
  background: var(--on-dark);
  transform: scaleX(0);
  transform-origin: left;
}
.plp__why { margin-left: auto; padding-left: 10px; color: var(--pl-dim); opacity: 0; }
/* The highlighter: the same text in ink on a the hot colour block, laid over
   the pick and wiped on and off with clip-path. */
.plp__hl {
  position: absolute;
  inset: -3px -5px;
  padding: 3px 5px;
  background: var(--hot);
  color: var(--ink);
  clip-path: inset(0 100% 0 0);
}
.plp__cand--val .plp__val { color: var(--on-dark); }
.plp__cand--val .plp__pick { margin-left: auto; opacity: 0; }

/* The match, with an outline of its package. */
.plp__c--match { display: flex; flex-direction: column; }
.plp__draw { position: relative; align-self: flex-start; }
.plp__pkg {
  display: block;
  width: auto;
  height: clamp(40px, 9.4cqh, 82px);
  aspect-ratio: 3 / 2;
  overflow: visible;
  fill: none;
  stroke: var(--on-dark);
  stroke-width: 1;
  stroke-linejoin: round;
}
.plp__pkg path { stroke-dasharray: 1 1; stroke-dashoffset: 1; opacity: 0; }
.plp__pkg .q { stroke: rgba(244, 244, 245, 0.56); }
.plp__dim { font-family: var(--sans); color: var(--pl-dimmer); opacity: 0; }
.plp__got { margin-top: auto; }
.plp__mpn { display: block; font-family: var(--mono); font-size: 0.9em; letter-spacing: 0; white-space: nowrap; }
.plp__mpn--text { font-family: var(--sans); font-size: 1em; font-weight: 500; letter-spacing: -0.004em; }
.plp__meta { display: flex; justify-content: space-between; gap: 10px; margin-top: 0.42em; white-space: nowrap; color: var(--pl-dim); }
.plp__meta b { color: var(--on-dark); }

/* At rest: the packages on the board, drawn side by side. */
.plp__c--family { grid-column: 2 / 5; display: flex; align-items: flex-end; }
.plp__family { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(8px, 1.6cqw, 18px); width: 100%; }
.plp__family li { display: flex; flex-direction: column; min-width: 0; white-space: nowrap; }
.plp__family .plp__pkg { height: clamp(34px, calc(var(--tier) * 0.4), 70px); max-width: 100%; margin-bottom: clamp(6px, 1.3cqh, 12px); }
.plp__family span { color: var(--on-dark); }
.plp__family b { margin-top: 0.3em; color: var(--pl-dim); }

/* --- B4. The table --------------------------------------------------------- */

.plp__table {
  --cells: 3.6em 10.6em 5.2em minmax(0, 1fr) 10.8em 1.8em 3.4em;
  display: grid;
  grid-auto-rows: var(--row);
  min-height: 0;
}
.plp__head, .plp__row {
  position: relative;
  display: grid;
  grid-template-columns: 2.2em minmax(0, 1fr) 3em;
  align-items: center;
  padding: 0 var(--pad);
  border-bottom: 1px solid var(--hair);
  white-space: nowrap;
}
.plp__cells {
  display: grid;
  grid-template-columns: var(--cells);
  column-gap: 1em;
  align-items: center;
  min-width: 0;
}
.plp__cells > span { min-width: 0; }
.plp__r { text-align: right; }
.plp__head {
  border-bottom-color: var(--pl-line);
  font-size: var(--lab);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pl-dimmer);
}
/* The head is set in the label size; keep its columns on the rows' grid. */
.plp__head { grid-template-columns: calc(2.2 * var(--fs)) minmax(0, 1fr) calc(3 * var(--fs)); }
.plp__head .plp__cells {
  grid-template-columns: calc(3.6 * var(--fs)) calc(10.6 * var(--fs)) calc(5.2 * var(--fs)) minmax(0, 1fr) calc(10.8 * var(--fs)) calc(1.8 * var(--fs)) calc(3.4 * var(--fs));
  column-gap: var(--fs);
}
.plp__n { color: var(--pl-dimmer); opacity: 0.6; transition: opacity 200ms var(--pl-ease); }
.plp__row[data-filled] .plp__n { opacity: 1; }
.plp__refs, .plp__pn { font-family: var(--mono); font-size: 0.9em; letter-spacing: 0; }
.plp__pn { position: relative; }
.plp__maker, .plp__pk { color: var(--pl-dim); }
.plp__hot {
  position: absolute;
  inset: 0;
  border-left: 2px solid var(--hot);
  background: rgba(255, 255, 255, 0.07);
  opacity: 0;
}
.plp__link { justify-self: end; display: block; width: 0.9em; height: 0.9em; opacity: 0; }
.plp__link svg { display: block; width: 100%; height: 100%; fill: none; stroke: var(--pl-dim); stroke-width: 1.1; }

.plp__foot {
  grid-row: span 2;
  display: flex;
  align-items: center;
  gap: clamp(20px, 4cqw, 44px);
  padding: 0 var(--pad);
  border-top: 1px solid var(--pl-line);
  margin-top: -1px;
  white-space: nowrap;
}
.plp__foot b {
  font-size: var(--lab);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pl-dimmer);
}
.plp__tot, .plp__sum { display: flex; align-items: baseline; gap: 0.7em; }
.plp__tot span { min-width: 1.3em; font-family: var(--display); font-size: 1.36em; font-weight: 600; letter-spacing: -0.02em; text-align: right; }
.plp__tot i { margin-left: -0.3em; color: var(--pl-dim); }
.plp__sum { margin-left: auto; }
.plp__sum span {
  min-width: 3.2em;
  font-family: var(--display);
  font-size: clamp(18px, calc(var(--row) * 0.94), 27px);
  font-weight: 600;
  letter-spacing: -0.02em;
  text-align: right;
}

/* --- B5. Narrow layers ------------------------------------------------------ */

/* A tablet: the match folds away and the maker column goes. */
@container (max-width: 740px) {
  .plp__in { --c1: 27%; }
  .plp__c--match .plp__dim { display: none; }
  .plp__tier { --cols: var(--c1) 28% minmax(0, 1fr); }
  .plp__col:nth-child(4), .plp__c--match { display: none; }
  .plp__c--family { grid-column: 2 / 4; }
  .plp__in { --fs: clamp(9px, calc(var(--row) * 0.5), 12.5px); }
  .plp__table { --cells: 3.6em 10.6em minmax(0, 1fr) 1.8em 3.4em; }
  .plp__head .plp__cells { grid-template-columns: calc(3.6 * var(--fs)) calc(10.6 * var(--fs)) minmax(0, 1fr) calc(1.8 * var(--fs)) calc(3.4 * var(--fs)); }
  .plp__cells > :nth-child(3), .plp__cells > :nth-child(5) { display: none; }
  .plp__desc { overflow: hidden; }
}
/* A phone: the library, the need, and the lines by reference, number and price. */
@container (max-width: 520px) {
  .plp__in { --c1: 34%; --pad: 8px; --band: 46px; --tier: clamp(56px, 17cqh, 78px); }
  .plp__tier { --cols: minmax(0, 1fr); }
  .plp__col:nth-child(n+2), .plp__c--lib, .plp__c--list, .plp__c--family, .plp__note, .plp__ref, .plp__rule { display: none; }
  .plp__need { font-size: 12.5px; }
  .plp__count { font-size: 20px; }
  .plp__table { --cells: 4.6em minmax(0, 1fr) 2em 3.6em; }
  .plp__head .plp__cells { grid-template-columns: calc(4.6 * var(--fs)) minmax(0, 1fr) calc(2 * var(--fs)) calc(3.6 * var(--fs)); }
  .plp__cells > :nth-child(4) { display: none; }
  .plp__head, .plp__row { grid-template-columns: 2em minmax(0, 1fr) 1.4em; }
  .plp__foot { gap: 14px; }
}
