/* 
 * 德育安全教育网 - 自定义样式
 * 补充Tailwind CSS的样式，提供特殊效果和动画
 */

/* ============ 全局样式 ============ */
:root {
  --primary-color: #3B82F6;
  --secondary-color: #F59E0B;
  --text-dark: #1F2937;
  --text-light: #6B7280;
  --bg-light: #F9FAFB;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* 移动端触摸优化 */
  -webkit-tap-highlight-color: transparent;
}

html {
  scroll-behavior: smooth;
  /* 防止移动端横向滚动 */
  overflow-x: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  line-height: 1.6;
  color: var(--text-dark);
  overflow-x: hidden;
  /* 移动端字体平滑 */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* 防止文本大小调整 */
  -webkit-text-size-adjust: 100%;
  -ms-text-size-adjust: 100%;
}

/* ============ 导航栏样式 ============ */
.navbar {
  transition: all 0.3s ease;
}

.navbar.scrolled {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
}

.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(--primary-color);
  transition: width 0.3s ease;
}

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

/* ============ 轮播图样式 ============ */
.carousel {
  position: relative;
  overflow: hidden;
}

.carousel-inner {
  display: flex;
  transition: transform 0.6s ease-in-out;
}

.carousel-item {
  flex: 0 0 100%;
  position: relative;
}

.carousel-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.carousel-caption {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
  color: white;
  padding: 3rem 2rem 2rem;
}

.carousel-controls {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 100%;
  display: flex;
  justify-content: space-between;
  padding: 0 1rem;
  pointer-events: none;
}

