/* ---------- the two ways products connect, told apart on sight --------------
   Blue + a solid edge  = one product, several sizes.
   Teal + a dashed edge = different products, same thing.
   The dash/solid difference carries the meaning on its own, so the two are
   still distinguishable without relying on the colours. Everything in
   js/connections.js draws through these classes. */

/* Sizes borrows --blue, which css/groups.css already uses for a product with
   sizes. Same-thing needs a hue that is neither that blue nor the green the app
   spends on stock and coverage, so it's a proper cyan — cool enough not to be
   read as "in stock" at a glance. */
:root {
  --cx-size-c: var(--blue);
  --cx-same-c: #0891b2;
}
:root[data-theme="dark"] {
  --cx-same-c: #22d3ee;
}

/* ---- chips (a row in My Products, a heading on an ingredient) ---- */
.cx-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700;
  cursor: pointer; max-width: 100%;
  border: 1px solid transparent;
  transition: background-color .15s ease, border-color .15s ease;
}
.cx-chip .ic { width: 12px; height: 12px; flex: none; }
.cx-chip i { font-style: normal; font-weight: 500; opacity: .75; }
.cx-chip.sm { font-size: 11px; padding: 1px 8px; }

.cx-chip.cx-size {
  background: color-mix(in srgb, var(--cx-size-c) 12%, transparent);
  color: var(--cx-size-c);
  border-color: color-mix(in srgb, var(--cx-size-c) 26%, transparent);
}
.cx-chip.cx-size:hover { background: color-mix(in srgb, var(--cx-size-c) 22%, transparent); }

.cx-chip.cx-same {
  background: color-mix(in srgb, var(--cx-same-c) 12%, transparent);
  color: var(--cx-same-c);
  border-color: color-mix(in srgb, var(--cx-same-c) 30%, transparent);
  border-style: dashed;
}
.cx-chip.cx-same:hover { background: color-mix(in srgb, var(--cx-same-c) 22%, transparent); }

/* the hero pills use the page's own pill shape, just recoloured */
.pp-pill.cx-p-size {
  background: color-mix(in srgb, var(--cx-size-c) 14%, transparent);
  color: var(--cx-size-c);
}
.pp-pill.cx-p-same {
  background: color-mix(in srgb, var(--cx-same-c) 14%, transparent);
  color: var(--cx-same-c);
  border: 1px dashed color-mix(in srgb, var(--cx-same-c) 40%, transparent);
  padding: 2px 9px;
}

/* ---- the band under the product hero ---- */
.cx-band { display: grid; gap: 12px; margin: 0 0 16px; }

.cx-block {
  --c: var(--text-muted);
  position: relative;
  padding: 14px 16px 14px 18px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--c) 5%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--c) 20%, transparent);
  overflow: hidden;
}
.cx-block::before {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 4px;
  background: var(--c);
}
.cx-block.cx-size { --c: var(--cx-size-c); }
.cx-block.cx-same { --c: var(--cx-same-c); }
/* dashed edge for same-thing: the difference you can still see in greyscale */
.cx-block.cx-same::before {
  background: repeating-linear-gradient(to bottom,
    var(--c) 0 7px, transparent 7px 12px);
}
.cx-block.cx-none { --c: var(--border-strong); background: var(--surface-2); }
.cx-block.flat { background: color-mix(in srgb, var(--c) 6%, var(--surface)); }

.cx-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cx-kind {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase;
  color: var(--c);
}
.cx-kind .ic { width: 13px; height: 13px; }
.cx-head > b {
  font-size: 15.5px; font-weight: 750; letter-spacing: -.01em; color: var(--text);
}
.cx-block.cx-size .cx-head > b,
.cx-block.cx-same .cx-head > b { cursor: pointer; }
.cx-block.cx-size .cx-head > b:hover,
.cx-block.cx-same .cx-head > b:hover { color: var(--c); text-decoration: underline; text-underline-offset: 3px; }
.cx-block .cx-count {
  font-size: 11px; font-weight: 700; color: var(--c);
  background: color-mix(in srgb, var(--c) 13%, transparent);
  padding: 2px 8px; border-radius: 999px;
}

/* a "counts as" chip a size inherits from its product: not this size's to
   remove, so it reads as borrowed and opens the product instead */
