/* ─── Google Fonts ────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@400;600;700&family=Noto+Sans+JP:wght@400;700;900&display=swap');

/* ─── Reset / Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --gold:    #C8922A;
  --gold-lt: #FFD95A;
  --bg:      #FFFDF5;
  --surface: #FFFFFF;
  --text:    #2C1810;
  --muted:   #7B6B5A;
  --radius:  16px;
}

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ─── Header (same as phrases) ────────────────────────────────────────────── */
.site-header {
  background: linear-gradient(135deg, #8B0000 0%, #C8922A 60%, #1565C0 100%);
  padding: 0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,.25);
}

.header-inner {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
}

.site-logo {
  font-size: 1.5rem;
  font-weight: 900;
  color: #FFD95A;
  text-decoration: none;
  white-space: nowrap;
  padding: 12px 0;
  text-shadow: 1px 1px 4px rgba(0,0,0,.4);
}

.site-logo .logo-sub {
  display: block;
  font-size: 0.6rem;
  font-weight: 400;
  color: rgba(255,255,255,.85);
  letter-spacing: .05em;
  font-family: 'Sarabun', sans-serif;
}

.site-nav { display: flex; gap: 4px; margin-left: auto; }

.nav-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  color: rgba(255,255,255,.85);
  font-size: 0.7rem;
  transition: background .2s, color .2s;
  line-height: 1.3;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255,255,255,.2);
  color: #FFD95A;
}

.nav-icon { font-size: 1.3rem; }

.voice-warning {
  display: none;
  background: #FFF3CD;
  border-bottom: 2px solid #FFC107;
  padding: 8px 16px;
  font-size: 0.8rem;
  color: #856404;
  align-items: center;
  gap: 8px;
  justify-content: center;
  text-align: center;
}

/* ─── Main ────────────────────────────────────────────────────────────────── */
main { max-width: 1000px; margin: 0 auto; padding: 16px; }

/* ─── Class Legend ────────────────────────────────────────────────────────── */
.class-legend {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
  align-items: center;
}

.class-legend-label {
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 700;
  margin-right: 4px;
}

.legend-dot {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 3px 10px;
  border-radius: 20px;
  color: white;
  font-weight: 700;
}

.legend-dot.high { background: #1E88E5; }
.legend-dot.mid  { background: #43A047; }
.legend-dot.low  { background: #E53935; }

/* ─── Filter Buttons ──────────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-btn {
  padding: 8px 18px;
  border-radius: 30px;
  border: 2px solid #DDD;
  background: var(--surface);
  font-family: 'Noto Sans JP', sans-serif;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  display: flex;
  align-items: center;
  gap: 4px;
}

.filter-btn[data-cls="all"].active  { background: #555; border-color: #555; color: white; }
.filter-btn[data-cls="high"].active { background: #1E88E5; border-color: #1E88E5; color: white; }
.filter-btn[data-cls="mid"].active  { background: #43A047; border-color: #43A047; color: white; }
.filter-btn[data-cls="low"].active  { background: #E53935; border-color: #E53935; color: white; }
.filter-btn:hover { transform: translateY(-1px); }

/* ─── Consonant Grid ──────────────────────────────────────────────────────── */
#consonantGrid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.con-btn {
  background: var(--surface);
  border-radius: 12px;
  border: 2px solid transparent;
  padding: 12px 6px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  box-shadow: 0 2px 6px rgba(0,0,0,.08);
  transition: all .2s;
  position: relative;
  animation: fadeUp .35s both;
  font-family: 'Noto Sans JP', sans-serif;
}

.con-btn:hover {
  border-color: var(--cls-color);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,.14);
}

.con-btn.active {
  border-color: var(--cls-color);
  background: color-mix(in srgb, var(--cls-color) 12%, white);
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}

.con-letter {
  font-family: 'Sarabun', sans-serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--cls-color);
  line-height: 1;
}

.con-sound {
  font-size: 0.6rem;
  color: var(--muted);
  font-weight: 600;
  text-align: center;
}

.con-cls-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--cls-color);
  position: absolute;
  top: 5px;
  right: 5px;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Detail Panel ────────────────────────────────────────────────────────── */
#detailPanel {
  background: var(--surface);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  border: 3px solid var(--det-color, #CCC);
  display: none;
}

.detail-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: start;
}

.detail-letter-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#detLetter {
  font-family: 'Sarabun', sans-serif;
  font-size: 5rem;
  font-weight: 700;
  line-height: 1;
}

.det-speak-btns {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.det-speak-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 2px solid var(--det-color, #ccc);
  background: none;
  font-size: 0.75rem;
  cursor: pointer;
  font-family: 'Noto Sans JP', sans-serif;
  font-weight: 700;
  color: var(--det-color, #555);
  transition: background .15s, color .15s;
}

.det-speak-btn:hover {
  background: var(--det-color, #ccc);
  color: white;
}

.detail-info { display: flex; flex-direction: column; gap: 10px; }

.info-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.info-label {
  font-size: 0.65rem;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.info-value {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.info-value.th {
  font-family: 'Sarabun', sans-serif;
  font-size: 1.4rem;
}

#detClass {
  display: inline-block;
  padding: 4px 14px;
  border-radius: 20px;
  color: white;
  font-size: 0.85rem;
  font-weight: 700;
}

.det-example {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--bg);
  border-radius: 12px;
  margin-top: 4px;
}

.det-example-emoji { font-size: 2rem; }

.det-example-text { display: flex; flex-direction: column; gap: 2px; }

#detExample {
  font-family: 'Sarabun', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

#detExRom {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
}

#detExJa {
  font-size: 0.8rem;
  color: var(--muted);
}

/* ─── Tone Info Box ───────────────────────────────────────────────────────── */
.tone-info {
  background: #FFF8E7;
  border: 1px solid #FFD95A;
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 16px;
  font-size: 0.82rem;
  color: #5D4037;
  line-height: 1.6;
}

.tone-info strong { color: #C8922A; }

/* ─── Footer ──────────────────────────────────────────────────────────────── */
.site-footer {
  text-align: center;
  padding: 32px 16px;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 40px;
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  #consonantGrid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); gap: 8px; }
  .con-letter    { font-size: 1.8rem; }
  .detail-grid   { grid-template-columns: 1fr; }
  #detLetter     { font-size: 4rem; }
  .nav-link      { padding: 8px 8px; font-size: 0.65rem; }
}
