/* ======================== */
/* === Global Variables === */
/* ======================== */
:root {
  /* Color System */
  --primary-color: #0366d6;
  --primary-hover: #0056b3;
  --success-color: #28a745;
  --success-bg: #d4edda;
  --success-border: #c3e6cb;
  --warning-color: #ffc107;
  --warning-bg: #fff3cd;
  --error-color: #dc3545;
  --text-color: #333;
  --text-light: #6c757d;
  --bg-color: #f8f9fa;
  --card-bg: white;
  --border-color: #e1e4e8;
  
  /* Gold Theme Colors */
  --gold-primary: #D4AF37;
  --gold-light: #FFD700;
  --gold-dark: #996515;
  --gold-bg: #FFF9E6;
  --gold-border: #E6C200;
  --royal-blue: #00539C;
  --off-white: #F8F8F8;
  --dark-text: #333333;

  /* Layout Variables */
  --max-content-width: 1200px;
  --content-padding: clamp(1rem, 5vw, 2rem);
  --card-max-width: 1000px;
  --mobile-breakpoint: 768px;
  
  /* Spacing System */
  --space-xxs: 0.25rem;   /* 4px */
  --space-xs: 0.5rem;     /* 8px */
  --space-sm: 0.75rem;    /* 12px */
  --space-md: 1rem;       /* 16px */
  --space-lg: 1.5rem;     /* 24px */
  --space-xl: 2rem;       /* 32px */
  --space-xxl: 3rem;      /* 48px */

  /* Border Radius */
  --radius-sm: 0.25rem;   /* 4px */
  --radius-md: 0.5rem;    /* 8px */
  --radius-lg: 0.75rem;   /* 12px */
  --radius-xl: 1rem;      /* 16px */
  --radius-pill: 100vmax;
  
  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.15);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1);
  --shadow-accent: 0 4px 20px rgba(212, 175, 55, 0.3);
  
  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
  --transition-slow: 0.5s ease;
  --transition-bounce: cubic-bezier(0.68, -0.6, 0.32, 1.6);
}

/* ======================== */
/* === Base Styles === */
/* ======================== */
* {
  box-sizing: border-box;
}

body {
  font-family: 'Arial', sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  min-height: 100vh;
  background-color: var(--bg-color);
  width: 100%;
  padding: var(--content-padding);
}

/* ======================== */
/* === Typography === */
/* ======================== */
h1, h2, h3, h4 {
  color: var(--dark-text);
  margin-top: 1.5em;
  margin-bottom: 0.5em;
}

h1 {
  font-size: 2rem;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.3em;
}

h2 {
  font-size: 1.5rem;
  color: var(--primary-color);
  margin-top: 0;
}

/* ======================== */
/* === Layout Containers === */
/* ======================== */

.main-content {
  background-color: var(--off-white);
  padding: var(--space-xl);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-xl);
  max-width: var(--max-content-width);
  margin: 0 auto;
  border: 1px solid var(--gold-border);
}

.content-group {
  margin-bottom: var(--space-xl);
}

.content-header {
  background: linear-gradient(135deg, var(--gold-primary), var(--gold-light));
  color: white;
  padding: var(--space-lg);
  margin: calc(-1 * var(--space-xl)) calc(-1 * var(--space-xl)) var(--space-xl) calc(-1 * var(--space-xl));
  border-bottom: 3px solid var(--gold-dark);
  position: relative;
}

.content-header::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 95%;
  height: var(--space-md);
  background: linear-gradient(to bottom, rgba(212,175,55,0.3), transparent);
}

/* Card Containers */
.card-container {
  width: 100%;
  max-width: var(--card-max-width);
  margin: 0 auto;
}

