/* AI เพื่อเยาวชน มัธยม 4-6 — advanced AI aesthetic + motion */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  --primary: #22d3ee;
  --primary-dark: #06b6d4;
  --primary-glow: rgba(34, 211, 238, 0.45);
  --accent: #a78bfa;
  --accent-2: #f472b6;
  --accent-3: #34d399;
  --success: #34d399;
  --warning: #fbbf24;
  --danger: #f87171;
  --bg: #070b14;
  --bg-elevated: #0f1629;
  --bg-card: rgba(15, 22, 41, 0.88);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.16);
  --grid: rgba(34, 211, 238, 0.05);
  --shadow: 0 12px 40px rgba(0,0,0,0.45);
  --radius: 14px;
  --font: 'Sarabun', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}
[data-theme="light"] {
  --bg: #f0f9ff; --bg-elevated: #fff; --bg-card: rgba(255,255,255,0.94);
  --text: #0f172a; --text-muted: #475569;
  --border: rgba(6,182,212,0.18); --grid: rgba(6,182,212,0.07);
  --shadow: 0 12px 40px rgba(6,182,212,0.12);
  --primary: #0891b2; --primary-dark: #0e7490;
  --primary-glow: rgba(8,145,178,0.25);
}
[data-theme="soft"] {
  --bg: #150f22; --bg-elevated: #1e1533; --bg-card: rgba(30,21,51,0.9);
  --text: #f5f3ff; --text-muted: #c4b5fd;
  --primary: #c4b5fd; --primary-dark: #a78bfa; --accent: #f9a8d4;
  --border: rgba(196,181,253,0.2); --grid: rgba(196,181,253,0.07);
}

* { 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.75; min-height: 100vh; font-size: 16.5px;
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 40px 40px;
  animation: gridDrift 60s linear infinite;
}
@keyframes gridDrift {
  0% { background-position: 0 0; }
  100% { background-position: 40px 40px; }
}

.container { width: 100%; max-width: 1060px; margin: 0 auto; padding: 0 1.2rem; }

/* Header */
.header {
  background: rgba(7,11,20,0.82); backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100;
}
[data-theme="light"] .header { background: rgba(255,255,255,0.9); }
.header-inner { display: flex; align-items: center; gap: 0.9rem; padding: 0.6rem 0; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 0.55rem; text-decoration: none; color: var(--text); }
.logo img {
  width: 40px; height: 40px; border-radius: 10px;
  box-shadow: 0 0 18px var(--primary-glow);
  animation: logoPulse 3s ease-in-out infinite;
}
@keyframes logoPulse {
  0%,100% { box-shadow: 0 0 12px var(--primary-glow); }
  50% { box-shadow: 0 0 24px var(--primary-glow), 0 0 40px rgba(167,139,250,0.2); }
}
.brand {
  font-weight: 800; font-size: 1.05rem;
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--accent-2));
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: shimmer 4s linear infinite;
}
@keyframes shimmer { to { background-position: 200% center; } }
.level { font-size: 0.72rem; color: var(--text-muted); font-weight: 600; letter-spacing: 0.04em; }

.nav { display: flex; gap: 0.25rem; margin-left: auto; flex-wrap: wrap; }
.nav-link {
  text-decoration: none; color: var(--text-muted); font-weight: 600; font-size: 0.86rem;
  padding: 0.4rem 0.8rem; border-radius: 8px; transition: all 0.18s; border: 1px solid transparent;
}
.nav-link:hover, .nav-link.active {
  color: var(--primary); background: rgba(34,211,238,0.1); border-color: rgba(34,211,238,0.3);
}
.nav-link.external {
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border: none;
}
.header-actions { display: flex; gap: 0.3rem; }
.icon-btn {
  appearance: none; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 9px; width: 36px; height: 36px; font-size: 1rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: var(--text);
  transition: all 0.18s;
}
.icon-btn:hover { border-color: var(--primary); box-shadow: 0 0 14px var(--primary-glow); }
.mobile-only { display: none !important; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  padding: 0.6rem 1.2rem; border-radius: 10px; font-weight: 700; font-size: 0.92rem;
  text-decoration: none; border: none; cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.btn.primary {
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  color: #fff; box-shadow: 0 4px 22px var(--primary-glow);
}
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 32px var(--primary-glow); }
.btn.secondary {
  background: transparent; color: var(--primary);
  border: 1.5px solid rgba(34,211,238,0.45);
}
.btn.secondary:hover { background: rgba(34,211,238,0.1); }
.btn.large { padding: 0.8rem 1.6rem; font-size: 1rem; }

