/* ==========================================================================
   鉴定师工具箱 · base.css
   --------------------------------------------------------------------------
   01 重置            02 设计 token        03 物证强调色
   04 基础排版        05 工具类            06 图标 / 无障碍
   07 背景特效 fx     08 滚动条 / 选择色   09 降级动效 / 高对比
   ========================================================================== */

/* ==========================================================================
   01 重置
   ========================================================================== */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  color-scheme: dark;
  scroll-padding-top: calc(var(--header-h) + 16px);
}

body {
  min-height: 100vh;
  min-height: 100svh;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
}

img {
  height: auto;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

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

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

fieldset {
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

legend {
  padding: 0;
}

figure,
dl,
dd {
  margin: 0;
}

[hidden] {
  display: none !important;
}

/* ==========================================================================
   02 设计 token
   ========================================================================== */
:root {
  /* 底色 / 面板 */
  --bg-0: #04060b;
  --bg-1: #070c15;
  --bg-2: #0b1420;
  --panel: rgba(10, 19, 31, 0.72);
  --panel-2: rgba(14, 26, 41, 0.86);
  --panel-solid: #0a131f;
  --panel-lift: rgba(19, 34, 53, 0.6);

  /* 文本 */
  --ink-0: #f2f9ff;
  --ink-1: #c2d4e5;
  --ink-2: #8aa2b8;
  --ink-3: #5b7086;

  /* 描边 */
  --line-0: rgba(124, 196, 255, 0.12);
  --line-1: rgba(124, 196, 255, 0.24);
  --line-strong: rgba(96, 224, 255, 0.55);

  /* 霓虹 */
  --cyan: #3ee6ff;
  --cyan-deep: #0096b8;
  --magenta: #ff3d9a;
  --violet: #a77bff;
  --amber: #ffc247;
  --lime: #7dffb0;
  --danger: #ff4d63;

  /* 字体 */
  --font-ui: "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Noto Sans SC", sans-serif;
  --font-mono: "Cascadia Mono", "Cascadia Code", "JetBrains Mono",
    "SFMono-Regular", Consolas, "Liberation Mono", monospace;

  /* 尺寸 / 节奏 */
  --maxw: 1280px;
  --gutter: clamp(16px, 4vw, 48px);
  --header-h: 62px;
  --clip: 14px;
  --clip-sm: 9px;
  --clip-lg: 20px;
  --r-1: 2px;

  /* 动效 */
  --dur-fast: 120ms;
  --dur: 240ms;
  --dur-slow: 520ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* 层级 */
  --z-header: 50;
  --z-nav: 40;
  --z-lightbox: 140;
  --z-toast: 120;
  --z-skip: 200;

  /* 默认强调色（cyan，body[data-accent] 会覆盖） */
  --accent: #3ee6ff;
  --accent-deep: #0096b8;
  --accent-rgb: 62 230 255;
  --accent-2: #ff3d9a;
  --accent-2-rgb: 255 61 154;
}

/* ==========================================================================
   03 物证强调色（JS 写在 body / screen / item-card 的 data-accent 上）
   ========================================================================== */
[data-accent="cyan"] {
  --accent: #3ee6ff;
  --accent-deep: #0096b8;
  --accent-rgb: 62 230 255;
  --accent-2: #ff3d9a;
  --accent-2-rgb: 255 61 154;
}

[data-accent="plasma"] {
  --accent: #b388ff;
  --accent-deep: #6c3bd6;
  --accent-rgb: 179 136 255;
  --accent-2: #28f0c8;
  --accent-2-rgb: 40 240 200;
}

[data-accent="amber"] {
  --accent: #ffc247;
  --accent-deep: #c47a00;
  --accent-rgb: 255 194 71;
  --accent-2: #6bffa5;
  --accent-2-rgb: 107 255 165;
}

/* ==========================================================================
   04 基础排版
   ========================================================================== */
body {
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.65;
  color: var(--ink-1);
  background-color: var(--bg-0);
  background-image:
    radial-gradient(120% 82% at 76% -12%, rgb(var(--accent-rgb) / 0.1), transparent 58%),
    radial-gradient(96% 70% at 4% 14%, rgb(var(--accent-2-rgb) / 0.065), transparent 62%),
    linear-gradient(180deg, #060a12 0%, var(--bg-0) 46%, #050810 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;
}

h1,
h2,
h3,
h4 {
  color: var(--ink-0);
  font-weight: 650;
  line-height: 1.25;
}

b,
strong {
  font-weight: 650;
}

.mono,
time,
b,
[data-estimate],
[data-counter] {
  font-variant-numeric: tabular-nums;
}

::selection {
  background: rgb(var(--accent-rgb) / 0.32);
  color: var(--ink-0);
}

/* ==========================================================================
   05 工具类
   ========================================================================== */

/* 图片内不参与读屏的块等由 HTML 处理，这里只保留公共类 */
.mono {
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
}

.num {
  font-variant-numeric: tabular-nums;
}

/* --- 视觉隐藏（读屏可见） --- */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* --- 跳到主内容 --- */
.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: var(--z-skip);
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid var(--line-strong);
  background: var(--panel-solid);
  color: var(--ink-0);
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  clip-path: polygon(0 0, calc(100% - 10px) 0, 100% 10px, 100% 100%, 10px 100%, 0 calc(100% - 10px));
  box-shadow: 0 0 24px rgb(var(--accent-rgb) / 0.22);
  transform: translateY(calc(-100% - 20px));
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus,
.skip-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  transform: translateY(0);
}

/* --- 语义色工具类（JS 会直接写在数值上） --- */
.is-plus {
  color: var(--lime) !important;
}

.is-minus {
  color: var(--danger) !important;
}

.is-zero {
  color: var(--ink-3) !important;
}

.is-danger {
  color: var(--danger) !important;
}

.is-met {
  color: var(--lime) !important;
}

.is-unmet {
  color: var(--ink-3) !important;
}

.is-warn {
  color: var(--amber) !important;
}

/* ==========================================================================
   06 图标 / 无障碍基础
   ========================================================================== */
.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.icon {
  width: 1.15em;
  height: 1.15em;
  flex: none;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
  vertical-align: -0.16em;
}

.icon--tiny {
  width: 0.95em;
  height: 0.95em;
  stroke-width: 2.1;
}

.icon--lg {
  width: 2.4em;
  height: 2.4em;
  stroke-width: 1.25;
}

.icon--clock {
  width: 1.05em;
  height: 1.05em;
  stroke-width: 1.5;
}

/* 键盘焦点：全局可见的 2px 强调色描边 */
:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 切角（clip-path）组件的外描边会被裁掉，改用内描边 */
:where(.item-card, .btn, .option-card__inner, .reference-card__thumb, .lightbox__close):focus-visible {
  outline-offset: -3px;
}

/* 程序化聚焦的标题（tabindex=-1）不显示常驻焦点框，改由标题自身的稳定装饰线表达位置 */
#stepTitle:focus,
#resultTitle:focus,
#stepTitle:focus-visible,
#resultTitle:focus-visible {
  outline: none;
}

/* JS 禁用提示 */
.noscript {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 11, 0.94);
  backdrop-filter: blur(10px);
}

