/*
 * The laboratory scene on the home page: a diamond under analysis.
 * Built by /assets/lab-scene.js over the static scene that design_lab_scene()
 * renders; without JavaScript, or with reduced motion, the static one stays.
 * Colours are the site's: steel blue #5e8ca3, ink #15201f, white.
 */
.ms-lab { position:absolute; inset:0; overflow:hidden }
.ms-lab .mono { font-family:'IBM Plex Mono',monospace }
.ms-lab .ms-grid { position:absolute; inset:0; background-image:linear-gradient(rgba(94,140,163,.10) 1px,transparent 1px),linear-gradient(90deg,rgba(94,140,163,.10) 1px,transparent 1px); background-size:40px 40px; animation:msGridPan 6s linear infinite }
.ms-lab .ms-glow { position:absolute; inset:0; background:radial-gradient(circle at 50% 46%,rgba(94,140,163,.18),transparent 55%) }
.ms-lab .ms-rain { position:absolute; inset:0; width:100%; height:100% }
.ms-lab .ms-ray { position:absolute; left:50%; top:44%; width:46%; height:1px; background:linear-gradient(90deg,rgba(94,140,163,.7),transparent); transform-origin:0 50%; animation:msRay var(--dur) ease-in-out var(--delay) infinite }

/* The stone: sized and placed by the script, still (no float). */
.ms-lab .ms-gem { position:absolute; aspect-ratio:1; transition:left .8s ease, top .8s ease, width .8s ease }
.ms-lab .ms-gem svg { position:absolute; inset:0; width:100%; height:100%; display:block; overflow:visible }
.ms-lab .lab { transition:opacity .7s }
.ms-lab .lab text { font-family:'IBM Plex Mono',monospace; font-size:7px; fill:#3d5a68 }
.ms-lab .lab path { fill:none; stroke:#5e8ca3; stroke-width:.7; stroke-dasharray:2 2 }

/* The scan bar runs inside a window between the texts above and below it,
   which clips the trails and the glow: nothing of it ever crosses the text.
   Each cycle opens with 3.5 s at rest at the top (the results of the stone
   just scanned are on show, and the next one is placed), then a 10.4 s
   sweep. --scanMin/--scanMax are set by the script. */
.ms-lab .ms-scanwin { position:absolute; left:0; right:0; overflow:hidden; pointer-events:none }
.ms-lab .ms-scan { position:absolute; left:8%; right:8%; height:0; animation:msScan 13.9s ease-in-out infinite }
.ms-lab .ms-trail-down { position:absolute; left:0; right:0; top:-46px; height:46px; background:linear-gradient(180deg,transparent,rgba(94,140,163,.22)); animation:msTrailDown 13.9s ease-in-out infinite }
.ms-lab .ms-trail-up { position:absolute; left:0; right:0; top:0; height:46px; background:linear-gradient(0deg,transparent,rgba(94,140,163,.22)); animation:msTrailUp 13.9s ease-in-out infinite }
.ms-lab .ms-beam { position:absolute; left:0; right:0; top:-1.5px; height:3px; border-radius:2px; background:linear-gradient(90deg,transparent,#5e8ca3 12%,#dff0f7 50%,#5e8ca3 88%,transparent); box-shadow:0 0 12px rgba(94,140,163,.9),0 0 28px rgba(94,140,163,.5) }

.ms-lab .ms-status { position:absolute; left:32px; top:32px; display:flex; align-items:center; gap:8px; font-size:10.5px; letter-spacing:.14em; color:#3d5a68 }
.ms-lab .ms-blink { width:7px; height:7px; border-radius:50%; background:#5e8ca3; animation:msBlink 1.4s ease-in-out infinite }
.ms-lab .ms-coords { position:absolute; left:32px; top:52px; font-size:9.5px; line-height:1.45; letter-spacing:.06em; color:rgba(61,90,104,.75); white-space:pre }

/* The terminal, top right: the analysis number is its title bar. */
.ms-lab .ms-term { position:absolute; right:32px; top:26px; width:38%; padding:6px 8px; font-size:9px; line-height:1.4; color:#3d5a68; background:rgba(255,255,255,.72); border:1px solid rgba(94,140,163,.3); min-height:40px }
.ms-lab .ms-term div { white-space:nowrap; overflow:hidden }
.ms-lab .ms-term .th { color:rgba(61,90,104,.6); letter-spacing:.14em; border-bottom:1px solid rgba(94,140,163,.25); padding-bottom:3px; margin-bottom:3px }
.ms-lab .ms-term .cur { animation:msBlink 1s steps(1) infinite }

/* FTIR spectrum under the stone. */
.ms-lab .ms-spec { position:absolute; left:13%; width:74%; top:61%; height:12% }
.ms-lab .ms-spec svg { width:100%; height:100%; display:block; overflow:visible }
.ms-lab .ms-spec .curve { fill:none; stroke:#5e8ca3; stroke-width:1.4 }
.ms-lab .ms-spec .axis { stroke:rgba(94,140,163,.5); stroke-width:.8 }
.ms-lab .ms-spec text { font-family:'IBM Plex Mono',monospace; font-size:7px; fill:#3d5a68 }
.ms-lab .ms-spec .mark { transition:opacity .6s; opacity:0 }
.ms-lab .ms-spec .mark.show { opacity:1 }

/* Six readouts in three columns; a long value wraps rather than being cut. */
.ms-lab .ms-read { position:absolute; left:32px; right:32px; bottom:32px; display:grid; grid-template-columns:repeat(3,1fr); gap:10px 12px }
.ms-lab .ms-read > div { display:flex; flex-direction:column; gap:3px; border-top:1px solid rgba(94,140,163,.4); padding-top:8px; min-width:0 }
.ms-lab .ms-read .k { font-size:9.5px; letter-spacing:.18em; color:#5e8ca3 }
.ms-lab .ms-read .v { font-size:13px; line-height:1.25; color:#15201f }

@keyframes msGridPan { from { background-position:0 0 } to { background-position:0 40px } }
@keyframes msRay { 0%,100% { opacity:.15; transform:scaleX(.6) } 50% { opacity:.9; transform:scaleX(1) } }
@keyframes msBlink { 0%,100% { opacity:1 } 50% { opacity:.2 } }
/* 0–25.2%: rest (3.5 s); 25.2–62.6%: down (5.2 s); 62.6–100%: back up. */
@keyframes msScan { 0%,25.2% { top:var(--scanMin,14px) } 62.6% { top:var(--scanMax,72%) } 100% { top:var(--scanMin,14px) } }
@keyframes msTrailDown { 0%,31% { opacity:0 } 37%,55% { opacity:1 } 62.6%,100% { opacity:0 } }
@keyframes msTrailUp { 0%,71% { opacity:0 } 78%,95% { opacity:1 } 100% { opacity:0 } }
