/* Creative 2026 Cyber-Glass Stylesheet for CodeKhmerLearning */
@import url('https://fonts.googleapis.com/css2?family=Kantumruy+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  --font-khmer: 'Kantumruy Pro', sans-serif;
  --font-ui: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', Consolas, monospace;
}

body {
  font-family: var(--font-khmer);
  background-color: #f8fafc;
  color: #1e293b;
  overflow-x: hidden;
  transition: background-color 0.2s ease, color 0.2s ease;
}

html.dark body {
  background-color: #030712; /* Extreme dark slate */
  color: #f1f5f9;
}

h1, h2, h3, h4, .font-heading {
  font-family: var(--font-khmer), var(--font-ui);
}

code, pre, .font-mono {
  font-family: var(--font-mono) !important;
}

/* Custom Cyber Mesh Background */
.cyber-bg {
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.08) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.08) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.05) 0px, transparent 50%),
    radial-gradient(at 80% 50%, rgba(236, 72, 153, 0.05) 0px, transparent 50%);
  background-attachment: fixed;
}

html.dark .cyber-bg {
  background-image: 
    radial-gradient(at 0% 0%, rgba(6, 182, 212, 0.12) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(139, 92, 246, 0.12) 0px, transparent 50%),
    radial-gradient(at 50% 100%, rgba(16, 185, 129, 0.08) 0px, transparent 50%),
    radial-gradient(at 80% 50%, rgba(236, 72, 153, 0.08) 0px, transparent 50%);
}

/* Minimalist Clean Header Style */
#mainHeader {
  background-color: #ffffff;
  border-bottom: 1px solid #e5e7eb;
}

html.dark #mainHeader {
  background-color: #0f172a;
  border-bottom: 1px solid #1e293b;
}

/* Header Logo Color Adaptation */
html.dark #navLogoBtn img {
  filter: invert(1) hue-rotate(180deg) brightness(1.1);
}

/* Glassmorphism Classes */
.glass-panel {
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(226, 232, 240, 0.8);
}

