:root {
  --primary-color: #1a237e;
  --secondary-color: #0d47a1;
  --accent-color: #5c6bc0;
  --text-dark: #212121;
  --text-light: #f5f5f5;
  --background-light: #ffffff;
  --background-dark: #f5f5f5;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s ease;
}

/* 性能优化 - 仅对需要的元素启用硬件加速 */
img, video, .hero, .card {
  /* 启用硬件加速 */
  transform: translateZ(0);
  /* 优化渲染性能 */
  will-change: auto;
}

/* 减少重绘和回流 */
img, video {
  /* 防止图片导致布局抖动 */
  max-width: 100%;
  height: auto;
  /* 启用GPU加速 */
  transform: translateZ(0);
  /* 优化图片渲染 */
  image-rendering: -webkit-optimize-contrast;
  image-rendering: crisp-edges;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  line-height: 1.6;
  color: var(--text-dark);
  background-color: var(--background-light);
  /* 确保没有额外的空白 */
  overflow-x: hidden;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
}

h1, h2, h3, h4, h5, h6 {
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
  margin-bottom: 1rem;
  color: var(--primary-color);
}

a {
  text-decoration: none;
  color: var(--secondary-color);
  transition: var(--transition);
}

a:hover {
  color: var(--accent-color);
}

section {
  padding: 5rem 0;
  margin: 0;
}

/* page-header需要特殊的margin-top来避开导航栏 */
section.page-header {
  margin-top: 80px !important;
  /* 强制Chrome正确渲染 */
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}

/* 确保第一个section（hero）没有额外的上边距 */
section:first-of-type:not(.page-header) {
  margin-top: 0;
  padding-top: 0;
}

/* 为page-header添加通用样式，确保正确处理导航栏偏移 */
.page-header {
  margin-top: 80px !important;
}

.btn {
  display: inline-block;
  padding: 12px 24px;
  background-color: var(--primary-color);
  color: var(--text-light);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
  text-align: center;
}

.btn:hover {
  background-color: var(--secondary-color);
  color: var(--text-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.btn-outline {
  background-color: transparent;
  border: 2px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: var(--text-light);
}

/* Header and Navigation */
header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background-color: rgba(255, 255, 255, 0.95);
  box-shadow: var(--shadow);
}

.navbar {
  height: 80px;
  display: flex;
  align-items: center;
}

.navbar .container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.logo {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--primary-color);
  font-family: "Microsoft YaHei", "微软雅黑", sans-serif;
}

.nav-links {
  display: flex;
  gap: 2rem;
}

.nav-links a {
  font-weight: 500;
  color: var(--text-dark);
  position: relative;
}

.nav-links a::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 0;
  height: 2px;
  background-color: var(--primary-color);
  transition: var(--transition);
}

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

.menu-toggle {
  display: none;
  flex-direction: column;
  cursor: pointer;
  padding: 5px;
  gap: 4px;
}

.menu-toggle span {
  width: 25px;
  height: 3px;
  background-color: var(--primary-color);
  transition: var(--transition);
  border-radius: 2px;
}

.menu-toggle:hover span {
  background-color: var(--secondary-color);
}

/* 菜单动画 */
.nav-links.active ~ .menu-toggle span:nth-child(1) {
  transform: rotate(45deg) translate(6px, 6px);
}

.nav-links.active ~ .menu-toggle span:nth-child(2) {
  opacity: 0;
}

.nav-links.active ~ .menu-toggle span:nth-child(3) {
  transform: rotate(-45deg) translate(6px, -6px);
}

/* Hero Section - 优化版本 */
.hero {
  height: 100vh;
  min-height: 700px;
  display: flex;
  align-items: center;
  position: relative;
  background: linear-gradient(to right, #1a237e, #283593);
  background-size: cover;
  background-position: center;
  color: var(--text-light);
  /* 移除margin-top，使用padding-top来避免被导航栏遮挡 */
  padding-top: 80px;
  /* 调整高度计算以考虑padding */
  min-height: calc(100vh - 80px);
  /* 性能优化 */
  will-change: background-image;
  transform: translateZ(0);
  /* 预设背景以避免闪烁 */
  background-attachment: fixed;
}

.hero-loaded {
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  transition: background-image 0.3s ease-out;
}

.hero-preview {
  background: linear-gradient(rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.7)), url('/images/gallery/shanghai-community-tiny.jpg');
  background-size: cover;
  background-position: center;
  filter: blur(3px);
  transition: filter 0.3s ease-out;
}

.hero-preview.loaded {
  filter: blur(0);
}

/* Hero按钮优化 */
.hero-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 2rem;
}

.hero-buttons .btn {
  /* 防止按钮导致重排 */
  min-width: 120px;
  text-align: center;
}

.hero-content {
  max-width: 700px;
}

.hero-content h1 {
  font-size: 3.5rem;
  margin-bottom: 1.5rem;
  color: var(--text-light);
}

