/* =============================================================
 * みんなの日本語 学習システム · デザインシステム / theme.css
 * このファイルが UI 全体の見た目の正典。
 * すべてのページ・モジュールはこのファイルを <link> して使う。
 * 個別ページは「自分のレイアウト」だけを持ち、色・字・部品はここから取る。
 * ============================================================= */

/* -----------------------------------------------------------
 * 1. デザイントークン
 * --------------------------------------------------------- */
:root {
  /* --- カラー --- */
  --bg:           #F5F0E6;  /* 背景ベージュ */
  --paper:        #FAF6EC;  /* カード／白寄りの面 */
  --ink:          #2A3A2A;  /* 本文・見出しの主色 */
  --green:        #3A5F3A;  /* ブランド緑（タイトル・主CTA） */
  --green-soft:   #6B8E6B;  /* 補助文字・ホバー */
  --green-pale:   #C8D6C8;  /* 区切り線・無効ボタン・dots */
  --accent:       #C9A961;  /* ゴールド：助詞「は・も・か」 */
  --highlight:    #D4574F;  /* 赤：述語「です・じゃありません」 */

  /* --- キャラクター用 --- */
  --skin:         #F4D5B8;
  --hair-dark:    #2A2520;
  --tanaka-suit:  #2C3E50;
  --linh-shirt:   #E89B7E;

  /* --- フォント --- */
  --font-jp: 'Zen Maru Gothic', sans-serif;  /* 日本語：丸ゴシック */
  --font-vn: 'Be Vietnam Pro', sans-serif;   /* ベトナム語 */

  /* --- スペーシング（4の倍数） --- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 24px;
  --s-6: 32px;
  --s-7: 48px;
  --s-8: 64px;

  /* --- 角丸 --- */
  --r-sm:   8px;
  --r-md:  14px;
  --r-lg:  20px;
  --r-pill: 999px;

  /* --- 影 --- */
  --shadow-card: 0 4px 18px rgba(58, 95, 58, 0.08);
  --shadow-pop:  0 8px 28px rgba(58, 95, 58, 0.14);
}

/* 多言語(i18n)：ベンガル語時のフォント上書き */
html[data-lang="bn"] { --font-vn: 'Noto Sans Bengali', 'Be Vietnam Pro', sans-serif; }

/* -----------------------------------------------------------
 * 2. リセット & ベース
 * --------------------------------------------------------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-jp);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--green);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button { font-family: inherit; }

/* -----------------------------------------------------------
 * 3. タイポグラフィ・ユーティリティ
 *    例：<span class="particle">は</span>  → ゴールド
 *        <span class="predicate">です</span> → 赤
 *        <div class="vn">Vietnamese...</div> → ベトナム語イタリック
 * --------------------------------------------------------- */
.kicker {
  font-size: 12px;
  color: var(--green-soft);
  letter-spacing: 0.22em;
  font-weight: 500;
  text-transform: uppercase;
}

.eyebrow {
  font-size: 13px;
  color: var(--green-soft);
  letter-spacing: 0.25em;
  font-weight: 500;
}

.vn {
  font-family: var(--font-vn);
  font-style: italic;
  color: var(--green-soft);
  font-weight: 400;
}

.particle { color: var(--accent);    font-weight: 700; }  /* は、も、か */
.predicate,
.accent   { color: var(--highlight); font-weight: 700; }  /* です、じゃありません */
.key      { color: var(--highlight); font-weight: 700; }  /* 強調 */
.n        { color: var(--ink);       font-weight: 900; }  /* N (placeholder) */

/* 見出し的なタイトル */
.title-xl {
  font-size: 76px;
  font-weight: 900;
  color: var(--green);
  letter-spacing: 0.04em;
  line-height: 1.1;
}
.title-lg {
  font-size: 48px;
  font-weight: 800;
  color: var(--green);
  letter-spacing: 0.03em;
  line-height: 1.15;
}
.title-md {
  font-size: 32px;
  font-weight: 700;
  color: var(--ink);
}

/* -----------------------------------------------------------
 * 4. レッスンバッジ（左上の番号）
 *    使用例：
 *      <div class="lesson-badge"><div class="num">1</div>...</div>
 * --------------------------------------------------------- */
.lesson-badge {
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.lesson-badge .num {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--green);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
}

