/*
 * Components — boutons, cartes recette, badges, cadenas, formulaires,
 * tableaux, pagination, flash, modale de confirmation, bandeau disclaimer.
 * Charge après tokens.css + base.css.
 */

/* ---------- Boutons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  min-height: 2.75rem;
  padding: var(--sp-3) var(--sp-5);
  border-radius: var(--radius-pill);
  border: 1px solid transparent;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: var(--fs-sm);
  text-decoration: none;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
    border-color var(--dur-fast) var(--ease-out),
    color var(--dur-fast) var(--ease-out),
    transform var(--dur-fast) var(--ease-out);
}

.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: var(--vv-white); }
.btn-primary:hover { background: var(--accent-strong); color: var(--vv-white); }

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border-color: var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-subtle); color: var(--fg); }

.btn-ghost { background: transparent; color: var(--accent-strong); }
.btn-ghost:hover { background: var(--accent-tint); color: var(--accent-strong); }

.btn-danger { background: var(--danger); color: var(--vv-white); }
.btn-danger:hover { background: #7f1e17; color: var(--vv-white); }

.btn-sm { min-height: 2.25rem; padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); }

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-self: flex-start; /* jamais étiré par un parent .stack (flex column, align-items: stretch) */
  align-items: center;
  gap: var(--sp-1);
  padding: 0.2em 0.7em;
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  font-weight: 700;
  line-height: 1.4;
  border: 1px solid transparent;
}

.badge--category { background: var(--accent-tint); color: var(--accent-strong); border-color: rgba(147, 68, 26, 0.25); }
.badge--season { background: var(--ok-tint); color: var(--ok-strong); border-color: rgba(63, 107, 58, 0.25); }
.badge--difficulty { background: var(--bg-subtle); color: var(--fg); border-color: var(--border-strong); }
.badge--kit {
  background: var(--vv-ink);
  color: var(--vv-white);
}

.badge__icon { width: 0.9em; height: 0.9em; flex-shrink: 0; }

/* ---------- Cartes recette ---------- */

.recipe-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}

.recipe-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.recipe-card__media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: var(--bg-subtle);
}

.recipe-card__media picture {
  display: block;
  width: 100%;
  height: 100%;
}

.recipe-card__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.recipe-card__badges {
  position: absolute;
  top: var(--sp-3);
  left: var(--sp-3);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.recipe-card__body {
  padding: var(--sp-4) var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  flex: 1;
}

.recipe-card__title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 600;
  margin: 0;
}

.recipe-card__title a {
  color: var(--fg);
  text-decoration: none;
}

.recipe-card__title a::after {
  /* Étend la cible cliquable à toute la carte */
  content: "";
  position: absolute;
  inset: 0;
}

.recipe-card { position: relative; }

.recipe-card__title a:hover { color: var(--accent-strong); }

.recipe-card__meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: auto;
}

/* Variante verrouillée (réservé au kit) */

.recipe-card--locked .recipe-card__media {
  position: relative;
}

.recipe-card--locked .recipe-card__media img {
  filter: grayscale(35%) brightness(0.85);
}

.recipe-card__lock {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to top, rgba(27, 27, 27, 0.55), rgba(27, 27, 27, 0.05));
}

.recipe-card__lock-icon {
  width: 2.5rem;
  height: 2.5rem;
  padding: var(--sp-2);
  border-radius: 50%;
  background: rgba(250, 247, 240, 0.92);
  color: var(--vv-ink);
}

.recipe-card--locked .recipe-card__title a { color: var(--fg-muted); }
.recipe-card--locked .recipe-card__title a:hover { color: var(--accent-strong); }

/* ---------- Cadenas générique (fiche recette réservée) ---------- */

.locked-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--sp-4);
  max-width: 32rem;
  margin-inline: auto;
  padding: var(--sp-7) var(--sp-5);
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.locked-panel__icon {
  width: 3rem;
  height: 3rem;
  color: var(--accent-strong);
}

