/* ==========================================================================
   Layout: header, page grid, 3D viewer, telemetry strip, viewer toolbar
   ========================================================================== */

.app {
  min-height: 100vh;
}

/* ---- header ---- */

.top {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.07em;
  white-space: nowrap;
}

.brand span,
.brand em {
  color: var(--accent);
  font-style: normal;
}

.top-center {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.status .dot {
  width: 7px;
  height: 7px;
  background: var(--idle);
}

.status[data-state='on'] .dot {
  background: var(--accent);
  box-shadow: 0 0 11px var(--accent);
}

.status[data-state='idle'] .dot {
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.3;
  }
}

.battery {
  padding-left: 10px;
  border-left: 1px solid var(--line);
  color: var(--muted);
}

/* ---- page grid ---- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(385px, 1fr);
  min-height: calc(100vh - var(--header-height));
}

.viewer {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
}

/* ---- 3D stage ---- */

.stage {
  height: min(70vh, 730px);
  min-height: 420px;
  position: relative;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 48%, #1b3024 0, #101e18 55%, var(--bg) 80%);
}

#gl {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}

#gl:active {
  cursor: grabbing;
}

.stage-top,
.stage-bottom {
  position: absolute;
  left: 22px;
  right: 22px;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none; /* let drags through to the canvas */
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.stage-top {
  top: 20px;
}

.stage-bottom {
  bottom: 18px;
  align-items: center;
}

.stage-bottom button {
  pointer-events: auto;
  background: transparent;
  border: 0;
  color: var(--accent);
  padding: 4px;
}

/* DualSense / Xbox switch */
.pad-tabs {
  display: flex;
  gap: 6px;
  pointer-events: auto;
}

.pad-tabs button {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--overlay-soft);
  border: 1px solid var(--line-strong);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 10px;
  letter-spacing: 0.08em;
}

.pad-tabs i {
  width: 6px;
  height: 6px;
  background: var(--idle);
}

.pad-tabs .live i {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.pad-tabs .on {
  border-color: var(--accent);
  color: var(--accent);
}

.hint {
  position: absolute;
  left: 50%;
  bottom: 18%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  text-align: center;
  white-space: nowrap;
  background: var(--overlay);
  border: 1px solid var(--line-strong);
  padding: 15px 20px;
  pointer-events: none;
}

.hint strong {
  font-size: 14px;
  color: var(--accent);
}

.hint span {
  color: var(--muted);
}

.drag-tip {
  position: absolute;
  bottom: 65px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  pointer-events: none;
}

.hint.gone,
.drag-tip.gone {
  opacity: 0;
  visibility: hidden;
}

/* Shown instead of the model when WebGL or a model file is unavailable. */
.stage-message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  text-align: center;
  line-height: 1.6;
  color: var(--muted);
  pointer-events: none;
}

/* ---- telemetry strip ---- */

.telemetry {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  margin: 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.telemetry > div {
  padding: 15px 18px;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.telemetry > div:last-child {
  border: 0;
}

.telemetry dt {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
}

.telemetry dd {
  margin: 7px 0 0;
  color: var(--accent);
  font-size: clamp(15px, 2vw, 24px);
  font-weight: 500;
  letter-spacing: -0.05em;
  white-space: nowrap;
}

/* ---- viewer toolbar ---- */

.viewer-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 17px 20px;
  margin-top: auto;
}

.viewer-tools > span {
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  margin-left: 8px;
}

.viewer-tools label {
  margin-right: auto;
  white-space: nowrap;
}

.viewer-tools input {
  accent-color: var(--accent);
}

.swatches {
  display: flex;
  gap: 6px;
}

.swatches button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid #c5d8c8;
  background: var(--c);
}

.swatches button[aria-pressed='true'] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---- footer ---- */

.credit {
  margin: 0;
  padding: 14px 22px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  line-height: 1.6;
}

.credit a {
  color: var(--accent);
}

/* ---- responsive ---- */

@media (max-width: 1000px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .viewer {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    height: 55vh;
    min-height: 360px;
  }

  .top-center {
    display: none;
  }
}

@media (max-width: 650px) {
  .top {
    padding: 0 14px;
  }

  .brand {
    font-size: 17px;
  }

  .status {
    font-size: 10px;
  }

  .stage {
    height: 47vh;
    min-height: 310px;
  }

  .stage-top,
  .stage-bottom {
    left: 12px;
    right: 12px;
  }

  .stage-title {
    display: none;
  }

  .hint {
    white-space: normal;
    width: 80%;
  }

  .telemetry {
    grid-template-columns: repeat(3, 1fr);
  }

  .telemetry > div {
    padding: 11px 12px;
    border-bottom: 1px solid var(--line);
  }

  .viewer-tools {
    padding: 12px;
  }
}

/* Crawlable help below the interactive tester. */
.search-guide {
  padding: 42px clamp(20px, 4vw, 64px);
  border-top: 1px solid var(--line);
  background: var(--panel);
}
.search-guide-intro {
  max-width: 720px;
}
.guide-kicker {
  color: var(--accent);
  letter-spacing: 0.12em;
  font-size: 10px;
}
.search-guide h2 {
  margin: 12px 0;
  font-size: clamp(20px, 2.5vw, 30px);
  letter-spacing: -0.04em;
}
.search-guide h3 {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
}
.search-guide p {
  color: var(--muted);
  line-height: 1.7;
}
.guide-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  margin-top: 32px;
}
.guide-grid > div {
  border-top: 1px solid var(--line-strong);
  padding-top: 20px;
}
.guide-faq {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 18px;
}
.guide-faq summary {
  cursor: pointer;
  color: var(--text);
}
.guide-faq p {
  max-width: 720px;
}
@media (max-width: 650px) {
  .guide-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}