.resource-card {
  width: 100%;
  margin-bottom: var(--space-lg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  background-color: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: var(--transition-normal);
  position: relative;
}

.resource-card:hover {
  box-shadow: var(--shadow-md);
}

/* Special Card Types */
.formula-group {
  background: var(--gold-bg);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin: var(--space-xl) 0;
}

.formula-container {
  background: white;
  padding: var(--space-md);
  margin-bottom: var(--space-md);
  border-left: 4px solid var(--gold-primary);
  border-radius: var(--radius-sm);
}

.video-container {
  border-top: 4px solid var(--gold-primary);
  background-color: var(--gold-bg);
  margin-bottom: var(--space-lg);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}

.video-container::before {
  content: "Video Resource";
  position: absolute;
  top: 0;
  right: 0;
  background: var(--gold-dark);
  color: white;
  padding: var(--space-xxs) var(--space-md);
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom-left-radius: var(--radius-sm);
}

/* ======================== */
/* === Video Components === */
/* ======================== */
.video-player {
  margin: var(--space-lg) 0;
}

.embed-container {
  position: relative;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding-bottom: 56.25%; /* 16:9 aspect ratio */
  height: 0;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: #000;
}

.embed-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.video-progress-container {
  margin-top: var(--space-md);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  position: relative;
}

.video-progress {
  flex-grow: 1;
  height: 12px;
  background-color: rgba(0,0,0,0.05);
  border-radius: var(--radius-pill);
  overflow: hidden;
  box-shadow: 
    inset 0 1px 3px rgba(0,0,0,0.1),
    0 1px 0 rgba(255,255,255,0.1);
  position: relative;
}

.video-progress-bar {
  height: 100%;
  background: linear-gradient(
    90deg,
    var(--gold-primary),
    var(--gold-light),
    var(--gold-primary)
  );
  width: 0%;
  transition: width 0.5s ease-out;
  border-radius: var(--radius-pill);
  position: relative;
  overflow: hidden;
}

/* Animated stripes for progress bar */
.video-progress-bar::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    -45deg,
    rgba(255,255,255,0.2) 25%,
    transparent 25%,
    transparent 50%,
    rgba(255,255,255,0.2) 50%,
    rgba(255,255,255,0.2) 75%,
    transparent 75%,
    transparent
  );
  background-size: 20px 20px;
  animation: progressStripes 1s linear infinite;
}

/* Glow effect when complete */
.video-progress-bar.complete {
  animation: pulseGlow 1.5s infinite alternate;
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.5);
}

.video-progress-text {
  font-size: 0.8rem;
  font-weight: bold;
  color: var(--gold-dark);
  min-width: 50px;
  text-align: center;
  background: rgba(255,255,255,0.7);
  padding: var(--space-xxs) var(--space-xs);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
}

/* Percentage indicator inside progress bar */
.video-progress-percent {
  position: absolute;
  right: var(--space-xs);
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.7rem;
  font-weight: bold;
  color: white;
  text-shadow: 0 1px 1px rgba(0,0,0,0.3);
  z-index: 2;
}

/* Completion checkmark */
.video-completion {
  margin-top: var(--space-md);
  padding: var(--space-sm);
  background: rgba(255,255,255,0.8);
  border-radius: var(--radius-md);
  border: 1px solid var(--gold-border);
  display: flex;
  align-items: center;
  transition: var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.video-completion::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    135deg,
    rgba(212,175,55,0.1) 0%,
    rgba(255,255,255,0.3) 50%,
    rgba(212,175,55,0.1) 100%
  );
}

.video-completion.completed {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.video-completion input[type="checkbox"] {
  margin-right: var(--space-sm);
  cursor: default;
  width: 20px;
  height: 20px;
  opacity: 0;
  position: absolute;
}

.video-completion label {
  cursor: pointer;
  user-select: none;
  flex-grow: 1;
  position: relative;
  padding-left: 30px;
  font-weight: 500;
}

/* Custom checkbox */
.video-completion label::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: white;
  transition: var(--transition-fast);
}

.video-completion input[type="checkbox"]:checked + label::before {
  background: var(--success-color);
  border-color: var(--success-color);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='20 6 9 17 4 12'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}


/* ======================== */
/* === Interactive Elements === */
/* ======================== */
.quiz-nav-container {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  margin: var(--space-xl) 0;
  padding: var(--space-md);
  background-color: rgba(255, 248, 220, 0.5);
  border-radius: var(--radius-md);
}

