/* ============================================================
   SevenJohn · Apple MacBook Pro 旗舰设计风格系统样式表
   核心设计哲学：纯黑影院级画布、大字紧致字距、苹果高光胶囊按钮、
   Bento 双层柔光微反光卡片、极度克制的物理微交互
   ============================================================ */

/* 基础平滑滚动 */
html {
  scroll-behavior: smooth;
}

/* 字体排版系统：对标 Apple SF Pro Display / Inter */
body {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-variant-numeric: tabular-nums;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 苹果风格紧致大标题字距 */
h1, h2, h3 {
  text-wrap: balance;
  letter-spacing: -0.03em;
}

/* 苹果风格吸顶导航 (LocalNav Blur) */
.apple-nav {
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

/* 键盘无障碍跳转链接：默认视觉隐藏，Tab 聚焦时浮现 */
.skip-link {
  position: absolute;
  left: 1rem;
  top: -3rem;
  z-index: 50;
  padding: 0.5rem 1rem;
  border-radius: 9999px;
  background: #0071e3;
  color: #ffffff;
  font-size: 0.75rem;
  transition: top 0.18s ease-out;
}
.skip-link:focus {
  top: 0.75rem;
}

/* 键盘可访问性焦点环 */
:focus-visible {
  outline: 2px solid #0071e3;
  outline-offset: 3px;
  border-radius: 9999px;
}

/* 极简自定义滚动条 */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #3a3a3c;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #636366;
}

/* 苹果胶囊按钮高光微反光 (Apple Pill Buttons) */
.apple-btn-primary {
  background: #0071e3;
  color: #ffffff;
  border-radius: 9999px;
  font-weight: 500;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}
.apple-btn-primary:hover {
  background: #0077ed;
  transform: scale(1.015);
}
.apple-btn-primary:active {
  transform: scale(0.97);
}

.apple-btn-secondary {
  border-radius: 9999px;
  font-weight: 500;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.apple-btn-secondary:hover {
  transform: scale(1.015);
}
.apple-btn-secondary:active {
  transform: scale(0.97);
}

/* 苹果 Bento 卡片微质感 */
.apple-bento-card {
  border-radius: 1.5rem;
  transition: border-color 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.25s ease;
}
.dark .apple-bento-card {
  background: #161617;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 0 rgba(255, 255, 255, 0.04), 0 8px 30px rgba(0, 0, 0, 0.5);
}
.dark .apple-bento-card:hover {
  border-color: rgba(255, 255, 255, 0.18);
  transform: translateY(-2px);
}
html:not(.dark) .apple-bento-card {
  background: #ffffff;
  border: 1px solid #e5e5e7;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.04), 0 8px 24px -4px rgba(0, 0, 0, 0.08);
}
html:not(.dark) .apple-bento-card:hover {
  border-color: #d2d2d7;
  transform: translateY(-2px);
}

/* 苹果参数大数字 */
.apple-stat-number {
  letter-spacing: -0.04em;
  font-weight: 800;
  line-height: 1;
}

/* 弹窗遮罩与面板：入场更重（大位移 + 弹性超调 + 背景模糊渐起），层次明确 */
.modal-overlay {
  animation: apple-fade 0.32s cubic-bezier(0.16, 1, 0.3, 1), apple-blur 0.4s ease-out;
}
.modal-panel {
  animation: apple-sheet 0.46s cubic-bezier(0.22, 1.24, 0.32, 1);
}

@keyframes apple-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
/* 遮罩模糊渐起：页面在身后"聚焦"到弹窗上 */
@keyframes apple-blur {
  from { backdrop-filter: blur(2px); }
  to   { backdrop-filter: blur(12px); }
}
@keyframes apple-sheet {
  from { opacity: 0; transform: translateY(44px) scale(0.92); }
  to   { opacity: 1; transform: none; }
}

/* 弹窗关闭（加速退出，motion-craft Exit 规则：出比进快近一倍） */
.modal-overlay.is-closing {
  animation: apple-fade-out 0.24s cubic-bezier(0.4, 0, 0.2, 1) both;
}
.modal-overlay.is-closing .modal-panel {
  animation: apple-sheet-out 0.24s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes apple-fade-out {
  to { opacity: 0; backdrop-filter: blur(0px); }
}
@keyframes apple-sheet-out {
  to { opacity: 0; transform: translateY(26px) scale(0.94); }
}

/* ============================================================
   动效编排（对标 Apple 官网：减速入场、错峰浮现、导航滚动状态）
   仅动画 transform / opacity，保证合成器 60fps
   ============================================================ */

/* Hero 入场：首屏元素级联升起，纯 CSS 无 JS 依赖 */
@keyframes hero-rise {
  from { opacity: 0; transform: translateY(22px); }
  to   { opacity: 1; transform: none; }
}
.hero-anim {
  animation: hero-rise 0.55s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 80ms);
}

/* 滚动浮现：仅 JS 可用时预隐藏，无 JS 环境内容直出（大位移 + 模糊消散，存在感更强） */
.js .reveal {
  opacity: 0;
  transform: translateY(40px) scale(0.985);
  filter: blur(6px);
  transition: opacity 0.72s cubic-bezier(0.16, 1, 0.3, 1), transform 0.72s cubic-bezier(0.16, 1, 0.3, 1), filter 0.72s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: var(--reveal-delay, 0ms);
}
.js .reveal.is-visible {
  opacity: 1;
  transform: none;
  filter: blur(0);
}
/* 封面图随卡片浮现做 1.03 → 1 微缩放 */
.js .reveal .reveal-img {
  transform: scale(1.03);
  transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}
.js .reveal.is-visible .reveal-img {
  transform: scale(1);
}

/* 导航滚动状态：顶部无边框，下滑后浮现边框（Apple LocalNav 行为） */
header.site-header {
  transition: border-color 0.3s ease, background-color 0.3s ease;
}
header.site-header:not(.is-scrolled) {
  border-bottom-color: transparent;
}

/* 背景光粒子画布：固定铺满、置于页面内容之下、不拦截任何交互 */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

/* 移动端菜单：展开下拉（错峰子项浮起），收起上滑退出（motion-craft Exit 规则） */
#mobile-menu:not(.hidden) {
  animation: menu-drop 0.28s cubic-bezier(0.16, 1, 0.3, 1);
}
#mobile-menu:not(.hidden) > * {
  animation: menu-item 0.34s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(var(--i, 0) * 45ms);
}
#mobile-menu.is-closing {
  animation: menu-close 0.2s cubic-bezier(0.4, 0, 0.2, 1) both;
}
@keyframes menu-drop {
  from { opacity: 0; transform: translateY(-14px); }
}
@keyframes menu-item {
  from { opacity: 0; transform: translateY(-10px); }
}
@keyframes menu-close {
  to { opacity: 0; transform: translateY(-12px); }
}

