/* ============================================================
   设备安全中心 — iOS 14-18 系统级安全扫描落地页
   纯 CSS，无任何框架依赖；深浅模式自适应；SF 系统字体栈
   ============================================================ */

/* ---------- Design Tokens（全部取自 iOS 系统色板） ---------- */
:root {
  --font-sys: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --bg: #F2F2F7;                              /* 设置页同款系统灰 */
  --card: rgba(255, 255, 255, 0.86);
  --card-border: rgba(60, 60, 67, 0.12);
  --flat: rgba(255, 255, 255, 0.62);
  --fg: #000000;
  --fg-2: rgba(60, 60, 67, 0.6);
  --hairline: rgba(60, 60, 67, 0.18);

  --blue: #007AFF;
  --red: #FF3B30;
  --green: #34C759;
  --orange: #FF9500;
  --terminal-bg: rgba(20, 24, 28, 0.92);
  --terminal-fg: rgba(52, 199, 89, 0.9);

  --radius-card: 16px;
  --radius-btn: 14px;
  --spring: cubic-bezier(.32, .72, 0, 1);     /* iOS 弹簧近似 */
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;                            /* 深色系统页同款纯黑 */
    --card: rgba(255, 255, 255, 0.08);        /* 毛玻璃卡面 */
    --card-border: rgba(255, 255, 255, 0.15); /* 0.5px 半透明描边 */
    --flat: rgba(255, 255, 255, 0.05);
    --fg: #FFFFFF;
    --fg-2: rgba(235, 235, 245, 0.6);
    --hairline: rgba(255, 255, 255, 0.12);
    --terminal-bg: rgba(18, 18, 20, 0.9);
  }
}

/* ---------- Reset & 全局（禁止原生滚动） ---------- */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  overflow: hidden;                           /* 全局禁止滚动条 */
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sys);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: background .6s ease;
}

/* ---------- 背景氛围：蓝(可信) → 红(危急) ---------- */
.aura {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 55% at 50% -8%, rgba(0, 122, 255, 0.10), transparent 62%),
    radial-gradient(90% 40% at 50% 108%, rgba(52, 199, 89, 0.05), transparent 60%);
  transition: background 1.2s var(--spring);
}

body.danger .aura {
  background:
    radial-gradient(120% 58% at 50% -8%, rgba(255, 59, 48, 0.16), transparent 64%),
    radial-gradient(90% 42% at 50% 108%, rgba(255, 59, 48, 0.07), transparent 60%);
}

/* ---------- 通用卡片（原生分组列表质感） ---------- */
.card {
  background: var(--card);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border: 0.5px solid var(--card-border);
  border-radius: var(--radius-card);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.06);
}

@media (prefers-color-scheme: dark) {
  .card { box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4); }
}

/* ---------- 三屏舞台 ---------- */
.stage {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;                          /* fallback: iOS 14/15 */
  min-height: 100dvh;                         /* 渐进增强: 动态视口 */
  padding:
    calc(env(safe-area-inset-top, 0px) + 20px)
    20px
    calc(env(safe-area-inset-bottom, 0px) + 16px);
}

.stage--hidden { display: none; }

.stage__body {
  width: 100%;
  max-width: 430px;                           /* 桌面/平板预览时保持手机比例 */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  animation: stageIn .55s var(--spring) both;
}

.stage__foot {
  margin-top: auto;
  padding-top: 14px;
  text-align: center;
  font-size: 12px;
  color: var(--fg-2);
  letter-spacing: .02em;
}

