/* ────────────────────────────────────
   Hydrater — Design Tokens & Styles
   ──────────────────────────────────── */

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

/* ══════════════════════════════════════
   Raw palette (never referenced directly)
   ══════════════════════════════════════ */
:root {
  --palette-blue-50:     #eff6ff;
  --palette-blue-100:    #dbeafe;
  --palette-blue-400:    #60a5fa;
  --palette-blue-500:    #3b82f6;
  --palette-blue-600:    #2563eb;
  --palette-blue-700:    #1d4ed8;
  --palette-gray-300:    #d1d5db;
  --palette-gray-400:    #9ca3af;
  --palette-gray-500:    #6b7280;
  --palette-gray-700:    #374151;
  --palette-gray-900:    #111827;
  --palette-white:       #ffffff;
  --palette-green-400:   #4ade80;
  --palette-green-500:   #22c55e;
  --palette-green-600:   #16a34a;

  /* dark palette */
  --palette-slate-100:   #f1f5f9;
  --palette-slate-400:   #94a3b8;
  --palette-slate-500:   #64748b;
  --palette-slate-600:   #475569;
  --palette-slate-700:   #334155;
  --palette-slate-800:   #1e293b;
  --palette-slate-900:   #0f172a;
  --palette-blue-300:    #93c5fd;
  --palette-navy-800:    #1e3a5f;
}

/* ══════════════════════════════════════
   Semantic tokens — light (default)
   ══════════════════════════════════════ */
:root {
  --bg-page:             var(--palette-blue-50);
  --bg-card:             var(--palette-white);
  --text-primary:        var(--palette-gray-900);
  --text-secondary:      var(--palette-gray-500);
  --text-muted:          var(--palette-gray-400);
  --intake-color:        var(--palette-blue-600);
  --progress-track:      var(--palette-blue-100);
  --progress-fill:       var(--palette-blue-500);
  --progress-done:       var(--palette-green-500);
  --btn-primary:         var(--palette-blue-500);
  --btn-primary-hover:   var(--palette-blue-600);
  --btn-primary-text:    var(--palette-white);
  --chip-border:         var(--palette-gray-300);
  --chip-color:          var(--palette-gray-700);
  --chip-hover-border:   var(--palette-blue-400);
  --chip-hover-color:    var(--palette-blue-600);
  --chip-active-border:  var(--palette-blue-500);
  --chip-active-bg:      var(--palette-blue-50);
  --chip-active-color:   var(--palette-blue-700);
  --action-link:         var(--palette-gray-400);
  --action-link-hover:   var(--palette-gray-700);
  --action-link-visible: var(--palette-gray-500);
  --toast-bg:            var(--palette-gray-900);
  --toast-color:         var(--palette-white);
  --goal-glow:           var(--palette-green-400);
  --focus-ring:          var(--palette-blue-400);
  --shadow-card:         0 4px 24px rgba(0,0,0,0.06), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-goal:         0 0 0 3px var(--goal-glow), 0 4px 24px rgba(34,197,94,0.18);
  --radius:              24px;
  --card-size:           min(360px, calc(100vw - 48px));
}

/* ══════════════════════════════════════
   Semantic tokens — dark override
   ══════════════════════════════════════ */
[data-theme="dark"] {
  --bg-page:             var(--palette-slate-900);
  --bg-card:             var(--palette-slate-800);
  --text-primary:        var(--palette-slate-100);
  --text-secondary:      var(--palette-slate-400);
  --text-muted:          var(--palette-slate-500);
  --intake-color:        var(--palette-blue-400);
  --progress-track:      var(--palette-slate-700);
  --progress-fill:       var(--palette-blue-400);
  --progress-done:       var(--palette-green-500);   /* unchanged */
  --btn-primary:         var(--palette-blue-500);    /* unchanged */
  --btn-primary-hover:   var(--palette-blue-600);    /* unchanged */
  --btn-primary-text:    var(--palette-white);        /* unchanged */
  --chip-border:         var(--palette-slate-600);
  --chip-color:          var(--palette-slate-100);
  --chip-hover-border:   var(--palette-blue-400);    /* unchanged */
  --chip-hover-color:    var(--palette-blue-300);
  --chip-active-border:  var(--palette-blue-400);
  --chip-active-bg:      var(--palette-navy-800);
  --chip-active-color:   var(--palette-blue-300);
  --action-link:         var(--palette-slate-500);
  --action-link-hover:   var(--palette-slate-100);
  --action-link-visible: var(--palette-slate-400);
  --toast-bg:            var(--palette-slate-100);
  --toast-color:         var(--palette-gray-900);
  --goal-glow:           var(--palette-green-400);   /* unchanged */
  --focus-ring:          var(--palette-blue-400);    /* unchanged */
  --shadow-card:         0 4px 24px rgba(0,0,0,0.25), 0 1px 4px rgba(0,0,0,0.15);
  --shadow-goal:         0 0 0 3px var(--goal-glow), 0 4px 24px rgba(34,197,94,0.18);
}

