/* ============================================================
   Jean Hu 主站样式（零构建，无任何外部依赖）
   配色体系：CSS 变量双套 token（亮 / 暗），面板卡片统一引用
   ============================================================ */

/* ---------- 主题 token：亮色（默认） ---------- */
:root {
  --ink: #29405a;                       /* 主文字 */
  --ink-soft: #48627e;                  /* 次级文字 */
  --accent: #2f6ea5;                    /* 强调色（链接/高亮） */
  --focus: #1d5c96;                     /* 焦点环 */
  --panel-bg: rgba(255, 255, 255, 0.55);          /* 毛玻璃面板底色 */
  --panel-bg-solid: rgba(255, 255, 255, 0.95);    /* 无毛玻璃支持时的回退底色 */
  --card-bg: rgba(255, 255, 255, 0.66);
  --card-bg-solid: rgba(255, 255, 255, 0.97);
  --panel-border: rgba(255, 255, 255, 0.7);
  --title-shadow: 0 2px 24px rgba(255, 255, 255, 0.65), 0 1px 3px rgba(41, 64, 90, 0.25);
}

/* ---------- 主题 token：暗色 ---------- */
[data-theme='dark'] {
  --ink: #eaf1fb;
  --ink-soft: #a7bcd6;
  --accent: #8ab8e8;
  --focus: #9cc5f5;
  --panel-bg: rgba(15, 27, 46, 0.55);
  --panel-bg-solid: rgba(13, 23, 40, 0.97);
  --card-bg: rgba(18, 32, 54, 0.66);
  --card-bg-solid: rgba(15, 27, 46, 0.97);
  --panel-border: rgba(146, 176, 214, 0.32);
  --title-shadow: 0 2px 26px rgba(6, 12, 24, 0.75), 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* 无 JS 回退：html 上没有 data-theme 时直接跟随系统暗色偏好 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --ink: #eaf1fb;
    --ink-soft: #a7bcd6;
    --accent: #8ab8e8;
    --focus: #9cc5f5;
    --panel-bg: rgba(15, 27, 46, 0.55);
    --panel-bg-solid: rgba(13, 23, 40, 0.97);
    --card-bg: rgba(18, 32, 54, 0.66);
    --card-bg-solid: rgba(15, 27, 46, 0.97);
    --panel-border: rgba(146, 176, 214, 0.32);
    --title-shadow: 0 2px 26px rgba(6, 12, 24, 0.75), 0 1px 3px rgba(0, 0, 0, 0.5);
  }
}

/* ---------- 基础 ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "PingFang SC",
    "Hiragino Sans GB", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: #f6e3c1; /* 背景图加载前的兜底底色（暖色，与黄昏主题一致；暗色下由变量覆盖） */
  min-height: 100svh;
}

[data-theme='dark'] body { background: #0e1a30; }

/* 键盘操作可见焦点态 */
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ---------- 主题切换渐变 ----------
   切换亮/暗时由 theme.js 在 <html> 上临时挂载 .theme-anim（约 1s 后移除），
   仅在切换瞬间为颜色相关属性启用缓慢过渡，让整体配色（含背景图交叉淡入）
   渐变过去而不是跳变；常驻的 hover 等交互动画不受影响。
   包一层 no-preference 媒体查询：减少动态偏好下即使类被挂载也不做过渡。 */
@media (prefers-reduced-motion: no-preference) {
  html.theme-anim body,
  html.theme-anim .glass-panel,
  html.theme-anim .card,
  html.theme-anim .card-name,
  html.theme-anim .card-desc,
  html.theme-anim .site-title,
  html.theme-anim .site-subtitle,
  html.theme-anim .lang-current,
  html.theme-anim .lang-option,
  html.theme-anim .theme-toggle,
  html.theme-anim .footer-mails a,
  html.theme-anim .footer-mails .dot,
  html.theme-anim .copyright,
  html.theme-anim #icp-beian,
  html.theme-anim .modal-backdrop,
  html.theme-anim .modal,
  html.theme-anim .modal-title,
  html.theme-anim .modal-addr,
  html.theme-anim .modal-note,
  html.theme-anim .modal-close {
    transition:
      background-color 0.9s ease,
      color 0.9s ease,
      border-color 0.9s ease,
      box-shadow 0.9s ease,
      text-shadow 0.9s ease;
  }
}

/* ---------- 全页星期背景 ---------- */
.page-bg {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;          /* 覆盖式裁切，配合 SVG 的 slice 语义 */
  object-position: center;
  z-index: -1;
  opacity: 1;
  transition: opacity 0.9s ease-in-out;  /* 昼夜图层交叉淡入，与主题颜色渐变同节奏 */
  user-select: none;
  pointer-events: none;
}
.page-bg--hidden { opacity: 0; }

/* ---------- 毛玻璃面板（顶/底共用） ---------- */
.glass-panel {
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(14px) saturate(1.5);
  backdrop-filter: blur(14px) saturate(1.5);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 28px rgba(10, 25, 47, 0.14);
  border-radius: 18px;
}

/* 回退：浏览器不支持 backdrop-filter 时用高不透明度纯色保证可读 */
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .glass-panel { background: var(--panel-bg-solid); }
}

