/* ═══════════════════════════════════════════════════════════════
   HSPIM v2.4 — Хүртээмжийн модуль
   Харанхуй горим · Үсгийн хэмжээ · Дуут унших (Yesui) · Дуут удирдлага · Чатбот
   ═══════════════════════════════════════════════════════════════ */

/* ── Үсгийн хэмжээ (--acc-font: 100–140%) ── */
html { font-size: var(--acc-font, 100%); }

/* ── Харанхуй горим ── */
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="dark"] body {
  --navy: #0B0E22;
  --navy-2: #12173F;
  --brand: #6D7CFF;
  --blue: #7D93FF;
  --blue-dark: #A9B7FF;
  --sky: #171D46;
  --ink: #E8EAF6;
  --muted: #A6ACC9;
  --line: #2A2F55;
  --bg: #0B0E1A;
  --bg-soft: #10142A;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.5);
  --shadow-md: 0 8px 30px rgba(0,0,0,.55);
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  background: var(--bg);
  color: var(--ink);
}
html[data-theme="dark"] img { filter: brightness(.88); }
html[data-theme="dark"] .card,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea,
html[data-theme="dark"] select { background: var(--bg-soft); color: var(--ink); border-color: var(--line); }

/* ── Skip link (гарын хэрэглэгчдэд) ── */
.acc-skip {
  position: absolute; left: -9999px; top: 0; z-index: 100000;
  background: var(--brand); color: #fff; padding: 10px 18px; border-radius: 0 0 10px 0;
  font-weight: 600; text-decoration: none;
}
.acc-skip:focus { left: 0; }

/* ── Хүртээмжийн самбар ── */
#acc-toolbar { position: fixed; right: 16px; bottom: 96px; z-index: 99990;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
#acc-toolbar .acc-fab {
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--brand, #10069F); color: #fff; font-size: 22px; line-height: 1;
  box-shadow: 0 4px 14px rgba(13,18,64,.35);
}
#acc-panel {
  display: none; background: var(--bg, #fff); color: var(--ink, #14162E);
  border: 1px solid var(--line, #E4E6EF); border-radius: 14px; padding: 14px;
  width: 258px; box-shadow: var(--shadow-lg, 0 10px 30px rgba(13,18,64,.25));
  font-size: 13px;
}
#acc-panel.open { display: block; }
#acc-panel h3 { font-size: 13px; margin: 0 0 10px; }
#acc-panel .row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
#acc-panel .row > button {
  flex: 1; min-width: 62px; padding: 8px 6px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line, #E4E6EF); background: transparent; color: inherit; font-size: 12.5px;
}
#acc-panel .row > button[aria-pressed="true"] { background: var(--brand, #10069F); color: #fff; border-color: transparent; }
#acc-panel .hint { font-size: 11px; color: var(--muted, #5A5F73); margin-top: 4px; line-height: 1.5; }

