/* UI refresh · linux
   Linux 平台布局层：body.platform-linux。GNOME/Adwaita 风格 header bar、圆形标题按钮、Cantarell/Noto 字体回退。
   只使用 refresh/foundation.css 中的 --ds-* 设计令牌；不得修改其他文件负责的选择器。

   WebKitGTK 下系统字体因发行版而异，所以字体栈按 GNOME → 常见发行版 → 中文
   字体 → 兜底的顺序回退。窗口按钮按 Adwaita 习惯画成 24px 圆形浅灰按钮，
   关闭按钮不变红。 */

body.platform-linux {
  --font-sans: "Adwaita Sans", "Cantarell", "Inter", "Noto Sans", "Ubuntu", "Noto Sans CJK SC", "Source Han Sans SC", "WenQuanYi Micro Hei", "Droid Sans Fallback", "DejaVu Sans", "Liberation Sans", system-ui, sans-serif, "Noto Color Emoji";
  --ds-font-sans: var(--font-sans);
  /* Adwaita header bar 高度 46-47px。 */
  --ds-titlebar-h: 46px;
  --gtk-radius-button: 6px;
  --gtk-radius-card: 12px;
  --gtk-caption-size: 24px;
  /* Adwaita 焦点环：强调色 50% 透明度的 2px 环。 */
  --ds-focus-ring: 0 0 0 2px var(--ds-accent); /* 旧 WebKit 兜底，见下方 @supports */
  font-family: var(--font-sans);
}

@supports (color: color-mix(in srgb, red 50%, transparent)) {
  body.platform-linux {
    --ds-focus-ring: 0 0 0 2px color-mix(in srgb, var(--ds-accent) 50%, transparent);
  }
}

/* ---- Header bar 窗口按钮：圆形、浅灰底、居中排列 ------------------------ */
body.platform-linux.desktop-shell .window-controls {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 12px;
  margin-left: var(--ds-space-2);
  padding: 0 var(--ds-space-1);
}

body.platform-linux.desktop-shell .topbar .window-controls {
  padding-right: var(--ds-space-3);
}

body.platform-linux.desktop-shell .window-control {
  width: var(--gtk-caption-size);
  height: var(--gtk-caption-size);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: var(--ds-radius-full);
  background: color-mix(in srgb, var(--ds-text) 10%, transparent);
  color: var(--ds-text);
  cursor: default;
  box-shadow: none;
  transition: background-color var(--ds-motion-fast) var(--ds-ease);
}

/* 圆形按钮保持 24px 的 Adwaita 外观，伪元素向外扩 4px，点击范围 32×32
   （桌面点击区域下限，README 规则 4）。按钮间距 12px，扩展后仍各留 4px，
   相邻按钮的点击范围不重叠。 */
body.platform-linux.desktop-shell .window-control {
  position: relative;
}

body.platform-linux.desktop-shell .window-control::before {
  content: "";
  position: absolute;
  inset: calc((var(--gtk-caption-size) - var(--ds-control-sm)) / 2);
  border-radius: var(--ds-radius-full);
}

body.platform-linux.desktop-shell .window-control svg {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

body.platform-linux.desktop-shell .window-control:hover,
body.platform-linux.desktop-shell .window-control-close:hover {
  background: color-mix(in srgb, var(--ds-text) 15%, transparent);
  color: var(--ds-text);
}

body.platform-linux.desktop-shell .window-control:active,
body.platform-linux.desktop-shell .window-control-close:active {
  background: color-mix(in srgb, var(--ds-text) 30%, transparent);
}

body.platform-linux.desktop-shell .window-control:focus-visible {
  box-shadow: var(--ds-focus-ring);
}

/* ---- 标题与工具按钮：Adwaita 平铺按钮 ---------------------------------- */
body.platform-linux.desktop-shell .brand-title {
  font-size: var(--ds-text-body);
  font-weight: 700;
  letter-spacing: 0;
}

body.platform-linux.desktop-shell .theme-toggle,
body.platform-linux.desktop-shell .language-select {
  border-radius: var(--gtk-radius-button);
}

body.platform-linux.desktop-shell .view .panel-shell {
  border-radius: var(--gtk-radius-card);
}

/* 侧栏：AdwNavigationSplitView 风格，选中项为中性浅灰块。 */
body.platform-linux.desktop-shell .tabbar .nav-item {
  border-radius: var(--gtk-radius-button);
  cursor: default;
}

body.platform-linux.desktop-shell .tabbar .nav-item:hover:not(.active) {
  background: color-mix(in srgb, var(--ds-text) 7%, transparent);
}

body.platform-linux.desktop-shell .tabbar .nav-item:active {
  background: color-mix(in srgb, var(--ds-text) 16%, transparent);
}

body.platform-linux.desktop-shell .tabbar .nav-item.active {
  background: color-mix(in srgb, var(--ds-text) 10%, transparent);
  color: var(--ds-text);
}

/* ---- 控件：6px 圆角，悬停 7% / 按下 16% 前景色填充 --------------------- */
body.platform-linux :is(.accent-button, .ghost-button, .danger-button, .history-action) {
  border-radius: var(--gtk-radius-button);
}

body.platform-linux .ghost-button:hover:not(:disabled) {
  background: color-mix(in srgb, var(--ds-text) 7%, transparent);
}

body.platform-linux .ghost-button:active:not(:disabled) {
  background: color-mix(in srgb, var(--ds-text) 16%, transparent);
}

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

body.platform-linux :is(.text-input, .text-area, select.text-input, .path-display) {
  border-radius: var(--gtk-radius-button);
}

body.platform-linux :is(.text-input, .text-area, select.text-input):focus {
  border-color: var(--ds-accent);
  box-shadow: var(--ds-focus-ring);
}

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

/* ---- 滚动条：Adwaita 悬浮滚动条，静止时细，悬停时变粗 ------------------ */
body.platform-linux * {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--ds-text) 35%, transparent) transparent;
}

body.platform-linux ::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}

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

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

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

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