/* ========================================================================
   Color Lab — modern, kid-friendly, iPad-first
   ======================================================================== */

:root {
  /* Warm cream + ink palette: feels editorial, not childish, but soft */
  --bg-1:        #fef9f3;
  --bg-2:        #fbeee0;
  --card:        #ffffff;
  --card-edge:   rgba(20, 20, 30, 0.06);
  --ink:         #1a1a22;
  --ink-soft:    #4a4a55;
  --ink-mute:    #8b8b95;
  --line:        #ece5db;

  --accent:      #ff6b5e;   /* warm coral */
  --accent-2:    #4f8cff;   /* sky */
  --accent-3:    #ffc24b;   /* honey */

  --shadow-sm:   0 2px 6px rgba(20, 20, 30, 0.04),
                 0 8px 24px rgba(20, 20, 30, 0.06);
  --shadow-md:   0 4px 12px rgba(20, 20, 30, 0.06),
                 0 16px 48px rgba(20, 20, 30, 0.10);
  --shadow-pop:  0 12px 36px rgba(255, 107, 94, 0.32);

  --radius-sm:   14px;
  --radius:      22px;
  --radius-lg:   28px;

  --slot:        clamp(96px, 14vw, 132px);
  --tap:         56px;        /* min iPad tap target */

  --ease-pop:    cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-1);
  color: var(--ink);
  overflow-x: hidden;
  touch-action: manipulation;
  min-height: 100vh;
  /* Subtle grain + warm radial wash */
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 0%, rgba(255, 194, 75, 0.18), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(79, 140, 255, 0.10), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

#app {
  max-width: 980px;
  margin: 0 auto;
  padding: clamp(16px, 3vw, 36px);
  padding-bottom: 80px;
}

/* ---------------- Header ---------------- */
header {
  text-align: center;
  margin: 12px 0 28px;
}

header h1 {
  font-family: 'Fraunces', 'Times New Roman', serif;
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  letter-spacing: -0.02em;
  line-height: 1;
  margin: 0;
  background: linear-gradient(120deg, var(--ink) 0%, #5a3a8a 50%, var(--accent) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

header .tagline {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-size: clamp(0.95rem, 1.6vw, 1.1rem);
  font-weight: 500;
}

/* ---------------- Layout ---------------- */
main {
  display: grid;
  gap: clamp(16px, 2.4vw, 24px);
}

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 3vw, 32px);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-edge);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.section-head h2,
section h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.35rem);
  color: var(--ink);
  letter-spacing: -0.01em;
}

.muted {
  color: var(--ink-mute);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ---------------- Mixing area ---------------- */
.mixing-area { text-align: center; }

.bowl {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1.5vw, 18px);
  flex-wrap: nowrap;
  margin: 8px 0 24px;
}

.slot, .result {
  width: var(--slot);
  height: var(--slot);
  border-radius: 50%;
  background: #f4ede2;
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.05),
    inset 0 -2px 6px rgba(255, 255, 255, 0.8);
  transition: background-color 0.4s ease,
              transform 0.25s var(--ease-pop),
              box-shadow 0.25s ease;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.slot-hint {
  font-size: 0.72rem;
  color: var(--ink-mute);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  pointer-events: none;
  opacity: 0.6;
}

/* Hide the hint as soon as the slot has a real color filled in */
.slot[style*="background"]:not([style*="rgb(244, 237, 226)"]) .slot-hint,
.result[style*="background"]:not([style*="rgb(244, 237, 226)"]) .slot-hint {
  opacity: 0;
}

.slot.drag-over {
  transform: scale(1.1);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.05),
    0 0 0 4px var(--accent-2);
}

.op {
  font-family: 'Fraunces', serif;
  font-size: clamp(1.4rem, 2.6vw, 1.8rem);
  font-weight: 600;
  color: var(--ink-mute);
  user-select: none;
}

.result.mixed {
  animation: pop 0.55s var(--ease-pop);
}

@keyframes pop {
  0%   { transform: scale(0.6) rotate(-6deg); }
  60%  { transform: scale(1.18) rotate(3deg); }
  100% { transform: scale(1) rotate(0); }
}

/* ---------------- Ratio slider (big, iPad-friendly) ---------------- */
.ratio-row {
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 520px;
  margin: 0 auto 8px;
  padding: 0 4px;
}

.ratio-end {
  font-weight: 700;
  color: var(--ink-mute);
  font-size: 0.9rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 44px;             /* big tap zone */
  background: transparent;
  cursor: pointer;
  margin: 0;
  padding: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fde6c8, #fbcfe0, #d4e3ff);
  border: 1px solid var(--line);
}

input[type="range"]::-moz-range-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, #fde6c8, #fbcfe0, #d4e3ff);
  border: 1px solid var(--line);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  margin-top: -12px;
  transition: transform 0.15s var(--ease-pop);
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.15); }

