/* ============================================
   IQ-TEEN - Main Stylesheet
   A modern, responsive quiz website for teens
   ============================================ */

/* ---------- Google Fonts ---------- */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

/* ---------- CSS Variables ---------- */
:root {
  --primary: #2563eb;
  --primary-light: #3b82f6;
  --maths: #3b82f6;
  --maths-light: #dbeafe;
  --maths-dark: #1d4ed8;
  --physics: #f97316;
  --physics-light: #ffedd5;
  --physics-dark: #ea580c;
  --chemistry: #a855f7;
  --chemistry-light: #f3e8ff;
  --chemistry-dark: #9333ea;
  --biology: #22c55e;
  --biology-light: #dcfce7;
  --biology-dark: #16a34a;
  --bg: #f8f9fb;
  --card-bg: #ffffff;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.1);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --font: 'Poppins', sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
  position: relative;
  min-height: 100vh;
}

a {
  text-decoration: none;
  color: inherit;
}

img {
  max-width: 100%;
  height: auto;
}

/* ---------- Page Transition ---------- */
.page-wrapper {
  opacity: 0;
  transform: translateY(12px);
  animation: fadeInUp 0.6s ease forwards;
  animation-delay: 0.1s;
}

@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---------- Preloader ---------- */
.preloader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  transition: opacity 0.6s ease, visibility 0.6s ease;
}

.preloader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-logo {
  font-size: 2.5rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: 2px;
  margin-bottom: 30px;
  animation: pulseLogo 1.5s ease-in-out infinite;
}

.preloader-logo span {
  background: linear-gradient(135deg, var(--maths), var(--chemistry));
  -webkit-background-clip: text;/* It controlls were the background is painted thsi means the gradient only works inside the text*/
  -webkit-text-fill-color: transparent;/*when I use webkit background clip I use this one with it*/
  background-clip: text;
}

.preloader-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--maths);
  border-right-color: var(--chemistry);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulseLogo {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* ---------- Floating Background Symbols ---------- */
.floating-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;/*It prevents it from being targeted By any event listener that uses touch hover or any mouse actions*/
  z-index: 0;
  overflow: hidden;
}

.floating-bg .symbol {
  position: absolute;
  font-size: 1.8rem;
  color: var(--text-primary);
  opacity: 0.04;
  animation: floatSymbol 20s linear infinite;
  font-weight: 600;
}

@keyframes floatSymbol {
  0% {
    transform: translateY(100vh) rotate(0deg);
    opacity: 0;
  }
  10% {
    opacity: 0.04;
  }
  90% {
    opacity: 0.04;
  }
  100% {
    transform: translateY(-10vh) rotate(360deg);
    opacity: 0;
  }
}

/* ---------- Navbar ---------- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(16px);/* blurs the pixels behind the element (the “backdrop”), creating a frosted‑glass effect*/
  -webkit-backdrop-filter: blur(16px);/*-webkit- prefix is a vendor prefix that targets WebKit (and Blink) browser engines — it enables use of experimental or engine-specific CSS features and provides compatibility fallbacks.*/
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  height: 68px;
  display: flex;
  align-items: center;
  transition: var(--transition);/*THis transition makes all effects run with the same timing and speed*/
}

.navbar.scrolled {
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06);
}

.nav-container {
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  color: var(--text-primary);
}

