/*
 * 祥和龙三主题契约
 *
 * 此文件必须在各静态模块自己的样式表之后载入。它只统一页面背景、
 * 中性表面、边框和主交互色；职业色、装备品质、伤害/治疗、证据等级等
 * 具有业务含义的颜色仍由模块保留。
 */

:root[data-theme="harmony"] body[data-module] {
  --theme-bg: #0b100f;
  --theme-surface: #141a18;
  --theme-surface-2: #1b2421;
  --theme-surface-3: #101513;
  --theme-line: #2e3935;
  --theme-line-strong: #405048;
  --theme-text: #f1efe8;
  --theme-muted: #9ca9a3;
  --theme-primary: #4bc7a1;
  --theme-primary-strong: #287a63;
  --theme-secondary: #e0b85c;
}

:root[data-theme="horde"] body[data-module] {
  --theme-bg: #100a0a;
  --theme-surface: #1a1111;
  --theme-surface-2: #241817;
  --theme-surface-3: #140d0d;
  --theme-line: #3c2928;
  --theme-line-strong: #59403d;
  --theme-text: #eee5d8;
  --theme-muted: #b7a69d;
  --theme-primary: #d45b50;
  --theme-primary-strong: #8d352f;
  --theme-secondary: #b98955;
}

:root[data-theme="alliance"] body[data-module] {
  --theme-bg: #08101e;
  --theme-surface: #101b2e;
  --theme-surface-2: #16233a;
  --theme-surface-3: #0c1626;
  --theme-line: #293b58;
  --theme-line-strong: #3b547a;
  --theme-text: #e8edf5;
  --theme-muted: #aab8ca;
  --theme-primary: #638cde;
  --theme-primary-strong: #365ca5;
  --theme-secondary: #d2ad56;
}

:root[data-theme] body[data-module] {
  --bg: var(--theme-bg);
  --panel: var(--theme-surface);
  --panel-2: var(--theme-surface-2);
  --panel-3: var(--theme-surface-3);
  --surface: var(--theme-surface);
  --surface-1: var(--theme-surface);
  --surface-2: var(--theme-surface-2);
  --surface-3: var(--theme-surface-3);
  --line: var(--theme-line);
  --line-strong: var(--theme-line-strong);
  --text: var(--theme-text);
  --muted: var(--theme-muted);
  --dim: color-mix(in srgb, var(--theme-muted) 72%, var(--theme-bg));
  --jade: var(--theme-primary);
  --jade-dark: var(--theme-primary-strong);
  --jade-soft: color-mix(in srgb, var(--theme-primary) 14%, transparent);
  --gold: var(--theme-secondary);
  --gold-light: color-mix(in srgb, var(--theme-secondary) 76%, white);
  color: var(--theme-text);
  background: var(--theme-bg);
}

:root[data-theme] body[data-module] .app-header {
  border-color: var(--theme-line);
  background-color: color-mix(in srgb, var(--theme-bg) 96%, transparent);
}

.module-data-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
}

:root[data-theme] body[data-module] :is(input, select, textarea, option) {
  color-scheme: dark;
}

/* 配装：沿用模块的语义变量，只把中性画布和交互主色接入全站主题。 */
:root[data-theme] body[data-module="gear-planner"] {
  --background: var(--theme-bg);
  --surface: var(--theme-surface);
  --surface-raised: var(--theme-surface-2);
  --surface-soft: var(--theme-surface-3);
  --border: var(--theme-line);
  --border-strong: var(--theme-line-strong);
  --text: var(--theme-text);
  --muted: var(--theme-muted);
  --muted-strong: color-mix(in srgb, var(--theme-muted) 72%, white);
  --jade: var(--theme-primary);
  --jade-bright: color-mix(in srgb, var(--theme-primary) 78%, white);
  --jade-soft: color-mix(in srgb, var(--theme-primary) 14%, transparent);
}

