/* ── Kanji pages — shared styles ── */

main { padding-top: 72px; }

.lesson-header { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%); color: #fff; padding: 3rem 1.5rem 2rem; text-align: center; margin-bottom: 2rem; }
.lesson-header h1 { font-family: 'Space Grotesk', sans-serif; font-size: clamp(1.6rem, 4vw, 2.4rem); font-weight: 700; margin-bottom: 0.5rem; }
.lesson-header p { opacity: 0.88; font-size: 1rem; }
.lang-badge { display: inline-block; background: rgba(255,255,255,0.2); border: 1px solid rgba(255,255,255,0.4); border-radius: 20px; padding: 0.2rem 0.9rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.06em; margin-bottom: 0.75rem; }
.milestone-badge { display: inline-block; background: rgba(255,215,0,0.25); border: 1px solid rgba(255,215,0,0.6); border-radius: 20px; padding: 0.2rem 0.9rem; font-size: 0.8rem; font-weight: 700; letter-spacing: 0.04em; margin-bottom: 0.5rem; color: #fef3c7; }

.lesson-container { max-width: 860px; margin: 0 auto; padding: 0 1.5rem 3rem; }
.ex-card { background: #fff; border-radius: 16px; padding: 2rem; margin-bottom: 2rem; box-shadow: 0 2px 12px rgba(0,0,0,0.08); border-left: 4px solid #1e40af; }
.ex-card h2 { font-family: 'Space Grotesk', sans-serif; color: #1e3a8a; font-size: 1.25rem; margin-bottom: 0.25rem; }
.ex-instructions { color: #64748b; margin-bottom: 1.25rem; font-size: 0.95rem; line-height: 1.6; }

.progress-bar-wrap { background: #fff; border-radius: 12px; padding: 1rem 1.25rem; margin-bottom: 1.75rem; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.progress-label { font-size: 0.9rem; color: #64748b; margin-bottom: 0.5rem; }
.progress-track { height: 8px; background: #e2e8f0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: linear-gradient(90deg, #1e40af, #16a34a); border-radius: 4px; transition: width 0.4s ease; width: 0%; }

/* Flashcard grid */
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 0.625rem; }
.flip-card { cursor: pointer; perspective: 600px; height: 110px; }
.flip-card-inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.4s; }
.flip-card.flipped .flip-card-inner { transform: rotateY(180deg); }
.flip-front, .flip-back { position: absolute; inset: 0; backface-visibility: hidden; border-radius: 10px; display: flex; align-items: center; justify-content: center; }
.flip-front { background: #eff6ff; border: 2px solid #93c5fd; font-size: 2.5rem; color: #1e293b; transition: background 0.15s; }
.flip-front:hover { background: #dbeafe; }
.flip-back { background: #1e40af; color: #fff; transform: rotateY(180deg); flex-direction: column; gap: 0.2rem; padding: 0.6rem 0.4rem; text-align: center; }
.back-meaning { font-size: 0.95rem; font-weight: 800; line-height: 1.2; }
.back-row { font-size: 0.6rem; opacity: 0.85; line-height: 1.4; }
.flip-all-btn { display: inline-flex; align-items: center; gap: 0.45rem; background: none; border: 1px solid #1e40af; color: #1e40af; padding: 0.4rem 1rem; border-radius: 8px; font-size: 0.85rem; font-weight: 600; cursor: pointer; margin-top: 1rem; transition: background 0.2s; }
.flip-all-btn:hover { background: #eff6ff; }

/* Input grids */
.char-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.char-item { background: #f8fafc; border-radius: 10px; padding: 0.875rem 0.625rem; text-align: center; border: 2px solid transparent; transition: border-color 0.25s, background 0.25s; }
.char-big { font-size: 2.5rem; display: block; line-height: 1.2; }
.char-label { font-size: 0.65rem; color: #94a3b8; text-transform: uppercase; letter-spacing: 0.05em; display: block; margin-top: 0.2rem; }
.char-input { width: 100%; border: none; border-bottom: 2px solid #93c5fd; background: transparent; text-align: center; font-size: 0.88rem; padding: 3px 2px; outline: none; margin-top: 0.4rem; font-family: 'Inter', sans-serif; color: #1e293b; transition: border-color 0.2s; }
.char-input:focus { border-bottom-color: #1e40af; }
.char-hint { display: block; font-size: 0.68rem; color: #dc2626; margin-top: 0.3rem; min-height: 1em; }
.char-item.correct { border-color: #16a34a; background: #f0fdf4; }
.char-item.incorrect { border-color: #dc2626; background: #fee2e2; }
.char-item.correct .char-input { border-bottom-color: #16a34a; }
.char-item.incorrect .char-input { border-bottom-color: #dc2626; }

/* Buttons */
.action-row { display: flex; gap: 0.75rem; margin-top: 1.25rem; flex-wrap: wrap; }
.btn-jp { display: inline-flex; align-items: center; gap: 0.45rem; padding: 0.6rem 1.25rem; border-radius: 8px; font-weight: 600; font-size: 0.9rem; cursor: pointer; border: none; transition: background 0.2s; }
.btn-primary { background: #1e40af; color: #fff; }
.btn-primary:hover { background: #1e3a8a; }
.btn-reset { background: #f1f5f9; color: #475569; }
.btn-reset:hover { background: #e2e8f0; }
.score-line { margin-top: 0.75rem; font-size: 0.9rem; font-weight: 600; color: #64748b; min-height: 1.3em; }
.score-line.success { color: #16a34a; }
.score-line.error { color: #dc2626; }

/* See Why accordion */
.see-why-card { border-left-color: #f59e0b; }
.see-why-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; background: none; border: none; cursor: pointer; padding: 0; font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; color: #d97706; text-align: left; }
.see-why-toggle:hover { color: #b45309; }
.see-why-chevron { transition: transform 0.25s ease; flex-shrink: 0; }
.see-why-toggle[aria-expanded="true"] .see-why-chevron { transform: rotate(180deg); }
.see-why-body { margin-top: 1.5rem; }
.see-why-body.hidden { display: none; }

/* Kanji entries */
.kanji-entry { margin-bottom: 2.25rem; padding-bottom: 2.25rem; border-bottom: 1px solid #f1f5f9; }
.kanji-entry:last-child { margin-bottom: 0; border-bottom: none; padding-bottom: 0; }
.kanji-entry-title { font-family: 'Space Grotesk', sans-serif; font-size: 1rem; font-weight: 700; color: #1e3a8a; margin-bottom: 1rem; display: flex; align-items: center; gap: 0.75rem; }
.kanji-display-lg { font-size: 2.25rem; border: 2px solid #bfdbfe; border-radius: 8px; width: 52px; height: 52px; display: flex; align-items: center; justify-content: center; background: #eff6ff; flex-shrink: 0; }
.kanji-entry-meta { display: flex; flex-direction: column; }
.kanji-entry-meaning { font-size: 1.1rem; }
.kanji-entry-readings { font-size: 0.78rem; color: #64748b; font-weight: 400; margin-top: 0.15rem; }
.why-sub { font-family: 'Space Grotesk', sans-serif; font-size: 0.82rem; font-weight: 700; color: #92400e; text-transform: uppercase; letter-spacing: 0.06em; margin: 1rem 0 0.5rem; border-bottom: 2px solid #fcd34d; padding-bottom: 0.25rem; }
.mnemonic-box { background: #fffbeb; border: 1px solid #fcd34d; border-radius: 10px; padding: 0.875rem 1rem; font-size: 0.88rem; color: #1e293b; line-height: 1.7; }
.vocab-list { list-style: none; padding: 0; margin: 0; }
.vocab-item { display: grid; grid-template-columns: 1.5rem 1fr 1fr 1.5fr; gap: 0.5rem; align-items: baseline; padding: 0.35rem 0; border-bottom: 1px solid #f1f5f9; font-size: 0.84rem; }
.vocab-item:last-child { border-bottom: none; }
.vocab-num { color: #94a3b8; font-size: 0.72rem; }
.vocab-word { font-size: 0.95rem; font-weight: 500; }
.vocab-reading { color: #64748b; }
.vocab-meaning { color: #334155; }
.sentence-card { background: #f8fafc; border-radius: 10px; padding: 0.875rem 1rem; margin-bottom: 0.625rem; border-left: 3px solid #93c5fd; }
.sentence-romaji { font-size: 0.76rem; color: #94a3b8; margin-bottom: 0.2rem; }
.sentence-jp { font-size: 1rem; line-height: 1.7; margin-bottom: 0.2rem; }
.sentence-jp .hl { background: #fef3c7; border-radius: 3px; padding: 0 2px; font-weight: 700; color: #1e40af; }
.sentence-gloss { font-size: 0.74rem; color: #94a3b8; font-style: italic; margin-bottom: 0.2rem; }
.sentence-en { font-size: 0.84rem; color: #475569; font-weight: 500; }

/* Review the Rules accordion */
.rules-card { border-left-color: #1e40af; }
.rules-toggle { width: 100%; display: flex; justify-content: space-between; align-items: center; background: none; border: none; cursor: pointer; padding: 0; font-family: 'Space Grotesk', sans-serif; font-size: 1.1rem; font-weight: 700; color: #1e40af; text-align: left; }
.rules-toggle:hover { color: #1e3a8a; }
.rules-chevron { transition: transform 0.25s ease; flex-shrink: 0; }
.rules-toggle[aria-expanded="true"] .rules-chevron { transform: rotate(180deg); }
.rules-body { margin-top: 1.25rem; }
.rules-body.hidden { display: none; }
.kanji-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.kanji-table th { background: #eff6ff; color: #1e3a8a; font-family: 'Space Grotesk', sans-serif; font-weight: 700; padding: 0.5rem 0.75rem; border: 1px solid #dbeafe; text-align: left; font-size: 0.78rem; }
.kanji-table td { padding: 0.6rem 0.75rem; border: 1px solid #e2e8f0; vertical-align: middle; }
.kanji-table td .k { font-size: 1.75rem; display: block; line-height: 1; }
.kanji-table td .m { font-weight: 600; }
.jlpt-pill { display: inline-block; background: #dbeafe; color: #1e40af; border-radius: 4px; font-size: 0.68rem; font-weight: 700; padding: 0.1rem 0.45rem; }

/* Page nav */
.page-nav { display: flex; justify-content: space-between; margin-bottom: 1.5rem; gap: 1rem; }
.page-nav a { display: inline-flex; align-items: center; gap: 0.4rem; background: #1e40af; color: #fff; padding: 0.5rem 1.1rem; border-radius: 8px; font-size: 0.88rem; font-weight: 600; text-decoration: none; transition: background 0.2s; }
.page-nav a:hover { background: #1e3a8a; }
.page-nav .nav-ghost { background: #f1f5f9; color: #94a3b8; cursor: default; }
.page-nav .nav-ghost:hover { background: #f1f5f9; }

@media (max-width: 768px) {
  main { padding-top: 60px; }
  .ex-card { padding: 1rem; }
  .lesson-container { padding: 0 0.75rem 2rem; }
  .card-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); }
  .char-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .vocab-item { grid-template-columns: 1.5rem 1fr 1fr; }
  .vocab-meaning { display: none; }
  .kanji-table th:nth-child(4), .kanji-table td:nth-child(4) { display: none; }
}
