/* Composants du Figma (section « Design system ») : Bouton, Étiquette,
   Sur-titre, Bloc de code, Action IA / Barre IA, Encadré, Question FAQ, Badge
   hébergement, Drapeau France. Les partials sont dans app/views/components/. */

/* ── Bouton : Primary / Secondary / Ghost / Inverse × M / L ──────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: 10px var(--space-5);
  border: 0;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  line-height: 20px;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}

.btn--l {
  padding: 14px 22px;
  font-size: 17px;
  line-height: 24px;
  letter-spacing: -0.002em; /* -0,2 % */
}

.btn--primary {
  background: var(--bg-accent);
  color: var(--text-on-accent);
}

.btn--primary:hover {
  background: var(--bg-accent-hover);
  color: var(--text-on-accent);
}

/* Secondary : contour 1,5 px border/strong (la hauteur gagne 3 px, comme le Figma). */
.btn--secondary {
  background: transparent;
  color: var(--text-primary);
  border: 1.5px solid var(--border-strong);
}

.btn--secondary:hover {
  background: var(--bg-subtle);
  color: var(--text-primary);
}

.btn--ghost {
  background: transparent;
  color: var(--text-accent);
  padding-inline: 0;
}

.btn--ghost:hover {
  color: var(--bg-accent-hover);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.btn--inverse {
  background: var(--bg-inverse);
  color: var(--text-on-inverse);
}

.btn--inverse:hover {
  background: var(--bg-accent-hover);
  color: var(--text-on-accent);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ── Bouton qui se confirme (Figma « Prototype — Consentement ») ─────────── */
/* Le libellé et la confirmation (coche + « Accepté ») partagent la même case
   de grille : le bouton garde la largeur du libellé. .is-confirmed : le
   libellé monte de 16 px en se floutant, la confirmation arrive par le bas,
   le fond passe au vert (succès) ou au neutre foncé (--neutral, pour un
   refus ni puni ni mis en scène). 260 ms, courbe des réactions Figma. */
.btn-confirm {
  display: inline-grid;
  place-items: center;
  transition:
    background-color var(--duration-confirm) var(--ease-emphasized),
    border-color var(--duration-confirm) var(--ease-emphasized),
    color var(--duration-confirm) var(--ease-emphasized);
}

.btn-confirm__label,
.btn-confirm__done {
  grid-area: 1 / 1;
  transition:
    transform var(--duration-confirm) var(--ease-emphasized),
    opacity var(--duration-confirm) var(--ease-emphasized),
    filter var(--duration-confirm) var(--ease-emphasized);
}

.btn-confirm__done {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transform: translateY(16px);
  filter: blur(2px);
}

.btn-confirm__check {
  flex: none;
  width: 14px;
  height: 14px;
}

.btn-confirm.is-confirmed,
.btn-confirm.is-confirmed:hover {
  background: var(--success-text);
  border-color: var(--success-text);
  color: var(--text-on-success);
  text-decoration: none;
  cursor: default;
}

.btn-confirm--neutral.is-confirmed,
.btn-confirm--neutral.is-confirmed:hover {
  background: var(--bg-inverse);
  border-color: var(--bg-inverse);
  color: var(--text-on-inverse);
}

.btn-confirm.is-confirmed .btn-confirm__label {
  opacity: 0;
  transform: translateY(-16px);
  filter: blur(2px);
}

.btn-confirm.is-confirmed .btn-confirm__done {
  opacity: 1;
  transform: none;
  filter: none;
}

/* ── Interrupteur 40 × 24 (modale cookies) ───────────────────────────────── */
/* <button role="switch" aria-checked>. Éteint : fond bg/subtle, contour
   1,5 px border/strong, pastille text/muted à gauche. Allumé : bg/accent,
   pastille blanche à droite. Toujours actif (aria-disabled) : text/muted. */
.switch {
  position: relative;
  flex: none;
  width: 40px;
  height: 24px;
  padding: 0;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  cursor: pointer;
  transition:
    background-color var(--duration-switch) var(--ease-emphasized),
    border-color var(--duration-switch) var(--ease-emphasized);
}

.switch::after {
  content: "";
  position: absolute;
  top: 1.5px;
  left: 1.5px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-muted);
  transition:
    transform var(--duration-switch) var(--ease-emphasized),
    background-color var(--duration-switch) var(--ease-emphasized);
}

.switch[aria-checked="true"] {
  background: var(--bg-accent);
  border-color: var(--bg-accent);
}

.switch[aria-checked="true"]::after {
  background: var(--text-on-accent);
  transform: translateX(16px);
}

.switch[aria-disabled="true"] {
  background: var(--text-muted);
  border-color: var(--text-muted);
  cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
  .btn-confirm,
  .btn-confirm__label,
  .btn-confirm__done,
  .switch,
  .switch::after {
    transition: none;
  }

  .btn-confirm__done,
  .btn-confirm.is-confirmed .btn-confirm__label {
    transform: none;
    filter: none;
  }
}

/* ── Étiquette : Critique / Attention / Succès / Neutre / Accent / Plein ─── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-weight: 400;
  font-size: 10px;
  line-height: 14px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.tag--critical { background: var(--critical-subtle); color: var(--critical-text); }
.tag--warning { background: var(--warning-subtle); color: var(--warning-text); }
.tag--success { background: var(--success-subtle); color: var(--success-text); }
.tag--neutral { background: var(--bg-subtle); color: var(--text-secondary); }
.tag--accent { background: var(--bg-accent-subtle); color: var(--text-accent); }
.tag--solid { background: var(--critical-fill); color: var(--text-on-accent); }

/* ── Sur-titre : puce carrée 8 px + Label/M accent ───────────────────────── */
.overline {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-accent);
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 11px;
  line-height: 16px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.overline::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--bg-accent);
}

