/* ─── Playground System ─────────────────────────────────────────────────────── */

.playground-wrapper {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  margin: 1.5em 0;
  border: 1px solid hsl(220, 15%, 18%);
  background: hsl(220, 15%, 8%);
}

.playground-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: hsl(220, 15%, 12%);
  border-bottom: 1px solid hsl(220, 15%, 18%);
}

.playground-lang {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: hsl(250, 90%, 75%);
  opacity: 0.8;
}

.playground-actions {
  display: flex;
  gap: 6px;
}

.playground-btn {
  padding: 4px 12px;
  border: 1px solid hsl(220, 15%, 22%);
  border-radius: 6px;
  background: hsl(220, 15%, 14%);
  color: hsl(220, 15%, 70%);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}

.playground-btn:hover {
  background: hsl(220, 15%, 18%);
  color: hsl(220, 15%, 90%);
  border-color: hsl(250, 90%, 65%);
}

.playground-btn.playground-run {
  background: hsl(250, 60%, 25%);
  border-color: hsl(250, 60%, 40%);
  color: hsl(250, 90%, 85%);
}

.playground-btn.playground-run:hover {
  background: hsl(250, 60%, 35%);
}

.playground-btn:disabled {
  opacity: 0.5;
  cursor: wait;
}

.playground-btn-icon {
  font-size: 0.7em;
}

.playground-code {
  margin: 0 !important;
  border-radius: 0 !important;
  border: none !important;
}

.playground-code code {
  display: block;
  padding: 16px;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
}

.playground-editor {
  width: 100%;
  padding: 16px;
  background: hsl(220, 15%, 6%);
  color: hsl(120, 60%, 70%);
  font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85rem;
  line-height: 1.6;
  border: none;
  border-top: 1px solid hsl(220, 15%, 18%);
  resize: vertical;
  min-height: 120px;
  outline: none;
  tab-size: 4;
}

.playground-output {
  padding: 12px 16px;
  border-top: 1px solid hsl(220, 15%, 18%);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  font-size: 0.82rem;
  line-height: 1.5;
  max-height: 300px;
  overflow-y: auto;
}

.playground-output pre {
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  border: none !important;
  font-size: inherit;
  white-space: pre-wrap;
  word-break: break-word;
}

.playground-output.loading {
  color: hsl(220, 15%, 60%);
}

.playground-output.success {
  background: hsl(120, 20%, 8%);
  color: hsl(120, 60%, 70%);
  border-left: 3px solid hsl(120, 60%, 40%);
}

.playground-output.error {
  background: hsl(0, 20%, 8%);
  color: hsl(0, 60%, 70%);
  border-left: 3px solid hsl(0, 60%, 40%);
}

.playground-output.simulated {
  background: hsl(40, 20%, 8%);
  color: hsl(40, 60%, 70%);
  border-left: 3px solid hsl(40, 60%, 40%);
}

.playground-simulated-header {
  font-weight: 600;
  margin-bottom: 8px;
  color: hsl(40, 80%, 65%);
}

.playground-api-note {
  margin-top: 12px;
  padding: 8px 12px;
  background: hsl(220, 15%, 12%);
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.8rem;
  color: hsl(220, 15%, 60%);
}

.playground-spinner {
  display: inline-block;
  animation: playground-pulse 1s ease-in-out infinite;
}

@keyframes playground-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Solo copy button on non-runnable code */
.playground-copy-solo {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: hsl(220, 15%, 14%);
  border: 1px solid hsl(220, 15%, 22%);
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0;
  transition: opacity 0.2s;
}

pre:hover .playground-copy-solo {
  opacity: 1;
}


/* ─── Quiz System ───────────────────────────────────────────────────────────── */

.quiz-container {
  margin: 2em 0;
  border: 1px solid hsl(250, 30%, 25%);
  border-radius: 16px;
  overflow: hidden;
  background: hsl(250, 15%, 8%);
}

.quiz-header {
  padding: 20px 24px 16px;
  background: linear-gradient(135deg, hsl(250, 30%, 15%), hsl(250, 20%, 10%));
  border-bottom: 1px solid hsl(250, 30%, 20%);
}