/* Hero with floating orbs */
.hero {
  padding: 3.2rem 0 2.6rem; position: relative; overflow: hidden;
}
.hero::before {
  content: ''; position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 15% 40%, rgba(34,211,238,0.18), transparent),
    radial-gradient(ellipse 50% 45% at 85% 55%, rgba(167,139,250,0.15), transparent),
    radial-gradient(ellipse 40% 30% at 50% 90%, rgba(244,114,182,0.08), transparent);
  pointer-events: none; animation: heroGlow 8s ease-in-out infinite alternate;
}
@keyframes heroGlow {
  from { opacity: 0.7; }
  to { opacity: 1; }
}
.orb {
  position: absolute; border-radius: 50%; filter: blur(40px); pointer-events: none;
  animation: floatOrb 12s ease-in-out infinite;
}
.orb-1 { width: 180px; height: 180px; background: rgba(34,211,238,0.2); top: 10%; left: 5%; }
.orb-2 { width: 140px; height: 140px; background: rgba(167,139,250,0.18); top: 40%; right: 8%; animation-delay: -4s; }
.orb-3 { width: 100px; height: 100px; background: rgba(244,114,182,0.15); bottom: 15%; left: 40%; animation-delay: -7s; }
@keyframes floatOrb {
  0%,100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(20px,-15px) scale(1.05); }
  66% { transform: translate(-15px,10px) scale(0.95); }
}

.hero-grid {
  display: grid; grid-template-columns: 1.25fr 0.75fr;
  gap: 2rem; align-items: center; position: relative; z-index: 1;
}
.hero h1 {
  font-size: clamp(1.75rem, 4vw, 2.4rem); font-weight: 800; line-height: 1.25; margin-bottom: 0.85rem;
}
.hero h1 span {
  background: linear-gradient(90deg, var(--primary), var(--accent), var(--accent-2));
  background-size: 200% auto;
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  animation: shimmer 5s linear infinite;
}
.hero-desc { font-size: 1.02rem; color: var(--text-muted); margin-bottom: 1.4rem; max-width: 540px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.hero-card {
  background: linear-gradient(145deg, rgba(34,211,238,0.12), rgba(167,139,250,0.18));
  border: 1px solid rgba(34,211,238,0.35);
  border-radius: 18px; padding: 1.9rem 1.4rem; text-align: center;
  box-shadow: 0 0 50px rgba(34,211,238,0.12), inset 0 1px 0 rgba(255,255,255,0.06);
  position: relative; overflow: hidden;
}
.hero-card::before {
  content: ''; position: absolute; inset: -50%;
  background: conic-gradient(from 0deg, transparent, rgba(34,211,238,0.15), transparent 40%);
  animation: spinSlow 10s linear infinite;
}
@keyframes spinSlow { to { transform: rotate(360deg); } }
.hero-card-inner { position: relative; z-index: 1; }
.hero-card .icons { font-size: 2.5rem; margin-bottom: 0.55rem; letter-spacing: 0.25rem;
  filter: drop-shadow(0 0 10px var(--primary-glow)); animation: iconBob 3s ease-in-out infinite; }
@keyframes iconBob {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.hero-card p { font-weight: 700; font-size: 1.02rem; }
.hero-card .tag {
  display: inline-block; margin-top: 0.7rem; font-family: var(--mono); font-size: 0.7rem;
  color: var(--primary); border: 1px solid rgba(34,211,238,0.45);
  padding: 0.25rem 0.6rem; border-radius: 6px;
  animation: tagBlink 2.5s ease-in-out infinite;
}
@keyframes tagBlink {
  0%,100% { opacity: 1; box-shadow: 0 0 0 transparent; }
  50% { opacity: 0.85; box-shadow: 0 0 12px var(--primary-glow); }
}

.section { padding: 2.2rem 0; }
.section-title {
  font-size: 1.35rem; font-weight: 800; margin-bottom: 0.3rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.section-title::before {
  content: ''; width: 4px; height: 1.1em;
  background: linear-gradient(var(--primary), var(--accent)); border-radius: 2px;
}
.section-sub { color: var(--text-muted); margin-bottom: 1.3rem; font-size: 0.93rem; }

.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem;
}
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.25rem; backdrop-filter: blur(8px); transition: all 0.25s; position: relative; overflow: hidden;
}
.feature-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--accent), transparent);
  opacity: 0; transition: opacity 0.25s;
}
.feature-card:hover {
  border-color: rgba(34,211,238,0.45); box-shadow: 0 0 28px rgba(34,211,238,0.12);
  transform: translateY(-4px);
}
.feature-card:hover::before { opacity: 1; }
.feature-icon { font-size: 1.55rem; margin-bottom: 0.45rem; }
.feature-card h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.3rem; }
.feature-card p { font-size: 0.87rem; color: var(--text-muted); line-height: 1.55; }

