:root {
  --bg: #050505;
  --fg: #ffffff;
  --grey: #888888;
  --line: #222222;
  --wedge: #ffffff;
}

body.light-mode {
  --bg: #ffffff;
  --fg: #050505;
  --grey: #555555;
  --line: #e0e0e0;
  --wedge: #050505;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Arial Black', 'Microsoft YaHei', 'PingFang SC', sans-serif;
  transition: background .4s, color .4s;
  cursor: crosshair;
  min-height: 100svh;
}

a { color: inherit; }

/* ---------- 动态几何背景 ---------- */
.bg-layer {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.block-wedge {
  position: absolute;
  top: -20%;
  left: -20%;
  width: 90vw;
  height: 140vh;
  background: var(--wedge);
  opacity: .9;
  clip-path: polygon(0 0, 100% 0, 55% 100%, 0% 100%);
  animation: slideWedge 8s infinite alternate cubic-bezier(.76, 0, .24, 1);
  transition: background .4s;
}

.block-grey {
  position: absolute;
  top: 14%;
  right: 4%;
  width: 24vw;
  height: 24vw;
  background: var(--grey);
  opacity: .55;
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  animation: rotateTriangle 6s infinite alternate ease-in-out;
  transition: background .4s;
}

.line-rule {
  position: absolute;
  top: 52%;
  left: -10%;
  width: 120vw;
  height: 4px;
  background: var(--line);
  transform: rotate(-15deg);
  animation: lineGrow 4s infinite alternate;
  transition: background .4s;
}

@keyframes slideWedge {
  0% { transform: translateX(-5%) skewX(-5deg); }
  100% { transform: translateX(5%) skewX(5deg); }
}

@keyframes rotateTriangle {
  0% { transform: translateY(0) rotate(0deg); }
  100% { transform: translateY(20px) rotate(15deg); }
}

@keyframes lineGrow {
  0% { transform: rotate(-15deg) scaleX(.8); }
  100% { transform: rotate(-15deg) scaleX(1.1); }
}

/* ---------- 页面骨架 ---------- */
.page {
  position: relative;
  z-index: 10;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding: clamp(14px, 2vw, 28px) clamp(16px, 3vw, 40px);
}

.hud {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 18px;
  flex-wrap: wrap;
  padding-bottom: 1.1vh;
  border-bottom: 2px solid var(--fg);
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(11px, 1.05vw, 13px);
  letter-spacing: .08em;
  text-transform: uppercase;
}

.hud span { color: var(--grey); }
.hud b { color: var(--fg); font-weight: 700; }

.menu-trigger {
  color: var(--fg);
  font-weight: 700;
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

.menu-trigger:hover { border-bottom-color: var(--fg); }

.theme-toggle {
  background: var(--fg);
  color: var(--bg);
  border: none;
  padding: 6px 14px;
  font-family: 'Courier New', Courier, monospace;
  font-size: inherit;
  font-weight: 700;
  letter-spacing: .08em;
  cursor: pointer;
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%);
  transition: transform .2s, background .4s, color .4s;
}

.theme-toggle:hover { transform: translateY(-2px); }
.theme-toggle:active { transform: translateY(0); }

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

/* ---------- 面板与列表 ---------- */
.panel {
  position: absolute;
  left: clamp(16px, 3vw, 40px);
  top: 13vh;
  z-index: 20;
  width: min(48ch, 62vw);
}

.panel + .panel { top: auto; }

.label {
  display: block;
  margin-bottom: 12px;
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  letter-spacing: .28em;
  color: var(--grey);
}

.label-gap { margin-top: 18px; }

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chips a {
  padding: 6px 10px;
  border: 1px solid var(--line);
  font-family: 'Courier New', Courier, monospace;
  font-size: 10.5px;
  letter-spacing: .12em;
  text-decoration: none;
  color: var(--grey);
  transition: background .18s, color .18s, border-color .18s;
}

.chips a:hover,
.chips a:focus-visible {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

.list { list-style: none; }
.list li + li { margin-top: 2px; }

.list a {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 7px 10px;
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(12px, 1.15vw, 14px);
  letter-spacing: .04em;
  text-decoration: none;
  border-left: 2px solid var(--line);
  transition: background .18s, color .18s, border-color .18s, padding-left .18s;
}

.list a:hover,
.list a:focus-visible {
  background: var(--fg);
  color: var(--bg);
  border-left-color: var(--fg);
  padding-left: 16px;
}

.idx { color: var(--grey); font-size: .85em; }
.list a:hover .idx,
.list a:focus-visible .idx { color: var(--bg); opacity: .6; }

.name { font-weight: 700; text-transform: uppercase; }

.desc {
  color: var(--grey);
  font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
  font-size: .92em;
  letter-spacing: 0;
}

.list a:hover .desc,
.list a:focus-visible .desc { color: var(--bg); opacity: .78; }

/* ---------- 主标题 ---------- */
.title-group {
  position: absolute;
  left: 50%;
  bottom: 8vh;
  transform: translateX(-50%) skewX(-12deg);
  text-align: center;
  pointer-events: none;
  z-index: 15;
  white-space: nowrap;
}

.title,
.title-shadow {
  display: inline-block;
  font-size: 20vw;
  line-height: .72;
  letter-spacing: -.6vw;
  font-weight: 900;
}

.title {
  position: relative;
  z-index: 2;
  color: transparent;
  -webkit-text-stroke: 3px var(--fg);
}

.title-shadow {
  position: absolute;
  top: 14px;
  left: -22px;
  z-index: 1;
  color: var(--grey);
  opacity: .45;
}

/* ---------- 内页 ---------- */
.doc {
  flex: 1;
  padding: clamp(28px, 6vh, 64px) 0 clamp(24px, 5vh, 48px);
  max-width: 1000px;
}

.doc-head { margin-bottom: clamp(24px, 4vh, 40px); }

.doc-title {
  font-size: clamp(2rem, 6vw, 4.2rem);
  line-height: .95;
  letter-spacing: -.02em;
  font-weight: 900;
  text-transform: uppercase;
}

.doc-sub {
  margin-top: 14px;
  max-width: 52ch;
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(12px, 1.15vw, 14px);
  line-height: 1.8;
  color: var(--grey);
}

/* 卡片网格 */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: clamp(10px, 1.4vw, 18px);
  align-content: start;
}

.card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 6px;
  min-height: 118px;
  padding: clamp(16px, 2vw, 24px);
  text-decoration: none;
  color: var(--fg);
  background: rgba(120, 120, 120, .06);
  border-left: 4px solid var(--fg);
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 18px), calc(100% - 18px) 100%, 0 100%);
  transition: background .2s, color .2s, transform .2s, border-color .2s;
}

