/* ==========================================================================
   Base Styles, CSS Resets, and Typography (個人專長與衛教網站專用)
   ========================================================================== */

/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Noto+Serif+TC:wght@400;600;700&display=swap');

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

/* Base Settings */
html {
  scroll-behavior: smooth;
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-primary);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  transition: background-color var(--transition-normal), color var(--transition-normal);
}

/* Custom Scrollbar for modern look */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: var(--radius-full);
  border: 2px solid var(--bg-primary);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Typography Selection styles */
::selection {
  background-color: var(--color-primary);
  color: var(--text-inverse);
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
  transition: color var(--transition-normal);
}

h1 {
  font-size: 2.5rem;
  letter-spacing: -0.03em;
}

h2 {
  font-size: 2rem;
  letter-spacing: -0.02em;
  position: relative;
  display: inline-block;
  margin-bottom: var(--spacing-lg);
}

/* Beautiful custom section header accent line */
.section-title {
  margin-bottom: var(--spacing-xxl);
  text-align: center;
}

.section-title h2::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary), var(--color-accent));
  border-radius: var(--radius-full);
}

h3 {
  font-size: 1.5rem;
}

p {
  color: var(--text-secondary);
  transition: color var(--transition-normal);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast), background var(--transition-fast);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: var(--radius-md);
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  outline: none;
}

button {
  cursor: pointer;
}

/* Grid & Layout Utilities */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.section {
  padding: var(--spacing-xxl) 0;
  position: relative;
}

/* Premium Glassmorphism Panel */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-md);
  border-radius: var(--radius-md);
  transition: background var(--transition-normal), border var(--transition-normal), box-shadow var(--transition-normal);
}

/* Micro-animations Keyframes */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pulseBorder {
  0% {
    box-shadow: 0 0 0 0 rgba(24, 169, 154, 0.4);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(24, 169, 154, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(24, 169, 154, 0);
  }
}

/* Applied Animations */
.animate-fade-in {
  animation: fadeIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.animate-scale-in {
  animation: scaleIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Utility Hidden state for lazy elements */
.reveal-on-scroll {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

.reveal-on-scroll.active {
  opacity: 1;
  transform: translateY(0);
}

/* ==========================================================================
   Sunlight Motes Background for Light Theme & Starry Night for Dark Theme
   ========================================================================== */
body {
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  background-image: 
    radial-gradient(1px 1px at 25px 35px, rgba(253, 186, 116, 0.45), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 75px 95px, rgba(20, 184, 169, 0.35), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 145px 155px, rgba(253, 186, 116, 0.4), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 215px 65px, rgba(20, 184, 169, 0.45), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 285px 235px, rgba(253, 186, 116, 0.35), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 355px 195px, rgba(20, 184, 169, 0.4), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 415px 85px, rgba(253, 186, 116, 0.45), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 485px 315px, rgba(20, 184, 169, 0.35), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 535px 145px, rgba(253, 186, 116, 0.45), rgba(0,0,0,0));
  background-size: 550px 550px;
  background-repeat: repeat;
  opacity: 0.7;
  animation: sunlightMotes 12s infinite alternate ease-in-out;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

[data-theme="dark"] body {
  background: 
    radial-gradient(circle at 20% 30%, rgba(20, 184, 166, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(244, 63, 94, 0.04) 0%, transparent 45%),
    linear-gradient(135deg, hsl(220, 24%, 8%) 0%, hsl(220, 24%, 4%) 100%) fixed;
  background-color: hsl(220, 24%, 4%);
}

[data-theme="dark"] body::before {
  background-image: 
    radial-gradient(1px 1px at 25px 35px, rgba(255, 255, 255, 0.75), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 75px 95px, rgba(255, 255, 255, 0.9), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 145px 155px, rgba(255, 255, 255, 0.7), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 215px 65px, rgba(255, 255, 255, 0.85), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 285px 235px, rgba(255, 255, 255, 0.7), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 355px 195px, rgba(255, 255, 255, 0.75), rgba(0,0,0,0)),
    radial-gradient(1.5px 1.5px at 415px 85px, rgba(255, 255, 255, 0.8), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 485px 315px, rgba(255, 255, 255, 0.7), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 535px 145px, rgba(255, 255, 255, 0.85), rgba(0,0,0,0));
  opacity: 0.6;
  animation: starTwinkle 10s infinite alternate ease-in-out;
}

@keyframes sunlightMotes {
  0% { opacity: 0.45; }
  50% { opacity: 0.85; }
  100% { opacity: 0.55; }
}

@keyframes starTwinkle {
  0% { opacity: 0.35; }
  50% { opacity: 0.75; }
  100% { opacity: 0.4; }
}
