:root {
  --rb-radius: 20px;       /* 彩虹外壳圆角 */
  --rb-thickness: 6px;     /* 彩虹边框厚度 */
  --content-max: 1600px;   /* 内容最大宽度 */
}

/* 页面基础样式 */
body {
  margin: 0;
  padding: 2rem 5%;
  background-color: #f8f9fb;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  justify-content: flex-start;
}

/* 容器居中，最大宽度限制 */
.article-wrapper {
  max-width: 1600px;
  width: 100%;
  margin: 0 auto;
  padding: 0;
}

/* 卡片样式 */
.article-card {
  background: white;
  border-radius: calc(var(--rb-radius) - var(--rb-thickness));
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
  animation: fadeInUp 0.6s ease forwards;
  opacity: 0;
}

/* 动画效果 */
@keyframes fadeInUp {
  from {
    transform: translateY(30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 标题样式 */
.article-title {
  font-size: 2rem;
  margin-bottom: 0.5rem;
  color: #222;
}

/* 日期样式 */
.article-date {
  font-size: 0.9rem;
  color: #888;
  margin-bottom: 1.5rem;
}

/* 正文内容 */
.article-content p {
  line-height: 1.7;
  margin-bottom: 1rem;
  color: #333;
  font-size: 1.05rem;
}

/* Enhance article typography */
.article-content h2, .article-content h3, .article-content h4 {
  color: #111;
  margin: 1.5rem 0 .75rem;
}
.article-content ul, .article-content ol { padding-left: 1.25rem; margin: .75rem 0 1rem; }
.article-content li { margin: .25rem 0; }
/* Deeply polished rainbow links */
@keyframes rainbow-shimmer { from { background-position: 0% 50%; } to { background-position: 200% 50%; } }
.article-content a, .toc a {
  position: relative;
  text-decoration: none;
  border-bottom: none;
  font-weight: 600; /* improve legibility */
  /* Full rainbow text for readability and style */
  color: transparent;
  background-image: linear-gradient(90deg,
    #ff0000, #ff7a00, #ffcc00, #33cc33, #3399ff, #7a33ff, #ff3399);
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  transition: background-position .6s ease, transform .2s ease;
}
.article-content a::after, .toc a::after { content: none; }
.article-content a::before, .toc a::before {
  content: '';
  position: absolute;
  left: -2px;
  right: -2px;
  bottom: -4px;
  height: 60%;
  background: radial-gradient(60% 60% at 50% 100%, rgba(0,255,65,.25), rgba(0,128,255,.18), rgba(128,0,255,.12), transparent 70%);
  filter: blur(10px);
  opacity: 0;
  transition: opacity .28s ease;
  pointer-events: none;
}
.article-content a:hover, .toc a:hover {
  transform: translateY(-1px);
  background-position: 100% 0; /* subtle motion across spectrum */
}
.article-content a:hover::after, .toc a:hover::after { content: none; }
.article-content a:hover::before, .toc a:hover::before { opacity: .6; }
.article-content a:focus-visible, .toc a:focus-visible { outline: 3px solid rgba(0, 128, 255, .35); outline-offset: 3px; border-radius: 6px; }
.article-content a:visited, .toc a:visited { color: #5a3fd4; }

/* Code blocks (light defaults) */
.article-content pre { background: #f6f8fa; color: #1c2025; border-radius: 10px; padding: 1rem; overflow: auto; box-shadow: none; border: 1px solid #e6e8eb; }
.article-content code { background: rgba(0,0,0,.06); padding: .2rem .4rem; border-radius: 6px; }
/* Mobile-friendly wide blocks used in pages */
.article-content pre.code-block { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 12px; border-radius: 8px; background: inherit; font-size: .95em; line-height: 1.5; margin: .75rem 0 1rem; }
.article-content pre.code-block code { white-space: pre; word-break: normal; }
/* Prism light overrides */
pre[class*="language-"], code[class*="language-"] { background: #f6f8fa !important; color: #1c2025 !important; }
:not(pre) > code[class*="language-"] { padding: .15rem .35rem; border-radius: 6px; border: 1px solid #e6e8eb; }
/* Remove unwanted glow/overlay on tokens */
pre[class*="language-"], code[class*="language-"],
pre[class*="language-"] *, code[class*="language-"] * {
  text-shadow: none !important;
  -webkit-text-stroke: 0 !important;
}

/* Blockquote */
.article-content blockquote { margin: 1.2rem 0; padding: .8rem 1rem; background: #f1f6ff; border-left: 4px solid #59a7ff; color: #2a405a; border-radius: 0 8px 8px 0; }

/* Images */
.article-content img { max-width: 100%; display: block; border-radius: 12px; box-shadow: 0 10px 24px rgba(0,0,0,.08); margin: 1rem auto; }

/* 响应式 */
@media (max-width: 600px) {
  .article-card {
    padding: 1.5rem 1rem;
  }

  .article-title {
    font-size: 1.5rem;
  }
}

/* 🌈 彩虹边框外壳 */
.rainbow-border {
  padding: var(--rb-thickness); /* 彩虹边框的厚度 */
  border-radius: var(--rb-radius);
  background: linear-gradient(270deg,
    #ff0000, #ff9900, #33cc33,
    #3399ff, #9933ff, #ff3399, #ff0000);
  background-size: 400% 400%;
  animation: rainbowFlow 8s linear infinite;

  display: block;
  width: 100%;
  max-width: var(--content-max);
  box-sizing: border-box;
  overflow: hidden;

  margin: 3rem auto; /* 页面居中 + 上下间距 */
  box-shadow: 0 0 20px rgba(255, 0, 150, 0.2); /* 可选：发光感 */
}

/* 🌈 彩虹流动动画 */
@keyframes rainbowFlow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

.back-button {
  position: fixed;
  top: 20px;
  left: 20px;
  font-size: 24px;
  text-decoration: none;
  color: #333;
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  transition: background 0.3s;
  z-index: 1000;
}

.back-button:hover {
  background: #f0f0f0;
}

/* 保证彩虹外壳内的卡片占满容器宽度，避免边缘长度异常 */
.rainbow-border > .article-card {
  display: block;
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

/* ======================
   Dark mode adaptations
   ====================== */
@media (prefers-color-scheme: dark) {
  body { background-color: #0a0a0a; color: #e8e8e8; }
  .article-card { background: #111213; box-shadow: 0 8px 24px rgba(0,0,0,0.6); }
  .article-title { color: #f2f2f2; }
  .article-content p { color: #d6d8db; }
  .article-content h2, .article-content h3, .article-content h4 { color: #f4f6f8; }
  /* Links: keep rainbow readable with subtle glow */
  .article-content a, .toc a { text-shadow: 0 0 8px rgba(255,255,255,0.08); }
  /* Code blocks dark */
  .article-content pre { background: #0f1011; color: #e9eef2; box-shadow: none; border: 1px solid rgba(255,255,255,.08); }
  pre[class*="language-"], code[class*="language-"] { background: #0f1011 !important; color: #e9eef2 !important; }
  :not(pre) > code[class*="language-"] { background: rgba(255,255,255,.06) !important; border: 1px solid rgba(255,255,255,.08); color: #f0f3f5 !important; }
  /* Ensure no glow in dark mode either */
  pre[class*="language-"], code[class*="language-"],
  pre[class*="language-"] *, code[class*="language-"] * { text-shadow: none !important; -webkit-text-stroke: 0 !important; }
  pre.line-numbers { position: relative; }
  pre.line-numbers .line-numbers-rows { border-right: 1px solid rgba(255,255,255,.08); background: transparent; }
  .line-numbers-rows > span:before { color: rgba(255,255,255,.35) !important; }
  .article-content code { background: rgba(255,255,255,.08); color: #f0f3f5; }
  /* Blockquote */
  .article-content blockquote { background: #0f1712; border-left: 4px solid #00c86b; color: #d1e7db; }
  /* Rainbow shell tweak */
  .rainbow-border { box-shadow: 0 0 26px rgba(0, 255, 150, 0.16); }
  /* Back button */
  .back-button { color: #e6e6e6; background: #1a1b1d; border: 1px solid #2a2c2f; box-shadow: 0 2px 8px rgba(0,0,0,0.45); }
  .back-button:hover { background: #232528; }
}
