/* Visualisation lab — the Showcase and Principles tabs on design.html.
 *
 * Everything here is scoped to .vizlab so it cannot leak into the rest of the
 * site. The first block is the whole integration: the renderers and the
 * showcase markup were written against their own variable names, and this maps
 * those onto reyanda.com's tokens. In particular --chart-* resolve to the
 * site's --fig-* figure tokens, which the site already switches with its own
 * theme control, so every figure follows the site's light/dark toggle without
 * a line of JavaScript.
 */

.vizlab {
  --vl-bg: var(--surface-0);
  --vl-surface: var(--surface-1);
  --vl-surface-2: var(--hover-wash);
  --vl-hairline: var(--rule);
  --vl-text: var(--ink);
  --vl-text-2: var(--ink-muted);
  --vl-text-3: var(--ink-muted);
  --vl-accent: var(--link);
  --vl-accent-soft: color-mix(in srgb, var(--link) 12%, transparent);
  --vl-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --vl-radius: 18px;

  --chart-ink: var(--fig-ink);
  --chart-rule: var(--fig-rule);
  --chart-muted: var(--fig-muted);
  --chart-paper: var(--surface-0);

  color: var(--vl-text);
}

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

.vl-tabs {
  display: flex; gap: 4px; padding: 4px; margin: 0 auto 8px;
  background: var(--vl-surface); border-radius: 14px;
  width: max-content; max-width: 100%; flex-wrap: wrap;
}
.vl-tabs button {
  border: none; background: transparent; color: var(--vl-text-2);
  font-family: var(--font-text); font-size: 15px; font-weight: 500;
  letter-spacing: -0.01em; padding: 9px 20px; border-radius: 11px;
  cursor: pointer; white-space: nowrap;
  transition: background 0.28s var(--vl-ease), color 0.28s var(--vl-ease);
}
.vl-tabs button:hover { color: var(--vl-text); }
.vl-tabs button[aria-selected="true"] {
  background: var(--surface-0); color: var(--vl-text);
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 4px 14px rgba(0, 0, 0, .07);
}
.vl-tabhint {
  text-align: center; color: var(--vl-text-3); font-size: var(--text-caption);
  margin: 0 0 40px;
}

.vl-panel[hidden] { display: none; }

/* ---- palette control --------------------------------------------------- */

.vl-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.vl-pill {
  display: inline-flex; align-items: center; gap: 9px;
  height: 36px; padding: 0 8px 0 14px; border: 1px solid var(--vl-hairline);
  border-radius: var(--radius-pill); background: var(--vl-surface);
  color: var(--vl-text); font-family: var(--font-text); font-size: 14px;
  font-weight: 500; cursor: pointer;
  transition: background 0.25s var(--vl-ease);
}
.vl-pill:hover { background: var(--vl-surface-2); }
.vl-swatches { display: flex; border-radius: var(--radius-pill); overflow: hidden; height: 20px; }
.vl-swatches i { width: 10px; height: 20px; display: block; }

