/* ================================================
   SORTING HAT QUIZ - STYLES
   Dark theme, mobile-first, diagonal card design
   ================================================ */

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

:root {
  --bg-dark: #0a0a12;
  --bg-card: #141422;
  --bg-card-hover: #1c1c33;
  --gold: #C4A265;
  --gold-light: #e8d5a8;
  --gold-glow: rgba(196, 162, 101, 0.3);
  --text-primary: #e8e4dc;
  --text-secondary: #9e9a90;
  --shadow-dark: rgba(0, 0, 0, 0.6);

  /* House colors */
  --gryffindor-primary: #740001;
  --gryffindor-secondary: #D3A625;
  --slytherin-primary: #1A472A;
  --slytherin-secondary: #5D5D5D;
  --ravenclaw-primary: #0E1A40;
  --ravenclaw-secondary: #946B2D;
  --hufflepuff-primary: #ecb939;
  --hufflepuff-secondary: #372E29;

  --font-display: 'Cinzel Decorative', serif;
  --font-body: 'Crimson Text', serif;
}

html, body {
  width: 100%;
  min-height: 100dvh;
  overflow-x: hidden;
  background: var(--bg-dark);
  color: var(--text-primary);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  position: relative;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(30, 20, 50, 0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(20, 15, 40, 0.6) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(40, 25, 10, 0.4) 0%, transparent 50%),
    var(--bg-dark);
}

/* ---------- PARTICLES ---------- */
.particles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 3px;
  height: 3px;
  background: var(--gold);
  border-radius: 50%;
  opacity: 0;
  animation: floatUp 6s ease-in infinite;
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translateY(100vh) scale(0);
  }
  10% {
    opacity: 0.8;
  }
  90% {
    opacity: 0.2;
  }
  100% {
    opacity: 0;
    transform: translateY(-20vh) scale(1);
  }
}

/* ---------- SCREENS ---------- */
.screen {
  display: none;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- WELCOME SCREEN ---------- */
.welcome-wrapper {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
}

.hat-container {
  position: relative;
  display: inline-block;
  margin-bottom: 1.5rem;
}

.sorting-hat {
  width: 200px;
  height: auto;
  filter: drop-shadow(0 8px 32px rgba(196, 162, 101, 0.25));
  animation: hatFloat 3s ease-in-out infinite;
}

@keyframes hatFloat {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-10px) rotate(2deg); }
}

.hat-glow {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 170px;
  height: 40px;
  background: radial-gradient(ellipse, var(--gold-glow) 0%, transparent 70%);
  border-radius: 50%;
  animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.4; transform: translateX(-50%) scaleX(1); }
  50% { opacity: 0.8; transform: translateX(-50%) scaleX(1.2); }
}

.title {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 2px 20px var(--gold-glow);
  margin-bottom: 0.6rem;
  letter-spacing: 0.05em;
}

.subtitle {
  font-size: 1.3rem;
  color: var(--text-secondary);
  font-style: italic;
  margin-bottom: 1.5rem;
}

