/* =========================================================
   ChromaMix — design tokens (house style)
   Light is default; dark overrides under [data-theme="dark"]
   ========================================================= */
:root {
  --font-outfit: 'Outfit', 'Inter', sans-serif;
  --font-inter: 'Inter', system-ui, sans-serif;

  --bg-primary: hsl(210, 40%, 98%);
  --bg-secondary: hsl(0, 0%, 100%);
  --bg-secondary-rgb: 255, 255, 255;
  --border-color: hsl(214, 32%, 91%);
  --text-primary: hsl(222, 47%, 11%);
  --text-secondary: hsl(215, 16%, 47%);

  --accent: hsl(217, 91%, 60%);
  --accent-hover: hsl(221, 83%, 53%);
  --accent-light: hsl(217, 91%, 95%);
  --accent-secondary: hsl(280, 78%, 62%);

  --success: hsl(142, 72%, 29%);
  --success-light: hsl(142, 72%, 95%);
  --error: hsl(0, 84%, 60%);
  --error-light: hsl(0, 84%, 95%);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .1), 0 2px 4px -1px rgba(0, 0, 0, .06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .1), 0 4px 6px -2px rgba(0, 0, 0, .05);

  --transition-fast: .15s ease;
  --transition-normal: .25s ease;

  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 20px;
  --border-radius-full: 9999px;
}

[data-theme="dark"] {
  --bg-primary: hsl(222, 47%, 6%);
  --bg-secondary: hsl(222, 47%, 10%);
  --bg-secondary-rgb: 15, 23, 42;
  --border-color: hsl(217, 32%, 18%);
  --text-primary: hsl(210, 40%, 98%);
  --text-secondary: hsl(215, 20%, 65%);

  --accent: hsl(217, 91%, 60%);
  --accent-hover: hsl(221, 83%, 53%);
  --accent-light: rgba(37, 99, 235, .18);
  --accent-secondary: hsl(280, 78%, 68%);

  --success: hsl(142, 69%, 58%);
  --success-light: rgba(22, 163, 74, .18);
  --error: hsl(0, 84%, 60%);
  --error-light: rgba(239, 68, 68, .18);

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, .3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .4), 0 2px 4px -1px rgba(0, 0, 0, .3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .5), 0 4px 6px -2px rgba(0, 0, 0, .4);
}

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

/* class-based display rules below would otherwise beat the UA [hidden] rule */
[hidden] { display: none !important; }

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-inter);
  font-size: 16px;
  line-height: 1.5;
  transition: background-color var(--transition-normal), color var(--transition-normal);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-outfit); font-weight: 700; line-height: 1.2; }
