
:root {
 /* Neutral backdrop with yellow accents */
 --bg-primary: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e0 100%);
 --bg-secondary: rgba(45, 55, 72, 0.03);
 --bg-card: rgba(45, 55, 72, 0.05);
 --bg-glass: rgba(255, 255, 255, 0.8);

 --text-primary: #2d3748;
 --text-secondary: rgba(45, 55, 72, 0.7);
 --text-muted: rgba(45, 55, 72, 0.5);

 --accent-primary: #ffd93d;   /* main */
 --accent-secondary: #ffed4a; /* light */
 --accent-tertiary: #f6d55c;  /* deep */
 --accent-warning: #ffd93d;
 --accent-success: #48bb78;

 --shadow-soft: 0 6px 22px rgba(45, 55, 72, 0.10);
 --shadow-medium: 0 10px 28px rgba(45, 55, 72, 0.18);
 --shadow-strong: 0 14px 38px rgba(45, 55, 72, 0.28);

 --border-radius-sm: 10px;
 --border-radius-md: 14px;
 --border-radius-lg: 18px;

 --container-max: 1300px;
 --container-pad: 1.5rem;

 /* Motion tuning for premium feel */
 --transition-fast: 140ms cubic-bezier(.22,.61,.36,1);  /* ease-out-quart-ish */
 --transition-smooth: 260ms cubic-bezier(.22,.61,.36,1);
 --transition-emphasized: 420ms cubic-bezier(.2,.8,.2,1);

 /* Glass morphism backdrop blur */
 --backdrop-blur: blur(22px);

 /* Card elevation layers */
 --card-shadow-ambient: 0 10px 30px rgba(45, 55, 72, 0.18);
 --card-shadow-key: 0 2px 8px rgba(45, 55, 72, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-size: 400% 400%;
  animation: gradientShift 20s ease infinite;
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 15% 85%, 
    rgba(255, 217, 61, 0.06) 0%,
    transparent 40%),
    radial-gradient(circle at 85% 15%, 
    rgba(255, 237, 74, 0.04) 0%,
    transparent 40%),
    radial-gradient(circle at 50% 50%, 
    rgba(246, 213, 92, 0.03) 0%,
    transparent 60%);
  pointer-events: none;
  z-index: -1;
}

header {
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid rgba(45, 55, 72, 0.08);
  box-shadow: 0 1px 3px rgba(45, 55, 72, 0.05);
}

header h1 {
  padding: 2rem 0;
  text-align: center;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text-primary);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  letter-spacing: -0.02em;
  margin: 0;
}

nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  padding: 1rem var(--container-pad);
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-bottom: 1px solid rgba(45, 55, 72, 0.08);
  display: flex;
  justify-content: center;
  transition: all var(--transition-smooth);
  box-shadow: 0 1px 3px rgba(45, 55, 72, 0.05);
}

/* 暗色主题下：提高导航条自身对比度，避免灰蒙蒙 */
:root[data-theme="dark"] nav {
  background: rgba(17, 24, 39, 0.65);                 /* 更深玻璃层 */
  border-bottom-color: rgba(255,255,255,0.08);
  box-shadow: 0 2px 14px rgba(0,0,0,0.45);
  -webkit-font-smoothing: antialiased;
  color: #e8ebef;                                      /* 作为继承色兜底 */
}

nav::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, 
    transparent 0%,
    rgba(255, 217, 61, 0.02) 50%,
    transparent 100%);
  pointer-events: none;
}

nav ul, footer nav {
  list-style-type: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Dark-mode specific nav readability fixes */
:root[data-theme="dark"] nav a {
  color: #e5e7eb; /* 明亮文字 */
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.10);
  text-shadow: 0 1px 1px rgba(0,0,0,0.35);
}
:root[data-theme="dark"] nav a:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.18);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
:root[data-theme="dark"] nav a.active {
  background: linear-gradient(135deg, #ffd93d 0%, #f6d55c 100%);
  color: #0b0f19; /* 在亮黄背景上使用深色字，提升对比 */
  border-color: rgba(246,213,92,0.9);
  text-shadow: none;
}

nav a {
  color: var(--text-primary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 600;                                    /* 提升字重增强清晰度 */
  letter-spacing: .1px;                                /* 微调字距 */
  padding: 0.75rem 1.25rem;
  border-radius: var(--border-radius-md);
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(45, 55, 72, 0.08);
  backdrop-filter: var(--backdrop-blur);
  transition: all var(--transition-smooth);
  position: relative;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(45, 55, 72, 0.05);
}

nav a::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, 
    rgba(255, 217, 61, 0.1) 0%, 
    rgba(255, 237, 74, 0.05) 100%);
  opacity: 0;
  transition: opacity var(--transition-smooth);
}

nav a:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-medium);
  border-color: rgba(255, 217, 61, 0.3);
  background: rgba(255, 255, 255, 0.85);
}

