/* Smashing Science — 3D model viewer layout */
.viewer-page { min-height: 100dvh; display: flex; flex-direction: column; }

.viewer { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr); min-height: 0; }

/* ---------- stage ---------- */
.stage {
  position: sticky;
  top: 0;
  z-index: 5;
  height: 56dvh;
  min-height: 300px;
  background: radial-gradient(120% 90% at 50% 35%, #1a2944 0%, #0d1628 55%, #080e1a 100%);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.stage-canvas { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.stage-canvas:active { cursor: grabbing; }
.stage-canvas:focus-visible { outline-offset: -3px; border-radius: 0; }

.stage-toolbar { position: absolute; top: 12px; left: 12px; display: flex; gap: 8px; }
.tool {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(13, 22, 40, 0.82);
  backdrop-filter: blur(8px);
  font-size: 0.9rem;
  font-weight: 550;
  cursor: pointer;
}
.tool:hover { border-color: var(--teal); }
.tool[aria-pressed='true'] { background: var(--teal); border-color: var(--teal); color: #04201c; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.stage-hint {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 10px;
  text-align: center;
  padding: 0 12px;
  color: var(--muted);
  font-size: 0.8rem;
  pointer-events: none;
}
.hover-tip {
  position: absolute;
  z-index: 3;
  padding: 4px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: rgba(10, 17, 32, 0.94);
  font-size: 0.85rem;
  font-weight: 550;
  white-space: nowrap;
  pointer-events: none;
}
.stage-error { max-width: 46ch; margin: 20vh auto 0; padding: 0 20px; text-align: center; color: var(--muted); }
.caption, .exit-present { display: none; }

/* ---------- panel ---------- */
.panel { display: grid; align-content: start; gap: 12px; padding: 14px; background: var(--bg-2); }
.panel:focus { outline: none; }
.card { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 16px; }
.card-title { margin-bottom: 12px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }

.info-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.info-title { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.25; }
.info-where { margin-top: 4px; color: var(--blue); font-size: 0.9rem; }
.info-text { margin-top: 10px; color: var(--text); }
.info .info-title + .info-text { color: var(--muted); }
.facts-title { margin-top: 14px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.facts { margin-top: 8px; display: grid; gap: 7px; }
.facts li { position: relative; padding-left: 18px; color: var(--text); font-size: 0.95rem; }
.facts li::before { content: ''; position: absolute; left: 2px; top: 0.62em; width: 6px; height: 6px; border-radius: 50%; background: var(--teal); }
.icon-btn { display: grid; place-items: center; width: 36px; height: 36px; margin: -6px -6px 0 0; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }

.swatch { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28); }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 36px;
  padding: 6px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  font-size: 0.88rem;
  font-weight: 520;
  cursor: pointer;
}
.chip:hover { border-color: var(--teal); }
.chip[aria-pressed='true'] { background: var(--teal-soft); border-color: var(--teal); color: #b6f5ec; }

.slider { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.slider + .slider { margin-top: 14px; }
.slider label { font-size: 0.93rem; font-weight: 520; }
.slider output { color: var(--muted); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.slider input { grid-column: 1 / -1; width: 100%; height: 28px; margin: 0; accent-color: var(--teal); cursor: pointer; }

.group { border-top: 1px solid var(--line); }
.group:first-of-type { border-top: 0; }
.group summary { display: flex; align-items: center; gap: 10px; min-height: 46px; cursor: pointer; list-style: none; font-weight: 580; }
.group summary::-webkit-details-marker { display: none; }
.group summary::before { content: ''; width: 7px; height: 7px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(-45deg); transition: transform 0.15s; margin: 0 4px 0 2px; }
.group[open] summary::before { transform: rotate(45deg); }
.group-title { flex: 1; }
.count { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }
.group-actions { display: flex; gap: 16px; padding: 0 0 6px 24px; }
.link { padding: 4px 0; border: 0; background: none; color: var(--blue); font-size: 0.85rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link:hover { color: #fff; }

.items { padding-bottom: 10px; }
.item { display: flex; align-items: center; gap: 4px; border-radius: 9px; }
.item input { width: 18px; height: 18px; margin: 0 6px 0 4px; accent-color: var(--teal); flex: none; cursor: pointer; }
.item-name { flex: 1; display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 6px 8px; border: 0; border-radius: 9px; background: none; text-align: left; font-size: 0.95rem; cursor: pointer; }
.item-name:hover { background: var(--surface-2); }
.item.is-off .item-name { color: var(--muted); }
.item.is-off .swatch { opacity: 0.4; }
.item.is-selected .item-name { background: var(--teal-soft); color: #c9faf3; font-weight: 580; }

/* ---------- desktop / projector ---------- */
@media (min-width: 900px) {
  .viewer-page { height: 100dvh; overflow: hidden; }
  .viewer { grid-template-columns: minmax(0, 1fr) clamp(340px, 28vw, 440px); }
  .stage { position: relative; height: auto; border-bottom: 0; border-right: 1px solid var(--line); }
  .stage-toolbar { top: 16px; left: 16px; }
  .panel { overflow-y: auto; padding: 16px; }
}

/* ---------- present mode ---------- */
.is-presenting .site-header, .is-presenting .panel, .is-presenting .stage-toolbar, .is-presenting .stage-hint { display: none; }
.is-presenting .stage { position: fixed; inset: 0; z-index: 50; width: 100vw; height: 100dvh; border: 0; }
.is-presenting .exit-present { display: inline-flex; position: absolute; top: 16px; right: 16px; opacity: 0.55; }
.is-presenting .exit-present:hover, .is-presenting .exit-present:focus-visible { opacity: 1; }
.is-presenting .caption {
  display: block;
  position: absolute;
  left: 50%;
  bottom: clamp(16px, 4vh, 48px);
  transform: translateX(-50%);
  width: min(900px, 100% - 32px);
  padding: clamp(14px, 2vw, 24px) clamp(18px, 2.6vw, 32px);
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: rgba(10, 17, 32, 0.86);
  backdrop-filter: blur(10px);
  pointer-events: none;
}
.caption-title { font-size: clamp(1.3rem, 2.6vw, 2.3rem); font-weight: 680; letter-spacing: -0.02em; line-height: 1.2; color: #fff; }
.caption-text { margin-top: 6px; font-size: clamp(1rem, 1.55vw, 1.4rem); line-height: 1.45; color: #d5deeb; }

noscript p { padding: 24px; color: var(--muted); }
