@import url(https://fonts.googleapis.com/css?family=Righteous);

:root {
  --bg: #0a0a0a;
  --fg: #e0e0e0;
  --surface-1: #141414;
  --surface-2: #1a1a1a;
  --surface-3: #252525;
  --primary: #e94560;
  --ease-out: cubic-bezier(0.5, 1, 0.89, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);

  /* 夜间模式颜色 */

  /* 日间模式颜色 */
  --day-bg: #f0f4f8;
  --day-fg: #1a202c;
  --day-surface: #ffffff;
}

/* 日间模式 */
body.day-mode {
  --bg: var(--day-bg);
  --fg: var(--day-fg);
  --surface-1: var(--day-surface);
  --surface-2: #f7fafc;
  --surface-3: #edf2f7;
  color-scheme: light;
}

body.day-mode #background-wrapper {
  background-color: rgb(248, 248, 248);
  background-image: url(../image/day-background.png);
  background-size: auto;
  background-repeat: repeat;
}

body.day-mode .card {
  background: hsla(0, 0%, 100%, 0.35);
  border-color: rgba(200, 200, 200, 0.4);
  border-radius: 10px;
  box-shadow: 5px 3px 30px rgba(0, 0, 0, 0.15);
}

body.day-mode .card::before {
  content: "";
  position: absolute;
  inset: -35px;
  background: url(../image/day-background.png);
  background-size: auto;
  background-repeat: repeat;
  filter: blur(20px);
  z-index: -1;
}

body.day-mode .card::after {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4), transparent 65%);
}

body.day-mode .card-icon {
  color: rgba(0, 0, 0, 0.4);
}

body.day-mode .card h2 {
  color: rgba(0, 0, 0, 0.9);
}

body.day-mode .card p {
  color: rgba(0, 0, 0, 0.6);
}

body.day-mode .card:where(:hover, :focus-within) .card-icon,
body.day-mode .card:where(:hover, :focus-within) h2 {
  color: var(--active-color, var(--primary));
}

body.day-mode .card:where(:hover, :focus-within) p {
  color: rgba(0, 0, 0, 0.8);
}

body.day-mode .card:where(:hover, :focus-within) {
  background: hsla(0, 0%, 100%, 0.6);
  border-color: var(--active-color, var(--primary));
  transform: translateY(-4px);
  box-shadow: 0 8px 35px rgba(0, 0, 0, 0.2);
}

body.day-mode .card:where(:hover, :focus-within)::before {
  opacity: 0;
}

body.day-mode .card:where(:hover, :focus-within)::after {
  opacity: 1;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.6), transparent 65%);
}

body.day-mode h1 {
  color: #2d3748;
  text-shadow: .03em .03em 0 hsla(200, 60%, 60%, 1);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  margin: 0;
  padding: 0;
  background-color: #1a1a1a;
  color: var(--fg);
  color-scheme: dark;
  overflow-x: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#background-wrapper {
  position: fixed;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  z-index: -1;
  background: linear-gradient(135deg, #1a1a1a 0%, #0a0a0a 100%);
  overflow: hidden;
}

#background-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.container {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
}

h1 {
  display: inline-block;
  color: white;
  font-family: 'Righteous', serif;
  font-size: 6em;
  text-shadow: .03em .03em 0 hsla(230,40%,50%,1);
  /* 关键修改：添加相对定位，使伪元素相对于 h1 定位 */
  position: relative;
  line-height: 1.2;
  margin-bottom: 0.8rem;
  margin-top: 0.5rem;
}

h1:after {
  content: attr(data-shadow);
  position: absolute;
  /* 确保伪元素覆盖整个 h1 区域 */
  top: .06em;
  left: .06em;
  width: 100%;
  height: 100%;
  z-index: -1;
  text-shadow: none;
  background-image:
    linear-gradient(
      45deg,
      transparent 45%,
      hsla(48,20%,90%,1) 45%,
      hsla(48,20%,90%,1) 55%,
      transparent 0
    );
  background-size: .05em .05em;
  -webkit-background-clip: text;
  background-clip: text; /* 增加标准属性 */
  -webkit-text-fill-color: transparent;

  /* 确保文字对齐 */
  display: flex;
  justify-content: center;
  align-items: center;
  white-space: nowrap;

  animation: shad-anim 45s linear infinite;
}

