/* ===== FancyBox 样式表 ===== */
/* 极简现代设计，支持亮色/暗色模式 */

/* ───── 基础重置 ───── */
.fb-hidden { display: none !important; }

/* ───── CSS变量（默认深色） ───── */
:root {
  --fb-overlay-bg: rgba(0,0,0,0.88);
  --fb-toolbar-bg: rgba(0,0,0,0.55);
  --fb-text-color: #fff;
  --fb-counter-color: rgba(255,255,255,0.7);
  --fb-caption-bg: linear-gradient(transparent, rgba(0,0,0,0.7));
  --fb-btn-hover: rgba(255,255,255,0.18);
  --fb-btn-active: rgba(255,255,255,0.30);
  --fb-shadow: 0 8px 32px rgba(0,0,0,0.6);
  --fb-radius: 12px;
  --fb-toolbar-radius: 10px;
  --fb-duration: 300ms;
  --fb-transition: cubic-bezier(0.25, 0.46, 0.45, 0.94);
  --fb-zoom-bg: rgba(255,255,255,0.06);
}

/* 亮色模式 - prefers-color-scheme 用户偏好 */
@media (prefers-color-scheme: light) {
  :root { --fb-overlay-bg: rgba(255,255,255,0.92);
          --fb-toolbar-bg: rgba(255,255,255,0.85);
          --fb-text-color: #222;
          --fb-counter-color: rgba(0,0,0,0.55);
          --fb-caption-bg: linear-gradient(transparent, rgba(255,255,255,0.85));
          --fb-btn-hover: rgba(0,0,0,0.08);
          --fb-btn-active: rgba(0,0,0,0.15);
          --fb-shadow: 0 8px 32px rgba(0,0,0,0.15);
          --fb-zoom-bg: rgba(0,0,0,0.04); }
}
/* 强制模式（通过JS设置 data-theme） */
[data-fb-theme="light"] { --fb-overlay-bg: rgba(255,255,255,0.92);
                          --fb-toolbar-bg: rgba(255,255,255,0.85);
                          --fb-text-color: #222;
                          --fb-counter-color: rgba(0,0,0,0.55);
                          --fb-caption-bg: linear-gradient(transparent, rgba(255,255,255,0.85));
                          --fb-btn-hover: rgba(0,0,0,0.08);
                          --fb-btn-active: rgba(0,0,0,0.15);
                          --fb-shadow: 0 8px 32px rgba(0,0,0,0.15);
                          --fb-zoom-bg: rgba(0,0,0,0.04); }

/* ───── 遮罩层 ───── */
.fb-overlay {
  position: fixed;  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;  justify-content: center;
  background: var(--fb-overlay-bg);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;          /* 不拦截点击 */
  transition: opacity var(--fb-duration) var(--fb-transition);
  touch-action: none;
}
.fb-overlay.fb-active { opacity: 1; pointer-events: auto; }

/* ───── 图片容器 ───── */
.fb-stage {
  position: relative;
  display: flex;  align-items: center;  justify-content: center;
  width: 100%;  height: 100%;
  padding: 60px 80px;
  box-sizing: border-box;
  overflow: hidden;
}

.fb-slide {
  position: absolute;
  display: flex;  align-items: center;  justify-content: center;
  width: 100%;  height: 100%;
  opacity: 0;
  transform: scale(0.92);
  transition: opacity calc(var(--fb-duration) * 0.6) var(--fb-transition),
              transform calc(var(--fb-duration) * 0.6) var(--fb-transition);
  will-change: transform, opacity;
}
.fb-slide.fb-active-img {
  opacity: 1;
  transform: scale(1);
}
.fb-slide.fb-leaving {
  opacity: 0;
  transform: scale(0.95);
}

.fb-slide img {
  max-width: 100%;  max-height: 100%;
  border-radius: var(--fb-radius);
  box-shadow: var(--fb-shadow);
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transition: transform var(--fb-duration) var(--fb-transition);
  cursor: grab;
}
.fb-slide img.fb-zoomed { cursor: grab; }
.fb-slide img.fb-dragging { cursor: grabbing; transition: none; }

/* ───── 加载中动画 ───── */
.fb-loader {
  position: absolute;
  width: 36px;  height: 36px;
  border: 3px solid rgba(255,255,255,0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: fb-spin 0.8s linear infinite;
}
@keyframes fb-spin { to { transform: rotate(360deg); } }

/* ───── 工具栏 ───── */
.fb-toolbar {
  position: absolute;
  top: 16px;  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: var(--fb-toolbar-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--fb-toolbar-radius);
  box-shadow: 0 2px 12px rgba(0,0,0,0.25);
  opacity: 0;
  transition: opacity var(--fb-duration) var(--fb-transition);
  z-index: 2;
  pointer-events: none;
}
.fb-active .fb-toolbar { opacity: 1; pointer-events: auto; }

.fb-btn {
  display: inline-flex;
  align-items: center;  justify-content: center;
  width: 36px;  height: 36px;
  border: none;  border-radius: 8px;
  background: transparent;
  color: var(--fb-text-color);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
  position: relative;
}
.fb-btn svg {
  width: 20px;  height: 20px;
  fill: currentColor;
  display: block;
}
.fb-btn:hover {
  background: var(--fb-btn-hover);
  transform: scale(1.12);
}
.fb-btn:active {
  background: var(--fb-btn-active);
  transform: scale(0.95);
}
.fb-btn.fb-active-btn {
  background: var(--fb-btn-active);
}
.fb-btn.fb-btn-disabled {
  opacity: 0.3;
  pointer-events: none;
  cursor: default;
}
.fb-reset-btn {
  font: 600 12px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  min-width: 40px;
  padding: 0 4px;
}

/* ───── 计数器 ───── */
.fb-counter {
  position: absolute;
  bottom: 24px;  left: 50%;
  transform: translateX(-50%);
  font: 500 14px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fb-counter-color);
  letter-spacing: 0.5px;
  opacity: 0;
  transition: opacity var(--fb-duration) var(--fb-transition);
  z-index: 2;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.fb-active .fb-counter { opacity: 1; }

/* ───── 标题 ───── */
.fb-caption {
  position: absolute;
  bottom: 0;  left: 0;  right: 0;
  padding: 50px 24px 18px;
  background: var(--fb-caption-bg);
  font: 400 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fb-text-color);
  text-align: center;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity var(--fb-duration) var(--fb-transition),
              transform var(--fb-duration) var(--fb-transition);
  z-index: 2;
  pointer-events: none;
}
.fb-active .fb-caption { opacity: 1; transform: translateY(0); }

