/* public/css/detail.css
 * 详情页样式。第 1 段是「详情页面板」原版 index.html 内联 <style> 的等价内容
 * （.card-surface / .edit-mode / .edit-active-ring / .drag-scroll / .no-scrollbar / .snap-*），
 * 其余是本项目为壁纸层、卡片半透明、富文本代码块补的覆盖。Tailwind 负责绝大多数原子类，
 * 这里只写原子类表达不了的状态与组合选择器。
 */

/* ==================== 1. 原版内联样式等价段 ==================== */
.no-scrollbar::-webkit-scrollbar {
  display: none;
}
.no-scrollbar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}
.snap-x-mandatory {
  scroll-snap-type: x mandatory;
}
.snap-start {
  scroll-snap-align: start;
}
.card-surface {
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.edit-mode .card-surface:hover {
  border-color: #3b82f6;
  box-shadow: 0 8px 24px -6px rgba(59, 130, 246, 0.18);
}
.edit-active-ring {
  border-color: #2563eb !important;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22) !important;
}
.drag-scroll {
  cursor: grab;
  user-select: none;
}
.drag-scroll.is-dragging {
  cursor: grabbing;
  scroll-snap-type: none !important;
  scroll-behavior: auto !important;
}

/* ==================== 2. 壁纸层 ==================== */
/* 骨架由 detail.html 提供，图片与 filter 由服务端注入的 <style id="xdh-detail-wallpaper"> 写入；
   这里只负责定位、默认显隐与可读性，绝不写 background-image（避免覆盖服务端）。 */
.detail-wallpaper {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}
.detail-wallpaper-layer {
  position: absolute;
  inset: -2%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.detail-wallpaper-layer[hidden] {
  display: none;
}
/* 桌面层默认显示；手机层在窄屏媒体查询里接管（服务端样式只写 display:none/block） */
@media (max-width: 767px) {
  .detail-wallpaper-layer[data-wallpaper-device="desktop"] {
    display: none;
  }
  .detail-wallpaper-layer[data-wallpaper-device="mobile"] {
    display: block;
  }
}

/* 有壁纸时的 body 透明规则由服务端注入的 <style id="xdh-detail-wallpaper"> 按桌面/移动端媒体查询分别控制，避免仅配桌面壁纸时移动端变白底 */

/*
 * 卡片外观：毛玻璃与圆角跟随后台「卡片设置」，具体数值由 SSR 注入的
 * CSS 变量决定（functions/detail/[id].js 的 buildCardAppearanceCss）：
 *   --detail-card-blur   毛玻璃半径，关闭时为 0px
 *   --detail-card-alpha  底色不透明度，开启毛玻璃时更透
 *   --detail-card-radius 圆角
 * 这里只提供兜底默认值，别再写死具体像素，否则后台调了也不会变。
 */
body {
  --detail-card-blur: 0px;
  --detail-card-backdrop: none;
  --detail-card-alpha: 0.85;
  --detail-card-radius: 14px;
}
/* 四类卡片共用 .card-surface 与 .card-solid，圆角统一由变量驱动 */
.card-surface,
.card-solid {
  border-radius: var(--detail-card-radius, 14px);
}
body.detail-has-wallpaper .card-surface,
body.detail-has-wallpaper .card-solid {
  background: rgba(255, 255, 255, var(--detail-card-alpha, 0.85));
  backdrop-filter: var(--detail-card-backdrop, none);
  -webkit-backdrop-filter: var(--detail-card-backdrop, none);
  border-color: rgba(226, 232, 240, 0.7);
}
html.dark body.detail-has-wallpaper .card-surface,
html.dark body.detail-has-wallpaper .card-solid {
  background: rgba(15, 23, 42, var(--detail-card-alpha, 0.8));
  border-color: rgba(51, 65, 85, 0.7);
}
/* Hero 也跟卡片同一套圆角，避免顶部一块方、下面圆 */
#detailHero {
  border-radius: var(--detail-card-radius, 12px);
}
/* 底部动作条同样吃这套圆角 */
/* ==================== 3. 布局细节 ==================== */
/* 卡片「整行 / 窄」由 data-span 驱动，不依赖 md:col-span-2（该原子类需重新构建） */
#cardsGrid {
  grid-auto-flow: row dense;
}
#cardsGrid > [data-span="2"] {
  grid-column: span 1 / span 1;
}
@media (min-width: 768px) {
  #cardsGrid > [data-span="2"] {
    grid-column: span 2 / span 2;
  }
}

