/* ========================================
   JPN 1111 - Japanese Pronunciation
   Mobile-first · Dark mode · Print-ready
   ======================================== */

:root {
  /* Light theme */
  --bg: #f7f9fc;
  --bg-card: #ffffff;
  --bg-header: #1a365d;
  --text: #1a202c;
  --text-secondary: #4a5568;
  --text-muted: #718096;
  --primary: #2b6cb0;
  --primary-dark: #1a365d;
  --primary-light: #ebf8ff;
  --accent: #ed8936;
  --border: #e2e8f0;
  --success: #38a169;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --font: 'Sarabun', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-jp: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
  --header-h: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* Dark mode */
[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-header: #0f172a;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --primary: #60a5fa;
  --primary-dark: #1e3a5f;
  --primary-light: #1e3a5f;
  --accent: #fbbf24;
  --border: #334155;
  --success: #4ade80;
  --shadow: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.4);
}

/* Reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  min-height: 100dvh;
  padding-top: var(--header-h);
  transition: background 0.25s, color 0.25s;
}
img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
ul, ol { list-style: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* Typography */
.jp { font-family: var(--font-jp); }
h1, h2, h3, h4 { line-height: 1.3; font-weight: 700; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

/* Container */
.container {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 0 16px;
}

/* ========== Header ========== */
.header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: var(--bg-header);
  color: #fff;
  z-index: 1000;
  box-shadow: var(--shadow);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 12px;
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #fff;
  text-decoration: none;
  font-weight: 700;
}
.logo-jp { font-family: var(--font-jp); font-size: 1.25rem; }
.logo-text { font-size: 0.95rem; letter-spacing: 0.5px; }
.header-actions { display: flex; gap: 4px; }
.btn-icon {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  color: #fff;
  transition: background 0.2s;
}
.btn-icon:hover, .btn-icon:focus { background: rgba(255,255,255,0.15); }
.btn-icon svg { display: block; }

/* Menu toggle (hamburger) */
.menu-toggle {
  width: 40px; height: 40px;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 5px;
  color: #fff;
}
.menu-toggle span {
  display: block;
  width: 20px; height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: 0.25s;
}

/* ========== Sidebar ========== */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: min(300px, 85vw);
  height: 100dvh;
  background: var(--bg-card);
  z-index: 1100;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding-bottom: var(--safe-bottom);
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--bg-header);
  color: #fff;
  font-weight: 600;
  position: sticky;
  top: 0;
}
.close-sidebar {
  font-size: 1.75rem;
  color: #fff;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}
.nav-list { padding: 8px 0; }
.nav-section {
  padding: 12px 20px 4px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: var(--text);
  text-decoration: none;
  transition: background 0.15s;
  font-size: 0.95rem;
}
.nav-link:hover, .nav-link.active {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}
.nav-icon {
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg);
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  flex-shrink: 0;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: 0.3s;
}
.overlay.show { opacity: 1; visibility: visible; }

/* ========== Main ========== */
.main { padding: 20px 0 80px; min-height: calc(100dvh - var(--header-h)); }

/* Hero */
.hero {
  text-align: center;
  padding: 32px 16px 40px;
  background: linear-gradient(135deg, var(--primary-dark) 0%, #2c5282 100%);
  color: #fff;
  border-radius: 0 0 var(--radius) var(--radius);
  margin: -20px -16px 28px;
}
.hero-badge {
  display: inline-block;
  background: rgba(255,255,255,0.2);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  margin-bottom: 12px;
}
.hero h1 {
  font-size: 1.9rem;
  margin-bottom: 8px;
}
.hero h1 .jp {
  font-size: 1.4rem;
  font-weight: 500;
  opacity: 0.9;
}
.hero-subtitle {
  font-size: 1rem;
  opacity: 0.9;
  margin-bottom: 24px;
  line-height: 1.5;
}
.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  transition: 0.2s;
  border: 2px solid transparent;
}
.btn-primary {
  background: var(--accent);
  color: #1a202c;
}
.btn-primary:hover {
  background: #dd6b20;
  text-decoration: none;
  color: #1a202c;
}
.btn-outline {
  background: transparent;
  border-color: rgba(255,255,255,0.6);
  color: #fff;
}
.btn-outline:hover {
  background: rgba(255,255,255,0.15);
  text-decoration: none;
  color: #fff;
}
.btn-sm {
  padding: 8px 16px;
  font-size: 0.85rem;
}

/* Section */
.section-title {
  text-align: center;
  margin-bottom: 20px;
  color: var(--text);
  position: relative;
}
.section-title::after {
  content: '';
  display: block;
  width: 40px; height: 3px;
  background: var(--accent);
  margin: 8px auto 0;
  border-radius: 2px;
}

/* Features */
.features { margin-bottom: 40px; }
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.feature-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.feature-card:hover { transform: translateY(-2px); }
.feature-icon { font-size: 1.75rem; margin-bottom: 8px; }
.feature-card h3 { font-size: 0.95rem; margin-bottom: 4px; }
.feature-card p { font-size: 0.8rem; color: var(--text-secondary); line-height: 1.4; }

