/* vizref.css -- the visualisation reference library page.
 *
 * Loaded after courses/css/lesson-lab.css and scoped inside its `.lesson-doc`
 * wrapper, so it inherits that file's --ld-* tokens and its light/dark
 * switching for free. The two files must stay loadable together: this one
 * adds components, it never redefines a token.
 */

.vizref { max-width: 100%; }

.vizref-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.4rem;
  padding-bottom: 1.1rem;
  border-bottom: 2px solid var(--ld-line);
}

.vizref-head h1 {
  font-size: 1.6rem;
  font-weight: 680;
  letter-spacing: -0.015em;
  margin: 0;
  color: var(--ld-ink);
}

.vizref-head p {
  margin: 0.35rem 0 0;
  color: var(--ld-ink-soft);
  font-size: 0.94rem;
  max-width: 62ch;
}

.vizref-count {
  margin-left: auto;
  font-family: var(--ld-mono);
  font-size: 0.78rem;
  color: var(--ld-ink-faint);
  white-space: nowrap;
}

/* --------------------------------------------------------------- tabs -- */

.vizref-tabs {
  display: flex;
  gap: 0.3rem;
  flex-wrap: wrap;
  margin-bottom: 1.4rem;
  border-bottom: 1px solid var(--ld-line);
}

.vizref-tab {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.6rem 1rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--ld-ink-faint);
  cursor: pointer;
  margin-bottom: -1px;
}

.vizref-tab:hover { color: var(--ld-ink); }
.vizref-tab.active { color: var(--ld-accent-ink); border-bottom-color: var(--ld-accent); }

.vizref-panel { display: none; }
.vizref-panel.active { display: block; }

/* ------------------------------------------------------------- filters -- */

.vizref-filter {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1.2rem;
  padding: 0.75rem;
  background: var(--ld-panel);
  border: 1px solid var(--ld-line);
  border-radius: var(--ld-radius);
  position: sticky;
  top: 0;
  z-index: 5;
}

.vizref-filter input[type="search"] {
  font: inherit;
  font-size: 0.9rem;
  flex: 1 1 15rem;
  min-width: 10rem;
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--ld-line);
  border-radius: 7px;
  background: var(--ld-bg);
  color: var(--ld-ink);
}

.vizref-chip {
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--ld-line);
  border-radius: 100px;
  background: var(--ld-bg);
  color: var(--ld-ink-soft);
  cursor: pointer;
  white-space: nowrap;
}

.vizref-chip:hover { background: var(--ld-panel-2); color: var(--ld-ink); }
.vizref-chip.active {
  background: var(--ld-accent);
  border-color: var(--ld-accent);
  color: #fff;
}

.vizref-hits {
  font-size: 0.8rem;
  color: var(--ld-ink-faint);
  font-variant-numeric: tabular-nums;
  margin-left: auto;
  white-space: nowrap;
}

/* -------------------------------------------------------- chart cards -- */

.vizref-jobhead {
  margin: 2rem 0 0.9rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--ld-line);
}

.vizref-jobhead h2 {
  font-size: 1.1rem;
  font-weight: 660;
  margin: 0;
  color: var(--ld-ink);
}

.vizref-jobhead p {
  margin: 0.2rem 0 0;
  font-size: 0.86rem;
  color: var(--ld-ink-faint);
}

.vizref-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(20rem, 1fr));
  gap: 0.9rem;
}

