@import url("https://fonts.googleapis.com/css2?family=Epilogue:wght@600&display=swap");

/* ── Tokens ────────────────────────────────────────────────── */
:root {
  --violet-900: #1a052f;
  --violet-800: #2d0a50;
  --pink-400:   #fa41a5;
  --purple-400: #b680f1;
  --beige-100:  #f5e9eb;
  --beige-50:   #fbeff1;
  --white:      #ffffff;
  --mascot-h:   180px;   /* space reserved at bottom for mascots */
}

/* ── Reset & base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--violet-800);
  font-family: 'Epilogue', sans-serif;
  font-weight: 600;
  color: var(--white);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout shell ──────────────────────────────────────────── */
.quiz-shell {
  background: var(--violet-900);
  position: relative;
  width: 100%;
  height: 100dvh;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}

/* ── Back-to-article link ──────────────────────────────────── */
.quiz-back {
  position: absolute;
  top: 18px;
  left: 20px;
  z-index: 20;
  color: rgba(255,255,255,0.55);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  letter-spacing: 0.2px;
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color 0.15s;
}
.quiz-back:hover { color: rgba(255,255,255,0.85); }
.quiz-back svg { width: 14px; height: 14px; flex-shrink: 0; }

/* ── Header (title + category) ─────────────────────────────── */
.quiz-header {
  position: relative;
  z-index: 10;
  margin-top: 62px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}

.quiz-header h1 {
  font-size: 26px;
  line-height: 1.1;
  letter-spacing: -0.4px;
  color: var(--beige-50);
}

.quiz-category {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 15px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.2px;
}

/* ── Progress bar ──────────────────────────────────────────── */
.quiz-progress-wrap {
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  width: calc(100% - 48px);
  margin-top: 18px;
  height: 4px;
  background: rgba(255,255,255,0.12);
  border-radius: 99px;
  overflow: hidden;
}

.quiz-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--purple-400), var(--pink-400));
  border-radius: 99px;
  transition: width 0.35s ease;
  width: 0%;
}

.quiz-progress-label {
  position: relative;
  z-index: 10;
  flex-shrink: 0;
  margin-top: 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.3px;
}

/* ── Card stack area ───────────────────────────────────────── */
/* flex:1 fills all remaining height between progress label and mascots */
.quiz-card-area {
  position: relative;
  z-index: 10;
  flex: 1;
  width: 100%;
  /* Leave space at the bottom for the mascots */
  padding: 16px 24px var(--mascot-h);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Decorative rotated shadow cards */
.quiz-card-wrap {
  position: relative;
  width: 100%;
  max-width: 360px;
}

.quiz-card-wrap::before,
.quiz-card-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 28px;
}
.quiz-card-wrap::before {
  background: var(--purple-400);
  transform: rotate(3deg);
  z-index: 0;
}
.quiz-card-wrap::after {
  background: var(--pink-400);
  transform: rotate(-1deg);
  z-index: 1;
}

/* The actual white card — taller min-height for comfort */
.quiz-card {
  position: relative;
  z-index: 2;
  background: var(--white);
  border-radius: 28px;
  padding: 28px 28px 24px;
  min-height: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  overflow: hidden;
  transition: transform 0.22s cubic-bezier(0.4,0,0.2,1), opacity 0.22s ease;
  /* Dragging */
  user-select: none;
  cursor: grab;
}
.quiz-card:active { cursor: grabbing; }

/* Drag-follow tilt while dragging */
.quiz-card.is-dragging {
  transition: none;
}

.quiz-card.is-exiting-left  { transform: translateX(-120%) rotate(-10deg); opacity: 0; }
.quiz-card.is-exiting-right { transform: translateX(120%)  rotate(10deg);  opacity: 0; }
.quiz-card.is-entering      { opacity: 0; animation: card-in 0.25s forwards; }

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

/* Badge ("1 / 40") */
.quiz-card-badge {
  background: var(--beige-100);
  color: var(--violet-900);
  font-size: 14px;
  letter-spacing: 0.3px;
  padding: 7px 18px;
  border-radius: 99px;
  flex-shrink: 0;
}

/* Question text */
.quiz-card-question {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--violet-900);
  font-size: clamp(20px, 5.5vw, 28px);
  line-height: 1.25;
  letter-spacing: -0.5px;
  padding: 8px 4px;
}

