/* ============================================
   ReadVenture Canvas Editor
   Canvas editor, Art style modal, Background drawer
   ============================================ */

/* ── Canvas Editor Container ── */
#editorViewport {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg-editor);
}

.editor-toolbar {
  position: absolute;
  top: 12px; left: 12px; right: 12px;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
}

.editor-tools-left {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.editor-tools-right {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.tool-btn {
  width: 36px; height: 36px;
  border-radius: var(--radius-md);
  background: var(--white-92);
  border: 1px solid var(--border-wall);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-16);
  cursor: pointer;
  color: var(--text-dark-bg);
  transition: all var(--anim-normal);
  box-shadow: var(--shadow-sm);
}
.tool-btn:hover {
  background: #fff;
}
.tool-btn.active {
  background: var(--purple-light);
  color: #fff;
  border-color: var(--purple);
}

.tool-btn--accent {
  background: var(--purple-12);
  color: var(--purple);
  border-color: var(--border-purple-25);
}

/* ── Canvas Layer ── */
.canvas-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#editorCanvas {
  display: block;
  cursor: crosshair;
  box-shadow: var(--shadow-xl);
  border-radius: var(--space-xs);
}

/* ── Color Picker ── */
.color-row {
  display: flex;
  gap: 6px;
}

.color-swatch {
  width: 28px; height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--anim-normal);
}
.color-swatch.selected {
  border-color: var(--text-dark-bg);
  box-shadow: 0 0 0 2px var(--purple-light);
}

/* ── Size Slider ── */
.size-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--glass-20);
  border-radius: var(--space-xs);
  outline: none;
}

.size-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  border-radius: var(--radius-full);
  background: var(--purple);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

/* ── Save Modal ── */
.save-confirm {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--card-dark);
  border-radius: var(--radius-2xl);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  box-shadow: var(--shadow-xl);
  z-index: 15;
  color: var(--text-primary);
  font-size: var(--text-14);
  font-weight: 600;
}

/* ── Art Style Modal ── */
#artStyleModal {
  position: absolute;
  inset: 0;
  z-index: 330;
  background: var(--grad-overlay);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transform: translateY(100%);
  transition: transform var(--anim-overlay) var(--ease-smooth);
  display: flex;
  flex-direction: column;
}
#artStyleModal.show {
  transform: translateY(0);
}

.style-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-md);
  padding: var(--space-xl);
}

.style-card {
  background: var(--card-dark);
  border-radius: var(--radius-5xl);
  padding: var(--space-lg);
  text-align: center;
  border: 2px solid var(--border-10);
  cursor: pointer;
  transition: border-color var(--anim-normal), transform var(--anim-normal);
}
.style-card:active {
  transform: scale(0.97);
}
.style-card.selected {
  border-color: var(--purple);
}

.style-card-icon {
  font-size: var(--text-40);
  margin-bottom: var(--space-sm);
}

.style-card-title {
  font-weight: 700;
  font-size: var(--text-15);
  color: var(--text-primary);
  margin-bottom: 4px;
}

.style-card-desc {
  font-size: var(--text-12);
  color: var(--text-muted);
}

/* Style preview thumbs */
.style-preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: var(--space-xl);
}

.style-preview-item {
  aspect-ratio: 1;
  border-radius: var(--radius-xl);
  background: var(--card-dark);
  border: 2px solid var(--border-10);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--anim-normal);
}
.style-preview-item img {
  width: 100%; height: 100%;
  object-fit: cover;
}
.style-preview-item.selected {
  border-color: var(--purple);
}

/* Generate btn */
.generate-btn {
  padding: 14px;
  margin: var(--space-lg) var(--space-xl);
  border-radius: var(--radius-pill);
  background: var(--grad-ai);
  font-size: var(--text-16);
  font-weight: 700;
  color: var(--text-primary);
  box-shadow: var(--shadow-cyan);
}

/*── Background Drawer ── */
#bgDrawer {
  min-height: 50vh;
}

.bg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
  padding: var(--space-md) 0;
}

.bg-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: var(--card-dark);
  border: 2px solid var(--border-10);
  cursor: pointer;
  transition: border-color var(--anim-normal);
}
.bg-thumb.selected {
  border-color: var(--purple);
}
.bg-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.bg-generate-btn {
  display: block;
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-pill);
  background: var(--grad-bg-gen);
  font-size: var(--text-15);
  font-weight: 700;
  color: var(--text-primary);
  margin-top: var(--space-md);
  border: none;
  cursor: pointer;
}

.bg-prompt-input {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius-2xl);
  background: var(--card-dark);
  border: 1px solid var(--border-15);
  color: var(--text-primary);
  font-size: var(--text-14);
  margin-top: var(--space-md);
}
