/* ============================================================================
   Enhanced Session Showcase Styles
   Adds: Sticky sidebar, back button, mobile sidebar, code improvements,
   quiz enhancements, confetti, and better spacing
   ============================================================================ */

/* ============================================================================
   Back to Hub Button - DISABLED (Button now added directly in HTML)
   ============================================================================ */

/* DISABLED: These styles were for JavaScript-generated back button
.back-to-hub {
  margin-bottom: 2rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--bg-light);
}

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--bg-medium);
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 8px;
  font-weight: 500;
  transition: all 0.3s ease;
  border: 1px solid var(--bg-light);
}

.btn-back:hover {
  background: var(--bg-light);
  transform: translateX(-4px);
  box-shadow: var(--shadow);
}

.btn-back i {
  width: 20px;
  height: 20px;
}
*/

/* ============================================================================
   Fixed Sidebar (Desktop) - Changed from sticky to fixed to prevent layout issues
   ============================================================================ */

@media (min-width: 768px) {
  .sidebar {
    position: fixed !important;
    top: 0;
    height: 100vh;
    overflow-y: auto;
  }
}

/* ============================================================================
   Mobile Sidebar Toggle
   ============================================================================ */

.mobile-menu-toggle {
  display: none;
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 1000;
  background: var(--bg-medium);
  border: 1px solid var(--bg-light);
  border-radius: 8px;
  padding: 0.75rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow);
}

.mobile-menu-toggle:hover {
  background: var(--bg-light);
  transform: scale(1.05);
}

.mobile-menu-toggle i {
  width: 24px;
  height: 24px;
}

@media (max-width: 767px) {
  .mobile-menu-toggle {
    display: block;
  }

  .sidebar {
    transform: translateX(-100%);
    position: fixed;
    z-index: 999;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    margin-left: 0 !important; /* No sidebar margin on mobile */
    padding: 0 1rem 2rem !important; /* Changed from 5rem to 0 for top padding */
  }

  /* DISABLED: .back-to-hub styles no longer needed
  .back-to-hub {
    margin-top: 1rem;
  }
  */
}

/* ============================================================================
   Code Block Enhancements: Line Numbers, Copy Button, Diff View
   ============================================================================ */

/* Line numbers styling (Prism compatible) */
pre[class*="language-"].line-numbers {
  position: relative;
  padding-left: 3.8em;
  counter-reset: linenumber;
}

pre[class*="language-"].line-numbers > code {
  position: relative;
  white-space: inherit;
}

.line-numbers .line-numbers-rows {
  position: absolute;
  pointer-events: none;
  top: 0;
  font-size: 100%;
  left: -3.8em;
  width: 3em;
  letter-spacing: -1px;
  border-right: 1px solid var(--code-border);
  user-select: none;
}

.line-numbers-rows > span {
  display: block;
  counter-increment: linenumber;
}

.line-numbers-rows > span:before {
  content: counter(linenumber);
  color: var(--text-muted);
  display: block;
  padding-right: 0.8em;
  text-align: right;
}

/* Code header improvements */
.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--code-border);
  border-radius: 8px 8px 0 0;
}

.code-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.code-label i {
  width: 18px;
  height: 18px;
  color: var(--info);
}

.language-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background: var(--bg-light);
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

/* Copy button improvements */
.copy-button {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--bg-medium);
  color: var(--text-secondary);
  border: 1px solid var(--bg-light);
  border-radius: 6px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.copy-button:hover {
  background: var(--bg-light);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.copy-button.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.copy-button i {
  width: 16px;
  height: 16px;
}

/* Side-by-side code diff view (Desktop) */
.code-diff {
  display: block;
  gap: 1rem;
  margin-top: 0;
}

@media (min-width: 1024px) {
  .code-diff {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .diff-panel {
    min-width: 0; /* Prevent overflow */
  }
}

.diff-panel {
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--code-border);
  margin-bottom: 1rem;
}

.diff-panel.hidden {
  display: none;
}

@media (min-width: 1024px) {
  .diff-panel.hidden {
    display: block;
  }
}

.diff-starter {
  border-left: 3px solid var(--warning);
}

.diff-solution {
  border-left: 3px solid var(--success);
}

.code-container {
  background: var(--code-bg);
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--code-border);
  margin: 1rem 0;
}

.code-container pre {
  margin: 0;
  border-radius: 0 0 8px 8px;
}

/* ============================================================================
   Quiz Enhancements: Progress, Better Spacing, Review
   ============================================================================ */

/* Better question spacing */
.quiz-question {
  background: var(--bg-medium);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 2rem;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

.quiz-question:hover {
  border-color: var(--bg-light);
}

.question-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--bg-light);
}