.stars-deco {
  width: 260px;
  height: auto;
  margin-bottom: 2rem;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.twinkle {
  animation: twinkle 2s ease-in-out infinite;
}
.twinkle.delay-1 { animation-delay: 0.7s; }
.twinkle.delay-2 { animation-delay: 1.4s; }

@keyframes twinkle {
  0%, 100% { opacity: 0.3; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* ---------- MAGIC BUTTON ---------- */
.btn-magic {
  display: inline-flex;
  align-items: center;
  gap: 0.8rem;
  padding: 1.2rem 2.5rem;
  background: linear-gradient(135deg, rgba(196, 162, 101, 0.15) 0%, rgba(196, 162, 101, 0.05) 100%);
  border: 2px solid var(--gold);
  border-radius: 50px;
  color: var(--gold);
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  position: relative;
  overflow: hidden;
}

.btn-magic::before {
  content: '';
  position: absolute;
  inset: -2px;
  background: linear-gradient(45deg, transparent 30%, var(--gold-glow) 50%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn-magic:hover,
.btn-magic:active {
  background: linear-gradient(135deg, rgba(196, 162, 101, 0.25) 0%, rgba(196, 162, 101, 0.1) 100%);
  box-shadow: 0 0 30px var(--gold-glow), inset 0 0 20px rgba(196, 162, 101, 0.1);
  transform: translateY(-2px);
}

.btn-magic:active {
  transform: translateY(0);
}

/* ---------- QUESTION SCREEN ---------- */
.question-wrapper {
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 1rem 0 0 0;
}

/* Progress */
.progress-bar {
  width: calc(100% - 2rem);
  height: 5px;
  background: rgba(196, 162, 101, 0.15);
  border-radius: 3px;
  margin: 0 auto 0.6rem auto;
  position: relative;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), #e8d5a8);
  border-radius: 2px;
  transition: width 0.5s ease;
  width: 0%;
  box-shadow: 0 0 8px var(--gold-glow);
}

.question-counter {
  text-align: center;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  letter-spacing: 0.12em;
}

.inline-icon {
  vertical-align: middle;
}

/* Question text */
.question-text-box {
  padding: 1.2rem 1.5rem;
  text-align: center;
}

.question-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: 400;
  color: var(--gold-light);
  line-height: 1.4;
  text-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

/* ---------- DIAGONAL CHOICE CARDS ---------- */
.choices-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  overflow: hidden;
}

.choice-card {
  flex: 1;
  display: flex;
  align-items: center;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: all 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  min-height: 120px;
}

/* Left-aligned cards (odd) */
.choice-card.card-left {
  clip-path: polygon(0 0, 100% 0, 100% 75%, 0 100%);
  background: linear-gradient(135deg, rgba(30, 25, 50, 0.9) 0%, rgba(20, 18, 35, 0.95) 100%);
  padding: 1.5rem 1.5rem 2.5rem 1.5rem;
  justify-content: flex-start;
  border-bottom: none;
}

/* Right-aligned cards (even) */
.choice-card.card-right {
  clip-path: polygon(0 25%, 100% 0, 100% 100%, 0 100%);
  background: linear-gradient(225deg, rgba(30, 25, 50, 0.9) 0%, rgba(20, 18, 35, 0.95) 100%);
  padding: 2.5rem 1.5rem 1.5rem 1.5rem;
  justify-content: flex-end;
  margin-top: -30px;
}

/* Two-option layout */
.choices-container.two-options .choice-card {
  min-height: 180px;
}

.choices-container.two-options .choice-card.card-left {
  clip-path: polygon(0 0, 100% 0, 100% 65%, 0 100%);
  padding-bottom: 3.5rem;
}

.choices-container.two-options .choice-card.card-right {
  clip-path: polygon(0 35%, 100% 0, 100% 100%, 0 100%);
  margin-top: -50px;
  padding-top: 3.5rem;
}

.choice-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, var(--gold-glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.35s;
}

.choice-card:hover::before,
.choice-card:active::before {
  opacity: 1;
}

.choice-card:active {
  transform: scale(0.98);
}

/* Diagonal accent line */
.choice-card::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 200%;
  background: linear-gradient(to bottom, transparent, var(--gold), transparent);
  opacity: 0.15;
}

.choice-card.card-left::after {
  left: 0;
  top: 0;
  transform: rotate(-15deg);
  transform-origin: top left;
}

.choice-card.card-right::after {
  right: 0;
  top: 0;
  transform: rotate(15deg);
  transform-origin: top right;
}

.choice-content {
  display: flex;
  align-items: center;
  gap: 1rem;
  z-index: 2;
  position: relative;
}

.card-left .choice-content {
  flex-direction: row;
}

.card-right .choice-content {
  flex-direction: row-reverse;
}

.choice-icon {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(196, 162, 101, 0.1);
  border-radius: 16px;
  border: 1.5px solid rgba(196, 162, 101, 0.25);
  padding: 12px;
}

.choice-icon svg {
  width: 100%;
  height: 100%;
}

.choice-label {
  font-family: var(--font-display);
  font-size: 1.35rem;
  font-weight: 400;
  color: var(--text-primary);
  line-height: 1.3;
}

.card-right .choice-label {
  text-align: right;
}

/* Selected state */
.choice-card.selected {
  background: linear-gradient(135deg, rgba(196, 162, 101, 0.2) 0%, rgba(196, 162, 101, 0.05) 100%);
}

.choice-card.selected .choice-label {
  color: var(--gold);
}

.choice-card.selected .choice-icon {
  background: rgba(196, 162, 101, 0.2);
  border-color: var(--gold);
  box-shadow: 0 0 15px var(--gold-glow);
}

/* Card entrance animation */
.choice-card.card-left {
  animation: slideLeft 0.5s ease-out backwards;
}

.choice-card.card-right {
  animation: slideRight 0.5s ease-out backwards;
}

.choice-card:nth-child(1) { animation-delay: 0.1s; }
.choice-card:nth-child(2) { animation-delay: 0.2s; }
.choice-card:nth-child(3) { animation-delay: 0.3s; }
.choice-card:nth-child(4) { animation-delay: 0.4s; }

@keyframes slideLeft {
  from { opacity: 0; transform: translateX(-40px); }
  to { opacity: 1; transform: translateX(0); }
}

@keyframes slideRight {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ---------- SORTING SCREEN ---------- */
.sorting-wrapper {
  text-align: center;
  padding: 2rem 1.5rem;
}

.sorting-hat-anim .sorting-hat {
  animation: hatThink 1s ease-in-out infinite;
}

@keyframes hatThink {
  0%, 100% { transform: rotate(-5deg) scale(1); }
  25% { transform: rotate(3deg) scale(1.02); }
  50% { transform: rotate(-3deg) scale(0.98); }
  75% { transform: rotate(5deg) scale(1.01); }
}

.sorting-glow {
  animation: sortingGlow 1s ease-in-out infinite;
}

@keyframes sortingGlow {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

.sorting-text {
  font-family: var(--font-display);
  font-size: 1.5rem;
  color: var(--gold-light);
  font-style: italic;
  margin-top: 2rem;
  animation: textPulse 2s ease-in-out infinite;
}

@keyframes textPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

.magic-sparkles {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

.sparkle {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  animation: sparkleAnim 1.5s ease-out forwards;
}

@keyframes sparkleAnim {
  0% {
    opacity: 1;
    transform: scale(0) rotate(0deg);
  }
  50% {
    opacity: 0.8;
    transform: scale(1.5) rotate(180deg);
  }
  100% {
    opacity: 0;
    transform: scale(0) rotate(360deg);
  }
}

/* ---------- RESULT SCREEN ---------- */
.result-wrapper {
  text-align: center;
  padding: 2rem 1.5rem;
  max-width: 400px;
  width: 100%;
  animation: resultReveal 1s ease-out;
}

@keyframes resultReveal {
  from {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.result-crest {
  margin-bottom: 1.5rem;
  display: flex;
  justify-content: center;
}

.result-crest svg {
  width: 160px;
  height: 175px;
  filter: drop-shadow(0 10px 30px rgba(0,0,0,0.7));
}

.result-house {
  font-family: var(--font-display);
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-bottom: 1rem;
  text-transform: uppercase;
}

/* House-specific result colors */
.result-wrapper.gryffindor .result-house {
  color: #D3A625;
  text-shadow: 0 0 30px rgba(211, 166, 37, 0.4);
}
.result-wrapper.slytherin .result-house {
  color: #2ECC71;
  text-shadow: 0 0 30px rgba(46, 204, 113, 0.4);
}
.result-wrapper.ravenclaw .result-house {
  color: #5DADE2;
  text-shadow: 0 0 30px rgba(93, 173, 226, 0.4);
}
.result-wrapper.hufflepuff .result-house {
  color: #F1C40F;
  text-shadow: 0 0 30px rgba(241, 196, 15, 0.4);
}

.result-description {
  font-size: 1.25rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 1.5rem;
  font-style: italic;
}

.result-traits {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 2rem;
}

.trait-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 1rem;
  border-radius: 24px;
  font-family: var(--font-display);
  font-size: 0.9rem;
  letter-spacing: 0.08em;
  border: 1px solid rgba(196, 162, 101, 0.3);
  background: rgba(196, 162, 101, 0.08);
  color: var(--gold-light);
}

.trait-badge svg {
  width: 18px;
  height: 18px;
}

.result-quote {
  background: rgba(196, 162, 101, 0.05);
  border: 1px solid rgba(196, 162, 101, 0.15);
  border-radius: 12px;
  padding: 1.2rem;
  margin-bottom: 2rem;
  position: relative;
}

.quote-icon {
  position: absolute;
  top: -9px;
  left: 16px;
  background: var(--bg-dark);
  padding: 0 4px;
}

.result-quote p {
  font-style: italic;
  font-size: 1.15rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* House-specific background glow */
.result-wrapper.gryffindor {
  background: radial-gradient(ellipse at center top, rgba(116, 0, 1, 0.15) 0%, transparent 60%);
}
.result-wrapper.slytherin {
  background: radial-gradient(ellipse at center top, rgba(26, 71, 42, 0.2) 0%, transparent 60%);
}
.result-wrapper.ravenclaw {
  background: radial-gradient(ellipse at center top, rgba(14, 26, 64, 0.25) 0%, transparent 60%);
}
.result-wrapper.hufflepuff {
  background: radial-gradient(ellipse at center top, rgba(236, 185, 57, 0.1) 0%, transparent 60%);
}

/* ---------- RESPONSIVE ---------- */
@media (min-width: 480px) {
  .title {
    font-size: 2.8rem;
  }
  .sorting-hat {
    width: 240px;
  }
  .choice-card {
    min-height: 150px;
  }
  .question-text {
    font-size: 1.7rem;
  }
  .choice-label {
    font-size: 1.5rem;
  }
  .choice-icon {
    width: 80px;
    height: 80px;
  }
  .result-house {
    font-size: 3.2rem;
  }
  .result-crest svg {
    width: 180px;
    height: 200px;
  }
}

@media (min-width: 768px) {
  .welcome-wrapper,
  .result-wrapper {
    max-width: 500px;
  }
  .question-wrapper {
    max-width: 600px;
    margin: 0 auto;
  }
}

/* ---------- HAT MOUTH ANIMATION ---------- */
.hat-mouth {
  animation: mouthTalk 0.5s ease-in-out infinite alternate;
}

.hat-mouth.sorting {
  animation: mouthTalkFast 0.3s ease-in-out infinite alternate;
}

@keyframes mouthTalk {
  from { d: path("M75 170 Q100 180 125 170"); }
  to { d: path("M75 170 Q100 188 125 170"); }
}

@keyframes mouthTalkFast {
  from { d: path("M75 170 Q100 178 125 170"); }
  to { d: path("M75 170 Q100 190 125 170"); }
}

/* ---------- UTILITY ---------- */
.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;
}