/* Variante sans puce (sur-titres de section du Figma en Label/S). */
.overline--plain::before {
  display: none;
}

/* ── Bloc de code ────────────────────────────────────────────────────────── */
.code-block {
  background: var(--code-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.code-block__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: 10px var(--space-5);
  border-bottom: 1px solid var(--code-border);
  color: var(--code-muted);
}

.code-block__copy {
  padding: var(--space-2) var(--space-3);
  background: transparent;
  border: 1px solid var(--code-border);
  border-radius: var(--radius-xs);
  color: var(--code-accent);
  cursor: pointer;
}

.code-block__copy:hover {
  border-color: var(--code-accent);
}

.code-block__body {
  margin: 0;
  padding: var(--space-5) var(--space-6);
  overflow-x: auto;
  color: var(--code-text);
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 21px;
  white-space: pre;
}

.code-block__body code {
  font: inherit;
}

.code-block__body .muted { color: var(--code-muted); }
.code-block__body .accent { color: var(--code-accent); }

/* ── Barre IA (« Lire avec une IA ») ─────────────────────────────────────── */
.ai-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

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

.ai-action {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-full);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  line-height: 19px;
  cursor: pointer;
}

.ai-action:hover {
  border-color: var(--border-accent);
  color: var(--text-accent);
}

/* « Copier pour un LLM » se confirme comme les boutons du bandeau cookies
   (.btn-confirm, WP #18365) : .ai-action, déclaré après, remettait du flex.
   La pastille rogne le libellé qui monte et la coche qui arrive. */
.ai-action.btn-confirm {
  display: inline-grid;
  overflow: clip;
}

/* ── Encadré : Info / Attention / Critique (filet 3 px à gauche) ─────────── */
.callout {
  display: flex;
  background: var(--bg-accent-subtle);
}

.callout::before {
  content: "";
  flex: none;
  width: 3px;
  background: var(--bg-accent);
}

.callout__content {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-5) var(--space-6);
}

.callout__title {
  color: var(--text-primary);
}

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

.callout--warning { background: var(--warning-subtle); }
.callout--warning::before { background: var(--warning-text); }
.callout--critical { background: var(--critical-subtle); }
.callout--critical::before { background: var(--critical-fill); }

/* ── Question FAQ (<details> natif) ──────────────────────────────────────── */
/* Figma : 20 px haut/bas, 12 px entre question et réponse, filet en haut. */
.faq {
  border-top: 1px solid var(--border-default);
  padding: 20px 0;
}

