/* Materials Graph Lab prototype */

:root {
  --lab-space: #101820;
  --lab-space-2: #182531;
  --lab-paper: #fff8e8;
  --lab-paper-2: #f7ead2;
  --lab-ink: #172033;
  --lab-muted: #536171;
  --lab-coral: #e85d4f;
  --lab-mint: #2fa77f;
  --lab-sky: #387bd8;
  --lab-gold: #f1b62d;
  --lab-violet: #7457c8;
  --lab-line: rgba(23, 32, 51, 0.16);
  --lab-shadow: 0 22px 80px rgba(25, 45, 67, 0.16);
}

.materials-lab-page {
  --bg: #fff8e8;
  --bg-alt: #e9f7ff;
  --surface: #ffffff;
  --surface-soft: rgba(56, 123, 216, 0.08);
  --text: var(--lab-ink);
  --muted: var(--lab-muted);
  --line: rgba(23, 32, 51, 0.18);
  --line-strong: rgba(23, 32, 51, 0.34);
  --primary-bg: var(--lab-sky);
  --primary-text: #ffffff;
  --ink-rgb: 23, 32, 51;
  color: var(--lab-ink);
  background:
    linear-gradient(135deg, rgba(47, 167, 127, 0.20), transparent 30%),
    linear-gradient(315deg, rgba(241, 182, 45, 0.20), transparent 34%),
    linear-gradient(180deg, #fff8e8 0%, #edf8fb 52%, #fff6df 100%);
}

.materials-lab-page .bg {
  opacity: 0.28;
  filter: saturate(1.1);
}

.materials-lab-page .site-header {
  background: rgba(255, 248, 232, 0.88);
  border-bottom-color: rgba(23, 32, 51, 0.12);
  backdrop-filter: blur(18px);
}

.materials-lab-page .site-header.scrolled {
  background: rgba(255, 248, 232, 0.94);
}

.materials-lab {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
  padding: clamp(1rem, 2vw, 2rem) 0 3rem;
}

.lab-hero {
  display: grid;
  grid-template-columns: minmax(280px, 0.82fr) minmax(520px, 1.35fr);
  min-height: min(820px, calc(100vh - 128px));
  gap: clamp(1rem, 2.4vw, 2.5rem);
  align-items: stretch;
}

.lab-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  padding: clamp(1rem, 3vw, 2.25rem) 0;
}

.lab-copy .kicker {
  margin: 0 0 0.65rem;
  color: var(--lab-mint);
  font-family: ui-sans-serif, system-ui, sans-serif;
  font-size: 0.84rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lab-copy h1 {
  margin: 0;
  color: var(--lab-ink);
  font-size: clamp(3rem, 7vw, 7rem);
  line-height: 0.9;
  letter-spacing: 0;
  max-width: 9ch;
}

.lab-deck {
  max-width: 54ch;
  margin: 1.2rem 0 0;
  color: var(--lab-muted);
  font-size: clamp(1.05rem, 1.5vw, 1.28rem);
  line-height: 1.55;
}

.paper-strip {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  margin-top: 2rem;
  padding: 1rem;
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-left: 5px solid var(--lab-gold);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 12px 42px rgba(23, 32, 51, 0.08);
  color: var(--lab-muted);
}

.paper-strip span {
  color: var(--lab-coral);
  font-size: 0.82rem;
  font-weight: 750;
  text-transform: uppercase;
}

.paper-strip strong {
  color: var(--lab-ink);
  line-height: 1.3;
}

.paper-strip a {
  width: fit-content;
  color: var(--lab-sky);
  font-weight: 750;
}

.lab-stage {
  position: relative;
  min-height: 540px;
  overflow: hidden;
  background:
    linear-gradient(145deg, var(--lab-space), var(--lab-space-2));
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 8px;
  box-shadow: var(--lab-shadow);
}

#crystal-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 540px;
  aspect-ratio: 16 / 10;
  cursor: grab;
  touch-action: none;
}

#crystal-canvas:active {
  cursor: grabbing;
}

.stage-hud {
  position: absolute;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  pointer-events: none;
}