/* Дэлгэц уншигчид зориулсан амьд бүс */
.acc-sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Уншиж буй хэсгийн тодруулга */
.acc-reading { outline: 3px solid #F5A623 !important; outline-offset: 3px; border-radius: 4px; }

/* «Сонсох» товч (мэдээний хуудас) */
.acc-listen-btn {
  display: inline-flex; align-items: center; gap: 8px; margin: 10px 0;
  padding: 9px 16px; border-radius: 999px; border: 1.5px solid var(--brand, #10069F);
  background: transparent; color: var(--brand, #10069F); cursor: pointer;
  font: 600 14px/1 var(--font-body, sans-serif);
}
.acc-listen-btn.playing { background: var(--brand, #10069F); color: #fff; }

/* Дуут удирдлагын төлөв */
#acc-voice-status {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 99995; display: none; align-items: center; gap: 10px;
  background: var(--navy, #0D1240); color: #fff; border-radius: 999px;
  padding: 10px 20px; font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
#acc-voice-status.on { display: inline-flex; }
#acc-voice-status .dot { width: 10px; height: 10px; border-radius: 50%; background: #ff5252; animation: accblink 1s infinite; }
@keyframes accblink { 50% { opacity: .25; } }

/* ── Чатбот ── */
#hspim-chat-fab {
  position: fixed; right: 16px; bottom: 24px; z-index: 99991;
  width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--navy, #0D1240); color: #fff; font-size: 24px;
  box-shadow: 0 4px 16px rgba(13,18,64,.4);
}
#hspim-chat {
  position: fixed; right: 16px; bottom: 24px; z-index: 99992;
  width: min(370px, calc(100vw - 24px)); height: min(540px, calc(100vh - 90px));
  display: none; flex-direction: column; border-radius: 16px; overflow: hidden;
  background: var(--bg, #fff); color: var(--ink, #14162E);
  border: 1px solid var(--line, #E4E6EF);
  box-shadow: 0 16px 48px rgba(13,18,64,.35); font-size: 14px;
}
#hspim-chat.open { display: flex; }
#hspim-chat .hc-head { background: var(--navy, #0D1240); color: #fff; padding: 12px 14px; display: flex; align-items: center; gap: 10px; }
#hspim-chat .hc-head strong { font-size: 14px; display: block; }
#hspim-chat .hc-head small { font-size: 11px; opacity: .75; }
#hspim-chat .hc-head button { margin-left: auto; background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; }
#hspim-chat .hc-body { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: var(--bg-soft, #F6F7FB); }
.hc-msg { max-width: 86%; padding: 9px 12px; border-radius: 14px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: break-word; }
.hc-msg.bot  { background: var(--bg, #fff); border: 1px solid var(--line, #E4E6EF); border-bottom-left-radius: 4px; align-self: flex-start; }
.hc-msg.user { background: var(--brand, #10069F); color: #fff; border-bottom-right-radius: 4px; align-self: flex-end; }
.hc-msg.bot a { color: var(--brand, #10069F); font-weight: 600; }
.hc-chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; }
.hc-chips button {
  border: 1px solid var(--brand, #10069F); color: var(--brand, #10069F);
  background: var(--bg, #fff); border-radius: 999px; padding: 6px 11px; font-size: 12px; cursor: pointer;
}
#hspim-chat .hc-foot { display: flex; gap: 6px; padding: 10px; border-top: 1px solid var(--line, #E4E6EF); background: var(--bg, #fff); }
#hspim-chat .hc-foot input {
  flex: 1; border: 1px solid var(--line, #E4E6EF); border-radius: 999px; padding: 9px 14px;
  font-size: 14px; background: transparent; color: inherit; min-width: 0;
}
#hspim-chat .hc-foot button {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--brand, #10069F); color: #fff; font-size: 16px;
}
#hspim-chat .hc-foot .hc-mic.listening { background: #c62828; animation: accblink 1s infinite; }

/* Focus ил харагдац */
#acc-toolbar button:focus-visible, #hspim-chat button:focus-visible,
.acc-listen-btn:focus-visible { outline: 3px solid var(--gold, #F5A623); outline-offset: 2px; }

@media (max-width: 480px) { #acc-toolbar { bottom: 92px; } }
@media (prefers-reduced-motion: reduce) {
  #acc-voice-status .dot, #hspim-chat .hc-foot .hc-mic.listening { animation: none; }
}

/* ── Харанхуй горим: нэмэлт тааруулга ── */
html[data-theme="dark"] .hero-card,
html[data-theme="dark"] .sv-card,
html[data-theme="dark"] .news-card,
html[data-theme="dark"] .project-card,
html[data-theme="dark"] .widget,
html[data-theme="dark"] .search-overlay .panel {
  background: var(--bg-soft) !important; color: var(--ink) !important; border-color: var(--line) !important;
}
html[data-theme="dark"] .hero-card .lbl { color: var(--muted); }