.quiz-header h3 {
  margin: 0 0 4px;
  font-size: 1.2rem;
  color: hsl(250, 90%, 85%);
}

.quiz-subtitle {
  margin: 0;
  font-size: 0.85rem;
  color: hsl(220, 15%, 55%);
}

.quiz-prev-score {
  margin-top: 8px;
  font-size: 0.8rem;
  color: hsl(250, 60%, 65%);
}

.quiz-question {
  padding: 20px 24px;
  border-bottom: 1px solid hsl(220, 15%, 14%);
}

.quiz-question:last-of-type {
  border-bottom: none;
}

.quiz-question-text {
  font-size: 1rem;
  line-height: 1.5;
  margin-bottom: 14px;
  color: hsl(220, 15%, 85%);
}

.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quiz-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: hsl(220, 15%, 10%);
  border: 1px solid hsl(220, 15%, 18%);
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: left;
  font-size: 0.9rem;
  color: hsl(220, 15%, 75%);
  font-family: inherit;
  width: 100%;
}

.quiz-option:hover {
  background: hsl(220, 15%, 14%);
  border-color: hsl(250, 60%, 45%);
}

.quiz-option.selected {
  background: hsl(250, 30%, 15%);
  border-color: hsl(250, 70%, 55%);
  color: hsl(250, 90%, 90%);
}

.quiz-option.correct {
  background: hsl(120, 25%, 12%) !important;
  border-color: hsl(120, 60%, 40%) !important;
  color: hsl(120, 60%, 80%) !important;
}

.quiz-option.wrong {
  background: hsl(0, 25%, 12%) !important;
  border-color: hsl(0, 60%, 40%) !important;
  color: hsl(0, 60%, 75%) !important;
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: hsl(220, 15%, 16%);
  font-weight: 600;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.quiz-option.selected .quiz-option-letter {
  background: hsl(250, 60%, 40%);
  color: white;
}

.quiz-option.correct .quiz-option-letter {
  background: hsl(120, 60%, 30%);
  color: white;
}

.quiz-option.wrong .quiz-option-letter {
  background: hsl(0, 60%, 30%);
  color: white;
}

.quiz-explanation {
  margin-top: 12px;
  padding: 12px 16px;
  background: hsl(220, 15%, 10%);
  border-radius: 8px;
  border-left: 3px solid hsl(40, 60%, 50%);
  font-size: 0.85rem;
  color: hsl(40, 40%, 70%);
  line-height: 1.5;
}

.quiz-explanation p {
  margin: 0;
}

.quiz-question.answered-correct {
  border-left: 3px solid hsl(120, 60%, 35%);
}

.quiz-question.answered-wrong {
  border-left: 3px solid hsl(0, 60%, 35%);
}

.quiz-submit-area {
  padding: 20px 24px;
  background: hsl(220, 15%, 6%);
  border-top: 1px solid hsl(220, 15%, 14%);
  text-align: center;
}

.quiz-submit-btn {
  padding: 12px 32px;
  background: linear-gradient(135deg, hsl(250, 60%, 45%), hsl(250, 50%, 35%));
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
  font-family: inherit;
}

.quiz-submit-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px hsl(250, 60%, 30%, 0.4);
}

.quiz-result {
  margin-top: 16px;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.quiz-result.great {
  background: hsl(120, 25%, 12%);
  color: hsl(120, 60%, 75%);
  border: 1px solid hsl(120, 40%, 25%);
}

.quiz-result.ok {
  background: hsl(40, 25%, 12%);
  color: hsl(40, 60%, 75%);
  border: 1px solid hsl(40, 40%, 25%);
}

.quiz-result.needs-work {
  background: hsl(0, 25%, 12%);
  color: hsl(0, 60%, 75%);
  border: 1px solid hsl(0, 40%, 25%);
}

.quiz-result.warning {
  background: hsl(40, 30%, 12%);
  color: hsl(40, 60%, 70%);
  border: 1px solid hsl(40, 40%, 25%);
}

/* ─── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 640px) {
  .playground-toolbar {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
  
  .playground-actions {
    width: 100%;
    justify-content: flex-end;
  }
  
  .quiz-question {
    padding: 16px;
  }
  
  .quiz-option {
    padding: 10px 12px;
    font-size: 0.85rem;
  }
}
