/* ===== POLICES ===== */
@font-face {
  font-family: 'Bricolage Grotesque';
  src: url('../fonts/BricolageGrotesque-VariableFont.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'DM Sans';
  src: url('../fonts/DMSans-VariableFont.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}

/* ===== TOKENS ===== */
:root {
  --bg: #FFF8EE;
  --ink: #1B1B2F;
  --ink-light: #5A5A7A;
  --white: #FFFFFF;

  --coral: #FF6B4A;
  --yellow: #FFC93C;
  --green: #2BB673;
  --blue: #2F80ED;
  --pink: #FF5DA2;
  --teal: #14B8A6;

  --radius-sm: 12px;
  --radius-md: 20px;
  --radius-lg: 32px;

  --shadow: 0 4px 16px rgba(27,27,47,0.10);
  --shadow-lg: 0 8px 32px rgba(27,27,47,0.14);

  --transition: 200ms ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: 'DM Sans', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 700;
  line-height: 1.2;
}

/* ===== LAYOUT ===== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 24px 16px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container--wide {
  max-width: 1200px;
}

/* ===== BOUTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 28px;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--transition), filter var(--transition);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
@media (hover: hover) { .btn:hover { filter: brightness(0.95); } }

.btn--primary {
  background: var(--coral);
  color: white;
  box-shadow: 0 4px 14px rgba(255,107,74,0.28);
  width: 100%;
  padding: 20px;
  font-size: 1.2rem;
}

.btn--secondary {
  background: var(--white);
  color: var(--ink);
  border: 2px solid var(--ink);
  width: 100%;
  padding: 16px;
}

.btn--small {
  padding: 10px 18px;
  font-size: 0.9rem;
  width: auto;
}

.btn--green { background: var(--green); color: white; }
.btn--blue { background: var(--blue); color: white; }
.btn--yellow { background: var(--yellow); color: var(--ink); }

/* ===== CARTES ===== */
.card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

/* ===== FORMULAIRE ===== */
.field {
  margin-bottom: 20px;
}

.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  font-size: 0.95rem;
  color: var(--ink-light);
}

.field input,
.field textarea {
  width: 100%;
  padding: 16px;
  border: 2px solid #E0D8CC;
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 1.05rem;
  color: var(--ink);
  background: var(--bg);
  transition: border-color var(--transition);
  -webkit-appearance: none;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--coral);
}

.field textarea {
  resize: none;
  min-height: 120px;
  line-height: 1.6;
}

.char-counter {
  text-align: right;
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-top: 6px;
}

.char-counter.warning { color: var(--coral); font-weight: 600; }

/* ===== EN-TÊTE ===== */
.app-header {
  text-align: center;
  padding: 32px 0 24px;
}

.app-logo {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--ink);
  letter-spacing: -1px;
}

.app-logo span {
  color: var(--coral);
}

/* ===== CODE SESSION ===== */
.session-code {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 3.5rem;
  font-weight: 800;
  letter-spacing: 8px;
  text-align: center;
  color: var(--ink);
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow);
  margin: 16px 0;
}

/* ===== AVATAR ===== */
.avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
}

.avatar--lg {
  width: 80px;
  height: 80px;
  font-size: 2.2rem;
}

.avatar, .avatar-option { overflow: hidden; }
.avatar svg, .avatar-option svg { width: 100%; height: 100%; display: block; }

/* Grille de choix d'avatars */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin: 16px 0;
}

.avatar-option {
  aspect-ratio: 1;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  border: 3px solid transparent;
  padding: 0;
  background: none;
  transition: transform var(--transition), border-color var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.avatar-option:active { transform: scale(0.9); }
.avatar-option.selected { border-color: var(--ink); transform: scale(1.1); }

/* Palettes de couleurs */
.color-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 8px;
  margin: 12px 0;
}

.color-swatch {
  width: 100%;
  aspect-ratio: 1;
  max-width: 44px;
  justify-self: center;
  border-radius: 50%;
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform var(--transition);
}

.color-swatch.selected {
  border-color: var(--ink);
  transform: scale(1.15);
}

/* ===== SALLE D'ATTENTE ===== */
.participants-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px 0;
  min-height: 80px;
}

.participant-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border-radius: 100px;
  padding: 8px 16px 8px 8px;
  box-shadow: var(--shadow);
  animation: pop-in 0.3s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.5); }
  to { opacity: 1; transform: scale(1); }
}

/* ===== MINUTEUR ===== */
.timer {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 4rem;
  font-weight: 800;
  text-align: center;
  color: var(--ink);
  line-height: 1;
}

.timer.warning { color: var(--coral); }