nav a:hover::before {
  opacity: 1;
}

nav a:active {
  transform: translateY(0);
  box-shadow: var(--shadow-soft);
}

/* 暗色主题下：导航链接文字与背景的强对比与层次 */
:root[data-theme="dark"] nav a {
  color: #eef2f7 !important;                           /* 强制高亮文字 */
  background: rgba(255,255,255,0.10) !important;       /* 提高按钮面层亮度 */
  border-color: rgba(255,255,255,0.16) !important;
  text-shadow: 0 1px 1px rgba(0,0,0,0.55);
}
:root[data-theme="dark"] nav a:hover {
  background: rgba(255,255,255,0.16) !important;
  border-color: rgba(255,255,255,0.24) !important;
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
}
:root[data-theme="dark"] nav a.active {
  background: linear-gradient(135deg, #ffd93d 0%, #f6d55c 100%) !important;
  color: #111827 !important;                           /* 黄色按钮上使用深色字 */
  border-color: rgba(246,213,92,0.95) !important;
  text-shadow: none;
}

/* 主题按钮图标颜色在暗色下也保持高对比 */
:root[data-theme="dark"] .theme-toggle-btn .theme-icon {
  color: #eef2f7;
}

nav a.active {
  background: var(--accent-primary);
  border-color: var(--accent-tertiary);
  color: #2d3748;
  box-shadow: var(--shadow-soft);
  font-weight: 600;
}

main {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 2.5rem var(--container-pad);
}

.category-title {
  font-size: 1.75rem;
  font-weight: 600;
  margin: 3rem 0 1.5rem;
  color: var(--text-primary);
  padding: 1rem 0;
  border-bottom: 2px solid rgba(45, 55, 72, 0.08);
  position: relative;
  outline: none;
  letter-spacing: -0.01em;
}

.category-title::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 60px;
  height: 2px;
  background: var(--accent-primary);
  border-radius: 1px;
}

.category-title::after {
  content: '';
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 30px;
  height: 2px;
  background: rgba(255, 217, 61, 0.4);
  border-radius: 1px;
  filter: blur(1px);
}

.category-title:first-of-type {
  margin-top: 1rem;
}

.link-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

/* Modern Glass Card Design - Premium Yellow + Gloss, depth */
.link-card {
  /* Multi-stop premium gradient with subtle light angle */
  background: linear-gradient(
      135deg,
      #ffe873 0%,
      #ffd93d 30%,
      #ffdf67 55%,
      #f7cf45 85%
  );
  /* Internal glossy sheen layer via overlay pseudo */
  border-color: rgba(255, 217, 61, 0.75);
  backdrop-filter: var(--backdrop-blur);
  border-radius: var(--border-radius-lg);
  border: 1px solid rgba(255, 217, 61, 0.65);
  cursor: pointer;
  min-height: 120px;
  padding: 1.6rem 1rem;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;

  /* Layered shadows to simulate depth */
  box-shadow:
    var(--card-shadow-ambient),
    var(--card-shadow-key);

  opacity: 1;
  transform: translateY(0) translateZ(0);
  transition: transform var(--transition-smooth), box-shadow var(--transition-smooth), filter var(--transition-smooth), background var(--transition-emphasized), border-color var(--transition-smooth);
  will-change: transform, box-shadow, filter;
}

/* Animation class applied by JavaScript */
.link-card.animate-in {
  opacity: 0;
  transform: translateY(30px);
}

/* Ensure cards are visible if JavaScript fails to load */
.no-js .link-card {
  opacity: 1 !important;
  transform: translateY(0) !important;
}

/* Gloss highlight sweep */
.link-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 60% at 10% 0%,
      rgba(255,255,255,0.35) 0%,
      rgba(255,255,255,0.15) 35%,
      rgba(255,255,255,0.0) 60%) ,
    linear-gradient(140deg,
      rgba(255,255,255,0.12) 0%,
      rgba(255,255,255,0.06) 40%,
      rgba(255,255,255,0.12) 100%);
  mix-blend-mode: soft-light;
  opacity: 0.0;
  transition: opacity var(--transition-smooth), transform var(--transition-emphasized);
  transform: translate3d(0,0,0);
  pointer-events: none;
}

/* Inner subtle vignette for depth */
.link-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(80% 70% at 50% 30%,
      rgba(0,0,0,0.06) 0%,
      rgba(0,0,0,0.04) 40%,
      rgba(0,0,0,0.02) 70%,
      rgba(0,0,0,0.00) 100%);
  opacity: .0;
  transition: opacity var(--transition-smooth);
  pointer-events: none;
}

.link-card > * {
  z-index: 2;
  color: #2d3748;
  position: relative;
}

.link-card a {
  position: absolute;
  inset: 0;
  z-index: 3;
}

