/* ========================================
   StudyHub - Design System
   ======================================== */

:root {
  --primary: #6C5CE7;
  --primary-light: #a29bfe33;
  --primary-dark: #5a4bd1;
  --secondary: #00CEC9;
  --secondary-light: #00cec933;
  --accent: #FDCB6E;
  --accent-light: #fdcb6e33;
  --success: #00B894;
  --success-light: #00b89433;
  --danger: #D63031;
  --danger-light: #d6303133;

  --bg: #F8F9FE;
  --bg-card: #FFFFFF;
  --text: #2D3436;
  --text-light: #636E72;
  --text-lighter: #B2BEC3;
  --border: #DFE6E9;

  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow: 0 2px 16px rgba(108, 92, 231, 0.08);
  --shadow-lg: 0 8px 32px rgba(108, 92, 231, 0.12);
  --shadow-hover: 0 16px 48px rgba(108, 92, 231, 0.16);
  --shadow-inset: inset 0 2px 4px rgba(0,0,0,0.06);

  --font: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --bounce: 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--primary-dark);
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

img { max-width: 100%; }

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

.text-gradient {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.page-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

.page-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

.page-subtitle {
  color: var(--text-light);
  margin-bottom: 2rem;
  font-size: 1.1rem;
}

.section-title {
  font-size: 1.5rem;
  margin: 2rem 0 1rem;
  color: var(--text);
}

.empty-state {
  text-align: center;
  padding: 3rem;
  color: var(--text-light);
  font-size: 1.1rem;
}

.breadcrumb {
  margin-bottom: 1.5rem;
  color: var(--text-light);
  font-size: 0.9rem;
}

.breadcrumb a {
  color: var(--text-light);
}

.breadcrumb a:hover {
  color: var(--primary);
}

/* ========================================
   Flash Messages
   ======================================== */

.flash {
  max-width: 1100px;
  margin: 1rem auto;
  padding: 1rem 1.5rem;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: space-between;
  animation: slideDown 0.3s ease;
}

.flash-success { background: var(--success-light); color: #00856a; border-left: 4px solid var(--success); }
.flash-error { background: var(--danger-light); color: #c0392b; border-left: 4px solid var(--danger); }
.flash-warning { background: var(--accent-light); color: #d4a017; border-left: 4px solid var(--accent); }

.flash-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
}

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

/* ========================================
   Error Page
   ======================================== */

.error-page {
  text-align: center;
  padding: 5rem 2rem;
}

.error-page h1 {
  font-size: 6rem;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.error-page p {
  font-size: 1.3rem;
  color: var(--text-light);
  margin: 1rem 0 2rem;
}

/* ========================================
   Math & Formula Rendering (Modern)
   ======================================== */

.lesson-body .formula,
.formula {
  background: linear-gradient(135deg, #f0edff 0%, #e8f4fd 100%);
  border-left: 4px solid var(--primary);
  padding: 1.2rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.2rem 0;
  font-size: 1.05rem;
  box-shadow: var(--shadow-inset);
}

.lesson-body .example,
.example {
  background: linear-gradient(135deg, #f0faf6 0%, #eef9f6 100%);
  border-left: 4px solid var(--success);
  padding: 1.2rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.2rem 0;
  box-shadow: var(--shadow-inset);
}

.lesson-body .tip-box,
.tip-box {
  background: linear-gradient(135deg, #fff8e6 0%, #fffdf0 100%);
  border-left: 4px solid var(--accent);
  padding: 1.2rem 1.5rem;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.2rem 0;
  box-shadow: var(--shadow-inset);
}

.lesson-body table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0;
  box-shadow: var(--shadow);
}

.lesson-body thead {
  background: linear-gradient(135deg, var(--primary), #8B7CF7);
  color: white;
}

.lesson-body th {
  padding: 0.8rem 1rem;
  font-weight: 700;
  text-align: left;
  font-size: 0.9rem;
}

.lesson-body td {
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 0.95rem;
}

.lesson-body tbody tr:last-child td {
  border-bottom: none;
}

.lesson-body tbody tr:nth-child(even) {
  background: var(--bg);
}

.lesson-body tbody tr:hover {
  background: var(--primary-light);
}

/* Math expressions in text */
.lesson-body code {
  background: linear-gradient(135deg, #f0edff, #ede8ff);
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
  font-family: 'Courier New', monospace;
  font-size: 0.95em;
  font-weight: 600;
  color: var(--primary-dark);
  border: 1px solid #d5cfff;
}

/* ========================================
   Modern Micro-animations
   ======================================== */

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.page-container {
  animation: fadeInUp 0.4s ease;
}

/* Smooth loading for cards */
.subject-card, .chapter-card, .feature-card, .tip-card, .level-card {
  animation: fadeInUp 0.4s ease backwards;
}

.subject-card:nth-child(2), .feature-card:nth-child(2) { animation-delay: 0.1s; }
.subject-card:nth-child(3), .feature-card:nth-child(3) { animation-delay: 0.2s; }
.subject-card:nth-child(4), .feature-card:nth-child(4) { animation-delay: 0.3s; }

/* Hover glow effect */
.subject-card:hover, .subject-preview-card:hover, .subject-card-large:hover {
  box-shadow: 0 20px 60px rgba(108, 92, 231, 0.2);
}

.level-card:hover {
  background: linear-gradient(135deg, var(--primary-light), transparent);
}

/* Success animation */
@keyframes successPop {
  0% { transform: scale(0.5); opacity: 0; }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.completed-badge {
  animation: successPop var(--bounce);
}

/* Streak fire animation */
.streak-fire, .streak-fire-big {
  animation: pulse 2s ease infinite;
}

/* Score animation */
.score-number, .big-score {
  animation: scaleIn 0.6s var(--bounce);
}
