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

:root {
  --primary: #06b6d4;
  --primary-dark: #0891b2;
  --primary-glow: rgba(6, 182, 212, 0.35);
  --accent: #8b5cf6;
  --accent-2: #ec4899;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0b1020;
  --bg-elevated: #12182b;
  --bg-card: rgba(18, 24, 43, 0.85);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --border: rgba(148, 163, 184, 0.18);
  --grid-line: rgba(6, 182, 212, 0.06);
  --shadow: 0 8px 32px rgba(0,0,0,0.35);
  --radius: 14px;
  --font: 'Sarabun', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

[data-theme="light"] {
  --bg: #f0f9ff;
  --bg-elevated: #ffffff;
  --bg-card: rgba(255,255,255,0.92);
  --text: #0f172a;
  --text-muted: #475569;
  --border: rgba(14, 116, 144, 0.15);
  --grid-line: rgba(6, 182, 212, 0.08);
  --shadow: 0 8px 32px rgba(8, 145, 178, 0.1);
}

[data-theme="soft"] {
  --bg: #1a1025;
  --bg-elevated: #241833;
  --bg-card: rgba(36, 24, 51, 0.9);
  --text: #f3e8ff;
  --text-muted: #c4b5fd;
  --primary: #a78bfa;
  --primary-dark: #8b5cf6;
  --accent: #f472b6;
  --border: rgba(167, 139, 250, 0.2);
  --grid-line: rgba(167, 139, 250, 0.08);
}

* { 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-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 48px 48px;
}

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

/* Header */
.header {
  background: rgba(11, 16, 32, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
}
[data-theme="light"] .header { background: rgba(255,255,255,0.88); }
.header-inner {
  display: flex; align-items: center; gap: 0.9rem;
  padding: 0.65rem 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 16px var(--primary-glow);
}
.brand {
  font-weight: 800; font-size: 1.05rem;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.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(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 0.25);
}
.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 12px 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), var(--accent));
  color: #fff; box-shadow: 0 4px 20px var(--primary-glow);
}
.btn.primary:hover { transform: translateY(-2px); box-shadow: 0 8px 28px var(--primary-glow); }
.btn.secondary {
  background: transparent; color: var(--primary);
  border: 1.5px solid rgba(6, 182, 212, 0.5);
}
.btn.secondary:hover { background: rgba(6, 182, 212, 0.12); }
.btn.large { padding: 0.8rem 1.6rem; font-size: 1rem; }

/* Hero — neural / circuit feel */
.hero {
  padding: 3rem 0 2.5rem;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 40%, rgba(6,182,212,0.15), transparent),
    radial-gradient(ellipse 60% 50% at 80% 60%, rgba(139,92,246,0.12), transparent);
  pointer-events: none;
}
.hero-grid {
  display: grid; grid-template-columns: 1.3fr 0.7fr;
  gap: 2rem; align-items: center; position: relative;
}
.hero h1 {
  font-size: clamp(1.7rem, 4vw, 2.35rem);
  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));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.hero-desc { font-size: 1.02rem; color: var(--text-muted); margin-bottom: 1.4rem; max-width: 520px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; }

.hero-card {
  background: linear-gradient(145deg, rgba(6,182,212,0.15), rgba(139,92,246,0.2));
  border: 1px solid rgba(6, 182, 212, 0.3);
  border-radius: 18px; padding: 1.8rem 1.4rem;
  text-align: center;
  box-shadow: 0 0 40px rgba(6,182,212,0.15), inset 0 1px 0 rgba(255,255,255,0.06);
  position: relative;
}
.hero-card::after {
  content: '⟨ / ⟩';
  position: absolute; top: 0.6rem; right: 0.8rem;
  font-family: var(--mono); font-size: 0.7rem; color: var(--primary); opacity: 0.6;
}
.hero-card .icons { font-size: 2.4rem; margin-bottom: 0.6rem; letter-spacing: 0.2rem; filter: drop-shadow(0 0 8px var(--primary-glow)); }
.hero-card p { font-weight: 700; font-size: 1rem; }
.hero-card .tag {
  display: inline-block; margin-top: 0.6rem;
  font-family: var(--mono); font-size: 0.72rem;
  color: var(--primary); border: 1px solid rgba(6,182,212,0.4);
  padding: 0.2rem 0.55rem; border-radius: 6px;
}

.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.22s;
  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.22s;
}
.feature-card:hover {
  border-color: rgba(6, 182, 212, 0.4);
  box-shadow: 0 0 24px rgba(6,182,212,0.12);
  transform: translateY(-3px);
}
.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(6, 182, 212, 0.45);
  box-shadow: 0 0 20px rgba(6,182,212,0.1);
  transform: translateX(4px);
}
.lesson-num {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary), 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 14px 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 page */
.lesson-header {
  background: linear-gradient(135deg, rgba(6,182,212,0.2), rgba(139,92,246,0.25));
  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.6rem 0 0.6rem;
  padding-bottom: 0.35rem;
  border-bottom: 1px solid var(--border);
  color: var(--primary);
  display: flex; align-items: center; gap: 0.4rem;
}
.lesson-content h2:first-child { margin-top: 0; }
.lesson-content h3 {
  font-size: 1.02rem; font-weight: 700;
  margin: 1.15rem 0 0.4rem; color: var(--text);
}
.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(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.25);
  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(139, 92, 246, 0.08);
  border: 1px solid rgba(139, 92, 246, 0.25);
  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(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 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); }
.code-chip {
  font-family: var(--mono); font-size: 0.85rem;
  background: rgba(6,182,212,0.12); color: var(--primary);
  padding: 0.15rem 0.45rem; border-radius: 5px;
}

.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(6, 182, 212, 0.1);
  border-color: rgba(6, 182, 212, 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.65);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 1rem; backdrop-filter: blur(4px);
}
.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: 280px; margin: 0 auto; }
}
@media print {
  body { background: #fff; color: #000; background-image: none; }
  .header, .footer, .no-print, .icon-btn, #reminder-modal, .quiz-question, .activity-box, .btn { display: none !important; }
  .lesson-content { box-shadow: none; border: 1px solid #ccc; background: #fff; }
}
