/* ============================================================
   每日一言与壁纸 · 极简大气单页
   设计理念：少即是多 —— 全屏壁纸 + 毛玻璃卡片 + 微光细节
   ============================================================ */

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

html,
body {
  height: 100%;
}

/* ---- 兜底背景层：壁纸未加载/失败时呈现（微光渐变，不黑屏） ---- */
body {
  background:
    radial-gradient(
      1200px 800px at 50% 38%,
      rgba(255, 255, 255, 0.07),
      transparent 60%
    ),
    linear-gradient(150deg, #24262a 0%, #1f2022 48%, #2a2d31 100%);
  background-attachment: fixed;
  color: #FFFFFF;
  /* 全站文字采用楷体（含各系统回退：Windows KaiTi / macOS STKaiti / Linux AR PL UKai） */
  font-family: "KaiTi", "楷体", "STKaiti", "Kaiti SC", "AR PL UKai CN",
    "Noto Serif CJK SC", serif;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---- 背景层：必应 4K 壁纸（双层交替实现 crossfade） ---- */
#bg {
  position: fixed;
  inset: 0;
  z-index: 0;
}

.bg-layer {
  position: absolute;
  inset: 0;
  background-position: center;
  background-size: cover;
  background-repeat: no-repeat;
  opacity: 0;
  transition: opacity 0.8s ease-in-out;
  will-change: opacity;
}

.bg-layer.active {
  opacity: 1;
}

/* ---- 内容层：居中舞台 ---- */
.stage {
  position: relative;
  z-index: 1;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

/* ---- 一言卡片：毛玻璃 + 微光边框（放大 + 通透） ---- */
.card {
  position: relative;
  max-width: 800px;
  width: 100%;
  padding: 68px 76px 56px;
  text-align: left;
  border-radius: 22px;

  /* 通透毛玻璃：低透明度遮罩，壁纸若隐若现 */
  background: rgba(15, 17, 20, 0.02);
  -webkit-backdrop-filter: blur(12px) saturate(150%);
  backdrop-filter: blur(12px) saturate(150%);

  /* 极细微光边框 + 柔和阴影 */
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);

  transition:
    transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1),
    box-shadow 0.45s ease;

  /* 默认隐藏，等 body.ready 触发进入动画 */
  opacity: 0;
}

/* 顶部高光线：增强玻璃质感 */
.card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 12%;
  right: 12%;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.55),
    transparent
  );
  opacity: 0.6;
}

/* 卡片悬浮：轻微上浮 + 阴影加深 */
.card:hover {
  transform: translateY(-5px);
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

/* ---- 加载遮罩：壁纸就绪前覆盖全屏，避免黑屏闪现 ---- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 30px;
  background: linear-gradient(150deg, #191a1c 0%, #1F2022 48%, #232529 100%);
  opacity: 1;
  transition: opacity 0.8s ease-in-out, visibility 0.8s ease-in-out;
}

.loader.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* 四个粒子绕中心旋转：呼应 favicon 粒子主题 */
.loader-particles {
  position: relative;
  width: 72px;
  height: 72px;
  animation: loaderSpin 3.4s linear infinite;
}

.loader-particles i {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #E5E5E5;
  box-shadow: 0 0 16px rgba(229, 229, 229, 0.85);
  animation: loaderPulse 1.6s ease-in-out infinite;
}

.loader-particles i:nth-child(1) { top: 0; left: 31px; }
.loader-particles i:nth-child(2) { top: 31px; right: 0; animation-delay: 0.4s; }
.loader-particles i:nth-child(3) { bottom: 0; left: 31px; animation-delay: 0.8s; }
.loader-particles i:nth-child(4) { top: 31px; left: 0; animation-delay: 1.2s; }

.loader-text {
  font-size: 0.82rem;
  letter-spacing: 0.28em;
  text-indent: 0.28em; /* 抵消 letter-spacing 造成的视觉偏移 */
  color: rgba(229, 229, 229, 0.6);
  animation: loaderTextIn 1.4s ease-out 0.2s both;
}

@keyframes loaderSpin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes loaderPulse {
  0%,
  100% {
    opacity: 0.2;
  }
  50% {
    opacity: 1;
  }
}

@keyframes loaderTextIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- 进入动画：壁纸就绪后依次呈现 ---- */

/* 卡片默认隐藏，等 body.ready 触发入场（backwards：动画前保持起始帧） */
body.ready .card {
  opacity: 1;
  animation: cardReveal 1.1s cubic-bezier(0.22, 0.61, 0.36, 1) backwards;
}

/* 子元素分层上浮：引号 → 正文 → 刷新按钮 */
body.ready .quote-mark {
  animation: itemUp 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) 0.18s backwards;
}

