/* Reset, typography and shared controls. */

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

html, body {
  height: 100%;
  margin: 0;
}

/* A page in another language than its markup's French stays hidden until its module
   has translated it; prepaint.js sets the class and lifts it after 1.5 s at most. */
html.i18n-pending body { visibility: hidden; }

body {
  font-family: var(--font-sans);
  font-size: var(--fs-md);
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

h1, h2, h3, p { margin: 0; }

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

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

[hidden] { display: none !important; }

/* ---------------------------------------------------------------- buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2rem;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: var(--fs-sm);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition);
  white-space: nowrap;
}

.btn:hover { background: var(--surface-3); }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-danger { border-color: var(--danger); color: var(--danger); background: transparent; }
.btn-danger:hover { background: var(--danger-soft); }

.btn-icon {
  min-width: 2rem;
  padding: 0;
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
  font-size: var(--fs-lg);
  line-height: 1;
}

.btn-icon:hover { background: var(--surface-3); color: var(--text); }

.btn-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* ----------------------------------------------------------------- inputs */

.input, .textarea, .select {
  width: 100%;
  min-height: 2.125rem;
  padding: var(--sp-1) var(--sp-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input:focus, .textarea:focus, .select:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.textarea { resize: vertical; line-height: 1.5; padding: var(--sp-2); }

.input-invalid, .input-invalid:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

.field-error {
  margin-top: var(--sp-1);
  color: var(--danger);
  font-size: var(--fs-xs);
}

label, .label {
  display: block;
  margin-bottom: var(--sp-1);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.hint { color: var(--text-faint); font-size: var(--fs-xs); }

/* --------------------------------------------------------------- segmented */

.segmented {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.segmented button {
  min-height: 2rem;
  padding: 0 var(--sp-3);
  border: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  cursor: pointer;
}

.segmented button:last-child { border-right: 0; }
.segmented button:hover { background: var(--surface-3); }

.segmented button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

/* ----------------------------------------------------------------- toasts */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(var(--sp-5) + env(safe-area-inset-bottom) + var(--keyboard-inset, 0px));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  max-width: min(90vw, 26rem);
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  pointer-events: auto;
  animation: toast-in 160ms ease;
}

.toast-error { border-color: var(--danger); }
.toast button { pointer-events: auto; }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(0.5rem); }
  to   { opacity: 1; transform: none; }
}

/* --------------------------------------------------------------- utilities */

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

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

/* ------------------------------------------------------------------- chips */

/* Filter chips and tag chips: on the board, in Fichiers, in every panel. */

.filter-group {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-width: 0;
}

.filter-group > .label { margin: 0; flex: 0 0 auto; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
}

.chip {
  min-height: 1.75rem;
  padding: 0 var(--sp-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  cursor: pointer;
}

.chip:hover { border-color: var(--border-strong); color: var(--text); }

.chip[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 600;
}

.tag-chip {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 var(--sp-2);
  border: 1px solid currentColor;
  border-radius: 999px;
  color: var(--text-muted);
  font-size: var(--fs-xs);
}

/* In the task's dialog, with the button that takes the tag off. */
.tag-chip-editable {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.125rem var(--sp-1) 0.125rem var(--sp-2);
  font-size: var(--fs-sm);
}

.tag-chip-editable button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0 0.125rem;
  font-size: var(--fs-md);
  line-height: 1;
  opacity: 0.7;
}

.tag-chip-editable button:hover { opacity: 1; }