.vl-drawer {
  border: 1px solid var(--vl-hairline); border-radius: var(--vl-radius);
  background: var(--vl-surface); padding: 16px; margin-bottom: 26px;
}
.vl-drawer[hidden] { display: none; }
.vl-drawer-controls { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.vl-search {
  flex: 1 1 220px; min-width: 180px; height: 36px;
  border: 1px solid var(--vl-hairline); border-radius: 10px;
  background: var(--surface-0); color: var(--vl-text);
  font-family: var(--font-text); font-size: 14px; padding: 0 12px; outline: none;
}
.vl-search:focus { border-color: var(--vl-accent); }
.vl-seg { display: inline-flex; padding: 3px; gap: 3px; background: var(--surface-0); border-radius: 10px; flex-wrap: wrap; }
.vl-seg button {
  border: none; background: transparent; color: var(--vl-text-2);
  font-family: var(--font-text); font-size: 13px; font-weight: 500;
  padding: 6px 12px; border-radius: 8px; cursor: pointer; white-space: nowrap;
}
.vl-seg button[aria-pressed="true"] { background: var(--vl-surface-2); color: var(--vl-text); }

.vl-palettes {
  display: grid; gap: 8px; max-height: 340px; overflow-y: auto;
  grid-template-columns: repeat(auto-fill, minmax(178px, 1fr));
}
.vl-pal {
  border: 1px solid transparent; border-radius: 12px; background: var(--surface-0);
  padding: 9px 10px 10px; cursor: pointer; text-align: left; font-family: var(--font-text);
  transition: border-color 0.25s var(--vl-ease), background 0.25s var(--vl-ease);
}
.vl-pal:hover { background: var(--vl-surface-2); }
.vl-pal[aria-pressed="true"] { border-color: var(--vl-accent); background: var(--vl-accent-soft); }
.vl-pal .sw { display: flex; height: 22px; border-radius: 6px; overflow: hidden; margin-bottom: 7px; }
.vl-pal .sw i { flex: 1; display: block; }
.vl-pal b { display: block; font-size: 13px; font-weight: 550; color: var(--vl-text); }
.vl-pal span { display: block; font-size: 11px; color: var(--vl-text-3); }

/* ---- gallery ----------------------------------------------------------- */

.vl-filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.vl-grid { display: grid; gap: 18px; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); }

.vl-card { position: relative; perspective: 1400px; cursor: pointer; }
.vl-card-inner {
  position: relative; transform-style: preserve-3d; min-height: 352px;
  transition: transform 0.62s var(--vl-ease);
}
.vl-card[data-flipped="true"] .vl-card-inner { transform: rotateY(180deg); }
.vl-face {
  border-radius: var(--vl-radius); border: 1px solid var(--vl-hairline);
  background: var(--surface-0); padding: 18px 18px 16px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.vl-back {
  position: absolute; inset: 0; transform: rotateY(180deg);
  display: flex; flex-direction: column; overflow-y: auto;
}
.vl-head { display: flex; align-items: baseline; gap: 8px; padding-right: 26px; }
.vl-head h3 { margin: 0; font-size: 17px; font-weight: 600; letter-spacing: -0.017em; color: var(--vl-text); }
.vl-recipe { margin-left: auto; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px; color: var(--vl-text-3); }
.vl-card figure { margin: 10px 0 0; }
.vl-card svg { display: block; width: 100%; height: auto; overflow: visible; }
.vl-tags { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 11px; }
.vl-tag {
  font-size: 11px; font-weight: 500; padding: 3px 9px;
  border-radius: var(--radius-pill); background: var(--vl-surface); color: var(--vl-text-2);
}
.vl-tag.chan { background: var(--vl-accent-soft); color: var(--vl-accent); }
.vl-tag.derived { background: color-mix(in srgb, var(--accent) 16%, transparent); color: var(--accent); }

.vl-notes { margin: 12px 0 0; display: grid; gap: 2px; }
.vl-notes dt {
  font-size: 10.5px; font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase;
  color: var(--vl-accent); margin-top: 8px;
}
.vl-notes dt:first-child { margin-top: 0; }
.vl-notes dd { margin: 0; font-size: 12.5px; line-height: 1.42; color: var(--vl-text-2); }
.vl-channel {
  margin: auto 0 0; padding-top: 10px; border-top: 1px solid var(--vl-hairline);
  display: flex; flex-direction: column; gap: 1px; font-size: 11px; color: var(--vl-text-3);
}
.vl-channel span:first-child { color: var(--vl-text-2); font-weight: 550; }

.vl-flip {
  position: absolute; top: 13px; right: 14px; z-index: 2;
  width: 23px; height: 23px; border: none; border-radius: var(--radius-pill);
  background: var(--vl-surface); color: var(--vl-text-2);
  font-family: var(--font-text); font-size: 11px; font-weight: 600; line-height: 1;
  cursor: pointer; display: grid; place-items: center;
  opacity: 0; transition: opacity 0.25s var(--vl-ease);
}
.vl-card:hover .vl-flip, .vl-card[data-flipped="true"] .vl-flip, .vl-flip:focus-visible { opacity: 1; }

/* ---- principles --------------------------------------------------------- */

.vl-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 34px; }
.vl-toc a {
  font-size: 13px; font-weight: 500; padding: 7px 14px; border-radius: var(--radius-pill);
  background: var(--vl-surface); color: var(--vl-text-2); text-decoration: none;
}
.vl-toc a:hover { background: var(--vl-surface-2); color: var(--vl-text); }

