/* =========================================================
   MISIJA: OTOPINE – Kemija 7. razred
   style.css
   ========================================================= */

/* ---------- 1. VARIJABLE I OSNOVA ---------- */
:root {
  --primary: #2563eb;
  --primary-dark: #1e40af;
  --accent: #f59e0b;
  --success: #16a34a;
  --danger: #dc2626;
  --purple: #7c3aed;
  --bg: #eef4ff;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --water: #7dd3fc;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(30, 64, 175, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Segoe UI", "Nunito", Arial, sans-serif;
  background: linear-gradient(180deg, var(--bg), #f8fbff);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

h1 { font-size: 1.9rem; margin-bottom: 0.8rem; color: var(--primary-dark); }
h2 { font-size: 1.35rem; margin: 1.2rem 0 0.6rem; color: var(--primary-dark); }
h3 { font-size: 1.1rem; margin: 0.6rem 0 0.4rem; }
p  { margin-bottom: 0.6rem; }

.hidden { display: none !important; }
.center { text-align: center; }

/* ---------- 2. ZAGLAVLJE + GAMIFIKACIJA ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.5rem;
  background: linear-gradient(90deg, var(--primary-dark), var(--purple));
  color: #fff;
  box-shadow: var(--shadow);
}
.logo { font-size: 1.5rem; font-weight: 800; }
.logo span { color: var(--accent); }

.player { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
#playerName {
  padding: 0.4rem 0.7rem; border: none; border-radius: 8px;
  font-size: 0.95rem; width: 160px;
}
.level-box { display: flex; flex-direction: column; min-width: 180px; font-size: 0.85rem; }
#levelName { font-weight: 700; color: #fde68a; }
.xp-bar {
  height: 10px; background: rgba(255,255,255,0.25);
  border-radius: 10px; overflow: hidden; margin: 3px 0;
}
#xpFill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, #facc15, #f97316);
  transition: width 0.6s ease;
}
.badges { display: flex; gap: 4px; font-size: 1.5rem; }
.badges span { animation: pop 0.5s ease; cursor: help; }

/* ---------- 3. NAVIGACIJA ---------- */
.tabs {
  display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center;
  padding: 0.8rem; background: #fff; box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.tab {
  border: 2px solid transparent; background: var(--bg);
  padding: 0.5rem 0.9rem; border-radius: 999px;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: all 0.2s;
}
.tab:hover { border-color: var(--primary); transform: translateY(-2px); }
.tab.active { background: var(--primary); color: #fff; }

/* ---------- 4. PANELI ---------- */
main { max-width: 1150px; margin: 1.5rem auto; padding: 0 1rem; }
.panel { display: none; animation: fadeIn 0.4s ease; }
.panel.active { display: block; }

.card {
  background: var(--card); border-radius: var(--radius);
  padding: 1.2rem 1.4rem; margin-bottom: 1.2rem; box-shadow: var(--shadow);
}
.hint {
  background: #fff7ed; border-left: 5px solid var(--accent);
  padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 1rem;
}

/* ---------- 5. GUMBI I UNOSI ---------- */
.btn {
  background: var(--primary); color: #fff; border: none;
  padding: 0.55rem 1.1rem; border-radius: 10px; margin: 0.3rem 0.2rem;
  font-size: 0.95rem; font-weight: 600; cursor: pointer;
  transition: transform 0.15s, background 0.2s;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-2px); }
.btn:active { transform: scale(0.96); }
.btn.big { font-size: 1.15rem; padding: 0.8rem 1.8rem; margin-top: 1rem; }
.btn.ghost { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn.ghost:hover { background: var(--bg); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

input[type="number"], input[type="text"], select, textarea {
  padding: 0.45rem 0.6rem; border: 2px solid #cbd5e1; border-radius: 8px;
  font-size: 1rem; font-family: inherit;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); }
input[type="number"] { width: 90px; }
textarea { width: 100%; min-height: 80px; margin-bottom: 0.6rem; }
input[type="range"] { width: 100%; accent-color: var(--primary); }
label { display: block; margin: 0.5rem 0; font-weight: 600; }

/* ---------- 6. UVOD ---------- */
.story { border-left: 6px solid var(--purple); font-size: 1.05rem; }
.goals { list-style: none; display: grid; gap: 0.4rem; margin-bottom: 1rem; }
.goals li { background: #fff; padding: 0.5rem 0.9rem; border-radius: 8px; }

.cards-grid {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}
.card.life { text-align: center; transition: transform 0.2s; }
.card.life:hover { transform: translateY(-5px) rotate(-1deg); }
.card.life span { font-size: 2.6rem; display: block; }

/* ---------- 7. FLIP KARTICE (pojmovi) ---------- */
.flip-grid {
  display: grid; gap: 1rem; margin-bottom: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}
.flip-card { perspective: 900px; height: 160px; cursor: pointer; }
.flip-inner {
  position: relative; width: 100%; height: 100%;
  transition: transform 0.6s; transform-style: preserve-3d;
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-front, .flip-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; align-items: center; justify-content: center;
  padding: 1rem; text-align: center;
}
.flip-front {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff; font-size: 1.2rem; font-weight: 700;
}
.flip-back { background: #fff; transform: rotateY(180deg); font-size: 0.92rem; }

/* ---------- 8. ČAŠE – vrste otopina ---------- */
.sat-row {
  display: grid; gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.sat { padding: 1rem; border-radius: 12px; text-align: center; }
.sat.nez  { background: #ecfdf5; }
.sat.zas  { background: #eff6ff; }
.sat.prez { background: #fdf4ff; }

.beaker {
  position: relative; width: 90px; height: 110px; margin: 0.8rem auto 0;
  border: 3px solid #64748b; border-top: none;
  border-radius: 0 0 14px 14px; overflow: hidden; background: #f8fafc;
}
.liquid { position: absolute; bottom: 0; width: 100%; height: 75%; }
.l1 { background: rgba(125, 211, 252, 0.55); }
.l2 { background: rgba(59, 130, 246, 0.65); }
.l3 { background: rgba(124, 58, 237, 0.65); animation: shimmer 2s infinite; }
.sediment {
  position: absolute; bottom: 0; width: 100%; height: 14%;
  background: repeating-linear-gradient(45deg, #fff 0 4px, #e2e8f0 4px 8px);
}

/* ---------- 9. FORMULE ---------- */
.formula { border-left: 6px solid var(--success); }
.eq {
  font-family: "Cambria Math", "Times New Roman", serif;
  font-size: 1.3rem; text-align: center;
  background: #f0fdf4; padding: 0.5rem; border-radius: 8px;
}

/* ---------- 10. GRAF TOPLJIVOSTI ---------- */
.graph-wrap {
  display: grid; gap: 1rem; grid-template-columns: 2fr 1fr; align-items: start;
}
#solCanvas, #myCanvas {
  width: 100%; height: auto; background: #fff;
  border-radius: var(--radius); box-shadow: var(--shadow); cursor: crosshair;
}
#myCanvas { margin: 1rem 0; cursor: default; }
#substanceToggles label {
  display: flex; align-items: center; gap: 0.5rem;
  font-weight: 600; cursor: pointer;
}
.color-dot { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.readout {
  margin-top: 1rem; background: var(--bg); border-radius: 10px;
  padding: 0.7rem; font-size: 0.95rem;
}
.readout div { display: flex; justify-content: space-between; }
.tip { border-left: 6px solid var(--accent); }

/* ---------- 11. VIRTUALNI LABORATORIJ ---------- */
.lab { display: grid; gap: 1.5rem; grid-template-columns: 1fr 1fr; }
.lab-btns { margin-top: 0.6rem; }
.lab-view { display: flex; flex-direction: column; align-items: center; }

.big-beaker {
  position: relative; width: 200px; height: 240px;
  border: 4px solid #475569; border-top: none;
  border-radius: 0 0 26px 26px; overflow: hidden; background: #f8fafc;
}
.lab-liquid {
  position: absolute; bottom: 0; width: 100%; height: 70%;
  background: rgba(125, 211, 252, 0.6);
  transition: background 0.6s, height 0.6s;
}
.lab-sediment {
  position: absolute; bottom: 0; width: 100%; height: 0;
  background: repeating-linear-gradient(45deg, #fff 0 5px, #cbd5e1 5px 10px);
  transition: height 0.6s;
}
.thermo {
  position: absolute; right: 8px; top: 15px;
  width: 12px; height: 160px; border: 2px solid #475569;
  border-radius: 8px; background: #fff; overflow: hidden;
}
#thermoFill {
  position: absolute; bottom: 0; width: 100%; height: 20%;
  background: linear-gradient(0deg, #3b82f6, #ef4444);
  transition: height 0.6s;
}
.lab-result {
  margin-top: 1rem; padding: 0.8rem 1rem; border-radius: 10px;
  width: 100%; text-align: center; font-weight: 600; background: var(--bg);
}
.lab-result.nez  { background: #dcfce7; color: #166534; }
.lab-result.zas  { background: #dbeafe; color: #1e40af; }
.lab-result.talog { background: #fee2e2; color: #991b1b; }

.challenge { border-left: 6px solid var(--purple); }
.challenge li { margin: 0.4rem 0 0.4rem 1.2rem; }
.challenge li.done { color: var(--success); text-decoration: line-through; }

/* čestice koje padaju u čašu */
.particle {
  position: absolute; top: 0; width: 6px; height: 6px;
  background: #fff; border: 1px solid #94a3b8; border-radius: 2px;
  animation: drop 0.9s ease-in forwards;
}

/* ---------- 12. MASENI UDIO ---------- */
#racun label { display: inline-block; margin-right: 1rem; }
.calc-out {
  margin-top: 1rem; background: #f0fdf4; border-radius: 10px;
  padding: 0.8rem 1rem; font-family: "Cambria Math", serif; font-size: 1.05rem;
}
.calc-out:empty { display: none; }
#genTask { font-size: 1.05rem; font-weight: 600; }
#genAnswer { width: 180px; }
#genFeedback { margin-top: 0.6rem; font-weight: 600; }

/* ---------- 13. PRAKTIČNA PROVJERA ---------- */
.practice-item {
  background: #fff; border-radius: 12px; padding: 1rem 1.2rem;
  margin-bottom: 0.9rem; box-shadow: var(--shadow);
  border-left: 6px solid #cbd5e1; transition: border-color 0.3s;
}
.practice-item.ok  { border-left-color: var(--success); background: #f0fdf4; }
.practice-item.bad { border-left-color: var(--danger); animation: shake 0.4s; }
.practice-item input { margin-right: 0.5rem; }
.practice-item .fb { margin-top: 0.4rem; font-weight: 600; }
.score-line {
  text-align: center; font-size: 1.2rem; font-weight: 700;
  margin: 1rem 0; color: var(--primary-dark);
}

/* ---------- 14. KVIZ ---------- */
.quiz-top {
  display: flex; justify-content: space-between;
  font-weight: 700; margin-bottom: 0.8rem; color: var(--muted);
}
#quizTimer.low { color: var(--danger); animation: pulse 0.8s infinite; }
.quiz-options { display: grid; gap: 0.7rem; margin: 1rem 0; }
.option {
  text-align: left; padding: 0.8rem 1rem; border-radius: 10px;
  border: 2px solid #cbd5e1; background: #fff;
  font-size: 1rem; cursor: pointer; transition: all 0.2s;
}
.option:hover:not(:disabled) { border-color: var(--primary); background: var(--bg); }
.option.correct { background: #dcfce7; border-color: var(--success); }
.option.wrong   { background: #fee2e2; border-color: var(--danger); animation: shake 0.4s; }
.option:disabled { cursor: default; }
.explain { font-style: italic; color: var(--muted); }
#quizEnd h2 { font-size: 1.8rem; }
.stars { font-size: 2.5rem; margin: 0.5rem 0; }

/* ---------- 15. PROJEKT ---------- */
.data-table { width: 100%; border-collapse: collapse; margin: 0.6rem 0; }
.data-table th, .data-table td {
  border: 1px solid #cbd5e1; padding: 0.4rem; text-align: center;
}
.data-table th { background: var(--primary); color: #fff; }
.data-table input { width: 100%; border: none; text-align: center; }
.safety {
  background: #fef2f2; border-left: 6px solid var(--danger); color: #7f1d1d;
}

/* ---------- 16. TOAST (obavijesti) ---------- */
.toast {
  position: fixed; bottom: 25px; left: 50%;
  transform: translateX(-50%) translateY(150%);
  background: #111827; color: #fff;
  padding: 0.8rem 1.5rem; border-radius: 999px;
  font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  transition: transform 0.4s ease; z-index: 100;
}
.toast.show { transform: translateX(-50%) translateY(0); }

/* konfeti */
.confetti {
  position: fixed; top: -10px; width: 10px; height: 14px; z-index: 99;
  animation: fall 2.5s linear forwards;
}

/* ---------- 17. PODNOŽJE ---------- */
footer { text-align: center; padding: 1.5rem; color: var(--muted); font-size: 0.9rem; }

/* ---------- 18. ANIMACIJE ---------- */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes pop { 0% { transform: scale(0); } 70% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}
@keyframes pulse { 50% { opacity: 0.4; } }
@keyframes shimmer { 50% { filter: brightness(1.25); } }
@keyframes drop { to { transform: translateY(220px); opacity: 0; } }
@keyframes fall { to { transform: translateY(105vh) rotate(720deg); } }

/* ---------- 19. PRILAGODBA ZA MOBITEL/TABLET ---------- */
@media (max-width: 800px) {
  .graph-wrap, .lab { grid-template-columns: 1fr; }
  .topbar { justify-content: center; text-align: center; }
  h1 { font-size: 1.5rem; }
  .tab { font-size: 0.85rem; padding: 0.4rem 0.7rem; }
}

/* ---------- 20. ISPIS (projekt) ---------- */
@media print {
  .topbar, .tabs, footer, .btn, .toast, .safety { display: none !important; }
  .panel { display: none !important; }
  #projekt { display: block !important; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}
