/* ============================================
   Jay's Page — Apple-Style Personal Homepage
   ============================================ */

/* --- CSS Variables / Theme System --- */
:root {
  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 32px;
  --space-xl: 64px;
  --space-2xl: 128px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Typography */
  --font-sans: 'Inter', 'Noto Sans SC', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;

  /* Transition */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --duration: 0.6s;
}

/* Dark Theme (default) */
[data-theme="dark"] {
  --bg-primary: #000000;
  --bg-secondary: #0a0a0a;
  --bg-card: rgba(255, 255, 255, 0.04);
  --bg-card-hover: rgba(255, 255, 255, 0.08);
  --bg-nav: rgba(0, 0, 0, 0.72);
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #6e6e73;
  --border: rgba(255, 255, 255, 0.08);
  --glow: rgba(100, 100, 255, 0.15);
  --accent: #2997ff;
  --accent-hover: #4dabff;
  --tag-bg: rgba(255, 255, 255, 0.06);
  --tag-border: rgba(255, 255, 255, 0.1);
  --shadow-card: 0 2px 20px rgba(0, 0, 0, 0.3);
  --shadow-card-hover: 0 8px 40px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}

/* Light Theme */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-card: rgba(0, 0, 0, 0.02);
  --bg-card-hover: rgba(0, 0, 0, 0.05);
  --bg-nav: rgba(255, 255, 255, 0.72);
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border: rgba(0, 0, 0, 0.08);
  --glow: rgba(100, 100, 255, 0.08);
  --accent: #0066cc;
  --accent-hover: #0077ed;
  --tag-bg: rgba(0, 0, 0, 0.04);
  --tag-border: rgba(0, 0, 0, 0.08);
  --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.06);
  --shadow-card-hover: 0 8px 30px rgba(0, 0, 0, 0.12);
  color-scheme: light;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: background var(--duration) var(--ease-out), color var(--duration) var(--ease-out);
  overflow-x: hidden;
}

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

/* --- Container --- */
.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* --- Navbar --- */
.navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: var(--bg-nav);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid var(--border);
  transition: background var(--duration) var(--ease-out), border var(--duration) var(--ease-out);
}

.nav-inner {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav-logo {
  font-size: 20px;
  line-height: 1;
}

.nav-links {
  display: flex;
  gap: var(--space-lg);
}

.nav-links a {
  font-size: 14px;
  font-weight: 400;
  color: var(--text-secondary);
  transition: color 0.3s;
}

.nav-links a:hover {
  color: var(--text-primary);
}

.theme-toggle {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: var(--space-sm);
  border-radius: var(--radius-sm);
  transition: color 0.3s, background 0.3s;
  display: flex;
  align-items: center;
}

.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }
[data-theme="light"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: block; }

/* --- Hero Section --- */
.hero {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.hero-glow {
  position: absolute;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  animation: glowPulse 8s ease-in-out infinite;
}

@keyframes glowPulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); }
}

.hero-content {
  text-align: center;
  position: relative;
  z-index: 2;
}

.hero-title {
  font-size: clamp(40px, 8vw, 80px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: var(--space-md);
}

.hero-sub {
  font-size: clamp(16px, 2.5vw, 22px);
  color: var(--text-secondary);
  font-weight: 300;
  margin-bottom: var(--space-xl);
  letter-spacing: 0.01em;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 15px;
  color: var(--accent);
  font-weight: 500;
  transition: color 0.3s, transform 0.3s;
}

.hero-cta:hover {
  color: var(--accent-hover);
  transform: translateY(3px);
}

.hero-cta svg {
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

/* Particles */
.hero-particles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 1;
}

.particle {
  position: absolute;
  width: 2px;
  height: 2px;
  background: var(--text-tertiary);
  border-radius: 50%;
  opacity: 0;
  animation: particleFade 4s ease-in-out infinite;
}

@keyframes particleFade {
  0%, 100% { opacity: 0; transform: translateY(0); }
  50% { opacity: 0.6; transform: translateY(-30px); }
}

/* --- Sections --- */
.section {
  padding: var(--space-2xl) 0;
}

.section-label {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  margin-bottom: var(--space-lg);
}

.section-desc {
  font-size: 17px;
  color: var(--text-secondary);
  margin-top: calc(-1 * var(--space-md));
  margin-bottom: var(--space-xl);
}

/* --- About --- */
.about-grid {
  display: flex;
  align-items: center;
  gap: var(--space-xl);
}

.about-avatar {
  position: relative;
  flex-shrink: 0;
}

.avatar-ring {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  border: 2px solid var(--border);
  position: absolute;
  inset: -8px;
  animation: ringPulse 4s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { opacity: 0.3; transform: scale(1); }
  50% { opacity: 0.8; transform: scale(1.03); }
}

.avatar-img {
  width: 124px;
  height: 124px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-tertiary);
}