/* Lesson list */
.lessons-overview { margin-bottom: 40px; }
.lesson-list { display: flex; flex-direction: column; gap: 8px; }
.lesson-item {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  box-shadow: var(--shadow);
  transition: 0.2s;
}
.lesson-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
  text-decoration: none;
  color: var(--text);
}
.lesson-num {
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.lesson-info { flex: 1; min-width: 0; }
.lesson-info h3 { font-size: 0.95rem; margin-bottom: 2px; }
.lesson-info p { font-size: 0.8rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lesson-arrow { color: var(--text-muted); font-size: 1.1rem; }

/* Quick start steps */
.quick-start { margin-bottom: 40px; }
.steps { display: flex; flex-direction: column; gap: 16px; }
.step {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.step-num {
  width: 36px; height: 36px;
  background: var(--accent);
  color: #1a202c;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}
.step h3 { font-size: 0.95rem; margin-bottom: 4px; }
.step p { font-size: 0.85rem; color: var(--text-secondary); }

/* Footer */
.footer {
  background: var(--bg-header);
  color: rgba(255,255,255,0.8);
  text-align: center;
  padding: 24px 16px;
  font-size: 0.85rem;
}
.footer-note { font-size: 0.75rem; opacity: 0.7; margin-top: 6px; }

/* Install banner */
.install-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  z-index: 900;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
}
.install-content {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  font-size: 0.9rem;
}
.install-content .btn { flex-shrink: 0; }

/* ========== Content pages (lessons) ========== */
.page-header {
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 2px solid var(--border);
}
.page-header .lesson-label {
  display: inline-block;
  background: var(--primary-light);
  color: var(--primary);
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 8px;
}
.page-header h1 { font-size: 1.5rem; margin-bottom: 6px; }
.page-header .jp-title {
  font-family: var(--font-jp);
  font-size: 1.2rem;
  color: var(--text-secondary);
}
.content-block {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.content-block h2 {
  font-size: 1.15rem;
  margin-bottom: 12px;
  color: var(--primary);
}
.content-block h3 {
  font-size: 1rem;
  margin: 16px 0 8px;
}
.content-block p, .content-block li {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.content-block ul, .content-block ol {
  padding-left: 20px;
  margin-bottom: 12px;
}
.content-block ul li { list-style: disc; }
.content-block ol li { list-style: decimal; }

/* Pronunciation cards */
.sound-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.sound-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 6px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s;
  user-select: none;
}
.sound-card:hover, .sound-card:active {
  border-color: var(--primary);
  background: var(--primary-light);
}
.sound-card .kana {
  font-family: var(--font-jp);
  font-size: 1.6rem;
  font-weight: 500;
  display: block;
  line-height: 1.2;
}
.sound-card .romaji {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.sound-card .thai {
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* Play button */
.btn-play {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--primary);
  color: #fff;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 4px 0;
}
.btn-play:hover { opacity: 0.9; }

/* Tip box */
.tip-box {
  background: #fef3c7;
  border-left: 4px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 14px;
  margin: 16px 0;
  font-size: 0.9rem;
}
[data-theme="dark"] .tip-box {
  background: #422006;
  border-left-color: var(--accent);
}
.tip-box strong { color: var(--accent); }

/* Table */
.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: center;
}
th {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}
[data-theme="dark"] th { background: var(--primary-dark); }

/* Navigation between lessons */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.lesson-nav a {
  flex: 1;
  padding: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
}
.lesson-nav a:hover {
  border-color: var(--primary);
  color: var(--primary);
}

/* ========== Print styles ========== */
@media print {
  .header, .sidebar, .overlay, .footer, .install-banner,
  .menu-toggle, .header-actions, .hero-actions, .btn-play,
  .lesson-nav, .nav-list { display: none !important; }
  body { padding-top: 0; background: #fff; color: #000; font-size: 12pt; }
  .main { padding: 0; }
  .hero {
    background: none !important;
    color: #000 !important;
    margin: 0 0 16px;
    padding: 0;
    text-align: left;
  }
  .hero-badge { display: none; }
  .content-block, .feature-card, .lesson-item, .step {
    box-shadow: none;
    border: 1px solid #ccc;
    break-inside: avoid;
  }
  a { color: #000; text-decoration: none; }
  .container { max-width: 100%; padding: 0; }
}

/* ========== Responsive ========== */
@media (min-width: 600px) {
  .feature-grid { grid-template-columns: repeat(3, 1fr); }
  .hero h1 { font-size: 2.2rem; }
  .sound-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
}
@media (min-width: 768px) {
  .container { padding: 0 24px; }
  .hero { margin: -20px -24px 32px; border-radius: 0 0 16px 16px; }
  .steps { flex-direction: row; }
  .step { flex: 1; flex-direction: column; text-align: center; }
}

/* Utility */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}
.text-center { text-align: center; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