html.dark .glass-panel {
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.glass-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(226, 232, 240, 0.8);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark .glass-card {
  background: rgba(17, 24, 39, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: none;
}

.glass-card:hover {
  background: rgba(241, 245, 249, 0.9);
  border-color: rgba(6, 182, 212, 0.45);
  box-shadow: 0 10px 25px -5px rgba(6, 182, 212, 0.15);
  transform: translateY(-2px);
}

html.dark .glass-card:hover {
  background: rgba(30, 41, 59, 0.7);
  border-color: rgba(6, 182, 212, 0.35);
  box-shadow: 0 10px 30px -10px rgba(6, 182, 212, 0.2);
}

.glass-dropdown {
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

html.dark .glass-dropdown {
  background: rgba(10, 15, 30, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
}

/* Glowing text and borders */
.glow-cyan {
  box-shadow: 0 0 20px -3px rgba(6, 182, 212, 0.4);
}

.glow-purple {
  box-shadow: 0 0 20px -3px rgba(168, 85, 247, 0.4);
}

.text-gradient {
  background: linear-gradient(135deg, #38bdf8 0%, #818cf8 50%, #c084fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: rgba(3, 7, 18, 0.8);
}

::-webkit-scrollbar-thumb {
  background: #334155;
  border-radius: 9999px;
}

::-webkit-scrollbar-thumb:hover {
  background: #06b6d4;
}

/* Markdown Reader Custom Styles */
.markdown-body {
  color: #334155;
  font-size: 1.05rem;
  line-height: 1.85;
}

html.dark .markdown-body {
  color: #cbd5e1;
}

/* Scroll Offset for sticky navigation */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4,
.markdown-body h5 {
  scroll-margin-top: 100px;
  position: relative;
  transition: all 0.3s ease;
}

.markdown-body h1 {
  font-size: 1.85rem;
  font-weight: 700;
  color: #0284c7;
  margin-top: 2rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

html.dark .markdown-body h1 {
  color: #38bdf8;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0369a1;
  margin-top: 2.25rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

html.dark .markdown-body h2 {
  color: #60a5fa;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.markdown-body h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: #0d9488;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
}

html.dark .markdown-body h3 {
  color: #93c5fd;
}

.markdown-body h4 {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0284c7;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

html.dark .markdown-body h4 {
  color: #bae6fd;
}

.markdown-body p {
  margin-bottom: 1.2rem;
  color: #334155;
}

html.dark .markdown-body p {
  color: #cbd5e1;
}

.markdown-body ul, .markdown-body ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

.markdown-body li {
  margin-bottom: 0.5rem;
  color: #334155;
}

html.dark .markdown-body li {
  color: #cbd5e1;
}

.markdown-body strong {
  color: #0f172a;
  font-weight: 600;
}

html.dark .markdown-body strong {
  color: #f8fafc;
}

.markdown-body blockquote {
  border-left: 4px solid #06b6d4;
  background: rgba(6, 182, 212, 0.08);
  padding: 1rem 1.25rem;
  border-radius: 0.5rem;
  margin: 1.5rem 0;
  color: #475569;
  font-style: italic;
}

html.dark .markdown-body blockquote {
  background: rgba(6, 182, 212, 0.06);
  color: #94a3b8;
}

/* Responsive Table Wrapper */
.markdown-body table {
  display: block;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-collapse: collapse;
  margin: 1.5rem 0;
  border-radius: 0.75rem;
  border: 1px solid rgba(226, 232, 240, 0.9);
}

html.dark .markdown-body table {
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.markdown-body th, .markdown-body td {
  padding: 0.7rem 1rem;
  border: 1px solid rgba(226, 232, 240, 0.8);
  font-size: 0.92rem;
  text-align: left;
}

html.dark .markdown-body th, html.dark .markdown-body td {
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.markdown-body th {
  background: rgba(241, 245, 249, 0.95);
  font-weight: 700;
  color: #0f172a;
}

html.dark .markdown-body th {
  background: rgba(30, 41, 59, 0.9);
  color: #f1f5f9;
}

/* Responsive Images */
.markdown-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.75rem;
  margin: 1.5rem auto;
  display: block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* Inline Code Snippet */
.markdown-body :not(pre) > code {
  background: rgba(241, 245, 249, 0.9);
  color: #be185d;
  padding: 0.2rem 0.45rem;
  border-radius: 0.375rem;
  font-size: 0.88em;
  border: 1px solid rgba(203, 213, 225, 0.8);
}

html.dark .markdown-body :not(pre) > code {
  background: rgba(30, 41, 59, 0.85);
  color: #f472b6;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Terminal Mac Window for Code Blocks */
.code-window {
  border-radius: 0.75rem;
  overflow: hidden;
  background: #090d16;
  border: 1px solid rgba(255, 255, 255, 0.08);
  margin: 1.75rem 0;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.6);
}

.code-window-header {
  background: #0f172a;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.code-window-dots {
  display: flex;
  gap: 0.4rem;
}

.code-dot {
  width: 10px;
  height: 10px;
  border-radius: 9999px;
}

.code-dot-red { background: #ef4444; }
.code-dot-yellow { background: #f59e0b; }
.code-dot-green { background: #10b981; }

.code-window pre {
  margin: 0 !important;
  padding: 1.25rem !important;
  background: transparent !important;
  overflow-x: auto;
  font-size: 0.92rem;
  line-height: 1.6;
}

/* Section Jump Highlight Pulse */
@keyframes sectionGlow {
  0% {
    background-color: rgba(6, 182, 212, 0.3);
    box-shadow: 0 0 30px rgba(6, 182, 212, 0.6);
    border-radius: 8px;
    padding: 6px 12px;
    transform: scale(1.01);
  }
  50% {
    background-color: rgba(6, 182, 212, 0.15);
    box-shadow: 0 0 15px rgba(6, 182, 212, 0.3);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
    padding: 0;
    transform: scale(1);
  }
}

.highlight-pulse {
  animation: sectionGlow 2.2s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Table of Contents Item Active State */
.toc-link {
  transition: all 0.2s ease;
  position: relative;
  display: block;
}

.toc-link:hover {
  color: #38bdf8 !important;
  transform: translateX(4px);
}

.toc-link.active-toc {
  color: #38bdf8 !important;
  font-weight: 700 !important;
  background: rgba(6, 182, 212, 0.1);
  border-left: 3px solid #06b6d4;
  padding-left: 8px !important;
  border-radius: 0 6px 6px 0;
}

/* Quiz Option Hover/Selected state */
.quiz-option {
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid rgba(226, 232, 240, 0.9);
  color: #1e293b;
}

html.dark .quiz-option {
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #e2e8f0;
}

.quiz-option:hover {
  background: rgba(241, 245, 249, 1);
  border-color: rgba(6, 182, 212, 0.5);
}

html.dark .quiz-option:hover {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(6, 182, 212, 0.4);
}

.quiz-option.selected {
  background: rgba(6, 182, 212, 0.12) !important;
  border-color: #06b6d4 !important;
  color: #0891b2 !important;
}

html.dark .quiz-option.selected {
  background: rgba(6, 182, 212, 0.18) !important;
  color: #38bdf8 !important;
}

.quiz-option.correct {
  background: rgba(16, 185, 129, 0.15) !important;
  border-color: #10b981 !important;
  color: #059669 !important;
}

html.dark .quiz-option.correct {
  background: rgba(16, 185, 129, 0.2) !important;
  border-color: #10b981 !important;
  color: #34d399 !important;
}

.quiz-option.incorrect {
  background: rgba(239, 68, 68, 0.15) !important;
  border-color: #ef4444 !important;
  color: #dc2626 !important;
}

html.dark .quiz-option.incorrect {
  background: rgba(239, 68, 68, 0.2) !important;
  border-color: #ef4444 !important;
  color: #f87171 !important;
}

/* ======================================================== */
/* RESPONSIVE OPTIMIZATIONS FOR MOBILE PHONES & IPADS       */
/* ======================================================== */

/* General Mobile Touch Feel */
html {
  -webkit-tap-highlight-color: transparent;
}

button, a, input, select, textarea, .quiz-option, .course-item, .lab-menu-item {
  touch-action: manipulation;
}

/* No-scrollbar utility */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

/* Sidebar Drawer on Mobile & Tablet */
@media (max-width: 1023px) {
  #sidebar {
    position: fixed !important;
    top: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    z-index: 50 !important;
    height: 100vh !important;
    will-change: transform;
  }

  /* When closed, hide completely so no ghost border or empty grid space occurs */
  #sidebar.-translate-x-full {
    transform: translateX(-105%) !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  /* When open, slide in smoothly and become interactive */
  #sidebar:not(.-translate-x-full) {
    transform: translateX(0) !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
}

/* Sidebar on Desktop (iPad Landscape & Large Screens) */
@media (min-width: 1024px) {
  #sidebar {
    position: sticky !important;
    top: 6rem !important;
    transform: none !important;
    visibility: visible !important;
    pointer-events: auto !important;
  }
}

/* Tablets & Mobile Phones (Up to iPad Landscape / 1023px) */
@media (max-width: 1023px) {
  /* Programming Lab: Horizontal scrollable strip for languages */
  #labMenuList {
    display: flex;
    flex-direction: row;
    overflow-x: auto;
    gap: 0.5rem;
    padding-bottom: 0.25rem;
  }

  #labMenuList .lab-menu-item {
    flex: 0 0 auto;
    padding: 0.5rem 0.85rem;
    margin-bottom: 0;
  }

  #labMenuList .lab-menu-item p {
    display: none;
  }

  /* Outline bottom sheet animation */
  #mobileTocDrawer > div {
    animation: slideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
}

@keyframes slideUp {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Mobile Phones (Up to 767px) */
@media (max-width: 767px) {
  .markdown-body {
    font-size: 0.98rem;
    line-height: 1.78;
  }

  .markdown-body h1 {
    font-size: 1.5rem;
    margin-top: 1.5rem;
    margin-bottom: 0.85rem;
  }

  .markdown-body h2 {
    font-size: 1.3rem;
    margin-top: 1.75rem;
    margin-bottom: 0.75rem;
  }

  .markdown-body h3 {
    font-size: 1.15rem;
    margin-top: 1.5rem;
  }

  .markdown-body h4 {
    font-size: 1.05rem;
  }

  .code-window {
    margin: 1.25rem 0;
    border-radius: 0.65rem;
  }

  .code-window-header {
    padding: 0.45rem 0.75rem;
  }

  .code-window pre {
    padding: 0.85rem !important;
    font-size: 0.82rem;
    line-height: 1.55;
  }

  .markdown-body th, .markdown-body td {
    padding: 0.55rem 0.75rem;
    font-size: 0.85rem;
  }

  /* Hero Banner compact on small phones */
  #courseHero .glass-panel {
    padding: 1rem !important;
  }
}

/* ======================================================== */
/* FONT RESIZING CLASSES                                    */
/* ======================================================== */
.font-size-sm .markdown-body {
  font-size: 0.92rem !important;
  line-height: 1.7 !important;
}
.font-size-md .markdown-body {
  font-size: 1.05rem !important;
  line-height: 1.85 !important;
}
.font-size-lg .markdown-body {
  font-size: 1.2rem !important;
  line-height: 1.95 !important;
}
.font-size-xl .markdown-body {
  font-size: 1.35rem !important;
  line-height: 2.1 !important;
}


/* ======================================================== */
/* PRINT & PDF EXPORT STYLING                               */
/* ======================================================== */
@media print {
  header, 
  footer, 
  aside, 
  #categoryPills, 
  #readingProgressBar, 
  #floatingTocContainer, 
  #mobileTocDrawer, 
  #searchModal, 
  #shortcutsModal, 
  .no-print, 
  .btn-copy-code, 
  .btn-try-lab, 
  .reader-toolbar, 
  #courseHero button,
  #sidebarBackdrop {
    display: none !important;
  }

  body {
    background: #ffffff !important;
    color: #1e293b !important;
    font-size: 11pt !important;
    line-height: 1.6 !important;
  }

  #coursesContainer, 
  main, 
  .markdown-body {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
  }

  .markdown-body h1, .markdown-body h2, .markdown-body h3, .markdown-body h4 {
    page-break-after: avoid;
    break-after: avoid;
    color: #0369a1 !important;
  }

  .code-window {
    background: #f8fafc !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    break-inside: avoid;
    margin: 1rem 0 !important;
  }

  .code-window-header {
    background: #f1f5f9 !important;
    border-bottom: 1px solid #cbd5e1 !important;
  }

  .code-window pre {
    color: #0f172a !important;
    white-space: pre-wrap !important;
    word-break: break-all !important;
    font-size: 9pt !important;
  }

  .markdown-body table {
    page-break-inside: avoid;
    break-inside: avoid;
    border: 1px solid #cbd5e1 !important;
  }

  .markdown-body th, .markdown-body td {
    border: 1px solid #cbd5e1 !important;
    color: #0f172a !important;
  }
}
