/* ==================== Tailwind CSS 无法处理的自定义样式 ==================== */

/* ==================== 宣纸纹理背景 ==================== */
body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.01) 2px,
      rgba(0, 0, 0, 0.01) 4px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 0, 0, 0.01) 2px,
      rgba(0, 0, 0, 0.01) 4px
    );
  pointer-events: none;
  z-index: 0;
  opacity: 0.3;
}

/* 深色模式下的宣纸纹理（更暗） */
.dark body::before {
  background:
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.02) 2px,
      rgba(255, 255, 255, 0.02) 4px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(255, 255, 255, 0.02) 2px,
      rgba(255, 255, 255, 0.02) 4px
    );
  opacity: 0.2;
}

/* ==================== 汉堡菜单 X 动画 ==================== */
.hamburger-line {
  transition: all 0.3s ease;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(9px) rotate(45deg);
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}

.mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-12px) rotate(-45deg);
}

/* 移动端 X 动画适配 */
@media (max-width: 480px) {
  .mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(1) {
    transform: translateY(7.5px) rotate(45deg);
  }
  .mobile-menu-toggle[aria-expanded="true"] .hamburger-line:nth-child(3) {
    transform: translateY(-10px) rotate(-45deg);
  }
}

/* ==================== Toast 提示框样式 ==================== */
.toast {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 10000;
  pointer-events: none;
  animation: fadeInOut 2s ease-in-out;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Toast 动画 */
@keyframes fadeInOut {
  0% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
  10% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  90% {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(-10px);
  }
}

/* ==================== 心跳动画 ==================== */
@keyframes heartbeat {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
}

.heart {
  display: inline-block;
  animation: heartbeat 1.5s ease-in-out infinite;
}

/* ==================== Modal 动画 ==================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

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

.modal-overlay.show {
  display: flex !important;
  animation: fadeIn 0.3s ease;
}

.modal-container {
  animation: slideUp 0.3s ease;
}

/* ==================== 导航下划线动画 ==================== */
.nav-link {
  position: relative;
}

.nav-link::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 2px;
  background-color: #2FA39A;
  transition: width 0.3s ease;
}

.dark .nav-link::after {
  background-color: #E8F5F4;
}

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

/* 移动端改为左侧竖线 */
@media (max-width: 768px) {
  .nav-link::after {
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 0;
  }

  .nav-link:hover::after,
  .nav-item.active .nav-link::after {
    width: 4px;
    height: 60%;
  }
}

/* ==================== Modal 标题下划线 ==================== */
.modal-title {
  position: relative;
}

.modal-title::after {
  content: '';
  display: block;
  width: 60px;
  height: 3px;
  background-color: #2FA39A;
  margin: 15px auto 0;
  border-radius: 2px;
}

.dark .modal-title::after {
  background-color: #E8F5F4;
}

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

::-webkit-scrollbar-track {
  background-color: #f9f6f0;
}

.dark ::-webkit-scrollbar-track {
  background-color: #1a1a1a;
}

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

.dark ::-webkit-scrollbar-thumb {
  background-color: #3a3a3a;
}

::-webkit-scrollbar-thumb:hover {
  background-color: #9ca3af;
}

.dark ::-webkit-scrollbar-thumb:hover {
  background-color: #4b5563;
}

/* ==================== 导航包裹器激活状态（移动端） ==================== */
@media (max-width: 768px) {
  .nav-wrapper.active {
    transform: translateX(0) !important;
  }
}

/* ==================== 主题下拉菜单样式 ==================== */
.theme-dropdown {
  position: relative;
}

/* 下拉菜单容器 */
.theme-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 140px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s ease;
  z-index: 1000;
}

/* 深色模式下的菜单 */
.dark .theme-menu {
  background: #2a2a2a;
  border-color: #3a3a3a;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* 显示状态 */
.theme-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* 菜单项 */
.theme-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid #f0f0f0;
}

.dark .theme-menu-item {
  border-bottom-color: #3a3a3a;
}

.theme-menu-item:last-child {
  border-bottom: none;
}

