/* debug panel — hotkey ` toggles. Glassmorphism to match scene language. */

.debug {
  position: fixed;
  top: 80px;
  right: 84px;
  z-index: 100;
  width: 300px;
  max-height: calc(100vh - 160px);
  padding: 18px;
  border-radius: 16px;
  background: linear-gradient(155deg, rgba(20, 30, 24, 0.7), rgba(20, 30, 24, 0.55));
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid rgba(255, 255, 255, 0.4);
  box-shadow:
    0 24px 56px rgba(6, 16, 10, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.35);
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  overflow-y: auto;
  overflow-x: hidden;
  transform: translateX(calc(100% + 100px));
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.25s ease;
}
.debug.is-open {
  transform: translateX(0);
  opacity: 1;
}
.debug::-webkit-scrollbar { width: 4px; }
.debug::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 2px; }

.debug__title {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.debug__hotkey {
  font-size: 9px;
  opacity: 0.5;
  padding: 2px 5px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 3px;
}

/* Editing-attribution badge — sits between title and body, communicates
   which section any un-namespaced edit is currently writing to. */
.debug__active-badge {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  margin: 0 0 14px 0;
  border-radius: 9px;
  background: rgba(159, 227, 180, 0.12);
  border: 1px solid rgba(159, 227, 180, 0.28);
}
.debug__active-label {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(159, 227, 180, 0.65);
}
.debug__active-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #9fe3b4;
  font-family: 'Space Grotesk', system-ui, sans-serif;
}
.debug__active-mode {
  font-size: 9px;
  letter-spacing: 0.06em;
  color: rgba(244, 243, 236, 0.55);
}
.debug__active-mode.is-manual {
  color: rgba(255, 180, 120, 0.75);
}

.debug__section {
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.debug__section:last-child { border-bottom: 0; }

.debug__section-title {
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label);
  opacity: 0.75;
  margin-bottom: 10px;
}

.debug__row {
  margin-bottom: 10px;
}
.debug__label {
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.debug__label b { color: var(--fg); font-weight: 500; }
.debug__range {
  width: 100%;
  accent-color: var(--fg);
  cursor: pointer;
}

.debug__toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  margin-bottom: 6px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--fg);
}
.debug__toggle input { accent-color: var(--accent); }

