/* Shared styles for all course pages */

/* ─── Design tokens ──────────────────────────────────────────── */
:root {
  /* Raw palette — used by flash messages only */
  --color-blue-50:   #eff6ff;
  --color-blue-600:  #1d4ed8;
  --color-blue-200:  #bfdbfe;
  --color-green-50:  #f0fdf4;
  --color-green-700: #15803d;
  --color-green-200: #bbf7d0;
  --color-red-50:    #fef2f2;
  --color-red-700:   #b91c1c;
  --color-red-200:   #fecaca;

  /* Semantic tokens — light mode */
  --color-accent:           #A78BFA; /* decorative only — ++ logo, highlights */
  --color-link:             #6D28D9; /* all hyperlinks */
  --color-heading:          #334155; /* h1–h4 */
  --color-body:             #475569; /* paragraphs, body copy */
  --color-muted:            #94A3B8; /* decorative muted — timestamps, UI chrome */
  --color-muted-functional: #64748B; /* functional muted — hints, status, labels */
  --color-bg:               #F8F9FB; /* page background */
  --color-surface:          #FFFFFF; /* cards, modals, panels */
  --color-border:           #E2E8F0; /* dividers, card borders */

  /* Flash message colors */
  --flash-notice-bg:     var(--color-blue-50);
  --flash-notice-text:   var(--color-blue-600);
  --flash-notice-border: var(--color-blue-200);
  --flash-success-bg:     var(--color-green-50);
  --flash-success-text:   var(--color-green-700);
  --flash-success-border: var(--color-green-200);
  --flash-error-bg:     var(--color-red-50);
  --flash-error-text:   var(--color-red-700);
  --flash-error-border: var(--color-red-200);
  --flash-default-bg:     var(--color-bg);
  --flash-default-text:   var(--color-body);
  --flash-default-border: var(--color-border);

  /* Auth modal */
  --auth-modal-bg:    var(--color-surface);
  --auth-input-border: var(--color-border);
  --auth-input-bg:    var(--color-surface);
  --auth-btn-bg:      #1a1a1a;
  --auth-btn-text:    #ffffff;
  --auth-btn-hover:   #374151;
}

html.dark {
  /* Raw palette — flash messages dark mode */
  --color-blue-50:   #1e3a5f;
  --color-blue-600:  #93c5fd;
  --color-blue-200:  #1e40af;
  --color-green-50:  #14532d;
  --color-green-700: #86efac;
  --color-green-200: #166534;
  --color-red-50:    #450a0a;
  --color-red-700:   #fca5a5;
  --color-red-200:   #7f1d1d;

  /* Semantic tokens — dark mode */
  --color-accent:           #A78BFA;
  --color-link:             #A78BFA;
  --color-heading:          #F1F5F9;
  --color-body:             #CBD5E1;
  --color-muted:            #94A3B8;
  --color-muted-functional: #94A3B8;
  --color-bg:               #1E1E2E;
  --color-surface:          #252537;
  --color-border:           #334155;

  /* Auth modal dark */
  --auth-btn-bg:    #e5e5e5;
  --auth-btn-text:  #1a1a1a;
  --auth-btn-hover: #d1d5db;
}

/* ─── Base ───────────────────────────────────────────────────── */
html {
  background-color: var(--color-bg);
  transition: background-color 0.3s ease;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--color-body);
  background-color: var(--color-bg);
  transition: color 0.3s ease, background-color 0.3s ease;
}

section {
  margin: 25px 0;
}

/* ─── Typography ─────────────────────────────────────────────── */
h1 {
  font-size: 2.25rem;
  line-height: 2.5rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--color-heading);
}

h2 {
  font-size: 1.5rem;
  line-height: 2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--color-heading);
}

h3 {
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--color-heading);
}

h4 {
  font-weight: 600;
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: var(--color-heading);
}