/* ══════════════════════════════════════
   Global
   ══════════════════════════════════════ */
html {
  transition: background 0.3s ease, color 0.3s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-page);
  color: var(--text-primary);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  transition: background 0.3s ease;
}

/* ══════════════════════════════════════
   Card
   ══════════════════════════════════════ */
.card {
  width: var(--card-size);
  aspect-ratio: 1;
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 28px 28px 24px;
  transition: box-shadow 0.3s, background 0.3s ease;
  position: relative;
}

.card.goal-reached {
  box-shadow: var(--shadow-goal);
}

/* ══════════════════════════════════════
   Theme toggle
   ══════════════════════════════════════ */
.theme-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color 0.2s, transform 0.3s ease;
  padding: 6px;
}

.theme-toggle:hover {
  color: var(--text-secondary);
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Icon visibility: moon in light mode, sun in dark mode */
.icon-sun  { display: none; }
.icon-moon { display: block; }

[data-theme="dark"] .icon-sun  { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* ══════════════════════════════════════
   Date
   ══════════════════════════════════════ */
.date {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* ══════════════════════════════════════
   Intake Number
   ══════════════════════════════════════ */
.intake-group {
  text-align: center;
}

.intake-value {
  font-size: 4rem;
  font-weight: 700;
  line-height: 1;
  color: var(--intake-color);
  transition: transform 0.15s ease, color 0.3s ease;
}

.intake-value.pop {
  transform: scale(1.12);
}

.intake-unit {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-top: 2px;
  letter-spacing: 0.02em;
}

/* ══════════════════════════════════════
   Progress bar
   ══════════════════════════════════════ */
.progress-wrap {
  width: 100%;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
  transition: background 0.3s ease;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--progress-fill);
  border-radius: 999px;
  transition: width 0.35s cubic-bezier(0.4, 0, 0.2, 1), background 0.3s ease;
}

.progress-fill.done {
  background: var(--progress-done);
}

.progress-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 6px;
  text-align: center;
  transition: color 0.3s ease;
}

/* ══════════════════════════════════════
   Add button
   ══════════════════════════════════════ */
.btn-add {
  width: 100%;
  padding: 14px 0;
  border: none;
  border-radius: 14px;
  background: var(--btn-primary);
  color: var(--btn-primary-text);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-add:hover  { background: var(--btn-primary-hover); }
.btn-add:active { transform: scale(0.97); }
.btn-add:focus-visible { outline: 3px solid var(--focus-ring); outline-offset: 2px; }

.btn-add.goal-reached {
  background: var(--progress-done);
}

.btn-add.goal-reached:hover {
  background: var(--palette-green-600);
}

/* ══════════════════════════════════════
   Drink size chips
   ══════════════════════════════════════ */
.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.chip {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--chip-border);
  background: transparent;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--chip-color);
  cursor: pointer;
  transition: all 0.15s;
}

.chip:hover {
  border-color: var(--chip-hover-border);
  color: var(--chip-hover-color);
}

.chip.active {
  border-color: var(--chip-active-border);
  background: var(--chip-active-bg);
  color: var(--chip-active-color);
}

.chip:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ══════════════════════════════════════
   Footer actions
   ══════════════════════════════════════ */
.actions {
  display: flex;
  gap: 20px;
}

.action-link {
  font-size: 0.78rem;
  color: var(--action-link);
  cursor: pointer;
  background: none;
  border: none;
  font-weight: 500;
  transition: color 0.15s;
  padding: 4px;
}

.action-link:hover   { color: var(--action-link-hover); }
.action-link:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; border-radius: 4px; }

.action-link.visible { color: var(--action-link-visible); }

/* ══════════════════════════════════════
   Toast
   ══════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--toast-bg);
  color: var(--toast-color);
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease, background 0.3s ease, color 0.3s ease;
  z-index: 100;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* ══════════════════════════════════════
   Confetti
   ══════════════════════════════════════ */
@keyframes floatUp {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(-120px) scale(0.3); opacity: 0; }
}

.confetti-piece {
  position: fixed;
  font-size: 1.5rem;
  pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
  z-index: 200;
}