.timer-bar {
  height: 8px;
  background: #E0D8CC;
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0;
}

.timer-bar-fill {
  height: 100%;
  background: var(--green);
  border-radius: 4px;
  transition: width 1s linear, background-color 0.5s;
}

.timer-bar-fill.warning { background: var(--coral); }

/* ===== PHASE BADGE ===== */
.phase-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 700;
  font-size: 0.85rem;
  padding: 6px 14px;
  border-radius: 100px;
  margin-bottom: 16px;
}

.phase-badge--test {
  background: var(--teal);
  color: white;
}

/* ===== ÉTATS ===== */
.screen { display: none; }
.screen.active { display: flex; flex-direction: column; }

.text-center { text-align: center; }
.mt-auto { margin-top: auto; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }

.text-muted { color: var(--ink-light); font-size: 0.9rem; }

/* ===== ADMIN LAYOUT ===== */
.admin-layout {
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto 1fr;
  min-height: 100vh;
  gap: 0;
}

.admin-sidebar {
  background: var(--ink);
  color: white;
  padding: 24px;
  grid-row: 1 / -1;
}

.admin-topbar {
  background: var(--white);
  padding: 16px 24px;
  border-bottom: 2px solid #E0D8CC;
  display: flex;
  align-items: center;
  gap: 16px;
}

.admin-main {
  padding: 32px;
  overflow-y: auto;
}

.admin-code {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: 6px;
  color: var(--yellow);
  margin: 8px 0;
}