.carousel-control {
  pointer-events: all;
  background: rgba(255, 255, 255, 0.8);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

.carousel-control:hover {
  background: white;
  transform: scale(1.1);
}

.carousel-indicators {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0.5rem;
}

.carousel-indicator {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
}

.carousel-indicator.active {
  background: white;
  width: 32px;
  border-radius: 6px;
}

/* ============ 卡片样式 ============ */
.card {
  transition: all 0.3s ease;
  cursor: pointer;
  /* 移动端触摸反馈 */
  -webkit-tap-highlight-color: rgba(59, 130, 246, 0.1);
}

.card:hover {
  transform: translateY(-8px);
  box-shadow: var(--shadow-lg);
}

/* 移动端使用active而不是hover */
@media (hover: none) and (pointer: coarse) {
  .card:hover {
    transform: none;
  }
  
  .card:active {
    transform: scale(0.98);
    box-shadow: var(--shadow-md);
  }
}

.card-icon {
  transition: transform 0.3s ease;
}

.card:hover .card-icon {
  transform: scale(1.1) rotate(5deg);
}

/* ============ 主题颜色样式 ============ */
.topic-card.blue { --topic-color: #3B82F6; }
.topic-card.yellow { --topic-color: #F59E0B; }
.topic-card.red { --topic-color: #EF4444; }
.topic-card.green { --topic-color: #10B981; }
.topic-card.purple { --topic-color: #8B5CF6; }
.topic-card.indigo { --topic-color: #6366F1; }
.topic-card.orange { --topic-color: #F97316; }
.topic-card.pink { --topic-color: #EC4899; }
.topic-card.teal { --topic-color: #14B8A6; }

.topic-card {
  border-top: 4px solid var(--topic-color);
}

.topic-card .card-icon {
  color: var(--topic-color);
}

.topic-card .btn-primary {
  background: var(--topic-color);
}

.topic-card .btn-primary:hover {
  opacity: 0.9;
}

/* ============ 按钮样式 ============ */
.btn {
  transition: all 0.3s ease;
  cursor: pointer;
  border: none;
  outline: none;
  /* 移动端触摸目标 */
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 防止文本选择 */
  user-select: none;
  -webkit-user-select: none;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.btn:active {
  transform: translateY(0);
  opacity: 0.9;
}

/* 移动端按钮优化 */
@media (hover: none) and (pointer: coarse) {
  .btn:hover {
    transform: none;
  }
  
  .btn:active {
    transform: scale(0.96);
  }
}

/* ============ 返回顶部按钮 ============ */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 48px;
  height: 48px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
}

.back-to-top:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

/* ============ 加载动画 ============ */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

/* ============ 面包屑导航 ============ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--text-light);
}

.breadcrumb a {
  color: var(--primary-color);
  text-decoration: none;
  transition: color 0.3s ease;
}

.breadcrumb a:hover {
  color: var(--secondary-color);
}

.breadcrumb-separator {
  color: var(--text-light);
}

/* ============ 标签样式 ============ */
.tag {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  background: var(--bg-light);
  color: var(--text-dark);
  transition: all 0.3s ease;
}

.tag:hover {
  background: var(--primary-color);
  color: white;
}

/* ============ 响应式图片 ============ */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ============ 视频容器 ============ */
.video-container {
  position: relative;
  padding-bottom: 56.25%; /* 16:9 宽高比 */
  height: 0;
  overflow: hidden;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* ============ 列表样式 ============ */
.custom-list {
  list-style: none;
  padding-left: 0;
}

.custom-list li {
  position: relative;
  padding-left: 2rem;
  margin-bottom: 1rem;
}

.custom-list li::before {
  content: '✓';
  position: absolute;
  left: 0;
  top: 0;
  width: 1.5rem;
  height: 1.5rem;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  font-weight: bold;
}

/* ============ 引用块样式 ============ */
blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: 1.5rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--text-light);
}

/* ============ 页脚样式 ============ */
footer {
  background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
  color: white;
}

footer a {
  color: rgba(255, 255, 255, 0.8);
  text-decoration: none;
  transition: color 0.3s ease;
}

footer a:hover {
  color: white;
}

/* ============ 汉堡菜单动画 ============ */
.hamburger {
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
}

.hamburger span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--text-dark);
  transition: all 0.3s ease;
}

.hamburger.active span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}

.hamburger.active span:nth-child(2) {
  opacity: 0;
}

.hamburger.active span:nth-child(3) {
  transform: rotate(-45deg) translate(7px, -7px);
}

/* ============ 移动端菜单 ============ */
.mobile-menu {
  position: fixed;
  top: 0;
  right: -100%;
  width: 80%;
  max-width: 320px;
  height: 100vh;
  background: white;
  box-shadow: var(--shadow-lg);
  transition: right 0.3s ease;
  z-index: 999;
  overflow-y: auto;
}

.mobile-menu.active {
  right: 0;
}

.mobile-menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  z-index: 998;
}

.mobile-menu-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ============ 响应式设计 ============ */

/* 移动端优化 */
@media (max-width: 768px) {
  /* 轮播图优化 */
  .carousel-caption {
    padding: 1.5rem 1rem 1rem;
  }
  
  .carousel-caption h2 {
    font-size: 1.5rem;
    line-height: 1.3;
  }
  
  .carousel-caption p {
    font-size: 0.95rem;
    line-height: 1.5;
  }
  
  /* 返回顶部按钮 */
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 48px;
    height: 48px;
  }
  
  /* 触摸目标优化 - 确保按钮至少44x44px */
  .btn, button, a.inline-block {
    min-height: 44px;
    padding: 0.75rem 1.5rem;
  }
  
  /* 卡片间距优化 */
  .card {
    margin-bottom: 1rem;
  }
  
  /* 导航栏优化 */
  .navbar {
    padding: 0.5rem 0;
  }
  
  /* 字体大小优化 */
  body {
    font-size: 16px; /* 防止iOS自动缩放 */
  }
  
  h1 {
    font-size: 1.5rem;
  }
  
  h2 {
    font-size: 1.35rem;
  }
  
  h3 {
    font-size: 1.2rem;
  }
  
  /* 表单元素优化 */
  input, textarea, select {
    font-size: 16px; /* 防止iOS自动缩放 */
    min-height: 44px;
  }
  
  /* 移动端导航优化 */
  .nav-link {
    padding: 1rem;
    display: block;
  }
}

/* 小屏手机优化 */
@media (max-width: 375px) {
  .carousel-caption h2 {
    font-size: 1.25rem;
  }
  
  .carousel-caption p {
    font-size: 0.85rem;
  }
  
  /* Logo和标题缩小 */
  .navbar svg {
    width: 2rem;
    height: 2rem;
  }
  
  .navbar h1 {
    font-size: 0.95rem;
  }
  
  .navbar p {
    font-size: 0.65rem;
  }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
  .carousel {
    height: 60vh;
  }
  
  .carousel-caption {
    padding: 1rem;
  }
  
  .carousel-caption h2 {
    font-size: 1.3rem;
  }
  
  .carousel-caption p {
    font-size: 0.85rem;
  }
}

/* ============ 打印样式 ============ */
@media print {
  .navbar,
  .back-to-top,
  .carousel-controls,
  .carousel-indicators,
  footer {
    display: none;
  }
  
  body {
    font-size: 12pt;
  }
  
  .card {
    page-break-inside: avoid;
  }
}

/* ============ 辅助功能 ============ */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ============ 选中文本样式 ============ */
::selection {
  background: var(--primary-color);
  color: white;
}

::-moz-selection {
  background: var(--primary-color);
  color: white;
}

/* ============ 滚动条样式 ============ */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

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

::-webkit-scrollbar-thumb {
  background: #CBD5E1;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: #94A3B8;
}

