/* 
  易哈佛医学插画 - 核心样式表
  包含：瀑布流、Swiper 自定义、弹窗动画及全局交互优化
*/

/* 1. 瀑布流基础布局 */
.masonry-grid {
  column-count: 4;
  column-gap: 1.5rem;
}

@media (max-width: 1200px) {
  .masonry-grid {
    column-count: 3;
  }
}

@media (max-width: 768px) {
  .masonry-grid {
    column-count: 2;
    column-gap: 1rem;
  }
}

.grid-item {
  break-inside: avoid;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.4s ease;
}

.grid-item:active {
  transform: scale(0.97) translateY(2px);
}

/* 2. Swiper 控件深度定制 */
.swiper-button-next,
.swiper-button-prev {
  width: 36px !important;
  height: 36px !important;
  background-color: rgba(0, 0, 0, 0.3) !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  background-size: 18px !important;
  border-radius: 50% !important;
  color: transparent !important;
  /* 强制隐藏可能的字符图标 */
  backdrop-filter: blur(4px) !important;
  user-select: none;
  -webkit-user-select: none;
  font-family: none !important;
  /* 彻底禁用系统字体图标库 */
}

/* 核心修复：完全屏蔽默认图标，改用自定义 SVG 背景 */
.swiper-button-next {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.swiper-button-prev {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='15 18 9 12 15 6'%3E%3C/polyline%3E%3C/svg%3E") !important;
}

.swiper-button-next:after,
.swiper-button-prev:after {
  content: none !important;
  display: none !important;
  /* 彻底移除伪元素层，防止图标重叠 */
}

.swiper-button-disabled {
  opacity: 0.1 !important;
  cursor: auto !important;
  pointer-events: none !important;
}

.swiper-pagination-bullet {
  background: #fff !important;
  opacity: 0.5 !important;
}

.swiper-pagination-bullet-active {
  opacity: 1 !important;
  transform: scale(1.2);
}

/* 3. 弹窗核心动画 (小红书式共享元素) */
#image-modal {
  transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1), backdrop-filter 0.5s ease;
}

#image-modal.modal-active {
  opacity: 1 !important;
  pointer-events: auto !important;
}

#image-modal .modal-wrapper {
  transition: transform 0.5s cubic-bezier(0.34, 1.2, 0.64, 1), opacity 0.4s ease;
  opacity: 0;
  will-change: transform, opacity;
}

#image-modal.modal-active .modal-wrapper {
  opacity: 1;
  transform: translate(0, 0) scale(1);
}

/* 4. 全局交互与视觉优化 */
* {
  -webkit-tap-highlight-color: transparent;
}

button:focus,
a:focus {
  outline: none !important;
}

/* 禁用 Swiper 内部意外选中与图片拖拽 */
.swiper {
  user-select: none;
  -webkit-user-select: none;
}

.swiper-slide img {
  pointer-events: none;
  -webkit-user-drag: none;
}

/* 5. 分类条辅助 */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.category-item {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.category-item:active {
  transform: scale(0.92);
}

/* 全局隐藏滚动条 (保持滚动功能，隐藏视觉条) */
::-webkit-scrollbar {
  display: none;
}

* {
  -ms-overflow-style: none;
  /* IE/Edge */
  scrollbar-width: none;
  /* Firefox */
}

/* 6. 图片加载占位与骨架屏 */
.img-container {
  background-color: #f1f5f9;
  position: relative;
  min-height: 180px;
  /* 手机端较小的基础占位 */
  overflow: hidden;
}

@media (min-width: 768px) {
  .img-container {
    min-height: 260px;
    /* 电脑端更适中的占位高度 */
  }
}

.img-container::after {
  content: "";
  position: absolute;
  inset: 0;
  transform: translateX(-100%);
  background: linear-gradient(90deg,
      transparent,
      rgba(255, 255, 255, 0.5),
      transparent);
  animation: skeleton-wave 1.5s infinite;
}

/* 图片加载完成后移除骨架动画 */
.img-loaded .img-container::after {
  display: none;
}

@keyframes skeleton-wave {
  100% {
    transform: translateX(100%);
  }
}

/* 破图容错 */
img:not([src]),
img[src=""] {
  opacity: 0;
}