/* ==========================================================================
   base.css — 设计令牌 + 目录页 + 希沃触屏适配
   郴州市第六中学 · 物理仿真实验平台
   深色底 / 高对比 / 远距离可读；不依赖 hover 完成任何关键操作。
   ========================================================================== */

:root {
  /* —— 底色层次（投影时避免泛白） —— */
  --bg: #091625;
  --bg-deep: #06111d;
  --bg-elev: #0e2033;
  --bg-panel: #0c1c2d;
  --bg-inset: #071522;

  /* —— 描边 —— */
  --line: rgba(122, 178, 232, 0.16);
  --line-strong: rgba(122, 178, 232, 0.32);

  /* —— 文字（正文 ≥16px，读数 ≥20px） —— */
  --text: #e8f2ff;
  --text-dim: #aac3dd;
  --text-mute: #7f9ab5;

  /* —— 强调（青 / 琥珀；不用纯红纯绿表达语义） —— */
  --cyan: #3ad6e8;
  --cyan-deep: #11839a;
  --amber: #ffb648;
  --amber-deep: #b87510;
  --violet: #b48cff;
  --ok: #4fd6b0;
  --warn: #ffb648;
  --err: #ff9b9b;

  /* —— 尺寸 —— */
  --radius: 14px;
  --radius-sm: 12px;
  --radius-xs: 7px;
  --tap: 48px;          /* 触屏最小点击区 */
  --page-max: 1440px;

  --shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
  --shadow-sm: 0 6px 18px rgba(0, 0, 0, 0.35);

  --font: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    system-ui, -apple-system, sans-serif;
  --font-num: "Cascadia Mono", "Consolas", "SF Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(1200px 700px at 12% -10%, rgba(58, 214, 232, 0.10), transparent 60%),
    radial-gradient(900px 600px at 100% 0%, rgba(180, 140, 255, 0.07), transparent 55%),
    linear-gradient(180deg, #0a1a2b 0%, var(--bg) 42%, var(--bg-deep) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, p, ul, ol, dl, dd {
  margin: 0;
}

ul, ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

button,
input,
select {
  font: inherit;
  color: inherit;
}

/* 触屏友好：所有可交互元素去掉 300ms 延迟与点按高亮 */
button,
select,
input[type="range"],
input[type="checkbox"],
summary {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* 键盘 / 触控笔可见焦点（不用 hover 传达状态） */
:focus-visible {
  outline: 3px solid var(--cyan);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ==========================================================================
   顶栏
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px clamp(16px, 3vw, 40px);
  background: rgba(9, 22, 37, 0.82);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: none;
  border-radius: 12px;
  background: linear-gradient(150deg, rgba(58, 214, 232, 0.22), rgba(58, 214, 232, 0.04));
  border: 1px solid rgba(58, 214, 232, 0.38);
  color: var(--cyan);
  font-size: 22px;
  box-shadow: inset 0 0 22px rgba(58, 214, 232, 0.14);
}

.brand-text {
  min-width: 0;
}

.brand-title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 12.5px;
  color: var(--text-mute);
  letter-spacing: 0.02em;
}

.topbar-spacer {
  flex: 1 1 auto;
}

.backlink {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  color: var(--text-dim);
  font-size: 16px;
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.backlink:active {
  background: rgba(58, 214, 232, 0.12);
  border-color: rgba(58, 214, 232, 0.5);
  color: var(--text);
}

/* ==========================================================================
   目录页
   ========================================================================== */

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: clamp(20px, 3vw, 40px) clamp(16px, 3vw, 40px) 72px;
}

.intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 26px;
}

.intro h1 {
  font-size: clamp(26px, 3vw, 36px);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.24;
}

.intro p {
  margin-top: 10px;
  max-width: 62ch;
  color: var(--text-dim);
  font-size: 16px;
}

.intro-stats {
  display: flex;
  gap: 26px;
  flex-wrap: wrap;
}