.noscript p {
  max-width: 440px;
  padding: 26px 30px;
  border: 1px solid var(--line-1);
  background: var(--panel-2);
  color: var(--ink-1);
  text-align: center;
  font-size: 14px;
  line-height: 1.8;
  clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
}

/* 滚动锁定（灯箱打开时 JS 加在 body 上） */
body.is-scroll-locked,
body.no-scroll {
  overflow: hidden;
}

/* ==========================================================================
   07 背景特效 fx
   ========================================================================== */
.fx {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.fx > * {
  position: absolute;
  inset: 0;
}

/* 透视网格地面 */
.fx__grid {
  inset: auto 0 0;
  height: 46vh;
  background-image:
    linear-gradient(to right, rgb(var(--accent-rgb) / 0.11) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(var(--accent-rgb) / 0.1) 1px, transparent 1px),
    linear-gradient(to right, rgb(var(--accent-2-rgb) / 0.12) 1px, transparent 1px);
  background-size:
    54px 54px,
    54px 54px,
    270px 270px;
  background-position: center bottom;
  transform-origin: 50% 100%;
  transform: perspective(520px) rotateX(64deg) scale(1.55);
  -webkit-mask-image: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0.55) 42%, transparent 92%);
  mask-image: linear-gradient(to top, #000 0%, rgba(0, 0, 0, 0.55) 42%, transparent 92%);
  opacity: 0.75;
  animation: grid-drift 72s linear infinite;
  will-change: transform;
}

/* 光晕 */
.fx__glow {
  inset: auto;
  border-radius: 50%;
  filter: blur(70px);
  mix-blend-mode: screen;
  transform: translateZ(0);
  will-change: transform, opacity;
}

.fx__glow--a {
  top: -28vmax;
  left: -12vmax;
  width: 78vmax;
  height: 62vmax;
  background: radial-gradient(circle at 50% 50%, rgb(var(--accent-rgb) / 0.16), transparent 66%);
  animation: glow-breathe-a 12s ease-in-out infinite alternate;
}

.fx__glow--b {
  right: -26vmax;
  bottom: -34vmax;
  width: 72vmax;
  height: 64vmax;
  background: radial-gradient(circle at 50% 50%, rgb(var(--accent-2-rgb) / 0.13), transparent 68%);
  animation: glow-breathe-b 16s ease-in-out infinite alternate;
}

/* 扫描线 */
.fx__scanlines {
  background: repeating-linear-gradient(
    180deg,
    rgba(3, 6, 11, 0.34) 0,
    rgba(3, 6, 11, 0.34) 1px,
    transparent 1px,
    transparent 3px
  );
  opacity: 0.55;
}

.fx__scanlines::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 34%;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgb(var(--accent-rgb) / 0.05) 55%,
    rgb(var(--accent-rgb) / 0.09) 92%,
    transparent 100%
  );
  animation: scan-band 13s linear infinite;
}

/* 噪点（内联 SVG，无网络请求） */
.fx__noise {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.05;
  mix-blend-mode: overlay;
}

/* 暗角 */
.fx__vignette {
  background:
    radial-gradient(ellipse 120% 90% at 50% 38%, transparent 42%, rgba(2, 4, 8, 0.58) 100%),
    linear-gradient(180deg, rgba(2, 4, 8, 0.5) 0%, transparent 18%, transparent 78%, rgba(2, 4, 8, 0.55) 100%);
}

/* ==========================================================================
   08 滚动条 / 选中色
   ========================================================================== */
@supports (scrollbar-width: thin) {
  html {
    scrollbar-width: thin;
    scrollbar-color: rgba(124, 196, 255, 0.26) transparent;
  }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
}

::-webkit-scrollbar-thumb {
  border: 2px solid var(--bg-0);
  background: rgba(124, 196, 255, 0.2);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 196, 255, 0.34);
}

/* ==========================================================================
   09 降级动效 / 高对比
   ========================================================================== */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .fx__glow,
  .fx__grid,
  .fx__scanlines::after {
    animation: none;
  }
}

@media (prefers-contrast: more) {
  :root {
    --ink-2: #a9c0d4;
    --ink-3: #8299ae;
    --line-0: rgba(124, 196, 255, 0.22);
    --line-1: rgba(124, 196, 255, 0.36);
  }
}
