/* Shared styles for all lab pages.
   Arctic palette: deep navy paper, frost ink, ice-blue accent. */

:root {
  --paper: #08111c;
  --paper-soft: #0d1828;
  --ink: #e8f0f8;
  --ink-soft: rgba(232, 240, 248, 0.78);
  --rule: rgba(232, 240, 248, 0.14);
  --rule-strong: rgba(232, 240, 248, 0.22);
  --tint: rgba(232, 240, 248, 0.05);
  --accent: #5cc8ff;
  --accent-2: #f5a85c;
  --serif: "Source Serif 4", Georgia, "Times New Roman", serif;
  --sans: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
html, body { overflow-x: hidden; }
body {
  margin: 0; padding: 0;
  background: var(--paper); color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent); color: var(--paper); }

.meta {
  font-family: var(--sans); font-size: 13px;
}

/* Top bar */
.labbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(8, 17, 28, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
  padding: 16px 48px;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--sans); font-size: 14px;
}
.labbar a { color: var(--ink); text-decoration: none; position: relative; }
.labbar a:hover { color: var(--accent); }
.labbar nav a::after {
  content: ''; position: absolute; left: 0; right: 100%; bottom: -4px;
  height: 1px; background: currentColor;
  transition: right .25s ease;
}
.labbar nav a:hover::after { right: 0; }
.labbar .brand { font-weight: 700; }
.labbar .brand span { color: var(--accent); }
.labbar nav { display: flex; gap: 22px; }

/* Article header */
.lab-head {
  padding: 80px 48px 56px;
  border-bottom: 1px solid var(--rule);
}
.lab-head .kicker {
  display: flex; gap: 24px;
  margin-bottom: 36px;
  color: var(--ink-soft);
  opacity: 0.75;
}
.lab-head h1 {
  margin: 0;
  font-family: var(--sans);
  font-size: 88px; line-height: 1.02; font-weight: 500;
  letter-spacing: -0.035em;
  max-width: 1100px;
  text-wrap: pretty;
}
.lab-head .lede {
  margin-top: 28px;
  font-family: var(--serif);
  font-size: 22px; line-height: 1.45; opacity: 0.82;
  max-width: 720px;
}
.lab-head .credits {
  margin-top: 56px;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 24px;
  border-top: 1px solid var(--rule); padding-top: 22px;
  font-family: var(--sans); font-size: 14px;
}
.lab-head .credits .label { color: var(--accent-2); font-size: 13px; margin-bottom: 6px; }
.lab-head .credits .value { font-size: 14px; }

/* Featured demo block — drop any <canvas> / live render in here */
.lab-demo {
  position: relative;
  padding: 0 48px;
  margin: 56px 0 72px;
}
.lab-demo .frame {
  position: relative;
  height: 600px;
  background: #04101c;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.lab-demo .frame canvas {
  display: block; width: 100%; height: 100%;
}
.lab-demo .demo-label,
.lab-demo .demo-tag {
  position: absolute;
  font-family: var(--sans); font-size: 13px;
  color: rgba(232, 240, 248, 0.75);
  pointer-events: none;
}
.lab-demo .demo-label { left: 28px; top: 24px; }
.lab-demo .demo-tag   { left: 28px; bottom: 24px; max-width: 480px; line-height: 1.55; }

