/* RAM1131 Digital Literacy — Polished UI */
/* Mobile-first · Dark Mode · Print-friendly */

:root {
  --primary: #1a365d;
  --primary-soft: #ebf4ff;
  --primary-mid: #2b6cb0;
  --accent: #3182ce;
  --accent-hover: #2c5282;
  --success: #276749;
  --success-bg: #f0fff4;
  --warning: #b7791f;
  --danger: #c53030;
  --danger-bg: #fff5f5;
  --bg: #f0f4f8;
  --bg-card: #ffffff;
  --text: #1a202c;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 1px 2px rgba(15,23,42,.06);
  --shadow-md: 0 8px 24px rgba(15,23,42,.08);
  --shadow-lg: 0 16px 40px rgba(15,23,42,.12);
  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --font: 'Sarabun', system-ui, -apple-system, sans-serif;
  --header-h: 64px;
  --ease: cubic-bezier(.4,0,.2,1);
  --grad: linear-gradient(135deg, #1a365d 0%, #2b6cb0 50%, #3182ce 100%);
}

body.dark-mode {
  --primary: #63b3ed;
  --primary-soft: #1a365d;
  --primary-mid: #4299e1;
  --accent: #63b3ed;
  --accent-hover: #90cdf4;
  --success: #68d391;
  --success-bg: #1c4532;
  --warning: #f6e05e;
  --danger: #fc8181;
  --danger-bg: #3b1a1a;
  --bg: #0b1220;
  --bg-card: #141c2e;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #243047;
  --shadow: 0 1px 2px rgba(0,0,0,.3);
  --shadow-md: 0 8px 24px rgba(0,0,0,.35);
  --shadow-lg: 0 16px 40px rgba(0,0,0,.4);
  --grad: linear-gradient(135deg, #1e3a5f 0%, #2b6cb0 100%);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background .25s var(--ease), color .25s var(--ease);
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-decoration: none; transition: color .2s; }
a:hover { color: var(--accent-hover); }

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

/* Skip */
.skip-link {
  position: absolute; top: -48px; left: 12px;
  background: var(--primary); color: #fff;
  padding: 10px 16px; border-radius: var(--radius-xs); z-index: 1000;
}
.skip-link:focus { top: 12px; }

/* ========== Header ========== */
.site-header {
  position: sticky; top: 0; z-index: 100;
  height: var(--header-h);
  background: rgba(255,255,255,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
body.dark-mode .site-header {
  background: rgba(20,28,46,.88);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  height: var(--header-h); gap: 12px;
}

.logo {
  display: flex; align-items: center; gap: 10px;
  color: var(--text); text-decoration: none; flex-shrink: 0;
}
.logo-icon {
  width: 40px; height: 40px;
  background: var(--grad);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  box-shadow: 0 4px 12px rgba(43,108,176,.35);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; }
.logo-text strong { font-size: 1.05rem; font-weight: 700; color: var(--primary); letter-spacing: -.02em; }
.logo-text small { font-size: .7rem; color: var(--text-muted); font-weight: 500; }

.main-nav { display: none; gap: 4px; }
.main-nav a {
  padding: 8px 14px; border-radius: 999px;
  color: var(--text-muted); font-weight: 500; font-size: .92rem;
  transition: all .2s var(--ease);
}
.main-nav a:hover { background: var(--primary-soft); color: var(--primary); }
.main-nav a.active {
  background: var(--grad); color: #fff;
  box-shadow: 0 4px 12px rgba(43,108,176,.3);
}

.header-actions { display: flex; align-items: center; gap: 4px; }

.btn-icon {
  background: transparent; border: none;
  width: 42px; height: 42px; border-radius: 50%;
  font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text); transition: background .2s;
}
.btn-icon:hover { background: var(--primary-soft); }
.btn-icon:active { transform: scale(.94); }

body.light-mode .icon-moon { display: inline; }
body.light-mode .icon-sun { display: none; }
body.dark-mode .icon-moon { display: none; }
body.dark-mode .icon-sun { display: inline; }

.menu-toggle { display: flex; }

.main-nav.open {
  display: flex; flex-direction: column;
  position: absolute; top: var(--header-h); left: 0; right: 0;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px 16px;
  box-shadow: var(--shadow-md); z-index: 99;
  gap: 4px;
  animation: slideDown .2s var(--ease);
}
.main-nav.open a { padding: 12px 16px; border-radius: var(--radius-sm); }

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Offline */
.offline-banner {
  background: linear-gradient(90deg, #d69e2e, #ecc94b);
  color: #1a202c; text-align: center;
  padding: 10px; font-size: .9rem; font-weight: 600;
}

/* Main */
.main-content { flex: 1; padding: 28px 0 56px; }

/* ========== Buttons ========== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border-radius: 999px;
  font-family: var(--font); font-size: .98rem; font-weight: 600;
  border: none; cursor: pointer;
  transition: all .2s var(--ease);
  text-decoration: none; line-height: 1.3;
}
.btn:active { transform: scale(.97); }

.btn-primary {
  background: var(--grad); color: #fff;
  box-shadow: 0 4px 14px rgba(43,108,176,.35);
}
.btn-primary:hover { filter: brightness(1.08); color: #fff; box-shadow: 0 6px 20px rgba(43,108,176,.4); }

.btn-secondary {
  background: var(--bg-card); color: var(--text);
  border: 1.5px solid var(--border);
  box-shadow: var(--shadow);
}
.btn-secondary:hover { border-color: var(--primary-mid); color: var(--primary); background: var(--primary-soft); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { background: var(--border); color: var(--text); }

.btn-sm { padding: 7px 16px; font-size: .88rem; }
.btn-lg { padding: 14px 28px; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ========== Cards ========== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 22px;
  transition: box-shadow .25s, transform .25s;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title {
  font-size: 1.15rem; font-weight: 700;
  margin-bottom: 6px; color: var(--primary);
}
.card-text { color: var(--text-muted); font-size: .95rem; line-height: 1.6; }

/* ========== Hero ========== */
.hero {
  text-align: center;
  padding: 48px 16px 40px;
  position: relative;
  overflow: hidden;
}
.hero::before {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(49,130,206,.12), transparent);
  pointer-events: none;
}
body.dark-mode .hero::before {
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(99,179,237,.1), transparent);
}
.hero h1 {
  font-size: 1.85rem; font-weight: 800;
  margin-bottom: 14px; line-height: 1.3;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -.03em;
}
.hero p {
  font-size: 1.05rem; color: var(--text-muted);
  max-width: 540px; margin: 0 auto 28px; line-height: 1.7;
}
.hero-actions {
  display: flex; flex-wrap: wrap; gap: 12px; justify-content: center;
}

/* Features */
.features {
  display: grid; grid-template-columns: 1fr; gap: 14px; margin: 36px 0;
}
.feature-card {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 20px !important;
}
.feature-card:hover { transform: translateY(-3px); }
.feature-icon {
  width: 52px; height: 52px; flex-shrink: 0;
  background: var(--primary-soft);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.feature-card .card-title { font-size: 1.05rem; margin-bottom: 4px; }
.feature-card .card-text { font-size: .9rem; }

/* Chapter list */
.chapter-list {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.chapter-item {
  display: flex; align-items: center; gap: 16px;
  padding: 18px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all .25s var(--ease);
  color: var(--text);
  box-shadow: var(--shadow);
}
.chapter-item:hover {
  border-color: var(--primary-mid);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
  color: var(--text);
}
.chapter-num {
  width: 44px; height: 44px; flex-shrink: 0;
  background: var(--grad); color: #fff;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.05rem;
  box-shadow: 0 4px 12px rgba(43,108,176,.3);
}
.chapter-info h3 {
  font-size: 1.02rem; font-weight: 700; margin-bottom: 2px;
  letter-spacing: -.01em;
}
.chapter-info p {
  font-size: .85rem; color: var(--text-muted); line-height: 1.45;
}

/* Page header */
.page-header { margin-bottom: 28px; }
.page-header h1 {
  font-size: 1.55rem; font-weight: 800;
  color: var(--primary); margin-bottom: 6px;
  letter-spacing: -.02em;
}
.breadcrumb {
  font-size: .88rem; color: var(--text-muted); margin-bottom: 8px;
}
.breadcrumb a { color: var(--accent); font-weight: 500; }

/* Content body */
.content-body {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 28px 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
  line-height: 1.8;
}
.content-body h2 {
  font-size: 1.28rem; font-weight: 700;
  color: var(--primary);
  margin: 32px 0 14px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--primary-soft);
  letter-spacing: -.01em;
}
.content-body h2:first-child { margin-top: 0; }
.content-body h3 {
  font-size: 1.08rem; font-weight: 700;
  margin: 22px 0 10px; color: var(--text);
}
.content-body p { margin-bottom: 14px; }
.content-body ul, .content-body ol {
  margin: 0 0 16px 1.4em;
}
.content-body li { margin-bottom: 8px; }

.content-body .highlight {
  background: var(--primary-soft);
  border-left: 4px solid var(--accent);
  padding: 14px 18px;
  margin: 18px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .97rem;
}
.content-body .key-point {
  background: var(--success-bg);
  border-left: 4px solid var(--success);
  padding: 14px 18px;
  margin: 18px 0;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: .97rem;
}
body.dark-mode .content-body .highlight { background: rgba(49,130,206,.12); }
body.dark-mode .content-body .key-point { background: rgba(104,211,145,.1); }

.content-body table {
  width: 100%; border-collapse: collapse;
  margin: 18px 0; font-size: .93rem;
  border-radius: var(--radius-sm); overflow: hidden;
}
.content-body th, .content-body td {
  border: 1px solid var(--border);
  padding: 12px 14px; text-align: left;
}
.content-body th {
  background: var(--primary-soft);
  font-weight: 700; color: var(--primary);
}

/* Quiz */
.quiz-container { max-width: 720px; margin: 0 auto; }
.question-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
  animation: fadeIn .3s var(--ease);
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.question-num {
  font-size: .82rem; font-weight: 600;
  color: var(--primary); margin-bottom: 10px;
  text-transform: uppercase; letter-spacing: .04em;
}
.question-text {
  font-size: 1.08rem; font-weight: 600;
  margin-bottom: 18px; line-height: 1.55;
}
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice-label {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .2s var(--ease);
  background: var(--bg);
}
.choice-label:hover {
  border-color: var(--primary-mid);
  background: var(--primary-soft);
}
.choice-label.selected {
  border-color: var(--primary-mid);
  background: var(--primary-soft);
  box-shadow: 0 0 0 3px rgba(49,130,206,.15);
}
.choice-label.correct {
  border-color: var(--success);
  background: var(--success-bg);
}
.choice-label.wrong {
  border-color: var(--danger);
  background: var(--danger-bg);
}
.choice-label input { margin-top: 4px; accent-color: var(--primary-mid); }
.choice-letter {
  font-weight: 800; color: var(--primary);
  min-width: 22px; font-size: .95rem;
}

.quiz-progress {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 16px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 10px;
  box-shadow: var(--shadow);
  font-weight: 600; font-size: .95rem;
}
.progress-bar {
  height: 8px; background: var(--border);
  border-radius: 99px; overflow: hidden;
  flex: 1; min-width: 100px;
}
.progress-fill {
  height: 100%;
  background: var(--grad);
  border-radius: 99px;
  transition: width .35s var(--ease);
}

.result-box {
  text-align: center;
  padding: 40px 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  margin-top: 20px;
}
.result-score {
  font-size: 3.2rem; font-weight: 800;
  background: var(--grad);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}
.result-msg { font-size: 1.15rem; margin: 12px 0 28px; color: var(--text-muted); font-weight: 500; }

/* Vocab */
.vocab-grid {
  display: grid; grid-template-columns: 1fr; gap: 12px;
}
.vocab-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  transition: transform .2s, box-shadow .2s;
}
.vocab-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.vocab-term {
  font-size: 1.12rem; font-weight: 700;
  color: var(--primary);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 4px;
}
.vocab-en {
  font-size: .88rem; color: var(--text-muted);
  font-style: italic; margin-bottom: 8px;
}
.vocab-def { font-size: .95rem; line-height: 1.6; }
.vocab-example {
  font-size: .8rem; color: var(--text-muted);
  margin-top: 10px;
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary);
  padding: 3px 10px;
  border-radius: 99px;
  font-weight: 600;
}
.btn-speak {
  background: var(--primary-soft); border: none;
  width: 32px; height: 32px; border-radius: 50%;
  font-size: 1rem; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: transform .15s, background .15s;
}
.btn-speak:hover { background: var(--primary); transform: scale(1.1); }
.btn-speak:active { transform: scale(.95); }

/* Footer */
.site-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 48px 0 24px;
  margin-top: auto;
}
.footer-grid {
  display: grid; grid-template-columns: 1fr; gap: 28px; margin-bottom: 28px;
}
.footer-col h4 {
  font-size: .95rem; font-weight: 700;
  margin-bottom: 12px; color: var(--primary);
}
.footer-col p, .footer-col li {
  font-size: .88rem; color: var(--text-muted); margin-bottom: 6px; line-height: 1.6;
}
.footer-col ul { list-style: none; }
.footer-col a { color: var(--text-muted); }
.footer-col a:hover { color: var(--accent); }
.footer-bottom {
  text-align: center;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: .82rem; color: var(--text-muted);
}
.version { margin-top: 4px; opacity: .6; }

