@font-face {
  font-family: "WJ Display";
  src: url("fonts/display.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --paper-deep: #f2efe6;
  --ink: #151515;
  --ink-soft: #5d5b55;
  --ink-faint: #a9a59b;
  --accent: #e2372b;
  --up: #e2372b;
  --up-soft: #f08a80;
  --down: #1d9a57;
  --down-soft: #7cc9a0;
  --flat: #d9d5ca;

  --font-display: "WJ Display", "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-body: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: ui-monospace, "SFMono-Regular", Consolas, monospace;

  --stroke: 3px;
  --shadow: 7px 7px 0 var(--ink);
  --shadow-lift: 12px 12px 0 var(--ink);
  --gutter: clamp(16px, 5vw, 64px);
  --section-gap: clamp(120px, 18vw, 220px);
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.8 var(--font-body);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: inherit; }

code {
  font: 0.88em var(--font-mono);
  background: var(--paper-deep);
  padding: 0.1em 0.4em;
  border-radius: 3px;
}

:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}

.d { font-family: var(--font-display); font-weight: 400; }

/* ---------- 顶栏 ---------- */
.top {
  position: fixed;
  inset: 0 0 auto;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 22px var(--gutter);
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.stamp {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  background: var(--ink);
  color: var(--paper);
  font-size: 22px;
  text-decoration: none;
  transform: rotate(-6deg);
  transition: transform 0.35s var(--ease-pop);
}
.stamp:hover { transform: rotate(4deg) scale(1.08); }

.top nav {
  display: flex;
  gap: clamp(18px, 3vw, 36px);
  padding: 8px 18px;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(6px);
  border-radius: 999px;
}
.top nav a {
  position: relative;
  font-size: 15px;
  text-decoration: none;
  color: var(--ink-soft);
  transition: color 0.2s;
}
.top nav a::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: 2px;
  height: 7px;
  background: var(--accent);
  opacity: 0.85;
  transform: scaleX(0) skewX(-12deg);
  transform-origin: left;
  transition: transform 0.3s var(--ease-out);
  z-index: -1;
}
.top nav a:hover { color: var(--ink); }
.top nav a:hover::after { transform: scaleX(1) skewX(-12deg); }

/* ---------- 通用漫画格 ---------- */
.panel {
  position: relative;
  border: var(--stroke) solid var(--ink);
  background: var(--paper);
  box-shadow: var(--shadow);
}

main { padding: 0 var(--gutter); }

/* ---------- 首屏 ---------- */
.hero {
  min-height: 100svh;
  max-width: 1420px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  align-items: center;
  gap: clamp(40px, 8vw, 120px);
  padding: 120px 0 80px;
}

.kicker {
  margin: 0 0 28px;
  font-size: 13px;
  letter-spacing: 0.3em;
  color: var(--ink-faint);
}

.title { margin: 0; line-height: 1; }
.title-small {
  display: block;
  font-size: clamp(28px, 4vw, 44px);
  margin-bottom: 14px;
  color: var(--ink-soft);
}
.title-big {
  display: block;
  font-size: clamp(64px, 11vw, 150px);
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.title-big .ch {
  display: inline-block;
  animation: pop-in 0.7s var(--ease-pop) both;
  animation-delay: calc(0.25s + var(--i) * 0.11s);
}
.title-big .ch:nth-child(2n) { --tilt: 4deg; }
.title-big .ch:nth-child(2n + 1) { --tilt: -3deg; }

@keyframes pop-in {
  0% { opacity: 0; transform: translateY(40%) scale(0.4) rotate(calc(var(--tilt, 0deg) * -4)); }
  60% { opacity: 1; }
  100% { opacity: 1; transform: none; }
}

.bubble {
  position: relative;
  display: inline-block;
  margin: 56px 0 0 8px;
  padding: 18px 28px;
  border: 2.5px solid var(--ink);
  border-radius: 40px / 32px;
  background: var(--paper);
  font-size: clamp(15px, 1.4vw, 17px);
  line-height: 1.75;
  animation: bubble-in 0.6s var(--ease-pop) 1s both;
}
.bubble::before,
.bubble::after {
  content: "";
  position: absolute;
  left: 46px;
  clip-path: polygon(0 100%, 100% 100%, 20% 0);
}
.bubble::before {
  top: -24px;
  width: 30px;
  height: 25px;
  background: var(--ink);
}
.bubble::after {
  top: -18px;
  left: 49.5px;
  width: 22px;
  height: 20px;
  background: var(--paper);
}

@keyframes bubble-in {
  from { opacity: 0; transform: scale(0.6) translateY(10px); }
  to { opacity: 1; transform: none; }
}

.scroll-hint {
  display: block;
  width: max-content;
  margin-top: 72px;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--ink-faint);
  text-decoration: none;
  animation: fade 0.6s ease 1.6s both;
}
.scroll-hint span {
  display: inline-block;
  animation: bob 1.6s ease-in-out infinite;
}
@keyframes bob { 50% { transform: translateY(5px); } }
@keyframes fade { from { opacity: 0; } }

