/* ==========================================================================
   Page « Votre avis » (avis.html). Préfixe .av-.
   Coque, jetons (--st-*) et boutons (.st-btn) : css/compte.css, comme « Paramètres » et « Ma classe ».
   Une feuille en deux parties : un panneau encre qui porte la note (étoiles corail) et un corps blanc pour le commentaire.
   Contrastes mesurés : crème sur encre 16:1, texte secondaire sur encre 10:1, contour d'une étoile vide 6,8:1, corail sur encre 5:1,
   erreur sur encre 9:1, contour du champ 3,7:1 sur blanc.
   ========================================================================== */

.avis-page {
  --av-plate: #14141a;
  --av-cream: #f7f2ea;
  --av-cream-soft: rgba(247, 242, 234, 0.78);
  --av-star-off: rgba(247, 242, 234, 0.62);
  --av-coral: #ef4a34;
  --av-warn: #ff9f8e;
}

/* « hidden » perd contre tout display d'auteur : on le rétablit pour toute la page. */
.avis-page [hidden] {
  display: none !important;
}

.avis-page ::selection {
  background: #fbd0c6;
  color: #14141a;
}

.avis-page .av-plate ::selection {
  background: rgba(239, 74, 52, 0.62);
  color: #fff;
}

.av-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

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

/* ---------- Mise en page : la feuille à gauche, ce qu'il faut savoir à droite ---------- */
.avis-page .st-head h1 {
  text-wrap: balance;
}

.avis-page .st-head__sub {
  max-width: 56ch;
  text-wrap: pretty;
}

/* « pensez-vous » ne se coupe pas au trait d'union : le titre passe à la ligne entre les mots. */
.av-nb {
  white-space: nowrap;
}

.av-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 17.5rem;
  gap: 56px;
  align-items: start;
}

.av-col {
  min-width: 0;
}

.av-aside {
  padding-top: 2px;
}

.av-notes {
  margin: 0;
  padding: 0;
  list-style: none;
}

.av-notes li {
  padding: 18px 0;
  border-top: 1px solid var(--st-line);
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--st-muted);
}

.av-notes li:first-child {
  padding-top: 0;
  border-top: 0;
}

.av-notes strong {
  display: block;
  margin-bottom: 2px;
  font-weight: 800;
  color: var(--st-ink);
}

.av-back {
  margin: 22px 0 0;
  font-size: 0.92rem;
  font-weight: 700;
}

.av-back a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--st-accent-text);
  text-decoration: none;
}

.av-back a:hover {
  text-decoration: underline;
  text-underline-offset: 0.25em;
}

/* ---------- La feuille : panneau encre + corps blanc ---------- */
.av-sheet {
  overflow: hidden;
  border-radius: 20px;
  background: var(--st-paper);
  box-shadow: 0 1px 2px rgba(20, 20, 26, 0.06), 0 26px 44px -30px rgba(20, 20, 26, 0.42);
  animation: avIn 0.26s var(--st-ease) both;
}

.av-plate {
  padding: 28px 32px 30px;
  background: var(--av-plate);
  color: var(--av-cream);
}

.av-body {
  padding: 28px 32px 32px;
  border: 1px solid var(--st-line);
  border-top: 0;
  border-radius: 0 0 20px 20px;
}

/* Le contour de focus du site est encre : invisible sur le panneau encre, on le passe en crème. */
.av-plate :focus-visible {
  outline-color: var(--av-cream);
}

/* ---------- La note ---------- */
.av-rate {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.av-rate legend,
.av-plate__title {
  display: block;
  margin: 0 0 14px;
  padding: 0;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0;
  color: var(--av-cream);
}

.av-stars {
  display: flex;
  gap: 6px;
  max-width: 100%;
}

.av-stars__input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.av-star {
  position: relative;
  display: grid;
  flex: 0 1 60px;
  place-items: center;
  min-width: 0;
  aspect-ratio: 1;
  border-radius: 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.av-star svg {
  width: 80%;
  height: 80%;
  fill: transparent;
  stroke: var(--av-star-off);
  stroke-width: 1.5;
  stroke-linejoin: round;
  transition: fill 0.16s ease, stroke 0.16s ease, transform 0.3s var(--st-ease);
}

.av-star.is-on svg {
  fill: var(--av-coral);
  stroke: var(--av-coral);
}

.av-star:active svg {
  transform: scale(0.92);
}

@media (hover: hover) and (pointer: fine) {
  .av-star:hover svg {
    transform: scale(1.08);
  }
}

.av-stars__input:focus-visible + .av-star {
  outline: 3px solid var(--av-cream);
  outline-offset: 1px;
}

/* Au choix d'une note, les étoiles se remplissent de gauche à droite, et celle qu'on a touchée rebondit : le seul mouvement de la page. */
.av-stars.is-picking .av-star svg {
  transition-delay: calc(var(--i, 0) * 38ms), calc(var(--i, 0) * 38ms), 0s;
}

.av-stars .av-star:nth-of-type(1) { --i: 0; }
.av-stars .av-star:nth-of-type(2) { --i: 1; }
.av-stars .av-star:nth-of-type(3) { --i: 2; }
.av-stars .av-star:nth-of-type(4) { --i: 3; }
.av-stars .av-star:nth-of-type(5) { --i: 4; }

.av-star.is-picked svg {
  animation: avPop 0.42s var(--st-ease);
}

.av-rate.is-invalid .av-star svg {
  stroke: var(--av-warn);
}

/* L'erreur prend la place de l'indication « Choisissez une note » : un seul message à la fois. */
.av-rate.is-invalid ~ .av-verdict.is-empty {
  display: none;
}

/* L'avis déjà enregistré : mêmes étoiles, sans interaction. */
.av-stars--static .av-star {
  flex-basis: 44px;
  cursor: default;
}

.av-stars--static .av-star:active svg {
  transform: none;
}

.av-verdict {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 12px;
  min-height: 2.1rem;
  margin: 16px 0 0;
}

.av-verdict__word {
  font-size: 1.6rem;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--av-cream);
}

.av-verdict__score {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--av-cream-soft);
  font-variant-numeric: tabular-nums;
}