/* ── Card action buttons ─────────────────────────────────────  */
.quiz-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
}

.quiz-btn-refresh {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: var(--beige-100);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, transform 0.15s;
}
.quiz-btn-refresh:hover  { background: #ede0e2; }
.quiz-btn-refresh:active { transform: scale(0.94); }
.quiz-btn-refresh svg { width: 22px; height: 22px; color: var(--violet-900); }

.quiz-btn-next {
  flex: 1;
  height: 56px;
  border-radius: 18px;
  background: var(--violet-900);
  color: var(--beige-50);
  border: none;
  cursor: pointer;
  font-family: 'Epilogue', sans-serif;
  font-weight: 600;
  font-size: 18px;
  letter-spacing: 0.3px;
  transition: background 0.15s, transform 0.15s;
}
.quiz-btn-next:hover  { background: #2d0a50; }
.quiz-btn-next:active { transform: scale(0.97); }

/* ── Swipe hint arrows (shown briefly on first load) ─────────  */
.quiz-swipe-hint {
  position: absolute;
  bottom: 80px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 8px;
  z-index: 15;
  pointer-events: none;
  opacity: 0;
  animation: hint-fade 2.5s ease 0.8s forwards;
}
.quiz-swipe-hint span {
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.3px;
}
@keyframes hint-fade {
  0%   { opacity: 0; }
  20%  { opacity: 1; }
  80%  { opacity: 1; }
  100% { opacity: 0; }
}

/* ── Unlock gate overlay (inside the card) ──────────────────  */
.quiz-gate {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 28px 24px 24px;
  text-align: center;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(255,255,255,0.72);
}
.quiz-gate.is-visible { display: flex; }

.quiz-gate-lock {
  font-size: 36px;
  line-height: 1;
}

.quiz-gate h2 {
  color: var(--violet-900);
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: -0.3px;
}

.quiz-gate p {
  color: rgba(26,5,47,0.65);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 600;
}

.quiz-gate-cta {
  display: block;
  width: 100%;
  padding: 15px 20px;
  border-radius: 16px;
  background: var(--violet-900);
  color: var(--beige-50);
  font-family: 'Epilogue', sans-serif;
  font-weight: 600;
  font-size: 16px;
  text-decoration: none;
  text-align: center;
  letter-spacing: 0.2px;
  transition: background 0.15s, transform 0.15s;
  margin-top: 4px;
}
.quiz-gate-cta:hover  { background: #2d0a50; }
.quiz-gate-cta:active { transform: scale(0.97); }

.quiz-gate-skip {
  font-size: 12px;
  color: rgba(26,5,47,0.4);
  cursor: pointer;
  background: none;
  border: none;
  font-family: 'Epilogue', sans-serif;
  font-weight: 600;
  letter-spacing: 0.2px;
  text-decoration: underline;
  padding: 0;
}
.quiz-gate-skip:hover { color: rgba(26,5,47,0.65); }

/* ── Mascots ────────────────────────────────────────────────── */
/*
 * Mascots are absolutely positioned at the very bottom of the shell,
 * each partially cropped by the shell's overflow:hidden, matching the
 * original Figma design. We do NOT set height:auto on the img — instead
 * we set a fixed width and let the SVG's natural aspect ratio define
 * the height. Bottom offset is negative so the lower part is cropped.
 */
.quiz-mascots {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--mascot-h);
  pointer-events: none;
  z-index: 1;
  /* No overflow:hidden here — shell's overflow:hidden does the cropping */
}

.quiz-mascot-pink {
  position: absolute;
  bottom: -30px;          /* crop bottom ~30px under the screen edge */
  right: -8px;
  width: 140px;
  height: auto;           /* preserve SVG aspect ratio */
}
.quiz-mascot-purple {
  position: absolute;
  bottom: -50px;
  left: -8px;
  width: 140px;
  height: auto;
  transform: scaleX(-1);  /* mirror so they face each other */
}

/* ── Desktop: center and constrain ─────────────────────────── */
@media (min-width: 500px) {
  body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
  }
  .quiz-shell {
    border-radius: 40px;
    height: min(820px, 100dvh);
    box-shadow: 0 24px 80px rgba(0,0,0,0.5);
    overflow: hidden;
  }
}