/* -----------------------------------------------------------
 * 5. ボタン
 *    主要：.btn  / .btn--ghost / .btn--accent / .btn--sm
 * --------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  font-family: var(--font-jp);
  background: var(--green);
  color: var(--paper);
  border: none;
  padding: 12px 26px;
  border-radius: var(--r-pill);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  text-decoration: none;
}
.btn:hover:not(:disabled) { background: var(--green-soft); text-decoration: none; }
.btn:active:not(:disabled) { transform: scale(0.96); }
.btn:disabled {
  background: var(--green-pale);
  color: var(--green-soft);
  cursor: not-allowed;
}
.btn--ghost {
  background: transparent;
  color: var(--green);
  border: 2px solid var(--green-pale);
}
.btn--ghost:hover:not(:disabled) {
  background: var(--green-pale);
  color: var(--green);
}
.btn--accent { background: var(--accent); }
.btn--accent:hover:not(:disabled) { background: #B8965A; }
.btn--danger { background: var(--highlight); }
.btn--sm { padding: 8px 18px; font-size: 14px; }
.btn--lg { padding: 14px 30px; font-size: 18px; }

/* -----------------------------------------------------------
 * 6. カード
 * --------------------------------------------------------- */
.card {
  background: var(--paper);
  border-radius: var(--r-md);
  padding: 20px 24px;
  box-shadow: var(--shadow-card);
}
.card--accent { border-left: 5px solid var(--highlight); }
.card--accent.green { border-left-color: var(--green); }
.card--accent.gold  { border-left-color: var(--accent); }

/* 例文カード（共通） */
.example-card {
  background: var(--paper);
  border-radius: var(--r-lg);
  padding: 28px 40px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  align-items: center;
  max-width: 760px;
  border-left: 5px solid var(--highlight);
}
.example-card.green { border-left-color: var(--green); }
.example-card.gold  { border-left-color: var(--accent); }
.example-card .ex-jp {
  font-size: 38px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.02em;
  text-align: center;
  line-height: 1.3;
}
.example-card .ex-vn {
  font-family: var(--font-vn);
  font-size: 16px;
  color: var(--green-soft);
  font-style: italic;
  text-align: center;
}

/* リプレイ（もういちど）ボタン */
.replay-btn {
  margin-top: var(--s-3);
  padding: 10px 22px;
  background: var(--green);
  color: var(--paper);
  border: none;
  border-radius: var(--r-pill);
  font-family: var(--font-jp);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  transition: background 0.15s, transform 0.1s;
}
.replay-btn:hover  { background: var(--green-soft); }
.replay-btn:active { transform: scale(0.97); }
.replay-btn.playing { background: var(--accent); }

/* -----------------------------------------------------------
 * 7. 進捗ドット ／ 進捗バー
 * --------------------------------------------------------- */
.dots {
  display: flex;
  gap: var(--s-1);
  flex-wrap: wrap;
  justify-content: center;
}
.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green-pale);
  cursor: pointer;
  transition: background 0.15s, transform 0.15s;
}
.dot:hover { background: var(--green-soft); }
.dot.active { background: var(--green); transform: scale(1.25); }
.dot.done   { background: var(--green); }  /* 完了済みスライド */

.progressbar {
  width: 100%;
  height: 6px;
  background: var(--green-pale);
  border-radius: var(--r-pill);
  overflow: hidden;
}
.progressbar > .fill {
  display: block;
  height: 100%;
  background: var(--green);
  border-radius: var(--r-pill);
  transition: width 0.3s ease-out;
}

/* チェックマーク（完了済みアイコン用） */
.check-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--green);
  color: var(--paper);
  font-size: 12px;
  font-weight: 800;
}
.check-icon::before { content: "✓"; }

/* ロックアイコン（未開放モジュール用） */
.lock-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--green-pale);
  color: var(--green-soft);
  font-size: 12px;
}
.lock-icon::before { content: "🔒"; }

/* -----------------------------------------------------------
 * 8. 装飾
 * --------------------------------------------------------- */
.ornament {
  width: 160px;
  height: 2px;
  background: var(--accent);
  margin: var(--s-4) auto;
  opacity: 0.7;
  border: none;
}

/* -----------------------------------------------------------
 * 9. 吹き出し
 *    <div class="speech-bubble tanaka">...</div>
 *    <div class="speech-bubble linh">...</div>
 * --------------------------------------------------------- */
.speech-bubble {
  position: relative;
  background: var(--paper);
  border: 2px solid var(--green-pale);
  border-radius: 18px;
  padding: 20px 26px;
  font-size: 28px;
  font-weight: 700;
  color: var(--ink);
  max-width: 440px;
}
.speech-bubble.tanaka::before {
  content: '';
  position: absolute;
  right: -16px; top: 30px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 10px 0 10px 16px;
  border-color: transparent transparent transparent var(--green-pale);
}
.speech-bubble.tanaka::after {
  content: '';
  position: absolute;
  right: -13px; top: 32px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 8px 0 8px 13px;
  border-color: transparent transparent transparent var(--paper);
}
.speech-bubble.linh::before {
  content: '';
  position: absolute;
  left: -16px; top: 30px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 10px 16px 10px 0;
  border-color: transparent var(--green-pale) transparent transparent;
}
.speech-bubble.linh::after {
  content: '';
  position: absolute;
  left: -13px; top: 32px;
  width: 0; height: 0;
  border-style: solid;
  border-width: 8px 13px 8px 0;
  border-color: transparent var(--paper) transparent transparent;
}
.speech-bubble .vn {
  display: block;
  font-size: 14px;
  margin-top: var(--s-2);
  font-weight: 400;
}

