/*
 * Routiny — custom CSS
 * Bootstrap 5 handles layout, buttons, and forms.
 * This file: palette overrides, font, task grid, progress bar, overlays, animations.
 */

/* ─── Bootstrap variable overrides ──────────────── */
:root {
  --bs-primary:             #EC4899;
  --bs-primary-rgb:         236, 72, 153;
  --bs-body-font-family:    'Nunito', -apple-system, 'Segoe UI', sans-serif;
  --bs-body-bg:             #FDF2F8;   /* soft pink */
  --bs-body-color:          #3B1A3A;
  --bs-secondary-color:     #C084A0;
  --bs-border-color:        #FBCFE8;
  --bs-border-radius:       999px;
  --bs-border-radius-lg:    999px;

  /* Custom tokens (not covered by Bootstrap) */
  --progress-fill:    #EC4899;
  --progress-track:   #FDE0EF;
  --progress-gold:    #FACC15;
  --task-done-bg:     #FCE7F3;
  --task-done-border: #F9A8D4;
  --checkmark:        #BE185D;
  --amber:            #F59E0B;
  --amber-glow:       rgba(245, 158, 11, 0.28);
}

/* ─── Global touch behaviour ─────────────────────── */
html { touch-action: manipulation; }   /* kill 300ms tap delay on iOS */

/* ─── Bootstrap btn-primary colour override ──────── */
.btn-primary {
  --bs-btn-bg:                 #EC4899;
  --bs-btn-border-color:       #EC4899;
  --bs-btn-hover-bg:           #DB2777;
  --bs-btn-hover-border-color: #DB2777;
  --bs-btn-active-bg:          #BE185D;
  --bs-btn-focus-shadow-rgb:   236, 72, 153;
  font-weight: 800;
  box-shadow: 0 3px 10px rgba(236, 72, 153, 0.35);
  min-height: 44px;   /* Apple HIG minimum touch target */
}

/* ─── Page wrapper ───────────────────────────────── */
.page {
  max-width: 700px;
  margin: 0 auto;
  padding-top: 28px;
  padding-bottom: max(28px, env(safe-area-inset-bottom));
  padding-left:  max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
  min-height: 100vh;
}

/* ─── Icon buttons (gear, stop — not Bootstrap btns) */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  padding: 6px 8px;
  min-width: 44px; min-height: 44px;   /* touch target */
  border-radius: 8px;
  color: var(--bs-secondary-color);
  text-decoration: none;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.icon-btn[aria-disabled="true"] { opacity: 0.28; pointer-events: none; }
.icon-btn.stop-btn { color: #DC2626; font-weight: 800; }

/* ─── Progress bar ───────────────────────────────── */
.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--bs-secondary-color);
  margin-bottom: 6px;
}
.progress-track {
  width: 100%;
  height: 22px;
  background: var(--progress-track);
  border-radius: 11px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--progress-fill);
  border-radius: 11px;
  width: 0%;
  transition: width 0.6s linear, background-color 0.5s ease;
}
.progress-fill.gold { background: var(--progress-gold); }

/* ─── Task grid ──────────────────────────────────── */
.run-body { position: relative; margin-top: 20px; }

.task-grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
  min-height: 280px;
  align-content: flex-start;
}

.task-card {
  flex: 0 0 130px;
  aspect-ratio: 1;
  background: #fff;
  border: 2px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius-lg);
  box-shadow: 0 2px 10px rgba(0,0,0,.07);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: border-color .35s ease, background-color .35s ease;
}
.task-card:active { transform: scale(0.96); }

.task-emoji {
  font-size: clamp(3rem, 7vw, 4.5rem);
  line-height: 1;
  transition: transform .35s ease;
}

.task-card.completed {
  background: var(--task-done-bg);
  border-color: var(--task-done-border);
}
.task-card.completed .task-emoji { transform: scale(0.75); opacity: 0.7; }

/* ─── Start overlay ──────────────────────────────── */
.start-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(253,242,248,.80);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 28px;
  z-index: 10;
}

/* ─── Celebration overlay ────────────────────────── */
.celebration-overlay {
  position: fixed; inset: 0;
  background: rgba(255,248,240,.92);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  z-index: 200; overflow: hidden; cursor: pointer;
}
.celebration-overlay.hidden { display: none; }

.celebration-message {
  font-size: clamp(2rem, 9vw, 3.8rem);
  font-weight: 800;
  color: var(--bs-body-color);
  text-align: center;
  position: relative; z-index: 1;
  animation: message-pop .55s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.confetti-piece { position: absolute; top: 0; animation: confetti-fall linear forwards; }

/* ─── Edit screen task list ──────────────────────── */
.task-edit-list { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.task-edit-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff;
  border: 1.5px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  padding: 10px 14px;
  cursor: grab;
}
.task-edit-row:active { cursor: grabbing; }
.task-edit-emoji { font-size: 1.9rem; }

.task-delete-btn {
  width: 36px; height: 36px;
  border: 1.5px solid #FECACA;
  border-radius: 8px;
  background: #fff;
  color: #EF4444;
  font-size: 1.2rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  flex-shrink: 0;
}
.task-delete-btn:active { background: #FEF2F2; }

.emoji-input {
  width: 70px; padding: 10px;
  border: 1.5px solid var(--bs-border-color);
  border-radius: var(--bs-border-radius);
  font-size: 1.6rem; text-align: center; outline: none;
}
.emoji-input:focus { border-color: var(--bs-primary); }
.sortable-ghost { opacity: 0.3; background: var(--task-done-bg); }

/* ─── Animation keyframes ────────────────────────── */

@keyframes task-bounce {
  0%   { transform: scale(1); }
  20%  { transform: scale(1.50); }
  40%  { transform: scale(0.85); }
  60%  { transform: scale(1.25); }
  78%  { transform: scale(0.94); }
  90%  { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.task-card.task-completing {
  animation: task-bounce .7s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes mini-burst {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

@keyframes amber-pulse {
  0%, 100% { background-color: var(--amber); box-shadow: 0 0 0 0 var(--amber-glow); }
  50%       { box-shadow: 0 0 0 9px transparent; }
}
.progress-fill.amber {
  animation: amber-pulse 1.9s ease-in-out infinite;
  background-color: var(--amber);
  transition: none;
}

@keyframes celebration-bounce {
  0%, 100% { transform: translateY(0) scale(1); }
  18%       { transform: translateY(-20px) scale(1.07); }
  48%       { transform: translateY(-10px) scale(1.03); }
  68%       { transform: translateY(-15px) scale(1.05); }
  88%       { transform: translateY(-5px)  scale(1.01); }
}
.task-card.celebrating { animation: celebration-bounce .95s ease-in-out both; }

@keyframes confetti-fall {
  0%   { transform: translateY(-15px) rotate(0deg) scale(1); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(108vh) rotate(740deg) scale(0.55); opacity: 0; }
}

@keyframes message-pop {
  0%   { transform: scale(0.45); opacity: 0; }
  65%  { transform: scale(1.10); }
  100% { transform: scale(1);    opacity: 1; }
}
