/* ============================================================
   暗色模式（跟随浏览器 prefers-color-scheme）
   - 本文件在 global.tail.css 之后加载：Tailwind 会把 hover:/focus:/group-hover:
     等变体工具类排在所有普通工具类之后，若暗色覆盖写进 assist.css，
     浅色 hover 规则会反过来覆盖它（表现为悬停处闪白底）。
   - 取值与 index.css 的暗色语义令牌一致；Canvas / 3Dmol / Chart.js 由
     theme.js 与 cif-colors.js 取同一套配色，避免跨渲染层漂移。
   ============================================================ */
@media (prefers-color-scheme: dark) {
    /* 加载层：遮罩压到近黑，脉冲条与文字提亮，避免低透明度下糊成一片 */
    .global-loading-overlay { background: rgba(0,0,0,0.86); }
    .loading-indicator__bar { background: #60a5fa; }
    .loading-indicator__text { color: #a3a3a3; }

    /* 模态 / 抽屉遮罩：原 30% 黑在纯黑页面上几乎无分层感，统一加深并去掉蓝灰底 */
    .bg-black\/30 { background-color: rgba(0,0,0,0.68); }
    .bg-slate-900\/50 { background-color: rgba(0,0,0,0.72); }

    /* 文本选中高亮 */
    ::selection { background: rgba(96,165,250,0.35); color: #f5f5f5; }

    /* 元素周期表选择器 */
    .ptable-f-label, .ptable-z, .ptable-legend-item { color: #a3a3a3; }
    .ptable-cell { background: #0d0d0d; color: #f5f5f5; border-color: #262626; }
    .ptable-cell:hover { background: rgba(96,165,250,0.24); border-color: #60a5fa; }
    .ptable-cell.is-placeholder { border-color: #3f3f3f; color: #737373; }
    .ptable-zh { color: #a3a3a3; }
    .ptable-cell[data-cat="alkali"]      { background: #7f1d1d; color: #fecaca; }
    .ptable-cell[data-cat="alkaline"]    { background: #7c2d12; color: #fed7aa; }
    .ptable-cell[data-cat="transition"]  { background: #0c4a6e; color: #bae6fd; }
    .ptable-cell[data-cat="post"]        { background: #134e4a; color: #99f6e4; }
    .ptable-cell[data-cat="metalloid"]   { background: #3f6212; color: #d9f99d; }
    .ptable-cell[data-cat="nonmetal"]    { background: #14532d; color: #bbf7d0; }
    .ptable-cell[data-cat="halogen"]     { background: #581c87; color: #e9d5ff; }
    .ptable-cell[data-cat="noble"]       { background: #312e81; color: #c7d2fe; }
    .ptable-cell[data-cat="lanthanide"]  { background: #831843; color: #fecdd3; }
    .ptable-cell[data-cat="actinide"]    { background: #701a75; color: #f5d0fe; }
    .ptable-cell.is-selected { background: #2563eb; border-color: #93c5fd; color: #fff; }
    .ptable-cell.is-selected .ptable-z { color: #bfdbfe; }
    .ptable-cell.is-selected .ptable-zh { color: #dbeafe; }
    .ptable-swatch { background: #0d0d0d; border-color: #262626; }
    .ptable-swatch[data-cat="alkali"]      { background: #7f1d1d; }
    .ptable-swatch[data-cat="alkaline"]    { background: #7c2d12; }
    .ptable-swatch[data-cat="transition"]  { background: #0c4a6e; }
    .ptable-swatch[data-cat="post"]        { background: #134e4a; }
    .ptable-swatch[data-cat="metalloid"]   { background: #3f6212; }
    .ptable-swatch[data-cat="nonmetal"]    { background: #14532d; }
    .ptable-swatch[data-cat="halogen"]     { background: #581c87; }
    .ptable-swatch[data-cat="noble"]       { background: #312e81; }
    .ptable-swatch[data-cat="lanthanide"]  { background: #831843; }
    .ptable-swatch[data-cat="actinide"]    { background: #701a75; }

    /* 中性面：纯黑页面 + 中性灰层级；模态遮罩 bg-slate-900/50 保持原样 */
    .bg-white { background-color: #050505; }
    .hover\:bg-white:hover { background-color: #111111; }
    .bg-surface-50 { background-color: #000000; }
    .bg-surface-100 { background-color: #111111; }
    .bg-surface-200 { background-color: #262626; }
    .bg-surface-300 { background-color: #3f3f3f; }
    .hover\:bg-surface-50:hover { background-color: #111111; }
    .hover\:bg-surface-100:hover { background-color: #262626; }
    .hover\:bg-surface-200:hover { background-color: #3f3f3f; }
    .bg-slate-100 { background-color: #111111; }
    .bg-slate-400 { background-color: #737373; }

    /* 分隔线 */
    .border-surface-100 { border-color: #1a1a1a; }
    .border-surface-200 { border-color: #262626; }
    .border-surface-300 { border-color: #3f3f3f; }
    .border-slate-100 { border-color: #1a1a1a; }
    .border-slate-200 { border-color: #262626; }
    .divide-surface-100 > :not([hidden]) ~ :not([hidden]) { border-color: #262626; }

    /* 正文/次要文字：纯中性灰阶，保持 900→300 由亮到暗的层级 */
    .text-slate-900 { color: #f5f5f5; }
    .text-slate-800 { color: #e5e5e5; }
    .text-slate-700 { color: #d4d4d4; }
    .text-slate-600 { color: #b8b8b8; }
    .text-slate-500 { color: #a3a3a3; }
    .text-slate-400 { color: #8a8a8a; }
    .text-slate-300 { color: #737373; }
    .hover\:text-slate-700:hover { color: #f5f5f5; }
    .placeholder-slate-400::placeholder { color: #8a8a8a; }

    /* 强调色与高亮态：纯黑底上把半透明蓝底/描边/焦点环整体加浓，避免「悬停了看不出来」。 */
    .text-primary { color: #60a5fa; }
    .hover\:text-primary:hover { color: #93c5fd; }
    .group:hover .group-hover\:text-primary { color: #93c5fd; }
    .text-primary\/60 { color: rgba(96,165,250,0.75); }
    .text-primary\/70 { color: rgba(96,165,250,0.85); }
    .hover\:text-primary-dark:hover { color: #93c5fd; }
    .text-accent { color: #22d3ee; }
    .hover\:text-accent:hover { color: #67e8f9; }
    .hover\:border-primary:hover { border-color: #60a5fa; }
    .focus\:border-primary:focus { border-color: #60a5fa; }
    .hover\:border-accent:hover { border-color: #22d3ee; }
    .bg-primary\/5 { background-color: rgba(59,130,246,0.10); }
    .bg-primary\/10 { background-color: rgba(59,130,246,0.18); }
    .hover\:bg-primary\/5:hover { background-color: rgba(59,130,246,0.18); }
    .focus-visible\:bg-primary\/5:focus-visible { background-color: rgba(59,130,246,0.18); }
    .hover\:bg-primary\/20:hover { background-color: rgba(59,130,246,0.30); }
    .border-primary\/20 { border-color: rgba(96,165,250,0.35); }
    .border-primary\/30 { border-color: rgba(96,165,250,0.50); }
    .focus-visible\:ring-primary\/30:focus-visible { --tw-ring-color: rgba(96,165,250,0.65); }

    /* 机构 Logo：外部 SVG 以 <img> 加载，父页 CSS 进不去 SVG 内部；
       invert + hue-rotate 在提亮深色墨迹（#0f172a / currentColor / #000）的同时保留原色相。 */
    img[src*="/assist/image/"][src$=".svg"] { filter: invert(1) hue-rotate(180deg); }

    /* 状态色：纯黑底上底色改半透明着色，文字/边框提亮 */
    .bg-emerald-50 { background-color: rgba(16,185,129,0.16); }
    .bg-emerald-100 { background-color: rgba(16,185,129,0.24); }
    .border-emerald-200 { border-color: rgba(52,211,153,0.50); }
    .text-emerald-500, .text-emerald-600 { color: #34d399; }
    .text-emerald-700 { color: #6ee7b7; }
    .hover\:text-emerald-500:hover { color: #6ee7b7; }
    .bg-amber-50 { background-color: rgba(245,158,11,0.16); }
    .bg-amber-50\/60 { background-color: rgba(245,158,11,0.10); }
    .border-amber-300 { border-color: rgba(251,191,36,0.50); }
    .text-amber-400, .text-amber-500, .text-amber-600 { color: #fbbf24; }
    .text-amber-600\/90 { color: rgba(251,191,36,0.9); }
    .text-amber-700 { color: #fcd34d; }
    .text-amber-800 { color: #fde68a; }
    .bg-red-50 { background-color: rgba(239,68,68,0.16); }
    .border-red-300 { border-color: rgba(248,113,113,0.50); }
    .text-red-600, .text-red-700 { color: #f87171; }
    .text-red-800 { color: #fca5a5; }
    .hover\:text-red-500:hover { color: #f87171; }
    .bg-yellow-50 { background-color: rgba(234,179,8,0.12); }
    .border-yellow-200 { border-color: rgba(250,204,21,0.4); }
    .text-yellow-600 { color: #facc15; }
    .text-blue-500 { color: #60a5fa; }
    .text-indigo-500 { color: #a5b4fc; }
    .text-rose-500 { color: #fb7185; }
}