.hero-content p {
  font-size: 1.2rem;
  margin-bottom: 2rem;
}

/* About Section */
.about-section {
  background-color: var(--background-dark);
  padding: 6rem 0;
}

.about-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3rem;
  align-items: center;
}

.about-image {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  height: auto;
  position: relative;
}

.about-image .progressive-image-container {
  width: 100%;
  height: auto;
  position: relative;
}

.about-image .progressive-image {
  width: 100%;
  height: auto;
  object-fit: contain;
  position: relative;
  top: auto;
  left: auto;
}

.about-image .progressive-image-placeholder {
  width: 100%;
  height: auto;
  background-size: contain;
  background-position: center;
  position: relative;
  top: auto;
  left: auto;
}

.about-image img {
  width: 100%;
  height: auto;
  transition: var(--transition);
}

.about-content h2 {
  font-size: 2.5rem;
  margin-bottom: 1.5rem;
}

.about-content p {
  margin-bottom: 1.5rem;
}

/* Courses Section */
.courses-section {
  padding: 6rem 0;
}

.courses-header {
  text-align: center;
  margin-bottom: 3rem;
}

.courses-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
}

.course-card {
  background-color: var(--background-light);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.course-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.course-content {
  padding: 1.5rem;
}

.course-content h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

/* Certificates Section */
.certificates-section {
  background-color: var(--background-dark);
  padding: 6rem 0;
}

.certificates-header {
  text-align: center;
  margin-bottom: 3rem;
}

.certificates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 2rem;
}

.certificate-card {
  background-color: var(--background-light);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: var(--transition);
}

.certificate-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.certificate-image {
  height: auto;
  min-height: 200px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #f8f9fa;
}

.certificate-image img {
  width: 100%;
  height: auto;
  object-fit: contain;
  transition: var(--transition);
  max-height: 300px;
}

.certificate-card:hover .certificate-image img {
  transform: scale(1.05);
}

.certificate-content {
  padding: 1.5rem;
}

.certificate-content h3 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

/* Gallery Section */
.gallery-section {
  padding: 6rem 0;
}

.gallery-header {
  text-align: center;
  margin-bottom: 3rem;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}

.gallery-item {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  position: relative;
}

.gallery-item img {
  width: 100%;
  height: 250px;
  object-fit: cover;
  transition: var(--transition);
}

.gallery-item:hover img {
  transform: scale(1.05);
}

.gallery-item::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: var(--transition);
}

.gallery-item:hover::after {
  opacity: 1;
}

/* Videos Section */
.videos-section {
  background-color: var(--background-dark);
  padding: 6rem 0;
}

.videos-header {
  text-align: center;
  margin-bottom: 3rem;
}

.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 2rem;
}

.video-container {
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.video-container video {
  width: 100%;
  height: auto;
}

/* Simple Footer */
.simple-footer {
  background: linear-gradient(135deg, #0a1030 0%, #1a237e 100%);
  color: var(--text-light);
  padding: 1.5rem 0;
  position: relative;
}

.simple-footer::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(92, 107, 192, 0.5), transparent);
}

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

.copyright-text {
  color: rgba(245, 245, 245, 0.8);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  padding: 0.5rem 1rem;
  border-radius: 4px;
}

.copyright-text:hover {
  color: var(--accent-color);
  background: rgba(255, 255, 255, 0.1);
}

/* 二维码弹窗样式 */
.qr-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  justify-content: center;
  align-items: center;
}

.qr-modal-content {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  position: relative;
  max-width: 90%;
  max-height: 90%;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.qr-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  color: #999;
  transition: var(--transition);
}

.qr-close:hover {
  color: #333;
}

.qr-popup {
  height: 200px !important;
  width: auto;
  display: block;
  margin: 0 auto 1rem auto;
  border-radius: 8px;
}

.qr-modal-content p {
  margin: 0;
  color: #666;
  font-size: 1rem;
}

