@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Thai:wght@300;400;500;700&display=swap');

:root {
  --ink: #0d0d0d;
  --ink-2: #141019;
  --vio: #8000ff;
  --mag: #ff00ff;
  --grn: #3dff9e;
  --tx: #e9e4f3;
  --body: #cfc9dd;
  --dim: #a49bb6;
  --line: #2a2236;
  --mw: 1120px;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html {
  background: var(--ink);
  color: var(--tx);
  font-size: 17px;
  line-height: 1.7;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Noto Sans Thai", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--ink);
  color: var(--tx);
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(255, 255, 255, .035) 0 1px, transparent 1px 3px);
}

a { color: inherit; }

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

main section[id] { scroll-margin-top: 92px; }

.skip {
  position: absolute;
  left: -999px;
  top: 0;
  z-index: 70;
  padding: 12px 16px;
  background: var(--mag);
  color: var(--ink);
  font: 500 13px/1 var(--mono);
  letter-spacing: .2em;
  text-decoration: none;
}
.skip:focus { left: 8px; top: 8px; }

/* ===== 顶部 HUD ===== */
.hud {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 13, 13, .94);
  border-bottom: 1px solid var(--vio);
}

.tape {
  margin: 0;
  padding: 5px 16px;
  border-bottom: 1px solid rgba(255, 0, 255, .28);
  color: var(--mag);
  font: 500 11px/1.5 var(--mono);
  letter-spacing: .32em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 0 10px rgba(255, 0, 255, .6);
}

.hud-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 10px;
}

.mark {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin-left: 12px;
  border: 1px solid var(--line);
  background: #100d16;
  text-decoration: none;
}
.mark:hover { border-color: var(--mag); }

.mark-img { width: 26px; height: 26px; object-fit: contain; }

.mark-glyph {
  width: 15px;
  height: 15px;
  border: 2px solid var(--mag);
  transform: skewX(-14deg);
  background: rgba(128, 0, 255, .35);
}

.nav { flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: thin; }
.nav ol {
  display: flex;
  gap: 2px;
  margin: 0;
  padding: 0 6px;
  list-style: none;
}
.nav a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid transparent;
  color: var(--dim);
  font: 500 13px/1 var(--mono);
  letter-spacing: .06em;
  text-decoration: none;
  white-space: nowrap;
}
.nav a:hover,
.nav a:focus-visible {
  color: #fff;
  border-color: var(--mag);
  background: rgba(255, 0, 255, .08);
  text-shadow: 0 0 9px var(--mag);
}

/* ===== Hero ===== */
.hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 20px;
  min-height: 100vh;
  min-height: 100svh;
  padding: 118px 22px 62px;
  text-align: right;
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(120% 80% at 100% 100%, rgba(128, 0, 255, .3), transparent 62%),
    radial-gradient(90% 60% at 0% 0%, rgba(255, 0, 255, .12), transparent 70%),
    var(--ink);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(128, 0, 255, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(128, 0, 255, .09) 1px, transparent 1px);
  background-size: 74px 74px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .85), transparent 78%);
  -webkit-mask-image: linear-gradient(to bottom, rgba(0, 0, 0, .85), transparent 78%);
}

.badge {
  position: absolute;
  left: 22px;
  top: 104px;
  padding: 6px 12px;
  border: 1px solid var(--mag);
  background: #0b0b10;
  color: var(--mag);
  font: 500 11px/1.4 var(--mono);
  letter-spacing: .3em;
  text-shadow: 0 0 10px rgba(255, 0, 255, .7);
}

.hero h1 {
  position: relative;
  margin: 0;
  max-width: 15ch;
  margin-left: auto;
  font-size: clamp(2.2rem, 8vw, 5.2rem);
  line-height: 1.06;
  font-weight: 700;
  letter-spacing: -.02em;
  color: #fff;
  text-shadow: 0 0 16px rgba(128, 0, 255, .85), 0 0 42px rgba(255, 0, 255, .35);
}

.hero h1::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: var(--mag);
  opacity: .5;
  clip-path: inset(0 0 54% 0);
  transform: translateX(-3px);
  animation: glitch 6s steps(1) infinite;
  pointer-events: none;
}

@keyframes glitch {
  0%, 90%, 100% { transform: translateX(-3px); opacity: .42; }
  92% { transform: translate(4px, -2px) skewX(-7deg); opacity: .8; }
  95% { transform: translate(-6px, 1px); opacity: .65; }
  97% { transform: translate(2px, 2px) skewX(5deg); opacity: .75; }
}

.lede {
  position: relative;
  margin: 0 0 4px auto;
  max-width: 46ch;
  color: var(--dim);
  font-size: 1.02rem;
  line-height: 1.75;
}

/* ===== 正文舞台 ===== */
.stage {
  display: grid;
  grid-template-columns: 228px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
  max-width: var(--mw);
  margin: 0 auto;
  padding: 58px 22px 78px;
}

.rail {
  position: sticky;
  top: 100px;
  padding-left: 16px;
  border-left: 2px solid var(--vio);
}

.rail small {
  display: block;
  margin-bottom: 6px;
  color: var(--mag);
  font: 500 11px/1.4 var(--mono);
  letter-spacing: .3em;
}

.rail h2 {
  margin: 0 0 12px;
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: .06em;
  color: #fff;
  text-shadow: 0 0 12px rgba(128, 0, 255, .7);
}