.stat {
  min-width: 92px;
}

.stat-num {
  font-family: var(--font-num);
  font-size: 30px;
  font-weight: 600;
  color: var(--cyan);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 14px;
  color: var(--text-mute);
}

/* —— 分类折叠：原生 <details> —— */
.cat {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(14, 32, 51, 0.72), rgba(10, 24, 38, 0.55));
  margin-bottom: 16px;
  overflow: hidden;
  transition: border-color 0.2s ease;
}

.cat[open] {
  border-color: var(--line-strong);
}

.cat > summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 12px 18px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.cat > summary::-webkit-details-marker {
  display: none;
}

.cat-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: rgba(58, 214, 232, 0.10);
  border: 1px solid rgba(58, 214, 232, 0.26);
  color: var(--cyan);
  font-size: 21px;
  flex: none;
}

.cat-head {
  min-width: 0;
}

.cat-name {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 17.5px;
  font-weight: 620;
}

.cat-en {
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-mute);
  font-weight: 500;
}

.cat-desc {
  font-size: 13.5px;
  color: var(--text-dim);
  margin-top: 2px;
}

.cat-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--text-mute);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.cat-chevron {
  display: inline-block;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  position: relative;
  transition: transform 0.22s ease;
}

.cat-chevron::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 46%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-dim);
  border-bottom: 2px solid var(--text-dim);
  transform: translate(-50%, -50%) rotate(-45deg);
}

.cat[open] .cat-chevron::before {
  transform: translate(-50%, -50%) rotate(45deg);
  border-color: var(--cyan);
}

.cat[open] .cat-chevron {
  border-color: rgba(58, 214, 232, 0.5);
}

.cat-body {
  padding: 4px 20px 20px;
  border-top: 1px solid var(--line);
}

.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 11px;
  padding-top: 16px;
}

.item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 92px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(7, 21, 34, 0.62);
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.item:active {
  transform: scale(0.994);
  border-color: rgba(58, 214, 232, 0.5);
  background: rgba(58, 214, 232, 0.08);
}

.item-name {
  font-size: 15.5px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-name::after {
  content: "›";
  color: var(--cyan);
  font-size: 16px;
  opacity: 0.85;
  transition: transform 0.18s ease;
}

.item-note {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.52;
}

.item.is-planned {
  border-style: dashed;
  opacity: 0.62;
}

.item.is-planned .item-name::after {
  content: "待建";
  font-size: 12px;
  color: var(--text-mute);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 1px 8px;
}

/* 仅在有精确指针设备时启用 hover 强调，触屏不依赖它 */
@media (hover: hover) and (pointer: fine) {
  .item:hover {
    border-color: rgba(58, 214, 232, 0.42);
    background: rgba(58, 214, 232, 0.07);
  }

  .item:hover .item-name::after {
    transform: translateX(3px);
  }

  .cat > summary:hover .cat-chevron {
    border-color: rgba(58, 214, 232, 0.55);
  }
}

.page-foot {
  margin-top: 40px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  color: var(--text-mute);
  font-size: 14px;
  display: flex;
  gap: 18px;
  flex-wrap: wrap;
  justify-content: space-between;
}

.page-foot code {
  font-family: var(--font-num);
  color: var(--text-dim);
}

/* ==========================================================================
   通用小件
   ========================================================================== */

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid rgba(58, 214, 232, 0.34);
  background: rgba(58, 214, 232, 0.10);
  color: var(--cyan);
  font-size: 13px;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.tag.is-amber {
  border-color: rgba(255, 182, 72, 0.36);
  background: rgba(255, 182, 72, 0.10);
  color: var(--amber);
}

.tag.is-violet {
  border-color: rgba(180, 140, 255, 0.36);
  background: rgba(180, 140, 255, 0.10);
  color: var(--violet);
}

.visually-hidden {
  position: absolute !important;
  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;
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
