/* styles.css — schone, toegankelijke, responsive styling voor de to-do app.
   Ontworpen voor WCAG AA-contrast, zichtbare focus-states en prettige
   bediening op mobiel én desktop. Ondersteunt licht en donker via prefers-color-scheme. */

/* -------------------------------------------------------------------------- */
/* Design tokens                                                              */
/* -------------------------------------------------------------------------- */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-muted: #f0f1f4;
  --border: #d6d9e0;
  --text: #1a1d24;          /* ~15:1 op wit */
  --text-muted: #565b66;    /* ~7:1 op wit → AA voor normale tekst */
  --primary: #2b59c3;       /* ~5.3:1 op wit → AA */
  --primary-hover: #1f47a3;
  --primary-contrast: #ffffff;
  --danger: #b3261e;        /* ~6.2:1 op wit → AA */
  --focus: #1f47a3;
  --completed: #6b7280;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.08);

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #1a1d24;
    --surface-muted: #23272f;
    --border: #333944;
    --text: #f3f4f6;
    --text-muted: #b3bac6;    /* AA op donkere surface */
    --primary: #7aa2f7;       /* lichter accent voor donkere modus */
    --primary-hover: #9bb8ff;
    --primary-contrast: #0f1115;
    --danger: #ff6b63;
    --focus: #9bb8ff;
    --completed: #8a919e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 4px 16px rgba(0, 0, 0, 0.5);
  }
}

/* -------------------------------------------------------------------------- */
/* Reset / basis                                                              */
/* -------------------------------------------------------------------------- */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  padding: var(--space-4);
}

h1 {
  margin: 0;
}

button {
  font: inherit;
  cursor: pointer;
}

/* Zichtbare, consistente focus voor toetsenbordgebruikers. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------------------- */
/* Hulpklassen                                                                */
/* -------------------------------------------------------------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: var(--space-2);
  top: -3rem;
  z-index: 10;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: top 0.15s ease;
}
.skip-link:focus {
  top: var(--space-2);
}

/* -------------------------------------------------------------------------- */
/* Layout                                                                     */
/* -------------------------------------------------------------------------- */

.app {
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app__header {
  text-align: center;
  padding-top: var(--space-4);
}

.app__title {
  font-size: clamp(1.6rem, 5vw, 2rem);
  letter-spacing: -0.01em;
}

.app__subtitle {
  margin: var(--space-2) 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.app__footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}
.app__footer p {
  margin: 0;
}

/* -------------------------------------------------------------------------- */
/* Nieuwe taak toevoegen                                                      */
/* -------------------------------------------------------------------------- */

.new-task {
  display: flex;
  gap: var(--space-2);
}

.new-task__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-3);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.new-task__input::placeholder {
  color: var(--text-muted);
}

.new-task__button {
  flex: 0 0 auto;
  padding: var(--space-3) var(--space-4);
  font-weight: 600;
  color: var(--primary-contrast);
  background: var(--primary);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}
.new-task__button:hover {
  background: var(--primary-hover);
}

/* -------------------------------------------------------------------------- */
/* Filters + teller                                                           */
/* -------------------------------------------------------------------------- */

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.filters__group {
  display: inline-flex;
  gap: var(--space-1);
  background: var(--surface-muted);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
}

.filter {
  padding: var(--space-2) var(--space-3);
  font-size: 0.9rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease;
}
.filter:hover {
  color: var(--text);
}
.filter--active {
  color: var(--text);
  background: var(--surface);
  border-color: var(--border);
  font-weight: 600;
}

.active-count {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------------------------- */
/* Takenlijst                                                                 */
/* -------------------------------------------------------------------------- */

.task-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.task-item__checkbox {
  flex: 0 0 auto;
  width: 1.25rem;
  height: 1.25rem;
  accent-color: var(--primary);
  cursor: pointer;
}

.task-item__title {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

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

.task-item__edit-input {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-2);
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--primary);
  border-radius: 6px;
}

.task-item__actions {
  flex: 0 0 auto;
  display: inline-flex;
  gap: var(--space-1);
}

.icon-button {
  padding: var(--space-2) var(--space-3);
  font-size: 0.85rem;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-button:hover {
  color: var(--text);
  background: var(--surface-muted);
}
.task-item__delete:hover {
  color: var(--danger);
  border-color: var(--danger);
}

/* Verberg de acties niet bij bewerken; het editveld neemt de titelplek in. */
.task-item--editing .task-item__actions {
  visibility: hidden;
}

/* -------------------------------------------------------------------------- */
/* Lege staat                                                                 */
/* -------------------------------------------------------------------------- */

.empty-state {
  margin: 0;
  padding: var(--space-5) var(--space-4);
  text-align: center;
  color: var(--text-muted);
  background: var(--surface-muted);
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
}

/* -------------------------------------------------------------------------- */
/* Responsive                                                                 */
/* -------------------------------------------------------------------------- */

@media (max-width: 480px) {
  body {
    padding: var(--space-2);
  }
  .new-task {
    flex-wrap: wrap;
  }
  .new-task__button {
    flex: 1 1 100%;
  }
  .filters {
    justify-content: center;
  }
  .filters__group {
    flex: 1 1 100%;
    justify-content: center;
  }
  .active-count {
    flex: 1 1 100%;
    text-align: center;
  }
  .icon-button {
    padding: var(--space-2);
  }
}

/* Respecteer voorkeur voor minder beweging. */
@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}
