/* =======================================================
   🎨 TITE TENTTAAJA - TYYLIT (tulosten parannettu versio)
   ======================================================= */
@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Poppins:wght@600;700;800&display=swap");

/* 1️⃣ YLEISET ------------------------------------------------*/
:root {
  font-family: "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.45;
  font-size: clamp(11px, 1.2vh + 0.6vw, 16px);
  color-scheme: light dark;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  background: var(--bg-main);
  color: var(--text-main);
  transition: background-color 0.4s, color 0.4s;
}

/* 2️⃣ KORTIT JA HERO ----------------------------------------*/
.app {
  width: min(880px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1rem;
}

.card {
  background: var(--bg-surface);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: 0 8px 24px var(--shadow);
  transition: all 0.3s ease;
}

.hero {
  text-align: center;
  padding: 1.2rem 1rem 2.2rem;
  position: relative;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  max-width: 540px;
  height: clamp(220px, 25vh, 280px);
  background: radial-gradient(ellipse at top, var(--hero-glow) 0%, transparent 65%);
  opacity: 0.35;
  filter: blur(8px);
  z-index: -1;
}

.hero h1 {
  font-family: "Poppins", "Inter", "Segoe UI", sans-serif;
  font-size: clamp(2.3rem, 2.5vh + 2vw, 3.1rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  margin: 0.2rem 0 0.6rem;
  background: var(--hero-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 10px 24px rgba(15, 23, 42, 0.2);
}

.hero p {
  margin: 0;
  font-size: clamp(1rem, 1.8vh + 0.6vw, 1.2rem);
  color: var(--hero-subtitle);
  font-weight: 500;
}

.theme-toggle {
  margin-top: 0.5rem;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  padding: 0.65rem 1.6rem;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  letter-spacing: 0.02em;
  box-shadow: 0 12px 24px rgba(79, 70, 229, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.theme-toggle:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(79, 70, 229, 0.32);
}

/* 3️⃣ LOMAKE JA VALIKOT -------------------------------------*/
label {
  font-weight: 600;
  color: var(--text-secondary);
}

.controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
}

.control-group {
  flex: 1;
  min-width: 180px;
  max-width: 320px;
}

#exam-select,
input[type="number"] {
  width: 100%;
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  transition: all 0.2s ease;
  font-size: 1rem;
}

/* Kysymysten määrä -kenttä kapeammaksi */
#question-count {
  max-width: 160px;
}

/* Poistetaan numerokentän nuolet */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
}

/* Valikon ryhmäotsikot */
#exam-select option[disabled] {
  color: #888;
  font-weight: bold;
  background: var(--bg-surface);
}

/* 4️⃣ PAINIKKEET --------------------------------------------*/
button {
  font: inherit;
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.25s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* 5️⃣ KYSYMYKSET JA VASTAUKSET ------------------------------*/
.quiz-header {
  text-align: left;
}

#question-text {
  text-align: left;
  margin: 0.4rem 0 0.6rem 0;
}

.question-image {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 1rem auto;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow);
  background: var(--bg-surface);
}

.options {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.option {
  background: var(--option-bg);
  color: var(--option-text);
  border: 1px solid transparent;
  padding: 0.7rem;
  border-radius: 10px;
  transition: all 0.2s ease;
  width: 100%;
  text-align: left;
}
.option:hover:not(:disabled) {
  background: var(--option-hover);
  transform: scale(1.02);
}
.option.correct {
  background: #10b98133;
  color: #065f46;
  border-color: #10b981;
}
.option.incorrect {
  background: #ef444433;
  color: #7f1d1d;
  border-color: #ef4444;
}

.option.selected {
  box-shadow: inset 0 0 0 2px rgba(99,102,241,0.18);
  background: rgba(99,102,241,0.08);
}

/* 6️⃣ TULOKSET JA VÄÄRIN MENNEET -----------------------------*/
.results {
  display: none;
}
.results:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  text-align: left;
}

/* 6️⃣ TULOKSET JA VÄÄRIN MENNEET -----------------------------*/
.results {
  display: none;
}
.results:not(.hidden) {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  text-align: left;
  max-height: 70vh;              /* rajoitetaan kokonaiskorkeus */
  overflow-y: auto;              /* lisätään scrollaus tarvittaessa */
  padding-right: 0.5rem;         /* ettei skrollipalkki osu tekstiin */
  scroll-behavior: smooth;
}

.wrong-heading {
  margin: 0.2rem 0 0.4rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-main);
}