/* ---------- Fiche recette : photo, métadonnées, sélecteur de convives ---------- */

.recipe-detail__figure {
  margin: 0;
}

.recipe-detail__figure picture {
  display: block;
}

.recipe-detail__cover {
  display: block;
  width: 100%;
  max-height: 28rem;
  object-fit: cover;
  border-radius: var(--radius-lg);
}

.recipe-detail__figure figcaption {
  margin-top: var(--sp-2);
}

.recipe-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-5);
  margin: 0;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.recipe-meta-bar__item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: 0;
  color: var(--fg);
  font-weight: 600;
  font-size: var(--fs-sm);
}

.recipe-meta-bar__item svg {
  width: 1.25rem;
  height: 1.25rem;
  flex-shrink: 0;
  color: var(--accent-strong);
}

.portions-stepper__label {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--fg);
  display: block;
  margin-bottom: var(--sp-2);
}

.stepper {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  overflow: hidden;
  width: max-content;
}

.stepper__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--fg);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}

.stepper__btn:hover { background: var(--bg-subtle); }
.stepper__btn:active { background: var(--accent-tint); color: var(--accent-strong); }

.stepper__btn:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.stepper__input {
  width: 4rem;
  min-height: 2.75rem;
  padding: var(--sp-2);
  border: none;
  border-inline: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  -moz-appearance: textfield;
}

.stepper__input::-webkit-inner-spin-button,
.stepper__input::-webkit-outer-spin-button {
  margin: 0;
}

.stepper__input:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

/* ---------- Formulaires ---------- */

fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5) var(--sp-5);
  margin: 0 0 var(--sp-5);
}

legend {
  font-weight: 700;
  padding: 0 var(--sp-2);
  font-size: var(--fs-sm);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  margin-bottom: var(--sp-5);
}

.field label,
.field legend {
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--fg);
}

.field__hint {
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  margin: 0;
}

.field__required {
  color: var(--accent-strong);
  font-weight: 700;
}

.field input[type="text"],
.field input[type="email"],
.field input[type="tel"],
.field input[type="url"],
.field input[type="password"],
.field input[type="number"],
.field input[type="search"],
.field input[type="date"],
.field textarea,
.field select {
  min-height: 2.75rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--fg);
  font-family: inherit;
  font-size: 1rem;
}

.field textarea { min-height: 8rem; resize: vertical; }

.field input:focus-visible,
.field textarea:focus-visible,
.field select:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 1px;
}

.field--error input,
.field--error textarea,
.field--error select {
  border-color: var(--danger);
}

.field__error {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-2);
  color: var(--danger);
  font-size: var(--fs-sm);
  font-weight: 600;
  margin: 0;
}

.field__error svg { width: 1.1em; height: 1.1em; flex-shrink: 0; margin-top: 0.15em; }

.checkbox-group,
.radio-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}

.checkbox-row,
.radio-row {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
}

.checkbox-row input,
.radio-row input {
  margin-top: 0.2em;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.form-actions {
  display: flex;
  gap: var(--sp-3);
  flex-wrap: wrap;
  margin-top: var(--sp-6);
}

.error-summary {
  border: 2px solid var(--danger);
  background: var(--danger-tint);
  border-radius: var(--radius-md);
  padding: var(--sp-4) var(--sp-5);
  margin-bottom: var(--sp-6);
}

.error-summary h2 {
  font-size: var(--fs-md);
  font-family: var(--font-body);
  color: var(--danger);
  margin-bottom: var(--sp-2);
}

.error-summary ul { margin: 0; padding-left: 1.1em; }
.error-summary a { color: var(--danger); font-weight: 600; }

/* ---------- Tableaux ---------- */

.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}

th, td {
  text-align: left;
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-weight: 700;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.75rem;
  white-space: nowrap;
}

tbody tr:hover { background: var(--bg-subtle); }

