/* ===== RAM1111 Base Styles ===== */
:root {
  --bg: #f7fafc;
  --bg-card: #ffffff;
  --text: #1a202c;
  --text-muted: #4a5568;
  --primary: #2b6cb0;
  --primary-dark: #1a365d;
  --accent: #ed8936;
  --border: #e2e8f0;
  --success: #38a169;
  --danger: #e53e3e;
  --radius: 12px;
  --shadow: 0 4px 12px rgba(0,0,0,0.08);
  --font: 'Sarabun', 'Noto Sans Thai', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
  --bg: #1a202c;
  --bg-card: #2d3748;
  --text: #f7fafc;
  --text-muted: #a0aec0;
  --primary: #63b3ed;
  --primary-dark: #90cdf4;
  --accent: #f6ad55;
  --border: #4a5568;
  --shadow: 0 4px 12px rgba(0,0,0,0.3);
}

* { 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.7;
  min-height: 100vh;
  transition: background 0.3s, color 0.3s;
}

.container { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

/* Header */
.header {
  position: sticky; top: 0; z-index: 100;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: 56px; gap: 12px;
}
.logo {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 1.15rem; color: var(--primary-dark);
  text-decoration: none;
}
.logo-icon { font-size: 1.4rem; }
.nav {
  display: flex; gap: 4px;
}
.nav-link {
  padding: 6px 12px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-size: 0.9rem;
  transition: all 0.2s;
}
.nav-link:hover, .nav-link.active {
  background: var(--primary); color: #fff;
}
.header-actions { display: flex; gap: 6px; align-items: center; }
.btn-icon {
  width: 40px; height: 40px; border: none; border-radius: 10px;
  background: transparent; font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text);
}
.btn-icon:hover { background: var(--border); }
.menu-toggle { display: none; }

