/* ddreams POV-GPU — dark IDE layout */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --background0: #0d0d10;
  --background1: #141417;
  --background2: #1c1c21;
  --background3: #26262d;
  --background4: #30303a;
  --accent1: #7c6aff;
  --accent2: #a295ff;
  --accent3: #6651ff;
  --accent4: #4ecdc4;
  --text0: #e8e8f0;
  --text1: #a0a0b0;
  --text2: #60607a;
  --colorRed: #ff5555;
  --colorGreen: #55ff88;
  --borderRadius: 6px;
  --fontMono: "Cascadia Code", "Fira Code", "JetBrains Mono", "Source Code Pro", monospace;
  --fontUi: system-ui, -apple-system, "Segoe UI", sans-serif;
}

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--background0);
  color: var(--text0);
  font-family: var(--fontUi);
}

/* ── App shell ─────────────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

/* ── Header ────────────────────────────────────────────────────────── */
header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  height: 48px;
  background: var(--background1);
  border-bottom: 1px solid var(--background3);
  flex-shrink: 0;
  z-index: 10;
}

.headerTitle {
  font-size: 16px;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: var(--accent2);
  display: flex;
  align-items: center;
  gap: 8px;
}

.headerSeparator {
  width: 1px;
  height: 24px;
  background: var(--background4);
}

.controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Buttons */
.button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border: 1px solid var(--background4);
  border-radius: var(--borderRadius);
  background: var(--background3);
  color: var(--text0);
  font-size: 12px;
  font-family: var(--fontUi);
  cursor: pointer;
  transition:
    background-color 0.15s,
    border-color 0.15s;
  user-select: none;
}

.button:hover {
  background: var(--background4);
  border-color: var(--accent1);
}

.button:active {
  background: var(--accent1);
  color: #fff;
}

.button.primary {
  background: var(--accent1);
  border-color: var(--accent2);
  color: #fff;
}

.button.primary:hover {
  background: var(--accent3);
}

/* Selects */
.controlSelect {
  appearance: none;
  padding: 4px 24px 4px 8px;
  background: var(--background3)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23a0a0b0'/%3E%3C/svg%3E")
    no-repeat right 8px center;
  border: 1px solid var(--background4);
  border-radius: var(--borderRadius);
  color: var(--text0);
  font-size: 12px;
  font-family: var(--fontUi);
  cursor: pointer;
}
.controlSelect:focus {
  outline: none;
  border-color: var(--accent1);
}

/* Labels */
.controlLabel {
  font-size: 11px;
  color: var(--text1);
  white-space: nowrap;
}

/* Checkboxes */
.controlCheck {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text1);
  cursor: pointer;
  user-select: none;
}
.controlCheck input[type="checkbox"] {
  accent-color: var(--accent1);
}

/* Statistics */
.statistics {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text2);
  font-family: var(--fontMono);
}
.statisticValue {
  color: var(--accent4);
}

/* ── Main split pane ────────────────────────────────────────────────── */
#splitLayout {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Editor pane */
#editorPane {
  display: flex;
  flex-direction: column;
  width: 380px;
  min-width: 150px;
  max-width: 75vw;
  background: var(--background1);
  flex-shrink: 0;
}

/* Split resize handle */
#splitHandle {
  width: 5px;
  background: var(--background3);
  cursor: col-resize;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  z-index: 5;
  transition:
    background 0.15s,
    width 0.1s;
  user-select: none;
}
#splitHandle:hover,
#splitHandle.dragging {
  background: var(--accent1);
  width: 6px;
}
.handleIcon {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.15s;
}
.handleGrip {
  opacity: 1;
  color: var(--text2);
}
.handleArrow {
  opacity: 0;
  color: #fff;
}
#splitHandle:hover .handleGrip,
#splitHandle.dragging .handleGrip {
  opacity: 0;
}
#splitHandle:hover .handleArrow,
#splitHandle.dragging .handleArrow {
  opacity: 1;
}

.paneTitle {
  padding: 6px 12px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--text2);
  background: var(--background1);
  border-bottom: 1px solid var(--background3);
  flex-shrink: 0;
}

#editorContainer {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
  background: var(--background1);
}

/* Shared layout — must match exactly so the caret aligns with highlighted text */
#editorHighlight,
#sceneEditor {
  position: absolute;
  inset: 0;
  margin: 0;
  border: none;
  outline: none;
  font-family: var(--fontMono);
  font-size: 12.5px;
  line-height: 1.65;
  padding: 12px 14px;
  tab-size: 2;
  white-space: pre;
  word-wrap: normal;
  letter-spacing: normal;
  word-spacing: normal;
}

#editorHighlight {
  overflow: hidden;
  pointer-events: none;
  color: var(--text0);
  background: transparent;
  z-index: 1;
}

#sceneEditor {
  overflow: auto;
  color: transparent;
  background: transparent;
  caret-color: var(--accent4);
  resize: none;
  z-index: 2;
}

#sceneEditor::placeholder {
  color: var(--text2);
}

/* Syntax token colours */
.ec-comment   { color: #60607a; font-style: italic; }
.ec-string    { color: #82c884; }
.ec-directive { color: #a295ff; font-weight: 600; }
.ec-shape     { color: #7c6aff; }
.ec-modifier  { color: #b8acff; }
.ec-transform { color: #b8acff; }
.ec-prop      { color: #7ab8d4; }
.ec-pattern   { color: #4ecdc4; }
.ec-number    { color: #d4a040; }
.ec-angle     { color: #a0a0b0; }
.ec-op        { color: #a0a0b0; }

/* Canvas pane */
#canvasPane {
  flex: 1;
  min-width: 0;
  background: var(--background0);
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

#renderCanvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}

/* ── Status bar ────────────────────────────────────────────────────── */
#statusBar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  height: 26px;
  background: var(--background1);
  border-top: 1px solid var(--background3);
  font-size: 11px;
  font-family: var(--fontMono);
  color: var(--text2);
  flex-shrink: 0;
}

#statusMessage {
  flex: 1;
  color: var(--text1);
}

/* ── Error panel ────────────────────────────────────────────────────── */
#errorPanel {
  position: absolute;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e0a0a;
  border: 1px solid var(--colorRed);
  border-radius: var(--borderRadius);
  padding: 10px 14px;
  color: var(--colorRed);
  font-family: var(--fontMono);
  font-size: 12px;
  max-width: 90%;
  white-space: pre-wrap;
  z-index: 100;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.7);
}

/* ── Overlay (no WebGPU) ────────────────────────────────────────────── */
#noWebGpu {
  display: none;
  position: absolute;
  inset: 0;
  background: var(--background0);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  z-index: 50;
}
#noWebGpu.show {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#noWebGpu h2 {
  font-size: 20px;
  color: var(--text0);
}
#noWebGpu p {
  font-size: 14px;
  color: var(--text1);
  max-width: 480px;
}

/* ── Scrollbar styling ──────────────────────────────────────────────── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: var(--background1);
}
::-webkit-scrollbar-thumb {
  background: var(--background4);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent1);
}

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  #splitLayout {
    flex-direction: column;
  }
  #editorPane {
    width: 100% !important;
    max-width: 100%;
    height: 40vh;
    border-bottom: 1px solid var(--background3);
  }
  #splitHandle {
    display: none;
  }
  #canvasPane {
    flex: 1;
  }
  .controls .controlLabel {
    display: none;
  }
}