/* -----------------------------------------------------------
 * 10. キャラクター（田中さん／リンさん）
 *     構造：<div class="character tanaka">
 *             <div class="char-head"><div class="char-hair"></div>
 *               <div class="char-face">
 *                 <div class="char-glasses">...</div>
 *                 <div class="char-eye left"></div>
 *                 <div class="char-eye right"></div>
 *                 <div class="char-mouth"></div>
 *               </div>
 *             </div>
 *             <div class="char-body">...</div>
 *           </div>
 * --------------------------------------------------------- */
.character {
  position: relative;
  width: 160px;
  height: 220px;
}
.char-head {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 88px;
  height: 104px;
}
.char-face {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: 80px;
  background: var(--skin);
  border-radius: 36px 36px 32px 32px;
  border: 2px solid #C4A289;
}
.char-eye {
  position: absolute;
  width: 6px;
  height: 8px;
  background: var(--hair-dark);
  border-radius: 50%;
  top: 40px;
}
.char-eye.left  { left: 24px; }
.char-eye.right { right: 24px; }
.char-mouth {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 13px;
  height: 3px;
  background: #B8755C;
  border-radius: 2px;
}

/* 田中さん固有 */
.tanaka .char-hair {
  position: absolute;
  top: 6px; left: 50%;
  transform: translateX(-50%);
  width: 80px; height: 40px;
  background: var(--hair-dark);
  border-radius: 40px 40px 0 0;
}
.tanaka .char-face .char-eye {
  top: 38px; width: 5px; height: 6px;
}
.tanaka .char-face .char-eye.left  { left: 18px; }
.tanaka .char-face .char-eye.right { right: 18px; }
.tanaka .char-glasses {
  position: absolute;
  top: 34px; left: 50%;
  transform: translateX(-50%);
  width: 62px; height: 18px;
  z-index: 4;
}
.tanaka .glass-frame {
  position: absolute;
  top: 0;
  width: 22px; height: 18px;
  border: 2px solid var(--hair-dark);
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
}
.tanaka .glass-frame.left  { left: 0; }
.tanaka .glass-frame.right { right: 0; }
.tanaka .glass-bridge {
  position: absolute;
  top: 7px; left: 50%;
  transform: translateX(-50%);
  width: 18px; height: 2px;
  background: var(--hair-dark);
}
.tanaka .char-body {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 128px; height: 136px;
  background: var(--tanaka-suit);
  border-radius: 64px 64px 16px 16px / 80px 80px 16px 16px;
}
.tanaka .char-shirt {
  position: absolute;
  top: 16px; left: 50%;
  transform: translateX(-50%);
  width: 32px; height: 64px;
  background: #FFFFFF;
  clip-path: polygon(50% 0, 100% 30%, 80% 100%, 20% 100%, 0 30%);
}
.tanaka .char-tie {
  position: absolute;
  top: 32px; left: 50%;
  transform: translateX(-50%);
  width: 11px; height: 48px;
  background: var(--highlight);
  clip-path: polygon(50% 0, 100% 15%, 70% 100%, 30% 100%, 0 15%);
}

/* リンさん固有 */
.linh .char-hair {
  position: absolute;
  top: 4px; left: 50%;
  transform: translateX(-50%);
  width: 92px; height: 72px;
  background: var(--hair-dark);
  border-radius: 44px 44px 32px 32px / 48px 48px 24px 24px;
}
.linh .char-hair::after {
  content: '';
  position: absolute;
  top: 40px; left: -8px;
  width: 24px; height: 56px;
  background: var(--hair-dark);
  border-radius: 16px 0 0 24px;
}
.linh .char-hair::before {
  content: '';
  position: absolute;
  top: 40px; right: -8px;
  width: 24px; height: 56px;
  background: var(--hair-dark);
  border-radius: 0 16px 24px 0;
}
.linh .char-body {
  position: absolute;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 120px; height: 128px;
  background: var(--linh-shirt);
  border-radius: 60px 60px 16px 16px / 72px 72px 16px 16px;
}
.linh .char-collar {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  width: 40px; height: 20px;
  background: var(--bg);
  border-radius: 20px 20px 0 0;
}

/* -----------------------------------------------------------
 * 10b. 学生バー（ログイン情報の表示）
 *
 * 二段構え:
 *  - `.student-bar`  （フル表示）：トップ／ハブ用。名前・ID・所属を見せる
 *  - `.student-chip` （ミニ表示） ：学習中ページ用。アバター＋IDのみ、クリックで詳細
 *
 * 共通：先頭1字を緑丸の中に表示するアバター `.student-avatar`
 * --------------------------------------------------------- */
