/* ============================================================
   ColorCube — Gradient Builder page styles
   ============================================================ */

/* ── Page layout ─────────────────────────────────────────────── */
.gb-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 720px) {
  .gb-layout { grid-template-columns: 1fr; }
}

/* ── Preview ─────────────────────────────────────────────────── */
.gb-preview-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-l);
  overflow: hidden;
  aspect-ratio: 1;
  position: relative;
}
canvas#gb-preview {
  width: 100%;
  height: 100%;
  display: block;
}

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

/* Type tabs */
.gb-tabs {
  display: flex;
  gap: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.25rem;
}
.gb-tab {
  flex: 1;
  padding: 0.4rem 0.5rem;
  background: none;
  border: none;
  border-radius: calc(var(--radius) - 2px);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.gb-tab.active {
  background: var(--surface2);
  color: var(--white);
}
.gb-tab:hover:not(.active) { color: var(--text); }

/* Control block */
.gb-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
}
.gb-block-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.6rem;
}

/* Angle / position */
.gb-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.gb-row:last-child { margin-bottom: 0; }
.gb-row label {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 2.5rem;
}
.gb-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--surface2);
  outline: none;
  cursor: pointer;
}
.gb-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
}
.gb-row input[type=range]::-moz-range-thumb {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
  cursor: pointer;
}
.gb-row .gb-val {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--white);
  width: 2.5rem;
  text-align: right;
  flex-shrink: 0;
}

/* ── Export size control ─────────────────────────────────────── */
.gb-size-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}
.gb-size-row:last-child { margin-bottom: 0; }
.gb-size-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
  width: 1.5rem;
}
.gb-size-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.3rem 0.5rem;
  outline: none;
  min-width: 0;
  transition: border-color 0.15s;
}
.gb-size-input:focus { border-color: var(--text-muted); }
.gb-size-unit {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.gb-lock-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: border-color 0.15s, color 0.15s;
  white-space: nowrap;
}
.gb-lock-btn.locked {
  border-color: var(--accent-b);
  color: var(--accent-b);
}
.gb-lock-btn:hover { border-color: var(--text-muted); color: var(--text); }

/* Colour stops */
.gb-stops {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.gb-stop-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: grab;
  transition: border-color 0.15s;
}
.gb-stop-row:hover { border-color: var(--text-muted); }
.gb-stop-row.dragging { opacity: 0.5; cursor: grabbing; }
.gb-stop-swatch {
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 3px;
  border: 1px solid rgba(255,255,255,0.15);
  cursor: pointer;
  flex-shrink: 0;
}
.gb-stop-pos {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex: 1;
}
.gb-stop-hex {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--white);
}
.gb-stop-del {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 0.15rem;
  line-height: 1;
  flex-shrink: 0;
}
.gb-stop-del:hover { color: var(--accent-r); }

/* Stop editor popup */
.gb-stop-editor {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  display: none;
  flex-direction: column;
  gap: 0.5rem;
}
.gb-stop-editor.open { display: flex; }
.gb-stop-editor input[type=color] {
  width: 100%;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  background: none;
  padding: 0;
}
.gb-stop-editor-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.gb-stop-editor-row label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-shrink: 0;
}
.gb-stop-editor-row input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  cursor: pointer;
}
.gb-stop-editor-row input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--white);
  border: 2px solid var(--border);
}
.gb-stop-editor-row .gb-val {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--white);
  width: 2.5rem;
  text-align: right;
}

/* Add stop */
.gb-add-stop {
  background: none;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.78rem;
  padding: 0.4rem;
  cursor: pointer;
  width: 100%;
  transition: border-color 0.15s, color 0.15s;
}
.gb-add-stop:hover { border-color: var(--text); color: var(--text); }

/* Mesh corners */
.gb-mesh-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}
.gb-mesh-cell {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  align-items: center;
}
.gb-mesh-cell label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
}
.gb-mesh-cell input[type=color] {
  width: 100%;
  height: 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  background: none;
  padding: 0;
}

/* Export */
.gb-export-buttons {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.gb-export-btn {
  flex: 1;
  min-width: 80px;
  padding: 0.5rem 0.75rem;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.gb-export-btn:hover { border-color: var(--text-muted); color: var(--white); }

/* CSS output */
.gb-css-out {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--accent-c);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  word-break: break-all;
  white-space: pre-wrap;
  line-height: 1.5;
  cursor: pointer;
  user-select: all;
}
.gb-css-out:active { opacity: 0.7; }

/* Copy toast */
.gb-toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--white);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 200;
}
.gb-toast.show { opacity: 1; }
