/* Pikee — mobile-first, KISS, direction indigo/blanc 2026. */

:root {
  --bg: #f6f6f3;
  --surface: #ffffff;
  --text: #111111;
  /* Contraste WCAG AA (4.5:1 texte normal) vérifié : text-secondary sur
     --bg, success sur --surface (.ok), danger sur --danger-soft (.error) —
     cf. issue #46. */
  --text-secondary: #71716c;
  --primary: #5b5cf6;
  --primary-soft: #ededff;
  --accent: #c8ff5a;
  --success: #218652;
  --success-soft: #e4faf0;
  --danger: #d41e24;
  --danger-soft: #fdeaea;
  --border: #deded8;
  --shadow-sm: 0 10px 28px rgba(0, 0, 0, 0.06);
  --radius-lg: 20px;
  --radius-md: 18px;
  --radius-sm: 15px;
  /* Signature de forme : un coin moins arrondi que les trois autres,
     appliquée à toutes les surfaces "carte". */
  --radius-card: 24px 24px 10px 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button,
input,
textarea {
  font-family: inherit;
  color: inherit;
}

.app {
  min-height: 100vh;
  /* 100vh inclut la zone masquée par la barre d'adresse mobile : la page
     dépasse alors l'écran réellement visible et il faut scroller pour
     voir le footer. 100dvh (hauteur de viewport dynamique) correspond à
     l'espace effectivement visible ; on la surcharge en second pour
     rester compatible avec les navigateurs qui ne la supportent pas. */
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

.app-header {
  padding: 18px 20px 6px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  display: inline-block;
  position: relative;
}

.brand-dot::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  right: -3px;
  top: -3px;
  background: var(--accent);
  border: 1.5px solid var(--text);
}

/* Logo plus affirmé sur l'accueil, seul écran où la marque est le premier
   élément que l'on voit avant tout contenu. */
.app.is-home .brand {
  font-size: 2.6rem;
  gap: 13px;
}

.app.is-home .brand-dot {
  width: 35px;
  height: 35px;
}

.app.is-home .brand-dot::after {
  width: 14px;
  height: 14px;
  right: -7px;
  top: -7px;
  border-width: 2px;
}

.view-root {
  flex: 1;
  padding: 8px 20px 40px;
  display: flex;
}

.view {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (prefers-reduced-motion: no-preference) {
  .view {
    animation: fade-in 0.2s ease-out;
  }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* ---------- Typographie ---------- */

.hero-title {
  font-size: 2.75rem;
  line-height: 1;
  letter-spacing: -0.045em;
  font-weight: 900;
  /* Beaucoup d'air sous le logo (~52px au total avec le padding du header) :
     c'est ce vide qui donne à la marque un statut propre plutôt qu'un
     simple en-tête. */
  margin: 40px 0 0;
}

.hero-title .accent {
  color: var(--primary);
}

.view-title {
  font-size: 2.1rem;
  font-weight: 850;
  line-height: 1.05;
  letter-spacing: -0.03em;
  margin: 4px 0 0;
}

h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
}

.hero-note {
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-secondary);
  margin: 0;
  max-width: 340px;
}

/* Raccourcis mnémotechniques depuis l'accueil : leur rôle est autant de
   rappeler les situations où Pikee peut devenir le réflexe que de
   pré-remplir la question pour gagner un écran. */
.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.preset-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text);
  cursor: pointer;
}

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

.mini-badge {
  margin: 4px 0 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text);
}

.mini-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  border: 1.5px solid var(--text);
  display: inline-block;
  flex-shrink: 0;
}

.hint {
  color: var(--text-secondary);
  font-size: 0.98rem;
  line-height: 1.5;
  margin: 0;
}

.micro {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin: 0;
}

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

.btn {
  appearance: none;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1.05rem;
  font-weight: 750;
  min-height: 58px;
  padding: 14px 20px;
  cursor: pointer;
  transition: transform 0.08s ease;
  touch-action: manipulation;
}