.lchip.cx-inherit {
  cursor: pointer;
  background: color-mix(in srgb, var(--cx-size-c) 11%, transparent);
  color: var(--cx-size-c);
  border: 1px dashed color-mix(in srgb, var(--cx-size-c) 38%, transparent);
}
.lchip.cx-inherit:hover { background: color-mix(in srgb, var(--cx-size-c) 20%, transparent); }
.lchip.cx-inherit i { display: inline-flex; align-items: center; gap: 3px; opacity: .8; }
.lchip.cx-inherit i .ic { width: 11px; height: 11px; }

/* the row in My Products for a product with sizes already reads blue (see
   css/groups.css); its "counts as" line is the same-thing half, so it takes the
   same-thing colour and the two halves of the row say which is which */
.prow.vrow .pname small.vr-links:not(.todo) { color: var(--cx-same-c); opacity: 1; }

.cx-say { font-size: 12.5px; line-height: 1.55; color: var(--text-soft); margin: 7px 0 0; }
.cx-say b { color: var(--text); font-weight: 700; }

.cx-note {
  display: flex; gap: 7px; align-items: flex-start;
  font-size: 12px; line-height: 1.5; color: var(--text-muted); margin: 9px 0 0;
}
.cx-note > .ic { width: 14px; height: 14px; flex: none; margin-top: 1px; color: var(--c); }
.cx-note b { color: var(--text-soft); }

/* the other products in this arrangement */
.cx-mems { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }
.cx-mem {
  display: inline-flex; align-items: baseline; gap: 7px;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  font-size: 12.5px; font-weight: 650; color: var(--text-soft);
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease;
}
.cx-mem:hover { border-color: var(--c); color: var(--text); }
.cx-mem i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--text-muted); }
.cx-mem.in { border-color: color-mix(in srgb, var(--accent) 34%, transparent); }
.cx-mem.in i { color: var(--green-dark); }
.cx-mem.here {
  cursor: default;
  background: color-mix(in srgb, var(--c) 14%, transparent);
  border-color: color-mix(in srgb, var(--c) 40%, transparent);
  color: var(--text);
}
.cx-mem.here i { color: var(--c); font-weight: 700; }
.cx-mem.here:hover { border-color: color-mix(in srgb, var(--c) 40%, transparent); }
.cx-mem.more { border-style: dashed; color: var(--text-muted); font-weight: 700; }

/* the three things you came to check: stock, minimum, what it counts as */
.cx-facts {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 12px;
}
.cx-fact {
  display: flex; flex-direction: column; gap: 1px;
  flex: 1 1 150px; min-width: 0;
  padding: 8px 11px; border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.cx-fact b {
  font-size: 13px; font-weight: 750; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cx-fact i { font-style: normal; font-size: 11px; font-weight: 500; color: var(--text-muted); line-height: 1.35; }
.cx-fact.todo { border-style: dashed; }
.cx-fact.todo b { color: var(--text-muted); font-weight: 700; }
.cx-fact.ok b { color: var(--green-dark); }
.cx-fact.bad b { color: var(--red); }

.cx-acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.cx-acts .tool { font-size: 12px; }

/* the "on its own" state: one line, because most products are in it */
.cx-block.cx-none {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 9px 14px 9px 16px;
}
.cx-oneline { font-size: 12.5px; line-height: 1.5; color: var(--text-muted); }
.cx-oneline b { color: var(--text-soft); font-weight: 700; }
.cx-gap { flex: 1 1 0; min-width: 0; }
.cx-mini {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  padding: 5px 11px; border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  font-size: 12px; font-weight: 700; color: var(--text-soft);
  white-space: nowrap;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.cx-mini:hover { background: var(--surface-3); color: var(--text); }
.cx-mini .ic { width: 13px; height: 13px; }
.cx-mini:nth-of-type(1) .ic { color: var(--cx-size-c); }
.cx-mini:nth-of-type(1):hover { border-color: var(--cx-size-c); }
.cx-mini:nth-of-type(2) .ic { color: var(--cx-same-c); }
.cx-mini:nth-of-type(2):hover { border-color: var(--cx-same-c); }

@media (max-width: 720px) {
  .cx-block { padding: 12px 13px 12px 15px; }
  .cx-head > b { font-size: 14.5px; }
  /* two facts to a row rather than three stacked tiles — the band sits above
     the numbers you came for, so it can't cost half a screen on a phone */
  .cx-fact { flex: 1 1 42%; padding: 7px 9px; }
  .cx-fact b { font-size: 12.5px; }
  .cx-mems { gap: 5px; }
  .cx-mem { padding: 4px 9px; font-size: 12px; }
  .cx-acts .tool { flex: 1 1 auto; justify-content: center; }
}
