/* Composants partagés par l'application et la page de présentation. */

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: inherit;
  text-decoration: none;
}

/* Logo complet ark.church (pictogramme et nom sur deux lignes), version blanche sur prune. */
.wordmark-logo {
  display: block;
  width: auto;
  height: 42px;
}

/* ------------------------------------------------------------ boutons */

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  background: var(--primary);
  color: var(--on-primary);
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease-out;
}

.button:hover {
  background: var(--primary-hover);
}

.button:active {
  background: var(--prune-800);
}

.button .icon {
  width: 18px;
  height: 18px;
}

.button.secondary {
  background: var(--bg-surface);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.button.secondary:hover {
  background: var(--bg-sunken);
}

.button.quiet {
  background: none;
  color: var(--primary);
  padding: 0 var(--space-2);
}

.button.quiet:hover {
  background: var(--primary-soft);
}

.button.small {
  min-height: 32px;
  padding: 0 var(--space-3);
  font-size: var(--text-s);
}

@media (pointer: coarse) {
  .button.small {
    min-height: 44px;
  }
}

.button.on-dark {
  background: var(--bg-surface);
  color: var(--prune-900);
}

.button.on-dark:hover {
  background: var(--primary-soft);
}

.button:disabled {
  background: var(--bg-sunken);
  border-color: var(--border);
  color: var(--text-muted);
  cursor: not-allowed;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: var(--control-height);
  height: var(--control-height);
  border: 0;
  border-radius: var(--radius-m);
  background: none;
  color: inherit;
  cursor: pointer;
}

.icon-button:hover {
  background: var(--bg-sunken);
}

/* ------------------------------------------------------------ puces de statut */

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px 2px 6px;
  border-radius: 999px;
  font-size: var(--text-s);
  font-weight: 500;
  white-space: nowrap;
}

.chip .icon {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.chip-ok {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.chip-waiting,
.chip-warning {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.chip-open {
  background: var(--lake-soft);
  color: var(--lake);
}

.chip-declined {
  background: var(--color-error-soft);
  color: var(--color-error);
}

.chip-neutral {
  padding-left: 9px;
  background: var(--bg-sunken);
  color: var(--text-secondary);
}

/* ------------------------------------------------------------ champs */

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: var(--text-s);
  font-weight: 500;
  color: var(--text-secondary);
}

/* Le padding de droite des listes déroulantes appartient à select.css (flèche à 12 px du bord) :
   on ne règle ici que le haut, le bas et la gauche, et la couleur de fond sans le raccourci background. */
.input,
.field input:not([type="checkbox"], [type="radio"]),
.field select,
.field textarea {
  width: 100%;
  min-height: var(--control-height);
  padding-block: 8px;
  padding-inline-start: var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background-color: var(--bg-surface);
  transition: border-color 0.15s ease-out, box-shadow 0.15s ease-out;
  font-size: 16px;
  font-weight: 400;
  color: var(--text-primary);
}

.input:not(select),
.field :is(input, textarea) {
  padding-inline-end: var(--space-3);
}

.input:hover,
.field :is(input, select, textarea):hover {
  border-color: var(--text-muted);
}

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

.field textarea {
  resize: vertical;
}

.form-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.form-grid .wide {
  grid-column: 1 / -1;
}

@media (min-width: 601px) {
  .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.form-flow {
  display: grid;
  gap: var(--space-5);
  min-width: 0;
}

.form-section {
  display: grid;
  gap: var(--space-3);
  min-width: 0;
  margin: 0;
}

.form-section + .form-section {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.form-section > :is(h3, h4),
.form-section > summary {
  color: var(--primary);
  font-size: var(--text-m);
  font-weight: 600;
}

details.form-section > summary {
  cursor: pointer;
}

details.form-section[open] > summary {
  margin-bottom: var(--space-3);
}

.form-hint,
.form-optional,
.form-error {
  color: var(--text-secondary);
  font-size: var(--text-s);
  font-weight: 400;
}

.form-error {
  color: var(--color-error);
}

.form-error:empty,
.field[hidden],
.form-section[hidden] {
  display: none;
}

.field :is(input, textarea, select)[aria-invalid="true"] {
  border-color: var(--color-error);
}

.person-suggest {
  display: grid;
  gap: var(--space-2);
  min-width: 0;
}

.person-suggest-results:empty {
  display: none;
}

.person-suggest-results .list {
  padding-inline: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  background: var(--bg-surface);
}

.person-suggest-results .row-button {
  overflow-wrap: anywhere;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 32px;
  font-weight: 400;
  color: var(--text-primary);
}

.check input {
  width: 18px;
  height: 18px;
  flex: none;
  accent-color: var(--primary);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-m);
  background: var(--bg-sunken);
}

.segmented button {
  min-height: 32px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: 7px;
  background: none;
  font-size: var(--text-s);
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
}

@media (pointer: coarse) {
  .segmented button {
    min-height: 44px;
  }
}

.segmented button[aria-pressed="true"],
.segmented button[aria-selected="true"] {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px oklch(0.3 0.03 335 / 0.14);
}

/* ------------------------------------------------------------ avatars et tuile de date */

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--prune-800);
  font-size: 12px;
  font-weight: 600;
}

.avatar.large {
  width: 56px;
  height: 56px;
  font-size: 18px;
  background: var(--primary);
  color: var(--on-primary);
}

.avatar.child {
  background: var(--amber-soft);
  color: var(--color-warning);
}

/* Tuile de date en forme d'arche, chiffres en serif comme sur un tableau des cantiques. */
.date-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  flex: none;
  width: 52px;
  height: 62px;
  padding-bottom: 7px;
  border-radius: var(--radius-arch);
  background: var(--primary-soft);
  color: var(--prune-800);
  line-height: 1;
}

