/* Visual demos for the noble page. Colors follow flexoki, same as site style.css.
   Palette (blue/orange/purple) is CVD-validated for both light & dark surfaces. */
.nvd-root {
  color-scheme: light;
  --nvd-s1: #205ea6; /* f-blue-600: point P, "1" bits */
  --nvd-s2: #bc5215; /* f-orange-600: point Q, changed bits */
  --nvd-s3: #5e409d; /* f-purple-600: result P+Q, auth tag */
  --nvd-good: #66800b; /* f-green-600 */
  --nvd-bad: #af3029; /* f-red-600 */
  --nvd-ink: #100f0f;
  --nvd-muted: #6f6e69; /* f-600 */
  --nvd-grid: #e6e4d9; /* f-100 */
  --nvd-surface: #ffffff;
  --nvd-cell-off: #f2f0e5; /* f-50 */
  --nvd-seq-lo: #dce7f3; /* byte-value ramp, single blue hue, light -> dark */
  --nvd-seq-hi: #10345e;
}
@media (prefers-color-scheme: dark) {
  .nvd-root {
    color-scheme: dark;
    --nvd-s1: #4385be; /* f-blue-400 */
    --nvd-s2: #da702c; /* f-orange-400 */
    --nvd-s3: #8b7ec8; /* f-purple-400 */
    --nvd-good: #879a39; /* f-green-400 */
    --nvd-bad: #d14d41; /* f-red-400 */
    --nvd-ink: #cecdc3;
    --nvd-muted: #878580; /* f-500 */
    --nvd-grid: #282726; /* f-850 */
    --nvd-surface: #100f0f;
    --nvd-cell-off: #1c1b1a; /* f-900 */
    --nvd-seq-lo: #16222f;
    --nvd-seq-hi: #8fc2f0;
  }
}

/* theme-neutral palette: flexoki 500s, legible on both paper & black.
   Used when rendering the static article diagrams to transparent PNGs. */
.nvd-root.nvd-neutral {
  --nvd-s1: #3171b2; /* f-blue-500 */
  --nvd-s2: #cb6120; /* f-orange-500 */
  --nvd-s3: #735eb5; /* f-purple-500 */
  --nvd-good: #768d21; /* f-green-500 */
  --nvd-bad: #c03e35; /* f-red-500 */
  --nvd-ink: #767470;
  --nvd-muted: #878580;
  --nvd-grid: #87858038;
  --nvd-surface: transparent;
  --nvd-cell-off: #87858022;
}

.nvd-root .nvd-demo {
  margin: 2.5rem 0 3.5rem;
}
.nvd-root h4 {
  margin: 0 0 0.3rem;
  font-size: 1.05em;
}
.nvd-root .nvd-sub {
  color: var(--nvd-muted);
  font-size: 0.85em;
  margin: 0 0 1rem;
}
.nvd-root canvas {
  width: 100%;
  height: auto;
  display: block;
  touch-action: none;
  border: 1px solid var(--nvd-grid);
  border-radius: 4px;
}
.nvd-root .nvd-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1.8rem;
  align-items: center;
  margin: 0.8rem 0;
  font-size: 0.85em;
}
.nvd-root .nvd-controls label {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}
.nvd-root input[type='range'] {
  width: 11rem;
  accent-color: var(--nvd-s1);
}
.nvd-root input[type='text'],
.nvd-root input[type='number'] {
  font-size: 1em;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--nvd-muted);
  border-radius: 3px;
  background: var(--nvd-surface);
  color: var(--nvd-ink);
}
.nvd-root input[type='number'] {
  width: 6.5rem;
}
.nvd-root .nvd-textinput {
  width: 100%;
}
.nvd-root select {
  font-size: 1em;
  padding: 0.2rem;
  background: var(--nvd-surface);
  color: var(--nvd-ink);
  border: 1px solid var(--nvd-muted);
  border-radius: 3px;
}
.nvd-root button {
  cursor: pointer;
  font-size: 0.95em;
  padding: 0.3rem 1rem;
  border: 1.5px solid var(--nvd-s1);
  border-radius: 4px;
  background: var(--nvd-surface);
  color: var(--nvd-ink);
}
.nvd-root button:hover {
  background: var(--nvd-cell-off);
}
.nvd-root .nvd-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.6rem;
  font-size: 0.8em;
  color: var(--nvd-muted);
  margin: 0.6rem 0;
}
.nvd-root .nvd-legend span {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.nvd-root .nvd-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}
.nvd-root .nvd-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
  flex-shrink: 0;
}
.nvd-root .nvd-readout {
  font-size: 0.8em;
  margin: 0.5rem 0;
}
.nvd-root .nvd-readout code {
  line-break: anywhere;
  font-size: 0.95em;
}
.nvd-root .nvd-grid-label {
  font-size: 0.8em;
  color: var(--nvd-muted);
  margin: 1rem 0 0.4rem;
}
.nvd-root .nvd-bitgrid {
  display: grid;
  grid-template-columns: repeat(32, 1fr);
  gap: 2px; /* the 2px surface gap between adjacent fills */
  max-width: 45rem;
}
.nvd-root .nvd-bitgrid div {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--nvd-cell-off);
}
.nvd-root .nvd-bitgrid .on {
  background: var(--nvd-s1);
}
.nvd-root .nvd-bitgrid .diff {
  background: var(--nvd-s2);
}
.nvd-root .nvd-bytegrid {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  max-width: 45rem;
}
.nvd-root .nvd-bytegrid div {
  aspect-ratio: 1;
  border-radius: 2px;
}
.nvd-root .nvd-bytegrid .tag {
  outline: 2px solid var(--nvd-s3);
  outline-offset: -2px;
}
.nvd-root .nvd-bytegrid .tampered {
  outline: 2.5px solid var(--nvd-bad);
  outline-offset: -1px;
}
.nvd-root .nvd-status {
  font-size: 0.9em;
  font-weight: 700;
  margin: 0.8rem 0;
  min-height: 1.6em;
}
.nvd-root .nvd-status.ok {
  color: var(--nvd-good);
}
.nvd-root .nvd-status.err {
  color: var(--nvd-bad);
}
.nvd-root .nvd-note {
  font-size: 0.8em;
  color: var(--nvd-muted);
  margin: 0.6rem 0 0;
}