.btn:active {
  transform: scale(0.97);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-big {
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}

.btn-primary:active {
  background: #4a4bd6;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

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

.btn-add {
  min-height: 50px;
}

.btn-link,
.link-btn {
  background: none;
  border: none;
  padding: 6px 0;
  color: var(--text-secondary);
  font-size: 0.95rem;
  font-weight: 600;
  align-self: flex-start;
  cursor: pointer;
}

.link {
  color: var(--primary);
  font-weight: 750;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-size: inherit;
}

/* ---------- Champs ---------- */

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-secondary);
}

/* Label accessible mais visuellement masqué : le contexte est déjà donné
   par un texte visible ailleurs (ex. « Pour répondre, indique ton prénom »
   au-dessus du champ). */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 15px 16px;
  font-size: 1.05rem;
  resize: none;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.14);
}

.error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 0.9rem;
  font-weight: 600;
  margin: 0;
}

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

.card {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

/* ---------- Options (création + aperçu) ---------- */

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.option-row input[type="text"] {
  flex: 1;
}

.option-remove {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
}

.option-remove:active {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.chips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  padding: 8px 14px;
  font-weight: 750;
  font-size: 0.9rem;
}

/* ---------- Vote ---------- */

/* Repères verbaux de l'échelle 0-10 : une seule légende partagée pour tout
   l'écran (pas répétée par option, ça surchargerait un vote à 8 options).
   Score faible = meilleur — jamais de couleur suggérant l'inverse ici. */
.scale-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.scale-legend b {
  color: var(--text);
  font-weight: 800;
}

.vote-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.vote-option {
  background: var(--surface);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-sm);
  padding: 18px;
}

.vote-option-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 12px;
}

.vote-option-name {
  font-weight: 750;
  font-size: 1.1rem;
  word-break: break-word;
  padding-right: 10px;
}

.vote-option-value {
  font-weight: 850;
  font-size: 1.9rem;
  color: var(--primary);
  min-width: 1.5ch;
  text-align: right;
}

.stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-btn {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  line-height: 1;
}

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

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary) 0%, var(--primary) var(--fill, 0%), var(--border) var(--fill, 0%), var(--border) 100%);
  outline: none;
}

/* outline:none ci-dessus supprime l'indicateur par défaut du navigateur —
   contrairement aux champs texte, il n'y avait aucun remplacement : au
   clavier, impossible de voir quel curseur de vote est focus. */
input[type="range"]:focus {
  box-shadow: 0 0 0 3px rgba(91, 92, 246, 0.14);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 6px solid var(--primary);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

input[type="range"]:focus::-webkit-slider-thumb {
  box-shadow: 0 0 0 4px rgba(91, 92, 246, 0.25), 0 1px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-thumb {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  border: 6px solid var(--primary);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}

input[type="range"]:focus::-moz-range-thumb {
  box-shadow: 0 0 0 4px rgba(91, 92, 246, 0.25), 0 1px 6px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-track {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
}

.scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
  color: var(--text-secondary);
  margin-top: 8px;
}

/* ---------- Attente ---------- */

.view-waiting {
  align-items: center;
  text-align: center;
  padding-top: 40px;
}

.spinner {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
}

@media (prefers-reduced-motion: no-preference) {
  .spinner {
    animation: spin 0.9s linear infinite;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ---------- Lobby (créateur·rice) ---------- */

.share-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.topline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  letter-spacing: 2px;
  font-size: 1.05rem;
}

.answer-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.person {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 0;
  border-bottom: 1px solid var(--border);
}

.person:last-child {
  border-bottom: none;
}

.person-name {
  font-weight: 650;
}

.ok {
  color: var(--success);
  font-weight: 800;
}

/* ---------- Résultats ---------- */
/* Le nom de l'option retenue est l'élément dominant ; le score
   d'objections vient toujours en second plan, jamais l'inverse
   (retour utilisateur : le score attirait plus l'œil que le nom).

   Une seule liste de lignes identiques du début à la fin (voir
   flipReorder() dans app.js) : les options se réordonnent sous les yeux
   (translateY, sans score visible), puis les scores apparaissent et la
   ligne gagnante se met en valeur — jamais l'inverse, sinon le résultat
   est visible avant la fin du mouvement. */

.result-list {
  display: flex;
  flex-direction: column;
}

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-height: 52px;
  padding: 4px 2px;
  border-bottom: 1px solid var(--border);
  font-size: 1.05rem;
}

.result-row:last-child {
  border-bottom: none;
}

.result-name {
  font-weight: 700;
}

.result-score {
  font-weight: 850;
  white-space: nowrap;
  color: var(--text-secondary);
  opacity: 0;
  transition: opacity 0.6s ease;
}

.result-score.is-revealed,
.result-row.is-winner .result-score {
  opacity: 1;
}

/* Ligne(s) gagnante(s) : même information que les autres, mise en valeur
   une fois le classement final atteint — pas un bloc séparé. */
.result-row.is-winner {
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  background: var(--primary);
  color: #fff;
  border-bottom: none;
  border-radius: var(--radius-card);
  padding: 24px 22px 26px;
  margin-bottom: 10px;
  animation: fade-in 0.6s ease-out;
}

.result-row.is-winner .result-tag {
  order: -1;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.045em;
  opacity: 0.92;
}

.result-row.is-winner .result-name {
  font-size: 3rem;
  line-height: 0.98;
  font-weight: 900;
  letter-spacing: -0.04em;
  word-break: break-word;
}

.result-row.is-winner .result-score {
  font-size: 1.2rem;
  color: #fff;
}

.result-row.is-winner .result-caption {
  margin: 0;
  font-size: 1rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.92);
  font-weight: 400;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--text);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  z-index: 20;
  max-width: 90vw;
  text-align: center;
}