/* ===== IDEAS GRID ===== */
.ideas-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.idea-card {
  background: var(--white);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
  position: relative;
  animation: card-appear 0.4s cubic-bezier(0.34,1.56,0.64,1) both;
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(30px) scale(0.9); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.idea-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.idea-card p { font-size: 0.95rem; line-height: 1.5; }
.idea-card .idea-excerpt { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

/* Couleurs des groupes */
.group-coral { border-left: 5px solid var(--coral); }
.group-yellow { border-left: 5px solid var(--yellow); }
.group-green { border-left: 5px solid var(--green); }
.group-blue { border-left: 5px solid var(--blue); }
.group-pink { border-left: 5px solid var(--pink); }
.group-teal { border-left: 5px solid var(--teal); }

/* ===== QR CODE ===== */
.qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.qr-wrapper img {
  width: 200px;
  height: 200px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
}

/* ===== PROGRESS ===== */
.progress-bar {
  height: 10px;
  background: #E0D8CC;
  border-radius: 5px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--green);
  border-radius: 5px;
  transition: width 0.5s ease;
}

[hidden] { display: none !important; }

/* ===== MESSAGES, BANDEAU, ATTENTE ===== */
.form-error { color: var(--coral); font-weight: 600; min-height: 1.2em; margin: 8px 0; }
.form-error:empty { margin: 0; min-height: 0; }

.test-banner {
  position: sticky; top: 0; z-index: 20;
  background: var(--teal); color: white; text-align: center;
  font-weight: 700; font-size: 0.9rem; padding: 8px 16px;
}

.waiting-dots { margin-top: 20px; }
.waiting-dots span {
  display: inline-block; width: 10px; height: 10px; margin: 0 4px; border-radius: 50%;
  background: var(--coral); animation: dot-pulse 1.4s infinite ease-in-out both;
}
.waiting-dots span:nth-child(2) { animation-delay: 0.2s; }
.waiting-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-pulse {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40% { transform: scale(1); opacity: 1; }
}

.phase-badge { align-self: flex-start; }

/* ===== VOTE ===== */
.vote-screen { min-height: 100dvh; padding-bottom: 16px; }
.vote-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.vote-top .phase-badge { margin-bottom: 0; }
.vote-timer {
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}
.vote-timer.warning { color: var(--coral); }
.vote-counter { margin: 14px 0 8px; font-weight: 600; color: var(--ink-light); }
.super-reminder {
  margin-top: 10px; font-size: 0.9rem; color: var(--ink-light);
  background: #FFF1C9; border-radius: var(--radius-sm); padding: 8px 12px;
}
.super-reminder[hidden] { display: none; }

.vote-stage { flex: 1; display: flex; padding: 16px 0; min-height: 260px; }
.vote-card {
  position: relative; flex: 1; display: flex;
  background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
  max-height: 52vh;
}
.vote-card.scrollable { touch-action: pan-y; }
.vote-card.enter { animation: card-enter 240ms ease-out; }
@keyframes card-enter {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: scale(1); }
}
.vote-card-scroll { flex: 1; overflow-y: auto; padding: 28px 24px; display: flex; flex-direction: column; justify-content: center; }
.vote-card.scrollable .vote-card-scroll { justify-content: flex-start; }
.vote-card-kind { font-size: 0.85rem; font-weight: 700; color: var(--ink-light); text-transform: uppercase; letter-spacing: 0.04em; }
.vote-card-title { font-size: 1.5rem; margin: 6px 0 14px; }
.vote-card-texts p { font-size: 1.15rem; line-height: 1.55; overflow-wrap: anywhere; }
.vote-card-texts.grouped p { font-size: 1.02rem; padding: 10px 0; border-top: 1px solid #EFE6D8; }
.vote-card-texts.grouped p:first-child { border-top: none; padding-top: 0; }

.swipe-stamp {
  position: absolute; top: 18px; padding: 6px 14px; border-radius: 10px; border: 3px solid;
  font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 1.1rem;
  background: var(--white); opacity: 0; pointer-events: none;
}
.swipe-stamp--pass { right: 18px; color: var(--ink-light); border-color: var(--ink-light); }
.swipe-stamp--star { left: 18px; color: var(--green); border-color: var(--green); }
.swipe-stamp--super { left: 50%; transform: translateX(-50%); color: #A87A00; border-color: var(--yellow); background: #FFF6D6; }

.vote-actions { display: flex; flex-direction: column; gap: 12px; }
.vote-actions-row { display: flex; gap: 12px; }
.vote-actions-row .btn { flex: 1; padding: 18px 12px; }
.btn--super {
  width: 100%; padding: 18px; font-size: 1.15rem;
  background: var(--yellow); color: var(--ink); box-shadow: 0 4px 14px rgba(255,201,60,0.35);
}
.btn--super[hidden] { display: none; }
.swipe-hint { text-align: center; font-size: 0.82rem; color: var(--ink-light); }

/* ===== RÉCAPITULATIF ===== */
.recap-list { display: flex; flex-direction: column; gap: 12px; margin: 16px 0 20px; }
.recap-row { background: var(--white); border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow); }
.recap-text {
  font-weight: 600; margin-bottom: 12px; overflow-wrap: anywhere;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.segment {
  min-height: 44px; padding: 8px 4px; border-radius: 12px; border: 2px solid #E0D8CC;
  background: var(--bg); color: var(--ink); font: inherit; font-size: 0.85rem; font-weight: 700; cursor: pointer;
}
.segment[aria-pressed="true"].segment--pass { background: var(--ink); border-color: var(--ink); color: white; }
.segment[aria-pressed="true"].segment--star { background: var(--green); border-color: var(--green); color: white; }
.segment[aria-pressed="true"].segment--super { background: var(--yellow); border-color: #c89a1e; color: var(--ink); }

/* ===== MERCI ===== */
.thanks { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; text-align: center; }
.thanks .text-muted { font-size: 1.1rem; }

@media (prefers-reduced-motion: reduce) {
  .vote-card.enter, .participant-chip, .idea-card { animation: none; }
}

/* ===== MEDIA ===== */
@media (max-width: 600px) {
  .admin-layout {
    grid-template-columns: 1fr;
  }
  .admin-sidebar { display: none; }
  .timer { font-size: 3rem; }
  .session-code { font-size: 2.5rem; letter-spacing: 4px; }
}

/* Points affichés entre deux questions */
.waiting-points { margin-top: 8px; font-weight: 700; color: var(--green); min-height: 0; }
.waiting-points:empty { display: none; }

/* ===== FINITIONS (étape 6) ===== */
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.field input:focus-visible, .field textarea:focus-visible { outline: none; }

/* Code à 6 chiffres : grand et centré, facile à vérifier */
.code-input {
  text-align: center; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
  font-size: 2rem !important; letter-spacing: 0.3em; padding: 14px 10px 14px calc(10px + 0.3em) !important;
  font-variant-numeric: tabular-nums;
}
.code-input::placeholder { color: #CFC6B8; }
.join-hint { text-align: center; margin-top: 4px; }

/* Avatar : le bouton de validation reste toujours à portée de pouce */
.sticky-actions {
  position: sticky; bottom: 0; z-index: 10;
  display: flex; gap: 12px; margin: 8px -16px -24px; padding: 12px 16px calc(16px + env(safe-area-inset-bottom));
  background: var(--bg); box-shadow: 0 -6px 16px rgba(255,248,238,0.9);
}
.avatar-name { text-align: center; font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 1.2rem; margin-top: -4px; }
.link-button {
  background: none; border: none; padding: 8px; margin-top: 8px; cursor: pointer;
  font: inherit; font-weight: 700; color: var(--blue); text-decoration: underline; text-underline-offset: 3px;
}