/* ============================================================
   弹窗内容切换：方向性交叉过渡
   - next/prev：← → 翻章，旧内容向出方向滑出，新内容从反侧滑入 + 轻微模糊消散
   - fade：上下温和交替（切版本 / 重开规格详情）
   仅动画 transform / opacity / filter
   ============================================================ */
@keyframes content-out-next { to { opacity: 0; transform: translateX(-28px); } }
@keyframes content-out-prev { to { opacity: 0; transform: translateX(28px); } }
@keyframes content-out-fade { to { opacity: 0; transform: translateY(-12px); } }

@keyframes content-in-next {
  from { opacity: 0; transform: translateX(34px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes content-in-prev {
  from { opacity: 0; transform: translateX(-34px); filter: blur(5px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}
@keyframes content-in-fade {
  from { opacity: 0; transform: translateY(16px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: blur(0); }
}

/* 保留旧类名：首次渲染 / 兼容 */
.modal-content-in { animation: content-in-fade 0.3s cubic-bezier(0.16, 1, 0.3, 1); }

.content-out-next { animation: content-out-next 0.18s cubic-bezier(0.4, 0, 1, 1) forwards; }
.content-out-prev { animation: content-out-prev 0.18s cubic-bezier(0.4, 0, 1, 1) forwards; }
.content-out-fade { animation: content-out-fade 0.18s cubic-bezier(0.4, 0, 1, 1) forwards; }

.content-in-next { animation: content-in-next 0.36s cubic-bezier(0.16, 1, 0.3, 1); }
.content-in-prev { animation: content-in-prev 0.36s cubic-bezier(0.16, 1, 0.3, 1); }
.content-in-fade { animation: content-in-fade 0.34s cubic-bezier(0.16, 1, 0.3, 1); }

/* 代码块一键复制按钮（代码块固定深色底，明暗主题共用一套样式） */
.code-copy-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  padding: 0.2rem 0.6rem;
  border-radius: 0.375rem;
  font-size: 0.7rem;
  line-height: 1.2;
  color: #8b949e;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.code-copy-btn:hover {
  color: #f5f5f7;
  border-color: rgba(255, 255, 255, 0.3);
}

/* ⌘K 搜索命令面板 */
.search-item.is-selected {
  background: rgba(0, 113, 227, 0.08);
}
.dark .search-item.is-selected {
  background: rgba(41, 151, 255, 0.12);
}
.search-item mark {
  background: transparent;
  color: #0071e3;
  font-weight: 600;
}
.dark .search-item mark {
  color: #2997ff;
}

/* 长文自动目录 */
.toc-box {
  border: 1px solid rgba(0, 113, 227, 0.2);
  background: rgba(0, 113, 227, 0.05);
  border-radius: 0.75rem;
  padding: 0.7rem 1rem;
  margin-bottom: 1.25rem;
  font-size: 0.85rem;
}
.toc-box summary {
  cursor: pointer;
  font-weight: 600;
  color: #0071e3;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.toc-box summary::before {
  content: '▸';
  transition: transform 0.15s ease;
}
.toc-box[open] summary::before {
  transform: rotate(90deg);
}
.dark .toc-box summary {
  color: #2997ff;
}
.toc-link {
  display: block;
  padding: 0.3rem 0.5rem;
  border-radius: 0.375rem;
  color: inherit;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.toc-link:hover {
  background: rgba(0, 113, 227, 0.08);
  color: #0071e3;
}
.dark .toc-link:hover {
  color: #2997ff;
}

/* 全局轻提示 */
.sj-toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(8px);
  z-index: 70;
  padding: 0.55rem 1.1rem;
  border-radius: 9999px;
  background: rgba(29, 29, 31, 0.92);
  color: #f5f5f7;
  font-size: 0.8rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.sj-toast.is-show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* 本地文本批注（仅存访客本机） */
mark.sj-note {
  background: rgba(255, 214, 10, 0.32);
  color: inherit;
  border-bottom: 2px solid rgba(255, 214, 10, 0.85);
  cursor: pointer;
  padding: 0.05em 0;
}
.sj-popover {
  position: absolute;
  z-index: 20;
  width: 250px;
  padding: 0.75rem;
  border-radius: 0.75rem;
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 12px 32px -6px rgba(0, 0, 0, 0.25);
  animation: content-in 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
.dark .sj-popover {
  background: #2a2a2c;
  border-color: rgba(255, 255, 255, 0.12);
}
.sj-popover textarea {
  width: 100%;
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  background: transparent;
  color: inherit;
  font-size: 0.8rem;
  resize: none;
  outline: none;
}
.dark .sj-popover textarea {
  border-color: rgba(255, 255, 255, 0.15);
}
.sj-popover textarea:focus {
  border-color: #0071e3;
}
.sj-popover-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.4rem;
  margin-top: 0.5rem;
}
.sj-popover-actions button {
  padding: 0.25rem 0.7rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  cursor: pointer;
  transition: all 0.15s ease;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: transparent;
  color: inherit;
}
.dark .sj-popover-actions button {
  border-color: rgba(255, 255, 255, 0.15);
}
.sj-popover-actions button[data-act='save'],
.sj-popover-actions button[data-act='del'] {
  background: #0071e3;
  border-color: #0071e3;
  color: #ffffff;
}
.sj-popover-actions button[data-act='save']:hover,
.sj-popover-actions button[data-act='del']:hover {
  background: #0077ed;
}
.sj-note-view {
  font-size: 0.8rem;
  line-height: 1.5;
  color: inherit;
}

/* 情绪反馈按钮（本地版） */
.emotion-btn {
  border-color: rgba(0, 0, 0, 0.1);
  background: transparent;
  color: #86868b;
}
.dark .emotion-btn {
  border-color: rgba(255, 255, 255, 0.15);
}
.emotion-btn:hover {
  border-color: #0071e3;
  color: #0071e3;
}
.dark .emotion-btn:hover {
  color: #2997ff;
  border-color: #2997ff;
}
.emotion-btn.is-active {
  background: #0071e3;
  border-color: #0071e3;
  color: #ffffff;
}
.dark .emotion-btn.is-active {
  background: #0071e3;
  border-color: #0071e3;
}

/* 版本切换与阅读偏好小按钮（复用胶囊样式） */
.pref-btn {
  padding: 0.15rem 0.55rem;
  border-radius: 0.375rem;
  font-size: 0.7rem;
  color: #86868b;
  background: transparent;
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: all 0.15s ease;
}
.dark .pref-btn {
  border-color: rgba(255, 255, 255, 0.12);
}
.pref-btn:hover {
  color: #0071e3;
  border-color: #0071e3;
}
.pref-btn.is-active {
  background: #0071e3;
  color: #ffffff;
  border-color: #0071e3;
}

/* 尊重减少动效 */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .modal-overlay,
  .modal-panel {
    animation: none !important;
  }
  .apple-bento-card:hover,
  .apple-btn-primary:hover,
  .apple-btn-secondary:hover {
    transform: none !important;
  }
  .hero-anim {
    animation: none !important;
  }
  .js .reveal {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
  .js .reveal .reveal-img {
    transform: none !important;
    transition: none !important;
  }
  header.site-header {
    transition: none !important;
  }
  #particle-canvas {
    display: none;
  }
  #mobile-menu:not(.hidden),
  #mobile-menu.is-closing,
  .modal-content-in,
  .content-out-next,
  .content-out-prev,
  .content-out-fade,
  .content-in-next,
  .content-in-prev,
  .content-in-fade {
    animation: none !important;
  }
}

/* Markdown 文章详情排版微调 */
.markdown-body {
  line-height: 1.75;
  font-size: 1rem;
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  font-weight: 700;
  margin-top: 1.6rem;
  margin-bottom: 0.75rem;
  line-height: 1.3;
}
.markdown-body h1 { font-size: 1.75rem; border-bottom: 1px solid #334155; padding-bottom: 0.5rem; }
.markdown-body h2 { font-size: 1.35rem; }
.markdown-body h3 { font-size: 1.15rem; }
.markdown-body p {
  margin-bottom: 1rem;
}
.markdown-body ul, .markdown-body ol {
  padding-left: 1.25rem;
  margin-bottom: 1rem;
}
.markdown-body ul { list-style-type: disc; }
.markdown-body ol { list-style-type: decimal; }
.markdown-body li { margin-bottom: 0.35rem; }
.markdown-body blockquote {
  border-left: 3px solid #0071e3;
  padding-left: 0.875rem;
  margin: 1rem 0;
  color: #86868b;
  background-color: rgba(0, 113, 227, 0.06);
  border-radius: 0 0.375rem 0.375rem 0;
  padding: 0.6rem 0.875rem;
}
.markdown-body pre {
  border-radius: 0.75rem;
  margin: 1rem 0;
  padding: 0.875rem 1rem;
  background: #0d1117 !important;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.markdown-body code:not(pre code) {
  background-color: rgba(255, 255, 255, 0.1);
  color: #2997ff;
  padding: 0.15rem 0.35rem;
  border-radius: 0.25rem;
  font-size: 0.88em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