.theme-menu-item:hover {
  background-color: #f5f5f5;
}

.dark .theme-menu-item:hover {
  background-color: #333;
}

/* 激活状态 */
.theme-menu-item.active {
  background-color: rgba(47, 163, 154, 0.1);
  color: #2FA39A;
}

.dark .theme-menu-item.active {
  background-color: rgba(47, 163, 154, 0.2);
  color: #2FA39A;
}

/* 图标样式 */
.theme-menu-item i {
  width: 16px;
  text-align: center;
  font-size: 14px;
}

/* 小三角（装饰） */
.theme-menu::before {
  content: '';
  position: absolute;
  top: -6px;
  right: 12px;
  width: 12px;
  height: 12px;
  background: white;
  border-left: 1px solid #e0e0e0;
  border-top: 1px solid #e0e0e0;
  transform: rotate(45deg);
}

.dark .theme-menu::before {
  background: #2a2a2a;
  border-color: #3a3a3a;
}

/* ==================== 防止登录状态闪烁 ==================== */
/* 登录按钮默认显示，但登录状态下隐藏 */
.is-logged-in .login-btn {
  display: none !important;
}

/* 用户信息默认隐藏（HTML中有hidden类），但登录状态下显示 */
.is-logged-in .user-info {
  display: flex !important;
}

/* ==================== 收藏按钮激活状态 ==================== */
/* 已收藏状态的按钮样式 */
.favorite-btn.active {
  color: #ef4444 !important; /* 红色文字 */
  border-color: #ef4444 !important; /* 红色边框 */
  background-color: rgba(239, 68, 68, 0.05) !important; /* 淡红色背景 */
}

/* 深色模式下的已收藏状态 */
.dark .favorite-btn.active {
  color: #f87171 !important; /* 浅红色文字 */
  border-color: #f87171 !important; /* 浅红色边框 */
  background-color: rgba(248, 113, 113, 0.1) !important; /* 淡红色背景 */
}

/* 已收藏按钮的图标样式 */
.favorite-btn.active i {
  color: #ef4444 !important; /* 红色图标 */
}

/* 深色模式下已收藏按钮的图标样式 */
.dark .favorite-btn.active i {
  color: #f87171 !important; /* 浅红色图标 */
}

/* 已收藏按钮悬停效果 */
.favorite-btn.active:hover {
  background-color: rgba(239, 68, 68, 0.1) !important;
  transform: scale(1.05);
}

.dark .favorite-btn.active:hover {
  background-color: rgba(248, 113, 113, 0.15) !important;
}

/* ==================== SEO 友好的链接样式 ==================== */
/* 通用块级链接 */
.block-link,
.poem-card-link {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: all 0.3s ease;
}

.block-link:hover,
.block-link:focus,
.poem-card-link:hover,
.poem-card-link:focus {
  text-decoration: none;
  color: inherit;
}

/* 确保嵌套链接的点击区域正确 */
.poem-card {
  position: relative;
}

.poem-card .author-link {
  position: relative;
  z-index: 10;
  display: inline-block;
}

/* 侧边栏项目作为链接 */
a.sidebar-item {
  display: block;
  color: inherit;
  text-decoration: none;
  transition: all 0.3s ease;
}

a.sidebar-item:hover,
a.sidebar-item:focus {
  text-decoration: none;
}

/* 禁用浏览器默认的链接样式 */
.no-underline {
  text-decoration: none !important;
}

a.no-underline:hover,
a.no-underline:focus {
  text-decoration: none !important;
}

/* 确保链接内的元素继承正确的颜色 */
.poem-card-link h2,
.poem-card-link .text-2xl {
  transition: color 0.3s ease;
}

/* 深色模式下的链接样式 */
.dark .block-link,
.dark .poem-card-link,
.dark a.sidebar-item {
  color: inherit;
}

.dark .block-link:hover,
.dark .block-link:focus,
.dark .poem-card-link:hover,
.dark .poem-card-link:focus,
.dark a.sidebar-item:hover,
.dark a.sidebar-item:focus {
  color: inherit;
}