a { color: inherit; text-decoration: none; }
button, input { font-family: inherit; font-size: inherit; color: inherit; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.muted { color: var(--text-secondary); }
.small { font-size: .85rem; }
.row-between { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem 1.5rem;
  font-family: var(--font-outfit); font-weight: 600;
  border-radius: var(--border-radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}
.btn-sm { padding: .5rem 1rem; font-size: .875rem; }
.btn-primary { background-color: var(--accent); color: #fff; }
.btn-primary:hover { background-color: var(--accent-hover); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-secondary {
  background-color: var(--bg-secondary);
  border-color: var(--border-color);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}
.btn-secondary:hover { background-color: var(--bg-primary); border-color: var(--text-secondary); }
.btn:focus-visible, .segmented-btn:focus-visible, .lang-switcher button:focus-visible,
.swatch:focus-visible, .copy-chip:focus-visible, .pot:focus-visible, .step:focus-visible {
  outline: 3px solid var(--accent-light);
  outline-offset: 2px;
  border-color: var(--accent);
}

.input-field {
  width: 100%;
  padding: .55rem .75rem;
  border-radius: var(--border-radius-md);
  border: 1.5px solid var(--border-color);
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}
.input-field:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-light); }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 100;
  background-color: rgba(var(--bg-secondary-rgb), .8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
}
.header-inner {
  max-width: 1180px; margin: 0 auto;
  padding: .75rem 1.5rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; }
.brand-dots { display: inline-flex; }
.brand-dots i {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--d); display: block; margin-right: -5px;
  mix-blend-mode: multiply;
}
[data-theme="dark"] .brand-dots i { mix-blend-mode: screen; }
.brand-wordmark {
  font-family: var(--font-outfit); font-weight: 800; font-size: 1.25rem; letter-spacing: -.5px;
  background: linear-gradient(135deg, var(--accent), var(--accent-secondary));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

.site-controls { display: flex; align-items: center; gap: .5rem; }
.lang-switcher {
  display: inline-flex; gap: .25rem; padding: .25rem;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
}
.lang-switcher button {
  padding: .25rem .7rem; border: none; border-radius: 8px;
  font-weight: 600; font-size: .85rem; cursor: pointer;
  background: transparent; color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.lang-switcher button:hover { color: var(--text-primary); }
.lang-switcher button[aria-current="true"] { background-color: var(--accent); color: #fff; }
.theme-toggle-btn { padding: .5rem; border-radius: 50%; width: 40px; height: 40px; flex: none; }
.theme-toggle-btn svg { width: 20px; height: 20px; }

/* ---------- page ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 2rem 1.5rem 3rem; display: flex; flex-direction: column; gap: 2rem; }

.hero { text-align: center; }
.hero h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 800; letter-spacing: -.5px; }
.hero .lead { color: var(--text-secondary); margin-top: .5rem; }
.steps {
  list-style: none; margin-top: 1.25rem;
  display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem;
}
.steps li {
  display: inline-flex; align-items: center; gap: .5rem;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  padding: .4rem .9rem .4rem .4rem;
  font-size: .85rem; color: var(--text-secondary);
  box-shadow: var(--shadow-sm);
}
.step-num {
  width: 22px; height: 22px; flex: none;
  display: grid; place-items: center;
  border-radius: 50%; background-color: var(--accent-light); color: var(--accent);
  font-family: var(--font-outfit); font-weight: 700; font-size: .75rem;
}
[data-theme="dark"] .step-num { color: hsl(217, 91%, 75%); }

/* ---------- cards ---------- */
.card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-top: 6px solid var(--accent);
  border-radius: var(--border-radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-palette { border-top-color: hsl(0, 84%, 60%); }
.card-pot { border-top-color: hsl(217, 91%, 60%); }
.card-result { border-top-color: hsl(48, 96%, 53%); }
.card-saved { border-top-color: var(--accent-secondary); }
.card-head { margin-bottom: 1rem; }
.card-head h2 { font-size: 1.1rem; }

.workspace {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(300px, 1.15fr) minmax(260px, 1fr);
  gap: 1.5rem;
  align-items: start;
}

/* ---------- swatches ---------- */
.swatch-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: .75rem; }
.swatch {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: .4rem;
  padding: 0; border: none; background: none; cursor: grab;
  touch-action: none; -webkit-tap-highlight-color: transparent;
}
.swatch:active { cursor: grabbing; }
.swatch .chip {
  width: 100%; aspect-ratio: 1 / 1; border-radius: var(--border-radius-md);
  border: 1px solid rgba(0, 0, 0, .12);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
[data-theme="dark"] .swatch .chip { border-color: rgba(255, 255, 255, .18); }
.swatch:hover .chip { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.swatch .name { font-size: .72rem; color: var(--text-secondary); text-align: center; line-height: 1.25; }
.swatch.dragging .chip { opacity: .35; }
.swatch .del {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; border-radius: 50%;
  border: 1px solid var(--border-color); background-color: var(--bg-secondary); color: var(--text-secondary);
  font-size: .75rem; line-height: 1; cursor: pointer; display: none;
  box-shadow: var(--shadow-sm);
}
.swatch:hover .del, .swatch:focus-within .del { display: block; }
.swatch .del:hover { color: var(--error); border-color: var(--error); }

.custom-color { margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px dashed var(--border-color); }
.custom-row { display: flex; gap: .5rem; margin-top: .5rem; align-items: center; }
.custom-row input[type="color"] {
  width: 44px; height: 40px; flex: none; padding: 2px;
  border: 1.5px solid var(--border-color); border-radius: var(--border-radius-md);
  background: var(--bg-secondary); cursor: pointer;
}
.custom-row .input-field { flex: 1; min-width: 0; text-transform: uppercase; font-family: ui-monospace, monospace; font-size: .85rem; }

/* ---------- pot ---------- */
.pot-wrap { display: grid; place-items: center; padding: .5rem 0 1.25rem; }
.pot {
  position: relative;
  width: min(260px, 70vw); aspect-ratio: 1/1;
  border-radius: 50%;
  display: grid; place-items: center;
  border: 2px dashed var(--border-color);
  transition: border-color var(--transition-fast), transform var(--transition-fast), box-shadow var(--transition-fast);
}
.pot.has-mix { border-style: solid; border-color: transparent; box-shadow: var(--shadow-lg); }
.pot.drop-hover { transform: scale(1.04); border-color: var(--accent); box-shadow: 0 0 0 8px var(--accent-light); }
.pot-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: transparent;
  transition: background var(--transition-normal);
}
.pot-core {
  position: relative;
  width: 68%; aspect-ratio: 1/1; border-radius: 50%;
  display: grid; place-items: center; text-align: center; padding: 1rem;
  background-color: var(--bg-secondary);
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .06), var(--shadow-md);
  transition: background-color var(--transition-normal), color var(--transition-normal);
}
.pot-empty { display: grid; justify-items: center; gap: .25rem; color: var(--text-secondary); }
.pot-empty svg { width: 26px; height: 26px; opacity: .7; }
.pot-empty b { font-family: var(--font-outfit); font-size: .9rem; color: var(--text-primary); }
.pot-empty em { font-style: normal; font-size: .75rem; }
.pot-hex { font-family: var(--font-outfit); font-weight: 700; font-size: 1.1rem; letter-spacing: .5px; }

.mode-block { display: grid; gap: .5rem; }
.segmented { display: flex; gap: .4rem; flex-wrap: wrap; }
.segmented-btn {
  flex: 1 1 auto;
  padding: .5rem .75rem; font-size: .85rem; font-weight: 500;
  background-color: var(--bg-primary); color: var(--text-primary);
  border: 1px solid var(--border-color); border-radius: var(--border-radius-md);
  cursor: pointer; transition: all var(--transition-fast);
}
.segmented-btn[aria-pressed="true"] {
  font-weight: 700; background-color: var(--accent); color: #fff;
  border-color: var(--accent); box-shadow: var(--shadow-sm);
}
.mode-desc { min-height: 2.4em; }
.pot-actions { display: flex; gap: .5rem; margin-top: 1rem; }
.pot-actions .btn { flex: 1; }

/* ---------- ingredients ---------- */
.ingredients { list-style: none; display: grid; gap: .5rem; }
.ingredient {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem; border-radius: var(--border-radius-md);
  border: 1px solid var(--border-color); background-color: var(--bg-primary);
  cursor: grab; touch-action: none;
  animation: pop var(--transition-normal) forwards;
}
.ingredient:active { cursor: grabbing; }
.ingredient.dragging { opacity: .4; }
.ingredient .dot {
  width: 30px; height: 30px; flex: none; border-radius: var(--border-radius-sm);
  border: 1px solid rgba(0, 0, 0, .15);
}
[data-theme="dark"] .ingredient .dot { border-color: rgba(255, 255, 255, .2); }
.ingredient .meta { flex: 1; min-width: 0; }
.ingredient .meta b { display: block; font-family: var(--font-outfit); font-size: .85rem; font-weight: 600; }
.ingredient .meta span { font-size: .7rem; color: var(--text-secondary); font-family: ui-monospace, monospace; }
.stepper { display: flex; align-items: center; gap: .15rem; }
.stepper button {
  width: 24px; height: 24px; border-radius: 6px; cursor: pointer;
  border: 1px solid var(--border-color); background-color: var(--bg-secondary);
  display: grid; place-items: center; font-size: .9rem; line-height: 1;
  transition: all var(--transition-fast);
}
.stepper button:hover { border-color: var(--accent); color: var(--accent); }
.stepper .parts { min-width: 24px; text-align: center; font-family: var(--font-outfit); font-weight: 700; font-size: .85rem; }
.ingredient .remove {
  width: 24px; height: 24px; flex: none; border: none; background: none; cursor: pointer;
  color: var(--text-secondary); border-radius: 6px; font-size: 1rem; line-height: 1;
}
.ingredient .remove:hover { color: var(--error); background-color: var(--error-light); }

.empty-note { padding: .75rem 0; }
.trash {
  margin-top: .75rem;
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .75rem; border-radius: var(--border-radius-md);
  border: 2px dashed var(--border-color); color: var(--text-secondary);
  font-size: .8rem; transition: all var(--transition-fast);
}
.trash svg { width: 16px; height: 16px; }
.trash.drop-hover { border-color: var(--error); color: var(--error); background-color: var(--error-light); }

/* ---------- result ---------- */
.result {
  margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px dashed var(--border-color);
  display: grid; gap: 1rem;
}
.result-swatch {
  width: 100%; height: 84px; border-radius: var(--border-radius-md);
  border: 1px solid rgba(0, 0, 0, .12); box-shadow: var(--shadow-md);
  cursor: grab; touch-action: none;
  transition: background-color var(--transition-normal);
}
[data-theme="dark"] .result-swatch { border-color: rgba(255, 255, 255, .18); }
.result-info { display: grid; gap: .4rem; }
.result-row { display: flex; align-items: center; gap: .5rem; }
.result-row .label {
  font-size: .7rem; font-weight: 700; letter-spacing: .5px;
  color: var(--text-secondary); width: 34px; flex: none;
}
.copy-chip {
  flex: 1; text-align: left; cursor: pointer;
  padding: .35rem .6rem; border-radius: var(--border-radius-sm);
  border: 1px solid var(--border-color); background-color: var(--bg-primary);
  font-size: .8rem; transition: all var(--transition-fast);
}
.copy-chip:hover { border-color: var(--accent); color: var(--accent); }
.recipe-text { margin-top: .25rem; }
#saveBtn { width: 100%; margin-top: .25rem; }

/* ---------- saved ---------- */
.saved-grid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.site-footer { text-align: center; padding-top: .5rem; }

/* ---------- drag ghost + toast ---------- */
.drag-ghost {
  position: fixed; top: 0; left: 0; z-index: 9999;
  width: 62px; height: 62px; border-radius: var(--border-radius-md);
  border: 2px solid rgba(255, 255, 255, .8);
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  transform: translate(-50%, -50%) scale(1.05);
  transition: opacity .12s ease;
}
.toast {
  position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 1rem);
  padding: .6rem 1.1rem; border-radius: var(--border-radius-full);
  background-color: var(--text-primary); color: var(--bg-secondary);
  font-size: .85rem; font-weight: 600; font-family: var(--font-outfit);
  box-shadow: var(--shadow-lg); z-index: 9998;
  opacity: 0; pointer-events: none; transition: all var(--transition-normal);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- animations ---------- */
@keyframes pop { 0% { transform: scale(.9); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slideInUp { 0% { transform: translateY(20px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
.animate-slide-up { opacity: 0; animation: slideInUp .4s cubic-bezier(.16, 1, .3, 1) forwards; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .animate-slide-up { opacity: 1; }
}

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  .workspace { grid-template-columns: 1fr 1fr; }
  .card-pot { grid-column: 1 / -1; order: -1; }
}
@media (max-width: 700px) {
  .workspace { grid-template-columns: 1fr; }
  .page { padding: 1.5rem 1rem 2.5rem; gap: 1.5rem; }
  .header-inner { padding: .6rem 1rem; }
  .brand-wordmark { font-size: 1.1rem; }
  .steps { flex-direction: column; align-items: stretch; }
}