.stage-hud span {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.35rem 0.62rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(12, 18, 26, 0.70);
  color: #fff8e8;
  font-size: 0.82rem;
  font-weight: 720;
}

.lab-workbench {
  display: grid;
  gap: 1rem;
  margin-top: 1rem;
}

.control-band,
.metrics-row {
  display: grid;
  grid-template-columns: minmax(150px, 0.72fr) minmax(280px, 1.25fr) minmax(190px, 0.9fr) minmax(190px, 0.9fr) minmax(140px, 0.65fr);
  gap: 0.75rem;
  align-items: stretch;
}

.control-group,
.metric-tile {
  min-width: 0;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  padding: 0.85rem;
  box-shadow: 0 10px 32px rgba(23, 32, 51, 0.08);
}

.control-group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.5rem;
  margin: 0;
}

.control-group > span,
.control-group legend,
.metric-tile span {
  color: #677080;
  font-size: 0.78rem;
  font-weight: 760;
  text-transform: uppercase;
}

.control-group select,
.control-group input,
.control-group button {
  font: inherit;
}

.control-group select {
  width: 100%;
  min-height: 2.55rem;
  border: 1px solid rgba(38, 33, 27, 0.24);
  border-radius: 6px;
  background: var(--lab-paper);
  color: var(--lab-ink);
  padding: 0.45rem 0.6rem;
}

.segmented,
.stepper {
  display: flex;
  min-width: 0;
}

.segment,
.stepper button {
  min-height: 2.55rem;
  border: 1px solid rgba(23, 32, 51, 0.16);
  background: #fff8e8;
  color: var(--lab-ink);
  font-weight: 750;
  cursor: pointer;
}

.segment {
  flex: 1 1 0;
  padding: 0.45rem 0.65rem;
}

.segment + .segment,
.stepper button + output,
.stepper output + button {
  border-left: 0;
}

.segment.active,
.stepper button:hover,
.segment:hover {
  background: var(--lab-space);
  color: #fff8e8;
}

.segment[data-mode="graph"].active { background: var(--lab-sky); }
.segment[data-mode="spin"].active { background: var(--lab-mint); }
.segment[data-mode="message"].active { background: var(--lab-violet); }
.segment[data-mode="property"].active { background: var(--lab-coral); }

.range-control input {
  width: 100%;
  accent-color: var(--lab-mint);
}

.range-control output {
  float: right;
  color: var(--lab-coral);
  font-weight: 800;
}

.stepper button {
  width: 2.75rem;
  padding: 0;
  font-size: 1.15rem;
}

.stepper output {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 3.2rem;
  min-height: 2.55rem;
  border: 1px solid rgba(38, 33, 27, 0.22);
  background: var(--lab-paper);
  color: var(--lab-ink);
  font-weight: 820;
}

.metrics-row {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric-tile {
  display: grid;
  gap: 0.25rem;
  min-height: 5.4rem;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.84), rgba(255, 248, 232, 0.72));
}

.metric-tile strong {
  color: var(--lab-ink);
  font-size: clamp(1.45rem, 3vw, 2.4rem);
  line-height: 1;
}

.lab-inspector {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(260px, 1fr) minmax(320px, 1.25fr);
  gap: 0.75rem;
}

