/* =========================================================
   Canvas Draw — Styles
   Design: Faber Castell meets Linear
   ========================================================= */

/* --- Reset & Base --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-family);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--color-background);
  color: var(--color-text);
  overflow: hidden;
}

/* --- Design Tokens --- */
:root {
  /* Colors */
  --color-primary: #1A1A1A;
  --color-secondary: #6B7280;
  --color-tertiary: #3B82F6;
  --color-tertiary-hover: #2563EB;
  --color-tertiary-active: #1D4ED8;
  --color-neutral: #FFFFFF;
  --color-background: #FFFFFF;
  --color-surface: #F9FAFB;
  --color-border: #E5E7EB;
  --color-text: #1A1A1A;
  --color-text-muted: #6B7280;
  --color-on-primary: #FFFFFF;
  --color-on-tertiary: #FFFFFF;

  /* Typography */
  --font-family: 'Inter', system-ui, sans-serif;
  --font-h1: 700 2rem/1.2 -0.02em;
  --font-h2: 600 1.25rem/1.3;
  --font-body-md: 400 0.9375rem/1.5;
  --font-body-sm: 400 0.8125rem/1.5;
  --font-label-caps: 600 0.6875rem/1.4 0.06em;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 40px;
  --space-2xl: 64px;

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  /* Transitions */
  --transition-fast: 120ms ease;
  --transition-base: 200ms ease;
}

/* --- Toolbar --- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 var(--space-md);
  background: var(--color-background);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.toolbar-brand {
  font: var(--font-h2);
  color: var(--color-text);
  font-weight: 600;
  flex-shrink: 0;
}

.toolbar-center {
  display: flex;
  align-items: center;
  gap: var(--space-md);
}

.toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;
}

/* --- Color Palette --- */
.color-palette {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  cursor: pointer;
  transition: var(--transition-fast);
  flex-shrink: 0;
  /* Reset button defaults */
  background: none;
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

.color-swatch:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.color-swatch.selected {
  background: var(--color-tertiary) !important;
  border-color: var(--color-tertiary);
  box-shadow: 0 0 0 2px var(--color-background), 0 0 0 4px var(--color-tertiary);
}

/* --- Toolbar Divider --- */
.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* --- Brush Size Control --- */
.brush-size-control {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.label-caps {
  font: var(--font-label-caps);
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.body-sm {
  font: var(--font-body-sm);
  color: var(--color-text-muted);
  white-space: nowrap;
}

.text-muted {
  color: var(--color-text-muted);
}

/* --- Slider --- */
.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 80px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  cursor: pointer;
  outline: none;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  background: var(--color-tertiary);
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
  margin-top: 0;
}

.slider::-webkit-slider-thumb:hover {
  background: var(--color-tertiary-hover);
}

.slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  background: var(--color-tertiary);
  border-radius: var(--radius-full);
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.slider::-moz-range-thumb:hover {
  background: var(--color-tertiary-hover);
}

/* --- Button Icon --- */
.button-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
  flex-shrink: 0;
  /* Reset button defaults */
  padding: 0;
  appearance: none;
  -webkit-appearance: none;
}

.button-icon:hover {
  background: var(--color-surface);
  color: var(--color-text);
}

.button-icon:active,
.button-icon.active {
  background: var(--color-surface);
  color: var(--color-tertiary);
}

/* --- Canvas Area --- */
.canvas-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  background: var(--color-surface);
  overflow: hidden;
  min-height: 0;
}

#draw-canvas {
  background: var(--color-neutral);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  cursor: crosshair;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  max-width: 100%;
  max-height: 100%;
  min-width: 320px;
  min-height: 320px;
}

/* --- Footer --- */
.footer {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-md);
  border-top: 1px solid var(--color-border);
  background: var(--color-background);
  flex-shrink: 0;
}

/* --- Focus Rings --- */
:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--color-tertiary);
  outline-offset: 2px;
}

/* --- Responsive: Mobile --- */
@media (max-width: 768px) {
  .toolbar {
    height: 44px;
    padding: 0 var(--space-sm);
    gap: var(--space-xs);
  }

  .toolbar-brand {
    font-size: 1rem;
  }

  .toolbar-center {
    gap: var(--space-sm);
  }

  .color-swatch {
    width: 24px;
    height: 24px;
  }

  .slider {
    width: 60px;
  }

  .canvas-area {
    padding: var(--space-sm);
  }

  #draw-canvas {
    min-width: 280px;
    min-height: 280px;
    border-radius: var(--radius-md);
  }

  .footer {
    height: 32px;
  }
}

@media (min-width: 769px) {
  #draw-canvas {
    min-width: 320px;
    min-height: 320px;
  }
}