.av-verdict.is-empty .av-verdict__word {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0;
  color: var(--av-cream-soft);
}

.av-rate-error {
  margin: 10px 0 0;
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.45;
  color: var(--av-warn);
}

.av-meta {
  margin: 6px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--av-cream-soft);
}

.av-flash {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 22px;
  color: var(--av-cream);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.av-flash:focus {
  outline: none;
}

.av-flash__icon {
  flex: none;
  width: 24px;
  height: 24px;
}

/* ---------- Le commentaire ---------- */
.av-field label {
  display: block;
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.3;
  color: var(--st-ink);
}

.av-opt {
  font-weight: 600;
  color: var(--st-muted);
}

.av-field textarea {
  display: block;
  width: 100%;
  min-height: 9.5rem;
  padding: 14px 16px;
  resize: vertical;
  border: 1.5px solid var(--st-field);
  border-radius: 12px;
  background: var(--st-paper);
  color: var(--st-ink);
  caret-color: var(--st-accent-text);
  font: inherit;
  font-size: 1rem;
  font-weight: 500;
  line-height: 1.6;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.av-field textarea::placeholder {
  color: #6b6b73;
  opacity: 1;
}

.av-field textarea:hover {
  border-color: var(--st-ink);
}

.av-field textarea:focus {
  outline: none;
  border-color: var(--st-accent-text);
  box-shadow: 0 0 0 4px rgba(239, 74, 52, 0.24);
}

.av-counter {
  margin: 8px 0 0;
  text-align: right;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.3;
  color: var(--st-muted);
  font-variant-numeric: tabular-nums;
}

.av-counter[data-level="near"] {
  color: var(--st-accent-text);
}

.av-counter[data-level="full"] {
  font-weight: 800;
  color: var(--st-danger);
}

/* ---------- Actions et messages ---------- */
.av-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  margin-top: 22px;
}

.av-send {
  min-height: 52px;
  padding: 0 30px;
  border-radius: 12px;
  font-size: 1.05rem;
}

.av-error {
  margin: 18px 0 0;
  padding: 12px 14px;
  border: 1px solid var(--st-danger-line);
  border-radius: 12px;
  background: var(--st-danger-soft);
  color: #6f130b;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.5;
}

.av-quote {
  max-width: 62ch;
  margin: 0;
  font-size: 1.05rem;
  font-weight: 500;
  line-height: 1.7;
  color: var(--st-ink);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.av-quote.is-none {
  color: var(--st-muted);
}

/* La confirmation prend la place des boutons : une question et deux réponses, sans boîte dans la feuille. */
.av-confirm {
  margin-top: 22px;
}

.av-confirm p {
  margin: 0;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.5;
  color: var(--st-danger);
}

.av-confirm .av-actions {
  margin-top: 12px;
}

.av-notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 18px;
  margin: 0 0 20px;
  padding: 16px 18px;
  border: 1px solid var(--st-danger-line);
  border-radius: 14px;
  background: var(--st-danger-soft);
  color: #6f130b;
  font-size: 0.97rem;
  font-weight: 600;
  line-height: 1.5;
}

.av-notice p {
  flex: 1 1 18rem;
  margin: 0;
}

/* ---------- Chargement : la feuille, en gris, à sa hauteur ---------- */
.av-skel {
  display: block;
  border-radius: 10px;
  background: rgba(247, 242, 234, 0.14);
  animation: avPulse 1.5s ease-in-out infinite;
}

.av-body .av-skel {
  background: rgba(20, 20, 26, 0.08);
}

.av-skel--label {
  width: 6.5rem;
  height: 1rem;
  margin-bottom: 18px;
}

.av-skel--stars {
  width: 100%;
  max-width: 20.5rem;
  height: 3.5rem;
}

.av-skel--verdict {
  width: 9rem;
  height: 1.6rem;
  margin-top: 18px;
}

.av-skel--field {
  width: 100%;
  height: 9.5rem;
  border-radius: 12px;
}

.av-skel--button {
  width: 11rem;
  height: 3.25rem;
  margin-top: 22px;
  border-radius: 12px;
}

@keyframes avIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes avPop {
  0% {
    transform: scale(0.82);
  }
  55% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes avPulse {
  50% {
    opacity: 0.55;
  }
}

/* ---------- Écrans étroits ---------- */
@media (max-width: 920px) {
  .av-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 36px;
  }

  .av-aside {
    max-width: 40rem;
  }
}

@media (max-width: 560px) {
  .av-sheet {
    border-radius: 18px;
  }

  .av-plate {
    padding: 22px 18px 24px;
  }

  .av-body {
    padding: 22px 18px 26px;
    border-radius: 0 0 18px 18px;
  }

  .av-verdict__word {
    font-size: 1.4rem;
  }

  .av-send {
    width: 100%;
  }

  .av-actions {
    gap: 6px 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .av-sheet,
  .av-star.is-picked svg,
  .av-skel {
    animation: none;
  }

  .av-star svg,
  .av-field textarea {
    transition: none;
  }

  .av-stars.is-picking .av-star svg {
    transition-delay: 0s;
  }
}