.inspector-panel {
  min-width: 0;
  padding: 1rem;
  border: 1px solid rgba(23, 32, 51, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  box-shadow: 0 10px 32px rgba(23, 32, 51, 0.08);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.panel-heading span {
  color: var(--lab-coral);
  font-size: 0.76rem;
  font-weight: 820;
  text-transform: uppercase;
}

.panel-heading strong {
  color: var(--lab-ink);
  text-align: right;
}

.sample-facts {
  display: grid;
  gap: 0.55rem;
  margin: 0;
}

.sample-facts div {
  display: grid;
  grid-template-columns: minmax(6.8rem, 0.58fr) 1fr;
  gap: 0.75rem;
  align-items: baseline;
}

.sample-facts dt {
  color: #677080;
  font-size: 0.74rem;
  font-weight: 780;
  text-transform: uppercase;
}

.sample-facts dd {
  margin: 0;
  color: var(--lab-ink);
  font-weight: 650;
}

.feature-bars {
  display: grid;
  gap: 0.45rem;
  margin-top: 0.9rem;
}

.feature-bar {
  display: grid;
  grid-template-columns: 4.5rem 1fr 3rem;
  gap: 0.5rem;
  align-items: center;
}

.feature-bar span,
.feature-bar strong {
  color: #677080;
  font-size: 0.75rem;
  font-weight: 760;
  text-transform: uppercase;
}

.feature-bar strong {
  color: var(--lab-ink);
  text-align: right;
}

.feature-bar i {
  display: block;
  height: 0.55rem;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(23, 32, 51, 0.12);
}

.feature-bar i::before {
  display: block;
  width: calc(var(--value) * 100%);
  height: 100%;
  background: linear-gradient(90deg, var(--lab-sky), var(--lab-mint), var(--lab-gold));
  content: "";
}

.model-panel p {
  margin: 0;
  color: var(--lab-muted);
  line-height: 1.55;
}

.model-panel .model-boundary {
  margin-top: 0.8rem;
  padding-top: 0.8rem;
  border-top: 1px solid rgba(23, 32, 51, 0.12);
  color: #7a4f20;
  font-size: 0.9rem;
}

.lab-explainer {
  margin-top: clamp(2rem, 5vw, 4.5rem);
}

.lab-explainer h2 {
  margin: 0 0 1rem;
  color: var(--lab-ink);
  font-size: clamp(1.8rem, 4vw, 3.2rem);
}

.pipeline-intro {
  max-width: 68rem;
  margin: -0.25rem 0 1.6rem;
  color: var(--lab-muted);
  font-size: clamp(1rem, 1.6vw, 1.15rem);
  line-height: 1.7;
}

.pipeline {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.75rem;
}

.pipeline article {
  min-width: 0;
  padding: clamp(1rem, 2vw, 1.5rem);
  border: 1px solid rgba(23, 32, 51, 0.12);
  border-top: 5px solid var(--lab-sky);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.66);
  box-shadow: 0 12px 34px rgba(23, 32, 51, 0.07);
}

.pipeline article:nth-child(2) { border-top-color: var(--lab-mint); }
.pipeline article:nth-child(3) { border-top-color: var(--lab-gold); }
.pipeline article:nth-child(4) { border-top-color: var(--lab-violet); }
.pipeline article:nth-child(5) { border-top-color: var(--lab-coral); }

.pipeline article:hover {
  transform: translateY(-2px);
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 16px 42px rgba(23, 32, 51, 0.11);
}

.pipe-index {
  color: var(--lab-coral);
  font-size: 0.78rem;
  font-weight: 820;
}

.pipeline h3 {
  margin: 0.45rem 0 0.55rem;
  color: var(--lab-ink);
}

.pipeline p {
  margin: 0;
  color: var(--lab-muted);
  line-height: 1.5;
}

@media (max-width: 980px) {
  .lab-hero {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .lab-copy {
    padding-bottom: 0;
  }

  .lab-copy h1 {
    max-width: 11ch;
  }

  .control-band {
    grid-template-columns: 1fr 1fr;
  }

  .metrics-row,
  .lab-inspector,
  .pipeline {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .model-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 640px) {
  .materials-lab {
    width: min(100vw - 20px, 1440px);
    padding-top: 0.65rem;
  }

  .lab-copy h1 {
    font-size: clamp(2.7rem, 16vw, 4.4rem);
  }

  .lab-deck {
    font-size: 1rem;
  }

  .lab-stage {
    min-height: 430px;
  }

  #crystal-canvas {
    min-height: 430px;
    aspect-ratio: 4 / 5;
  }

  .control-band,
  .metrics-row,
  .lab-inspector,
  .pipeline {
    grid-template-columns: 1fr;
  }

  .model-panel {
    grid-column: auto;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  }

  .segment + .segment {
    border-left: 1px solid rgba(38, 33, 27, 0.22);
  }

  .segment:nth-child(n + 3) {
    border-top: 0;
  }
}