/* piilotetaan skrollipalkki kun sitä ei tarvita */
.results::-webkit-scrollbar {
  width: 8px;
}
.results::-webkit-scrollbar-thumb {
  background: rgba(120, 120, 120, 0.4);
  border-radius: 4px;
}
.results::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 120, 120, 0.6);
}

/* 🔹 Tiivis ja kompakti yksittäinen tulos */
.wrong-answer {
  background: var(--wrong-bg);
  margin: 0.7rem 0;
  padding: 0.75rem 1rem 0.8rem;
  border-radius: 10px;
  box-shadow: var(--wrong-shadow);
  border: 1px solid var(--wrong-border);
  line-height: 1.45;
  color: var(--text-main);
}

.wrong-answer strong {
  display: block;
  margin-bottom: 0.45rem;
  font-weight: 600;
  color: var(--text-main);
}

.wrong-your,
.wrong-correct {
  display: block;
  font-weight: 500;
  margin-left: 0.3rem;
  margin-top: 0;
  line-height: 1.2;
  color: var(--text-main);
}

.wrong-your {
  margin-bottom: 0.15rem;
}

.label-wrong {
  color: #ef4444;
  font-weight: 700;
  margin-right: 0.3rem;
}

.label-correct {
  color: #10b981;
  font-weight: 700;
  margin-right: 0.3rem;
}

/* 7️⃣ TEEMAVAIHTOPAINIKE ------------------------------------*/
#theme-toggle:hover {
  filter: brightness(1.1);
}

/* 8️⃣ TEEMAT -------------------------------------------------*/
/* Vaalea teema */
:root[data-theme="light"] {
  --bg-main: #f5f7fa;
  --bg-surface: #ffffff;
  --text-main: #111827;
  --text-secondary: #374151;
  --input-bg: #ffffff;
  --input-text: #111827;
  --option-bg: #eef2ff;
  --option-text: #111827;
  --option-hover: #c7d2fe;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --border: #cbd5e1;
  --shadow: rgba(0, 0, 0, 0.1);
  --wrong-bg: rgba(255, 255, 255, 0.82);
  --wrong-border: rgba(148, 163, 184, 0.35);
  --wrong-shadow: 0 4px 18px rgba(15, 23, 42, 0.12);
  --hero-gradient: linear-gradient(90deg, #4f46e5 0%, #8b5cf6 50%, #ec4899 100%);
  --hero-subtitle: #4b5563;
  --hero-glow: rgba(99, 102, 241, 0.35);
}

/* Tumma teema */
:root[data-theme="dark"] {
  --bg-main: #0b0b12;
  --bg-surface: #16161f;
  --text-main: #f8fafc;
  --text-secondary: #cbd5e1;
  --input-bg: #1f2028;
  --input-text: #f9fafb;
  --option-bg: #1f2028;
  --option-text: #f9fafb;
  --option-hover: #312e81;
  --accent: #7c3aed;
  --accent-text: #ffffff;
  --border: #2e2e3b;
  --shadow: rgba(0, 0, 0, 0.6);
  --wrong-bg: rgba(33, 36, 53, 0.9);
  --wrong-border: rgba(148, 163, 184, 0.18);
  --wrong-shadow: 0 10px 26px rgba(0, 0, 0, 0.55);
  --hero-gradient: linear-gradient(90deg, #a855f7 0%, #6366f1 45%, #60a5fa 100%);
  --hero-subtitle: #cbd5f5;
  --hero-glow: rgba(124, 58, 237, 0.35);
}

/* 9️⃣ PIILOTUSLUOKKA ----------------------------------------*/
.hidden {
  display: none !important;
}

/* 🔟 LUKUMATERIAALI ----------------------------------------*/
.reading-text {
  background: var(--bg-surface);
  border-left: 4px solid var(--accent-color);
  padding: 0.9rem;
  border-radius: 8px;
  line-height: 1.55;
  margin: 1rem 0;
  font-size: 0.9rem;
}

.reading-material-image {
  max-width: 100% !important;
  max-height: 300px !important;
  width: auto !important;
  height: auto !important;
  margin: 0.8rem auto !important;
  display: block !important;
}

.reading-nav {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  margin-top: 1.2rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}

.reading-nav button {
  padding: 0.55rem 1.1rem;
  background: var(--accent-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  font-size: 0.88rem;
}

.reading-nav button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px var(--accent-color);
  opacity: 0.9;
}

#question-text h3 {
  margin: 0 0 0.4rem 0;
  color: var(--accent-color);
  font-size: 1.05rem;
}