/* ---------- Pagination ---------- */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding-top: var(--sp-6);
}

.pagination a,
.pagination span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0 var(--sp-2);
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--fg);
  font-weight: 600;
  font-size: var(--fs-sm);
}

.pagination a:hover { background: var(--bg-subtle); }

.pagination [aria-current="page"] {
  background: var(--accent);
  color: var(--vv-white);
}

.pagination .is-disabled {
  color: var(--fg-muted);
  opacity: 0.5;
}

/* ---------- Flash / notices ---------- */

.banner {
  padding: var(--sp-3) var(--gutter);
  text-align: center;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.banner--success { background: var(--ok-tint); color: var(--ok-strong); }
.banner--error { background: var(--danger-tint); color: var(--danger); }

.notice {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--sp-5);
  border: 1px solid transparent;
}

.notice svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; margin-top: 0.1em; }

.notice-warn { background: var(--danger-tint); color: var(--danger); border-color: rgba(163, 39, 30, 0.25); }
.notice-info { background: var(--accent-tint); color: var(--accent-strong); border-color: rgba(147, 68, 26, 0.25); }
.notice-ok { background: var(--ok-tint); color: var(--ok-strong); border-color: rgba(63, 107, 58, 0.25); }

/* ---------- Bandeau disclaimer nutrition ---------- */

.disclaimer {
  display: flex;
  gap: var(--sp-3);
  align-items: flex-start;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
}

.disclaimer svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; color: var(--accent-strong); }
.disclaimer strong { color: var(--fg); }
.disclaimer p { margin: 0; }

/* ---------- Modale de confirmation ---------- */

.confirm-dialog {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow-lg);
  max-width: 26rem;
  width: calc(100% - 2rem);
  color: var(--fg);
  background: var(--bg-raised);
}

.confirm-dialog::backdrop {
  background: rgba(27, 27, 27, 0.55);
}

.confirm-dialog__body { padding: var(--sp-6); }

.confirm-dialog h2 { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }

.confirm-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-3);
  margin-top: var(--sp-6);
}

/* ---------- Auth card (admin login / TOTP) ---------- */

.auth-card {
  max-width: 24rem;
  margin: var(--sp-9) auto;
  padding: var(--sp-7);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  box-shadow: var(--shadow-sm);
}

.auth-card .sub { color: var(--fg-muted); margin-top: calc(-1 * var(--sp-2)); }

/* ---------- Aide contextuelle ---------- */

.help-box {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-left: 3px solid var(--accent);
  background: var(--accent-tint);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  font-size: var(--fs-sm);
  color: var(--fg);
  margin-bottom: var(--sp-5);
}

.help-box svg { width: 1.25rem; height: 1.25rem; flex-shrink: 0; color: var(--accent-strong); }
.help-box p { margin: 0; }

/* ---------- Éditeur de texte simple ---------- */

.editor {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-raised);
}

.editor__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-1);
  padding: var(--sp-2);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
}

.editor__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
}

.editor__btn:hover { background: var(--bg-raised); border-color: var(--border-strong); }
.editor__btn[aria-pressed="true"] { background: var(--accent-tint); color: var(--accent-strong); border-color: transparent; }
.editor__btn svg { width: 1.1rem; height: 1.1rem; }

.editor__surface {
  min-height: 12rem;
  padding: var(--sp-4);
  outline: none;
  line-height: var(--lh-body);
}

.editor__surface:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: -3px;
}

.editor__surface h3 { font-size: var(--fs-md); margin: var(--sp-4) 0 var(--sp-2); }
.editor__surface p { margin: 0 0 var(--sp-3); }
.editor__surface ul { margin: 0 0 var(--sp-3); }

/* ---------- Plan de convives / calculatrice de portion ---------- */

.guest-plan { margin-bottom: var(--sp-4); }

.guest-plan__fields {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-4);
  margin: var(--sp-3) 0;
}

