:root {
  --bg: #0d0f13;
  --bg-card: #16191f;
  --bg-card-2: #1c2028;
  --line: #272c36;
  --line-hi: #3a414f;
  --text: #e8ecf3;
  --muted: #8b94a6;
  --accent: #6ea8fe;
  --radius: 14px;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 ui-sans-serif, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---- the single shared canvas -------------------------------------------
   Fixed to the viewport and transparent. Each viewer is drawn into a scissor
   rectangle matching its card, so everything outside the cards stays clear
   and the page's own markup shows through. */
#gl {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;   /* cards below receive the drag events */
}

/* ---- header -------------------------------------------------------------- */
.head {
  position: relative;
  z-index: 2;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #12151b, var(--bg));
}
.head-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 28px;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: flex-end;
  justify-content: space-between;
}
.title h1 {
  margin: 0 0 6px;
  font-size: 27px;
  letter-spacing: -0.02em;
  font-weight: 620;
}
.title p {
  margin: 0;
  color: var(--muted);
  max-width: 62ch;
  font-size: 14px;
}

/* ---- loader -------------------------------------------------------------- */
.loader { min-width: 220px; }
.loader[hidden] { display: none; }
.loader-bar {
  height: 4px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.loader-bar span {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 4px;
  background: var(--accent);
  transition: width .18s ease-out;
}
.loader-text {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---- toolbar ------------------------------------------------------------- */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar[hidden] { display: none; }
.btn {
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-card-2);
  border: 1px solid var(--line-hi);
  border-radius: 9px;
  padding: 7px 13px;
  cursor: pointer;
  transition: background .13s, border-color .13s, color .13s;
}
.btn:hover { background: #242935; }
.btn[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-color: var(--accent);
  color: #cfe0ff;
}

/* ---- grid of viewers ----------------------------------------------------- */
.grid {
  position: relative;
  z-index: 0;           /* below the canvas, so the model draws over the card */
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 20px;
  grid-template-columns: repeat(3, 1fr);
}
@media (max-width: 1000px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .grid { grid-template-columns: 1fr; } }

.card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    radial-gradient(120% 90% at 50% 0%, var(--bg-card-2), var(--bg-card) 70%);
  overflow: hidden;
  transition: border-color .15s;
}
.card.is-active { border-color: var(--line-hi); }

/* The stage is the hit area + the rectangle the renderer scissors to. */
.stage {
  aspect-ratio: 4 / 3;
  width: 100%;
  display: block;
  touch-action: none;      /* required for OrbitControls on touch devices */
  cursor: grab;
}
.stage:active { cursor: grabbing; }

/* Everything chrome-like sits above the canvas. */
.card-ui {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 14px;
}
.card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-label {
  font-size: 12.5px;
  font-weight: 560;
  letter-spacing: .02em;
  color: var(--text);
  background: rgba(13, 15, 19, .62);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
}
.card-reset {
  pointer-events: auto;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: rgba(13, 15, 19, .62);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, color .15s;
}
.card:hover .card-reset { opacity: 1; }
.card-reset:hover { color: var(--text); }

/* Hidden by default so it never sits on top of the model; revealed on hover
   and kept visible while the card is the active one. */
.card-hint {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  background: rgba(13, 15, 19, .62);
  backdrop-filter: blur(6px);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 10px;
  opacity: 0;
  transition: opacity .2s, color .2s;
}
.card:hover .card-hint,
.card.is-active .card-hint { opacity: 1; }
.card.is-active .card-hint { color: #cfe0ff; }

/* skeleton shimmer while the model loads */
.card.is-loading::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(100deg, transparent 30%, rgba(255,255,255,.045) 50%, transparent 70%);
  background-size: 220% 100%;
  animation: shimmer 1.35s infinite linear;
}
@keyframes shimmer { from { background-position: 120% 0; } to { background-position: -120% 0; } }

/* ---- stats bar ----------------------------------------------------------- */
.stats {
  position: relative;
  z-index: 2;
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 24px 56px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.stat {
  flex: 1 1 130px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--bg-card);
  padding: 11px 13px;
}
.stat b {
  display: block;
  font-size: 19px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.stat span {
  display: block;
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .card.is-loading::after { animation: none; }
}
