@import url('https://fonts.googleapis.com/css2?family=Syne:wght@700&display=swap');

/* ===================================
   BASE STYLES
   =================================== */
.qs-quiz-scope,
.qs-quiz-scope * {
  box-sizing: border-box;
}

.qs-quiz-scope {
  --qs-blue: #27408f;
  --qs-pink: #d32d7d;
  --qs-white: #ffffff;
  font-family: "Red Hat Display", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--qs-blue);
}

.qs-quiz-scope [hidden] { display: none !important; }
.qs-quiz-scope button { font: inherit; }
.qs-quiz-scope img { max-width: 100%; height: auto; }

/* ===================================
   QUIZ COMPLET (STYLES INCHANGÉS)
   =================================== */
.qs-quiz-scope[data-jssq-mode="quiz"] .qs-quiz__layout {
  width: min(960px, 100%);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(28px, 4vw, 48px);
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-stage {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(32px, 8vw, 120px);
}

.qs-quiz-scope .qs-stageFooter {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 3vw, 24px);
  margin-top: clamp(12px, 3vw, 22px);
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-choice {
  padding: 10px 25px !important;
  border: 1px solid var(--qs-blue);
  border-radius: 999px !important;
  font-family: "Red Hat Display", sans-serif !important;
  font-weight: 600 !important;
  font-size: 17px !important;
  cursor: pointer !important;
  text-transform: none !important;
  transition: none !important;
  color: var(--qs-blue) !important;
  background: transparent !important;
  text-align: center;
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-choice.is-selected {
  background: var(--qs-blue) !important;
  color: #ffffff !important;
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-choice:disabled {
  opacity: 0.6;
  cursor: not-allowed !important;
}

.qs-quiz-scope .qs-nav {
  display: flex;
  gap: 10px;
  margin-top: clamp(10px, 2.4vw, 20px);
}

.qs-quiz-scope .qs-nav-btn {
  background: var(--qs-pink);
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.3s ease, transform 0.2s ease;
  padding: 0;
}

.qs-quiz-scope .qs-nav-btn.is-disabled,
.qs-quiz-scope .qs-nav-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.qs-quiz-scope .qs-nav-btn:hover:not(.is-disabled):not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

.qs-quiz-scope .qs-nav-btn:active:not(.is-disabled):not(:disabled) {
  transform: scale(0.95);
}

.qs-quiz-scope .qs-nav-btn img {
  width: 18px;
  height: 18px;
  display: block;
  filter: brightness(0) invert(1);
}

.qs-quiz-scope .arrow-left {
  transform: rotate(180deg);
}

.qs-quiz-scope .qs-nav-btn:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 2px;
}

.qs-quiz-scope .qs-progressBlock {
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.qs-quiz-scope .qs-count {
  font-family: "Red Hat Display", sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--qs-blue);
}

.qs-quiz-scope .qs-meter {
  width: 100%;
  height: 15px;
  background: #ffffff;
  border-radius: 999px;
  overflow: hidden;
}

.qs-quiz-scope .qs-meter__fill {
  width: 0%;
  height: 100%;
  background: var(--qs-blue);
  border-radius: 999px;
  transition: width 350ms ease;
}

.qs-quiz-scope .qs-deck {
  --cardH: clamp(340px, 56vh, 460px);
  --cardW: min(560px, calc(var(--cardH) * 0.72));
  width: var(--cardW);
  height: var(--cardH);
  justify-self: center;
  position: relative;
  perspective: 1200px;
  -webkit-perspective: 1200px;
}

.qs-quiz-scope .qs-card {
  position: absolute;
  inset: 0;
  transform-origin: center;
  transition: transform 520ms cubic-bezier(.22,.61,.36,1);
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-card.is-top {
  transform: translate(0, 0) rotate(-2deg);
  z-index: 30;
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-card.is-mid {
  transform: translate(9px, 7px) rotate(1.3deg);
  z-index: 20;
}

.qs-quiz-scope[data-jssq-mode="quiz"] .qs-card.is-bot {
  transform: translate(16px, 12px) rotate(2.6deg);
  z-index: 10;
}

.qs-quiz-scope .qs-card.is-placeholder {
  pointer-events: none;
}

.qs-quiz-scope .qs-card__inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 640ms cubic-bezier(.2,.8,.2,1);
  will-change: transform;
}

.qs-quiz-scope .qs-card.is-flipped .qs-card__inner {
  transform: rotateY(180deg);
  -webkit-transform: rotateY(180deg);
}

.qs-quiz-scope .qs-face {
  position: absolute;
  inset: 0;
  border-radius: 18px;
  overflow: hidden;
  border: 3px solid var(--qs-blue);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

.qs-quiz-scope .qs-front {
  background: #ffffff;
  transform: rotateY(0deg) translateZ(1px);
  -webkit-transform: rotateY(0deg) translateZ(1px);
}

.qs-quiz-scope .qs-back {
  background: #ffffff;
  transform: rotateY(180deg) translateZ(0);
  -webkit-transform: rotateY(180deg) translateZ(0);
}

.qs-quiz-scope .qs-backPad {
  position: absolute;
  inset: 0;
  padding: 8px;
}

.qs-quiz-scope .qs-backInner {
  width: 100%;
  height: 100%;
  background: var(--qs-blue);
  border: 2px solid var(--qs-blue);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: clamp(16px, 2.5vw, 22px);
  text-align: center;
}

.qs-quiz-scope .qs-backTitle {
  font-family: "Syne", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 700;
  text-transform: uppercase;
  color: #ffffff;
  font-size: clamp(18px, 2.2vw, 26px);
  letter-spacing: 0;
  margin: 0;
}

.qs-quiz-scope .qs-backText {
  font-family: "Red Hat Display", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 400;
  font-size: 17px;
  color: #ffffff;
  text-transform: none;
  max-width: 38ch;
  line-height: 1.2em;
  margin: 0;
}

.qs-quiz-scope .qs-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

.qs-quiz-scope .qs-corner--tl {
  top: 16px;
  left: 16px;
}

.qs-quiz-scope .qs-corner--br {
  bottom: 16px;
  right: 16px;
  transform: rotate(180deg);
}

.qs-quiz-scope .qs-num {
  font-family: "Red Hat Display", sans-serif;
  font-weight: 900;
  font-size: clamp(26px, 3vw, 40px);
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qs-quiz-scope .qs-star {
  width: clamp(22px, 2.6vw, 34px);
  height: clamp(22px, 2.6vw, 34px);
  display: block;
  color: var(--qs-blue);
  background-color: currentColor;
  mask-image: var(--qs-star);
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-image: var(--qs-star);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

.qs-quiz-scope .qs-question {
  margin: 0;
  font-family: "Syne", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 600;
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(100% - clamp(36px, 8vw, 56px));
  font-size: clamp(17px, 2.3vw, 24px);
  line-height: 1.18;
  color: var(--qs-blue);
}

.qs-quiz-scope .qs-card.accent-pink .qs-num,
.qs-quiz-scope .qs-card.accent-pink .qs-question,
.qs-quiz-scope .qs-card.accent-pink .qs-star {
  color: var(--qs-pink);
}

.qs-quiz-scope .qs-card.accent-blue .qs-num,
.qs-quiz-scope .qs-card.accent-blue .qs-question,
.qs-quiz-scope .qs-card.accent-blue .qs-star {
  color: var(--qs-blue);
}

.qs-quiz-scope .qs-card.is-placeholder .qs-question,
.qs-quiz-scope .qs-card.is-placeholder .qs-num,
.qs-quiz-scope .qs-card.is-placeholder .qs-star {
  opacity: 0;
}

.qs-quiz-scope .qs-card.is-placeholder .qs-backInner {
  opacity: 0;
}

.qs-quiz-scope .qs-result {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: min(520px, 80vh);
  width: 100%;
  padding: clamp(32px, 6vw, 64px) 0;
  text-align: center;
  color: var(--qs-blue);
}

.qs-quiz-scope .qs-result__wrap {
  width: min(720px, 92vw);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin: 0 auto;
}

.qs-quiz-scope .qs-result__subtitle {
  font-family: "Syne", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 700;
  font-size: 17px;
  color: var(--qs-blue);
  margin: 6px 0 2px;
}

.qs-quiz-scope .qs-result__score {
  font-family: "Syne", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 800;
  color: var(--qs-blue);
  font-size: clamp(34px, 6vw, 44px);
  line-height: 1.1;
  margin: 2px 0 16px;
}

@media (max-width: 520px) {
  .qs-quiz-scope .qs-result__score {
    font-size: 32px;
  }
}

.qs-quiz-scope .qs-result__actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: clamp(10px, 2.5vw, 18px);
}

.qs-quiz-scope .qs-restart,
.qs-quiz-scope .qs-share {
  padding: 10px 25px;
  border-radius: 100px;
  font-family: "Red Hat Display", sans-serif;
  font-weight: 600;
  font-size: 17px;
  cursor: pointer;
  text-transform: none;
  border: none;
  color: #ffffff;
}

.qs-quiz-scope .qs-restart {
  background: var(--qs-blue);
}

.qs-quiz-scope .qs-share {
  background: var(--qs-pink);
}

/* ===================================
   MODE PREVIEW - RESTAURATION STABLE
   =================================== */

.qs-preview-scope {
  width: 100%;
  max-width: calc((340px * var(--scale) * 2) + var(--grid-gap) + 2rem);
  margin: 0 auto;
  position: relative;
  
  /* ✅ VARIABLE OBLIGATOIRE - STRICTEMENT PRÉSERVÉE */
  --visual-offset: clamp(2.75rem, 6.5vw, 5.25rem);
  
  --scale: 0.55;
  --grid-gap: clamp(1rem, 2.5vw, 1.5rem);
  --card-width: calc(340px * var(--scale));
  --card-height: calc(460px * var(--scale));
  --button-size: calc(160px * var(--scale));
}

/* GRILLE 2×2 STABLE */
.qs-preview-scope .qs-preview-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  /* Hauteurs automatiques pour éviter l'écrasement */
  grid-template-rows: auto auto;
  gap: var(--grid-gap);
  width: 100%;
  /* Padding bottom compensatoire pour l'effet d'escalier */
  padding-bottom: calc(var(--visual-offset) * 0.5);
}

/* ✅ CORRECTION ESPACE FLEX PARASITE : display: block */
.qs-preview-scope .qs-card {
  position: relative;
  width: 100%;
  height: 100%;
  margin: 0 !important;
  padding: 0;
  /* ✅ SUPPRESSION TOTALE DU FLEX - Plus d'espace violet parasite */
  display: block;
  /* Hauteur minimale pour maintenir la structure */
  min-height: var(--card-height);
}

.qs-preview-scope .qs-card__inner {
  width: var(--card-width);
  height: var(--card-height);
  position: relative;
  /* Centrage horizontal simple */
  margin: 0 auto;
  aspect-ratio: 340 / 460;
}

.qs-preview-scope .qs-face {
  position: absolute;
  inset: 0;
  background: #ffffff;
  border-radius: calc(18px * var(--scale));
  border-width: 3px;
  border-style: solid;
  border-color: var(--qs-blue);
}

.qs-preview-scope .qs-num {
  font-family: "Red Hat Display", sans-serif;
  font-weight: 900;
  font-size: calc(40px * var(--scale));
  line-height: 1;
}

.qs-preview-scope .qs-star {
  width: calc(34px * var(--scale));
  height: calc(34px * var(--scale));
  display: block;
  color: var(--qs-blue);
  background-color: currentColor;
  mask-image: var(--qs-star);
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
  -webkit-mask-image: var(--qs-star);
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
}

/* ✅ TEXTE AVEC SCALE STRICT */
.qs-quiz-scope.qs-preview-scope .qs-question {
  font-family: "Syne", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif !important;
  font-weight: 600 !important;
  text-align: center !important;
  position: absolute !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  width: calc(100% - calc(56px * var(--scale))) !important;
  font-size: calc(24px * var(--scale)) !important;
  line-height: 1.18 !important;
  color: var(--qs-blue) !important;
  margin: 0 !important;
}

.qs-preview-scope .qs-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(6px * var(--scale));
  text-align: center;
}

.qs-preview-scope .qs-corner--tl {
  top: calc(16px * var(--scale));
  left: calc(16px * var(--scale));
}

.qs-preview-scope .qs-corner--br {
  bottom: calc(16px * var(--scale));
  right: calc(16px * var(--scale));
  transform: rotate(180deg);
}

.qs-preview-scope .qs-card.accent-pink .qs-num,
.qs-preview-scope .qs-card.accent-pink .qs-question,
.qs-preview-scope .qs-card.accent-pink .qs-star {
  color: var(--qs-pink);
}

.qs-preview-scope .qs-card.accent-blue .qs-num,
.qs-preview-scope .qs-card.accent-blue .qs-question,
.qs-preview-scope .qs-card.accent-blue .qs-star {
  color: var(--qs-blue);
}

/* ✅ TRANSFORMS : ROTATIONS ORIGINALES + EFFET D'ESCALIER MAÎTRISÉ */

/* Carte 1 (Haut Gauche) : Rotation -3deg PRÉSERVÉE */
.qs-preview-scope .qs-card[data-card-index="0"] .qs-card__inner {
  transform: rotate(-3deg);
  z-index: 2;
}

/* Carte 2 (Haut Droite) : Rotation 0deg + ESCALIER BAS (--visual-offset) */
.qs-preview-scope .qs-card[data-card-index="1"] .qs-card__inner {
  transform: translateY(calc(var(--visual-offset) * 0.35)) rotate(0deg);
  z-index: 1;
}

/* Carte 3 (Bas Gauche) : Rotation 0deg PRÉSERVÉE */
.qs-preview-scope .qs-card[data-card-index="2"] .qs-card__inner {
  transform: rotate(0deg);
  z-index: 1;
}

/* Carte 4 (Bas Droite) : Rotation 3deg + ESCALIER BAS (--visual-offset) */
.qs-preview-scope .qs-card[data-card-index="3"] .qs-card__inner {
  transform: translateY(calc(var(--visual-offset) * 0.35)) rotate(3deg);
  z-index: 2;
}

/* ✅ BOUTON REPOSITIONNÉ : AU-DESSUS DE LA CARTE 2 SANS CHEVAUCHEMENT */
.qs-preview-scope .rotate-button-wrapper {
  position: absolute;
  /* Centre horizontal de la colonne droite */
  left: calc(50% + (var(--grid-gap) / 2) + (var(--card-width) / 2));
  /* Position verticale calculée : top + décalage de la carte 2 */
  top: calc(var(--visual-offset) * 0.35);
  /* Remontée pour être AU-DESSUS sans chevauchement */
  transform: translate(-50%, calc(-100% - clamp(0.75rem, 2vw, 1.25rem)));
  width: auto;
  display: flex;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}

.qs-preview-scope .rotate-button {
  width: var(--button-size);
  height: var(--button-size);
  position: relative;
  pointer-events: auto;
  cursor: pointer;
}

.qs-preview-scope .rotate-text-svg { 
  width: 100%; 
  height: 100%; 
}

.qs-preview-scope .rotate-text-svg text {
  fill: #1c4294;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  font-size: clamp(7px, 0.85vw, 9.5px);
  letter-spacing: clamp(2.5px, 0.35vw, 4px);
  text-transform: uppercase;
}

.qs-preview-scope .rotate-circle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: calc(78px * var(--scale));
  height: calc(78px * var(--scale));
  background-color: #e6007e;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease;
}

.qs-preview-scope .rotate-button:hover .rotate-circle { 
  transform: translate(-50%, -50%) scale(1.08); 
}

.qs-preview-scope .rotate-icon {
  width: calc(36px * var(--scale));
  height: calc(36px * var(--scale));
  display: block;
  filter: brightness(0) invert(1);
}

.qs-preview-scope .rotate-icon.spinning { 
  transform: rotate(360deg); 
  transition: transform 0.6s ease; 
}

/* ===================================
   RESPONSIVE
   =================================== */

/* TABLETTE */
@media (max-width: 1024px) {
  .qs-preview-scope {
    --scale: 0.45;
  }
  
  .qs-preview-scope .qs-face {
    border-width: max(2px, calc(3px * var(--scale)));
  }
}

/* MOBILE */
@media (max-width: 480px) {
  .qs-preview-scope {
    --scale: 0.35;
  }
  
  .qs-preview-scope .qs-face {
    border-width: 2px;
  }
}

/* QUIZ RESPONSIVE (INCHANGÉ) */
@media (max-width: 900px) {
  .qs-quiz-scope[data-jssq-mode="quiz"] .qs-stage {
    gap: clamp(20px, 6vw, 48px);
  }
}

@media (max-width: 720px) {
  .qs-quiz-scope[data-jssq-mode="quiz"] .qs-stage {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-areas:
      "deck deck"
      "choice-true choice-false";
    gap: clamp(44px, 11vw, 60px) clamp(22px, 9vw, 48px);
    justify-items: center;
  }

  .qs-quiz-scope .qs-deck {
    grid-area: deck;
  }

  .qs-quiz-scope .qs-choice[data-choice="true"] {
    grid-area: choice-true;
    justify-self: end;
  }

  .qs-quiz-scope .qs-choice[data-choice="false"] {
    grid-area: choice-false;
    justify-self: start;
  }

  .qs-quiz-scope .qs-question {
    font-size: clamp(20px, 6vw, 28px);
  }

  .qs-quiz-scope .qs-stageFooter {
    margin-top: clamp(10px, 4vw, 18px);
  }
}

@media (min-width: 721px) and (max-width: 1024px) {
  .qs-quiz-scope .qs-question {
    font-size: clamp(22px, 2.4vw, 30px);
  }
}

@media (max-width: 640px) {
  .qs-quiz-scope .qs-deck {
    --cardW: min(72vw, 280px);
    --cardH: min(440px, calc(var(--cardW) * 1.4));
  }
}

@media (prefers-reduced-motion: reduce) {
  .qs-quiz-scope .qs-card,
  .qs-quiz-scope .qs-card__inner,
  .qs-quiz-scope .qs-meter__fill,
  .qs-preview-scope .rotate-icon {
    transition: none !important;
  }
}
