/* ChemicallyFired — 3D Museum page styles (2026-07 museum upgrade).
 * A bright, calm, Apple-like science museum: white base, frosted glass panels,
 * pastel nebula accents. Loaded only on /lab/. */

.lab3d-body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(80% 60% at 82% -6%, rgba(122, 224, 196, 0.16), transparent 60%),
    radial-gradient(70% 55% at 6% 100%, rgba(217, 211, 245, 0.2), transparent 62%),
    linear-gradient(180deg, #f7faf9, #f2f6f4);
  color: var(--ink, #111615);
}

.lab3d-top {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 64px;
  padding: 10px clamp(14px, 3vw, 40px);
  border-bottom: 1px solid rgba(17, 22, 21, 0.07);
  background: rgba(250, 253, 252, 0.7);
  -webkit-backdrop-filter: blur(22px) saturate(160%);
  backdrop-filter: blur(22px) saturate(160%);
}

.lab3d-brand span {
  color: var(--ink, #111615);
  white-space: nowrap;
}

.lab3d-brand em {
  font-style: normal;
  color: var(--sea-dark, #13745f);
  font-weight: 800;
}

.lab3d-top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.lab3d-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 16px;
  border: 1px solid rgba(17, 22, 21, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.66);
  color: #2c3634;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  box-shadow: 0 8px 22px rgba(26, 45, 40, 0.06);
  transition: background 200ms ease, border-color 200ms ease, transform 160ms ease;
}

.lab3d-chip:hover {
  background: rgba(255, 255, 255, 0.92);
  transform: translateY(-1px);
}

.lab3d-chip.is-active {
  border-color: rgba(42, 169, 138, 0.55);
  background: rgba(42, 169, 138, 0.12);
  color: var(--sea-dark, #13745f);
}

.lab3d-chip:focus-visible {
  outline: 2px solid var(--sea, #2aa98a);
  outline-offset: 2px;
}

.lab3d-exit {
  display: inline-flex;
  align-items: center;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--dark, #101716);
  color: #fff;
  font-weight: 750;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: transform 160ms ease, background 200ms ease;
}

.lab3d-exit:hover {
  transform: translateY(-1px);
  background: #25302e;
}

/* --- Music controls ---------------------------------------------------------- */
.lab3d-music {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid rgba(17, 22, 21, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
}

.lab3d-music .music-tab-icon {
  color: #66706d;
}

.lab3d-music.is-playing .music-tab-icon {
  color: var(--sea-dark, #13745f);
}

.lab3d-volume {
  width: 86px;
  accent-color: var(--sea, #2aa98a);
}

.lab3d-music-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 20px;
  font-size: 0.92rem;
  color: #4a5450;
  cursor: pointer;
}

.lab3d-music-opt input {
  width: 18px;
  height: 18px;
  accent-color: var(--sea, #2aa98a);
}

/* --- Viewport ------------------------------------------------------------- */
.lab3d-stage {
  position: relative;
  flex: 1;
  min-height: max(430px, calc(100dvh - 64px));
  overflow: hidden;
}

#labCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.lab3d-loading {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: #66706d;
  font-weight: 650;
  pointer-events: none;
}

.lab3d-spinner {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(42, 169, 138, 0.18);
  border-top-color: var(--sea, #2aa98a);
  animation: lab3dSpin 0.9s linear infinite;
}

@keyframes lab3dSpin {
  to { transform: rotate(360deg); }
}

/* --- Intro overlay ------------------------------------------------------------ */
.lab3d-intro {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(244, 249, 247, 0.5);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
}

.lab3d-intro-card {
  width: min(520px, 100%);
  padding: clamp(24px, 4vw, 40px);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  backdrop-filter: blur(28px) saturate(160%);
  box-shadow: 0 40px 110px rgba(26, 45, 40, 0.18);
}

.lab3d-intro-card .eyebrow {
  color: var(--sea-dark, #13745f);
}

.lab3d-intro-card h1 {
  margin-bottom: 12px;
  font-size: clamp(1.9rem, 4.5vw, 2.7rem);
}

.lab3d-intro-lead {
  color: #4a5450;
}

.lab3d-controls-list {
  margin: 18px 0 14px;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.lab3d-controls-list li {
  padding: 10px 14px;
  border: 1px solid rgba(17, 22, 21, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.6);
  color: #4a5450;
  font-size: 0.92rem;
}

.lab3d-controls-list strong {
  color: var(--sea-dark, #13745f);
}

.lab3d-intro-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
}

.lab3d-intro-alt {
  color: #66706d;
  font-weight: 650;
  font-size: 0.9rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Touch joystick --------------------------------------------------------- */
.lab3d-joystick {
  position: absolute;
  left: 22px;
  bottom: 24px;
  z-index: 8;
  width: 118px;
  height: 118px;
  border-radius: 50%;
  border: 1.5px solid rgba(42, 169, 138, 0.4);
  background: rgba(255, 255, 255, 0.42);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  box-shadow: 0 14px 34px rgba(26, 45, 40, 0.14);
  touch-action: none;
}

.lab3d-stick {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(42, 169, 138, 0.75);
  box-shadow: 0 6px 18px rgba(19, 116, 95, 0.35);
  transform: translate(-50%, -50%);
}

/* --- Transient hint ---------------------------------------------------------- */
.lab3d-hint {
  position: absolute;
  left: 50%;
  bottom: 20px;
  z-index: 7;
  transform: translateX(-50%);
  max-width: min(92%, 560px);
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  color: #3f4946;
  font-size: 0.85rem;
  font-weight: 650;
  text-align: center;
  pointer-events: none;
  box-shadow: 0 12px 30px rgba(26, 45, 40, 0.1);
}

/* --- Scan / identify card ------------------------------------------------------ */
.lab3d-scan {
  position: absolute;
  z-index: 9;
  width: min(360px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.74);
  -webkit-backdrop-filter: blur(26px) saturate(160%);
  backdrop-filter: blur(26px) saturate(160%);
  box-shadow: 0 30px 80px rgba(26, 45, 40, 0.2);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 220ms ease, transform 260ms cubic-bezier(.2, .8, .2, 1);
  pointer-events: none;
}

.lab3d-scan.is-open {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* Animated identify sweep across the top of the card. */
.lab3d-scan::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--sea, #2aa98a) 35%, #8f7bf0 65%, transparent);
  background-size: 220% 100%;
  animation: labScanSweep 1.1s ease-out 1;
}

@keyframes labScanSweep {
  from { background-position: 120% 0; opacity: 1; }
  to   { background-position: -60% 0; opacity: 0.7; }
}

.lab3d-scan-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 0 0 8px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--sea-dark, #13745f);
}

.lab3d-scan-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--sea, #2aa98a);
  animation: labScanPulse 1.4s ease-in-out infinite;
}

@keyframes labScanPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(42, 169, 138, 0.2); }
  50%      { box-shadow: 0 0 0 7px rgba(42, 169, 138, 0.05); }
}

.lab3d-scan h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.lab3d-scan-summary {
  margin: 0 0 10px;
  color: var(--sea-dark, #13745f);
  font-size: 0.9rem;
  font-weight: 650;
}

.lab3d-scan h3 {
  margin: 12px 0 4px;
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: #8a948f;
}

.lab3d-scan p {
  margin: 0;
  color: #3f4946;
  font-size: 0.92rem;
}

.lab3d-scan-safety {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(232, 131, 58, 0.3);
  background: rgba(232, 131, 58, 0.08);
}

.lab3d-scan-safety h3 {
  margin: 0 0 3px;
  color: #b05f1e;
}

.lab3d-scan-safety p {
  font-size: 0.86rem;
}

.lab3d-scan-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.lab3d-scan-badges span {
  padding: 4px 10px;
  border: 1px solid rgba(42, 169, 138, 0.25);
  border-radius: 999px;
  background: rgba(42, 169, 138, 0.09);
  color: var(--sea-dark, #13745f);
  font-size: 0.74rem;
  font-weight: 700;
}

.lab3d-scan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.lab3d-scan-link {
  display: inline-flex;
  padding: 9px 15px;
  border-radius: 999px;
  background: var(--sea, #2aa98a);
  color: #fff;
  font-weight: 750;
  font-size: 0.85rem;
  transition: transform 160ms ease, background 200ms ease;
}

.lab3d-scan-link:hover {
  transform: translateY(-1px);
  background: #35bd9b;
}

.lab3d-scan-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  border: 1px solid rgba(17, 22, 21, 0.1);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  color: #3f4946;
  font-size: 0.95rem;
  cursor: pointer;
}

.lab3d-scan-close:hover {
  background: #fff;
}

/* Desktop: card floats near the scanned object; mobile: bottom sheet. */
@media (max-width: 700px) {
  .lab3d-scan {
    left: 12px !important;
    right: 12px !important;
    top: auto !important;
    bottom: 12px !important;
    width: auto;
    max-height: 56%;
    border-radius: 18px;
  }
}

/* --- Exhibit rail: removed from the museum (kept for potential reuse) -------- */
.lab3d-rail {
  display: none;
}

.lab3d-rail-unused {
  display: flex;
  gap: 12px;
  padding: 16px clamp(14px, 3vw, 40px) 22px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(226, 238, 233, 0.5));
}

.lab3d-rail-card {
  flex: none;
  scroll-snap-align: start;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 210px;
  min-height: 64px;
  padding: 12px 18px 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.85);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.68);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  backdrop-filter: blur(18px) saturate(150%);
  box-shadow: 0 14px 30px rgba(26, 45, 40, 0.08);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 200ms ease, border-color 200ms ease, background 200ms ease;
}

.lab3d-rail-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 20px 44px rgba(26, 45, 40, 0.14);
  border-color: rgba(42, 169, 138, 0.4);
}

.lab3d-rail-card.is-active {
  border-color: rgba(42, 169, 138, 0.6);
  background: rgba(42, 169, 138, 0.1);
}

.lab3d-rail-card:focus-visible {
  outline: 2px solid var(--sea, #2aa98a);
  outline-offset: 2px;
}

.lab3d-rail-dot {
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 1rem;
  background: linear-gradient(150deg, rgba(42, 169, 138, 0.16), rgba(143, 123, 240, 0.14));
  color: var(--sea-dark, #13745f);
}

.lab3d-rail-card.is-featured .lab3d-rail-dot {
  background: linear-gradient(150deg, rgba(143, 123, 240, 0.2), rgba(238, 166, 98, 0.18));
  color: #6d55d8;
}

.lab3d-rail-copy {
  min-width: 0;
}

.lab3d-rail-copy strong {
  display: block;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lab3d-rail-copy span {
  display: block;
  margin-top: 1px;
  color: #66706d;
  font-size: 0.78rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 240px;
}

@media (max-width: 700px) {
  .lab3d-rail {
    padding-bottom: 26px;
    gap: 10px;
  }
  .lab3d-rail-card {
    min-width: 200px;
    min-height: 68px; /* larger tap target on phones */
  }
}

/* --- Fallback directory ------------------------------------------------------- */
.lab3d-fallback {
  padding: clamp(28px, 5vw, 64px) clamp(16px, 4vw, 48px) 64px;
}

.lab3d-fallback-head .eyebrow {
  color: var(--sea-dark, #13745f);
}

.lab3d-fallback-head h2 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  margin-bottom: 10px;
}

.lab3d-fallback-head p {
  color: #66706d;
  max-width: 640px;
}

.lab3d-fallback-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 28px;
}

.lab3d-fallback-card {
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.72);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
  box-shadow: 0 16px 38px rgba(26, 45, 40, 0.08);
}

.lab3d-fallback-card h3 {
  margin: 0 0 6px;
  font-size: 1.12rem;
}

.lab3d-fallback-card p {
  color: #4a5450;
  font-size: 0.92rem;
}

.lab3d-fallback-card .lab3d-scan-badges {
  margin-top: 12px;
}

.lab3d-fallback-card a {
  display: inline-block;
  margin-top: 14px;
  color: var(--sea-dark, #13745f);
  font-weight: 700;
  font-size: 0.9rem;
}

.lab3d-fallback-foot {
  margin-top: 34px;
}

/* --- Mobile / motion ------------------------------------------------------------ */
@media (max-width: 700px) {
  .lab3d-intro-card {
    max-height: 82dvh;
    overflow: auto;
  }
  .lab3d-hint {
    bottom: auto;
    top: 14px;
  }
  .lab3d-volume {
    display: none; /* volume via device buttons on phones; toggle stays */
  }
}

@media (prefers-reduced-motion: reduce) {
  .lab3d-spinner { animation: none; }
  .lab3d-scan::before { animation: none; opacity: 0.6; }
  .lab3d-scan-status::before { animation: none; }
  .lab3d-scan,
  .lab3d-chip,
  .lab3d-exit,
  .lab3d-rail-card,
  .lab3d-scan-link { transition: none; }
}