.debug__presets {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin-top: 4px;
}
.debug__preset {
  padding: 7px 4px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 0.15s ease;
}
.debug__preset:hover { background: rgba(255, 255, 255, 0.12); }
.debug__preset.is-active {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.debug__select {
  width: 100%;
  padding: 4px 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  cursor: pointer;
  text-transform: capitalize;
}
.debug__select option { background: #1a2a1f; color: var(--fg); }

.debug__swatch {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  vertical-align: middle;
  margin-left: 6px;
}

/* ---- Sections subsection ---- */

.debug__section-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.debug__section-row {
  display: grid;
  grid-template-columns: 12px 1fr auto auto auto auto;
  align-items: center;
  gap: 5px;
  padding: 4px 4px;
  border-radius: 5px;
  transition: background 0.12s ease;
}
.debug__section-row.is-active {
  outline: 1px solid rgba(159, 227, 180, 0.4);
}

.debug__section-badges {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.debug__section-badges .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.35);
}
.dot--rig     { background: #9fe3b4; border-color: #9fe3b4; }
.dot--webgl   { background: #7bc7f0; border-color: #7bc7f0; }
.dot--objects { background: #f0c56b; border-color: #f0c56b; }
.dot--layout  { background: #d494f0; border-color: #d494f0; }

.debug__section-legend {
  display: flex;
  gap: 10px;
  padding-top: 8px;
  margin-top: 6px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 9px;
  color: rgba(244, 243, 236, 0.5);
  letter-spacing: 0.06em;
}
.debug__section-legend span {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.debug__section-legend .dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.debug__mini--danger {
  border-color: rgba(220, 100, 100, 0.35);
  color: rgba(255, 190, 180, 0.85);
}
.debug__mini--danger:hover {
  background: rgba(220, 100, 100, 0.15);
}
.debug__section-row.is-active { background: rgba(255, 255, 255, 0.06); }
.debug__section-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: background 0.15s ease;
}
.debug__section-row.is-saved .debug__section-dot {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 6px var(--accent);
}
.debug__section-name {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  color: var(--fg);
  letter-spacing: 0.06em;
}
.debug__section-row.is-active .debug__section-name { color: var(--accent); }

.debug__mini {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  padding: 3px 7px;
  border-radius: 4px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--fg);
  cursor: pointer;
  letter-spacing: 0.06em;
  transition: background 0.12s ease;
}
.debug__mini:hover { background: rgba(255, 255, 255, 0.14); }

/* ---- JSON subsection ---- */

.debug__json-btn {
  width: 100%;
  margin-bottom: 5px;
}
.debug__json-btn--danger {
  border-color: rgba(220, 100, 100, 0.4);
  color: rgba(255, 190, 180, 0.9);
}
.debug__json-btn--danger:hover {
  background: rgba(220, 100, 100, 0.15);
}
.debug__json-status {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: var(--accent);
  min-height: 12px;
  margin-top: 4px;
  letter-spacing: 0.06em;
  text-align: center;
}
.debug__json-status.is-error { color: rgb(255, 150, 140); }

/* ---- Import assets (Phase B) ---- */
.debug__dropzone {
  display: block;
  padding: 12px 8px;
  border: 1.5px dashed rgba(255, 255, 255, 0.32);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: rgba(246, 246, 236, 0.7);
  text-align: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
  transition: background 0.15s ease, border-color 0.15s ease;
  cursor: default;
}
.debug__dropzone small { display: block; opacity: 0.6; margin-top: 2px; font-size: 9px; }
.debug__dropzone.is-drag-over {
  border-color: var(--accent);
  background: rgba(159, 227, 180, 0.08);
  color: var(--accent);
}
.debug__import-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 6px;
  max-height: 180px;
  overflow-y: auto;
}
.debug__import-empty {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.35);
  text-align: center;
  padding: 6px 0;
}
.debug__import-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
}
.debug__import-name {
  flex: 1;
  color: var(--fg);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.debug__import-size {
  color: var(--muted);
  font-size: 9px;
}

/* ---- Assets subsection ---- */

.debug__assets {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
  max-height: 320px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}
.debug__assets::-webkit-scrollbar { width: 3px; }
.debug__assets::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.15); border-radius: 2px; }

.debug__asset-row {
  padding: 5px 6px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
}
.debug__asset-row[data-status="failed"] { border-color: rgba(255, 100, 100, 0.4); }
.debug__asset-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.debug__asset-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 200, 90, 0.7); /* pending yellow */
  flex-shrink: 0;
}
.debug__asset-row[data-status="ready"]  .debug__asset-dot { background: var(--accent); box-shadow: 0 0 4px var(--accent); }
.debug__asset-row[data-status="failed"] .debug__asset-dot { background: rgb(255, 100, 100); }
.debug__asset-name {
  flex: 1;
  color: var(--fg);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.debug__asset-body {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 4px;
  align-items: center;
  font-size: 9px;
}
.debug__asset-body label { display: flex; align-items: center; gap: 4px; color: var(--muted); }
.debug__asset-body label input[type="range"] { width: 100%; accent-color: var(--fg); }
.debug__asset-body b { color: var(--fg); font-weight: 500; min-width: 14px; text-align: right; }
.debug__asset-body select {
  grid-column: 1 / -1;
  background: rgba(255, 255, 255, 0.06);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 4px;
  font-family: inherit;
  font-size: 9px;
}
.debug__toggle--tight { font-size: 9px !important; margin: 0 !important; }
.debug__toggle--tight input { transform: scale(0.85); }

.debug__subsection-title {
  font-family: 'JetBrains Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 10px 0 6px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.08);
}
