/* css/viz.css
 *
 * The lattice panel and its no WebGL fallback. Owned by the 3D builder.
 *
 * Every colour reads a token from css/tokens.css and carries the literal from docs/SPEC.md section 6 as its
 * fallback, so this file is correct on its own and correct inside the site.
 *
 * There are no box shadows on this site. Depth is a hairline. Nothing here springs or bounces.
 */

.viz {
  position: relative;
  display: block;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 240px;
  overflow: hidden;
  background: var(--bg-deep, #000b04);
  color: var(--text, #E8F5EC);
  /* The lattice is drawn on a transparent canvas, so a faint radial lift behind it reads as depth without a
     shadow and without a second paint. */
  background-image: radial-gradient(
    120% 90% at 50% 46%,
    color-mix(in srgb, var(--green-600, #19A355) 9%, transparent) 0%,
    transparent 62%
  );
  touch-action: none;
  outline: none;
}

.viz:focus-visible {
  outline: 1px solid var(--green-500, #35B86B);
  outline-offset: -1px;
}

.viz__canvas {
  display: block;
  inline-size: 100%;
  block-size: 100%;
  /* A canvas is replaced content and picks up the line box, which leaves a few pixels under it. */
  vertical-align: bottom;
}

/* ---------------------------------------------------------------- the no WebGL fallback */

.viz[data-fallback] {
  background-image: none;
}

.viz-fallback {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  inline-size: 100%;
  block-size: 100%;
  padding: 20px 16px 22px;
  overflow: auto;
  box-sizing: border-box;
  background: var(--bg-deep, #000b04);
}

.viz-fallback__figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-inline-size: 320px;
}

.viz-fallback__image {
  display: block;
  inline-size: 100%;
  block-size: auto;
  max-block-size: 320px;
  object-fit: contain;
  border: 1px solid var(--line, #143024);
  background: var(--bg, #01100a);
}

.viz-fallback__caption,
.viz-fallback__attribution {
  margin: 0;
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, Consolas, monospace);
  font-size: 11px;
  line-height: 1.5;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  /* --text-dim, not --text-faint: --text-faint is 4.28:1 on this ground, under the 4.5 the layout gate
     enforces for text this size, and this caption only appears on the route where a gate cannot see it. */
  color: var(--text-dim, #6A8C78);
  text-align: center;
}

.viz-fallback__attribution {
  text-transform: none;
  letter-spacing: 0;
  max-inline-size: 560px;
}

.viz-fallback__profile {
  display: block;
  inline-size: 100%;
  max-inline-size: 560px;
  block-size: 180px;
  border-block-start: 1px solid var(--line, #143024);
  padding-block-start: 12px;
}

.viz-fallback__note {
  margin: 0;
  max-inline-size: 560px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-muted, #9FBFAB);
  text-align: center;
}

@media (max-width: 520px) {
  .viz {
    min-block-size: 200px;
  }

  .viz-fallback {
    padding: 14px 12px 16px;
    gap: 12px;
  }

  .viz-fallback__figure {
    max-inline-size: 240px;
  }

  .viz-fallback__profile {
    block-size: 140px;
  }

  .viz-fallback__note {
    font-size: 13px;
  }
}

/* ---------------------------------------------------------------- the harness, js/viz/harness.html
 * Development only. The harness page is the only thing that uses these rules, and nothing on the public site
 * links to it. */

.vizh {
  --gap: 14px;
  margin: 0;
  min-block-size: 100vh;
  background: var(--bg, #01100a);
  color: var(--text, #E8F5EC);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
}

.vizh__bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding: 10px 14px;
  border-block-end: 1px solid var(--line, #143024);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  letter-spacing: 0.06em;
}

.vizh__bar > * {
  min-inline-size: 0;
}

.vizh__bar select {
  max-inline-size: min(100%, 240px);
}

.vizh__bar button,
.vizh__bar select {
  background: var(--surface, #04170d);
  color: var(--text, #E8F5EC);
  border: 1px solid var(--line-bright, #1e4a34);
  border-radius: 0;
  padding: 6px 10px;
  font: inherit;
  cursor: pointer;
}

.vizh__bar button[aria-pressed="true"] {
  border-color: var(--green-400, #4FD98A);
  color: var(--green-300, #7CFFB2);
}

.vizh__stage {
  position: relative;
  inline-size: 100%;
  block-size: calc(100vh - 92px);
  min-block-size: 320px;
}

.vizh__stats {
  padding: 8px 14px;
  border-block-start: 1px solid var(--line, #143024);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-muted, #9FBFAB);
  white-space: pre-wrap;
}

/* ---------------------------------------------------------------- the loading skeleton
 *
 * The 3D module is 733 KiB of vendored three.js. On a phone on a slow connection the hero panel is more than
 * half the first screen, and before this it was a 470px empty black slab for eight seconds. This is what
 * stands there instead: the site's own capsid mark, a label saying what is being waited for, and one line of
 * context. It is deliberately NOT a picture of the structure, and it fetches nothing: the published RCSB
 * still is fetched only when the browser has no WebGL, which is what /privacy tells the reader.
 *
 * The renderer removes it the moment it knows which path it took, and the attribute selector below is the
 * belt to that braces: once the mount says which path it took, this is gone either way. */

.viz-skeleton {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  inline-size: 100%;
  block-size: 100%;
  min-block-size: 240px;
  padding: 24px 20px;
  box-sizing: border-box;
  text-align: center;
  color: var(--text-dim, #6A8C78);
}

[data-viz-mode] .viz-skeleton { display: none; }

.viz-skeleton__mark {
  inline-size: clamp(64px, 18%, 132px);
  block-size: auto;
  color: var(--green-600, #19A355);
  opacity: 0.55;
}

.js .viz-skeleton__mark { animation: viz-skeleton-pulse 2.4s var(--ease-in-out, ease-in-out) infinite; }

@keyframes viz-skeleton-pulse { 0%, 100% { opacity: 0.32; } 50% { opacity: 0.72; } }

.viz-skeleton__label { color: var(--text-muted, #9FBFAB); }

.viz-skeleton__note {
  max-width: 44ch;
  font-size: var(--t-nano, 11px);
  line-height: 1.7;
  color: var(--text-dim, #6A8C78);
}

@media (prefers-reduced-motion: reduce) {
  .js .viz-skeleton__mark { animation: none; opacity: 0.55; }
}

/* ---------------------------------------------------------------- the colour legend
 *
 * The structure is coloured the way the RCSB Protein Data Bank colours it, one entry per polymer entity. A
 * colour that means something the reader cannot check is decoration, so the legend always names the real
 * entity behind each swatch, and it always says the colours are a display choice. */

.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  font-family: var(--font-mono, monospace);
  font-size: var(--t-nano, 11px);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim, #6A8C78);
}

.legend__item { display: inline-flex; align-items: center; gap: 7px; }

.legend__dot {
  inline-size: 10px;
  block-size: 10px;
  flex: 0 0 auto;
  border-radius: 1px;
  background: var(--swatch, var(--green-400, #4FD98A));
}

.legend__note {
  flex: 1 1 100%;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-sans, sans-serif);
  line-height: 1.6;
  /* --text-dim, not --text-faint: --text-faint is 4.28:1 on the page ground, under the 4.5 the layout gate
     enforces for text this size. */
  color: var(--text-dim, #6A8C78);
}