.lesson-list { display: flex; flex-direction: column; gap: 0.7rem; }
.lesson-item {
  display: flex; align-items: center; gap: 1rem;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1rem 1.15rem; text-decoration: none; color: var(--text); transition: all 0.2s;
}
.lesson-item:hover {
  border-color: rgba(34,211,238,0.5); box-shadow: 0 0 22px rgba(34,211,238,0.12);
  transform: translateX(5px);
}
.lesson-num {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary-dark), var(--accent));
  color: #fff; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 0.95rem; flex-shrink: 0; font-family: var(--mono);
  box-shadow: 0 0 16px var(--primary-glow);
}
.lesson-info h3 { font-size: 1rem; font-weight: 700; margin-bottom: 0.1rem; }
.lesson-info p { font-size: 0.84rem; color: var(--text-muted); }

.lesson-header {
  background: linear-gradient(135deg, rgba(34,211,238,0.18), rgba(167,139,250,0.22));
  border-bottom: 1px solid var(--border); padding: 2rem 0 1.7rem; position: relative;
}
.lesson-header::after {
  content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary), var(--accent), transparent);
}
.lesson-header h1 { font-size: 1.55rem; font-weight: 800; margin-bottom: 0.25rem; }
.lesson-meta { font-family: var(--mono); font-size: 0.78rem; color: var(--primary); margin-bottom: 0.25rem; opacity: 0.9; }

.lesson-content {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.7rem 1.5rem; margin: 1.4rem 0 2.2rem; backdrop-filter: blur(8px);
}
.lesson-content h2 {
  font-size: 1.18rem; font-weight: 800; margin: 1.7rem 0 0.6rem; padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border); color: var(--primary);
}
.lesson-content h2:first-child { margin-top: 0; }
.lesson-content h3 { font-size: 1.02rem; font-weight: 700; margin: 1.2rem 0 0.4rem; }
.lesson-content p { margin-bottom: 0.75rem; font-size: 0.97rem; }
.lesson-content ul, .lesson-content ol { margin: 0.5rem 0 1rem 1.35rem; }
.lesson-content li { margin-bottom: 0.4rem; font-size: 0.95rem; }

.example-box {
  background: rgba(34,211,238,0.07); border: 1px solid rgba(34,211,238,0.28);
  border-left: 3px solid var(--primary); padding: 1rem 1.15rem; border-radius: 0 10px 10px 0;
  margin: 1rem 0; font-size: 0.93rem;
}
.example-box strong { color: var(--primary); }
.activity-box {
  background: rgba(167,139,250,0.08); border: 1px solid rgba(167,139,250,0.28);
  border-left: 3px solid var(--accent); padding: 1rem 1.15rem; border-radius: 0 10px 10px 0;
  margin: 1rem 0; font-size: 0.93rem;
}
.key-box {
  background: rgba(251,191,36,0.08); border: 1px solid rgba(251,191,36,0.3);
  border-left: 3px solid var(--warning); padding: 1rem 1.15rem; border-radius: 0 10px 10px 0;
  margin: 1rem 0; font-size: 0.93rem;
}
.ref-box {
  background: var(--bg-elevated); border: 1px dashed var(--border);
  padding: 0.9rem 1rem; border-radius: 10px; margin: 1.2rem 0 0.4rem;
  font-size: 0.84rem; color: var(--text-muted);
}
.ref-box strong { color: var(--text); }