/* Pas de filet sous la dernière question (pages CVE, écosystèmes, comparatifs). */

.faq__question {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-7);
  list-style: none;
  cursor: pointer;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  line-height: 26px;
  letter-spacing: -0.005em;
}

.faq__question::-webkit-details-marker {
  display: none;
}

/* +/− : deux traits de 13,5 × 2,5 px mesurés sur le glyphe « + » du Figma
   (Schibsted Grotesk 600, 26/32) dans une case de 16 × 32 px. À l'ouverture,
   le trait vertical tourne de 90° et se couche sur l'horizontal (WP #18365) ;
   .is-closing (faq_controller.js) le relève dès le début de la fermeture. */
.faq__icon {
  position: relative;
  flex: none;
  width: 16px;
  height: 32px;
  color: var(--text-accent);
}

.faq__icon::before,
.faq__icon::after {
  content: "";
  position: absolute;
  top: 15px;
  left: 2px;
  width: 13.5px;
  height: 2.5px;
  background: currentColor;
}

.faq__icon::after {
  transform: rotate(90deg);
  transition: transform var(--duration-confirm) var(--ease-emphasized);
}

.faq[open]:not(.is-closing) .faq__icon::after {
  transform: rotate(180deg);
}

@media (prefers-reduced-motion: reduce) {
  .faq__icon::after {
    transition: none;
  }
}

.faq__answer {
  max-width: 680px;
  margin-top: var(--space-4);
  color: var(--text-secondary);
  font-size: 17px;
  line-height: 27px;
}

.faq__answer a {
  color: var(--text-accent);
}

/* ── Badge hébergement + drapeau qui ondule ──────────────────────────────── */
.hosting-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  line-height: 19px;
  color: var(--text-primary);
}

.hosting-badge--on-navy {
  color: var(--text-on-accent);
}

/* 15 tranches de 2 px, 5 par couleur (bleu #000091, blanc, rouge #e1000f) :
   trois tiers de 10 px qui remplissent exactement la boîte de 30 px. Les
   tranches sont décalées en vague comme la variante « Mouvement=Vague » ;
   immobile si l'utilisateur réduit les animations. (Avec 12 tranches de 3 px,
   soit 36 px, overflow: hidden rognait 6 px du rouge.) */
.flag-fr {
  display: inline-flex;
  align-items: flex-start;
  width: 30px;
  height: 22px;
  padding-top: 1px;
  overflow: hidden;
  border-radius: 1.5px;
}

.flag-fr span {
  display: block;
  width: 2px;
  height: 20px;
  flex: none;
  animation: flag-wave 1.6s ease-in-out infinite;
  /* Une période de vague (1,6 s) répartie sur les 15 tranches. */
  animation-delay: calc(var(--i) * -0.1067s);
}