.nav-logo span {
  background: linear-gradient(135deg, var(--maths), var(--chemistry));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-links li a {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: var(--transition);
  display: block;
}

.nav-links li a:hover,
.nav-links li a.active {
  color: var(--primary);
  background: var(--maths-light);
}

/* Hamburger Menu */
.hamburger {
  display: none;
  flex-direction: column;
  cursor: pointer;
  gap: 5px;
  padding: 4px;
  z-index: 1001;
}

.hamburger span {/*Are the three lines*/
  width: 24px;
  height: 2.5px;
  background: var(--text-primary);
  border-radius: 4px;
  transition: var(--transition);
}

.hamburger.active span:nth-child(1) {/*nth-child(1) is equivalent to selecting the first child of this parent*/
  transform: translateY(7.5px) rotate(45deg);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: translateY(-7.5px) rotate(-45deg);
}

/*These tree span make the hamburger menu look like an X when active*/



/* Mobile Menu Overlay */
.mobile-menu {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  z-index: 999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.mobile-menu.active {
  display: flex;
  opacity: 1;
  visibility: visible;
}

.mobile-menu a {
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--text-primary);
  padding: 12px 32px;
  border-radius: 12px;
  transition: var(--transition);
}

.mobile-menu a:hover {/*when hovering on the links like math, physics and exetra a hover effect is trigered*/
  background: var(--maths-light);
  color: var(--primary);
}

/* ---------- Main Content ---------- */
.main-content {
  position: relative;
  z-index: 1;
  padding-top: 68px;
}

/* ---------- Hero Section ---------- */
.hero {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px 60px;
  display: flex;
  align-items: center;
  gap: 60px;
}

.hero-text {
  flex: 1; /*this means , take the space available to you or share it evenly if another element have the same propperty*/
}

.hero-text h1 {
  font-size: 3.2rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 16px;
  color: var(--text-primary);
}

.hero-text h1 .highlight {
  background: linear-gradient(135deg, var(--maths), var(--chemistry));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-text .subtitle {/*this is the text inside the <p> tag in html*/
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 32px;
  max-width: 480px;
  line-height: 1.7;
}

.hero-image {
  flex: 1;
  display: flex;
  justify-content: center;
}

.hero-image img {
  width: 100%;
  max-width: 460px;
  border-radius: 24px;
  box-shadow: var(--shadow);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  border: none;
  border-radius: 12px;
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {/*is the start testing button under the paragraph*/
  background: linear-gradient(135deg, var(--maths), var(--maths-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(37, 99, 235, 0.4);
}

.btn-maths {
  background: linear-gradient(135deg, var(--maths), var(--maths-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(59, 130, 246, 0.3);
}

.btn-physics {
  background: linear-gradient(135deg, var(--physics), var(--physics-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(249, 115, 22, 0.3);
}

.btn-chemistry {
  background: linear-gradient(135deg, var(--chemistry), var(--chemistry-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(168, 85, 247, 0.3);
}

.btn-biology {
  background: linear-gradient(135deg, var(--biology), var(--biology-dark));
  color: #fff;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}

.btn-maths:hover,
.btn-physics:hover,
.btn-chemistry:hover,
.btn-biology:hover {/*All these buttons have now a hover effect that lifts them up and brightens them slightly*/
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.btn-outline {
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text-primary);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--maths-light);
}

/* ---------- Section Header ---------- */
.section-header { /*is the div that has the text choose your subject*/
  text-align: center;
  max-width: 600px;
  margin: 0 auto 48px;
}

.section-header h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.section-header p {
  color: var(--text-secondary);
  font-size: 1.05rem;
}

/* ---------- Subject Cards Grid ---------- */
.subjects-section {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 24px 80px;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

.subject-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.subject-card::before {/*A CSS pseudo‑element that inserts a generated element as the first child of the selected element.*/
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  border-radius: var(--radius) var(--radius) 0 0;
}

.subject-card.maths::before { background: linear-gradient(90deg, var(--maths), var(--maths-dark)); }
.subject-card.physics::before { background: linear-gradient(90deg, var(--physics), var(--physics-dark)); }
.subject-card.chemistry::before { background: linear-gradient(90deg, var(--chemistry), var(--chemistry-dark)); }
.subject-card.biology::before { background: linear-gradient(90deg, var(--biology), var(--biology-dark)); }

.subject-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
}

.subject-card .icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  margin: 0 auto 20px;
}

.subject-card.maths .icon { background: var(--maths-light); }
.subject-card.physics .icon { background: var(--physics-light); }
.subject-card.chemistry .icon { background: var(--chemistry-light); }
.subject-card.biology .icon { background: var(--biology-light); }

.subject-card h3 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.subject-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 20px;
  line-height: 1.6;
}

.subject-card .btn {
  width: 100%;
  padding: 12px 20px;
  font-size: 0.9rem;
}

/* ---------- Subject Detail Page ---------- */
.subject-hero {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 24px 40px;
  text-align: center;
}

.subject-hero .subject-icon {
  width: 80px;
  height: 80px;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.2rem;
  margin: 0 auto 24px;
}

.subject-hero.maths .subject-icon { background: var(--maths-light); }
.subject-hero.physics .subject-icon { background: var(--physics-light); }
.subject-hero.chemistry .subject-icon { background: var(--chemistry-light); }
.subject-hero.biology .subject-icon { background: var(--biology-light); }

.subject-hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  margin-bottom: 12px;
}

.subject-hero p {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 500px;
  margin: 0 auto;
  line-height: 1.7;
}

/* Level Cards */
.levels-section {
  max-width: 700px;
  margin: 0 auto;
  padding: 20px 24px 80px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

.level-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: var(--transition);
  border: 1px solid var(--border);
}

.level-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.level-card .level-badge {
  display: inline-block;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 16px;
}

.level-card.easy .level-badge {
  background: #dcfce7;
  color: #16a34a;
}

.level-card.hard .level-badge {
  background: #fef2f2;
  color: #dc2626;
}

.level-card h3 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.level-card p {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 24px;
  line-height: 1.6;
}

.level-card .btn {
  width: 100%;
  padding: 12px 24px;
}

/* ---------- Quiz Page ---------- */
.quiz-header {
  max-width: 800px;
  margin: 0 auto;
  padding: 80px 24px 0;
  text-align: center;
}

.quiz-header h1 {
  font-size: 2rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.quiz-header p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* Progress Bar */
.progress-container {
  max-width: 800px;
  margin: 0 auto 32px;
  padding: 0 24px;
}

.progress-bar-wrapper {
  background: var(--border);
  border-radius: 20px;
  height: 10px;
  overflow: hidden;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--maths), var(--chemistry));
  transition: width 0.4s ease;
  width: 0%;
}

.progress-text {
  text-align: right;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 8px;
  font-weight: 500;
}

/* Quiz Questions */
.quiz-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 40px;
}

.question-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: var(--transition);
}

.question-card:hover {
  border-color: var(--primary-light);
}

.question-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 12px;
  color: #fff;
}

.question-card[data-subject="maths"] .question-number { background: var(--maths); }
.question-card[data-subject="physics"] .question-number { background: var(--physics); }
.question-card[data-subject="chemistry"] .question-number { background: var(--chemistry); }
.question-card[data-subject="biology"] .question-number { background: var(--biology); }

.question-text {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 16px;
  line-height: 1.6;
}

.question-input {
  width: 100%;
  padding: 12px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--bg);
  transition: var(--transition);
  outline: none;
}

.question-input:focus {
  border-color: var(--primary-light);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.1);
}

.question-input.error {
  border-color: #ef4444;
  background: #fef2f2;
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.question-input.filled {
  border-color: #22c55e;
  background: #f0fdf4;
}

.error-message {
  color: #ef4444;
  font-size: 0.8rem;
  font-weight: 500;
  margin-top: 6px;
  display: none;
}

.error-message.visible {
  display: block;
}

/* Submit Section */
.quiz-submit {
  max-width: 800px;
  margin: 0 auto;
  padding: 0 24px 80px;
  text-align: center;
}

.quiz-submit .btn {
  min-width: 240px;
  padding: 16px 40px;
  font-size: 1.05rem;
}

.quiz-submit .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* ---------- Results Page ---------- */
.results-section {
  max-width: 600px;
  margin: 0 auto;
  padding: 100px 24px 80px;
  text-align: center;
}

.results-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 48px 36px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.results-card .emoji {
  font-size: 4rem;
  margin-bottom: 20px;
  display: block;
}

.score-circle {
  width: 160px;
  height: 160px;
  border-radius: 50%;
  border: 8px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin: 0 auto 28px;
  position: relative;
}

.score-circle .score-value {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1;
}

.score-circle .score-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.score-circle.genius { border-color: var(--maths); }
.score-circle.genius .score-value { color: var(--maths); }

.score-circle.excellent { border-color: var(--biology); }
.score-circle.excellent .score-value { color: var(--biology); }

.score-circle.good { border-color: var(--physics); }
.score-circle.good .score-value { color: var(--physics); }

.score-circle.low { border-color: #ef4444; }
.score-circle.low .score-value { color: #ef4444; }

.results-message {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.results-detail {
  color: var(--text-secondary);
  font-size: 1rem;
  margin-bottom: 32px;
}

.results-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.results-actions .btn {
  min-width: 160px;
}

/* ---------- Confetti ---------- */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -20px;
  opacity: 0;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg) scale(0.5);
  }
}

/* ---------- Footer ---------- */
.footer {
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  padding: 32px 24px;
  text-align: center;
}

.footer p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.footer span {
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Tablet */
@media (max-width: 1024px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .hero {
    gap: 40px;
    padding: 60px 24px 40px;
  }

  .hero-text h1 {
    font-size: 2.5rem;
  }
}

/* Mobile */
@media (max-width: 768px) {
  .hamburger {
    display: flex;
  }

  .nav-links {
    display: none;
  }

  .hero {
    flex-direction: column;
    text-align: center;
    padding: 40px 20px 32px;
    gap: 32px;
  }

  .hero-text h1 {
    font-size: 2rem;
  }

  .hero-text .subtitle {
    margin: 0 auto 24px;
    font-size: 1rem;
  }

  .hero-image img {
    max-width: 320px;
  }

  .cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  .levels-section {
    grid-template-columns: 1fr;
  }

  .section-header h2 {
    font-size: 1.6rem;
  }

  .subject-hero h1 {
    font-size: 1.8rem;
  }

  .quiz-header h1 {
    font-size: 1.5rem;
  }

  .question-card {
    padding: 20px;
  }

  .results-card {
    padding: 32px 20px;
  }

  .score-circle {
    width: 130px;
    height: 130px;
  }

  .score-circle .score-value {
    font-size: 2.2rem;
  }

  .results-actions {
    flex-direction: column;
    align-items: center;
  }

  .results-actions .btn {
    width: 100%;
    max-width: 280px;
  }
}

/* Small Mobile */
@media (max-width: 400px) {
  .hero-text h1 {
    font-size: 1.7rem;
  }

  .navbar {
    padding: 0 16px;
  }

  .subjects-section,
  .quiz-container,
  .quiz-submit,
  .progress-container {
    padding-left: 16px;
    padding-right: 16px;
  }
}