/* 首屏右侧的大格子：集中线 + 网点 + 拟声词 */
.hero-panel {
  margin: 0;
  aspect-ratio: 4 / 4.6;
  overflow: hidden;
  transform: rotate(2.5deg);
  animation: slam 0.75s var(--ease-pop) 0.1s both;
}

.chapter {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 3;
  padding: 4px 12px;
  background: var(--ink);
  color: var(--paper);
  font-size: 15px;
}

.focus {
  position: absolute;
  inset: -40%;
  background: repeating-conic-gradient(from 0deg at 50% 50%, var(--ink) 0deg 0.9deg, transparent 0.9deg 6.2deg);
  -webkit-mask: radial-gradient(circle at 50% 50%, transparent 17%, #000 46%);
  mask: radial-gradient(circle at 50% 50%, transparent 17%, #000 46%);
  opacity: 0.9;
  animation: flicker 0.24s steps(1) infinite;
}
@keyframes flicker {
  0% { transform: rotate(0deg); }
  50% { transform: rotate(2.4deg) scale(1.02); }
}

.tone {
  position: absolute;
  inset: 0;
  background: radial-gradient(var(--ink) 1.3px, transparent 1.6px) 0 0 / 9px 9px;
  -webkit-mask: linear-gradient(160deg, transparent 45%, #000 100%);
  mask: linear-gradient(160deg, transparent 45%, #000 100%);
  opacity: 0.35;
}

.sfx {
  position: absolute;
  z-index: 2;
  color: var(--paper);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--ink);
  line-height: 1;
}
/* 猫说话的拟声词：由 cat.js 更新文字 */
.say {
  top: 8%;
  right: 7%;
  font-size: clamp(34px, 4.2vw, 58px);
  color: var(--paper);
  opacity: 0;
  pointer-events: none;
  transform: rotate(9deg);
}
.say[data-tone="red"] { color: var(--accent); }
.say.pop { animation: say-pop 1.5s var(--ease-pop) forwards; }
.say.hold { animation: say-hold 0.35s var(--ease-pop) forwards, shake 0.5s ease-in-out 0.35s infinite; }
@keyframes say-pop {
  0% { opacity: 0; scale: 2.2; }
  18% { opacity: 1; scale: 1; }
  78% { opacity: 1; }
  100% { opacity: 0; translate: 0 -10px; }
}
@keyframes say-hold {
  0% { opacity: 0; scale: 2.2; }
  100% { opacity: 1; scale: 1; }
}

/* 动画片段版的猫（验证中）：贴在画框底部居中 */
.kitty-clips {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}
/* 猫身体所在的大致区域，用来判断鼠标是不是在"摸"它 */
.cat-zone {
  position: absolute;
  left: 14%;
  right: 42%;
  top: 44%;
  bottom: 0;
  pointer-events: auto;
  cursor: grab;
}

.kitty-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: bottom center;
  opacity: 0;
  transition: opacity 0.24s linear;
}
/* 验证期间先把拼接版藏起来，只留抓痕层 */
.kitty-sit, .kitty-nap { display: none; }

/* ---------- 互动猫（动画片段版） ---------- */
.svg-defs { position: absolute; width: 0; height: 0; }
.loaf g { transform-box: fill-box; }

/* 猫抓印 */
.scratch path { stroke-dasharray: 1; stroke-dashoffset: 1; animation: scratch-draw 0.16s ease-out forwards; }
.scratch.fading { opacity: 0; transition: opacity 0.8s ease; }
@keyframes scratch-draw { to { stroke-dashoffset: 0; } }

@keyframes sfx-hit {
  0% { opacity: 0; scale: 2.6; }
  100% { opacity: 1; scale: 1; }
}
@keyframes shake {
  0%, 86%, 100% { translate: 0 0; }
  88% { translate: -4px 2px; }
  90% { translate: 4px -2px; }
  92% { translate: -3px -1px; }
  94% { translate: 2px 2px; }
}
@keyframes slam {
  0% { opacity: 0; transform: scale(1.18) rotate(-4deg); }
  70% { opacity: 1; }
  100% { opacity: 1; }
}

/* ---------- 章节 ---------- */
.section {
  max-width: 1080px;
  margin: 0 auto;
  padding-top: var(--section-gap);
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 18px;
  margin-bottom: clamp(40px, 6vw, 72px);
}
.ep {
  font-size: 15px;
  color: var(--accent);
  letter-spacing: 0.1em;
}
.section-head h2 {
  position: relative;
  margin: 0;
  font-size: clamp(40px, 6vw, 68px);
  line-height: 1;
}
.section-head h2::after {
  content: "";
  position: absolute;
  left: -4px;
  right: -10px;
  bottom: -10px;
  height: 10px;
  background: var(--ink);
  clip-path: polygon(0 40%, 100% 0, 97% 100%, 3% 80%);
}

/* 滚动进入时"拍"进画面 */
[data-slam] {
  opacity: 0;
  transform: translateY(24px) scale(1.06) rotate(var(--rot, 0deg));
}
[data-slam].in {
  animation: slam-in 0.6s var(--ease-pop) both;
  animation-delay: var(--delay, 0s);
}
@keyframes slam-in {
  0% { opacity: 0; transform: translateY(24px) scale(1.08) rotate(calc(var(--rot, 0deg) - 3deg)); }
  55% { opacity: 1; transform: translateY(-3px) scale(0.99) rotate(var(--rot, 0deg)); }
  70% { transform: translateX(-3px) rotate(var(--rot, 0deg)); }
  82% { transform: translateX(2px) rotate(var(--rot, 0deg)); }
  100% { opacity: 1; transform: rotate(var(--rot, 0deg)); }
}

/* ---------- 工具 ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: clamp(28px, 4vw, 48px);
  align-items: start;
}

.tool {
  display: block;
  text-decoration: none;
  padding: clamp(22px, 3vw, 34px);
  transition: transform 0.35s var(--ease-pop), box-shadow 0.35s var(--ease-pop);
}
.tool-main { --rot: -1.2deg; }
.tool-next { --rot: 1.8deg; --delay: 0.12s; margin-top: 64px; }

.tool-main:hover,
.tool-main:focus-visible {
  transform: rotate(0.6deg) translate(-4px, -4px) !important;
  box-shadow: var(--shadow-lift);
}

.poke {
  position: absolute;
  top: -26px;
  right: -18px;
  z-index: 2;
  padding: 10px 16px 8px;
  background: var(--accent);
  color: var(--paper);
  font-size: 24px;
  clip-path: polygon(50% 0, 62% 24%, 92% 10%, 80% 40%, 100% 55%, 76% 66%, 86% 96%, 56% 80%, 40% 100%, 34% 76%, 4% 88%, 18% 60%, 0 40%, 24% 32%, 16% 4%, 42% 20%);
  width: 92px;
  height: 92px;
  display: grid;
  place-items: center;
  transform: scale(0) rotate(-30deg);
  transition: transform 0.35s var(--ease-pop);
}
.tool-main:hover .poke,
.tool-main:focus-visible .poke { transform: scale(1) rotate(8deg); }

.mini-map {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-auto-rows: 22px;
  gap: 3px;
  padding: 6px;
  border: 2px solid var(--ink);
  background: var(--ink);
  margin-bottom: 26px;
}
.mini-map span {
  background: var(--flat);
  transition: background-color 0.5s ease;
}
.mini-map .up { background: var(--up); }
.mini-map .up2 { background: var(--up-soft); }
.mini-map .down { background: var(--down); }
.mini-map .down2 { background: var(--down-soft); }

.live {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--ink-soft);
}
.live i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse {
  50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 20%, transparent); }
}

.tool h3 {
  margin: 0 0 10px;
  font-size: clamp(30px, 3.4vw, 42px);
  line-height: 1.15;
}
.tool p { margin: 0; color: var(--ink-soft); }
.go {
  display: inline-block;
  margin-top: 22px;
  font-weight: 700;
  border-bottom: 3px solid var(--accent);
  transition: transform 0.25s var(--ease-out);
}
.tool-main:hover .go { transform: translateX(6px); }

.tool-next {
  border-style: dashed;
  box-shadow: none;
  background:
    radial-gradient(var(--ink-faint) 1px, transparent 1.3px) 0 0 / 8px 8px,
    var(--paper);
  text-align: center;
  padding-block: 40px 44px;
}
.tool-next h3 { color: var(--ink-soft); }
.nap {
  position: relative;
  width: min(100%, 240px);
  margin: 0 auto 14px;
}
.loaf {
  display: block;
  width: 100%;
  transform-origin: 50% 100%;
  will-change: transform;
  animation: breathe 3.2s ease-in-out infinite;
}
@keyframes breathe { 50% { transform: scale(1.01, 1.035); } }

.zzz {
  position: absolute;
  top: -18px;
  left: 18%;
  color: var(--ink-soft);
}
.zzz i {
  position: absolute;
  font-style: normal;
  opacity: 0;
  animation: zzz 3s ease-out infinite;
}
.zzz i:nth-child(1) { font-size: 26px; }
.zzz i:nth-child(2) { font-size: 20px; animation-delay: 1s; }
.zzz i:nth-child(3) { font-size: 15px; animation-delay: 2s; }
@keyframes zzz {
  0% { opacity: 0; transform: translate(0, 10px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-26px, -34px) rotate(-12deg); }
}

/* ---------- 已上线工具入口 ---------- */
.tool-directory {
  padding: clamp(22px, 3vw, 34px);
}
.tool-directory h3 {
  margin: 0 0 18px;
  font-size: clamp(28px, 3vw, 36px);
  line-height: 1.2;
}
.tool-entries {
  list-style: none;
  margin: 0;
  padding: 0;
}
.tool-entries li + li { border-top: 1px solid var(--flat); }
.tool-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 100px;
  padding: 16px 0;
  text-decoration: none;
}
.entry-copy { display: grid; min-width: 0; gap: 2px; }
.entry-copy strong { font-size: 19px; line-height: 1.4; }
.entry-copy > span { font-size: 14px; color: var(--ink-soft); }
.entry-copy small { font-size: 12px; color: var(--ink-soft); overflow-wrap: anywhere; }
.entry-arrow {
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--accent);
  transition: transform 0.2s var(--ease-out);
}
.tool-entry:hover strong,
.tool-entry:focus-visible strong { text-decoration: underline; text-decoration-color: var(--accent); text-underline-offset: 5px; }
.tool-entry:hover .entry-arrow,
.tool-entry:focus-visible .entry-arrow { transform: translate(3px, -3px); }

