/* Copyright 2026 Brandon Anderson
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

:root {
  --bg: #141414;
  --surface: #1e1e1e;
  --border: #333;
  --text: #e0e0e0;
  --muted: #888;
  --accent: #5b9bd5;
  --font: system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
}

header {
  padding: 1rem 1.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

header h1 {
  font-size: 1.15rem;
  font-weight: 600;
  color: #fff;
  margin-bottom: 0.25rem;
}

.subtitle {
  font-size: 0.8rem;
  color: var(--muted);
  max-width: 70ch;
}

main {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1rem;
  padding: 1rem 1.5rem;
  align-items: start;
}

@media (max-width: 780px) {
  main { grid-template-columns: 1fr; }
}

/* Left column: canvas + plot */
.left-col {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.canvas-wrap {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

canvas#canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  image-rendering: pixelated;
  background: #000;
}

.frame-label {
  font-family: monospace;
  font-size: 0.9rem;
  color: var(--accent);
  margin-top: 0.3rem;
  letter-spacing: 0.03em;
}

.loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  font-size: 0.85rem;
  pointer-events: none;
}

.hidden { display: none !important; }

.plot-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

canvas#plot-canvas {
  display: block;
  max-width: 100%;
  border: 1px solid var(--border);
  background: #111;
}

.plot-caption {
  font-size: 0.72rem;
  color: var(--muted);
}

/* Controls panel */
.controls {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.6rem 0.75rem 0.75rem;
  background: var(--surface);
}

legend {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0 0.3rem;
}

.row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.row label {
  min-width: 90px;
  font-size: 0.82rem;
  color: var(--muted);
  flex-shrink: 0;
}

.row input[type="range"] {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.row select {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0.2rem 0.4rem;
  font-size: 0.82rem;
}

.val {
  font-size: 0.78rem;
  font-family: monospace;
  color: var(--accent);
  min-width: 3.8ch;
  text-align: right;
  flex-shrink: 0;
}

.hint {
  font-size: 0.72rem;
  color: var(--muted);
  margin-top: 0.4rem;
  line-height: 1.4;
}

.btn-row {
  display: flex;
  gap: 0.4rem;
  margin-top: 0.6rem;
}

button {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}

button:hover:not(:disabled) {
  background: #2a2a2a;
  border-color: var(--accent);
}

button:disabled {
  opacity: 0.35;
  cursor: default;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 32px;
  height: 18px;
  flex-shrink: 0;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 18px;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-track::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  left: 3px;
  top: 3px;
  background: var(--muted);
  border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}

.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track::after {
  transform: translateX(14px);
  background: #fff;
}

.upload-row input[type="file"] {
  flex: 1;
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 0;
}

.explainer {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.75rem;
}

.explainer h2 {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.explainer p {
  font-size: 0.8rem;
  color: #bbb;
  margin-bottom: 0.5rem;
  line-height: 1.5;
}

.explainer p:last-child { margin-bottom: 0; }

.caveat {
  font-size: 0.72rem !important;
  color: var(--muted) !important;
  font-style: italic;
}
