/* ============================================
   Simple Color Picker - Modern Dark Theme
   ============================================ */

:root {
  /* Base colors */
  --bg-deep: #0a0a0c;
  --bg-surface: #111114;
  --bg-elevated: #18181c;

  /* Metal colors */
  --metal-dark: #1a1a1e;
  --metal-mid: #2a2a30;
  --metal-light: #3a3a42;
  --metal-highlight: #4a4a55;

  /* Accent - Warm coral */
  --accent-primary: #ff6b4a;
  --accent-bright: #ff8a6e;
  --accent-glow: rgba(255, 107, 74, 0.4);
  --accent-dim: #cc5538;

  /* Text */
  --text-primary: #e8e8ec;
  --text-secondary: #8a8a96;
  --text-muted: #5a5a66;

  /* Fonts */
  --font-display: 'Instrument Sans', -apple-system, sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* Shadows */
  --shadow-deep: 0 20px 60px rgba(0, 0, 0, 0.8);
}

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

html {
  font-size: 16px;
}

body {
  font-family: var(--font-display);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Texture overlay for depth */
.texture-overlay {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  opacity: 0.03;
  pointer-events: none;
  z-index: 1000;
}

/* Ambient glow effect */
.ambient-glow {
  position: fixed;
  top: 30%;
  left: 50%;
  transform: translateX(-50%);
  width: 600px;
  height: 400px;
  background: radial-gradient(ellipse, var(--accent-glow) 0%, transparent 70%);
  opacity: 0.15;
  pointer-events: none;
  z-index: 0;
}

/* Header */
.header {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.back-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.2s;
}

.back-link:hover {
  color: var(--accent-primary);
}

.back-link svg {
  transition: transform 0.2s;
}

.back-link:hover svg {
  transform: translateX(-3px);
}

.header-title {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-title h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 10px;
  background: rgba(255, 107, 74, 0.1);
  color: var(--accent-primary);
  border-radius: 4px;
  border: 1px solid rgba(255, 107, 74, 0.2);
}

/* Main */
.main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 24px 100px;
}

/* Demo Section */
.demo-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
  margin-bottom: 80px;
}

/* Color Picker Container */
.picker-container {
  width: 100%;
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* SV Canvas */
.sv-canvas-wrapper {
  position: relative;
  width: 100%;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: crosshair;
}

.sv-canvas-wrapper canvas {
  display: block;
  width: 100%;
  height: 200px;
}

.sv-cursor {
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid #fff;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.4);
  transition: border-color 0.15s;
}

.sv-canvas-wrapper.dragging {
  cursor: none;
}

/* Hue Slider */
.hue-slider-wrapper {
  position: relative;
}

.hue-slider-wrapper label {
  display: block;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.hue-slider {
  position: relative;
  width: 100%;
  height: 20px;
  border-radius: 10px;
  background: linear-gradient(
    to right,
    hsl(0, 100%, 50%),
    hsl(60, 100%, 50%),
    hsl(120, 100%, 50%),
    hsl(180, 100%, 50%),
    hsl(240, 100%, 50%),
    hsl(300, 100%, 50%),
    hsl(360, 100%, 50%)
  );
  cursor: pointer;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hue-handle {
  position: absolute;
  top: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid #fff;
  transform: translate(-50%, -50%);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.3),
    0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  transition: transform 0.1s;
}

.hue-slider.dragging .hue-handle {
  transform: translate(-50%, -50%) scale(1.15);
}

/* Preview */
.preview-section {
  display: flex;
  align-items: center;
  gap: 20px;
}

.preview-swatch {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    0 4px 16px rgba(0, 0, 0, 0.4),
    inset 0 1px 1px rgba(255, 255, 255, 0.05);
  flex-shrink: 0;
}

.preview-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hex-row input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 12px;
  letter-spacing: 0.05em;
  outline: none;
  transition: border-color 0.2s;
}

.hex-row input:focus {
  border-color: var(--accent-primary);
}

.copy-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 10px 16px;
  background: rgba(255, 107, 74, 0.1);
  color: var(--accent-primary);
  border: 1px solid rgba(255, 107, 74, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.copy-btn:hover {
  background: rgba(255, 107, 74, 0.2);
  border-color: var(--accent-primary);
}

.copy-btn.copied {
  background: rgba(57, 255, 20, 0.15);
  color: #39ff14;
  border-color: rgba(57, 255, 20, 0.3);
}

/* Input Groups */
.input-groups {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.input-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.input-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-field {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.input-field label {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 400;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.input-field input {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  padding: 8px 10px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s;
}

.input-field input:focus {
  border-color: var(--accent-primary);
}

/* Prevent spinner on number inputs */
.input-field input[type="number"]::-webkit-outer-spin-button,
.input-field input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.input-field input[type="number"] {
  -moz-appearance: textfield;
}

/* Control Info */
.control-info {
  display: flex;
  gap: 32px;
  padding: 16px 24px;
  background: var(--bg-elevated);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.04);
}

.control-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
}

kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 8px;
  background: var(--bg-surface);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: var(--text-primary);
}

/* ─────────────────────────────────────────────────────────
   Responsive
   ───────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .header {
    flex-direction: column;
    gap: 16px;
    padding: 16px 20px;
    text-align: center;
  }

  .header-title {
    order: -1;
  }

  .main {
    padding: 40px 20px 80px;
  }

  .picker-container {
    max-width: 100%;
  }

  .control-info {
    flex-direction: column;
    gap: 12px;
    width: 100%;
    max-width: 400px;
  }

  .control-hint {
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .header {
    padding: 14px 16px;
    gap: 12px;
  }

  .header-title h1 {
    font-size: 18px;
  }

  .tag {
    font-size: 9px;
    padding: 3px 8px;
  }

  .back-link {
    font-size: 13px;
  }

  .main {
    padding: 32px 16px 60px;
  }

  .demo-section {
    gap: 24px;
    margin-bottom: 60px;
  }

  .preview-swatch {
    width: 52px;
    height: 52px;
  }

  .hex-row input {
    font-size: 15px;
    padding: 6px 10px;
  }

  .copy-btn {
    padding: 8px 12px;
    font-size: 10px;
  }

  .input-field input {
    font-size: 13px;
    padding: 6px 8px;
  }

  .control-info {
    padding: 14px 20px;
    gap: 10px;
  }

  .control-hint {
    font-size: 12px;
  }

  kbd {
    font-size: 10px;
    padding: 3px 6px;
  }
}

@media (max-width: 375px) {
  .header {
    padding: 12px 14px;
  }

  .header-title h1 {
    font-size: 16px;
  }

  .main {
    padding: 24px 14px 50px;
  }

  .preview-section {
    flex-direction: column;
    align-items: stretch;
  }

  .preview-swatch {
    width: 100%;
    height: 48px;
  }

  .ambient-glow {
    width: 300px;
    height: 200px;
  }

  .control-info {
    padding: 12px 16px;
    border-radius: 10px;
  }

  .control-hint {
    font-size: 11px;
    gap: 6px;
  }

  kbd {
    font-size: 9px;
    padding: 2px 5px;
  }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
  .sv-canvas-wrapper canvas {
    min-height: 180px;
  }

  .hue-slider {
    height: 28px;
    border-radius: 14px;
  }

  .hue-handle {
    width: 32px;
    height: 32px;
  }
}
