/* Multi-Font Typography System (Thai + English + Coding Monospace) */
@import url('https://fonts.googleapis.com/css2?family=Prompt:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400;1,600&family=IBM+Plex+Sans+Thai:wght@300;400;500;600;700&family=Anuphan:wght@300;400;500;600;700&family=Kanit:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=Inter:wght@300;400;500;600;700;800&family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;1,400&family=JetBrains+Mono:wght@400;500;600;700&family=Fira+Code:wght@400;500;600;700&display=swap');

:root {
  --primary-brand: #4f46e5;
  --primary-brand-dark: #3730a3;
  --slate-dark: #0f172a;
  --soft-snow: #f8fafc;
  --accent-emerald: #059669;
  --accent-cyan: #0284c7;
  --accent-rose: #e11d48;
  --accent-amber: #d97706;
  --accent-purple: #7c3aed;

  /* Typography Presets */
  --font-code: 'JetBrains Mono', 'Fira Code', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  
  /* Default: Modern Tech & Innovation (Prompt + Inter) */
  --active-font-family: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --active-heading-family: 'Prompt', 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Theme 1: Modern Tech (Prompt + Inter) */
body.font-theme-prompt, html[data-font="prompt"] body {
  --active-font-family: 'Prompt', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --active-heading-family: 'Prompt', 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Theme 2: IBM Engineering Tech (IBM Plex Sans Thai + IBM Plex Sans) */
body.font-theme-ibm, html[data-font="ibm"] body {
  --active-font-family: 'IBM Plex Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --active-heading-family: 'IBM Plex Sans Thai', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Theme 3: Clean Science & Soft (Anuphan + Plus Jakarta Sans) */
body.font-theme-anuphan, html[data-font="anuphan"] body {
  --active-font-family: 'Anuphan', 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --active-heading-family: 'Anuphan', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Theme 4: Energetic Youth & EdTech (Kanit + Inter) */
body.font-theme-kanit, html[data-font="kanit"] body {
  --active-font-family: 'Kanit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --active-heading-family: 'Kanit', 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Theme 5: Classic Academic (Sarabun + Inter) */
body.font-theme-sarabun, html[data-font="sarabun"] body {
  --active-font-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --active-heading-family: 'Sarabun', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Advanced Thai Typography & Word Breaking Protection */
html, body {
  overflow-x: hidden;
  width: 100%;
  word-break: normal;
  overflow-wrap: break-word;
}

body, p, span, a, li, label, input, select, button {
  font-family: var(--active-font-family);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  word-break: normal;
  overflow-wrap: break-word;
}

h1, h2, h3, h4, h5, h6, .font-heading {
  font-family: var(--active-heading-family);
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.015em;
  text-wrap: balance;
}

body {
  background-color: var(--soft-snow);
  color: #1e293b;
  font-size: 15.5px;
  line-height: 1.75;
  letter-spacing: 0.005em;
}

p, li {
  text-wrap: pretty;
}

.nowrap, .name-tag, .badge-pill, .btn-pill {
  white-space: nowrap;
  display: inline-block;
}

code, pre, .font-mono, textarea {
  font-family: var(--font-code) !important;
  font-feature-settings: "liga" on, "calt" on;
}

pre {
  overflow-x: auto;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

/* Glassmorphism & Modern Light Card Elevation */
.glass-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -1px rgba(15, 23, 42, 0.02);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card-hover {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.glass-card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 25px -5px rgba(79, 70, 229, 0.12), 0 8px 10px -6px rgba(79, 70, 229, 0.08);
  border-color: #c7d2fe;
}

/* Tab Content Smooth Fade-In Transition */
.tab-content-active {
  animation: fadeInContent 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* Terminal Window Header Decoration (MacOS Style) */
.terminal-header {
  background: #1e293b;
  border-top-left-radius: 1rem;
  border-top-right-radius: 1rem;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #334155;
}

.terminal-dots {
  display: flex;
  align-items: center;
  gap: 6px;
}

.terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

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

/* Custom Pulse and Success Glow */
@keyframes successPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(16, 185, 129, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.animate-success-pulse {
  animation: successPulse 0.7s cubic-bezier(0.4, 0, 0.2, 1) 1;
}

/* ======================================================== */
/* Bento Grid & Shimmer Glow Visual Architecture            */
/* ======================================================== */
.card-shimmer {
  position: relative;
  overflow: hidden;
}

.card-shimmer::before {
  content: "";
  position: absolute;
  top: -60%;
  left: -60%;
  width: 220%;
  height: 220%;
  background: linear-gradient(
    65deg,
    transparent 35%,
    rgba(255, 255, 255, 0.12) 48%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0.12) 52%,
    transparent 65%
  );
  transform: translateX(-100%) rotate(25deg);
  transition: transform 0.9s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  z-index: 10;
}

.card-shimmer:hover::before {
  transform: translateX(100%) rotate(25deg);
}

/* Scientific Theme Ambient Glows */
.glow-indigo:hover {
  border-color: rgba(129, 140, 248, 0.6) !important;
  box-shadow: 0 16px 32px -8px rgba(99, 102, 241, 0.25), 0 0 0 1px rgba(129, 140, 248, 0.3) !important;
}

.glow-cyan:hover {
  border-color: rgba(103, 232, 249, 0.6) !important;
  box-shadow: 0 16px 32px -8px rgba(6, 182, 212, 0.25), 0 0 0 1px rgba(103, 232, 249, 0.3) !important;
}

.glow-emerald:hover {
  border-color: rgba(110, 231, 183, 0.6) !important;
  box-shadow: 0 16px 32px -8px rgba(16, 185, 129, 0.25), 0 0 0 1px rgba(110, 231, 183, 0.3) !important;
}

.glow-purple:hover {
  border-color: rgba(216, 180, 254, 0.6) !important;
  box-shadow: 0 16px 32px -8px rgba(168, 85, 247, 0.25), 0 0 0 1px rgba(216, 180, 254, 0.3) !important;
}

.glow-amber:hover {
  border-color: rgba(252, 211, 77, 0.6) !important;
  box-shadow: 0 16px 32px -8px rgba(245, 158, 11, 0.25), 0 0 0 1px rgba(252, 211, 77, 0.3) !important;
}

.glow-rose:hover {
  border-color: rgba(253, 164, 175, 0.6) !important;
  box-shadow: 0 16px 32px -8px rgba(244, 63, 94, 0.25), 0 0 0 1px rgba(253, 164, 175, 0.3) !important;
}

/* ======================================================== */
/* VS Code Studio & macOS Terminal Enhanced Playground      */
/* ======================================================== */
.vscode-window {
  background-color: #0d1117;
  border-radius: 1.5rem;
  border: 1px solid #21262d;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  overflow: hidden;
  transition: all 0.3s ease;
}

.vscode-titlebar {
  background: #161b22;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #21262d;
}

.vscode-traffic-lights {
  display: flex;
  align-items: center;
  gap: 7px;
}

.traffic-light {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  box-shadow: inset 0 1px 1px rgba(255, 255, 255, 0.3);
}

.traffic-red { background: #ff5f56; border: 1px solid #e0443e; }
.traffic-yellow { background: #ffbd2e; border: 1px solid #dea123; }
.traffic-green { background: #27c93f; border: 1px solid #1aab29; }

.vscode-tabs-bar {
  background: #0d1117;
  display: flex;
  align-items: center;
  border-bottom: 1px solid #21262d;
  overflow-x: auto;
}

.vscode-tab {
  padding: 0.55rem 1rem;
  font-family: var(--font-code);
  font-size: 0.75rem;
  color: #c9d1d9;
  background: #161b22;
  border-right: 1px solid #21262d;
  border-top: 2px solid #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.vscode-breadcrumbs {
  background: #0d1117;
  padding: 0.35rem 1rem;
  font-size: 0.68rem;
  font-family: var(--font-code);
  color: #8b949e;
  border-bottom: 1px solid #21262d;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.vscode-editor-area {
  background: #0d1117;
  color: #e6edf3;
  font-family: var(--font-code);
  line-height: 1.65;
}

.vscode-statusbar {
  background: #1f2937;
  color: #9ca3af;
  font-family: var(--font-code);
  font-size: 0.7rem;
  padding: 0.35rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid #374151;
}

.vscode-terminal-panel {
  background: #090d16;
  border-top: 1px solid #1f2937;
  padding: 0.85rem 1rem;
  font-family: var(--font-code);
}

.terminal-cursor {
  display: inline-block;
  width: 7px;
  height: 14px;
  background-color: #38bdf8;
  vertical-align: middle;
  animation: cursorBlink 1s infinite;
}

@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Code Editor Enhanced Styling */
textarea.code-editor-input, textarea.font-mono {
  background-color: #0d1117 !important;
  color: #38bdf8 !important;
  caret-color: #38bdf8;
  resize: vertical;
  line-height: 1.65;
  border: 1px solid #21262d !important;
}

textarea.code-editor-input:focus, textarea.font-mono:focus {
  outline: none;
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.2) !important;
}

/* Custom Soft Scrollbars */
::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 8px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Responsive Touch Targets & Mobile Optimizations */
@media (max-width: 640px) {
  body {
    font-size: 15px;
    line-height: 1.7;
  }

  /* Prevent table overflow on small screens */
  .table-responsive-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  /* Improve button touch targets on smartphones without distorting compact/fixed-size buttons */
  button:not([class*="w-"]):not([class*="h-"]):not(.btn-compact), a.btn-touch {
    min-height: 42px;
  }
  button[class*="w-"][class*="h-"] {
    min-height: unset;
  }

  /* Prevent iOS Safari auto-zoom on form inputs */
  input[type="text"],
  input[type="password"],
  input[type="email"],
  input[type="number"],
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Reduce editor height on small mobile */
  textarea.code-editor-input, textarea.font-mono {
    font-size: 13px !important;
  }
}

/* Tablet Optimizations */
@media (min-width: 641px) and (max-width: 1024px) {
  body {
    font-size: 15.5px;
  }
}

/* Ensure images never cause horizontal overflow */
img {
  max-width: 100%;
  height: auto;
}

/* Selection Highlight */
::selection {
  background-color: #c7d2fe;
  color: #1e1b4b;
}

/* Custom Button Ripple on Click */
button:active {
  transform: scale(0.98);
}

/* ======================================================== */
/* Aceternity UI: Aurora Background Engine (Pure CSS / 60fps) */
/* ======================================================== */
@keyframes aurora {
  from {
    background-position: 50% 50%, 50% 50%;
  }
  to {
    background-position: 350% 50%, 350% 50%;
  }
}

.aurora-bg-container {
  position: relative;
  overflow: hidden;
  background-color: #030712;
}

.aurora-layer {
  position: absolute;
  inset: -10px;
  pointer-events: none;
  opacity: 0.55;
  filter: blur(12px);
  will-change: transform, background-position;
  
  --white-gradient: repeating-linear-gradient(100deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.15) 7%, transparent 10%, transparent 12%, rgba(255,255,255,0.15) 16%);
  --dark-gradient: repeating-linear-gradient(100deg, #000000 0%, #000000 7%, transparent 10%, transparent 12%, #000000 16%);
  --aurora: repeating-linear-gradient(100deg, #3b82f6 10%, #a5b4fc 15%, #38bdf8 20%, #c084fc 25%, #6366f1 30%);
  
  background-image: var(--dark-gradient), var(--aurora);
  background-size: 300% 200%;
  background-position: 50% 50%, 50% 50%;
  mask-image: radial-gradient(ellipse at 100% 0%, black 20%, transparent 75%);
  -webkit-mask-image: radial-gradient(ellipse at 100% 0%, black 20%, transparent 75%);
}

.aurora-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: var(--dark-gradient), var(--aurora);
  background-size: 200% 100%;
  background-attachment: fixed;
  mix-blend-mode: difference;
  animation: aurora 50s linear infinite;
}

/* Light Theme Aurora (Optional variation for light cards) */
.aurora-light-layer {
  filter: blur(12px) invert(0.92);
  opacity: 0.45;
  background-image: var(--white-gradient), var(--aurora);
}

.aurora-light-layer::after {
  background-image: var(--white-gradient), var(--aurora);
}

/* ======================================================== */
/* Universal VS Code Playground Enhancements Across Units   */
/* ======================================================== */
textarea[id^="editor-"] {
  background-color: #0d1117 !important;
  color: #38bdf8 !important;
  border: 1px solid #30363d !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.45);
  font-family: var(--font-code) !important;
  font-size: 13.5px !important;
  line-height: 1.65 !important;
  border-radius: 1rem !important;
}

textarea[id^="editor-"]:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25), inset 0 2px 4px rgba(0, 0, 0, 0.45) !important;
}

/* Styled Console Box */
div:has(> pre[id^="output-"]) {
  background: #090d16 !important;
  border: 1px solid #21262d !important;
  border-radius: 1rem !important;
  box-shadow: 0 4px 20px -3px rgba(0, 0, 0, 0.5);
}

pre[id^="output-"] {
  font-family: var(--font-code) !important;
  color: #34d399 !important;
}

/* ======================================================== */
/* Cyber Science Arcade Styles & Animations                */
/* ======================================================== */
@keyframes arcadeShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-7px); }
  40%, 80% { transform: translateX(7px); }
}

.shake-animation {
  animation: arcadeShake 0.45s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes pulseNeon {
  0%, 100% { box-shadow: 0 0 15px rgba(56, 189, 248, 0.35); }
  50% { box-shadow: 0 0 30px rgba(56, 189, 248, 0.7); }
}

.pulse-neon {
  animation: pulseNeon 2s infinite ease-in-out;
}

@keyframes fireStreakPulse {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 8px rgba(249, 115, 22, 0.6)); }
  50% { transform: scale(1.08); filter: drop-shadow(0 0 16px rgba(239, 68, 68, 0.9)); }
}

.fire-streak {
  animation: fireStreakPulse 1s infinite ease-in-out;
}

.cyber-card {
  background: linear-gradient(135deg, rgba(15, 23, 42, 0.92) 0%, rgba(10, 14, 23, 0.97) 100%);
  border: 1px solid rgba(56, 189, 248, 0.2);
  box-shadow: 0 20px 40px -15px rgba(0, 0, 0, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px);
}

.cyber-card-active {
  border-color: rgba(56, 189, 248, 0.6) !important;
  box-shadow: 0 0 25px rgba(56, 189, 248, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.15) !important;
}

/* ======================================================== */
/* Pedagogical Showcase & Print Optimization Styles         */
/* ======================================================== */
@media print {
  body {
    background: #ffffff !important;
    color: #0f172a !important;
    font-size: 12pt;
  }
  header, footer, nav, #model-tab-bar, .no-print, button, .aurora-bg-container {
    display: none !important;
  }
  main {
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }
  .glass-card, .cyber-card {
    background: #ffffff !important;
    border: 1px solid #cbd5e1 !important;
    box-shadow: none !important;
    color: #0f172a !important;
  }
  .print-only {
    display: block !important;
  }
  .print-page-break {
    page-break-before: always;
  }
}