body.ready .hitokoto {
  animation: itemUp 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) 0.32s backwards;
}

body.ready .refresh {
  animation: itemUp 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) 0.46s backwards;
}

/* 首次壁纸：模糊 → 清晰，电影感揭示 */
.bg-layer.enter {
  animation: bgReveal 2.8s ease-out both;
}

@keyframes cardReveal {
  from {
    opacity: 0;
    transform: translateY(36px) scale(0.98);
    filter: blur(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

@keyframes itemUp {
  from {
    opacity: 0;
    transform: translateY(26px);
    filter: blur(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes bgReveal {
  from {
    opacity: 0;
    transform: scale(1.06);
    filter: blur(18px) brightness(1.12);
  }
  to {
    opacity: 1;
    transform: scale(1.01);
    filter: blur(0) brightness(1);
  }
}

/* 全角引号：仪式感（楷体，中文书法韵味） */
.quote-mark {
  display: block;
  font-family: "KaiTi", "楷体", "STKaiti", "Kaiti SC", "AR PL UKai CN", serif;
  font-size: 4.2rem;
  line-height: 0.6;
  margin-bottom: 1.1rem;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 24px rgba(255, 255, 255, 0.18);
  user-select: none;
}

/* 一言正文：左对齐，首行空两格 */
.hitokoto {
  font-size: 1.75rem;
  line-height: 1.6;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #FFFFFF;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.35);
  min-height: 2.5em;
  text-align: left;
  text-indent: 2em;
}

/* 诗词内容 */
.hitokoto .quote-text {
  display: block;
}

/* 诗词作者信息：小字体，右对齐 */
.hitokoto .quote-info {
  display: block;
  margin-top: 0.5em;
  font-size: 0.5em;
  line-height: 1.6;
  font-weight: 400;
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
  text-indent: 0;
}

/* 一言切换动效 */
.hitokoto.pop {
  animation: fadeUp 0.6s ease-in-out;
}

/* 英文模式：双语卡片（content 英文主句 + note 中文译文） */
.hitokoto .quote-en,
.hitokoto .quote-zh {
  display: block;
}

.hitokoto .quote-zh {
  margin-top: 0.7em;
  font-size: 0.62em;
  line-height: 1.75;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.78);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ---- 刷新按钮：微型粒子图标（卡片底部居中） ---- */
.refresh {
  margin: 34px auto 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.07);
  color: #E5E5E5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0.45;
  transition:
    opacity 0.5s ease,
    transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.5s ease;
}

.refresh:hover,
.refresh:focus-visible {
  opacity: 1;
  transform: rotate(90deg);
  background: rgba(255, 255, 255, 0.14);
}

.refresh:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 3px;
}

.refresh:active {
  transform: rotate(90deg) scale(0.92);
}

.refresh-icon {
  width: 20px;
  height: 20px;
  animation: particlesSpin 14s linear infinite;
}

/* 粒子自转：静止时也有微光呼吸感 */
@keyframes particlesSpin {
  to {
    transform: rotate(360deg);
  }
}

/* ---- 交互层：壁纸信息角标（右下角，含低调刷新按钮） ---- */
.credit {
  position: fixed;
  right: 22px;
  bottom: 18px;
  z-index: 10;
  max-width: min(420px, calc(100vw - 44px));
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  color: rgba(229, 229, 229, 0.55);
  cursor: default;
  user-select: none;
  transition: color 0.5s ease;
}

.credit:hover,
.credit:focus-visible {
  color: rgba(255, 255, 255, 0.92);
}

/* 壁纸刷新按钮：小巧低调，但保持可见可寻 */
.wallpaper-refresh {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.3);
  background: rgba(255, 255, 255, 0.09);
  color: #E5E5E5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
  opacity: 0.6;
  transition:
    opacity 0.5s ease,
    transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1),
    background 0.5s ease;
}

.wallpaper-refresh:hover,
.wallpaper-refresh:focus-visible {
  opacity: 1;
  transform: rotate(180deg);
  background: rgba(255, 255, 255, 0.2);
}

.wallpaper-refresh:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 3px;
}

/* 加载中：缓慢自转提示 */
.wallpaper-refresh.loading .wallpaper-refresh-icon {
  animation: spinSlow 1.1s linear infinite;
}

.wallpaper-refresh-icon {
  width: 13px;
  height: 13px;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes spinSlow {
  to {
    transform: rotate(360deg);
  }
}

/* 悬浮弹出的标题与故事 */
.credit-pop {
  position: absolute;
  right: 0;
  bottom: calc(100% + 12px);
  width: max-content;
  max-width: min(320px, calc(100vw - 60px));
  padding: 12px 16px;
  text-align: left;
  border-radius: 12px;
  background: rgba(15, 17, 20, 0.72);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition:
    opacity 0.45s ease,
    transform 0.45s cubic-bezier(0.22, 0.61, 0.36, 1);
}

.credit:hover .credit-pop,
.credit:focus-visible .credit-pop {
  opacity: 1;
  transform: translateY(0);
}

.credit-pop-title {
  display: block;
  font-size: 0.86rem;
  font-weight: 600;
  color: #FFFFFF;
}

.credit-pop-desc {
  display: block;
  margin-top: 5px;
  font-size: 0.76rem;
  line-height: 1.55;
  color: rgba(229, 229, 229, 0.78);
}

/* ---- 语言切换：右上角胶囊按钮（中文一言 / 英文每日一句） ---- */
.lang-switch {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 10;
  min-width: 46px;
  height: 30px;
  padding: 0 13px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #E5E5E5;
  font-family: inherit;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-indent: 0.08em; /* 抵消 letter-spacing 视觉偏移 */
  cursor: pointer;
  opacity: 0.6;
  transition:
    opacity 0.5s ease,
    background 0.5s ease,
    transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.lang-switch:hover,
.lang-switch:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.16);
}

.lang-switch:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.5);
  outline-offset: 3px;
}

