/* UI refresh · windows
   Windows 平台布局层：body.platform-windows。Fluent 标题栏/标题按钮(46×32)、Mica 风格、Segoe UI Variable。
   只使用 refresh/foundation.css 中的 --ds-* 设计令牌；不得修改其他文件负责的选择器。

   Tauri 桌面窗口 decorations=false：最小化 / 最大化 / 关闭按钮由页面绘制，按
   Windows 11 习惯贴在窗口右上角，46×32、无圆角、无边框；关闭按钮悬停使用
   系统红 #c42b1c（README 允许的平台规定色）。 */

body.platform-windows {
  --font-sans: "Segoe UI Variable Text", "Segoe UI Variable", "Segoe UI", "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif;
  --ds-font-sans: var(--font-sans);
  /* Fluent 控件圆角 4px，浮层 8px。 */
  --win-radius-control: 4px;
  --win-radius-overlay: 8px;
  --win-caption-w: 46px;
  --win-caption-h: 32px;
  /* Fluent 焦点框：内 1px 底色描边 + 外 2px 前景色描边。 */
  --ds-focus-ring: 0 0 0 1px var(--ds-bg), 0 0 0 3px var(--ds-text);
  font-family: var(--font-sans);
}

/* ---- 标题按钮：贴右上角，46×32，与 Win32/WinUI 标准标题栏一致 ---------- */
body.platform-windows.desktop-shell .topbar .window-controls {
  align-self: flex-start;
  height: var(--win-caption-h);
  margin-left: var(--ds-space-2);
}

body.platform-windows.desktop-shell .window-controls {
  display: inline-flex;
  align-items: stretch;
  gap: 0;
}

body.platform-windows.desktop-shell .window-control {
  width: var(--win-caption-w);
  height: var(--win-caption-h);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--ds-text);
  cursor: default;
  box-shadow: none;
  transition: background-color var(--ds-motion-fast) linear, color var(--ds-motion-fast) linear;
}

/* Segoe Fluent Icons 风格：约 10px 的细符号。 */
body.platform-windows.desktop-shell .window-control svg {
  width: 12px;
  height: 12px;
  fill: currentColor;
}

body.platform-windows.desktop-shell .window-control:hover {
  background: var(--ds-state-hover);
  color: var(--ds-text);
}

body.platform-windows.desktop-shell .window-control:active {
  background: var(--ds-state-press);
  color: var(--ds-text-muted);
}

body.platform-windows.desktop-shell .window-control-close:hover {
  background: #c42b1c;
  color: #fff;
}

body.platform-windows.desktop-shell .window-control-close:active {
  background: color-mix(in srgb, #c42b1c 90%, transparent);
  color: rgba(255, 255, 255, 0.7);
}

body.platform-windows.desktop-shell .window-control:focus-visible {
  box-shadow: inset 0 0 0 2px var(--ds-text);
}

/* 阅读器标题栏的按钮同样贴右上角。 */
body.platform-windows.desktop-shell .reader-window-controls {
  align-self: start;
  margin-top: calc(-9px - var(--safe-area-top));
  margin-right: calc(-12px - var(--safe-area-right));
}

/* ---- 标题栏与侧栏：Mica 观感（透出底色，层次靠细微填充区分） ---------- */
body.platform-windows.desktop-shell .brand-title {
  font-size: var(--ds-text-caption);
  font-weight: 400;
  letter-spacing: 0;
}

body.platform-windows.desktop-shell .theme-toggle,
body.platform-windows.desktop-shell .language-select {
  border-radius: var(--win-radius-control);
}

body.platform-windows.desktop-shell .view .panel-shell {
  border-radius: var(--win-radius-overlay);
}

/* NavigationView：选中项左侧 3×16 强调色指示条 + 浅填充。 */
body.platform-windows.desktop-shell .tabbar .nav-item {
  position: relative;
  border-radius: var(--win-radius-control);
  cursor: default;
}

body.platform-windows.desktop-shell .tabbar .nav-item:hover:not(.active) {
  background: var(--ds-state-hover);
}

body.platform-windows.desktop-shell .tabbar .nav-item:active {
  background: var(--ds-state-press);
}

body.platform-windows.desktop-shell .tabbar .nav-item.active {
  background: var(--ds-state-hover);
  color: var(--ds-text);
}

body.platform-windows.desktop-shell .tabbar .nav-item.active::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  width: 3px;
  height: 16px;
  border-radius: var(--ds-radius-full);
  background: var(--ds-accent);
  transform: translateY(-50%);
}

/* ---- 控件：Fluent 4px 圆角，按下略淡而非缩放 --------------------------- */
body.platform-windows :is(.accent-button, .ghost-button, .danger-button, .history-action) {
  border-radius: var(--win-radius-control);
}

body.platform-windows .ghost-button:hover:not(:disabled) {
  background: var(--ds-state-hover);
}

body.platform-windows :is(.accent-button, .ghost-button, .danger-button, .history-action):active:not(:disabled) {
  opacity: 0.82;
  transform: none;
}

body.platform-windows :is(.text-input, .text-area, select.text-input, .path-display) {
  border-radius: var(--win-radius-control);
}

/* Fluent 文本框：聚焦时底边 2px 强调色，而不是整圈描边。 */
body.platform-windows :is(.text-input, .text-area, select.text-input):focus {
  border-color: var(--ds-border);
  box-shadow: inset 0 -2px 0 var(--ds-accent);
}

body.platform-windows :is(button, select, input, textarea, [role="button"], a):focus-visible {
  outline: none;
  box-shadow: var(--ds-focus-ring);
}

/* ---- 滚动条：Windows 11 细条，悬停时加粗 ------------------------------ */
body.platform-windows * {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ds-text) 42%, transparent) transparent;
}

body.platform-windows ::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

body.platform-windows ::-webkit-scrollbar-thumb {
  min-height: 32px;
  border: 4px solid transparent;
  border-radius: var(--ds-radius-full);
  background: color-mix(in srgb, var(--ds-text) 38%, transparent) padding-box;
}

body.platform-windows ::-webkit-scrollbar-thumb:hover,
body.platform-windows ::-webkit-scrollbar-thumb:active {
  border-width: 3px;
  background-color: color-mix(in srgb, var(--ds-text) 56%, transparent);
}

body.platform-windows ::-webkit-scrollbar-track:hover {
  background: color-mix(in srgb, var(--ds-text) 4%, transparent);
}

body.platform-windows ::-webkit-scrollbar-track,
body.platform-windows ::-webkit-scrollbar-corner {
  background: transparent;
}
