/* style.css — Todo PWA */

/* ── Google Fonts ─────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* ── Variables ────────────────────────────────────────────── */
:root {
  /* Claude AI dark mode palette */
  --bg-primary:    #0f1117;
  --bg-secondary:  #1a1d27;
  --bg-tertiary:   #222639;
  --bg-hover:      #2a2f45;
  --border:        #2e3348;
  --border-light:  #3a3f58;

  --text-primary:   #e8eaf0;
  --text-secondary: #8b92a8;
  --text-muted:     #5a6070;

  --accent:         #c17cff;      /* Claude purple */
  --accent-dim:     #8b52d4;
  --accent-glow:    rgba(193, 124, 255, 0.15);

  --green:          #4ade80;
  --green-dim:      rgba(74, 222, 128, 0.12);
  --red:            #f87171;
  --red-dim:        rgba(248, 113, 113, 0.12);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  16px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);

  --transition: 150ms ease;
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  /* Prevent iOS font size adjustment */
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100%;
  /* Safe area for iPhone notch / home bar */
  padding-bottom: env(safe-area-inset-bottom);
}

/* ── Layout ───────────────────────────────────────────────── */
#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
  padding: 28px 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.header-left h1 {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.header-left .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Sync indicator */
.sync-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 6px 10px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all var(--transition);
}
.sync-btn:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}
.sync-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.sync-btn.syncing svg {
  animation: spin 1s linear infinite;
}
.sync-btn.error {
  border-color: var(--red);
  color: var(--red);
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Add Task Form ────────────────────────────────────────── */
.add-form {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.add-input {
  flex: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  padding: 11px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.add-input::placeholder {
  color: var(--text-muted);
}
.add-input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.add-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-md);
  color: #0f0813;
  cursor: pointer;
  font-family: inherit;
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
  padding: 0 16px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  flex-shrink: 0;
}
.add-btn:hover {
  background: #d49aff;
}
.add-btn:active {
  transform: scale(0.96);
}

/* ── Filter Tabs ──────────────────────────────────────────── */
.filters {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  padding: 4px;
  border: 1px solid var(--border);
}

.filter-btn {
  flex: 1;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 7px 12px;
  transition: all var(--transition);
  text-align: center;
}
.filter-btn:hover {
  color: var(--text-primary);
}
.filter-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* ── Stats bar ────────────────────────────────────────────── */
.stats {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.stats-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  display: inline-block;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Task List ────────────────────────────────────────────── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 40px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon {
  font-size: 36px;
  margin-bottom: 12px;
  opacity: 0.4;
}
.empty-state p {
  font-size: 14px;
}

/* ── Task Item ────────────────────────────────────────────── */
.task-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  transition: background var(--transition), border-color var(--transition), opacity var(--transition);
  position: relative;
  animation: slideIn 180ms ease;
}
.task-item:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
}
.task-item.completed {
  opacity: 0.55;
}
.task-item.completed:hover {
  opacity: 0.75;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Checkbox */
.task-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid var(--border-light);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  background: none;
  padding: 0;
}
.task-check:hover {
  border-color: var(--accent-dim);
  background: var(--accent-glow);
}
.task-item.completed .task-check {
  background: var(--green-dim);
  border-color: var(--green);
}
.task-check svg {
  width: 11px;
  height: 11px;
  stroke: var(--green);
  opacity: 0;
  transition: opacity var(--transition);
}
.task-item.completed .task-check svg {
  opacity: 1;
}

/* Task title */
.task-title {
  flex: 1;
  font-size: 15px;
  color: var(--text-primary);
  word-break: break-word;
  cursor: default;
  line-height: 1.4;
}
.task-item.completed .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* Task edit input (inline) */
.task-edit-input {
  flex: 1;
  background: var(--bg-tertiary);
  border: 1px solid var(--accent-dim);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 15px;
  padding: 3px 8px;
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-glow);
}

/* Actions (shown on hover) */
.task-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.task-item:hover .task-actions {
  opacity: 1;
}
/* Always show on touch devices */
@media (hover: none) {
  .task-actions { opacity: 1; }
}

.task-action-btn {
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  font-size: 13px;
}
.task-action-btn:hover {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}
.task-action-btn.delete:hover {
  background: var(--red-dim);
  color: var(--red);
}
.task-action-btn svg {
  width: 14px;
  height: 14px;
}

/* ── Loading / Error state ────────────────────────────────── */
.status-msg {
  text-align: center;
  padding: 32px 0;
  color: var(--text-muted);
  font-size: 14px;
}
.status-msg.error {
  color: var(--red);
}

/* ── Divider between active/done ──────────────────────────── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.section-divider::before,
.section-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ── Toast notification ───────────────────────────────────── */
#toast {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 13px;
  padding: 10px 18px;
  pointer-events: none;
  opacity: 0;
  transition: all 250ms ease;
  white-space: nowrap;
  box-shadow: var(--shadow-md);
  z-index: 100;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.error {
  border-color: var(--red);
  color: var(--red);
}

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }


/* ── Task animations ──────────────────────────────────────────*/

/* --- Complete: phase 1 green flash --- */
@keyframes completeFlash {
  0%   { background: var(--bg-secondary); border-color: var(--border); }
  30%  { background: var(--green-dim); border-color: var(--green); box-shadow: 0 0 0 4px rgba(74,222,128,0.15); }
  70%  { background: var(--green-dim); border-color: var(--green); }
  100% { background: var(--bg-secondary); border-color: var(--border); }
}

@keyframes checkPop {
  0%   { transform: scale(0.4); opacity: 0; }
  55%  { transform: scale(1.35); opacity: 1; }
  75%  { transform: scale(0.9); }
  100% { transform: scale(1); opacity: 1; }
}

.task-item.completing-flash {
  animation: completeFlash 500ms ease forwards;
  pointer-events: none;
}
.task-item.completing-flash .task-check {
  background: var(--green-dim) !important;
  border-color: var(--green) !important;
}
.task-item.completing-flash .task-check svg {
  opacity: 1 !important;
  animation: checkPop 300ms cubic-bezier(0.34,1.56,0.64,1) forwards;
  stroke: var(--green);
}

/* --- Complete: phase 2 strikethrough --- */
@keyframes strikeThrough {
  from { text-decoration-color: transparent; color: var(--text-primary); }
  to   { text-decoration-color: var(--text-muted); color: var(--text-muted); }
}
.task-title.striking {
  text-decoration: line-through;
  animation: strikeThrough 250ms ease forwards;
}

/* --- Complete: phase 3 collapse --- */
@keyframes collapseOut {
  0%   { opacity: 1; transform: scaleY(1); max-height: 200px; margin-bottom: 6px; }
  40%  { opacity: 0; transform: scaleY(0.6) translateY(-6px); }
  100% { opacity: 0; transform: scaleY(0); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}
.task-item.completing-collapse {
  animation: collapseOut 350ms cubic-bezier(0.4,0,0.2,1) forwards;
  pointer-events: none;
}

/* --- Un-complete quick fade --- */
@keyframes uncompleteFlash {
  0%   { opacity: 0.5; }
  100% { opacity: 1; }
}
.task-item.uncompleting {
  animation: uncompleteFlash 200ms ease forwards;
}

/* --- Delete: swipe right + collapse --- */
@keyframes swipeDelete {
  0%   { opacity: 1; transform: translateX(0);    }
  40%  { opacity: 0; transform: translateX(60px); }
  100% { opacity: 0; transform: translateX(80px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; }
}
.task-item.deleting {
  animation: swipeDelete 320ms cubic-bezier(0.4,0,1,1) forwards;
  pointer-events: none;
}