.date-tile strong {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 400;
}

.date-tile span {
  margin-top: 3px;
  font-size: 12px;
}

/* ------------------------------------------------------------ fenêtres de dialogue */

dialog {
  padding: 0;
  border: 0;
  color: var(--text-primary);
  background: var(--bg-surface);
}

dialog::backdrop {
  background: oklch(0.2 0.05 335 / 0.5);
}

/* La fenêtre reçoit le focus à l'ouverture : son contour suffit à la situer. */
dialog:focus-visible {
  outline: none;
}

.modal {
  width: min(560px, calc(100vw - 32px));
  max-height: min(760px, calc(100dvh - 32px));
  border-radius: var(--radius-l);
  box-shadow: var(--shadow-float);
}

.modal.wide {
  width: min(760px, calc(100vw - 32px));
}

.modal[open] {
  display: flex;
  flex-direction: column;
  animation: modal-in 0.18s ease-out;
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-5) var(--space-4);
}

.modal-head h2 {
  overflow-wrap: anywhere;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 400;
  line-height: 1.2;
}

/* Le titre reçoit le focus à l’ouverture pour les lecteurs d’écran : pas de cadre visible sur un texte. */
dialog h2[tabindex="-1"]:focus {
  outline: 2px solid transparent;
}

.modal-head p {
  margin-top: 4px;
  color: var(--text-secondary);
}

.modal-head .icon-button {
  flex: none;
  margin: -8px -8px 0 0;
}

.modal-body {
  flex: 1;
  min-height: 0;
  scroll-padding-block: var(--space-3);
  padding: 0 var(--space-5) var(--space-5);
  overflow-y: auto;
}

.modal-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
}

.modal-foot .button,
.form-actions .button {
  max-width: 100%;
  min-width: 0;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  .modal :is(.modal-head, .modal-body, .modal-foot) {
    padding-inline: var(--space-4);
  }

  .modal-foot {
    padding-bottom: max(var(--space-3), env(safe-area-inset-bottom));
  }

  .modal[open]:has(form).form-keyboard {
    display: block;
    height: var(--form-visible-height);
    overflow-y: auto;
    scroll-padding-block: var(--space-4);
  }

  .modal.form-keyboard .modal-body {
    overflow: visible;
  }
}

@media (max-height: 520px) {
  .modal[open]:has(form) {
    display: block;
    overflow-y: auto;
    scroll-padding-block: var(--space-3);
  }

  .modal:has(form) .modal-body {
    overflow: visible;
  }
}

.modal-foot .foot-note {
  margin-right: auto;
  font-size: var(--text-s);
  color: var(--text-secondary);
}

.drawer {
  width: min(460px, 100vw);
  height: 100dvh;
  max-height: none;
  margin: 0 0 0 auto;
  overflow-y: auto;
  box-shadow: var(--shadow-float);
}

.drawer[open] {
  animation: drawer-in 0.22s ease-out;
}

@keyframes drawer-in {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

@media (max-width: 600px) {
  .modal,
  .modal.wide {
    width: 100vw;
    max-width: none;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
  }
}

/* ------------------------------------------------------------ notification */

.toast {
  position: fixed;
  left: 50%;
  bottom: var(--space-5);
  z-index: 50;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  max-width: min(520px, calc(100% - 32px));
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-m);
  background: var(--prune-950);
  color: var(--on-primary);
  transform: translateX(-50%);
  box-shadow: var(--shadow-float);
}