@keyframes shad-anim {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 100% -100%;
  }
}

.cards-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
  width: 100%;
  max-width: 1200px;
  padding: 0 1rem;
}

.card {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-areas: "card";
  place-items: center;
  aspect-ratio: 1;
  background: rgba(20, 20, 20, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  isolation: isolate;
  transition:
    border-color 200ms var(--ease-out),
    transform 200ms var(--ease-out),
    box-shadow 200ms var(--ease-out);
  user-select: none;
  backdrop-filter: blur(10px);
  container-type: size;
}

/* 左下角径向渐变背景 */
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(
    circle at bottom left,
    transparent 55%,
    var(--surface-1)
  );
  pointer-events: none;
  box-shadow: var(--bg) -0.5cqi 0.5cqi 2.5cqi inset;
  transition: opacity 900ms var(--ease-out);
  z-index: 0;
}

/* 中心径向渐变 - hover 时显示 */
.card::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  aspect-ratio: 1;
  background: radial-gradient(circle, var(--bg), transparent 65%);
  opacity: 0;
  transition: opacity 800ms var(--ease-out);
  z-index: 0;
}

.card > * {
  grid-area: card;
}

.card pixel-canvas {
  z-index: 1;
}

.card-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.5rem;
  text-align: center;
}

.card-icon {
  width: 48px;
  height: 48px;
  color: rgba(255, 255, 255, 0.3);
  transition: 300ms var(--ease-out);
  transition-property: color, transform;
  display: block;
}

.card h2 {
  font-size: 1.25rem;
  margin: 0;
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  transition: color 300ms var(--ease-out);
}

.card p {
  font-size: 0.85rem;
  line-height: 1.4;
  margin: 0;
  color: rgba(255, 255, 255, 0.5);
  transition: color 300ms var(--ease-out);
}

.card a {
  position: absolute;
  inset: 0;
  z-index: 3;
  text-indent: -9999px;
  overflow: hidden;
  white-space: nowrap;
  outline-offset: 2px;
}

/* Hover 和 Focus 效果 */
.card:focus-within {
  outline: 2px solid var(--active-color);
}

.card:where(:hover, :focus-within) .card-icon {
  color: var(--active-color, var(--primary));
  transform: scale(1.1);
  transition: 300ms var(--ease-in-out);
}

.card:where(:hover, :focus-within) h2 {
  color: var(--active-color, var(--primary));
}

.card:where(:hover, :focus-within) p {
  color: rgba(255, 255, 255, 0.8);
}

.card:where(:hover, :focus-within)::before {
  opacity: 0;
}

.card:where(:hover, :focus-within)::after {
  opacity: 1;
}

/* 焦点可见性 */
.card:focus-within a {
  outline: 3px solid var(--active-color, var(--primary));
  outline-offset: 2px;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* 响应式设计 */
@media (max-width: 768px) {
  .container {
    padding: 20px 10px;
    justify-content: flex-start;
    padding-top: 60px;
  }

  h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
  }

  /* 修复标题阴影错位 */
  h1::after {
    top: 0.06em;
    left: 0.06em;
    background-size: 0.05em 0.05em;
  }

  .cards-container {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.8rem;
    max-width: 500px;
  }

  .card-content {
    gap: 0.4rem;
    padding: 1rem;
  }

  .card-icon {
    width: 36px;
    height: 36px;
  }

  .card h2 {
    font-size: 0.9rem;
  }

  .card p {
    font-size: 0.65rem;
  }
}

