/* ---------- Design tokens ---------- */
:root {
  --page-bg: linear-gradient(160deg, #eef2ff 0%, #f5f3ff 50%, #fdf4ff 100%);
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --text: #1e293b;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-soft: #eef2ff;
  --accent: #7c3aed;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --success: #16a34a;
  --shadow: 0 10px 40px -12px rgba(79, 70, 229, 0.25);
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page-bg: linear-gradient(160deg, #0f172a 0%, #1e1b4b 100%);
    --surface: #1e293b;
    --surface-soft: #172033;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: #334155;
    --border-strong: #475569;
    --primary: #6366f1;
    --primary-hover: #818cf8;
    --primary-soft: #26264d;
    --danger: #f87171;
    --danger-soft: #3b1f26;
    --shadow: 0 10px 40px -12px rgba(0, 0, 0, 0.6);
  }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--page-bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; cursor: pointer; }
button:disabled { opacity: 0.6; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; }

.app {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem 1rem 2.5rem;
}

/* ---------- Header ---------- */
.hero {
  padding: 1.75rem 1.5rem 1.5rem;
  color: #fff;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  border-radius: 20px 20px 0 0;
}

.hero__date {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.8;
}

.hero__title {
  margin: 0.25rem 0 0;
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  line-height: 1.2;
}

.hero__summary {
  margin: 0.35rem 0 1.25rem;
  min-height: 1.5em;
  opacity: 0.9;
}

.progress {
  height: 10px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 999px;
}

.progress__fill {
  width: 0%;
  height: 100%;
  background: #fff;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* ---------- Main panel ---------- */
.panel {
  padding: 1.25rem 1.25rem 1.5rem;
  background: var(--surface);
  border-radius: 0 0 20px 20px;
  box-shadow: var(--shadow);
}

.banner {
  margin-bottom: 1rem;
  padding: 0.75rem 1rem;
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  border-radius: 10px;
}

/* ---------- Form ---------- */
.task-form {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.task-form input {
  flex: 1;
  min-width: 0;
  padding: 0.85rem 1rem;
  color: var(--text);
  font: inherit;
  background: var(--surface-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.task-form input::placeholder { color: var(--muted); }

.task-form input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.task-form__button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.85rem 1.3rem;
  color: #fff;
  font-weight: 600;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: 0;
  border-radius: var(--radius);
  transition: transform 0.1s, box-shadow 0.15s;
}

.task-form__button span { font-size: 1.25rem; line-height: 1; }

.task-form__button:hover:not(:disabled) {
  box-shadow: 0 6px 16px -4px rgba(79, 70, 229, 0.55);
  transform: translateY(-1px);
}

.task-form__button:active:not(:disabled) { transform: translateY(0); }

/* ---------- Task list ---------- */
.task-list {
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.task {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.85rem 1rem;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.task:hover {
  border-color: var(--border-strong);
  box-shadow: 0 4px 14px -6px rgba(0, 0, 0, 0.15);
}

.task--new { animation: slide-in 0.25s ease-out; }
.task--removing { animation: slide-out 0.18s ease-in forwards; }

@keyframes slide-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes slide-out {
  to { opacity: 0; transform: translateX(24px); }
}

/* Custom round checkbox */
.task input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  display: grid;
  flex-shrink: 0;
  place-content: center;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.task input[type="checkbox"]::after {
  content: "";
  width: 0.35rem;
  height: 0.65rem;
  margin-top: -2px;
  border: solid #fff;
  border-width: 0 2.5px 2.5px 0;
  transform: rotate(45deg) scale(0);
  transition: transform 0.15s ease-out;
}

.task input[type="checkbox"]:hover { border-color: var(--primary); }

.task input[type="checkbox"]:checked {
  background: var(--success);
  border-color: var(--success);
}

.task input[type="checkbox"]:checked::after { transform: rotate(45deg) scale(1); }

.task label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  cursor: pointer;
  transition: color 0.15s;
}

.task--done label {
  color: var(--muted);
  text-decoration: line-through;
}

.task__delete {
  padding: 0.2rem 0.55rem;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
  background: transparent;
  border: 0;
  border-radius: 8px;
  transition: color 0.15s, background 0.15s, opacity 0.15s;
}

.task__delete:hover {
  color: var(--danger);
  background: var(--danger-soft);
}

/* On devices with a mouse, reveal the delete button on hover/focus. */
@media (hover: hover) {
  .task__delete { opacity: 0; }
  .task:hover .task__delete,
  .task__delete:focus-visible { opacity: 1; }
}

/* ---------- Empty state ---------- */
.empty {
  padding: 2rem 1rem 1rem;
  text-align: center;
  color: var(--muted);
}

.empty__icon { color: var(--border-strong); }

.empty__title {
  margin: 0.5rem 0 0.15rem;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 600;
}

.empty__text { margin: 0; }

/* ---------- Footer ---------- */
.footer {
  margin-top: 1.5rem;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

/* ---------- Utilities ---------- */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- Small screens ---------- */
@media (max-width: 480px) {
  .app { padding: 1rem 0.75rem 2rem; }
  .hero { padding: 1.5rem 1.25rem 1.25rem; }
  .panel { padding: 1rem 1rem 1.25rem; }
}

/* ---------- Respect reduced-motion preferences ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}