/* Demo controls drawer (bottom-right, inside the demo frame) */
.lab-controls {
  position: absolute; right: 24px; top: 24px;
  background: rgba(4, 16, 28, 0.72);
  backdrop-filter: blur(6px);
  color: var(--ink);
  padding: 18px 20px;
  min-width: 280px;
  border: 1px solid rgba(232, 240, 248, 0.14);
}
.lab-controls .group { margin-bottom: 16px; }
.lab-controls .group:last-child { margin-bottom: 0; }
.lab-controls label {
  font-family: var(--sans); font-size: 12px;
  display: flex; justify-content: space-between;
  opacity: 0.78; margin-bottom: 8px;
}
.lab-controls label span:last-child { opacity: 1; color: var(--accent); }
.lab-controls input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}
.lab-controls .swatches {
  display: flex; gap: 6px;
}
.lab-controls .swatches button {
  all: unset; cursor: pointer;
  width: 24px; height: 24px;
  border: 1px solid rgba(232, 240, 248, 0.18);
}
.lab-controls .swatches button.active {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Article body */
.lab-body {
  padding: 0 48px 96px;
  display: grid;
  grid-template-columns: 200px minmax(0, 720px) 200px;
  gap: 56px;
  max-width: 1280px;
  margin: 0 auto;
}
.lab-body .toc {
  position: sticky; top: 80px; align-self: start;
  font-family: var(--sans); font-size: 14px;
}
.lab-body .toc .label { color: var(--accent-2); font-size: 13px; margin-bottom: 14px; }
.lab-body .toc ol {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 10px;
}
.lab-body .toc ol li a {
  color: var(--ink); text-decoration: none; opacity: 0.65;
}
.lab-body .toc ol li a:hover { opacity: 1; color: var(--accent); }

.lab-body article {
  font-family: var(--serif);
  font-size: 18px; line-height: 1.65;
}
.lab-body article p { margin: 0 0 20px; }
.lab-body article p:has(+ h2) { margin-bottom: 0; }
.lab-body article h2 {
  font-family: var(--sans);
  font-size: 36px; line-height: 1.05; font-weight: 500;
  letter-spacing: -0.02em;
  margin: 64px 0 22px;
  padding-top: 24px;
  border-top: 1px solid var(--rule);
}
.lab-body article h3 {
  font-family: var(--sans);
  font-size: 20px; font-weight: 500;
  letter-spacing: -0.01em;
  margin: 32px 0 12px;
}
.lab-body article em { font-style: italic; }
.lab-body article strong { font-weight: 600; }
.lab-body article a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.lab-body article ul, .lab-body article ol {
  margin: 0 0 24px; padding-left: 22px;
}
.lab-body article li { margin-bottom: 8px; }
.lab-body article blockquote {
  margin: 28px 0;
  padding: 4px 0 4px 24px;
  border-left: 2px solid var(--accent);
  font-style: italic;
  font-size: 22px; line-height: 1.45;
  color: var(--ink);
}
.lab-body article pre {
  background: #04101c;
  color: #c0d6e8;
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  padding: 22px 24px;
  margin: 28px -24px;
  overflow-x: auto;
  border: 1px solid var(--rule);
}
.lab-body article pre .k { color: #5cc8ff; }
.lab-body article pre .c { color: rgba(192, 214, 232, 0.5); font-style: italic; }
.lab-body article pre .s { color: #a8e0c0; }
.lab-body article code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--tint); padding: 2px 6px;
  overflow-wrap: break-word; word-break: break-word;
}
.lab-body article pre code { background: transparent; padding: 0; font-size: 13px; }

.lab-body aside.notes {
  position: sticky; top: 80px; align-self: start;
  font-family: var(--sans); font-size: 14px;
  opacity: 0.72; line-height: 1.55;
}
.lab-body aside.notes .label {
  font-size: 13px; color: var(--accent-2);
  margin-bottom: 10px;
}

/* Inline figure inside the article */
.lab-body article figure {
  margin: 32px -24px;
}
.lab-body article figure .frame {
  position: relative;
  height: 320px;
  background: #04101c;
  overflow: hidden;
  border: 1px solid var(--rule);
}
.lab-body article figure figcaption {
  margin-top: 10px;
  font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase;
  opacity: 0.6;
}

/* Footer / related */
.lab-foot {
  border-top: 1px solid var(--rule);
  padding: 64px 48px 48px;
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.lab-foot .next h3 {
  font-family: var(--sans);
  font-size: 32px; font-weight: 500;
  letter-spacing: -0.02em;
  margin: 8px 0 8px;
}
.lab-foot .next p {
  font-family: var(--serif); margin: 0;
  opacity: 0.82; max-width: 380px;
}
.lab-foot .next a {
  color: inherit; text-decoration: none; display: block;
  padding: 24px; border: 1px solid var(--rule);
  transition: transform 0.2s, border-color 0.2s;
}
.lab-foot .next a:hover {
  transform: translateY(-4px); border-color: var(--ink);
}
.lab-foot .next a .meta { color: var(--accent-2); margin-bottom: 18px; }
.lab-foot .colophon {
  border-top: 1px solid var(--rule);
  margin-top: 48px;
  padding: 18px 48px 0;
  grid-column: 1 / -1;
  display: flex; justify-content: space-between;
  font-family: var(--sans); font-size: 13px;
  opacity: 0.6;
}

/* ---- Responsive (tablet / mobile) ---- */
@media (max-width: 900px) {
  .labbar { padding: 14px 28px; }
  .labbar nav { gap: 16px; font-size: 13px; }
  .lab-head { padding: 56px 28px 40px; }
  .lab-head h1 { font-size: 52px; }
  .lab-head .lede { font-size: 19px; }
  .lab-head .credits { grid-template-columns: repeat(2, 1fr); gap: 20px 24px; }
  .lab-demo { padding: 0 28px; }
  .lab-demo .frame { height: 420px; }
  .lab-controls { min-width: 220px; padding: 14px 16px; right: 16px; top: 16px; }
  .lab-body { padding: 0 28px 72px; grid-template-columns: 160px minmax(0, 1fr); gap: 32px; }
  .lab-body aside.notes { display: none; }
  .lab-body article h2 { font-size: 30px; margin: 48px 0 18px; }
  .lab-body article pre { margin: 24px -28px; }
  .lab-foot { padding: 48px 28px 40px; grid-template-columns: 1fr; gap: 28px; }
  .lab-foot .colophon { padding: 18px 28px 0; }
}
@media (max-width: 620px) {
  .labbar { padding: 12px 20px; flex-wrap: wrap; gap: 8px; }
  .labbar nav { gap: 12px; font-size: 12px; }
  .lab-head { padding: 44px 20px 32px; }
  .lab-head h1 { font-size: 34px; }
  .lab-head .lede { font-size: 17px; }
  .lab-head .kicker { flex-wrap: wrap; gap: 12px; }
  .lab-head .credits { grid-template-columns: 1fr 1fr; gap: 16px 20px; }
  .lab-demo { padding: 0 20px; margin: 40px 0 56px; }
  .lab-demo .frame { height: 300px; }
  .lab-controls { position: static; margin-top: 12px; width: 100%; min-width: 0; box-sizing: border-box; }
  .lab-demo .demo-tag { max-width: none; left: 20px; right: 20px; }
  .lab-head .credits { grid-template-columns: 1fr 1fr; }
  .lab-body { padding: 0 20px 56px; grid-template-columns: 1fr; gap: 32px; }
  .lab-body .toc { position: static; }
  .lab-body article { font-size: 17px; }
  .lab-body article h2 { font-size: 26px; }
  .lab-body article pre { margin: 24px 0; }
  .lab-body article figure { margin: 28px 0; }
  .lab-foot { padding: 40px 20px 32px; }
  .lab-foot .colophon { padding: 16px 20px 0; flex-direction: column; gap: 6px; }
}

/* ---- Large screens: scale typography/spacing up so the design keeps
   its proportions instead of floating in extra whitespace ---- */
@media (min-width: 1920px) {
  .labbar { padding: 19px 58px; font-size: 17px; }
  .lab-head { padding: 96px 58px 67px; }
  .lab-head h1 { font-size: 106px; }
  .lab-head .lede { font-size: 26px; }
  .lab-body { padding: 0 58px 115px; grid-template-columns: 240px minmax(0, 860px) 240px; gap: 67px; max-width: 1536px; }
  .lab-body article { font-size: 22px; }
  .lab-body article h2 { font-size: 43px; }
  .lab-demo .frame { height: 720px; }
  .lab-foot .next h3 { font-size: 38px; }
}
@media (min-width: 2560px) {
  .labbar { padding: 23px 69px; font-size: 20px; }
  .lab-head { padding: 115px 69px 81px; }
  .lab-head h1 { font-size: 127px; }
  .lab-head .lede { font-size: 31px; }
  .lab-body { padding: 0 69px 138px; grid-template-columns: 288px minmax(0, 1030px) 288px; gap: 81px; max-width: 1843px; }
  .lab-body article { font-size: 26px; }
  .lab-body article h2 { font-size: 52px; }
  .lab-demo .frame { height: 860px; }
  .lab-foot .next h3 { font-size: 46px; }
}