/* ---------- 顶部面板 ---------- */
.top-panel {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: min(1060px, calc(100% - 28px));
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 8px 12px;
  flex-wrap: wrap;   /* 窄屏允许换行 */
}

/* 语言切换：左上角只显示当前语言本名，点开后在下方菜单中选择 */
.lang-switch {
  position: relative;   /* 下拉菜单的定位锚点 */
}

.lang-current {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: background 0.2s ease;
}
.lang-current:hover { background: rgba(127, 150, 175, 0.18); }

.lang-current .chev {
  width: 14px;
  height: 14px;
  transition: transform 0.2s ease;
}
/* 展开时箭头翻转 */
.lang-current[aria-expanded='true'] .chev { transform: rotate(180deg); }

.lang-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  margin: 0;
  padding: 6px;
  min-width: 170px;
  display: grid;
  gap: 2px;
  border-radius: 14px;
  z-index: 30;
  animation: menu-pop 0.16s ease;
}
.lang-menu[hidden] { display: none; }

.lang-option {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.92rem;
  line-height: 1.2;
  padding: 9px 12px 9px 32px;
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  position: relative;
  width: 100%;
  white-space: nowrap;
  transition: background 0.15s ease;
}
.lang-option:hover { background: rgba(127, 150, 175, 0.18); }

/* 当前语言：强调色 + 对勾 */
.lang-option[aria-checked='true'] { color: var(--accent); font-weight: 600; }
.lang-option[aria-checked='true']::before {
  content: '';
  position: absolute;
  left: 12px;
  top: 50%;
  width: 10px;
  height: 6px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: translateY(-70%) rotate(-45deg);
}

@keyframes menu-pop {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}

.theme-toggle {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--ink);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  transition: background 0.2s ease;
}
.theme-toggle:hover { background: rgba(127, 150, 175, 0.18); }

.theme-icon { width: 22px; height: 22px; }

/* 亮色显示月亮（点击去暗色），暗色显示太阳 */
.icon-moon { display: block; }
.icon-sun { display: none; }
[data-theme='dark'] .icon-moon { display: none; }
[data-theme='dark'] .icon-sun { display: block; }

/* ---------- 首屏 Hero ---------- */
.hero {
  min-height: 100svh;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 120px 20px 70px; /* 上方预留悬浮顶栏空间；底栏已随文档流，无需预留 */
}

.hero-inner { max-width: 960px; }

.site-title {
  margin: 0;
  font-size: clamp(2.4rem, 8vw, 5.6rem);
  font-weight: 700;
  letter-spacing: 0.05em;
  line-height: 1.15;
  text-shadow: var(--title-shadow);
  overflow-wrap: break-word;
}

.site-subtitle {
  margin: 18px 0 0;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  color: var(--ink-soft);
  letter-spacing: 0.12em;
  text-shadow: var(--title-shadow);
}

/* 解码动画的逐字 span：宽度预锁定，避免乱码字符宽度抖动 */
.dec-char {
  display: inline-block;
  text-align: center;
  vertical-align: bottom;
  white-space: pre;
}
.dec-char--pending { opacity: 0.82; }

/* ---------- 导航卡片区 ---------- */
.cards {
  max-width: 1060px;
  margin: 0 auto;
  padding: 8px 20px 46px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 18px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border-radius: 18px;
  background: var(--card-bg);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  backdrop-filter: blur(10px) saturate(1.3);
  border: 1px solid var(--panel-border);
  box-shadow: 0 6px 20px rgba(10, 25, 47, 0.10);
  color: var(--ink);
  text-decoration: none;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}