/* handshake: three columns — alice | channel | bob */
.nvd-root .nvd-cols {
  display: grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
}
.nvd-root .nvd-col {
  border: 1px solid var(--nvd-grid);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  font-size: 0.8em;
}
.nvd-root .nvd-col h5 {
  margin: 0 0 0.6rem;
  font-size: 1.05em;
}
.nvd-root .nvd-col .who-a {
  color: var(--nvd-s1);
}
.nvd-root .nvd-col .who-b {
  color: var(--nvd-s2);
}
.nvd-root .nvd-chip-row {
  margin-bottom: 0.7rem;
}
.nvd-root .nvd-chip-row .lbl {
  display: block;
  color: var(--nvd-muted);
  margin-bottom: 0.2rem;
}
.nvd-root .nvd-secret {
  border-left: 3px solid var(--nvd-s3);
  padding-left: 0.6rem;
}
@media (max-width: 480px) {
  .nvd-root .nvd-cols {
    grid-template-columns: 1fr;
  }
}

/* two side-by-side panels (signature demo) */
.nvd-root .nvd-panels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.2rem;
  margin: 1rem 0;
}
.nvd-root .nvd-panel {
  border: 1px solid var(--nvd-grid);
  border-radius: 4px;
  padding: 0.8rem 1rem;
  font-size: 0.8em;
}
.nvd-root .nvd-panel h5 {
  margin: 0 0 0.6rem;
  font-size: 1.05em;
}
@media (max-width: 480px) {
  .nvd-root .nvd-panels {
    grid-template-columns: 1fr;
  }
}

