/* ==========================================
   TASKR — CSS
   Aesthetic: Editorial / Raw / Bold
   ========================================== */

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

:root {
  --bg: #0e0e0e;
  --surface: #161616;
  --surface-2: #1e1e1e;
  --border: #2a2a2a;
  --border-hover: #444;
  --text: #f0ede8;
  --text-muted: #7a7672;
  --text-dim: #3d3d3d;
  --accent: #e8d44d;
  --accent-dark: #c9b835;
  --accent-glow: rgba(232, 212, 77, 0.15);
  --danger: #e85d5d;
  --success: #5de8a0;
  --radius: 12px;
  --radius-sm: 8px;
  --font-display: 'Syne', sans-serif;
  --font-body: 'DM Sans', sans-serif;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Noise texture overlay */
.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)'/%3E%3C/svg%3E");
  background-repeat: repeat;
  background-size: 128px 128px;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(14, 14, 14, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text);
}

.logo-icon {
  color: var(--accent);
  font-size: 1.1rem;
  animation: spin 8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stats {
  display: flex;
  gap: 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stats span:last-child {
  color: var(--success);
}

/* ── MAIN ── */
main {
  max-width: 680px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

/* ── HERO ── */
.hero {
  margin-bottom: 40px;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -0.04em;
  color: var(--text);
}

.hero h1 em {
  font-style: italic;
  font-weight: 600;
  color: var(--accent);
}

/* ── INPUT ── */
.input-area {
  margin-bottom: 28px;
}

.input-wrapper {
  display: flex;
  gap: 10px;
  position: relative;
}

#task-input {
  flex: 1;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#task-input::placeholder {
  color: var(--text-dim);
}

#task-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

#add-btn {
  background: var(--accent);
  color: #0e0e0e;
  border: none;
  border-radius: var(--radius);
  width: 56px;
  min-width: 56px;
  font-size: 1.6rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition), transform var(--transition);
  line-height: 1;
}

#add-btn:hover {
  background: var(--accent-dark);
  transform: scale(1.05);
}

#add-btn:active {
  transform: scale(0.97);
}

.input-error {
  font-size: 0.78rem;
  color: var(--danger);
  margin-top: 6px;
  min-height: 18px;
  padding-left: 4px;
}

/* ── FILTERS ── */
.filters {
  display: flex;
  gap: 6px;
  margin-bottom: 24px;
}

.filter-btn {
  background: transparent;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.filter-btn:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #0e0e0e;
}

/* ── TASK LIST ── */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── TASK ITEM ── */
.task-item {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  transition: border-color var(--transition), background var(--transition), opacity var(--transition), transform var(--transition);
  animation: slideIn 0.2s ease-out both;
  position: relative;
  overflow: hidden;
}

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

.task-item:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
}

.task-item.completed {
  opacity: 0.55;
}

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

/* Checkbox */
.task-check {
  width: 22px;
  min-width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-hover);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  flex-shrink: 0;
}

.task-check:hover {
  border-color: var(--accent);
  background: var(--accent-glow);
}

.task-check.checked {
  background: var(--success);
  border-color: var(--success);
}

.task-check.checked::after {
  content: '';
  display: block;
  width: 6px;
  height: 10px;
  border: 2px solid #0e0e0e;
  border-top: none;
  border-left: none;
  transform: rotate(45deg) translate(-1px, -1px);
}

/* Task text */
.task-text {
  flex: 1;
  font-size: 0.95rem;
  word-break: break-word;
  color: var(--text);
  transition: color var(--transition);
}

/* Task actions */
.task-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity var(--transition);
}

.task-item:hover .task-actions,
.task-item:focus-within .task-actions {
  opacity: 1;
}

.task-btn {
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 6px 8px;
  transition: all var(--transition);
}

.task-btn:hover {
  color: var(--text);
  background: var(--surface-2);
}

.task-btn.delete:hover {
  color: var(--danger);
  background: rgba(232, 93, 93, 0.1);
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-dim);
}

.empty-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.3;
}

.empty-state p {
  font-size: 0.9rem;
  font-family: var(--font-display);
  letter-spacing: 0.02em;
}

/* ── LIST FOOTER ── */
.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
  padding: 12px 4px;
  font-size: 0.82rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.clear-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.clear-btn:hover {
  color: var(--danger);
  background: rgba(232, 93, 93, 0.08);
}

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  animation: fadeIn 0.15s ease-out;
}

.modal-overlay[hidden] {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--surface);
  border: 1.5px solid var(--border-hover);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 480px;
  animation: modalIn 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
}

#modal-input {
  width: 100%;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-family: var(--font-body);
  font-size: 0.95rem;
  color: var(--text);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

#modal-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

.btn-primary, .btn-secondary {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  padding: 10px 22px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-primary {
  background: var(--accent);
  color: #0e0e0e;
}

.btn-primary:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
}

.btn-secondary:hover {
  border-color: var(--border-hover);
  color: var(--text);
}

/* ── RESPONSIVE ── */
@media (max-width: 480px) {
  header {
    padding: 16px 20px;
  }

  main {
    padding: 32px 16px 80px;
  }

  .hero h1 {
    font-size: 2.1rem;
  }

  .task-actions {
    opacity: 1;
  }

  .modal {
    padding: 24px 20px;
  }
}

/* ── ACCESSIBILITY ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