@keyframes stageIn {
  from { opacity: 0; transform: translateY(14px) scale(.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 阶段一：拦截卡 ---------- */
.alert-card {
  margin-top: auto;
  padding: 30px 22px 22px;
  text-align: center;
}

.badge-ring {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  position: relative;
}

.badge-ring svg { width: 38px; height: 38px; }

.badge-ring--blue {
  color: var(--blue);
  background: rgba(0, 122, 255, 0.12);
}
.badge-ring--blue::after {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 1.5px solid rgba(0, 122, 255, 0.25);
  animation: ringPulse 2.4s ease-in-out infinite;
}

.badge-ring--scan { color: var(--green); background: rgba(52, 199, 89, 0.12); }
.badge-ring--red  { color: var(--red);  background: rgba(255, 59, 48, 0.12); }

@keyframes ringPulse {
  0%, 100% { opacity: .4; transform: scale(1); }
  50%      { opacity: 1;  transform: scale(1.06); }
}

.alert-card__title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.alert-card__desc {
  margin-top: 10px;
  font-size: 15px;
  color: var(--fg-2);
}

.alert-card__meta {
  list-style: none;
  margin: 18px auto 22px;
  display: inline-flex;
  flex-direction: column;
  gap: 9px;
  text-align: left;
  font-size: 14px;
}

.alert-card__meta li { display: flex; align-items: center; gap: 8px; }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.dot--red    { background: var(--red); }
.dot--orange { background: var(--orange); }

/* ---------- iOS 风格按钮 ---------- */
.btn {
  width: 100%;
  height: 50px;
  border: 0;
  border-radius: var(--radius-btn);
  font-family: var(--font-sys);
  font-size: 17px;
  font-weight: 600;
  color: #fff;
  cursor: pointer;
  transition: transform .18s var(--spring), opacity .18s ease;
}
.btn:active { opacity: .72; transform: scale(.975); }

.btn--primary {
  background: var(--blue);
  box-shadow: 0 6px 20px rgba(0, 122, 255, 0.32);
}
.btn--danger {
  background: var(--red);
  animation: breathe 1.6s ease-in-out infinite;
}

/* 终局 CTA：呼吸跳动 */
@keyframes breathe {
  0%, 100% {
    transform: scale(1);
    box-shadow: 0 6px 20px rgba(255, 59, 48, 0.3);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 12px 36px rgba(255, 59, 48, 0.55);
  }
}

/* ---------- 灵动岛式系统通知 ---------- */
.sys-noti {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 10px;
  right: 10px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 20px;
  background: rgba(250, 250, 250, 0.9);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  backdrop-filter: blur(24px) saturate(1.8);
  border: 0.5px solid rgba(60, 60, 67, 0.14);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  transform: translateY(calc(-100% - 40px));  /* 默认藏在屏幕外 */
  transition: transform .85s var(--spring), opacity .5s ease;
}

@media (prefers-color-scheme: dark) {
  .sys-noti {
    background: rgba(38, 38, 42, 0.86);
    border-color: rgba(255, 255, 255, 0.14);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  }
}

.sys-noti--shown { transform: translateY(0); }
.sys-noti--hide  {
  transform: translateY(calc(-100% - 40px));
  opacity: 0;
}

.sys-noti__icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(180deg, #3EA0FF, var(--blue));
}
.sys-noti__icon svg { width: 22px; height: 22px; }

.sys-noti__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.sys-noti__app   { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-2); }
.sys-noti__title { font-size: 14px; font-weight: 600; }
.sys-noti__time  { font-size: 11px; color: var(--fg-2); flex: none; }

/* ---------- 阶段二：扫描 ---------- */
.scan-head {
  text-align: center;
  margin-bottom: 20px;
}
.scan-head__title {
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.scan-head__sub {
  margin-top: 6px;
  font-size: 14px;
  color: var(--fg-2);
}
.scan-head__sub--red { color: var(--red); }

/* 雷达扫描线旋转 */
.radar-sweep {
  transform-origin: 12px 12px;
  animation: radar 2s linear infinite;
}
@keyframes radar { to { transform: rotate(360deg); } }

.scan-progress { padding: 16px; }

.scan-progress__top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--fg-2);
}

.scan-progress__pct {
  font-size: 15px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;         /* 百分比不抖动 */
}

.bar {
  height: 5px;
  border-radius: 3px;
  background: var(--hairline);
  overflow: hidden;
}
.bar__fill {
  height: 100%;
  width: 0%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--green), #30D158);
  transition: width .12s linear;
}