.student-bar {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 10px 24px;
  background: var(--paper);
  border-bottom: 1px solid var(--green-pale);
  font-size: 14px;
}
.student-bar .student-avatar { flex-shrink: 0; }
.student-bar .student-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.student-bar .row-1 {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
  flex-wrap: wrap;
}
.student-bar .student-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}
.student-bar .student-id {
  font-size: 12px;
  color: var(--green-soft);
  font-family: var(--font-vn);
  letter-spacing: 0.05em;
}
.student-bar .student-sub {
  font-size: 12px;
  color: var(--green-soft);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.student-bar .student-sub .dot-sep { color: var(--green-pale); }
.student-bar .logout-btn {
  background: transparent;
  color: var(--highlight);
  border: 1px solid var(--green-pale);
  padding: 10px 14px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.student-bar .logout-btn:hover {
  background: var(--highlight);
  color: var(--paper);
}

/* アバター（先頭1字を色付き丸の中に） */
.student-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--green);
  color: var(--paper);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  user-select: none;
  flex-shrink: 0;
}
.student-avatar.sm { width: 28px; height: 28px; font-size: 13px; }
.student-avatar.lg { width: 56px; height: 56px; font-size: 24px; }

/* 学習中ページ用：右上ミニチップ（アバター + ID） */
.student-chip-wrap { position: relative; display: inline-block; }
.student-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--r-pill);
  background: var(--bg);
  border: 1px solid var(--green-pale);
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.student-chip:hover { background: var(--green-pale); text-decoration: none; }
.student-chip .student-id {
  font-size: 12px;
  color: var(--green-soft);
  font-family: var(--font-vn);
  letter-spacing: 0.05em;
  white-space: nowrap;
}

/* 折りたたみ詳細パネル（chip クリックで開く） */
.student-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--paper);
  border: 1px solid var(--green-pale);
  border-radius: var(--r-md);
  padding: 16px 18px;
  box-shadow: var(--shadow-pop);
  min-width: 240px;
  max-width: calc(100vw - 32px);
  z-index: 1000;
  display: none;
}
.student-popover.open { display: block; }
.student-popover .pop-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
  padding: 4px 0;
}
.student-popover .pop-row .label {
  color: var(--green-soft);
  letter-spacing: 0.05em;
}
.student-popover .pop-row .value {
  color: var(--ink);
  font-weight: 500;
  text-align: right;
}
.student-popover .pop-sep {
  border-top: 1px solid var(--green-pale);
  margin: 10px -18px;
}
.student-popover .logout-btn {
  width: 100%;
  margin-top: 8px;
  background: transparent;
  color: var(--highlight);
  border: 1px solid var(--highlight);
  padding: 8px;
  border-radius: var(--r-pill);
  cursor: pointer;
  font-weight: 500;
}
.student-popover .logout-btn:hover {
  background: var(--highlight);
  color: var(--paper);
}

@media (max-width: 720px) {
  .student-bar { padding: 8px 16px; }
  .student-bar .student-sub { display: none; } /* モバイルでは所属を隠す */
}

/* -----------------------------------------------------------
 * 11. アプリ・シェル（上部バー／下部ナビの共通骨格）
 * --------------------------------------------------------- */
.app-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 1280px;
  min-height: 100vh;
  margin: 0 auto;
  background: var(--bg);
}
.app-bar {
  display: flex;
  align-items: center;
  gap: var(--s-4);
  padding: 20px 32px 16px;
  border-bottom: 1px solid var(--green-pale);
  flex-shrink: 0;
}
.app-bar .lesson-title {
  flex: 1;
  font-size: 18px;
  color: var(--ink);
  font-weight: 600;
}
.app-bar .lesson-title .vn {
  font-family: var(--font-vn);
  font-weight: 400;
  font-style: italic;
}
.app-bar .right {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  font-family: var(--font-vn);
  font-size: 14px;
  color: var(--green-soft);
}

.app-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 32px;
  border-top: 1px solid var(--green-pale);
  background: var(--bg);
  flex-shrink: 0;
  gap: var(--s-4);
}

/* -----------------------------------------------------------
 * 12. レスポンシブ
 * --------------------------------------------------------- */
@media (max-width: 720px) {
  .title-xl    { font-size: 48px; }
  .title-lg    { font-size: 32px; }
  .title-md    { font-size: 22px; }
  .example-card .ex-jp { font-size: 26px; }
  .speech-bubble       { font-size: 20px; padding: 16px 18px; }
  .app-bar             { padding: 14px 16px; }
  .app-foot            { padding: 12px 16px; }
}

/* モバイル: ダブルタップでの拡大を無効化（ピンチ拡大は維持） */
html, body {
  touch-action: manipulation;
}
