/* ==========================================================================
   Strain lineage explorer (general_pages/strain_lineages.html)
   --------------------------------------------------------------------------
   Scoped under .cc-lx and built from the brand tokens in css/styles.css. The
   graph itself is the shared component (css/components/lineage_graph.css);
   the rules here place it and style the search, path and details panel.
   Behaviour: js/pages/products/strainLineageExplorer_10042026.js. Notes:
   docs/STRAIN_LINEAGES.md.

   Refactoring UI principles applied:
   * One spacing scale (--lx-space-*), one radius pair, one type scale.
   * The search is the primary action: the largest field on the page with
     the only solid green button. Everything else is quieter (outlined chips,
     text buttons).
   * Hierarchy through weight and color before size: bone titles, muted
     secondary text, small uppercase green eyebrows for context labels.
   * Numbers lead in the stats (large value, small muted label).
   * Separation from spacing and surface tone; borders stay low-contrast.
   * The graph gets the room: details sit beside it on wide screens and
     below it on narrow ones, so nothing scrolls sideways.
   * Motion is short, uses transforms and opacity, and is off under
     prefers-reduced-motion.
   ========================================================================== */

.cc-lx {
  --lx-space-1: 0.25rem;
  --lx-space-2: 0.5rem;
  --lx-space-3: 0.75rem;
  --lx-space-4: 1rem;
  --lx-space-5: 1.5rem;
  --lx-space-6: 2rem;
  --lx-space-7: 3rem;
  --lx-radius: 16px;
  --lx-radius-sm: 10px;
  --lx-gutter: 1rem;
  --lx-surface: var(--cc-surface-1, #1a1a1a);
  --lx-raised: var(--cc-surface-2, #242424);
  --lx-border: rgba(var(--cc-bone-rgb), 0.1);
  --lx-border-strong: rgba(var(--cc-bone-rgb), 0.18);
  --lx-muted: var(--cc-muted, #b3b3b3);
  --lx-target: 40px;
  max-width: 1440px;
  margin-inline: auto;
  padding: var(--lx-space-7) var(--lx-gutter) 4rem;
  color: var(--cc-bone);
}

@media (min-width: 768px) { .cc-lx { --lx-gutter: 1.5rem; } }
@media (min-width: 1200px) { .cc-lx { --lx-gutter: 2rem; } }
@media (pointer: coarse) { .cc-lx { --lx-target: 44px; } }

.cc-lx :is(button, a, input):focus-visible {
  outline: 3px solid var(--cc-bone);
  outline-offset: 2px;
  box-shadow: none;
}

/* ----------------------------------------------------------- Shared type */
.cc-lx-eyebrow {
  margin: 0 0 var(--lx-space-2);
  color: var(--cc-green);
  font: 600 0.75rem/1.5 var(--cc-font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.cc-lx-label {
  margin: 0 0 var(--lx-space-2);
  color: var(--lx-muted);
  font: 600 0.6875rem/1.5 var(--cc-font-body);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.cc-lx-empty,
.cc-lx-note {
  margin: 0;
  color: var(--lx-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ Hero */
.cc-lx-hero {
  display: grid;
  gap: var(--lx-space-5);
  margin-bottom: var(--lx-space-6);
}

@media (min-width: 992px) {
  .cc-lx-hero {
    grid-template-columns: minmax(0, 1fr) minmax(380px, 36rem);
    align-items: center;
    gap: var(--lx-space-6);
  }
}

.cc-lx-hero h1 {
  margin: 0 0 var(--lx-space-4);
  font-size: clamp(2.75rem, 5vw, 4.5rem);
  line-height: 1.05;
}

.cc-lx-intro {
  max-width: 38rem;
  margin: 0;
  color: var(--lx-muted);
  line-height: 1.7;
}

.cc-lx-search-card {
  display: grid;
  gap: var(--lx-space-4);
  padding: var(--lx-space-5);
  border: 1px solid var(--lx-border);
  border-radius: var(--lx-radius);
  background: var(--lx-surface);
}

/* ---------------------------------------------------------------- Search */
.cc-lx-search { display: grid; gap: var(--lx-space-2); }

.cc-lx-search__label {
  color: var(--cc-bone);
  font: 600 0.875rem/1.5 var(--cc-font-body);
}

.cc-lx-search__field {
  position: relative;
  display: flex;
  gap: var(--lx-space-2);
}

.cc-lx-search__icon {
  position: absolute;
  top: 50%;
  left: 1rem;
  z-index: 1;
  transform: translateY(-50%);
  color: var(--lx-muted);
  pointer-events: none;
}

/* 3:1+ outline on the #101010 fill; outranks the site-wide default field
   border in styles.css by specificity. */
.cc-lx .cc-lx-search input.cc-lx-search__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 52px;
  padding-left: 2.75rem;
  color: var(--cc-bone);
  background-color: #101010;
  border: 1px solid var(--cc-control-border, #707070);
  border-radius: var(--lx-radius-sm);
  font-size: 1rem;
}

.cc-lx .cc-lx-search input.cc-lx-search__input::placeholder { color: #a6a6a6; opacity: 1; }

.cc-lx .cc-lx-search input.cc-lx-search__input:focus {
  border-color: var(--cc-green);
  box-shadow: 0 0 0 3px rgba(var(--cc-green-rgb), 0.18);
}

.cc-lx .cc-lx-search__submit {
  flex: none;
  min-height: 52px;
  padding-inline: var(--lx-space-5);
  border-radius: var(--lx-radius-sm);
  font: 600 0.9375rem/1 var(--cc-font-body);
  letter-spacing: 0;
  text-transform: none;
  box-shadow: none;
}

.cc-lx-status {
  min-height: 1.25rem;
  margin: 0;
  color: var(--lx-muted);
  font-size: 0.8125rem;
  line-height: 1.5;
}

.cc-lx-status[data-tone="error"] { color: var(--cc-pink-hover, #ff5288); }

/* ----------------------------------------------------------------- Chips */
.cc-lx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--lx-space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.cc-lx-chips--center { justify-content: center; }
.cc-lx-chips li[hidden] { display: none; }

.cc-lx-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--lx-space-2);
  max-width: 100%;
  min-height: var(--lx-target);
  padding: 0 0.875rem;
  border: 1px solid var(--lx-border-strong);
  border-radius: 999px;
  background: var(--lx-raised);
  color: var(--cc-bone);
  font: 500 0.8125rem/1.2 var(--cc-font-body);
  text-align: left;
  transition:
    background-color var(--cc-motion-fast, 160ms) ease,
    border-color var(--cc-motion-fast, 160ms) ease,
    color var(--cc-motion-fast, 160ms) ease;
}

.cc-lx-chip__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.cc-lx-chip__count {
  min-width: 1.5rem;
  padding: 0.125rem 0.4rem;
  border-radius: 999px;
  background: rgba(var(--cc-black-rgb), 0.6);
  color: var(--lx-muted);
  font-size: 0.6875rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.cc-lx-chip:hover {
  border-color: rgba(var(--cc-green-rgb), 0.6);
  background: rgba(var(--cc-green-rgb), 0.1);
  color: var(--cc-green);
}

.cc-lx-chip-skeleton {
  width: 6.5rem;
  height: var(--lx-target);
  border-radius: 999px;
  background: linear-gradient(90deg, var(--lx-raised) 0%, #2e2e2e 50%, var(--lx-raised) 100%);
  background-size: 200% 100%;
  animation: cc-lx-shimmer 1.2s linear infinite;
}

.cc-lx-chip-skeleton:nth-child(2n) { width: 5rem; }
.cc-lx-chip-skeleton:nth-child(3n) { width: 7.5rem; }

@keyframes cc-lx-shimmer { to { background-position: -200% 0; } }

/* "Show all" for long chip lists and the product list. */
.cc-lx-more {
  display: inline-flex;
  align-items: center;
  min-height: var(--lx-target);
  margin-top: var(--lx-space-1);
  padding: 0 var(--lx-space-1);
  border: 0;
  background: none;
  color: var(--cc-green);
  font: 600 0.8125rem/1 var(--cc-font-body);
}

.cc-lx-more:hover { color: var(--cc-green-hover); text-decoration: underline; }

/* ------------------------------------------------------------- Workspace */
.cc-lx-workspace {
  display: grid;
  gap: var(--lx-space-5);
  align-items: start;
}

.cc-lx-workspace:not(.has-strain) .cc-lx-panel { display: none; }

@media (min-width: 1200px) {
  .cc-lx-workspace.has-strain { grid-template-columns: minmax(0, 1fr) minmax(340px, 400px); }
}

/* ----------------------------------------------------------------- Stage */
.cc-lx-stage {
  position: relative;
  min-width: 0;
  padding: var(--lx-space-4);
  border: 1px solid var(--lx-border);
  border-radius: var(--lx-radius);
  background: var(--lx-surface);
}

@media (min-width: 768px) { .cc-lx-stage { padding: var(--lx-space-5); } }

.cc-lx-stage__head {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  justify-content: space-between;
  gap: var(--lx-space-3) var(--lx-space-5);
  margin-bottom: var(--lx-space-4);
}

.cc-lx-stage__title {
  margin: 0;
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.cc-lx-stage__title:focus { outline: none; }
.cc-lx-stage__title:focus-visible { outline: 3px solid var(--cc-bone); outline-offset: 4px; }

.cc-lx-workspace:not(.has-strain) .cc-lx-stage__head { display: none; }

/* Path: Runtz › Gelato › Sunset Sherbet */
.cc-lx-trail__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.8125rem;
}

.cc-lx-trail__step { display: inline-flex; align-items: center; min-width: 0; }

.cc-lx-trail__step + .cc-lx-trail__step::before {
  content: "›";
  padding-inline: var(--lx-space-2);
  color: var(--lx-muted);
}

.cc-lx-trail__link {
  min-height: var(--lx-target);
  padding: 0 var(--lx-space-1);
  border: 0;
  background: none;
  color: var(--lx-muted);
  font: 500 0.8125rem/1 var(--cc-font-body);
  text-decoration: underline;
  text-decoration-color: rgba(var(--cc-bone-rgb), 0.3);
  text-underline-offset: 3px;
}

.cc-lx-trail__link:hover { color: var(--cc-green); text-decoration-color: currentColor; }
.cc-lx-trail__current { color: var(--cc-bone); font-weight: 600; }

/* Graph: relatives are buttons that make themselves the selected strain. */
.cc-lx .cc-lineage__card.is-explorable {
  cursor: pointer;
  transition:
    transform var(--cc-motion-fast, 160ms) ease,
    border-color var(--cc-motion-fast, 160ms) ease;
}

.cc-lx .cc-lineage__card.is-explorable:hover {
  border-color: rgba(var(--cc-green-rgb), 0.7);
  transform: translateY(-2px);
}

.cc-lx .cc-lineage__card.is-explorable:focus-visible {
  outline: 3px solid var(--cc-bone);
  outline-offset: 2px;
}

/* styles.css reserves 400-600px for the product page's #lineageChart; here
   the component sizes its own viewport and an empty mount takes no room. */
.cc-lx #lineageChart { height: auto; min-height: 0; }

/* A thumbnail that fails to load becomes a quiet brand placeholder. */
.cc-lx-thumb-fallback {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  background: var(--lx-raised);
  color: rgba(var(--cc-green-rgb), 0.55);
  font-size: 1.25rem;
}

/* Loading: the previous family stays visible, dimmed, under a spinner. */
.cc-lx-chart { transition: opacity var(--cc-motion-fast, 160ms) ease; }
.cc-lx-workspace.is-loading .cc-lx-chart,
.cc-lx-workspace.is-loading .cc-lx-message,
.cc-lx-workspace.is-loading .cc-lx-panel { opacity: 0.45; pointer-events: none; }

.cc-lx-loading {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: inherit;
  color: var(--cc-green);
}

.cc-lx-workspace.is-loading .cc-lx-loading { display: flex; }

/* Empty, not-found, no-lineage and error messages inside the stage. */
.cc-lx-message {
  display: grid;
  justify-items: center;
  gap: var(--lx-space-3);
  padding: var(--lx-space-7) var(--lx-space-4);
  border: 1px dashed var(--lx-border-strong);
  border-radius: 12px;
  background-color: rgba(var(--cc-black-rgb), 0.55);
  background-image: radial-gradient(rgba(var(--cc-bone-rgb), 0.07) 1px, transparent 1px);
  background-size: 18px 18px;
  text-align: center;
}

.cc-lx-message[hidden] { display: none; }

.cc-lx-chart:not(:empty) + .cc-lx-message { margin-top: var(--lx-space-4); }

.cc-lx-message__icon {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  background: rgba(var(--cc-green-rgb), 0.12);
  color: var(--cc-green);
  font-size: 1.35rem;
}

.cc-lx-message[data-tone="error"] .cc-lx-message__icon,
.cc-lx-message[data-tone="missing"] .cc-lx-message__icon {
  background: rgba(var(--cc-pink-rgb), 0.12);
  color: var(--cc-pink-hover, #ff5288);
}

.cc-lx-message__title {
  margin: 0;
  font-size: 1.75rem;
  line-height: 1.1;
}

.cc-lx-message__body {
  max-width: 34rem;
  margin: 0;
  color: var(--lx-muted);
  line-height: 1.6;
}

.cc-lx-message .cc-lx-label { margin: var(--lx-space-2) 0 0; }

/* ----------------------------------------------------------------- Panel */
.cc-lx-panel {
  min-width: 0;
  padding: var(--lx-space-5);
  border: 1px solid var(--lx-border);
  border-radius: var(--lx-radius);
  background: var(--lx-surface);
}

.cc-lx-panel__head {
  display: flex;
  align-items: center;
  gap: var(--lx-space-4);
  margin-bottom: var(--lx-space-4);
}

.cc-lx-panel__thumb {
  flex: none;
  width: 72px;
  height: 72px;
  border: 1px solid var(--cc-green);
  border-radius: 12px;
  object-fit: cover;
  background: var(--lx-raised);
}

.cc-lx-panel__identity { min-width: 0; }
.cc-lx-panel__identity .cc-lx-eyebrow { margin-bottom: var(--lx-space-1); }

.cc-lx-panel__title {
  margin: 0;
  font-size: 2rem;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.cc-lx-note { margin-bottom: var(--lx-space-4); }

.cc-lx-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--lx-space-2);
  margin: 0;
}

@media (min-width: 576px) and (max-width: 1199.98px) {
  .cc-lx-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.cc-lx-stat {
  display: flex;
  flex-direction: column-reverse;
  gap: var(--lx-space-1);
  padding: var(--lx-space-3);
  border-radius: var(--lx-radius-sm);
  background: var(--lx-raised);
}

.cc-lx-stat__label {
  color: var(--lx-muted);
  font: 600 0.6875rem/1.3 var(--cc-font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cc-lx-stat__value {
  margin: 0;
  color: var(--cc-bone);
  font: 700 1.5rem/1 var(--cc-font-body);
  font-variant-numeric: tabular-nums;
}

.cc-lx-section {
  margin-top: var(--lx-space-5);
  padding-top: var(--lx-space-5);
  border-top: 1px solid var(--lx-border);
}

.cc-lx-section__title {
  display: flex;
  align-items: center;
  gap: var(--lx-space-2);
  margin: 0 0 var(--lx-space-3);
  color: var(--cc-bone);
  font: 600 0.8125rem/1.4 var(--cc-font-body);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cc-lx-section__title i { color: var(--cc-green); font-size: 0.75rem; }

.cc-lx-gen + .cc-lx-gen { margin-top: var(--lx-space-4); }

.cc-lx-gen__label {
  display: flex;
  align-items: center;
  gap: var(--lx-space-2);
  margin: 0 0 var(--lx-space-2);
  color: var(--lx-muted);
  font-size: 0.8125rem;
  font-weight: 500;
}

.cc-lx-gen__count {
  color: var(--lx-muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.cc-lx-gen__count::before { content: "· "; }

/* Panel chips are a step smaller than the hero's. */
.cc-lx-panel .cc-lx-chip { padding-inline: 0.75rem; font-size: 0.78125rem; }

/* -------------------------------------------------------------- Products */
.cc-lx-products {
  display: grid;
  gap: var(--lx-space-1);
  margin: var(--lx-space-2) 0 0;
  padding: 0;
  list-style: none;
}

.cc-lx-products li[hidden] { display: none; }

.cc-lx-product__link {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--lx-space-3);
  padding: var(--lx-space-2);
  border-radius: var(--lx-radius-sm);
  color: var(--cc-bone);
  text-decoration: none;
  transition: background-color var(--cc-motion-fast, 160ms) ease;
}

.cc-lx-product__link:hover { background: var(--lx-raised); color: var(--cc-bone); }
.cc-lx-product__link > i { color: var(--lx-muted); font-size: 0.75rem; }
.cc-lx-product__link:hover > i { color: var(--cc-green); }

.cc-lx-product__thumb,
.cc-lx-product__link > .cc-lx-thumb-fallback {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--lx-raised);
}

.cc-lx-product__text { display: grid; gap: 0.125rem; min-width: 0; }

.cc-lx-product__name {
  overflow: hidden;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-lx-product__meta {
  overflow: hidden;
  color: var(--lx-muted);
  font-size: 0.75rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cc-lx-product__tag {
  justify-self: start;
  padding: 0.0625rem 0.4rem;
  border: 1px solid rgba(var(--cc-bone-rgb), 0.2);
  border-radius: 999px;
  color: var(--lx-muted);
  font-size: 0.625rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ---------------------------------------------------------------- Motion */
@keyframes cc-lx-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: no-preference) {
  .cc-lx-hero { animation: cc-lx-enter 240ms ease-out both; }
  .cc-lx-workspace.has-strain .cc-lx-panel { animation: cc-lx-enter 200ms ease-out both; }
}

@media (prefers-reduced-motion: reduce) {
  .cc-lx-chip,
  .cc-lx-chart,
  .cc-lx-product__link,
  .cc-lx .cc-lineage__card.is-explorable { transition: none; }
  .cc-lx .cc-lineage__card.is-explorable:hover { transform: none; }
  .cc-lx-chip-skeleton { animation: none; }
}

/* ----------------------------------------------------------------- Small */
@media (max-width: 991.98px) {
  .cc-lx { padding-top: var(--lx-space-6); }
}

@media (max-width: 575.98px) {
  .cc-lx-search-card,
  .cc-lx-panel { padding: var(--lx-space-4); }
  .cc-lx .cc-lx-search__submit { padding-inline: var(--lx-space-4); }
  .cc-lx-message { padding-block: var(--lx-space-6); }
}