input[type="range"]::-moz-range-thumb {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: transform 0.15s var(--ease-pop);
}

.ratio-meta {
  text-align: center;
  font-size: 0.85rem;
  color: var(--ink-mute);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  margin-bottom: 20px;
}

/* ---------------- Buttons ---------------- */
.actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0 28px;
  height: var(--tap);
  min-width: 120px;
  font-family: 'Inter', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s var(--ease-pop),
              box-shadow 0.2s ease,
              opacity 0.2s ease,
              background 0.2s ease;
  user-select: none;
}

.btn:active { transform: scale(0.96); }

.btn-icon {
  display: inline-flex;
  font-size: 1.1em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #ff8a4f 100%);
  color: #fff;
  box-shadow: var(--shadow-pop);
}
.btn-primary:hover  { box-shadow: 0 16px 44px rgba(255, 107, 94, 0.45); }
.btn-primary:disabled {
  background: #e8d5cf;
  color: #b8a09a;
  box-shadow: none;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border: 1.5px solid var(--line);
}
.btn-ghost:hover { background: rgba(20, 20, 30, 0.04); }

/* ---------------- Palette swatches ---------------- */
.color-list, .saved-list {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(14px, 2vw, 22px);
  justify-content: center;
}

.color-swatch {
  width: clamp(64px, 9vw, 88px);
  height: clamp(64px, 9vw, 88px);
  border-radius: 50%;
  cursor: grab;
  box-shadow:
    0 4px 14px rgba(0, 0, 0, 0.10),
    inset 0 -3px 10px rgba(0, 0, 0, 0.10),
    inset 0 3px 10px rgba(255, 255, 255, 0.30);
  transition: transform 0.18s var(--ease-pop),
              box-shadow 0.2s ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  user-select: none;
  position: relative;
  margin-bottom: 26px;       /* room for the label below */
  -webkit-touch-callout: none;
}

.color-swatch:hover  { transform: translateY(-3px) scale(1.04); }
.color-swatch:active { cursor: grabbing; transform: scale(0.94); }

.color-swatch .label {
  position: absolute;
  bottom: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0.01em;
}

.color-swatch.selected {
  outline: 4px solid var(--ink);
  outline-offset: 4px;
  transform: scale(1.06);
}

.saved-colors .color-swatch {
  width: clamp(52px, 7vw, 72px);
  height: clamp(52px, 7vw, 72px);
  margin-bottom: 22px;
}
.saved-colors .color-swatch .label {
  font-size: 0.7rem;
  bottom: -20px;
}

/* ---------------- Modal ---------------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.42);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 1;
  transition: opacity 0.25s ease;
  padding: 20px;
}

.modal.hidden { opacity: 0; pointer-events: none; }

.modal-content {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 32px 28px 24px;
  text-align: center;
  width: min(92vw, 380px);
  box-shadow: var(--shadow-md);
  transform: translateY(0) scale(1);
  transition: transform 0.35s var(--ease-pop);
}

.modal.hidden .modal-content {
  transform: translateY(20px) scale(0.96);
}

.modal-eyebrow {
  margin: 0 0 14px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-mute);
}

.preview-color {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  margin: 0 auto 16px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.16),
    inset 0 -4px 14px rgba(0, 0, 0, 0.10),
    inset 0 4px 14px rgba(255, 255, 255, 0.30);
  animation: preview-in 0.5s var(--ease-pop);
}

@keyframes preview-in {
  from { transform: scale(0.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

.preview-name {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 1.5rem;
  margin: 0 0 18px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.modal-content input {
  width: 100%;
  padding: 14px 16px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  font-size: 1rem;
  font-family: inherit;
  margin-bottom: 18px;
  outline: none;
  background: #fbf7f1;
  color: var(--ink);
  transition: border-color 0.2s, background 0.2s;
}

.modal-content input:focus {
  border-color: var(--accent);
  background: #fff;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.modal-buttons .btn { flex: 1; min-width: 0; }

/* ---------------- Particles ---------------- */
.particle {
  position: fixed;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  pointer-events: none;
  z-index: 50;
  box-shadow: 0 0 12px currentColor;
}

/* ---------------- iPad portrait & landscape tuning ---------------- */
@media (min-width: 768px) {
  main {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "mix mix"
      "palette saved";
  }
  #mixing-area  { grid-area: mix; }
  #palette      { grid-area: palette; }
  #saved-colors { grid-area: saved; }
}

/* ---------------- Phones ---------------- */
@media (max-width: 520px) {
  :root { --slot: 88px; }
  header h1 { font-size: 2.2rem; }
  .bowl { gap: 6px; }
  .op { font-size: 1.2rem; }
  .btn { min-width: 100px; padding: 0 22px; font-size: 1rem; }
}

/* ---------------- Reduce motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
