/* ==========================================================================
   Melo 游戏商店 · base.css
   设计令牌 / 排版 / 主题 / 无障碍工具
   普惠原则：不依赖颜色传达信息、最小字号 14px、全程键盘可达、
   动效可关、对比度可加、字号可放大到 130%。
   ========================================================================== */

:root {
  /* 品牌与语义色（浅色）· Switch 风格：正红主色 + 高饱和辅助色 */
  --brand: #e60012;
  --brand-strong: #b5000e;
  --brand-soft: #ffe6e9;
  --coral: #ff5c00;
  --coral-soft: #fff0e6;
  --ok: #00b26f;
  --ok-soft: #d9fbee;
  --warn: #ffb400;
  --danger: #ff2d3f;

  /* 强调渐变 */
  --grad-brand: linear-gradient(135deg, #ff3b4d 0%, #d40019 100%);
  --grad-free: linear-gradient(135deg, #19d996 0%, #00a86b 100%);
  --grad-sale: linear-gradient(135deg, #ff9d00 0%, #ff3d00 100%);
  --grad-hero: radial-gradient(130% 150% at 0% 45%, #ffc9d1 0%, rgba(255, 255, 255, 0) 62%);

  /* 中性色（浅色） */
  --bg: #f7f9ff;
  --bg-elev: #ffffff;
  --bg-sunken: #eaf0fa;
  --bg-glass: rgba(255, 255, 255, .82);
  --text: #131c26;
  --text-2: #4f6076;
  --text-3: #7d8da1;
  --line: #dee6f0;
  --line-strong: #c6d3e2;

  /* 形状与阴影 */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 28px;
  --r-pill: 999px;
  --shadow-1: 0 1px 2px rgba(16, 32, 56, .05), 0 6px 18px rgba(16, 32, 56, .06);
  --shadow-2: 0 2px 6px rgba(16, 32, 56, .08), 0 18px 48px rgba(16, 32, 56, .14);
  --shadow-focus: 0 0 0 3px var(--bg), 0 0 0 6px var(--brand);

  /* 排版 */
  --font-sans: "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", "Noto Sans SC",
               system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", "Cascadia Mono", Consolas, "Roboto Mono", monospace;

  /* 布局 */
  --rail-w: 88px;
  --topbar-h: 68px;
  --page-max: 1480px;
  --gutter: clamp(16px, 2.4vw, 36px);
  --card-w: 248px;
  --shelf-gap: 18px;

  --ease: cubic-bezier(.22, .61, .36, 1);
  --dur: 220ms;

  --fs-scale: 1;
}

/* ---- 深色主题 ---- */
html[data-theme="dark"] {
  --brand: #ff4d5c;
  --brand-strong: #ff7a86;
  --brand-soft: #3a1218;
  --coral: #ff8a3d;
  --coral-soft: #3a1f12;
  --ok: #2ee6a8;
  --ok-soft: #0f2a22;
  --warn: #ffc73d;
  --danger: #ff5b66;

  --grad-brand: linear-gradient(135deg, #ff5f6d 0%, #d40019 100%);
  --grad-free: linear-gradient(135deg, #2ee6a8 0%, #00b37a 100%);
  --grad-sale: linear-gradient(135deg, #ffb43d 0%, #ff5a00 100%);
  --grad-hero: radial-gradient(130% 150% at 0% 45%, #4d0f18 0%, rgba(0, 0, 0, 0) 62%);

  --bg: #0a1018;
  --bg-elev: #131d29;
  --bg-sunken: #0d151e;
  --bg-glass: rgba(15, 24, 34, .86);
  --text: #e9f0f8;
  --text-2: #a9b9cb;
  --text-3: #74869b;
  --line: #21303f;
  --line-strong: #2e4054;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 22px rgba(0, 0, 0, .35);
  --shadow-2: 0 2px 8px rgba(0, 0, 0, .5), 0 22px 60px rgba(0, 0, 0, .55);
}

/* ---- 全局字号缩放：100% / 115% / 130% ---- */
html[data-scale="1.15"] { --fs-scale: 1.15; }
html[data-scale="1.3"]  { --fs-scale: 1.3; }

/* ---- 高对比度模式 ---- */
html[data-contrast="high"] {
  --text-2: var(--text);
  --text-3: #55657a;
  --line: var(--line-strong);
  --bg: #ffffff;
  --bg-sunken: #eef2f8;
  --bg-elev: #ffffff;
}
html[data-contrast="high"][data-theme="dark"] {
  --text-2: #ffffff;
  --text-3: #c3d2e2;
  --line: #4a6076;
  --bg: #000000;
  --bg-elev: #0b131c;
  --bg-sunken: #05090d;
}

/* ---- 色弱友好配色：色彩不作为唯一信息载体，同时切换语义色相 ---- */
html[data-cb="deutan"] { --ok: #2f7fd6; --danger: #d06a2a; --warn: #b07f00; }
html[data-cb="protan"] { --ok: #2f7fd6; --danger: #a05ad0; --warn: #a07800; }
html[data-cb="tritan"] { --ok: #1f8f6a; --danger: #d0407a; --warn: #c08a00; }

*, *::before, *::after { box-sizing: border-box; }

/* hidden 属性必须优先于组件自身的 display 值（否则空态/网格显隐会失效） */
[hidden] { display: none !important; }

html {
  font-size: calc(16px * var(--fs-scale));
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, figure, ul, ol { margin: 0; }
ul, ol { padding: 0; list-style: none; }
img, svg { max-width: 100%; }
svg.ico { display: inline-block; width: 1.15em; height: 1.15em; flex: none; vertical-align: -.14em; }
svg.cover { display: block; width: 100%; height: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
a { color: inherit; text-decoration: none; }

:focus { outline: none; }
:focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 3px;
  border-radius: 6px;
}
/* 高对比 + 键盘焦点更醒目 */
html[data-contrast="high"] :focus-visible {
  outline: 4px solid var(--brand);
  outline-offset: 4px;
}

/* 减少动效：商店内设置 */
html[data-motion="reduced"] *,
html[data-motion="reduced"] *::before,
html[data-motion="reduced"] *::after {
  animation-duration: .001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: .001ms !important;
}
html[data-motion="reduced"] { scroll-behavior: auto; }

/* 减少动效：尊重系统偏好 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: -100px;
  left: 16px;
  z-index: 200;
  padding: 12px 18px;
  border-radius: var(--r-pill);
  background: var(--brand);
  color: #fff;
  font-weight: 600;
  box-shadow: var(--shadow-2);
  transition: top var(--dur) var(--ease);
}
.skip-link:focus-visible { top: 16px; }

/* 程序化聚焦的标题不显示焦点环（读屏仍可获得焦点） */
h1[tabindex="-1"]:focus,
h1[tabindex="-1"]:focus-visible,
main[tabindex="-1"]:focus,
main[tabindex="-1"]:focus-visible { outline: none; }

/* 搜索面板内的输入框已经有边框，不再叠加焦点环 */
.search-field input:focus,
.search-field input:focus-visible { outline: none; }

/* 滚动条（桌面） */
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 999px;
  border: 3px solid transparent;
  background-clip: content-box;
}
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

/* 文本选中 */
::selection { background: var(--brand); color: #fff; }

/* 通用小工具类 */
.muted { color: var(--text-2); }
.dim { color: var(--text-3); }
.mono { font-family: var(--font-num); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.stack-1 { display: grid; gap: 4px; }
.stack-2 { display: grid; gap: 8px; }
.stack-3 { display: grid; gap: 14px; }
.stack-4 { display: grid; gap: 24px; }
.row { display: flex; align-items: center; gap: 10px; }
.row--between { justify-content: space-between; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: .78rem;
  font-weight: 650;
  line-height: 1.5;
  background: var(--bg-sunken);
  color: var(--text-2);
  white-space: nowrap;
}
.badge--brand { background: var(--brand-soft); color: var(--brand-strong); }
.badge--coral { background: var(--coral-soft); color: #b83f1c; }
html[data-theme="dark"] .badge--coral { color: var(--coral); }
.badge--ok { background: var(--ok-soft); color: var(--ok); }
.badge--free { background: var(--ok-soft); color: var(--ok); }
.badge--dot::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* 打印 */
@media print {
  .rail, .topbar__search, .topbar__actions, .foot { display: none !important; }
  body { background: #fff; }
}