/* 超小屏幕优化（< 375px）*/
@media (max-width: 374px) {
  h1 {
    font-size: 2rem;
  }

  /* 调整超小屏幕的阴影 */
  h1::after {
    top: 0.08em;
    left: 0.08em;
    background-size: 0.06em 0.06em;
  }

  .cards-container {
    gap: 0.6rem;
    padding: 0 0.5rem;
  }

  .card-content {
    padding: 0.8rem;
    gap: 0.3rem;
  }

  .card-icon {
    width: 32px;
    height: 32px;
  }

  .card h2 {
    font-size: 0.85rem;
  }

  .card p {
    font-size: 0.6rem;
  }
}

@media (min-width: 769px) and (max-width: 1024px) {
  .theme-toggle {
    --theme-toggle-scale: 0.47;
  }

  .cards-container {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 1025px) {
  .cards-container {
    grid-template-columns: repeat(4, 1fr);
  }
}

/* 横屏优化 */
@media (max-height: 600px) and (orientation: landscape) {
  .container {
    padding-top: 20px;
    padding-bottom: 20px;
  }

  h1 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
  }

  /* 横屏模式阴影调整 */
  h1::after {
    top: 0.1em;
    left: 0.1em;
    background-size: 0.07em 0.07em;
  }

  .cards-container {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
  }

  .card-content {
    gap: 0.3rem;
    padding: 0.8rem;
  }

  .card-icon {
    width: 28px;
    height: 28px;
    font-size: 1.5rem;
  }

  .card h2 {
    font-size: 1.25rem;
  }

  .card p {
    font-size: 0.95rem;
    display: none;
  }
}

/* 触摸设备优化 */
@media (hover: none) {
  .card:hover {
    border-color: rgba(255, 255, 255, 0.1);
  }

  .card:hover .card-icon,
  .card:hover h2,
  .card:hover p {
    color: inherit;
    transform: none;
  }

  .card:active {
    transform: scale(0.98);
    transition: transform 0.1s ease;
  }
}

/* 减少动效模式 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== 日夜切换器样式 ===== */
.theme-toggle {
  --theme-toggle-scale: 0.52;
  position: fixed;
  top: clamp(12px, 2vw, 20px);
  right: clamp(12px, 2vw, 20px);
  z-index: 1000;
  user-select: none;
  /* 使用 transform scale 缩小整体，保持内部比例一致 */
  transform: scale(var(--theme-toggle-scale));
  transform-origin: top right;
}

.theme-toggle__checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.theme-toggle__btn {
  display: block;
  position: relative;
  width: 125px;
  height: 70px;
  border-radius: 70px;
  border: 5px solid #1c1c1c;
  background-color: #3c4145;
  cursor: pointer;
  transition: all 350ms ease-in;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle__checkbox:focus-visible + .theme-toggle__btn {
  outline: 3px solid rgba(255, 255, 255, 0.8);
  outline-offset: 4px;
}

body.day-mode .theme-toggle__checkbox:focus-visible + .theme-toggle__btn {
  outline-color: rgba(0, 0, 0, 0.55);
}

/* 切换按钮（月亮/太阳）*/
.theme-toggle__btn::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background-color: #fff;
  border: 5px solid #e3e3c7;
  transition: all 250ms ease-in;
}

/* 云朵（日间模式时显示）*/
.theme-toggle__btn::after {
  content: '';
  position: absolute;
  top: 62%;
  left: 39px;
  z-index: 10;
  width: 9.2px;
  height: 9.2px;
  opacity: 0;
  background-color: #fff;
  border-radius: 50%;
  box-shadow:
    #fff 0 0,
    #fff 2.5px 0,
    #fff 5px 0,
    #fff 7.5px 0,
    #fff 9px 0,
    #fff 11.5px 0,
    #fff 13px 0,
    #fff 17px -1px 0 1px,
    #fff 13px -6px 0 -2px,
    #fff 6px -6px 0 1px,
    #d3d3d3 0 0 0 3.5px,
    #d3d3d3 5px 0 0 3.5px,
    #d3d3d3 9px 0 0 3.5px,
    #d3d3d3 13px 0 0 3.5px,
    #d3d3d3 17px -1px 0 4.5px,
    #d3d3d3 13px -6px 0 1px,
    #d3d3d3 6px -6px 0 4.5px;
  transition: opacity 100ms ease-in;
}