.link-card i {
  font-size: 2.3rem;
  margin-bottom: 0.75rem;
  transition: transform var(--transition-smooth), filter var(--transition-smooth), opacity var(--transition-smooth);
  position: relative;
  z-index: 2;
  filter: drop-shadow(0 3px 10px rgba(45, 55, 72, 0.32));
  color: #2d3748;
  opacity: .95;
}

.link-card h3 {
  font-size: 0.92rem;
  margin: 0;
  font-weight: 600;
  line-height: 1.3;
  position: relative;
  z-index: 2;
  text-align: center;
  opacity: 0.92;
  color: #2d3748;
}

/* Hover and Active States - refined motion curve and sheen */
.link-card:hover {
  transform: translateY(-6px) scale(1.01);
  box-shadow:
    0 16px 48px rgba(45,55,72,0.28),
    0 4px 14px rgba(45,55,72,0.18);
  border-color: rgba(246, 213, 92, 0.95);
  background: linear-gradient(
      135deg,
      #ffe873 0%,
      #ffd93d 24%,
      #ffe27a 58%,
      #f6d55c 100%
  );
  filter: saturate(1.02);
}

.link-card:hover::before {
  opacity: 1;
  transform: translate3d(0,-2px,0);
}

.link-card:hover i {
  transform: translateY(-1px) scale(1.08);
  filter: drop-shadow(0 6px 16px rgba(45, 55, 72, 0.45));
}

.link-card:hover h3 {
  opacity: 1;
  color: #1a202c;
  letter-spacing: .1px;
}

.link-card:active {
  transform: translateY(-3px) scale(0.995);
  box-shadow:
    0 10px 28px rgba(45,55,72,0.22),
    0 2px 10px rgba(45,55,72,0.14);
  background: linear-gradient(
      135deg,
      #f6d55c 0%,
      #ffd93d 60%,
      #ffea8a 100%
  );
}


/* Footer */
footer {
  background: var(--bg-glass);
  backdrop-filter: var(--backdrop-blur);
  border-top: 1px solid rgba(45, 55, 72, 0.08);
  color: var(--text-secondary);
  text-align: center;
  padding: 3rem var(--container-pad) 2rem;
  font-size: 0.9rem;
  margin-top: 3rem;
  position: relative;
  box-shadow: 0 -1px 3px rgba(45, 55, 72, 0.05);
}

footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 1px;
  background: linear-gradient(90deg, 
    transparent 0%,
    var(--accent-primary) 50%,
    transparent 100%);
}

footer p {
  margin: 0 0 1rem;
  color: var(--text-primary);
}

footer nav {
  margin-top: 1rem;
}

footer nav a {
  color: var(--text-secondary);
  text-decoration: none;
  margin: 0 1rem;
  transition: all var(--transition-smooth);
  font-size: 0.85rem;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius-sm);
  position: relative;
}

footer nav a:hover {
  color: var(--text-primary);
  background: rgba(255, 217, 61, 0.1);
  transform: translateY(-1px);
}

/* Enhanced Responsive Design */
@media (max-width: 1200px) {
  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
}

@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
    padding: 1.5rem 0;
  }
  
  nav {
    padding: 0.75rem var(--container-pad);
  }
  
  nav a {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
  }
  
  main {
    padding: 2rem var(--container-pad);
  }
  
  .category-title {
    font-size: 1.5rem;
    margin: 2rem 0 1rem;
  }
  
  .link-grid {
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 1.25rem;
  }
  
  .link-card {
    min-height: 100px;
    padding: 1.25rem 0.75rem;
  }
  
  .link-card i {
    font-size: 2rem;
  }
}

@media (max-width: 480px) {
  header h1 {
    font-size: 1.75rem;
  }
  
  nav ul {
    gap: 0.25rem;
  }
  
  nav a {
    padding: 0.5rem;
    font-size: 0.8rem;
  }
  
  .link-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
  }
  
  .link-card {
    min-height: 90px;
    padding: 1rem 0.5rem;
  }
  
  .link-card i {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
  }
  
  .link-card h3 {
    font-size: 0.8rem;
  }
  
  footer {
    padding: 2rem var(--container-pad) 1.5rem;
  }
  
  footer nav a {
    margin: 0 0.5rem;
  }
}

/* High-resolution display optimizations */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 2dppx) {
  .link-card i {
    -webkit-font-smoothing: antialiased;
  }
}