.question-number {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.question-number::before {
  content: "📝";
  font-size: 1.25rem;
}

.question-points {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--info);
  background: rgba(59, 130, 246, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 12px;
}

.question-text {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

/* Quiz options spacing */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.quiz-option {
  padding: 1rem 1.25rem;
  background: var(--bg-dark);
  border: 2px solid var(--bg-light);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.quiz-option:hover {
  border-color: var(--info);
  background: rgba(59, 130, 246, 0.05);
  transform: translateX(4px);
}

.quiz-option.selected {
  border-color: var(--info);
  background: rgba(59, 130, 246, 0.1);
}

.quiz-option.correct {
  border-color: var(--success);
  background: rgba(16, 185, 129, 0.1);
}

.quiz-option.incorrect {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.1);
}

.quiz-option input[type="radio"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.quiz-option span {
  flex: 1;
  font-size: 1rem;
  color: var(--text-primary);
}

/* Quiz feedback */
.quiz-feedback {
  display: none;
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-top: 1.5rem;
  font-size: 0.9375rem;
  line-height: 1.6;
}

.quiz-feedback.show {
  display: block;
  animation: slideDown 0.3s ease;
}

.quiz-feedback.correct {
  background: rgba(16, 185, 129, 0.1);
  border-left: 4px solid var(--success);
  color: var(--success);
}

.quiz-feedback.incorrect {
  background: rgba(239, 68, 68, 0.1);
  border-left: 4px solid var(--error);
  color: var(--error);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Quiz score display */
.quiz-score {
  background: var(--bg-medium);
  border-radius: 12px;
  padding: 2rem;
  text-align: center;
  margin: 2rem 0;
  border: 2px solid var(--info);
}

.quiz-score h3 {
  font-size: 1.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-primary);
}

.score-display {
  font-size: 4rem;
  font-weight: 700;
  margin-bottom: 1rem;
  background: linear-gradient(135deg, var(--info), var(--success));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-display[data-score="100"] {
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.score-message {
  font-size: 1.25rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
}

/* Quiz actions */
.quiz-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  margin: 2rem 0;
}

.btn-review-incorrect {
  background: var(--warning);
  color: white;
  border: none;
}

.btn-review-incorrect:hover {
  background: #d97706;
}

/* ============================================================================
   Confetti Animation
   ============================================================================ */

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

.confetti {
  position: absolute;
  font-size: 2rem;
  animation: confettiFall 3s ease-out forwards;
}

.confetti:nth-child(1) { left: 10%; animation-delay: 0s; }
.confetti:nth-child(2) { left: 20%; animation-delay: 0.2s; }
.confetti:nth-child(3) { left: 30%; animation-delay: 0.4s; }
.confetti:nth-child(4) { left: 40%; animation-delay: 0.1s; }
.confetti:nth-child(5) { left: 50%; animation-delay: 0.3s; }
.confetti:nth-child(6) { left: 60%; animation-delay: 0.5s; }
.confetti:nth-child(7) { left: 70%; animation-delay: 0.2s; }
.confetti:nth-child(8) { left: 80%; animation-delay: 0.4s; }

@keyframes confettiFall {
  0% {
    top: -10%;
    opacity: 1;
    transform: translateX(0) rotate(0deg);
  }
  100% {
    top: 110%;
    opacity: 0;
    transform: translateX(calc(-50px + 100px * var(--random))) rotate(720deg);
  }
}

.confetti:nth-child(odd) {
  --random: 0.3;
}

.confetti:nth-child(even) {
  --random: 0.7;
}

/* ============================================================================
   Utility Classes
   ============================================================================ */

.hidden {
  display: none !important;
}

/* Button styles */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 500;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  border: none;
  text-decoration: none;
}

.btn-primary {
  background: var(--info);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: var(--bg-light);
  color: var(--text-primary);
  border: 1px solid var(--bg-light);
}

.btn-secondary:hover {
  background: var(--bg-medium);
}

.btn-warning {
  background: var(--warning);
  color: white;
}

.btn-warning:hover {
  background: #d97706;
}

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

.btn i {
  width: 18px;
  height: 18px;
}

/* ============================================================================
   Responsive Improvements
   ============================================================================ */

@media (max-width: 767px) {
  .quiz-question {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
  }

  .question-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .question-text {
    font-size: 1rem;
  }

  .quiz-option {
    padding: 0.875rem 1rem;
  }

  .score-display {
    font-size: 3rem;
  }

  .quiz-actions {
    flex-direction: column;
  }

  .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================================================
   Accessibility Improvements
   ============================================================================ */

/* Focus states */
.btn:focus,
.quiz-option:focus,
.copy-button:focus,
.mobile-menu-toggle:focus {
  outline: 2px solid var(--info);
  outline-offset: 2px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .confetti {
    display: none;
  }
}

/* High contrast mode */
@media (prefers-contrast: high) {
  .quiz-option {
    border-width: 3px;
  }

  .code-header {
    border-bottom-width: 2px;
  }
}