/* Install prompt */
.install-prompt {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 30px rgba(0,0,0,.12);
  padding: 18px; z-index: 200;
  animation: slideUp .3s var(--ease);
}
@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.install-content {
  max-width: 480px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 12px;
  align-items: center; text-align: center;
  font-weight: 500;
}
.install-actions { display: flex; gap: 10px; }

/* Section title */
.section-title {
  font-size: 1.35rem; font-weight: 800;
  color: var(--primary); margin-bottom: 20px;
  text-align: center; letter-spacing: -.02em;
}

/* Utils */
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 28px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 28px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 12px; }
.justify-center { justify-content: center; }

/* ========== Responsive ========== */
@media (min-width: 640px) {
  .features { grid-template-columns: 1fr 1fr; }
  .chapter-list { grid-template-columns: 1fr 1fr; }
  .vocab-grid { grid-template-columns: 1fr 1fr; }
  .footer-grid { grid-template-columns: 2fr 1fr 1fr; }
  .hero h1 { font-size: 2.35rem; }
  .content-body { padding: 36px 40px; }
}

@media (min-width: 900px) {
  .main-nav { display: flex; }
  .menu-toggle { display: none; }
  .features { grid-template-columns: 1fr 1fr 1fr; }
  .hero { padding: 64px 16px 48px; }
  .hero h1 { font-size: 2.6rem; }
}

/* ========== Print ========== */
@media print {
  .site-header, .site-footer, .header-actions,
  .offline-banner, .install-prompt, .btn,
  .menu-toggle, #darkModeToggle, #printBtn,
  .quiz-actions, .skip-link, .hero-actions { display: none !important; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .main-content { padding: 0; }
  .content-body {
    border: none; box-shadow: none; padding: 0;
  }
  .content-body h2 { page-break-after: avoid; border-bottom: 1px solid #ccc; }
  a { color: #000; text-decoration: none; }
  .page-header { margin-bottom: 12px; }
  .highlight, .key-point { border: 1px solid #ccc; background: #f9f9f9; }
}