/* Prompt lab / demo blocks */
.demo-lab {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 12px; margin: 1.2rem 0; overflow: hidden;
}
.demo-lab-header {
  font-family: var(--mono); font-size: 0.75rem; color: var(--primary);
  padding: 0.5rem 1rem; border-bottom: 1px solid var(--border);
  background: rgba(34,211,238,0.06); display: flex; align-items: center; gap: 0.5rem;
}
.demo-lab-header .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-3);
  box-shadow: 0 0 8px var(--accent-3); animation: logoPulse 2s ease-in-out infinite; }
.demo-prompt {
  padding: 0.9rem 1rem; font-family: var(--mono); font-size: 0.85rem;
  color: var(--text); border-bottom: 1px solid var(--border); white-space: pre-wrap;
}
.demo-prompt .label { color: var(--accent-2); font-weight: 700; }
.demo-output {
  padding: 0.9rem 1rem; font-size: 0.9rem; color: var(--text-muted);
  background: rgba(52,211,153,0.05);
}
.demo-output .label { color: var(--accent-3); font-family: var(--mono); font-size: 0.75rem; font-weight: 700; }

.flow-diagram {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin: 1rem 0;
  font-family: var(--mono); font-size: 0.8rem;
}
.flow-node {
  background: rgba(34,211,238,0.12); border: 1px solid rgba(34,211,238,0.35);
  padding: 0.45rem 0.75rem; border-radius: 8px; color: var(--primary);
}
.flow-arrow { color: var(--accent); font-weight: 700; }

.quiz-question {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 10px; padding: 1rem 1.1rem; margin-bottom: 0.85rem;
}
.quiz-question p { margin-bottom: 0.5rem; font-weight: 600; font-size: 0.95rem; }
.quiz-options label {
  display: block; padding: 0.45rem 0.7rem; margin-bottom: 0.25rem;
  border-radius: 7px; border: 1px solid transparent; cursor: pointer; font-size: 0.92rem; transition: all 0.15s;
}
.quiz-options label:hover { background: rgba(34,211,238,0.1); border-color: rgba(34,211,238,0.25); }
.quiz-options input { margin-right: 0.45rem; }

.footer {
  background: var(--bg-elevated); border-top: 1px solid var(--border);
  padding: 1.4rem 0; margin-top: auto;
}
.footer-content { text-align: center; }
.footer-brand {
  font-weight: 800;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
  margin-bottom: 0.25rem;
}
.footer-note { font-size: 0.8rem; color: var(--text-muted); }

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center; z-index: 200;
  padding: 1rem; backdrop-filter: blur(6px);
}
.modal.hidden { display: none; }
.modal-content {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 16px; padding: 1.6rem; max-width: 400px; width: 100%;
  text-align: center; box-shadow: var(--shadow);
}
.modal-content h2 { font-size: 1.1rem; margin-bottom: 0.6rem; }
.dhikr { font-size: 1.1rem; direction: rtl; margin: 0.6rem 0 0.2rem; color: var(--primary); font-weight: 600; }
.dhikr-trans { font-size: 0.86rem; color: var(--text-muted); margin-bottom: 0.85rem; }
.health-tips {
  text-align: left; background: var(--bg); padding: 0.75rem; border-radius: 9px;
  margin-bottom: 0.85rem; font-size: 0.86rem; border: 1px solid var(--border);
}
.health-tips h3 { font-size: 0.9rem; margin-bottom: 0.3rem; }
.health-tips ul { margin-left: 1.1rem; }
.modal-actions { display: flex; flex-direction: column; gap: 0.6rem; align-items: center; }
.checkbox-label { font-size: 0.84rem; color: var(--text-muted); cursor: pointer; }

@media (max-width: 900px) {
  .mobile-only { display: inline-flex !important; }
  .nav {
    display: none !important; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--bg-elevated); flex-direction: column; padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--border); gap: 0.15rem; z-index: 150;
  }
  .nav.open { display: flex !important; }
  .nav-link { width: 100%; text-align: center; padding: 0.75rem; }
  .header-inner { position: relative; }
  .hero-grid { grid-template-columns: 1fr; }
  .hero-card { order: -1; max-width: 300px; margin: 0 auto; }
  .orb { display: none; }
}
@media print {
  body { background: #fff; color: #000; background-image: none; animation: none; }
  .header, .footer, .no-print, .icon-btn, #reminder-modal, .quiz-question, .activity-box, .btn, .orb { display: none !important; }
  .lesson-content { box-shadow: none; border: 1px solid #ccc; background: #fff; }
}