/* 抽屉与弹窗的 hidden 优先：它们同时带 tailwind 的 flex / 居中类，单类 .hidden 会被 flex 压过 */
#editorDrawer.hidden,
#pasteCardModal.hidden,
#addCardModal.hidden,
#lightboxModal.hidden {
  display: none !important;
}

/* 管理员按钮：默认隐藏，detail.js 在 isAdmin 为真时移除 hidden 并补 inline-flex */
.admin-only.hidden {
  display: none !important;
}

/* Hero logo 兜底：图片加载失败时显示书签首字母色块 */
.hero-logo-box {
  background-image: linear-gradient(135deg, #e2e8f0, #cbd5e1);
}
html.dark .hero-logo-box {
  background-image: linear-gradient(135deg, #1e293b, #0f172a);
}

/* ==================== 4. 富文本正文 ==================== */
.rich-md > * + * {
  margin-top: 0.625rem;
}
.rich-md h2 {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.5;
}
.rich-md h3 {
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.5;
}
.rich-md blockquote {
  border-left: 3px solid #3b82f6;
  padding-left: 0.75rem;
  color: #64748b;
}
html.dark .rich-md blockquote {
  color: #94a3b8;
}
.rich-md ul,
.rich-md ol {
  padding-left: 1.25rem;
}
.rich-md ul {
  list-style: disc;
}
.rich-md ol {
  list-style: decimal;
}
.rich-md li + li {
  margin-top: 0.25rem;
}
.rich-md hr {
  border: 0;
  border-top: 1px dashed #cbd5e1;
}
html.dark .rich-md hr {
  border-top-color: #334155;
}
.rich-md mark {
  background: #fef08a;
  color: #78350f;
  padding: 0 0.15em;
  border-radius: 0.2em;
}
html.dark .rich-md mark {
  background: #854d0e;
  color: #fef9c3;
}
.rich-md a.md-link {
  color: #2563eb;
  text-decoration: underline;
  text-underline-offset: 2px;
}
html.dark .rich-md a.md-link {
  color: #60a5fa;
}
.rich-md code.md-inline-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8125em;
  padding: 0.1em 0.35em;
  border-radius: 0.375rem;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  cursor: copy;
}
html.dark .rich-md code.md-inline-code {
  background: #1e293b;
  border-color: #334155;
}

/* 代码块：顶部标题条 + 一键复制 */
.code-block {
  border-radius: 0.75rem;
  overflow: hidden;
  border: 1px solid #e2e8f0;
  background: #0f172a;
}
html.dark .code-block {
  border-color: #334155;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem;
  background: rgba(255, 255, 255, 0.06);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.code-block-lang {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.6875rem;
  color: #94a3b8;
  letter-spacing: 0.02em;
}
.code-copy-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.15rem 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #e2e8f0;
  font-size: 0.6875rem;
  cursor: pointer;
  background: transparent;
}
.code-copy-btn:hover {
  background: rgba(255, 255, 255, 0.12);
}
.code-block pre {
  margin: 0;
  padding: 0.7rem 0.8rem;
  overflow-x: auto;
  color: #e2e8f0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  white-space: pre;
}

/* 图文混排：图片与视频统一带说明文字 */
.rich-figure {
  margin: 0.75rem 0 0;
}
.rich-figure img,
.rich-figure video {
  width: 100%;
  border-radius: 0.75rem;
  border: 1px solid #e2e8f0;
  display: block;
}
html.dark .rich-figure img,
html.dark .rich-figure video {
  border-color: #334155;
}
.rich-figure img {
  cursor: zoom-in;
}
.rich-figure figcaption {
  margin-top: 0.35rem;
  font-size: 0.6875rem;
  color: #94a3b8;
  text-align: center;
}

/* 灯箱内容里的媒体 */
#lightboxContent img,
#lightboxContent video {
  max-height: 82vh;
  max-width: 100%;
  border-radius: 0.75rem;
  object-fit: contain;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

/* ==================== 5. 自定义 HTML 卡片 ==================== */
.custom-html-slot {
  overflow-x: auto;
}
.custom-html-slot > :first-child {
  margin-top: 0;
}

/* ==================== 6. 编辑态辅助 ==================== */
/* 编辑模式下可点选的卡片指针 */
.edit-mode #cardsGrid > .card-surface {
  cursor: pointer;
}
/* 抽屉在移动端底部弹出时的滚动条瘦身 */
#editorDrawer > div:last-child {
  scrollbar-width: thin;
}
/* 抽屉内部小控件统一行高，避免 input/button 混排时高低不齐 */
#editorDrawer input[type="text"],
#editorDrawer input[type="number"],
#editorDrawer input[type="color"],
#editorDrawer select {
  line-height: 1.4;
}
