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

:root {
  --kerala-green: #1B6B3A;
  --kerala-gold: #E6A817;
  --kerala-saffron: #FF6B35;
  --kerala-blue: #3A9ED4;
  --sky-top: #87CEEB;
  --sky-bot: #FFF0C8;
  --card-bg: #FFFDF0;
  --card-border: #E6A817;
  --font-main: 'Baloo 2', cursive;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-main);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--sky-top) 0%, var(--sky-bot) 60%, #7DBF5A 100%);
  overflow-x: hidden;
  position: relative;
}

/* ===== BACKGROUND SCENE ===== */
.bg-scene {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

/* Sun */
.sun {
  position: absolute;
  top: 20px;
  right: 80px;
  width: 80px;
  height: 80px;
  animation: rotateSun 20s linear infinite;
}
@keyframes rotateSun { to { transform: rotate(360deg); } }

/* Clouds */
.cloud {
  position: absolute;
  background: white;
  border-radius: 50px;
  opacity: 0.85;
}
.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: white;
  border-radius: 50%;
}
.cloud1 { width: 120px; height: 40px; top: 60px; left: -140px; animation: driftCloud 30s linear infinite; }
.cloud1::before { width: 60px; height: 55px; top: -30px; left: 20px; }
.cloud1::after { width: 40px; height: 40px; top: -20px; left: 55px; }
.cloud2 { width: 90px; height: 30px; top: 110px; left: -100px; animation: driftCloud 45s linear infinite 10s; }
.cloud2::before { width: 45px; height: 45px; top: -25px; left: 15px; }
.cloud2::after { width: 35px; height: 35px; top: -15px; left: 45px; }
.cloud3 { width: 140px; height: 45px; top: 40px; left: -160px; animation: driftCloud 55s linear infinite 20s; }
.cloud3::before { width: 70px; height: 60px; top: -35px; left: 25px; }
.cloud3::after { width: 50px; height: 50px; top: -25px; left: 70px; }
@keyframes driftCloud { from { left: -200px; } to { left: 110vw; } }

/* Trees */
.coconut-tree {
  position: absolute;
  bottom: 100px;
  width: 90px;
  height: 220px;
}
.tree-left { left: 8px; transform: rotate(-5deg); }
.tree-right { right: 8px; transform: rotate(5deg) scaleX(-1); }

.banana-tree {
  position: absolute;
  bottom: 100px;
  width: 70px;
  height: 180px;
}
.btree-left { left: 90px; }
.btree-right { right: 90px; }

/* River */
.river {
  position: absolute;
  bottom: 60px;
  left: 0; right: 0;
  width: 100%;
  height: 100px;
  animation: flowRiver 6s ease-in-out infinite;
}
@keyframes flowRiver { 0%,100% { transform: translateX(0); } 50% { transform: translateX(-15px); } }

.boat { animation: sailBoat 18s linear infinite; }
@keyframes sailBoat { from { transform: translateX(0); } to { transform: translateX(1200px); } }

/* Ground */
.ground {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 75px;
  background: linear-gradient(to bottom, #5A9E3A 0%, #3D7A2A 100%);
  border-top: 4px solid #7DBF5A;
}

.grass-row {
  position: absolute;
  bottom: 68px;
  width: 100%;
  display: flex;
  justify-content: space-around;
  font-size: 1.4rem;
}
.grass-tuft { animation: swayGrass 3s ease-in-out infinite; display: inline-block; }
.grass-tuft:nth-child(even) { animation-delay: 0.5s; animation-direction: alternate-reverse; }
@keyframes swayGrass { 0%,100% { transform: rotate(-5deg); } 50% { transform: rotate(5deg); } }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 16px 180px;
}