.vl-chapter { padding: 30px 0 4px; }
.vl-chapter h3 {
  margin: 0 0 6px; font-size: var(--text-heading-lg); font-weight: 600;
  letter-spacing: -0.024em; color: var(--vl-text);
}
.vl-chapter .num {
  display: block; font-size: 12px; font-weight: 600; color: var(--vl-accent);
  letter-spacing: 0.02em; text-transform: uppercase; margin-bottom: 6px;
}
.vl-chapter p { margin: 0; max-width: 640px; color: var(--vl-text-2); font-size: 15.5px; }

.vl-principle {
  border-top: 1px solid var(--vl-hairline); padding: 24px 0;
  display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr);
}
.vl-principle.with-figure { grid-template-columns: minmax(270px, 1fr) minmax(0, 1.15fr); }
@media (max-width: 900px) { .vl-principle.with-figure { grid-template-columns: minmax(0, 1fr); } }
.vl-principle h4 { margin: 0 0 8px; font-size: 17px; font-weight: 600; letter-spacing: -0.016em; color: var(--vl-text); }
.vl-principle p { margin: 0 0 10px; font-size: 14.5px; line-height: 1.5; color: var(--vl-text-2); }
.vl-principle p:last-child { margin-bottom: 0; }
.vl-principle strong { color: var(--vl-text); font-weight: 600; }
.vl-principle code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12.5px;
  background: var(--vl-surface); padding: 1px 5px; border-radius: 5px; color: var(--vl-text);
}

.vl-demo { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(185px, 1fr)); }
.vl-demo figure {
  margin: 0; background: var(--surface-0); border: 1px solid var(--vl-hairline);
  border-radius: 14px; padding: 12px 12px 10px;
}
.vl-demo svg { display: block; width: 100%; height: auto; overflow: visible; }
.vl-demo figcaption {
  margin-top: 9px; font-size: 11.5px; line-height: 1.4; color: var(--vl-text-2);
  display: flex; align-items: baseline; gap: 6px;
}
.vl-verdict {
  flex: none; font-size: 10px; font-weight: 700; letter-spacing: 0.03em;
  padding: 2px 7px; border-radius: var(--radius-pill); text-transform: uppercase;
}
.vl-verdict.good { background: rgba(48, 160, 96, .16); color: #1c7a45; }
.vl-verdict.bad { background: rgba(214, 64, 52, .15); color: #b03024; }
.vl-verdict.note { background: var(--vl-surface); color: var(--vl-text-2); }
html.dark-theme .vl-verdict.good { color: #30d158; }
html.dark-theme .vl-verdict.bad { color: #ff453a; }
@media (prefers-color-scheme: dark) {
  :root:not(.light-theme) .vl-verdict.good { color: #30d158; }
  :root:not(.light-theme) .vl-verdict.bad { color: #ff453a; }
}

table.vl-ranks { border-collapse: collapse; width: 100%; font-size: 13px; margin-top: 4px; }
table.vl-ranks td { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--vl-hairline); color: var(--vl-text-2); }
table.vl-ranks td:first-child { width: 26px; color: var(--vl-text-3); font-variant-numeric: tabular-nums; }
table.vl-ranks td:nth-child(2) { font-weight: 550; color: var(--vl-text); white-space: nowrap; }

@media (prefers-reduced-motion: reduce) {
  .vl-card-inner, .vl-tabs button, .vl-pill { transition-duration: 0.01ms !important; }
}