.guest-plan__fields .field { margin-bottom: 0; min-width: 8rem; flex: 1 1 8rem; }

.portion-calculator {
  margin-top: var(--sp-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
}

.portion-calculator summary {
  cursor: pointer;
  font-weight: 600;
}

.portion-calculator[open] summary { margin-bottom: var(--sp-3); }

/* ---------- Filtres /recettes : puces, résumé, bloc avancé ---------- */

.recipe-filters__search { max-width: 32rem; }

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.chip {
  display: inline-flex;
}

.chip input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.chip label {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: var(--sp-2) var(--sp-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.chip input[type="checkbox"]:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--vv-white);
}

.chip input[type="checkbox"]:focus-visible + label {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ---------- Compose ton assiette : tuiles de choix ---------- */

/* Une tuile est un bouton radio déguisé : le choix reste un vrai champ de
   formulaire, donc la page fonctionne sans JavaScript et se navigue au
   clavier avec les flèches, comme n'importe quel groupe de radios. */

.tile-group {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.tile {
  display: inline-flex;
}

.tile input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.tile label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  justify-content: center;
  min-width: 7.5rem;
  min-height: 3.25rem;
  padding: var(--sp-2) var(--sp-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  background: var(--bg-raised);
  color: var(--fg);
  font-size: var(--fs-sm);
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out);
}

.tile__count {
  font-weight: 400;
  font-size: var(--fs-xs);
  color: var(--fg-muted);
}

.tile input[type="radio"]:checked + label {
  background: var(--accent-soft, #f3e2d6);
  border-color: var(--accent);
  color: var(--accent-strong, var(--accent));
}

.tile input[type="radio"]:checked + label .tile__count { color: inherit; }

.tile input[type="radio"]:focus-visible + label {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

/* « Au hasard » : présent dans chaque groupe, volontairement en retrait. */
.tile--hasard label {
  border-style: dashed;
  background: transparent;
  font-weight: 500;
  color: var(--fg-muted);
}

.assiette-role {
  border: 0;
  padding: 0;
  margin: var(--sp-5) 0 0;
}

.assiette-role legend { padding: 0; }
.assiette-role legend h2 { margin: 0 0 var(--sp-2); }

.plate-summary {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--bg-sunken, var(--bg-raised));
}

.plate-summary__item { display: flex; flex-direction: column; gap: 2px; }

.plate-summary__role {
  font-size: var(--fs-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}

.plate-summary__value { font-weight: 700; }

.plate-summary__actions { margin-left: auto; }

.chip__count {
  margin-left: var(--sp-1, 4px);
  font-weight: 400;
  opacity: 0.7;
}

.chip-more { display: inline-flex; flex-direction: column; }
.chip-more summary {
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-pill);
  font-size: var(--fs-sm);
  color: var(--fg-muted);
  cursor: pointer;
}
.chip-more[open] > .chip-group { margin-top: var(--sp-2); }

/* Le raccourci de saison est contextuel, pas une facette parmi d'autres. */
.chip--saison label { border-color: var(--accent); }

.filters-advanced {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}

.filters-advanced > summary {
  cursor: pointer;
  font-weight: 700;
}

.filters-advanced[open] > summary { margin-bottom: var(--sp-3); }

.active-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-4);
}

.active-filters__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 0.2em 0.4em 0.2em 0.8em;
  border-radius: var(--radius-pill);
  background: var(--accent-tint);
  color: var(--accent-strong);
  font-size: var(--fs-sm);
  font-weight: 600;
  text-decoration: none;
}

.active-filters__chip:hover { background: var(--accent); color: var(--vv-white); }

.active-filters__chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.4em;
  height: 1.4em;
}

.recipe-results-count {
  font-weight: 600;
  color: var(--fg-muted);
  margin-bottom: var(--sp-3);
}

.recipe-empty-state {
  padding: var(--sp-5);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  text-align: center;
}