/* 星星 */
.theme-toggle__feature {
  display: block;
  position: absolute;
  top: 9px;
  left: 52.5%;
  z-index: 20;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: #fff;
  box-shadow:
    rgba(255,255,255,0.1) 30px -3px 0 0,
    rgba(255,255,255,0.1) 12px 10px 0 -1px,
    #fff 38px 18px 0 1px,
    rgba(255,255,255,0.1) 32px 34px 0 0,
    #fff 20px 24px 0 -1.5px,
    rgba(255,255,255,0.1) 5px 38px 0 1px;
  animation: starry_star 5s ease-in-out infinite;
}

.theme-toggle__feature::before {
  content: '';
  position: absolute;
  top: -2px;
  left: -25px;
  width: 15px;
  height: 15px;
  background-color: #fff;
  border-radius: 50%;
  border: 4px solid #e3e3c7;
  box-shadow:
    #e3e3c7 -28px 0 0 -3px,
    #e3e3c7 -8px 24px 0 -2px;
  transform-origin: -6px 130%;
  transition: all 250ms ease-in;
}

@keyframes starry_star {
  50% {
    background-color: rgba(255,255,255,0.1);
    box-shadow:
      #fff 30px -3px 0 0,
      #fff 12px 10px 0 -1px,
      rgba(255,255,255,0.1) 38px 18px 0 1px,
      #fff 32px 34px 0 0,
      rgba(255,255,255,0.1) 20px 24px 0 -1.5px,
      #fff 5px 38px 0 1px;
  }
}

@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
  55% {
    transform: scale(1.1);
  }
  75% {
    transform: scale(.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* 选中状态（日间模式）*/
.theme-toggle__checkbox:checked + .theme-toggle__btn {
  background-color: #9ee3fb;
  border: 5px solid #86c3d7;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn::before {
  left: 57px;
  background-color: #ffdf6d;
  border: 5px solid #e1c348;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn::after {
  opacity: 1;
  animation-name: bounceIn;
  animation-duration: 0.60s;
  animation-delay: 0.10s;
  animation-fill-mode: backwards;
  animation-timing-function: ease-in-out;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn .theme-toggle__feature {
  opacity: 0;
  box-shadow:
    rgba(255,255,255,0.1) 30px -3px 0 -4px,
    rgba(255,255,255,0.1) 12px 10px 0 -5px,
    #fff 38px 18px 0 -3px,
    rgba(255,255,255,0.1) 32px 34px 0 -4px,
    #fff 20px 24px 0 -5.5px,
    rgba(255,255,255,0.1) 5px 38px 0 -3px;
  animation: none;
}

.theme-toggle__checkbox:checked + .theme-toggle__btn .theme-toggle__feature::before {
  left: 25px;
  transform: rotate(70deg);
}

/* 响应式 - 移动端 */
@media (max-width: 768px) {
  .theme-toggle {
    --theme-toggle-scale: 0.42;
    position: absolute;
    top: calc(env(safe-area-inset-top, 0px) + 10px);
    right: 10px;
    z-index: 2;
  }
}

/* ===== 页脚样式 ===== */
.footer {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 2rem 1rem;
  text-align: center;
}

.footer p {
  margin: 0;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.4);
  transition: color 300ms var(--ease-out);
}

/* 日间模式页脚样式 */
body.day-mode .footer p {
  color: rgba(0, 0, 0, 0.5);
}

/* 页脚响应式 */
@media (max-width: 768px) {
  .footer {
    padding: 1.5rem 1rem;
  }

  .footer p {
    font-size: 0.75rem;
  }
}
