/* ============================================================
   InlineLightbox · 内嵌灯箱模块样式（v1.0.0）
   - 页面内嵌入布局：常规文档流，无 fixed 覆盖层
   - 主题变量带默认值，可独立使用，也可跟随宿主浅粉主题
   ============================================================ */

.ilb-gallery,
.ilb-article {
  /* 主题变量（宿主未定义时使用默认值） */
  --ilb-accent: var(--accent, #E85D75);
  --ilb-accent-deep: var(--accent-deep, #D24359);
  --ilb-accent-soft: var(--accent-soft, #FFE3EA);
  --ilb-text: var(--text, #4A3A3E);
  --ilb-text-sub: var(--text-sub, #9A8288);
  --ilb-border: var(--border, #FFD9E1);
  --ilb-radius: 16px;
  --ilb-ratio: 16 / 9;
  --ilb-h: auto;
}

/* ============================================================
   图片子模块
   ============================================================ */

.ilb-gallery {
  display: block;
  width: 100%;
  margin: 22px 0;
  border: 1px solid var(--ilb-border);
  border-radius: var(--ilb-radius);
  background: #fff;
  box-shadow: 0 4px 18px rgba(232, 93, 117, 0.08);
  overflow: hidden;
}

.ilb-viewport {
  position: relative;
  width: 100%;
  height: var(--ilb-h);
  aspect-ratio: var(--ilb-ratio);
  overflow: hidden;
  background: #FFF7F9;
  touch-action: pan-y;      /* 放行页面垂直滚动，横向手势由模块接管 */
  outline: none;
}

.ilb-viewport:focus-visible {
  box-shadow: inset 0 0 0 2px var(--ilb-accent);
}

/* 轮播轨道：flex 流 + transform 位移 */
.ilb-track {
  display: flex;
  width: 100%;
  height: 100%;
  transform: translateX(0);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

.ilb-track.ilb-no-anim { transition: none; }

.ilb-item {
  position: relative;
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.ilb-thumb,
.ilb-full {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
}

.ilb-full {
  position: absolute;
  inset: 0;
  margin: auto;
  opacity: 0;
  transition: opacity 0.4s ease;
}

/* 高清图加载完成：淡入并盖住缩略图 */
.ilb-item.is-hd .ilb-full { opacity: 1; }

/* 缩放动画类（拖拽平移时由 JS 移除） */
.ilb-anim { transition: transform 0.22s ease; }

/* 高清加载指示 */
.ilb-loader {
  position: absolute;
  right: 12px;
  bottom: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.45);
  border-top-color: #fff;
  background: rgba(74, 58, 62, 0.25);
  opacity: 0;
  animation: ilb-spin 0.8s linear infinite;
  pointer-events: none;
}

.ilb-item:not(.is-hd) .ilb-loader { opacity: 1; }

@keyframes ilb-spin { to { transform: rotate(360deg); } }

/* 箭头按钮（模块内浮动，不脱离模块边界） */
.ilb-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ilb-accent-deep);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(74, 58, 62, 0.18);
  transition: all 0.18s ease;
  z-index: 3;
}

.ilb-arrow:hover { background: #fff; transform: translateY(-50%) scale(1.08); }

.ilb-prev { left: 12px; }
.ilb-next { right: 12px; }

/* 指示圆点 */
.ilb-dots {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  gap: 7px;
  z-index: 3;
}

.ilb-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  box-shadow: 0 1px 4px rgba(74, 58, 62, 0.3);
  cursor: pointer;
  transition: all 0.18s ease;
}

.ilb-dot:hover { background: #fff; }

.ilb-dot.active {
  width: 22px;
  border-radius: 5px;
  background: var(--ilb-accent);
}

/* 计数器与缩放提示 */
.ilb-counter {
  position: absolute;
  top: 12px;
  right: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(74, 58, 62, 0.45);
  color: #fff;
  font-size: 12px;
  line-height: 1.5;
  z-index: 3;
}

.ilb-zoom-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--ilb-text-sub);
  font-size: 11.5px;
  line-height: 1.5;
  z-index: 3;
  pointer-events: none;
  opacity: 0.92;
}

/* 缩放态：抓取光标，隐藏翻页控件（避免遮挡图像） */
.ilb-viewport.is-zoomed {
  cursor: grab;
  touch-action: none;
}

.ilb-viewport.is-zoomed:active { cursor: grabbing; }

.ilb-viewport.is-zoomed .ilb-arrow,
.ilb-viewport.is-zoomed .ilb-dots { opacity: 0; pointer-events: none; }

.ilb-viewport .ilb-arrow,
.ilb-viewport .ilb-dots { transition: opacity 0.2s ease; }

/* 图片说明 */
.ilb-caption {
  padding: 10px 16px;
  border-top: 1px dashed var(--ilb-border);
  color: var(--ilb-text-sub);
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.ilb-caption[hidden] { display: none; }

/* ============================================================
   文章子模块
   ============================================================ */

.ilb-article {
  display: block;
  width: 100%;
  color: var(--ilb-text);
  font-size: 15px;
  line-height: 1.85;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* 段落排版 */
.ilb-article p { margin: 0 0 1em; }

.ilb-article h1, .ilb-article h2, .ilb-article h3, .ilb-article h4 {
  margin: 1.6em 0 0.7em;
  line-height: 1.4;
  color: var(--ilb-accent-deep);
  font-weight: 700;
}

.ilb-article h1 { font-size: 1.5em; }
.ilb-article h2 { font-size: 1.3em; }
.ilb-article h3 { font-size: 1.15em; }
.ilb-article h4 { font-size: 1em; }

.ilb-article h1:first-child,
.ilb-article h2:first-child,
.ilb-article h3:first-child { margin-top: 0; }

/* 引用 */
.ilb-article blockquote {
  margin: 1.2em 0;
  padding: 10px 16px;
  border-left: 3px solid var(--ilb-accent);
  border-radius: 8px;
  background: var(--ilb-accent-soft);
  color: var(--ilb-text-sub);
}

.ilb-article blockquote p:last-child { margin-bottom: 0; }

/* 列表 */
.ilb-article ul, .ilb-article ol {
  margin: 1em 0;
  padding-left: 1.6em;
}

.ilb-article li { margin: 0.3em 0; }

/* 链接 */
.ilb-article a { color: var(--ilb-accent); text-decoration: none; }
.ilb-article a:hover { color: var(--ilb-accent-deep); text-decoration: underline; }

/* 行内代码与代码块 */
.ilb-article code {
  padding: 2px 6px;
  border-radius: 6px;
  background: #FFF1F4;
  color: var(--ilb-accent-deep);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
}

.ilb-article pre {
  margin: 1.2em 0;
  padding: 14px 16px;
  border-radius: 12px;
  background: #3B2F33;
  color: #F6E9EC;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  line-height: 1.6;
  font-size: 13.5px;
}

.ilb-article pre code { padding: 0; background: none; color: inherit; font-size: inherit; }

/* 图片：响应式自适应 */
.ilb-article img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
}

/* 表格：窄屏横向滚动容器 */
.ilb-scroll {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.2em 0;
}

.ilb-article table {
  width: 100%;
  min-width: 420px;
  border-collapse: collapse;
  font-size: 14px;
}

.ilb-article th, .ilb-article td {
  padding: 9px 12px;
  border: 1px solid var(--ilb-border);
  text-align: left;
}

.ilb-article th { background: var(--ilb-accent-soft); color: var(--ilb-accent-deep); }

/* 分隔线 */
.ilb-article hr {
  margin: 1.8em 0;
  border: none;
  border-top: 1px dashed var(--ilb-border);
}

/* ============================================================
   响应式与可访问性
   ============================================================ */

@media (max-width: 640px) {
  .ilb-arrow { width: 32px; height: 32px; font-size: 19px; }
  .ilb-prev { left: 8px; }
  .ilb-next { right: 8px; }
  .ilb-caption { font-size: 12.5px; }
  .ilb-zoom-hint { display: none; }  /* 小屏以双击手势为主 */
  .ilb-article { font-size: 14.5px; }
  .ilb-article table { min-width: 340px; }
}

/* 用户偏好减少动效 */
@media (prefers-reduced-motion: reduce) {
  .ilb-track,
  .ilb-anim,
  .ilb-arrow,
  .ilb-dot { transition: none !important; }
  .ilb-loader { animation-duration: 1.6s; }
}
