/* CSS变量定义 */
:root {
  --love-primary: #ff8096;
  --love-dark: #ff6b84;
  --love-light: #ffe0e6;
  --romance-primary: #994dff;
  --gray-50: #f9fafb;
  --gray-900: #111827;
  --transition-fast: 150ms;
  --transition-normal: 300ms;
  --transition-slow: 500ms;
  --border-radius: 0.5rem;
  --border-radius-lg: 1rem;
  /* 新增字体和阴影变量 */
  --font-sans: 'Inter', sans-serif;
  --font-romantic: 'Dancing Script', cursive;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

/* 基础重置和样式 */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: var(--font-sans);
  color: var(--gray-900);
  background-color: #ffffff;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 16px;
}

/* 备用Tailwind样式定义，防止CDN加载失败 */
.bg-gray-50 { background-color: var(--gray-50); }
.bg-white { background-color: #ffffff; }
.bg-gray-900 { background-color: var(--gray-900); }
.bg-love-100 { background-color: var(--love-light); }
.bg-love-500 { background-color: var(--love-primary); }
.bg-love-600 { background-color: var(--love-dark); }
.bg-gradient-love { background: linear-gradient(135deg, var(--love-primary) 0%, var(--romance-primary) 100%); }
.bg-gradient-love\/10 { background: rgba(255, 128, 150, 0.1); }

.text-gray-900 { color: #111827; }
.text-gray-800 { color: #1f2937; }
.text-gray-700 { color: #374151; }
.text-gray-600 { color: #4b5563; }
.text-gray-500 { color: #6b7280; }
.text-gray-400 { color: #9ca3af; }
.text-white { color: #ffffff; }
.text-red-500 { color: #ef4444; }
.text-love-500 { color: #ff8096; }

.font-bold { font-weight: 700; }
.font-medium { font-weight: 500; }

.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
.text-6xl { font-size: 3.75rem; line-height: 1; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-xl { font-size: 1.25rem; line-height: 1.75rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }

.p-8 { padding: 2rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.py-16 { padding-top: 4rem; padding-bottom: 4rem; }
.pt-24 { padding-top: 6rem; }
.pb-8 { padding-bottom: 2rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-4 { margin-top: 1rem; }
.mb-8 { margin-bottom: 2rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-10 { margin-bottom: 2.5rem; }
.mr-1 { margin-right: 0.25rem; }
.mx-4 { margin-left: 1rem; margin-right: 1rem; }
.mx-auto { margin-left: auto; margin-right: auto; }

.w-full { width: 100%; }
.w-20 { width: 5rem; }
.h-20 { height: 5rem; }
.h-full { height: 100%; }
.max-w-md { max-width: 28rem; }

.rounded-2xl { border-radius: 1rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-full { border-radius: 9999px; }

.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.shadow-lg { box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1); }

.border { border-width: 1px; }
.border-gray-300 { border-color: #d1d5db; }

.fixed { position: fixed; }
.relative { position: relative; }
.absolute { position: absolute; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.left-0 { left: 0; }

.z-50 { z-index: 50; }
.pointer-events-none { pointer-events: none; }

.flex { display: flex; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.text-center { text-align: center; }
.grid { display: grid; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }

.hidden { display: none; }
.block { display: block; }

.overflow-x-hidden { overflow-x: hidden; }
.overflow-hidden { overflow: hidden; }

.transition-colors { transition-property: color, background-color, border-color, text-decoration-color, fill, stroke; transition-duration: 150ms; }
.transition-opacity { transition-property: opacity; transition-duration: 150ms; }

.hover\:bg-love-600:hover { background-color: #ff6b84; }
.hover\:scale-105:hover { transform: scale(1.05); }
.hover\:scale-102:hover { transform: scale(1.02); }

.focus\:outline-none:focus { outline: 2px solid transparent; outline-offset: 2px; }
.focus\:ring-2:focus { box-shadow: 0 0 0 2px; }
.focus\:ring-love-500:focus { box-shadow: 0 0 0 2px #ff8096; }
.focus\:border-transparent:focus { border-color: transparent; }

@media (max-width: 768px) {
  .md\:grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .md\:text-6xl { font-size: 3.75rem; line-height: 1; }
  .md\:text-2xl { font-size: 1.5rem; line-height: 2rem; }
  .md\:py-16 { padding-top: 4rem; padding-bottom: 4rem; }
  .md\:gap-6 { gap: 1.5rem; }
  
  /* 响应式设计 - 平板和手机额外优化 */
  .grid-cols-3 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .w-16 {
    width: 12rem;
  }
  
  .h-16 {
    height: 12rem;
  }
  
  /* 所有section增加顶部padding为导航栏留出空间 (导航栏高度h-20 = 80px + padding 20px) */
  section {
    padding-top: 6rem;
    padding-bottom: 3rem;
    min-height: auto;
  }
  
  /* 首页横幅优化 */
  #home {
    min-height: calc(100vh - 6rem) !important;
    padding-top: 6rem;
    padding-bottom: 3rem;
  }
  
  /* 照片展示容器优化 */
  .max-w-2xl {
    max-width: 100%;
  }
  
  /* 按钮组优化 */
  .flex-col.sm\:flex-row {
    flex-direction: column;
  }
  
  /* 导航优化 */
  #mobile-menu {
    position: fixed;
    top: 4rem;
    left: 0;
    right: 0;
    z-index: 50;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
  }
  
  /* 页脚优化 */
  footer {
    padding: 2rem 1rem;
  }
}

@media (max-width: 640px) {
  .sm\:text-sm { font-size: 0.875rem; line-height: 1.25rem; }
  
  /* 响应式设计 - 手机小屏幕额外优化 */
  .grid-cols-3 {
    grid-template-columns: 1fr;
  }
  
  .w-16 {
    width: 100%;
    max-width: 16rem;
  }
  
  .h-16 {
    height: auto;
    aspect-ratio: 1/1;
  }
  
  /* 文字大小优化 */
  h1, h2, h3 {
    line-height: 1.2;
  }
  
  /* 间距优化 */
  section > div.container > div.text-center {
    margin-bottom: 3rem;
  }
  
  /* 所有section增加顶部padding为导航栏留出空间 - 超小屏幕*/
  section {
    padding-top: 5.5rem;
    padding-bottom: 2.5rem;
    min-height: auto;
  }
  
  #home {
    min-height: calc(100vh - 5.5rem) !important;
    padding-top: 5.5rem;
    padding-bottom: 2.5rem;
  }
  
  /* 照片墙容器优化 */
  #photo-wall-container {
    gap: 1rem;
  }
}

@media (min-width: 1024px) {
  .lg\:grid-cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  
  /* 响应式设计 - 大屏幕额外优化 */
  .max-w-5xl {
    max-width: 7xl;
  }
  
  /* 大屏幕布局优化 */
  #love-story-container, #countdown-container {
    max-width: 5xl;
  }
}

/* 横竖屏适配 */
@media (orientation: landscape) and (max-width: 768px) {
  section {
    min-height: auto !important;
    padding: 5rem 0 2rem 0;
  }
  
  #home-photo-container {
    max-height: 70vh;
    overflow: hidden;
  }
  
  #home-photo-container img {
    object-fit: contain;
    width: 100%;
    height: 100%;
  }
}

/* 高分辨率屏幕优化 */
@media (-webkit-device-pixel-ratio: 2), (resolution: 192dpi) {
  /* 优化高DPI屏幕上的字体渲染 */
  body {
    -webkit-font-smoothing: subpixel-antialiased;
  }
}

.container { width: 100%; margin-left: auto; margin-right: auto; padding-left: 1rem; padding-right: 1rem; }
@media (min-width: 640px) { .container { max-width: 640px; } }
@media (min-width: 768px) { .container { max-width: 768px; } }
@media (min-width: 1024px) { .container { max-width: 1024px; } }
@media (min-width: 1280px) { .container { max-width: 1280px; } }

/* Tailwind配置需要保留在HTML中或单独配置，这里只放自定义样式 */
@layer utilities {
  .text-shadow {
    text-shadow: 0 2px 4px rgba(0,0,0,0.1);
  }
  .text-shadow-lg {
    text-shadow: 0 4px 8px rgba(0,0,0,0.25);
  }
  .bg-gradient-love {
    background: linear-gradient(135deg, #ff8096 0%, #994dff 100%);
  }
  .animate-float {
    animation: float 6s ease-in-out infinite;
  }
  .animate-fade-in {
    animation: fadeIn 0.8s ease-in-out forwards;
  }
  .animate-shake {
    animation: shake 0.5s ease-in-out;
  }
  .scrollbar-hide::-webkit-scrollbar {
    display: none;
  }
  .scrollbar-hide {
    -ms-overflow-style: none;
    scrollbar-width: none;
  }
}

/* 导航栏样式 */
.nav-link {
  position: relative;
  transition: color 0.3s ease;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--love-primary);
  transition: width 0.3s ease;
}

.nav-link:hover::after,
.nav-link.active::after {
  width: 100%;
}

/* 时间线样式 */
.timeline-dot {
  position: relative;
  z-index: 10;
}

.timeline-line {
  background: linear-gradient(180deg, var(--love-primary) 0%, var(--romance-primary) 100%);
}

/* 祝福卡片样式 */
.wish-card {
  transition: all 0.3s ease;
  border-left: 4px solid transparent;
}

.wish-card:hover {
  border-left-color: var(--love-primary);
  transform: translateY(-2px);
}

/* 个人介绍卡片 */
.profile-card {
  transition: all 0.3s ease;
}

.profile-card:hover {
  transform: scale(1.05);
}

/* 响应式调整 */
@media (max-width: 768px) {
  .timeline-container {
    padding-left: 2rem;
  }
  
  .timeline-line {
    left: 1rem;
  }
  
  .timeline-dot {
    left: 0.5rem;
  }
}

/* 自定义动画 */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

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

@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* 全局样式补充 */
html {
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* 图片优化样式 */
img {
  max-width: 100%;
  height: auto;
}

/* 移除懒加载的opacity限制，让图片正常显示 */

/* 移动设备优化 */
@media (max-width: 768px) {
  /* 触摸目标优化 */
  button, a, .btn, .nav-link {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
  }
  
  /* 修复移动端点击延迟 */
  * {
    -webkit-tap-highlight-color: transparent;
  }
  
  /* 调整移动设备内容间距 */
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  /* 调整移动端内容间距 - 但保持导航栏空间 */
  section {
    padding-top: 6rem !important;
    padding-bottom: 3rem !important;
  }
  
  #home {
    min-height: calc(100vh - 6rem) !important;
    padding-top: 6rem !important;
    padding-bottom: 3rem !important;
  }
  
  /* 优化卡片触摸反馈 */
  .card, .nav-item, .btn {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
  }

  .card:active, .nav-item:active, .btn:active {
    transform: scale(0.98);
  }
}/* 模态框样式优化 */
.modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

/* 模态框图片容器 */
.modal-image-container {
  max-height: 80vh !important;
  max-width: 90vw !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  position: relative !important;
}

/* 模态框图片 */
.modal-image {
  max-height: 80vh !important;
  max-width: 90vw !important;
  width: auto !important;
  height: auto !important;
  object-fit: contain !important;
}

/* 模态框关闭按钮样式 */
.modal-close-btn {
  position: absolute !important;
  z-index: 9999 !important;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  border: none;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  padding: 0.25rem 0.75rem;
  white-space: nowrap;
}

.modal-close-btn:hover {
  transform: scale(1.1);
  border-color: rgba(255, 255, 255, 0.8);
}

.modal-close-btn-alt {
  /* 备用按钮样式 */
  z-index: 55 !important;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  /* 固定定位，相对于视口 */
  position: fixed !important;
  /* 确保按钮可点击 */
  pointer-events: auto !important;
  /* 确保按钮显示 */
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  /* 确保按钮可见 */
  opacity: 1 !important;
  visibility: visible !important;
}

.modal-close-btn-alt:hover {
  background-color: rgba(0, 0, 0, 0.8);
  transform: translateY(-1px);
}

/* 确保模态框内容可滚动 */
.modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

/* 模态框背景点击区域优化 */
.modal-backdrop {
  /* 增加点击区域的容错性 */
  cursor: pointer;
}

/* 减少动画对性能的影响 */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 照片墙样式 - 性能优化版本 */
#photo-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  padding: 1rem 0;
  /* 启用GPU加速 */
  transform: translateZ(0);
  will-change: transform;
}

#photo-gallery img {
  transition: transform var(--transition-normal) ease, opacity var(--transition-normal) ease;
  cursor: pointer;
  /* 性能优化属性 */
  backface-visibility: hidden;
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  -webkit-font-smoothing: antialiased;
  /* 图片渲染优化 */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
  /* 防止布局偏移 */
  contain: layout;
}

#photo-gallery img:hover {
  transform: scale(1.02) translateZ(0);
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  will-change: transform;
}

/* 图片加载状态优化 */
#photo-gallery img:not(.loaded) {
  opacity: 0.7;
  filter: blur(1px);
}

#photo-gallery img.loaded {
  opacity: 1;
  filter: blur(0);
}

#photo-gallery .loaded {
  animation: fadeIn 0.5s ease-in;
}

/* 照片容器样式，防止布局跳动 */
#photo-gallery .photo-container {
  position: relative;
  overflow: hidden;
  border-radius: 0.5rem;
  min-height: 12rem; /* 减少最小高度，让布局更紧凑 */
  background-color: #f3f4f6;
}

/* 已加载图片的稳定显示 */
#photo-gallery img[data-loaded="true"] {
  opacity: 1 !important;
  visibility: visible !important;
  display: block !important;
}

/* 占位符样式优化 */
.loading-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
  z-index: 1;
}

/* 优化的加载动画和过渡效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.opacity-0 {
  opacity: 0;
}

.opacity-100 {
  opacity: 1;
}

/* 加载占位符动画 */
@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.animate-pulse {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* 旋转加载动画 */
@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

.animate-spin {
  animation: spin 1s linear infinite;
}

/* 照片墙响应式设计 */
@media (max-width: 768px) {
  #photo-gallery {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    padding: 0.75rem 0;
  }
}

@media (max-width: 480px) {
  #photo-gallery {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    padding: 0.5rem 0;
  }
}

/* 密码验证震动动画 */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/*
🔐 密码保护功能说明：

默认密码：love520

修改密码方法：
1. 打开 js/main.js 文件
2. 找到 correctPassword 变量
3. 修改为您的密码

💡 提示：
- 密码保存在浏览器会话中
- 关闭浏览器后需要重新输入
- 建议使用有意义的密码
*/

/* 首页背景图片容器 - 确保充满整个section */
#home-background-container {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
  z-index: -20 !important;
}

#home-background-container img {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
}

/* 手机端背景图片调整 */
@media (max-width: 768px) {
  #home-background-container img {
    object-position: center center !important;
  }
}

/* 桌面端背景图片调整 */
@media (min-width: 769px) {
  #home-background-container img {
    object-position: center 30% !important;
  }
}