/* ---------- 笔记 ---------- */
.notes {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: var(--stroke) solid var(--ink);
}
.note { border-bottom: 1.5px solid var(--ink); }
.note:nth-child(2) { --delay: 0.08s; }
.note:nth-child(3) { --delay: 0.16s; }

.note summary {
  display: grid;
  grid-template-columns: 120px 1fr 32px;
  align-items: center;
  gap: 24px;
  padding: 30px 4px;
  cursor: pointer;
  list-style: none;
}
.note summary::-webkit-details-marker { display: none; }

.note time {
  font: 13px var(--font-mono);
  color: var(--ink-faint);
}
.note-title {
  font-size: clamp(17px, 1.8vw, 21px);
  font-weight: 700;
  background: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 28%, transparent) 62%) no-repeat 0 0 / 0% 100%;
  transition: background-size 0.4s var(--ease-out);
}
.note summary:hover .note-title { background-size: 100% 100%; }

.plus {
  font-size: 26px;
  line-height: 1;
  justify-self: end;
  transition: transform 0.35s var(--ease-pop);
}
.note details[open] .plus { transform: rotate(135deg); color: var(--accent); }

.note-body {
  position: relative;
  margin: 0 0 34px 144px;
  padding: 22px 26px;
  border: 2.5px solid var(--ink);
  border-radius: 6px;
  box-shadow: 5px 5px 0 var(--ink);
  color: var(--ink-soft);
  animation: bubble-in 0.4s var(--ease-pop) both;
}
.note-body p { margin: 0 0 12px; }
.note-body p:last-child { margin-bottom: 0; }