.lang-switch:active {
  transform: scale(0.92);
}

/* ---- 备案信息：底部中央，极简低调 ---- */
.beian {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 14px;
  z-index: 10;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: rgba(229, 229, 229, 0.38);
  transition: color 0.5s ease;
  user-select: none;
}

.beian a {
  color: inherit;
  text-decoration: none;
}

.beian:hover,
.beian a:focus-visible {
  color: rgba(255, 255, 255, 0.85);
}

/* ---- 响应式适配 ---- */
@media (max-width: 640px) {
  .card {
    width: 90%;
    padding: 50px 28px 42px;
    border-radius: 18px;
  }

  .quote-mark {
    font-size: 3.2rem;
  }

  .hitokoto {
    font-size: 1.3rem;
    line-height: 1.7;
  }

  .refresh {
    margin: 28px auto 0;
    width: 42px;
    height: 42px;
  }

  .credit {
    right: 16px;
    bottom: 14px;
    font-size: 0.7rem;
  }

  /* 小屏/手机：壁纸说明与备案号分两行（说明在上，备案号在下），避免重叠 */
  .credit {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    bottom: 42px;
    white-space: nowrap;
  }

  .beian {
    bottom: 14px;
  }

  .lang-switch {
    top: 14px;
    right: 16px;
    height: 28px;
    min-width: 42px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