.vizref-card {
  border: 1px solid var(--ld-line);
  border-radius: var(--ld-radius);
  background: var(--ld-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.vizref-card-head {
  display: flex;
  gap: 0.75rem;
  align-items: center;
  padding: 0.7rem 0.85rem;
  background: var(--ld-panel);
  border-bottom: 1px solid var(--ld-line);
}

.vizref-glyph {
  flex: 0 0 auto;
  width: 44px;
  height: 32px;
  border-radius: 5px;
  background: var(--ld-bg);
  border: 1px solid var(--ld-line-soft);
  padding: 3px;
}

.vizref-glyph svg { display: block; width: 100%; height: 100%; }
.vizref-glyph .g-fill { fill: var(--ld-accent); }
.vizref-glyph .g-fill-2 { fill: var(--ld-accent); fill-opacity: 0.42; }
.vizref-glyph .g-line { stroke: var(--ld-accent); stroke-width: 2; fill: none; stroke-linecap: round; }
.vizref-glyph .g-line-2 { stroke: var(--ld-info); stroke-width: 2; fill: none; stroke-linecap: round; }
.vizref-glyph .g-soft { stroke: var(--ld-line); stroke-width: 1.5; fill: none; }

.vizref-card-title { min-width: 0; flex: 1 1 auto; }

.vizref-card-title h3 {
  font-size: 0.95rem;
  font-weight: 650;
  margin: 0;
  color: var(--ld-ink);
  line-height: 1.35;
}

.vizref-card-title .id {
  font-family: var(--ld-mono);
  font-size: 0.72rem;
  color: var(--ld-ink-faint);
}

.vizref-card-body {
  padding: 0.85rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--ld-ink-soft);
  flex: 1 1 auto;
}

.vizref-card-body > p { margin: 0 0 0.7rem; }
.vizref-card-body > p:last-child { margin-bottom: 0; }

.vizref-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
}

.vizref-row .k {
  flex: 0 0 5.2rem;
  font-weight: 650;
  color: var(--ld-ink-faint);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding-top: 0.15rem;
}

.vizref-row .v { flex: 1 1 auto; min-width: 0; }

.vizref-row.avoid .v { color: var(--ld-bad); }
[data-bs-theme="dark"] .vizref-row.avoid .v { color: var(--ld-bad); }

.vizref-dims { display: flex; flex-wrap: wrap; gap: 0.3rem; }

.vizref-dim {
  font-family: var(--ld-mono);
  font-size: 0.72rem;
  padding: 0.12rem 0.45rem;
  border-radius: 4px;
  background: var(--ld-panel-2);
  border: 1px solid var(--ld-line-soft);
  color: var(--ld-ink-soft);
}

.vizref-dim.req { border-color: var(--ld-accent); color: var(--ld-accent-ink); }

/* recipe tabs inside a card */
.vizref-recipe { border-top: 1px solid var(--ld-line-soft); }

.vizref-recipe-tabs { display: flex; }

.vizref-recipe-tabs button {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 650;
  flex: 1 1 0;
  padding: 0.45rem 0.5rem;
  border: 0;
  border-bottom: 2px solid transparent;
  background: var(--ld-panel);
  color: var(--ld-ink-faint);
  cursor: pointer;
}

.vizref-recipe-tabs button.active {
  color: var(--ld-accent-ink);
  border-bottom-color: var(--ld-accent);
  background: var(--ld-bg);
}

.vizref-recipe-body { display: none; padding: 0.7rem 0.85rem; }
.vizref-recipe-body.active { display: block; }

.vizref-recipe-body ol { margin: 0; padding-left: 1.1rem; font-size: 0.82rem; }
.vizref-recipe-body li { margin-bottom: 0.25rem; }

.vizref-recipe-body pre {
  margin: 0;
  font-family: var(--ld-mono);
  font-size: 0.76rem;
  line-height: 1.55;
  background: var(--ld-code-bg);
  border: 1px solid var(--ld-line-soft);
  border-radius: 6px;
  padding: 0.6rem 0.7rem;
  overflow-x: auto;
  color: var(--ld-code-ink);
  white-space: pre;
}

.vizref-pitfall {
  padding: 0.55rem 0.85rem;
  background: var(--ld-warn-soft);
  border-top: 1px solid var(--ld-line-soft);
  font-size: 0.8rem;
  color: var(--ld-warn);
  line-height: 1.55;
}

.vizref-empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--ld-ink-faint);
  font-size: 0.92rem;
}

/* ------------------------------------------------------------ palettes -- */