.rail ol {
  counter-reset: rail;
  margin: 0;
  padding: 0;
  list-style: none;
}

.rail li {
  counter-increment: rail;
  border-bottom: 1px solid var(--line);
}

.rail a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: var(--dim);
  font-size: .94rem;
  text-decoration: none;
}
.rail a::before {
  content: counter(rail, decimal-leading-zero);
  color: var(--vio);
  font: 500 11px/1 var(--mono);
  letter-spacing: .1em;
}
.rail a:hover { color: #fff; background: rgba(128, 0, 255, .12); }

.doc { min-width: 0; }

.doc > section {
  padding: 46px 0;
  border-top: 1px dashed #241d30;
}
.doc > section:first-child { border-top: 0; padding-top: 0; }

.doc h2 {
  margin: 0 0 18px;
  font-size: clamp(1.55rem, 3.6vw, 2.05rem);
  line-height: 1.24;
  color: #fff;
  letter-spacing: .01em;
  text-shadow: 0 0 14px rgba(128, 0, 255, .6);
}

.doc h3 {
  margin: 30px 0 12px;
  font-size: 1.22rem;
  line-height: 1.4;
  color: var(--mag);
}

.doc small {
  display: block;
  margin-bottom: 8px;
  color: var(--mag);
  font: 500 11px/1.4 var(--mono);
  letter-spacing: .28em;
}

.doc p { margin: 0 0 16px; color: var(--body); }
.doc strong { color: #fff; }
.doc a { color: var(--mag); text-underline-offset: 3px; }
.doc a:hover { color: #fff; }

.doc ul, .doc ol { margin: 0 0 18px; padding-left: 1.3em; color: var(--body); }
.doc li { margin: .4em 0; }

.doc figure {
  margin: 26px 0;
  padding: 8px;
  border: 1px solid var(--vio);
  background: #0b0b10;
}
.doc img { max-width: 100%; height: auto; border: 1px solid var(--line); }

.doc blockquote {
  margin: 26px 0;
  padding: 10px 0 10px 18px;
  border-left: 3px solid var(--mag);
  background: rgba(255, 0, 255, .05);
  color: var(--body);
}

.doc code {
  font-family: var(--mono);
  font-size: .92em;
  padding: .1em .4em;
  border: 1px solid var(--line);
  background: var(--ink-2);
  color: var(--grn);
}

.doc table { width: 100%; border-collapse: collapse; margin: 24px 0; font-size: .96rem; }
.doc th, .doc td { border: 1px solid var(--line); padding: 9px 11px; text-align: left; }
.doc th { background: rgba(128, 0, 255, .14); color: #fff; }

.doc hr { border: 0; border-top: 1px dashed var(--line); margin: 32px 0; }

/* ===== 页脚 ===== */
.foot {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr);
  gap: 26px 34px;
  max-width: var(--mw);
  margin: 0 auto;
  padding: 52px 22px 30px;
  border-top: 1px solid var(--vio);
  background: linear-gradient(to bottom, rgba(128, 0, 255, .09), transparent 70%);
}

.foot-brand {
  margin: 0;
  font-size: clamp(2rem, 7vw, 3.5rem);
  line-height: 1;
  font-weight: 700;
  letter-spacing: -.03em;
  color: #fff;
  text-shadow: 0 0 20px rgba(255, 0, 255, .45);
}

.foot-links {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  justify-content: flex-end;
  align-content: start;
}
.foot-links a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  color: var(--dim);
  font-size: .92rem;
  text-decoration: none;
}
.foot-links a:hover { color: var(--mag); }

.foot-copy {
  grid-column: 1 / -1;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: #6f6883;
  font: 400 12px/1.6 var(--mono);
  letter-spacing: .16em;
}

/* ===== 回到顶部 ===== */
.totop {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 55;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--grn);
  background: #0b0b10;
  color: var(--grn);
  font: 500 12px/1 var(--mono);
  letter-spacing: .2em;
  text-decoration: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease;
}
.totop.on { opacity: 1; pointer-events: auto; }

/* ===== 动效 ===== */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .5s ease, transform .5s ease; }
.reveal.is-in { opacity: 1; transform: none; }

/* ===== 响应式 ===== */
@media (max-width: 880px) {
  .stage {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 34px 18px 60px;
  }
  .doc { order: 1; }
  .rail {
    order: 2;
    position: static;
    margin-top: 40px;
    padding: 20px 0 0;
    border-left: 0;
    border-top: 1px solid var(--vio);
  }
  .rail ol { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 16px; }
  .hero { padding: 104px 18px 46px; }
  .badge { left: 18px; top: 88px; letter-spacing: .18em; }
  .foot { grid-template-columns: minmax(0, 1fr); padding: 40px 18px 26px; }
  .foot-links { justify-content: flex-start; }
}

@media (max-width: 420px) {
  .hud-row { padding-right: 6px; }
  .mark { width: 44px; height: 44px; margin-left: 8px; }
  .nav a { padding: 0 9px; font-size: 12.5px; }
  .rail ol { grid-template-columns: minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .hero h1::after { animation: none; }
  .reveal { opacity: 1; transform: none; transition: none; }
  .totop { transition: none; }
}

button[aria-expanded]{min-width:44px;min-height:44px}