/* ===== HEADER ===== */
.site-header {
  text-align: center;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.header-emblem { font-size: 2.5rem; animation: bounce 2s ease-in-out infinite; display: inline-block; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.site-title {
  font-size: clamp(2rem, 6vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, #1B6B3A, #E6A817, #FF6B35);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: none;
  letter-spacing: 1px;
  filter: drop-shadow(2px 3px 0px rgba(0,0,0,0.15));
  line-height: 1.1;
}

.site-subtitle {
  font-size: 1.05rem;
  font-weight: 600;
  color: #1B6B3A;
  background: rgba(255,255,255,0.75);
  padding: 8px 20px;
  border-radius: 20px;
  border: 2px solid var(--kerala-gold);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.subtitle-en { font-size: 0.85rem; color: #555; font-weight: 400; }

/* ===== SELECTION ZONE (arrow + cards wrapper) ===== */
.selection-zone {
  position: relative;
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 32px;
}

/* ===== ARROW ===== */
.arrow-container {
  position: absolute;
  /* sits just above the cards; cards-container starts at arrow-container height */
  top: 0;
  left: 0;
  width: 100%;
  height: 52px;
  z-index: 10;
  pointer-events: none;
}
.arrow-pointer {
  position: absolute;
  font-size: 2.2rem;
  top: 4px;
  left: 0;
  transform: translateX(-50%);   /* centre the emoji on the target X */
  transition: left 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 2px 6px rgba(0,0,0,0.3));
  animation: arrowBob 0.5s ease-in-out infinite;
  white-space: nowrap;
}
@keyframes arrowBob { 0%,100% { top: 4px; } 50% { top: 12px; } }

/* ===== CARDS ===== */
.cards-container {
  display: flex;
  flex-wrap: nowrap;              /* always one row */
  gap: 20px;
  justify-content: center;
  width: 100%;
  /* push down to make room for the arrow-container (52px) */
  margin-top: 52px;
  padding: 0 8px;
}

.candidate-card {
  background: var(--card-bg);
  border: 4px solid var(--card-border);
  border-radius: 24px;
  flex: 1 1 200px;                /* fluid: grow/shrink but start at 200px */
  max-width: 260px;
  padding: 20px 12px;
  text-align: center;
  box-shadow: 6px 8px 0px #C8890A, 0 12px 30px rgba(0,0,0,0.15);
  transition: transform 0.25s, box-shadow 0.25s;
  position: relative;
  cursor: default;
  background-image:
    radial-gradient(circle at 20% 20%, rgba(255,215,0,0.08) 0%, transparent 50%),
    radial-gradient(circle at 80% 80%, rgba(27,107,58,0.06) 0%, transparent 50%);
}
.candidate-card:hover { transform: translateY(-6px) rotate(-1deg); box-shadow: 8px 14px 0px #C8890A, 0 18px 40px rgba(0,0,0,0.2); }
.candidate-card.highlighted {
  border-color: #FF4444;
  box-shadow: 6px 8px 0px #CC0000, 0 0 30px rgba(255,68,68,0.5);
  transform: translateY(-8px) scale(1.04);
  animation: highlightPulse 0.4s ease-in-out infinite alternate;
}
@keyframes highlightPulse { from { box-shadow: 6px 8px 0px #CC0000, 0 0 20px rgba(255,68,68,0.4); } to { box-shadow: 8px 12px 0px #CC0000, 0 0 45px rgba(255,68,68,0.8); } }
.candidate-card.winner {
  border-color: var(--kerala-gold);
  box-shadow: 6px 8px 0px #A07800, 0 0 50px rgba(230,168,23,0.7);
  animation: winnerGlow 1s ease-in-out infinite alternate;
}
@keyframes winnerGlow { from { box-shadow: 6px 8px 0px #A07800, 0 0 30px rgba(230,168,23,0.5); } to { box-shadow: 8px 14px 0px #A07800, 0 0 70px rgba(230,168,23,0.9); } }

.card-number-badge {
  position: absolute;
  top: -14px; right: -14px;
  background: var(--kerala-saffron);
  color: white;
  width: 32px; height: 32px;
  border-radius: 50%;
  font-size: 0.9rem;
  font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid white;
  box-shadow: 2px 2px 0 #C04A1A;
}

.card-photo-wrap {
  width: 150px;
  height: 150px;
  margin: 0 auto 14px;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--kerala-green);
  box-shadow: 4px 4px 0 var(--kerala-green);
  background: #ddd;
  position: relative;
}
.card-photo-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}
.card-photo-placeholder {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  background: linear-gradient(135deg, #e0f0e8, #c8e6d4);
}

.card-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #1B3A28;
  margin-bottom: 4px;
  line-height: 1.2;
}
.card-party {
  font-size: 0.8rem;
  font-weight: 600;
  color: #555;
  background: rgba(27,107,58,0.1);
  padding: 3px 10px;
  border-radius: 12px;
  display: inline-block;
  margin-bottom: 8px;
}
.card-tagline {
  font-size: 0.75rem;
  color: #888;
  font-style: italic;
}

/* ===== BUTTON ===== */
.btn-area { margin: 8px 0 24px; }

.select-btn {
  background: linear-gradient(135deg, #1B6B3A, #2E9E5A);
  color: white;
  border: 4px solid #0D4A24;
  border-radius: 50px;
  padding: 16px 48px;
  font-family: var(--font-main);
  font-size: 1.4rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 0 #0D4A24, 0 8px 20px rgba(0,0,0,0.25);
  transition: transform 0.15s, box-shadow 0.15s, background 0.3s;
  display: flex; align-items: center; gap: 12px;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}
.select-btn::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
  border-radius: inherit;
}
.select-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 9px 0 #0D4A24, 0 12px 28px rgba(0,0,0,0.3);
}
.select-btn:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 3px 0 #0D4A24, 0 4px 12px rgba(0,0,0,0.2);
}
.select-btn:disabled {
  cursor: not-allowed;
  background: linear-gradient(135deg, #E6A817, #F5C842);
  border-color: #C08000;
  box-shadow: 0 6px 0 #C08000;
  animation: selectingPulse 1s ease-in-out infinite;
}
@keyframes selectingPulse {
  0%,100% { box-shadow: 0 6px 0 #C08000, 0 0 10px rgba(230,168,23,0.3); }
  50% { box-shadow: 0 6px 0 #C08000, 0 0 30px rgba(230,168,23,0.7); }
}

/* ===== RESULT SECTION ===== */
.result-section {
  margin-top: 20px;
  text-align: center;
  animation: resultAppear 0.6s cubic-bezier(0.34,1.56,0.64,1);
}
@keyframes resultAppear {
  from { opacity: 0; transform: scale(0.5) rotate(-5deg); }
  to { opacity: 1; transform: scale(1) rotate(0deg); }
}

.result-banner {
  background: linear-gradient(135deg, #fffbe6, #fff9d0);
  border: 5px solid var(--kerala-gold);
  border-radius: 28px;
  padding: 28px 40px;
  box-shadow: 8px 10px 0 #C8890A, 0 20px 50px rgba(0,0,0,0.2);
  max-width: 420px;
  margin: 0 auto 20px;
}
.result-crown { font-size: 3rem; animation: crownBounce 0.8s ease-in-out infinite alternate; display: block; margin-bottom: 8px; }
@keyframes crownBounce { from { transform: translateY(0) rotate(-5deg); } to { transform: translateY(-10px) rotate(5deg); } }
.result-title { font-size: 1.3rem; font-weight: 700; color: #5A4000; margin-bottom: 12px; }
.result-name {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #1B6B3A, #E6A817);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 12px;
  line-height: 1.2;
}
.result-stars { font-size: 1.5rem; letter-spacing: 8px; }

.share-btn {
  background: linear-gradient(135deg, #25D366, #128C7E);
  color: white;
  border: 3px solid #0A6A5A;
  border-radius: 50px;
  padding: 14px 36px;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 5px 0 #0A6A5A, 0 8px 20px rgba(0,0,0,0.2);
  transition: transform 0.15s, box-shadow 0.15s;
  display: inline-flex; align-items: center; gap: 10px;
}
.share-btn:hover { transform: translateY(-3px); box-shadow: 0 8px 0 #0A6A5A, 0 12px 28px rgba(0,0,0,0.25); }
.share-btn:active { transform: translateY(2px); box-shadow: 0 3px 0 #0A6A5A; }

/* ===== CONFETTI ===== */
.confetti-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
  top: -20px;
}
@keyframes confettiFall {
  0% { transform: translateY(0) rotate(0deg) translateX(0); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(105vh) rotate(720deg) translateX(var(--drift)); opacity: 0; }
}
.popper-emoji {
  position: absolute;
  font-size: 2rem;
  animation: popperFly 1.5s ease-out forwards;
  pointer-events: none;
}
@keyframes popperFly {
  0% { transform: translate(0,0) rotate(0deg) scale(0.5); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--dr)) scale(1.2); opacity: 0; }
}

/* ===== FOOTER ===== */
.site-footer {
  margin-top: 40px;
  text-align: center;
  color: #2D6B3A;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(255,255,255,0.6);
  padding: 12px 24px;
  border-radius: 20px;
  border: 2px solid rgba(27,107,58,0.3);
}

/* ===== RESPONSIVE ===== */
@media (max-width: 700px) {
  /* Shrink cards to fit 3 in one row; photo scales down */
  .cards-container { gap: 8px; padding: 0 4px; }
  .candidate-card { padding: 12px 6px; border-radius: 16px; border-width: 3px; }
  .card-photo-wrap { width: 80px; height: 80px; border-width: 3px; }
  .card-name { font-size: 0.75rem; }
  .card-party { font-size: 0.65rem; padding: 2px 6px; }
  .card-tagline { display: none; }
  .card-number-badge { width: 24px; height: 24px; font-size: 0.7rem; top: -10px; right: -10px; }
  .select-btn { padding: 12px 28px; font-size: 1.1rem; }
  .coconut-tree { width: 60px; height: 150px; }
  .banana-tree { width: 50px; height: 130px; }
  .site-title { font-size: 1.8rem; }
  .arrow-pointer { font-size: 1.8rem; }
}