.quiz-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-sm) var(--space-md);
  background: linear-gradient(135deg, var(--primary-color), var(--primary-hover));
  color: white;
  border-radius: var(--radius-md);
  margin: 0;
  font-weight: bold;
  transition: var(--transition-normal);
  text-align: center;
  border: none;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  min-width: 180px;
}

.quiz-link:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, var(--primary-hover), var(--primary-color));
}

.quiz-link:active {
  transform: translateY(0);
}

/* Disabled Button Styles */
.quiz-link.disabled {
  background: linear-gradient(135deg, #cccccc, #aaaaaa) !important;
  color: #666 !important;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  opacity: 0.7;
}

.quiz-link.disabled::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: repeating-linear-gradient(
    -45deg,
    rgba(255,255,255,0.1),
    rgba(255,255,255,0.1) 5px,
    transparent 5px,
    transparent 10px
  );
}

/* Tooltip for disabled buttons */
.quiz-link.disabled::after {
  content: "Complete all videos to unlock";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text-color);
  color: white;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  white-space: nowrap;
  margin-bottom: var(--space-xs);
  opacity: 0;
  transition: var(--transition-fast);
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.quiz-link.disabled:hover::after {
  opacity: 1;
}

/* ======================== */
/* === References Section === */
/* ======================== */
.references-container {
  background: var(--off-white);
  padding: var(--space-lg);
  border-radius: var(--radius-md);
  margin: var(--space-xxl) 0;
  border-left: 4px solid var(--royal-blue);
  position: relative;
}

.references-container::before {
  content: "References";
  position: absolute;
  top: calc(-1 * var(--space-sm));
  left: var(--space-md);
  background: var(--royal-blue);
  color: white;
  padding: var(--space-xxs) var(--space-md);
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* ======================== */
/* === Utility Classes === */
/* ======================== */
.text-muted { color: var(--text-light); }
.text-center { text-align: center; }
.hidden { display: none !important; }

/* Spacing Utilities */
.mt-1 { margin-top: var(--space-xxs); }
.mt-2 { margin-top: var(--space-xs); }
.mt-3 { margin-top: var(--space-sm); }
.mb-1 { margin-bottom: var(--space-xxs); }
.mb-2 { margin-bottom: var(--space-xs); }
.mb-3 { margin-bottom: var(--space-sm); }

/* Width Utilities */
.w-full { width: 100%; }
.w-screen { width: 100vw; }
.max-w-full { max-width: 100%; }
.max-w-screen { max-width: 100vw; }
.max-w-content { max-width: var(--max-content-width); }
.max-w-card { max-width: var(--card-max-width); }

/* ======================== */
/* === Responsive Design === */
/* ======================== */
@media (max-width: 768px) {
  :root {
    --content-padding: 1rem;
  }
  
  .main-content {
    padding: var(--space-lg);
  }
  
  .content-header {
    margin: calc(-1 * var(--space-lg)) calc(-1 * var(--space-lg)) var(--space-lg) calc(-1 * var(--space-lg));
    padding: var(--space-md);
  }
  
  .resource-card,
  .video-container {
    border-radius: 0;
    padding: var(--space-md);
  }
  
  .quiz-nav-container {
    flex-direction: column;
  }
  
  .quiz-link {
    width: 100%;
  }
}

/* ======================== */
/* === MathJax Overrides === */
/* ======================== */
.MathJax_Display, 
.mjx-chtml {
  max-width: 100%;
  overflow-x: auto;
  display: block !important;
}

@media (max-width: 768px) {
  .MathJax_Display {
    font-size: 90% !important;
  }
}

/* Animations */
@keyframes progressStripes {
  0% { background-position: 0 0; }
  100% { background-position: 20px 20px; }
}

@keyframes pulseGlow {
  0% { box-shadow: 0 0 5px rgba(212, 175, 55, 0.5); }
  100% { box-shadow: 0 0 15px rgba(212, 175, 55, 0.8); }
}