.vizref-palette {
  border: 1px solid var(--ld-line);
  border-radius: var(--ld-radius);
  margin-bottom: 0.9rem;
  overflow: hidden;
  background: var(--ld-bg);
}

.vizref-palette.dispute { border-color: var(--ld-warn); }

.vizref-palette-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.7rem;
  padding: 0.7rem 0.85rem;
  background: var(--ld-panel);
  border-bottom: 1px solid var(--ld-line);
}

.vizref-palette-head .pname {
  font-family: var(--ld-mono);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--ld-ink);
}

.vizref-verdict {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.55rem;
  border-radius: 100px;
  white-space: nowrap;
}

.vizref-verdict.aman { background: var(--ld-accent-soft); color: var(--ld-accent-ink); }
.vizref-verdict.berlabel { background: var(--ld-warn-soft); color: var(--ld-warn); }
.vizref-verdict.jangan { background: var(--ld-bad-soft); color: var(--ld-bad); }
.vizref-verdict.ramp { background: var(--ld-info-soft); color: var(--ld-info); }
.vizref-verdict.rusak { background: var(--ld-bad-soft); color: var(--ld-bad); }

.vizref-claim {
  font-size: 0.75rem;
  color: var(--ld-ink-faint);
  margin-left: auto;
  white-space: nowrap;
}

.vizref-swatches { display: flex; flex-wrap: wrap; }

.vizref-swatch {
  flex: 1 1 auto;
  min-width: 42px;
  height: 46px;
  position: relative;
  cursor: pointer;
  border: 0;
  padding: 0;
}

.vizref-swatch span {
  position: absolute;
  inset: auto 0 0 0;
  font-family: var(--ld-mono);
  font-size: 0.58rem;
  text-align: center;
  padding: 1px 0;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  opacity: 0;
  transition: opacity 0.12s;
}

.vizref-swatch:hover span, .vizref-swatch:focus span { opacity: 1; }

.vizref-palette-body {
  padding: 0.75rem 0.85rem;
  font-size: 0.86rem;
  color: var(--ld-ink-soft);
  line-height: 1.62;
}

.vizref-measures {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

.vizref-measure {
  font-family: var(--ld-mono);
  font-size: 0.74rem;
  padding: 0.22rem 0.5rem;
  border-radius: 5px;
  background: var(--ld-panel-2);
  border: 1px solid var(--ld-line-soft);
  color: var(--ld-ink-soft);
}

.vizref-measure.bad { border-color: var(--ld-bad); color: var(--ld-bad); }
.vizref-measure.good { border-color: var(--ld-accent); color: var(--ld-accent-ink); }

.vizref-copy {
  font: inherit;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--ld-line);
  border-radius: 6px;
  background: var(--ld-bg);
  color: var(--ld-ink-soft);
  cursor: pointer;
}

.vizref-copy:hover { background: var(--ld-panel-2); color: var(--ld-ink); }

/* --------------------------------------------------------- anti-patterns -- */

.vizref-anti {
  border: 1px solid var(--ld-line);
  border-left: 3px solid var(--ld-bad);
  border-radius: var(--ld-radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.8rem;
  background: var(--ld-bg);
}

.vizref-anti h4 {
  margin: 0 0 0.4rem;
  font-size: 0.94rem;
  font-weight: 660;
  color: var(--ld-bad);
  text-transform: none;
  letter-spacing: 0;
}

.vizref-anti p { margin: 0 0 0.45rem; font-size: 0.87rem; line-height: 1.62; color: var(--ld-ink-soft); }
.vizref-anti .fix { color: var(--ld-accent-ink); margin-bottom: 0; }
.vizref-anti .fix strong { color: var(--ld-accent-ink); }

@media (max-width: 640px) {
  .vizref-grid { grid-template-columns: 1fr; }
  .vizref-filter { position: static; }
  .vizref-row { flex-direction: column; gap: 0.15rem; }
  .vizref-row .k { flex: none; }
}