/* ---------- Bottom sheet (info / confirmation) ---------- */

.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 17, 17, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 30;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sheet-overlay[hidden] {
  display: none;
}

.sheet-overlay.is-open {
  opacity: 1;
}

.sheet {
  width: min(100%, 440px);
  background: var(--surface);
  border-radius: 24px;
  padding: 22px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  gap: 14px;
  transform: translateY(16px);
  transition: transform 0.2s ease;
}

.sheet-overlay.is-open .sheet {
  transform: translateY(0);
}

.sheet-title {
  font-size: 1.4rem;
  font-weight: 800;
  margin: 0;
}

.sheet p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

.sheet strong {
  color: var(--text);
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Pied de page (toutes les vues) ---------- */

.app-footer {
  padding: 28px 20px 12px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
  line-height: 1.5;
}

.footer-line {
  font-weight: 700;
  color: #4f504f;
  margin-bottom: 8px;
}

.footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
}

.footer-links button {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.footer-links button:active {
  text-decoration: underline;
}

/* ---------- Pages statiques (Comment ça marche / Confidentialité) ---------- */

.lead {
  color: var(--text-secondary);
  font-size: 1.05rem;
  line-height: 1.45;
  margin: 0;
}

.card h2 {
  margin: 0 0 10px;
  font-size: 1.25rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
}

.card p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 1rem;
  line-height: 1.5;
}

.card p + p {
  margin-top: 10px;
}

.stack-steps {
  display: flex;
  flex-direction: column;
}

.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 15px 0;
  border-top: 1px solid var(--border);
}

.step:first-child {
  border-top: 0;
  padding-top: 4px;
}

.step .num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 850;
  flex: none;
}

.step b {
  display: block;
  margin-bottom: 4px;
  font-size: 1rem;
}

.step span {
  display: block;
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.45;
}

.scale-box {
  margin-top: 14px;
  background: var(--primary-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.scale-head {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--primary);
}

.scale-sub {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.notice {
  background: var(--primary);
  color: #fff;
  border-radius: var(--radius-card);
  padding: 20px;
}

.notice h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.notice p {
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 1rem;
  line-height: 1.45;
}

.list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--text-secondary);
}

.list li {
  margin: 8px 0;
  line-height: 1.45;
}

.inline-link {
  color: var(--primary);
  font-weight: 750;
  text-decoration: none;
}

.small {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

@media (min-width: 700px) {
  .app {
    min-height: 900px;
    margin: 28px auto;
    border-radius: 34px;
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.14);
  }
}
