/* ============================================================
   故障特效层 —— analog horror 低保真美学
   全部由 html.d-on / --dread 闸控：基线(L0)完全不显示。
   不用 jump scare，只做"信号不对劲"的持续压迫感。
   ============================================================ */

/* —— CRT 扫描线（L1 起，极淡；随腐化加深）—— */
html.d-on body::after {
  background-image:
    repeating-linear-gradient(0deg,
      rgba(0,0,0,calc(0.012 * var(--dv))) 0px,
      rgba(0,0,0,calc(0.012 * var(--dv))) 1px,
      transparent 1px, transparent 3px),
    radial-gradient(130% 100% at 50% 42%, rgba(0,0,0,0) 46%, rgba(12,16,12,0.55) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: auto, cover, 150px 150px;
}

/* —— 图片：随腐化出现轻微色偏与错位（RGB split 的廉价实现）—— */
html.d-on #pet-results article img,
html.d-on .pc img,
html.d-on .photo img {
  filter: contrast(calc(1 + 0.03 * var(--dv))) saturate(calc(1 - 0.06 * var(--dv)));
}
html[data-dread="3"] #pet-results article img,
html[data-dread="4"] #pet-results article img,
html[data-dread="5"] #pet-results article img,
html[data-dread="6"] #pet-results article img {
  animation: rgbshift 9s steps(1) infinite;
}
@keyframes rgbshift {
  0%, 93%, 100% { transform: translate(0,0); filter: none; }
  94% { transform: translate(-1px,0); filter: hue-rotate(6deg); }
  95% { transform: translate(1px,0);  filter: hue-rotate(-6deg); }
  96% { transform: translate(0,1px); }
}

/* —— 极偶尔的整屏"掉帧"横切（L2 起）—— */
html.d-flicker #wrapper::before {
  content: ""; position: fixed; left: 0; right: 0; height: 2px; z-index: 9997;
  background: rgba(255,255,255,.5); pointer-events: none; opacity: 0;
  animation: tear 13s linear infinite;
}
@keyframes tear {
  0%, 88%, 100% { opacity: 0; top: 20%; }
  89% { opacity: .35; top: 30%; }
  90% { opacity: 0;   top: 45%; }
  93% { opacity: .28; top: 62%; }
  94% { opacity: 0;   top: 70%; }
}

/* —— 文本：深度腐化时极轻微的字距抖动（不影响阅读）—— */
html[data-dread="4"] #content h3, html[data-dread="5"] #content h3, html[data-dread="6"] #content h3,
html[data-dread="4"] .page-head h1, html[data-dread="5"] .page-head h1, html[data-dread="6"] .page-head h1 {
  animation: jitter 7s steps(1) infinite;
}
@keyframes jitter {
  0%, 95%, 100% { letter-spacing: normal; }
  96% { letter-spacing: 1.5px; }
  97% { letter-spacing: normal; }
  98% { letter-spacing: -0.5px; }
}

/* —— 可发现元素的"可疑"提示：极淡的下划虚线（仅腐化后出现）—— */
html.d-on .clue-hint { border-bottom: 1px dotted rgba(140,90,80,.35); cursor: help; }

/* —— 深度腐化：页面边缘渗出的暗红 —— */
html[data-dread="5"] body::before, html[data-dread="6"] body::before {
  box-shadow: inset 0 0 120px rgba(90,20,15,.18);
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 9996;
}

/* 放大看原图时，图片的色偏/错位动画也要停 —— 同 horror.css 的理由 */
html.zooming #gal-ov img, html.zooming #zoom-ov img { animation: none !important; filter: none !important; }