/* 掉落与特效装备库：统一主画布和中性卡片，保留来源/品质/机制语义色。 */
:root[data-theme] body[data-module="loot-catalog"] :is(
  .site-header,
  .hero-panel,
  .dataset-summary,
  .filter-panel,
  .results-panel,
  .results-heading,
  .trinket-card,
  .card-open,
  .detail-dialog,
  .detail-side,
  .tooltip-block,
  .history-event,
  .history-event li,
  .history-empty,
  .raw-description,
  .card-stats,
  .check-grid label,
  .tag
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface);
}

:root[data-theme] body[data-module="loot-catalog"] .hero-panel {
  background-image:
    radial-gradient(circle at 92% 8%, color-mix(in srgb, var(--theme-primary) 18%, transparent), transparent 36%),
    linear-gradient(135deg, var(--theme-surface-2), var(--theme-surface) 58%, var(--theme-surface-2));
}

:root[data-theme] body[data-module="loot-catalog"] :is(
  .search-field input,
  .select-field select,
  .sort-field select,
  .detail-controls select,
  .dialog-close
) {
  border-color: var(--theme-line);
  color: var(--theme-text);
  background: var(--theme-surface-3);
}

:root[data-theme] body[data-module="loot-catalog"] :is(.results-heading, .detail-hero) {
  background-color: var(--theme-surface-2);
}

:root[data-theme] body[data-module="loot-catalog"] :is(.card-open:hover, .trinket-card .card-open:hover) {
  background-color: color-mix(in srgb, var(--theme-primary) 8%, var(--theme-surface-2));
}

:root[data-theme] body[data-module="loot-catalog"] :is(
  .filter-tag.is-active,
  .check-grid label:has(input:checked)
) {
  border-color: color-mix(in srgb, var(--theme-primary) 62%, var(--theme-line));
  color: color-mix(in srgb, var(--theme-primary) 60%, white);
  background: color-mix(in srgb, var(--theme-primary) 14%, var(--theme-surface));
}

/* 专精资料库：主题只接管资料库框架，职业和专精色继续表达业务含义。 */
:root[data-theme] body[data-module="game-database"] :is(
  .site-header,
  .specialization-picker,
  .specialization-picker-panel,
  .specialization-class-list,
  .specialization-list,
  .tree-panel,
  .healing-results,
  .simulation-workspace,
  .mechanics-dialog,
  .comparison-workspace,
  .comparison-column,
  .cross-build-section,
  .global-relation-panel,
  .skill-card,
  .global-result-row
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface);
}

:root[data-theme] body[data-module="game-database"] :is(
  .specialization-class-option,
  .specialization-option,
  .result-mode-control button,
  .result-mastery-control select,
  .catalog-filters,
  .search-field,
  .global-result-actions,
  .cross-build-controls button
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface-3);
}

:root[data-theme] body[data-module="game-database"] :is(
  .specialization-class-option:hover,
  .specialization-option:hover,
  .result-mode-control button:hover,
  .global-result-row:hover,
  .cross-build-controls button:hover
) {
  background-color: color-mix(in srgb, var(--theme-primary) 8%, var(--theme-surface-2));
}

/* 大秘境资料库：将旧的固定翡翠色框架映射到当前主题主色。 */
:root[data-theme] body[data-module^="mythic-plus"] {
  --library-gold: var(--theme-secondary);
  --library-jade: var(--theme-primary);
  --library-panel: var(--theme-surface);
  --library-panel-2: var(--theme-surface-2);
  --library-panel-3: color-mix(in srgb, var(--theme-primary) 7%, var(--theme-surface-2));
  --library-line: var(--theme-line);
  --library-soft: var(--theme-muted);
  --mp-e3: var(--theme-primary);
  --mp-e2: var(--theme-secondary);
}

:root[data-theme] body[data-module^="mythic-plus"] :is(
  .mythic-plus-page,
  .library-main,
  .library-toolbar,
  .library-workspace,
  .dungeon-rail,
  .monster-browser,
  .monster-detail,
  .browser-filters,
  .sheet-heading,
  .sheet-metrics > dl div,
  .skill-card,
  .property-grid div,
  .method-panel,
  .catalog-search-results,
  .map-panel,
  .map-sidebar
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface);
}