/* architecture scheme (fast-ecc article) */
.nvd-root .nvd-scheme {
  color: var(--nvd-ink);
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-areas:
    'fake pmul pmul endo'
    'fake pmul pmul proj'
    '.    gmul gmul pre'
    '.    gmul gmul wnaf'
    'gss  ver  sig  gpk'
    'mgss mver msig mgpk';
  gap: 2.2rem 1.4rem;
  align-items: center;
  margin: 1.5rem 0 0.5rem;
  font-size: 0.8em;
}
.nvd-root .nvd-scheme-edges {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.nvd-root .nvd-scheme-edges .arrow {
  stroke: var(--nvd-ink);
  stroke-width: 1.8;
}
.nvd-root .nvd-scheme-edges .link {
  stroke: var(--nvd-muted);
  stroke-width: 1.5;
  stroke-dasharray: 3 4;
}
.nvd-root .nvd-sbox {
  border: 1.5px solid;
  border-radius: 6px;
  padding: 0.7rem 0.8rem;
  text-align: center;
  background: var(--nvd-surface);
}
.nvd-root .nvd-sbox .ttl {
  font-weight: 700;
}
.nvd-root .nvd-sbox .sub {
  color: var(--nvd-muted);
  margin-top: 0.3rem;
  font-size: 0.9em;
}
.nvd-root .nvd-sbox.op {
  border-color: var(--nvd-s1);
  background: color-mix(in srgb, var(--nvd-s1) 10%, var(--nvd-surface));
}
.nvd-root .nvd-sbox.opt {
  border-color: var(--nvd-s2);
  background: color-mix(in srgb, var(--nvd-s2) 10%, var(--nvd-surface));
}
.nvd-root .nvd-sbox.safe {
  border-color: var(--nvd-s3);
  border-radius: 14px;
  background: color-mix(in srgb, var(--nvd-s3) 10%, var(--nvd-surface));
}
.nvd-root .nvd-sbox.api,
.nvd-root .nvd-sbox.op {
  cursor: pointer;
}
.nvd-root .nvd-sbox.api {
  border-color: var(--nvd-muted);
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nvd-root .nvd-smath {
  align-self: start;
  white-space: pre-line;
  font-size: 0.85em;
  color: var(--nvd-muted);
  background: var(--nvd-cell-off);
  border-radius: 4px;
  padding: 0.5rem 0.6rem;
}
.nvd-root .nvd-scheme .nvd-sbox,
.nvd-root .nvd-scheme .nvd-smath,
.nvd-root .nvd-scheme-edges line {
  transition: opacity 0.15s ease;
}
.nvd-root .nvd-scheme.focus .nvd-sbox:not(.lit),
.nvd-root .nvd-scheme.focus .nvd-smath:not(.lit) {
  opacity: 0.3;
}
.nvd-root .nvd-scheme.focus .nvd-scheme-edges line:not(.lit) {
  opacity: 0.12;
}
@media (max-width: 560px) {
  .nvd-root .nvd-scheme {
    grid-template-columns: 1fr;
    grid-template-areas:
      'pmul' 'fake' 'endo' 'proj'
      'gmul' 'pre' 'wnaf'
      'gss' 'mgss' 'ver' 'mver' 'sig' 'msig' 'gpk' 'mgpk';
    gap: 0.8rem;
  }
  .nvd-root .nvd-scheme-edges {
    display: none;
  }
}

/* Montgomery batch inversion (fast-ecc article) */
.nvd-root .nvd-batch-scroll {
  overflow-x: auto;
  margin: 1.5rem 0;
}
.nvd-root .nvd-batch {
  color: var(--nvd-ink);
  position: relative;
  display: flex;
  gap: 1.6rem;
  width: max-content;
  margin: 0 auto;
  padding: 0.3rem 0.3rem 3rem;
  font-weight: 600;
  font-size: 0.95em;
}
.nvd-root .nvd-batch .col div {
  line-height: 2.1;
  white-space: nowrap;
}
.nvd-root .nvd-batch .col .hl {
  outline: 2px solid var(--nvd-s1);
  outline-offset: 3px;
  border-radius: 2px;
}
.nvd-root .nvd-batch sub,
.nvd-root .nvd-batch sup {
  font-size: 0.7em;
}
.nvd-root .nvd-batch .walk {
  width: 12px;
  align-self: stretch;
  overflow: visible;
}
.nvd-root .nvd-batch .walk line {
  stroke: var(--nvd-good);
  stroke-width: 2.2;
}
.nvd-root .nvd-batch .invert-link {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.nvd-root .nvd-batch .invert-link .curve {
  stroke: var(--nvd-s1);
  stroke-width: 2;
  fill: none;
}
@media (max-width: 480px) {
  .nvd-root .nvd-batch {
    gap: 0.9rem;
    font-size: 0.8em;
  }
}

/* horizontal bars (benchmark) */
.nvd-root .nvd-bars {
  margin: 1rem 0;
  font-size: 0.8em;
}
.nvd-root .nvd-bar-row {
  display: grid;
  grid-template-columns: 15rem 1fr 8rem;
  gap: 1rem;
  align-items: center;
  margin-bottom: 0.6rem;
}
.nvd-root .nvd-bar {
  height: 14px;
  background: var(--nvd-cell-off);
  border-radius: 4px;
  overflow: hidden;
}
.nvd-root .nvd-bar-fill {
  height: 100%;
  width: 0;
  background: var(--nvd-s1);
  border-radius: 4px 0 0 4px;
  transition: width 0.3s ease;
}
.nvd-root .nvd-bar-val {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 480px) {
  .nvd-root .nvd-bar-row {
    grid-template-columns: 9rem 1fr 6rem;
    gap: 0.5rem;
  }
}