.card:hover,
.card:focus-visible {
  background: var(--fg);
  color: var(--bg);
  border-left-color: var(--grey);
  transform: translateX(8px);
}

.card-title {
  font-size: clamp(15px, 1.6vw, 20px);
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}

.card-desc {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(11px, 1.05vw, 13px);
  color: var(--grey);
}

.card:hover .card-desc,
.card:focus-visible .card-desc { color: var(--bg); opacity: .7; }

.card-arrow {
  position: absolute;
  right: 18px;
  bottom: 12px;
  font-size: 20px;
  opacity: .35;
  transition: opacity .2s, right .2s;
}

.card:hover .card-arrow,
.card:focus-visible .card-arrow { opacity: 1; right: 14px; }

/* 文章 */
.entry {
  padding: clamp(16px, 2.2vw, 24px) 0;
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(88px, 12ch) 1fr;
  gap: clamp(14px, 3vw, 40px);
}

.entry:last-of-type { border-bottom: 1px solid var(--line); }

.entry-key {
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--grey);
  padding-top: .45em;
}

.entry-body {
  font-size: clamp(1rem, 1.55vw, 1.28rem);
  line-height: 1.85;
  letter-spacing: .01em;
}

.entry-body em {
  font-style: normal;
  color: var(--grey);
}

.note {
  margin-top: clamp(20px, 3vh, 32px);
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  line-height: 1.9;
  letter-spacing: .06em;
  color: var(--grey);
}

.note a { border-bottom: 1px solid var(--line); text-decoration: none; }
.note a:hover { color: var(--fg); border-color: var(--fg); }

/* ---------- 页脚 ---------- */
.foot {
  position: relative;
  z-index: 20;
  margin-top: auto;
  padding-top: clamp(20px, 4vh, 36px);
  font-family: 'Courier New', Courier, monospace;
  font-size: 11px;
  letter-spacing: .12em;
  color: var(--grey);
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  justify-content: space-between;
  border-top: 1px solid var(--line);
}

.foot a { text-decoration: none; border-bottom: 1px solid var(--line); }
.foot a:hover { color: var(--fg); border-color: var(--fg); }

#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
}

:focus-visible {
  outline: 2px solid var(--fg);
  outline-offset: 2px;
}

/* ---------- 移动端 ---------- */
@media screen and (max-width: 899px) {
  .page { min-height: 100svh; }

  .stage {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-top: 9vh;
  }

  .panel {
    position: static;
    width: 100%;
    margin-bottom: 4vh;
  }

  .title-group {
    position: static;
    transform: skewX(-10deg);
    margin: 8vh 0 12vh;
    text-align: left;
  }

  .title,
  .title-shadow { font-size: 27vw; letter-spacing: -1vw; }
  .title-shadow { top: 8px; left: -12px; }

  .doc { padding-top: 22px; }

  .entry { grid-template-columns: 1fr; gap: 8px; }
  .entry-key { padding-top: 0; }

  .cards { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .block-wedge,
  .block-grey,
  .line-rule { animation: none; }
  * { transition-duration: .01ms !important; }
}