/* ---------- 关于 ---------- */
.about-text {
  max-width: 34em;
  margin: 0;
  font-size: clamp(18px, 2vw, 22px);
  line-height: 1.9;
}

/* ---------- 页脚 ---------- */
.foot {
  max-width: 1080px;
  margin: var(--section-gap) auto 0;
  padding: 40px var(--gutter) 56px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 28px;
  font-size: 13px;
  color: var(--ink-faint);
}
.foot a { text-decoration: none; }
.foot a:hover { color: var(--ink); }
.end { margin-left: auto; font-size: 20px; color: var(--ink); }

/* ---------- 点击拟声词 ---------- */
.burst {
  position: fixed;
  z-index: 50;
  pointer-events: none;
  width: 96px;
  height: 96px;
  margin: -48px 0 0 -48px;
  display: grid;
  place-items: center;
  font-size: 26px;
  color: var(--paper);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  animation: burst 0.7s var(--ease-pop) forwards;
}
.burst::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--ink);
  clip-path: polygon(50% 0, 60% 30%, 95% 15%, 72% 45%, 100% 62%, 66% 64%, 78% 100%, 50% 74%, 22% 100%, 34% 64%, 0 62%, 28% 45%, 5% 15%, 40% 30%);
}
.burst.red::before { background: var(--accent); }
@keyframes burst {
  0% { opacity: 0; transform: scale(0.2) rotate(var(--r)); }
  35% { opacity: 1; transform: scale(1.1) rotate(var(--r)); }
  70% { opacity: 1; transform: scale(1) rotate(var(--r)); }
  100% { opacity: 0; transform: scale(1.15) translateY(-14px) rotate(var(--r)); }
}

/* ---------- 窄屏 ---------- */
@media (max-width: 820px) {
  .hero {
    grid-template-columns: 1fr;
    gap: 64px;
    padding-top: 110px;
  }
  .hero-panel { width: min(100%, 380px); justify-self: center; }
  .tool-grid { grid-template-columns: 1fr; }
  .tool-next { margin-top: 0; }
  .note summary { grid-template-columns: 1fr 28px; gap: 6px 16px; }
  .note time { grid-column: 1 / -1; }
  .note-body { margin-left: 0; }
  .wide-only { display: none; }
}

@media (max-width: 420px) {
  .title-big { font-size: 58px; }
  .top nav { padding: 6px 14px; gap: 16px; }
  .poke { right: -8px; }
}

/* ---------- 减少动态效果 ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    animation-delay: 0s !important;
    transition-duration: 0.01ms !important;
  }
  html { scroll-behavior: auto; }
  [data-slam] { opacity: 1; transform: rotate(var(--rot, 0deg)); }
  .zzz i:first-child { opacity: 1; }
}