.toast .icon {
  color: var(--lake-bright);
}

/* ------------------------------------------------------------ listes */

.list {
  display: flex;
  flex-direction: column;
  margin: 0;
  padding: 0;
  list-style: none;
}

.list > li {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: var(--space-2) 0;
  border-top: 1px solid var(--border);
}

.list > li:first-child {
  border-top: 0;
}

.list small {
  display: block;
  font-size: var(--text-s);
  color: var(--text-secondary);
}

.grow {
  flex: 1;
  min-width: 0;
}

.muted {
  color: var(--text-secondary);
}

.numeric {
  font-variant-numeric: tabular-nums;
}

.row-button {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
}

.row-button:hover strong {
  color: var(--primary);
}

.row-button small {
  display: block;
  font-size: var(--text-s);
  color: var(--text-secondary);
}

.meter {
  display: block;
  height: 6px;
  border-radius: 3px;
  background: var(--bg-sunken);
  overflow: hidden;
}

.meter > span {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--primary);
}

/* ------------------------------------------------------------ micro-interactions
   Retours d'action courts (150 à 220 ms, ease-out), désactivés par prefers-reduced-motion (tokens.css). */

.button.on-dark,
.button.amber {
  --ark-relief-color: var(--amber);
}

.button.on-dark {
  --ark-relief-color: oklch(0.85 0.03 335);
}

.icon-button {
  transition: background-color 0.15s ease-out, transform 0.1s ease-out;
}

.icon-button:active {
  transform: scale(0.94);
}

.row-button > .icon:last-child,
.song > .icon:last-child,
.module-tabs .icon {
  transition: transform 0.18s ease-out, color 0.15s ease-out;
}

@media (hover: hover) {
  .row-button:hover > .icon:last-child,
  .song:hover > .icon:last-child {
    transform: translateX(3px);
    color: var(--primary);
  }
}

.row-button strong,
.song .grow {
  transition: color 0.15s ease-out;
}

.chip {
  transition: background-color 0.2s ease-out, color 0.2s ease-out;
}

.toast {
  animation: toast-in 0.22s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

.check input,
.segmented button {
  transition: background-color 0.15s ease-out, box-shadow 0.15s ease-out, color 0.15s ease-out;
}

/* ------------------------------------------------------------ choix guidés
   Propositions à cocher (plusieurs réponses possibles) et champ libre ouvert par « Autre ». */

.choice-field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.choice-field legend {
  padding: 0;
  margin-bottom: var(--space-2);
  font-size: var(--text-s);
  font-weight: 600;
}

.choice-hint {
  margin: calc(var(--space-1) * -1) 0 var(--space-2);
  font-size: var(--text-s);
  color: var(--text-secondary);
}

.choice-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.choice-chip {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  min-width: 0;
  cursor: pointer;
}

.choice-chip input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.choice-chip span {
  display: inline-flex;
  align-items: center;
  min-height: var(--control-height);
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--bg-surface);
  font-weight: 500;
  overflow-wrap: anywhere;
  transition: background-color 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out;
}

.choice-chip:hover span {
  border-color: var(--text-muted);
}

.choice-chip input:checked + span {
  border-color: var(--prune-900);
  background: var(--prune-900);
  color: var(--on-primary);
}

.choice-chip input:focus-visible + span {
  outline: 2px solid var(--lake);
  outline-offset: 2px;
}

.choice-other {
  margin-top: var(--space-3);
}

.suggest-field {
  position: relative;
  min-width: 0;
}

.suggest-field .form-hint:empty { display: none; }

.suggest-options {
  position: absolute;
  z-index: 4;
  inset: calc(100% + 4px) 0 auto;
  max-height: 210px;
  overflow: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-m);
  background: var(--bg-surface);
  list-style: none;
  scrollbar-width: thin;
}

.suggest-options [role="option"],
.suggest-options .suggest-empty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 9px;
  min-height: 44px;
  padding: 7px 9px;
  border-radius: var(--radius-s);
  overflow-wrap: anywhere;
}

.suggest-options [role="option"] {
  cursor: pointer;
  transition: background-color 130ms ease-out;
}

.suggest-options [role="option"]:hover,
.suggest-options [aria-selected="true"] { background: var(--primary-soft); }
.suggest-options small, .suggest-options .suggest-empty { color: var(--text-secondary); }

@media (prefers-reduced-motion: reduce) {
  .suggest-options [role="option"] { transition: none; }
}