.about-desc {
  font-size: 17px;
  color: var(--text-secondary);
  line-height: 1.8;
  margin-bottom: var(--space-lg);
}

.skill-tags {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: var(--radius-full);
  transition: background 0.3s, color 0.3s, border 0.3s;
}

.tag svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.tag:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--text-tertiary);
}

/* --- Bookmarks --- */
.bookmark-category {
  margin-bottom: var(--space-xl);
}

.category-title {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: var(--space-md);
  color: var(--text-primary);
}

.bookmark-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-md);
}

.bookmark-card {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.35s var(--ease-out);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.bookmark-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx, 50%) var(--my, 50%), var(--glow) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.bookmark-card:hover::before {
  opacity: 1;
}

.bookmark-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--text-tertiary);
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
}

.card-icon {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: color 0.3s;
}

.bookmark-card:hover .card-icon {
  color: var(--text-primary);
}

.card-info {
  flex: 1;
  min-width: 0;
}

.card-info h4 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.card-info p {
  font-size: 13px;
  color: var(--text-tertiary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-arrow {
  flex-shrink: 0;
  color: var(--text-tertiary);
  opacity: 0;
  transform: translate(-4px, 4px);
  transition: all 0.3s var(--ease-out);
}

.bookmark-card:hover .card-arrow {
  opacity: 1;
  transform: translate(0, 0);
}

/* --- Footer --- */
.footer {
  padding: var(--space-xl) 0;
  border-top: 1px solid var(--border);
}

.footer-inner {
  display: flex;
  justify-content: center;
  align-items: center;
}

.footer-copy {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* --- Scroll Animation --- */
.fade-up {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out);
}

.fade-up.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered card animation */
.bookmark-card {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out), background 0.35s var(--ease-out), border 0.35s var(--ease-out), box-shadow 0.35s var(--ease-out);
}

.bookmark-card.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered tag animation */
.tag {
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  transition: opacity 0.4s var(--ease-out), transform 0.4s var(--ease-out), background 0.3s, color 0.3s, border 0.3s;
}

.tag.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Nav slide-in */
.navbar {
  transform: translateY(-100%);
  transition: transform 0.5s var(--ease-out), background var(--duration) var(--ease-out), border var(--duration) var(--ease-out);
}

.navbar.visible {
  transform: translateY(0);
}

/* Hero stagger children */
.hero-content .hero-title {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.8s 0.2s var(--ease-out), transform 0.8s 0.2s var(--ease-out), background 0s;
}

.hero-content .hero-sub {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.8s 0.4s var(--ease-out), transform 0.8s 0.4s var(--ease-out);
}

.hero-content .hero-cta {
  opacity: 0;
  transform: translateY(16px);
  transition: opacity 0.8s 0.6s var(--ease-out), transform 0.8s 0.6s var(--ease-out), color 0.3s;
}

.hero-content.visible .hero-title,
.hero-content.visible .hero-sub,
.hero-content.visible .hero-cta {
  opacity: 1;
  transform: translateY(0);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .nav-inner {
    padding: 0 var(--space-md);
  }

  .nav-links {
    gap: var(--space-md);
  }

  .nav-links a {
    font-size: 13px;
  }

  .container {
    padding: 0 var(--space-md);
  }

  .section {
    padding: var(--space-xl) 0;
  }

  .about-grid {
    flex-direction: column;
    text-align: center;
  }

  .skill-tags {
    justify-content: center;
  }

  .bookmark-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    text-align: center;
  }
}

@media (max-width: 480px) {
  .hero-title {
    font-size: 36px;
  }

  .hero-sub {
    font-size: 15px;
  }

  .nav-links a:nth-child(2) {
    display: none;
  }
}