/* ───── 导航箭头（左右） ───── */
.fb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;  height: 44px;
  display: flex;  align-items: center;  justify-content: center;
  border: none;  border-radius: 50%;
  background: var(--fb-toolbar-bg);
  backdrop-filter: blur(8px);
  color: var(--fb-text-color);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity var(--fb-duration) var(--fb-transition);
  opacity: 0;
  z-index: 3;
}
.fb-active .fb-nav { opacity: 1; }
.fb-nav:hover { background: var(--fb-btn-hover); transform: translateY(-50%) scale(1.1); }
.fb-nav:active { transform: translateY(-50%) scale(0.95); }
.fb-nav svg { width: 22px; height: 22px; fill: currentColor; }
.fb-nav-prev { left: 16px; }
.fb-nav-next { right: 16px; }
.fb-nav.fb-hidden { display: none; }

/* ───── 关闭按钮（独立于工具栏右侧） ───── */
.fb-close-btn {
  position: absolute;
  top: 16px;  right: 16px;
  width: 40px;  height: 40px;
  display: flex;  align-items: center;  justify-content: center;
  border: none;  border-radius: 50%;
  background: var(--fb-toolbar-bg);
  backdrop-filter: blur(8px);
  color: var(--fb-text-color);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, opacity var(--fb-duration) var(--fb-transition);
  opacity: 0;
  z-index: 3;
}
.fb-active .fb-close-btn { opacity: 1; }
.fb-close-btn:hover { background: #e74c3c; transform: scale(1.1); }
.fb-close-btn svg { width: 20px; height: 20px; fill: currentColor; }

/* ───── 缩略图网格（前台） ───── */
.fb-thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 8px;
  margin: 1em 0;
}
.fb-thumb-grid a { display: block; overflow: hidden; border-radius: 8px; transition: transform 0.2s ease; }
.fb-thumb-grid a:hover { transform: scale(1.03); }
.fb-thumb-grid img {
  width: 100%;  height: 200px;
  object-fit: cover;  display: block;
  border-radius: 8px;
}

/* 瀑布流 */
.fb-masonry {
  column-count: 3;  column-gap: 8px;
  margin: 1em 0;
}
.fb-masonry a {
  display: inline-block;  width: 100%;
  margin-bottom: 8px;  break-inside: avoid;
  overflow: hidden;  border-radius: 8px;
  transition: transform 0.2s ease;
}
.fb-masonry a:hover { transform: scale(1.02); }
.fb-masonry img { width: 100%; display: block; border-radius: 8px; }

/* ───── 分享菜单 ───── */
.fb-share-menu {
  position: absolute;
  top: 60px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--fb-toolbar-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--fb-toolbar-radius);
  box-shadow: 0 4px 20px rgba(0,0,0,0.35);
  opacity: 0;
  transform: translateY(-8px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 10;
  min-width: 150px;
}
.fb-share-menu.fb-share-open {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.fb-share-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--fb-text-color);
  font: 400 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
}
.fb-share-item:hover {
  background: var(--fb-btn-hover);
}
.fb-share-item svg {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

/* 分享按钮在禁用时隐藏 */
.fb-share-btn.fb-hidden { display: none !important; }

/* ───── 响应式 ───── */
@media (max-width: 768px) {
  .fb-stage { padding: 50px 12px; }
  .fb-toolbar { top: 10px; gap: 2px; padding: 4px 6px; }
  .fb-btn { width: 32px; height: 32px; }
  .fb-btn svg { width: 18px; height: 18px; }
  .fb-nav { width: 36px; height: 36px; }
  .fb-nav svg { width: 18px; height: 18px; }
  .fb-nav-prev { left: 6px; }
  .fb-nav-next { right: 6px; }
  .fb-close-btn { top: 8px; right: 8px; width: 36px; height: 36px; }
  .fb-counter { bottom: 16px; font-size: 12px; }
  .fb-caption { padding: 36px 16px 12px; font-size: 13px; }
  .fb-thumb-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .fb-masonry { column-count: 2; }
}

@media (max-width: 480px) {
  .fb-stage { padding: 44px 6px; }
  .fb-toolbar { top: 6px; gap: 1px; padding: 3px 4px; }
  .fb-btn { width: 28px; height: 28px; border-radius: 6px; }
  .fb-btn svg { width: 16px; height: 16px; }
  .fb-thumb-grid { grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
  .fb-masonry { column-count: 1; }
}