/* Hero */
.hero {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  color: #fff; padding: 48px 0 56px; text-align: center;
}
.hero h1 { font-size: 1.9rem; line-height: 1.3; margin-bottom: 8px; }
.hero h1 span { font-size: 1.35rem; font-weight: 500; opacity: 0.95; }
.hero-sub { opacity: 0.85; margin-bottom: 12px; }
.hero-desc { max-width: 520px; margin: 0 auto 24px; opacity: 0.9; font-size: 0.95rem; }
.hero-btns { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 12px 24px; border-radius: 10px; font-weight: 600;
  text-decoration: none; border: 2px solid transparent; cursor: pointer;
  font-size: 1rem; transition: all 0.2s;
}
.btn-primary { background: var(--accent); color: #1a202c; }
.btn-primary:hover { filter: brightness(1.1); }
.btn-outline { background: transparent; border-color: #fff; color: #fff; }
.btn-outline:hover { background: rgba(255,255,255,0.15); }
.btn-sm { padding: 8px 16px; font-size: 0.9rem; }

/* Sections */
.section-title {
  font-size: 1.4rem; margin: 40px 0 20px; text-align: center;
  color: var(--primary-dark);
}
.feature-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.feature-card {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.feature-icon { font-size: 2rem; margin-bottom: 8px; }
.feature-card h3 { font-size: 1.05rem; margin-bottom: 6px; }
.feature-card p { font-size: 0.9rem; color: var(--text-muted); }

.chapter-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 40px; }
.chapter-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; text-decoration: none;
  color: var(--text); transition: all 0.2s;
}
.chapter-item:hover { border-color: var(--primary); transform: translateX(4px); }
.ch-num {
  background: var(--primary); color: #fff; width: 36px; height: 36px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; flex-shrink: 0;
}

.howto-list { padding-left: 24px; margin-bottom: 48px; }
.howto-list li { margin-bottom: 10px; }

/* Content pages */
.page-title {
  font-size: 1.5rem; margin: 24px 0 8px; color: var(--primary-dark);
}
.page-sub { color: var(--text-muted); margin-bottom: 24px; }

.unit {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 24px;
  box-shadow: var(--shadow);
}
.unit h2 {
  font-size: 1.25rem; margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 2px solid var(--primary); color: var(--primary-dark);
}
.unit h3 { font-size: 1.05rem; margin: 16px 0 8px; color: var(--primary); }
.unit p, .unit li { margin-bottom: 8px; font-size: 0.95rem; }
.unit ul, .unit ol { padding-left: 22px; margin-bottom: 12px; }
.example {
  background: var(--bg); border-left: 4px solid var(--accent);
  padding: 10px 14px; margin: 10px 0; border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
}
.tip {
  background: rgba(237,137,54,0.12); border-radius: 8px;
  padding: 10px 14px; margin: 12px 0; font-size: 0.9rem;
}
.table-wrap { overflow-x: auto; margin: 12px 0; }
table {
  width: 100%; border-collapse: collapse; font-size: 0.9rem;
}
th, td {
  border: 1px solid var(--border); padding: 8px 10px; text-align: left;
}
th { background: var(--primary); color: #fff; }
[data-theme="dark"] th { background: #2c5282; }

/* Quiz */
.quiz-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; margin-bottom: 20px;
}
.q-item { margin-bottom: 20px; padding-bottom: 16px; border-bottom: 1px solid var(--border); }
.q-item:last-child { border-bottom: none; }
.q-num { font-weight: 700; color: var(--primary); margin-right: 6px; }
.options { margin-top: 8px; }
.opt {
  display: block; padding: 10px 12px; margin: 6px 0;
  border: 1px solid var(--border); border-radius: 8px; cursor: pointer;
  transition: all 0.15s;
}
.opt:hover { border-color: var(--primary); background: rgba(43,108,176,0.08); }
.opt.selected { border-color: var(--primary); background: rgba(43,108,176,0.15); }
.opt.correct { border-color: var(--success); background: rgba(56,161,105,0.15); }
.opt.wrong { border-color: var(--danger); background: rgba(229,62,62,0.12); }
.score-box {
  text-align: center; padding: 24px; background: var(--bg-card);
  border-radius: var(--radius); border: 1px solid var(--border);
  margin: 20px 0;
}
.score-num { font-size: 2.5rem; font-weight: 700; color: var(--primary); }

/* Footer */
.footer {
  background: var(--bg-card); border-top: 1px solid var(--border);
  padding: 24px 0; text-align: center; margin-top: 40px;
  font-size: 0.85rem; color: var(--text-muted);
}
.footer-note { margin-top: 4px; opacity: 0.8; }

/* Mobile */
@media (max-width: 768px) {
  .nav {
    display: none; position: absolute; top: 56px; left: 0; right: 0;
    background: var(--bg-card); flex-direction: column; padding: 12px;
    border-bottom: 1px solid var(--border); box-shadow: var(--shadow);
  }
  .nav.open { display: flex; }
  .menu-toggle { display: flex; }
  .hero h1 { font-size: 1.5rem; }
  .hero h1 span { font-size: 1.15rem; }
  .feature-grid { grid-template-columns: 1fr; }
}

/* Print */
@media print {
  .header, .footer, .hero-btns, .btn-icon, .menu-toggle, #darkToggle, #printBtn { display: none !important; }
  body { background: #fff; color: #000; font-size: 12pt; }
  .unit, .feature-card, .chapter-item { box-shadow: none; border: 1px solid #ccc; break-inside: avoid; }
  a { color: #000; text-decoration: none; }
  .hero { background: none; color: #000; padding: 16px 0; }
}

/* Speak button */
.example {
  position: relative;
  padding-right: 48px !important;
}
.speak-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: transform 0.15s, background 0.15s;
  z-index: 2;
}
.speak-btn:hover {
  transform: scale(1.1);
  background: var(--primary-dark);
}
.speak-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}
.speak-btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 0.9rem;
  cursor: pointer;
  margin-left: 6px;
  vertical-align: middle;
}
.speak-btn-inline:hover {
  background: var(--primary-dark);
}

@media print {
  .speak-btn, .speak-btn-inline { display: none !important; }
  .example { padding-right: 14px !important; }
}


/* High-yield notes */
.badge-hot {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #c05621;
  color: #fff;
  font-size: 0.72rem;
  font-weight: 700;
  vertical-align: middle;
  letter-spacing: 0.02em;
}
.warn-note {
  background: rgba(197, 48, 48, 0.1);
  border-left: 4px solid #c53030;
  border-radius: 0 8px 8px 0;
  padding: 10px 14px;
  margin: 12px 0;
  font-size: 0.92rem;
}

/* 30-minute rest reminder */
.rest-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.rest-card {
  width: min(520px, 100%);
  max-height: min(90vh, 720px);
  overflow: auto;
  background: var(--bg-card);
  color: var(--text);
  border-radius: 16px;
  padding: 22px 20px 18px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  border: 1px solid var(--border);
}
.rest-kicker {
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  color: var(--primary);
  font-weight: 700;
  margin-bottom: 6px;
}
.rest-card h2 {
  font-size: 1.25rem;
  margin-bottom: 10px;
  color: var(--primary-dark);
}
.dhikr {
  text-align: center;
  background: rgba(43, 108, 176, 0.1);
  border-radius: 12px;
  padding: 14px 12px;
  margin: 12px 0 14px;
}
.dhikr-ar {
  font-size: 1.55rem;
  line-height: 1.6;
  direction: rtl;
}
.dhikr-th {
  margin-top: 4px;
  color: var(--text-muted);
  font-size: 0.95rem;
}
.rest-card p { margin-bottom: 10px; font-size: 0.95rem; }
.rest-card ul { padding-left: 18px; margin: 0 0 12px; }
.rest-card li { margin-bottom: 6px; font-size: 0.92rem; }
.rest-src {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 14px;
}
.rest-actions { display: flex; justify-content: flex-end; }
.rest-close {
  border: none;
  background: var(--primary);
  color: #fff;
  border-radius: 10px;
  padding: 10px 18px;
  font-weight: 700;
  cursor: pointer;
  font-size: 1rem;
}
.rest-close:hover { filter: brightness(1.08); }

@media print {
  .rest-overlay, .badge-hot { }
  .rest-overlay { display: none !important; }
}