:root[data-theme] body[data-module^="mythic-plus"] .library-hero {
  border-color: var(--theme-line);
  background-image:
    radial-gradient(circle at 82% 30%, color-mix(in srgb, var(--theme-primary) 13%, transparent), transparent 32%),
    linear-gradient(135deg, var(--theme-surface), var(--theme-bg) 68%);
}

:root[data-theme] body[data-module^="mythic-plus"] .sheet-heading {
  background-image: linear-gradient(105deg, var(--theme-surface-2), var(--theme-surface-3));
}

:root[data-theme] body[data-module^="mythic-plus"] :is(
  .dungeon-utility-requirements,
  .sheet-force,
  .health-card
) {
  background-image: linear-gradient(90deg, color-mix(in srgb, var(--theme-primary) 7%, transparent), transparent);
}

:root[data-theme] body[data-module^="mythic-plus"] :is(
  .library-summary,
  .catalog-search-field,
  .channel-switch button,
  .level-control input[type="number"],
  .level-presets,
  .level-presets button,
  .method-button,
  .search-field,
  .segmented button,
  .effect-filter button,
  .monster-item,
  .dungeon-item,
  .dungeon-list-icon,
  .dungeon-header-icon-art,
  .sheet-icon,
  .health-card,
  .sheet-force,
  .sheet-footnote,
  .skill-models .model-line
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface-3);
}

:root[data-theme] body[data-module^="mythic-plus"] :is(
  .channel-switch button.is-active,
  .level-presets button:hover,
  .level-presets button.is-active,
  .segmented button.is-active,
  .effect-filter button.is-active,
  .monster-item.is-active,
  .dungeon-item.is-active
) {
  border-color: color-mix(in srgb, var(--theme-primary) 58%, var(--theme-line));
  color: var(--theme-text);
  background-color: color-mix(in srgb, var(--theme-primary) 14%, var(--theme-surface));
}

/* 时间轴：统一工作台中性底色，事件类型和玩家/技能配色不受影响。 */
:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) :is(
  .site-header,
  .panel,
  .panel-heading,
  .timeline-controls,
  .stage-jumps,
  .timeline-viewport,
  .timeline-ruler,
  .ruler-label,
  .lane-label,
  .timeline-hint,
  .selected-event-card,
  .response-card,
  .response-card header,
  .round-card,
  .filter-block,
  .filter-detail,
  .detail-panel,
  .ability-group,
  .sequence-table th
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface);
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) .analysis-import-panel {
  border-color: var(--theme-line);
  background-image:
    radial-gradient(circle at 8% 0, color-mix(in srgb, var(--theme-primary) 13%, transparent), transparent 38%),
    linear-gradient(140deg, var(--theme-surface-2), var(--theme-surface) 68%);
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) :is(
  .analysis-pipeline,
  .sample-library-panel,
  .sample-log-card,
  .analysis-result-summary > div,
  .analysis-result-summary > p
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface-3);
  background-image: none;
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) :is(
  .wcl-import-control input,
  .sample-library-controls select,
  .sample-library-controls input
) {
  border-color: var(--theme-line);
  color: var(--theme-text);
  background: var(--theme-surface-3);
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) .primary-action {
  border-color: var(--theme-primary);
  color: color-mix(in srgb, var(--theme-bg) 88%, black);
  background: var(--theme-primary);
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) .primary-action:hover {
  background: color-mix(in srgb, var(--theme-primary) 82%, white);
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) :is(
  .switch-control,
  .zoom-control,
  .stage-button,
  .select-control select,
  .quiet-button,
  .round-mechanic,
  .response-entry,
  .status-pill
) {
  border-color: var(--theme-line);
  background-color: var(--theme-surface-3);
}

:root[data-theme] body:is([data-module="boss-timeline"], [data-module="timeline-v1"]) :is(
  .response-entry:hover,
  .round-card:hover,
  .sequence-table tbody tr:hover
) {
  background-color: color-mix(in srgb, var(--theme-primary) 8%, var(--theme-surface-2));
}

@media (prefers-reduced-motion: reduce) {
  :root[data-theme] body[data-module] * {
    scroll-behavior: auto !important;
  }
}