.flag-fr span:nth-child(-n + 5) { background: #000091; }
.flag-fr span:nth-child(n + 6):nth-child(-n + 10) { background: #ffffff; }
.flag-fr span:nth-child(n + 11) { background: #e1000f; }

@keyframes flag-wave {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(2px); }
}

@media (prefers-reduced-motion: reduce) {
  .flag-fr span { animation: none; }
}

/* ── Mascotte ────────────────────────────────────────────────────────────── */
/* SVG en ligne (components/_mascot.html.erb), animé comme le logo du
   dashboard : l'œil cligne seul, logo_eye_controller.js pose lw-winking au
   survol (clin d'œil, tête penchée) et lw-crying au clic (rouge, paupière
   triste, larmes). L'humeur Alerte (mascot--alerte) pleure en continu :
   rouge, paupière baissée, larmes qui coulent en boucle. Distances en unités du
   viewBox 100 × 100. La tête penchée déborde un peu de la boîte : visible. */
.mascot {
  flex: none;
  overflow: visible;
}

.mascot .lw-blink {
  transform-origin: 37.84px 43.97px;
  animation: lw-blink 7s 2s ease-in-out infinite;
}

.mascot .lw-head {
  transform-origin: 50px 60px;
}

.mascot.lw-winking .lw-blink {
  animation: lw-wink 0.5s ease-in-out;
}

.mascot.lw-winking .lw-head {
  animation: lw-tilt 0.5s ease-in-out;
}

.mascot .lw-back,
.mascot .lw-side,
.mascot .lw-pupil {
  transition: fill 0.3s;
}

.mascot .lw-skin stop {
  transition: stop-color 0.3s;
}

.mascot.lw-crying .lw-back { fill: #7f1d1d; }
.mascot.lw-crying .lw-side { fill: #b91c1c; }
.mascot.lw-crying .lw-pupil { fill: #450a0a; }
.mascot.lw-crying .lw-skin-1 { stop-color: #ff8080; }
.mascot.lw-crying .lw-skin-2 { stop-color: #f25c5c; }
.mascot.lw-crying .lw-skin-3 { stop-color: #e53e3e; }
.mascot.lw-crying .lw-skin-4 { stop-color: #dc3030; }

.mascot .lw-lid {
  transform: translateY(-22px);
  transition: transform 0.3s;
}

.mascot.lw-crying .lw-lid,
.mascot--alerte .lw-lid {
  transform: none;
}

.mascot .lw-tear {
  opacity: 0;
}

.mascot--alerte .lw-tear {
  opacity: 1;
}

.mascot.lw-crying .lw-head,
.mascot--alerte .lw-head {
  animation: lw-sob 0.5s ease-in-out infinite;
}

.mascot.lw-crying .lw-tear,
.mascot--alerte .lw-tear {
  animation: lw-tear 1s ease-in infinite;
}

.mascot.lw-crying .lw-tear-late,
.mascot--alerte .lw-tear-late {
  animation-delay: 0.5s;
}

@keyframes lw-blink {
  0%, 4%, 100% { transform: none; }
  2% { transform: scaleY(0.08); }
}

@keyframes lw-wink {
  0%, 100% { transform: none; }
  25%, 65% { transform: scaleY(0.08); }
}

@keyframes lw-tilt {
  0%, 100% { transform: none; }
  25%, 65% { transform: rotate(-7deg); }
}

@keyframes lw-sob {
  0%, 100% { transform: none; }
  50% { transform: translateY(1.2px); }
}

@keyframes lw-tear {
  0% { opacity: 0; transform: scale(0.3); }
  15% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateY(24px); }
}

/* Mouvement réduit : ni clignement, ni tête qui bouge, ni larmes qui
   coulent ; les couleurs changent quand même et les larmes restent posées. */
@media (prefers-reduced-motion: reduce) {
  .mascot .lw-blink,
  .mascot .lw-head,
  .mascot .lw-tear {
    animation: none !important;
  }

  .mascot .lw-lid {
    transition: none;
  }

  .mascot.lw-crying .lw-tear {
    opacity: 1;
  }
}

/* ── Champ de formulaire (composant « Champ », Figma 122:480) ────────────── */
/* États Défaut / Focus / Erreur, mesurés le 22/10/2026 : libellé Body/S
   Strong, 8 px d'écart, champ surface + Body/M (12 px × 14 px de marge
   intérieure, filet 2 px border/accent au focus, critical/fill en erreur),
   aide Body/XS muted (critical/text en erreur). Le filet passe de 1 à 2 px :
   la marge intérieure perd 1 px pour que le champ garde ses 55 px de haut. */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  min-width: 0;
}

.field__label {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  line-height: 23px;
  color: var(--text-primary);
}

.field__input {
  width: 100%;
  min-width: 0;
  padding: 13px 15px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-weight: 400;
  font-size: 17px;
  line-height: 27px;
}

.field__input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.field__input:focus,
.field__input:focus-visible {
  outline: none;
  padding: var(--space-4) 14px;
  border: 2px solid var(--border-accent);
}

.field__input[aria-invalid="true"] {
  padding: var(--space-4) 14px;
  border: 2px solid var(--critical-fill);
}

.field__hint,
.field__error {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 13px;
  line-height: 19px;
  color: var(--text-muted);
}

.field__error {
  color: var(--critical-text);
}
