/* ===========================
   UNIVERSAL QUIZ STYLESHEET
   =========================== */

/* ===========================
   UNIVERSAL QUIZ STYLESHEET - NAVBAR SAFE + CENTERED
   =========================== */

/* Core Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;

  /* Flex centering */
  display: flex;
  justify-content: center;
  align-items: center;

  /* Fallback padding */
  padding: 20px;
}

/* --- Navbar safe wrapper --- */
body.has-nav-banner {
  /* preserve flex centering but offset content by navbar */
  display: flex;
  flex-direction: column;
}

body.has-nav-banner .quiz-wrapper {
  /* vertically center, full height minus navbar */
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: calc(100vh - var(--nav-height, 120px));
}
/* --- Container --- */
.container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 40px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  max-width: 1400px;
  width: 100%;
}

/* --- Headings --- */
h2 {
  text-align: center;
  color: #333;
  font-size: 32px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

h3 {
  text-align: center;
  color: #555;
  font-size: 24px;
  margin-bottom: 25px;
}

/* --- Header and Score Controls --- */
.header-row {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 30px;
  min-height: 48px;
  flex-wrap: wrap;
  gap: 10px;
}

.header-row h2 {
  margin: 0;
  flex: 1 1 100%;
  text-align: center;
}

.score-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  justify-content: center;
}

#scoreDisplay {
  color: #555;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 22px;
  background: transparent;
}

.reset-btn {
  background: #f44336;
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: bold;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.reset-btn:hover {
  background: #d32f2f;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

/* --- Target Display (iframe or matrix area) --- */
#target {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  margin-bottom: 30px;
  width: 100%;
  min-height: 400px;
}

#target iframe {
  width: 600px;
  height: 400px;
  border: 3px solid #667eea;
  border-radius: 15px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  max-width: 100%;
}

/* --- Matrix / Graph Section (from Style 2) --- */
.graph-type-badge {
  text-align: center;
  margin-bottom: 20px;
}

.graph-type-badge span {
  background: rgba(102, 126, 234, 0.2);
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: bold;
  color: #667eea;
}

.matrix-display {
  background: white;
  border: 3px solid #667eea;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  margin-bottom: 15px;
}

.matrix-display table {
  border-collapse: collapse;
}

.matrix-display td {
  width: 50px;
  height: 50px;
  text-align: center;
  border: 1px solid #ddd;
  font-weight: 500;
  font-size: 16px;
}

.matrix-display td.connected {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.matrix-display td.disconnected {
  background: #f0f0f0;
  color: #999;
}

/* --- Options Section --- */
.options {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

/* --- Option Cards (iframe-based quizzes) --- */
.option-card {
  flex: 1;
  min-width: 300px;
  max-width: 420px;
  height: 300px;
  border: 3px solid #ddd;
  border-radius: 15px;
  overflow: hidden;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  position: relative; /* important for overlay positioning */
  background: #f9f9f9;
  display: flex;
  align-items: center;
  justify-content: center;
}
.option-card iframe {
  width: 100%;
  height: 100%;
  border: none;
}
.option-card.selected {
  border-color: #667eea; /* blue border */
  border-width: 4px;
  box-shadow: 0 0 20px rgba(102, 126, 234, 0.6); /* subtle blue glow */
  transition: all 0.3s ease;
}
.option-card:hover .select-overlay {
  opacity: 1;
  pointer-events: all;
}

.option-card.selected .select-overlay {
  opacity: 1;
  background: rgba(102, 126, 234, 1);
}
.option-card:hover .select-overlaygraph {
  opacity: 1;
  pointer-events: all;
}
.option-card.correct {
  border-color: #4caf50;
  border-width: 4px;
  animation: correctPulse 0.5s ease;
}

.option-card.incorrect {
  border-color: #f44336;
  border-width: 4px;
  animation: incorrectShake 0.5s ease;
}

.option-card.disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* --- Overlay Labels (for iframe options) --- */
.option-label {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(102, 126, 234, 0.9);
  color: white;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  pointer-events: none;
}

.select-overlay {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(102, 126, 234, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
}

.select-overlay:hover {
  background: rgba(102, 126, 234, 1);
  transform: translateX(-50%) translateY(-3px);
}
.select-overlaygraph {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(102, 126, 234, 0.9);
  color: white;
  padding: 10px 20px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
}

.select-overlaygraph:hover {
  background: rgba(102, 126, 234, 1);
  transform: translateX(-50%) translateY(-3px);
}
/* --- Choice Buttons (for button-based quizzes) --- */
.choice-btn {
  padding: 15px 40px;
  font-size: 18px;
  font-weight: 600;
  border: 3px solid #ddd;
  border-radius: 12px;
  cursor: pointer;
  background: white;
  color: #333;
  transition: all 0.3s ease;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  min-width: 120px;
}

.choice-btn:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

.choice-btn.selected {
  border-color: #667eea;
  border-width: 4px;
  background: #f0f4ff;
}

.choice-btn.correct {
  border-color: #4caf50;
  background: #e8f5e9;
  border-width: 4px;
  animation: correctPulse 0.5s ease;
}

.choice-btn.incorrect {
  border-color: #f44336;
  background: #ffebee;
  border-width: 4px;
  animation: incorrectShake 0.5s ease;
}

.choice-btn.disabled {
  pointer-events: none;
  opacity: 0.6;
}

/* --- Feedback Text --- */
.feedback {
  text-align: center;
  font-weight: bold;
  font-size: 24px;
  min-height: 40px;
  margin-bottom: 20px;
}

/* --- Buttons (Submit, Next) --- */
.button-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
}

.submit-btn, .next-btn {
  padding: 15px 40px;
  font-size: 18px;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  color: white;
  font-weight: bold;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  transition: all 0.3s ease;
}

.submit-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.submit-btn:disabled {
display:none;
  background: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

.submit-btn:not(:disabled):hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.next-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: none;
}

.next-btn:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}
/* Color legend for matrix */
.color-legend {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
}

.legend-label {
  font-weight: 600;
  color: #333;
  font-size: 14px;
}

.legend-gradient {
  display: flex;
  height: 24px;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  border: 1px solid #ddd;
}

.legend-segment {
  width: 20px;
  flex-shrink: 0;
}

.legend-labels {
  display: flex;
  justify-content: space-between;
  width: 80px;
  font-size: 13px;
  color: #666;
  font-weight: 500;
}

.legend-labels span:first-child {
  text-align: left;
}

.legend-labels span:last-child {
  text-align: right;
}
/* --- Animations --- */
@keyframes correctPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

@keyframes incorrectShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* --- Responsive Adjustments --- */
@media (max-width: 1200px) {
  .container { padding: 30px 20px; }
  #target iframe { height: 500px; }
  .option-card { height: 280px; }
}

@media (max-width: 768px) {
  body { padding: 10px; }
  .container { padding: 20px 15px; border-radius: 15px; }
  h2 { font-size: 24px; }
  h3 { font-size: 20px; margin-bottom: 20px; }
  #target iframe { height: 400px; }
  .options { gap: 15px; }
  .button-container { flex-direction: column; gap: 15px; }
  .submit-btn, .next-btn, .choice-btn { width: 100%; padding: 12px 30px; font-size: 16px; }
}

@media (max-width: 480px) {
  .container { padding: 15px 10px; }
  h2 { font-size: 20px; }
  h3 { font-size: 18px; }
  #target iframe { height: 350px; }
  .feedback { font-size: 20px; }
  #scoreDisplay { padding: 10px 18px; font-size: 16px; }
  .reset-btn { padding: 10px 16px; font-size: 13px; }
}