p {
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

ul {
  list-style-type: none;
  padding-left: 0;
  margin-top: 0.5rem;
  margin-bottom: 0.75rem;
}

li {
  padding-left: 1.5rem;
  margin-bottom: 0.25rem;
}

/* ─── Links ──────────────────────────────────────────────────── */
a:not(h1 a):not(h2 a):not(h3 a):not(h4 a):not(h5 a):not(h6 a):not(.text-white):not(.btn) {
  color: var(--color-link);
}

h1 a, h2 a, h3 a, h4 a, h5 a, h6 a {
  color: inherit;
}

a:not(.btn):hover {
  color: var(--color-link);
  text-decoration: underline;
}

/* ─── Theme toggle ───────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.theme-toggle:hover {
  background-color: rgba(0, 0, 0, 0.1);
}

html.dark .theme-toggle:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle svg {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}

.theme-toggle:hover svg {
  transform: scale(1.1);
}

.sun-icon  { display: block; color: #f59e0b; }
.moon-icon { display: none;  color: #6366f1; }
html.dark .sun-icon  { display: none; }
html.dark .moon-icon { display: block; color: #818cf8; }

/* ─── Logo light/dark toggle ─────────────────────────────────── */
.logo-light-mode { display: block; }
.logo-dark-mode  { display: none; }
html.dark .logo-light-mode { display: none; }
html.dark .logo-dark-mode  { display: block; }

/* ─── Utility ────────────────────────────────────────────────── */
.text-subtle {
  color: var(--color-muted-functional);
}

/* ─── Flash messages ─────────────────────────────────────────── */
.flash-notice  { background-color: var(--flash-notice-bg);  color: var(--flash-notice-text);  border: 1px solid var(--flash-notice-border); }
.flash-success { background-color: var(--flash-success-bg); color: var(--flash-success-text); border: 1px solid var(--flash-success-border); }
.flash-error   { background-color: var(--flash-error-bg);   color: var(--flash-error-text);   border: 1px solid var(--flash-error-border); }
.flash-default { background-color: var(--flash-default-bg); color: var(--flash-default-text); border: 1px solid var(--flash-default-border); }

/* ─── Auth modal ─────────────────────────────────────────────── */
.auth-modal-container {
  background-color: var(--auth-modal-bg);
  color: var(--color-body);
}

.auth-input {
  background-color: var(--auth-input-bg);
  border: 1px solid var(--auth-input-border);
  color: var(--color-body);
  width: 100%;
  border-radius: 0.25rem;
  padding: 0.5rem 0.75rem;
}

.auth-input:focus {
  outline: none;
  border-color: var(--color-link);
}

.auth-btn {
  background-color: var(--auth-btn-bg);
  color: var(--auth-btn-text);
  width: 100%;
  padding: 0.5rem 1rem;
  border-radius: 0.25rem;
  border: none;
  cursor: pointer;
  font-weight: 500;
}

.auth-btn:hover    { background-color: var(--auth-btn-hover); }
.auth-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.auth-link       { color: var(--color-muted-functional); }
.auth-link:hover { color: var(--color-body); }

.auth-close-btn       { color: var(--color-muted-functional); }
.auth-close-btn:hover { color: var(--color-body); }

/* ─── Pro badge ──────────────────────────────────────────────── */
.pro-badge {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.15rem 0.4rem;
  border-radius: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.025em;
  vertical-align: middle;
  margin-left: 0.35rem;
}

html.dark .pro-badge {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
}

/* ─── Pro locked content ─────────────────────────────────────── */
.pro-locked-content {
  background-color: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 0.5rem;
  padding: 2rem;
  text-align: center;
  margin: 2rem 0;
}

html.dark .pro-locked-content {
  background-color: #292524;
  border-color: #d97706;
}

.pro-locked-message h2 { color: #92400e; margin-top: 0; margin-bottom: 1rem; }
html.dark .pro-locked-message h2 { color: #fbbf24; }

.pro-locked-message p { color: #78350f; margin-bottom: 1.5rem; }
html.dark .pro-locked-message p { color: #fde68a; }

.pro-upgrade-button {
  display: inline-block;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: white;
  font-weight: 600;
  padding: 0.75rem 1.5rem;
  border-radius: 0.375rem;
  text-decoration: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.pro-upgrade-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
  color: white;
}

/* ─── Lesson cards grid ──────────────────────────────────────── */
.lesson-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

@media (min-width: 768px) {
  .lesson-cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* ─── Lesson thumbnail animation ─────────────────────────────── */
.lesson-thumbnail-wrapper {
  display: inline-block;
  position: relative;
  width: 80px;
  height: 45px;
  vertical-align: middle;
  margin-right: 8px;
}

.lesson-thumbnail-wrapper .lesson-thumbnail,
.lesson-thumbnail-wrapper .lesson-thumbnail-animation {
  position: absolute;
  top: 0; left: 0;
  width: 80px; height: 45px;
  object-fit: cover;
  border-radius: 4px;
  transition: opacity 0.2s ease;
}

.lesson-thumbnail-wrapper .lesson-thumbnail           { opacity: 1; }
.lesson-thumbnail-wrapper .lesson-thumbnail-animation { opacity: 0; }

.lesson-thumbnail-wrapper:hover .lesson-thumbnail,
.lesson-thumbnail-wrapper.active .lesson-thumbnail    { opacity: 0; }

.lesson-thumbnail-wrapper:hover .lesson-thumbnail-animation,
.lesson-thumbnail-wrapper.active .lesson-thumbnail-animation { opacity: 1; }

/* ─── Lesson cards ───────────────────────────────────────────── */
.lesson-card-thumbnail  { opacity: 1; }
.lesson-card-animation  { opacity: 0; }

.lesson-card:hover .lesson-card-thumbnail { opacity: 0; }
.lesson-card:hover .lesson-card-animation { opacity: 1; }
.lesson-card-play-icon  { display: none; }

.lesson-card:hover {
  outline: 3px solid var(--color-accent);
}

/* ─── Breadcrumbs ────────────────────────────────────────────── */
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.875rem;
  color: var(--color-muted);
  margin-bottom: 1.5rem;
}

.breadcrumbs a {
  color: var(--color-muted);
  text-decoration: none;
}

.breadcrumbs a:hover {
  color: var(--color-body);
  text-decoration: none;
}

.breadcrumb-separator { opacity: 0.4; }

.breadcrumb-current { color: var(--color-heading); }

/* ─── Shared list item styles (modules + lessons) ────────────── */
.list-item-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-heading);
  text-decoration: none;
  line-height: 1.4;
}

.list-item-blurb {
  font-size: 1rem;
  color: var(--color-muted-functional);
  margin-bottom: 0.5rem;
}

.list-item-meta {
  display: flex;
  gap: 0.75rem;
  font-size: 0.875rem;
  color: var(--color-muted);
}

.list-item-index {
  font-size: 0.875rem;
  color: var(--color-muted);
}

.lesson-list-item:hover .list-item-title {
  color: var(--color-link);
}

/* ─── Lesson list ────────────────────────────────────────────── */
.lesson-list {
  border: 1px solid var(--color-border);
  border-radius: 0.5rem;
  overflow: hidden;
}

.lesson-list-item {
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.lesson-list-item:first-child {
  border-top: none;
}

.lesson-list-item:hover {
  background: var(--color-bg);
}

/* ─── Curriculum tree ────────────────────────────────────────── */
.curriculum-module {
  padding: 1.25rem 0;
  border-top: 1px solid var(--color-border);
}

.curriculum-module:last-child {
  border-bottom: 1px solid var(--color-border);
}

.curriculum-chapter {
  margin: 0.75rem 0 0.25rem 1rem;
  padding-left: 0.75rem;
  border-left: 2px solid var(--color-border);
}

.curriculum-lesson {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.2rem 0 0.2rem 1rem;
}

/* ─── Module show stats ──────────────────────────────────────── */
.module-stats {
  display: flex;
  gap: 1rem;
  font-size: 0.875rem;
  color: var(--color-muted-functional);
  margin-bottom: 1.5rem;
}

/* ─── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-weight: 600;
  font-size: 15px;
  padding: 11px 22px;
  border-radius: 8px;
  letter-spacing: 0.01em;
  transition: background 150ms ease;
  text-decoration: none;
  cursor: pointer;
  border: none;
}

/* Primary — same in light and dark */
.btn-primary             { background: #6D28D9; color: #FFFFFF; }
.btn-primary:hover       { background: #5B21B6; color: #FFFFFF; text-decoration: none; }

/* Secondary */
.btn-secondary           { background: #EDE9FE; color: #6D28D9; }
.btn-secondary:hover     { background: #DDD6FE; color: #6D28D9; text-decoration: none; }

html.dark .btn-secondary       { background: #2D2B55; color: #C4B5FD; }
html.dark .btn-secondary:hover { background: #3B3870; color: #C4B5FD; }

/* Ghost */
.btn-ghost           { background: transparent; color: var(--color-heading); border: 1.5px solid var(--color-border); }
.btn-ghost:hover     { background: #F1F5F9; color: var(--color-heading); text-decoration: none; }

html.dark .btn-ghost       { background: transparent; color: var(--color-body); border: 1.5px solid var(--color-border); }
html.dark .btn-ghost:hover { background: #1E2A3A; color: var(--color-body); }

/* ─── Inline code ────────────────────────────────────────────── */
:not(pre) > code {
  background-color: #272822;
  color: #f8f8f2;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
  font-family: 'SF Mono', Monaco, 'Cascadia Code', 'Roboto Mono', Consolas, 'Courier New', monospace;
  font-size: 0.875em;
}