/* Responsive Design */
@media (max-width: 992px) {
  .hero-content h1 {
    font-size: 3rem;
  }

  .about-container {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .about-image {
    order: -1;
    margin-bottom: 0;
  }

  .about-image .progressive-image-container {
    max-height: 350px;
    overflow: hidden;
  }

  .about-content {
    padding-top: 0;
  }
}

@media (max-width: 768px) {
  .navbar {
    height: 70px;
  }

  .about-section {
    padding: 4rem 0 3rem;
  }

  .about-image .progressive-image-container {
    max-height: 300px;
  }

  .about-content h2 {
    margin-top: 0;
    font-size: 2rem;
  }

  .about-content p {
    margin-bottom: 1rem;
  }

  .nav-links {
    position: fixed;
    top: 70px;
    right: -100%;
    width: 80%;
    height: calc(100vh - 70px);
    background-color: var(--background-light);
    flex-direction: column;
    align-items: center;
    padding: 2rem 0;
    gap: 1.5rem;
    transition: var(--transition);
    box-shadow: -5px 0 10px rgba(0, 0, 0, 0.1);
  }

  .nav-links.active {
    right: 0;
  }

  .menu-toggle {
    display: block;
  }

  .hero-content h1 {
    font-size: 2.5rem;
  }

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

  /* Footer responsive */
  .qr-modal-content {
    padding: 1.5rem;
  }

  .qr-popup {
    height: 180px !important;
  }
}

@media (max-width: 576px) {
  .hero-content h1 {
    font-size: 2rem;
  }

  section {
    padding: 4rem 0;
  }

  /* Footer mobile */
  .simple-footer {
    padding: 1.5rem 0;
  }

  .copyright-text {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }

  .qr-modal-content {
    padding: 1rem;
    margin: 1rem;
  }

  .qr-popup {
    height: 160px !important;
  }
}

/* 渐进式图片加载样式 */
.progressive-image-container {
  position: relative;
  overflow: hidden;
  background-color: #f0f0f0;
}

.progressive-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.progressive-image.loaded {
  opacity: 1;
}

.progressive-image-placeholder {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  filter: blur(10px);
  transform: scale(1.1);
  transition: filter 0.3s ease-out;
}

.progressive-image-placeholder.loaded {
  filter: blur(0);
  transform: scale(1);
}

/* 优化图片加载性能 */
img {
  max-width: 100%;
  height: auto;
  display: block;
  /* 防止图片加载时的布局抖动 */
  background-color: #f0f0f0;
  /* 优化图片渲染 */
  image-rendering: -webkit-optimize-contrast;
  /* 启用硬件加速 */
  transform: translateZ(0);
  /* 平滑过渡 */
  transition: opacity 0.3s ease-in-out;
}

/* 图片加载状态 */
img[data-src] {
  opacity: 0;
}

img[data-src].loaded {
  opacity: 1;
}

/* 渐进式图片加载 */
.progressive-image {
  opacity: 0;
  transition: opacity 0.5s ease;
}

.progressive-image.loaded {
  opacity: 1;
}

.progressive-image-placeholder {
  transition: filter 0.5s ease;
}

/* 数据节省模式优化 */
.data-saver img {
  filter: contrast(0.8) brightness(1.1);
}

.data-saver .progressive-image-container {
  background-color: #e0e0e0;
}

/* 中等质量模式 */
.medium-quality img {
  image-rendering: auto;
}

/* 高质量模式 */
.high-quality img {
  image-rendering: -webkit-optimize-contrast;
}

/* 添加图片加载动画 */
@keyframes imageLoadingPulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.8; }
  100% { opacity: 0.6; }
}

.image-loading {
  animation: imageLoadingPulse 1.5s infinite;
}

/* 视频缩略图增强样式 */
.video-thumbnail {
  position: relative;
  height: 200px;
  overflow: hidden;
  cursor: pointer;
  border-radius: 8px;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.featured-thumbnail {
  height: 100%;
  min-height: 350px;
  border-radius: 10px 0 0 10px;
}

.video-thumbnail:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.video-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}

.video-thumbnail:hover img {
  transform: scale(1.05);
}

.play-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60px;
  height: 60px;
  background-color: rgba(26, 35, 126, 0.8);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.5rem;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.video-thumbnail:hover .play-button {
  background-color: rgba(240, 0, 0, 0.9);
  transform: translate(-50%, -50%) scale(1.1);
}

/* 视频卡片增强样式 */
.video-card {
  background-color: var(--background-light);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.video-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

.video-card-info {
  padding: 1.5rem;
}

.video-card-info h4 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
  font-weight: 600;
}

.video-duration {
  color: var(--accent-color);
  margin-bottom: 1rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 5px;
}

.video-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: #666;
  margin-bottom: 1rem;
}

/* 视频模态框增强样式 */
.video-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  backdrop-filter: blur(10px);
}

.video-modal-content {
  position: relative;
  width: 90%;
  max-width: 1000px;
  background-color: var(--background-light);
  border-radius: 12px;
  overflow: hidden;
  padding: 20px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.video-modal-content h3 {
  text-align: center;
  margin-bottom: 15px;
  color: var(--primary-color);
  font-size: 1.5rem;
}

.modal-video-container {
  position: relative;
  width: 100%;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.loading-indicator {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  z-index: 1;
  backdrop-filter: blur(4px);
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary-color);
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

.loading-status {
  font-size: 14px;
  margin-top: 10px;
  opacity: 0.8;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.video-modal-close {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 28px;
  cursor: pointer;
  color: var(--primary-color);
  transition: color 0.3s ease;
  z-index: 10;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background-color: rgba(255, 255, 255, 0.9);
}

.video-modal-close:hover {
  color: #f44336;
  background-color: white;
}

.video-preloaded .play-button {
  background-color: rgba(76, 175, 80, 0.8);
}