/* Touch devices: reduce shadows and motion for battery/stability */
@media (hover: none), (pointer: coarse) {
  .link-card {
    box-shadow:
      0 8px 22px rgba(45,55,72,0.18),
      0 2px 8px rgba(45,55,72,0.10);
    transform: translateY(0);
    transition: transform 160ms ease-out, box-shadow 200ms ease-out, filter 200ms ease-out, background 220ms ease-out, border-color 200ms ease-out;
  }
  .link-card:hover,
  .link-card:active {
    transform: translateY(-3px) scale(1.003);
    box-shadow:
      0 10px 26px rgba(45,55,72,0.22),
      0 3px 10px rgba(45,55,72,0.12);
    filter: none;
  }
  .link-card::before {
    opacity: .08;
  }
  .link-card i {
    transform: none !important;
    filter: drop-shadow(0 3px 10px rgba(45, 55, 72, 0.28));
  }
}

/* Optional dark mode support - prefers-color-scheme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg-primary: linear-gradient(135deg, #0f172a 0%, #111827 50%, #0b1220 100%);
    --bg-secondary: rgba(255,255,255,0.03);
    --bg-card: rgba(255,255,255,0.06);
    --bg-glass: rgba(17, 24, 39, 0.6);

    --text-primary: #e5e7eb;
    --text-secondary: rgba(229, 231, 235, 0.75);
    --text-muted: rgba(229, 231, 235, 0.55);

    --shadow-soft: 0 6px 22px rgba(0, 0, 0, 0.35);
    --shadow-medium: 0 10px 28px rgba(0, 0, 0, 0.45);
    --shadow-strong: 0 14px 38px rgba(0, 0, 0, 0.55);

    --backdrop-blur: blur(24px);
  }

  nav, header, footer {
    background: rgba(17, 24, 39, 0.55);
    backdrop-filter: var(--backdrop-blur);
    border-color: rgba(255,255,255,0.06);
    box-shadow: 0 1px 2px rgba(0,0,0,0.35);
  }

  nav a {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.10);
    color: #e5e7eb; /* 更亮以提升对比 */
    text-shadow: 0 1px 1px rgba(0,0,0,0.35);
  }

  .category-title {
    border-bottom-color: rgba(255,255,255,0.08);
    color: var(--text-primary);
  }

  .link-card {
    /* Keep yellow theme but adjust contrast for dark */
    background: linear-gradient(
      135deg,
      #d1a900 0%,
      #e7c100 35%,
      #ffda2e 70%,
      #f6d55c 100%
    );
    border-color: rgba(255, 217, 61, 0.55);
    box-shadow:
      0 14px 40px rgba(0,0,0,0.55),
      0 4px 14px rgba(0,0,0,0.35);
  }

  .link-card i, .link-card h3 {
    color: #0b0f19; /* maintain readability on bright card */
  }

  footer p, footer nav a {
    color: var(--text-secondary);
  }
}

/* Explicit theme switching via data-theme */
:root[data-theme="dark"] {
  --bg-primary: linear-gradient(135deg, #0f172a 0%, #111827 50%, #0b1220 100%);
  --bg-secondary: rgba(255,255,255,0.03);
  --bg-card: rgba(255,255,255,0.06);
  --bg-glass: rgba(17, 24, 39, 0.6);

  --text-primary: #e5e7eb;
  --text-secondary: rgba(229, 231, 235, 0.75);
  --text-muted: rgba(229, 231, 235, 0.55);

  --shadow-soft: 0 6px 22px rgba(0, 0, 0, 0.35);
  --shadow-medium: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-strong: 0 14px 38px rgba(0, 0, 0, 0.55);

  --backdrop-blur: blur(24px);
}

:root[data-theme="dark"] nav,
:root[data-theme="dark"] header,
:root[data-theme="dark"] footer {
  background: rgba(17, 24, 39, 0.55);
  backdrop-filter: var(--backdrop-blur);
  border-color: rgba(255,255,255,0.06);
  box-shadow: 0 1px 2px rgba(0,0,0,0.35);
}

:root[data-theme="dark"] nav a {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.06);
  color: var(--text-primary);
}

:root[data-theme="dark"] .category-title {
  border-bottom-color: rgba(255,255,255,0.08);
  color: var(--text-primary);
}

:root[data-theme="dark"] .link-card {
  background: linear-gradient(
    135deg,
    #d1a900 0%,
    #e7c100 35%,
    #ffda2e 70%,
    #f6d55c 100%
  );
  border-color: rgba(255, 217, 61, 0.55);
  box-shadow:
    0 14px 40px rgba(0,0,0,0.55),
    0 4px 14px rgba(0,0,0,0.35);
}

:root[data-theme="dark"] .link-card i,
:root[data-theme="dark"] .link-card h3 {
  color: #0b0f19;
}

:root[data-theme="dark"] footer p,
:root[data-theme="dark"] footer nav a {
  color: var(--text-secondary);
}

/* Loading and entrance animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Entrance animations - Simplified */

.category-title {
  animation: fadeInLeft 0.8s ease-out;
}


/* Smooth scrolling for the entire page */
html {
  scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(45, 55, 72, 0.05);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent-primary);
  border-radius: 4px;
  transition: background var(--transition-smooth);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-tertiary);
}