/* 扫描命中的风险条目 */
.threat-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.threat-list:empty { margin: 0; }

.threat-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-radius: var(--radius-card);
  background: rgba(255, 59, 48, 0.08);
  border: 0.5px solid rgba(255, 59, 48, 0.28);
  animation: threatIn .35s ease both;
}

.threat-item--high {
  background: rgba(255, 59, 48, 0.12);
  border-color: rgba(255, 59, 48, 0.4);
}

.threat-item__icon {
  width: 30px;
  height: 30px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--red);
  background: rgba(255, 59, 48, 0.14);
}
.threat-item__icon svg { width: 18px; height: 18px; }

.threat-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.threat-item__name   { font-size: 14px; font-weight: 600; }
.threat-item__detail { font-size: 12px; color: var(--fg-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@keyframes threatIn {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* 风险项出现即横向震动 */
@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-5px); }
  30% { transform: translateX(5px); }
  45% { transform: translateX(-4px); }
  60% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  90% { transform: translateX(1px); }
}

/* 终端日志（SF Mono，不折行，内部滚动） */
.terminal {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-card);
  border: 0.5px solid var(--hairline);
  background: var(--terminal-bg);
  overflow: hidden;
}

.terminal__head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 9px 12px;
  border-bottom: 0.5px solid rgba(255, 255, 255, 0.08);
  flex: none;
}
.terminal__dot  { width: 10px; height: 10px; border-radius: 50%; }
.terminal__title {
  margin-left: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: rgba(235, 235, 245, 0.45);
  letter-spacing: .02em;
}

.terminal__log {
  flex: 1;
  min-height: 0;
  overflow: hidden;                           /* 内部滚动，全局无滚动条 */
  padding: 10px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.65;
  color: var(--terminal-fg);
}

.log-line {
  white-space: nowrap;                        /* 保持终端气质，不折行 */
  animation: logIn .18s ease both;
}
.log-line--warn { color: #FF6961; font-weight: 600; }

@keyframes logIn {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ---------- 阶段三：结果 ---------- */
.result-head { margin-top: 6px; }
.result-badge {
  width: 84px;
  height: 84px;
  margin-bottom: 16px;
}
.result-badge svg { width: 44px; height: 44px; }

.result-list {
  padding: 6px 16px;
  display: flex;
  flex-direction: column;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 0;
  animation: threatIn .45s ease both;
  animation-delay: calc(var(--d) * 110ms + 120ms);
}
.result-item + .result-item { border-top: 0.5px solid var(--hairline); }

.result-item__icon {
  width: 36px;
  height: 36px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}
.result-item__icon svg { width: 20px; height: 20px; }
.result-item__icon--red    { color: var(--red);    background: rgba(255, 59, 48, 0.12); }
.result-item__icon--orange { color: var(--orange); background: rgba(255, 149, 0, 0.12); }

.result-item__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.result-item__name   { font-size: 15px; font-weight: 600; }
.result-item__detail { font-size: 12px; color: var(--fg-2); }

/* 风险等级标签 */
.tag {
  flex: none;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  letter-spacing: .03em;
}
.tag--high { color: #fff; background: var(--red); }
.tag--mid  { color: #fff; background: var(--orange); }

/* 终局 CTA 区：固定贴底 */
.result-cta {
  margin-top: auto;
  padding-top: 16px;
  text-align: center;
}
.result-cta__sub {
  margin-top: 10px;
  font-size: 12px;
  color: var(--fg-2);
}

/* ---------- 可访问性：动效降级 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- 桌面预览兜底（非 iOS 环境下保持手机框感） ---------- */
@media (min-width: 768px) {
  .stage__body {
    max-width: 430px;
    border-radius: 0;
  }
}