@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .card { background: var(--card-bg-solid); }
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 14px 34px rgba(10, 25, 47, 0.20);
}

/* 动作卡片（如 Minecraft 服务器）：按钮形态，视觉与链接卡片一致 */
button.card {
  appearance: none;
  font: inherit;
  text-align: left;
  width: 100%;
  cursor: pointer;
}

.card-icon {
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
  color: var(--accent);
}

.card-text { display: grid; gap: 4px; min-width: 0; }

.card-name { font-size: 1.06rem; font-weight: 600; }

.card-desc {
  font-size: 0.88rem;
  color: var(--ink-soft);
  line-height: 1.45;
}

/* ---------- 底部面板（随文档流，滚动到底部才可见） ---------- */
.bottom-panel {
  width: min(1060px, calc(100% - 28px));
  margin: 0 auto 26px;
  padding: 12px 18px;
}

.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px 18px;
  flex-wrap: wrap;
  font-size: 0.9rem;
}

.footer-mails {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.footer-mails a {
  color: var(--ink);
  text-decoration: none;
  border-bottom: 1px dashed var(--ink-soft);
  padding-bottom: 1px;
}
.footer-mails a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.footer-mails .dot { color: var(--ink-soft); }

.copyright { margin: 0; color: var(--ink-soft); }

/* ICP 主体备案号（备案已通过，随页脚常驻；见 index.html 底部链接） */
#icp-beian {
  display: inline-block;
  margin-top: 6px;
  color: var(--ink-soft);
  text-decoration: none;
  font-size: 0.85rem;
}
#icp-beian:hover { color: var(--accent); }

/* ---------- Minecraft 服务器信息弹窗 ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 18, 34, 0.45);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.modal-backdrop[hidden] { display: none; }

.modal {
  width: min(440px, 100%);
  padding: 26px 26px 22px;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(5, 12, 26, 0.35);
  animation: modal-pop 0.22s ease;
}
.modal:focus { outline: none; } /* 焦点环由可交互元素自身提供 */

.modal-title {
  margin: 0 0 14px;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-addr {
  display: flex;
  flex-wrap: wrap;      /* 窄屏时复制按钮换行，不挤压地址 */
  align-items: center;
  gap: 6px 8px;
  margin: 0 0 10px;
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);
  overflow-wrap: anywhere;
}

/* 服务器主机名：等宽字体更易读，也是复制按钮取值的节点 */
.mc-host {
  font-family: ui-monospace, "SF Mono", Consolas, "Courier New", monospace;
  font-size: 0.95em;
}

/* 复制按钮：造型与 modal-close 同源（胶囊、描边、悬停淡底） */
.mc-copy {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.88rem;
  padding: 5px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.mc-copy:hover { background: rgba(127, 150, 175, 0.18); }

/* 复制成功态：双图标切换（对勾呈强调色），文案由 JS 换为"已复制" */
.mc-copy .ic-check { display: none; }
.mc-copy.copied .ic-copy { display: none; }
.mc-copy.copied .ic-check { display: block; color: var(--accent); }

.modal-note {
  margin: 0 0 20px;
  color: var(--ink-soft);
  line-height: 1.7;
}

.modal-close {
  appearance: none;
  border: 1px solid var(--panel-border);
  background: transparent;
  color: var(--ink);
  font: inherit;
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.modal-close:hover { background: rgba(127, 150, 175, 0.18); }

@keyframes modal-pop {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

/* 弹窗打开时锁定页面滚动 */
body.modal-open { overflow: hidden; }

/* ---------- 响应式微调 ---------- */
@media (max-width: 560px) {
  .top-panel { top: 10px; }
  .lang-current { padding: 8px 10px; font-size: 0.86rem; }
  .lang-option { font-size: 0.86rem; }
  .hero { padding-top: 150px; }  /* 顶部面板换行后更高 */
  .cards { grid-template-columns: 1fr; } /* 窄屏卡片单列 */
}

/* ---------- 动效偏好：减少动态时关闭所有过渡 ---------- */
@media (prefers-reduced-motion: reduce) {
  .page-bg, .card, .lang-current, .lang-menu, .lang-option, .theme-toggle, .modal, .modal-close, .mc-copy { transition: none; animation: none; }
  .lang-current .chev { transition: none; }
  .card:hover { transform: none; }
}
