/* BODHI Dashboard 自定义样式：strip 切片 + 卡片细节 */

/* Strip 16:9 单帧预览 + hover 扫播 5 帧动画。
   strip.jpg 是 5 帧横向拼接（80:9）；用 background-size: 500% 100% 把整张塞进 16:9 容器，
   通过 background-position 切换显示哪一帧。默认显示第 1 帧；hover 时动画扫过 5 帧。 */
.strip-frame {
  aspect-ratio: 16 / 9;
  background-color: #0c0a09;
  background-repeat: no-repeat;
  background-size: 500% 100%;
  background-position: 0 0;
  position: relative;
  overflow: hidden;
}
/* 5 帧横向 sprite：background-size 500% 下，帧 i 的位置 = i/4*100%（0/25/50/75/100%）。
   steps(5, jump-none) 在 0%→100% 上产生 5 个均匀停顿，正好对齐 5 帧，末帧后跳回首帧循环。 */
@keyframes strip-scan {
  from { background-position: 0% 0; }
  to   { background-position: 100% 0; }
}
.strip-frame:hover {
  animation: strip-scan 2s steps(5, jump-none) infinite;
}
.strip-frame .strip-meta {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 10px;
  padding: 1px 5px;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border-radius: 3px;
  letter-spacing: 0.05em;
  font-family: var(--font-mono, monospace);
}
.strip-frame .strip-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.65);
  font-size: 28px;
  text-shadow: 0 2px 8px rgba(0,0,0,0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity 120ms;
}
.strip-frame:hover .strip-play { opacity: 1; }

/* 16:9 wrapper for single image preview */
.aspect-16-9 {
  aspect-ratio: 16 / 9;
}

/* 镜次卡片网格：按窗口宽 auto-fill 自动决定列数，单列 280px 下限钉住卡片不过大
   （宽屏自然多列、每列 ≈280–360px；比固定 1/2/3 列在大屏上小很多） */
.shot-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

/* Shot state badges */
.state-badge {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.state-missing-prompt { background: #fef2f2; color: #b91c1c; }
.state-has-prompt     { background: #fef3c7; color: #92400e; }
.state-has-firstframe { background: #dbeafe; color: #1e40af; }
.state-has-take       { background: #ede9fe; color: #6b21a8; }
.state-selected       { background: #d1fae5; color: #065f46; }
.state-cut            { background: #e7e5e4; color: #1c1917; }

.dark .state-missing-prompt { background: #450a0a; color: #fca5a5; }
.dark .state-has-prompt     { background: #451a03; color: #fcd34d; }
.dark .state-has-firstframe { background: #0c1f3d; color: #93c5fd; }
.dark .state-has-take       { background: #2e1065; color: #c4b5fd; }
.dark .state-selected       { background: #052e16; color: #6ee7b7; }
.dark .state-cut            { background: #292524; color: #d6d3d1; }

/* 卡片 hover lift */
.lift {
  transition: transform 120ms ease, box-shadow 120ms ease;
}
.lift:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px -4px rgb(0 0 0 / 0.15);
}

/* nav link active */
.nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 6px;
  color: rgb(87 83 78);
  cursor: pointer;
}
.nav-link:hover { background: rgb(245 245 244); color: rgb(28 25 23); }
.dark .nav-link { color: rgb(168 162 158); }
.dark .nav-link:hover { background: rgb(41 37 36); color: rgb(231 229 228); }
.nav-link.active {
  background: rgb(28 25 23);
  color: rgb(254 254 253);
}
.dark .nav-link.active {
  background: rgb(254 254 253);
  color: rgb(28 25 23);
}

/* Locked gold border (for asset published versions) */
.locked-border {
  outline: 2px solid #b08642;
  outline-offset: -2px;
}

/* markdown-ish prose */
.prose-bodhi h1 { font-size: 1.5em; font-weight: 700; margin: 1.2em 0 0.5em; }
.prose-bodhi h2 { font-size: 1.25em; font-weight: 600; margin: 1em 0 0.4em; }
.prose-bodhi h3 { font-size: 1.1em; font-weight: 600; margin: 0.8em 0 0.3em; }
.prose-bodhi p { margin: 0.5em 0; line-height: 1.65; }
.prose-bodhi ul { list-style: disc; padding-left: 1.5em; margin: 0.4em 0; }
.prose-bodhi ol { list-style: decimal; padding-left: 1.5em; margin: 0.4em 0; }
.prose-bodhi code { background: #f5f5f4; padding: 1px 4px; border-radius: 3px; font-size: 0.9em; }
.dark .prose-bodhi code { background: #292524; }
.prose-bodhi pre { background: #f5f5f4; padding: 10px; border-radius: 6px; overflow-x: auto; font-size: 0.85em; }
.dark .prose-bodhi pre { background: #1c1917; }
.prose-bodhi blockquote { border-left: 3px solid #d6d3d1; padding-left: 1em; color: #57534e; margin: 0.5em 0; }
.prose-bodhi table { border-collapse: collapse; margin: 0.5em 0; font-size: 0.9em; }
.prose-bodhi th, .prose-bodhi td { border: 1px solid #d6d3d1; padding: 4px 8px; }
.dark .prose-bodhi th, .dark .prose-bodhi td { border-color: #44403c; }

/* progress ring */
.ring-bg {
  background: conic-gradient(var(--ring-color) calc(var(--ring-pct) * 1%), rgb(231 229 228) 0);
}
.dark .ring-bg {
  background: conic-gradient(var(--ring-color) calc(var(--ring-pct) * 1%), rgb(41 37 36) 0);
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 9, 0.6);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.modal-card {
  background: white;
  border-radius: 8px;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  width: 1100px;
}
.dark .modal-card { background: rgb(28 25 23); }

/* @图片N prompt mention + 悬浮 ref 预览 tip */
.ref-mention {
  color: rgb(138 103 48);
  border-bottom: 1px dashed rgb(201 163 107);
  cursor: zoom-in;
  font-weight: 600;
  padding: 0 1px;
}
.dark .ref-mention { color: rgb(201 163 107); border-bottom-color: rgb(138 103 48); }
.ref-mention:hover { background: rgba(201,163,107,0.18); border-radius: 3px; }
.ref-mention-broken {
  color: rgb(220 60 60);
  border-bottom-style: dotted;
  border-bottom-color: rgb(220 60 60);
  cursor: help;
}
.ref-tip {
  position: fixed;
  z-index: 200;
  width: 248px;
  background: white;
  border: 1px solid rgb(214 211 209);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
  padding: 6px;
  pointer-events: none;
}
.dark .ref-tip { background: rgb(28 25 23); border-color: rgb(68 64 60); }
.ref-tip-img {
  width: 100%;
  display: block;
  border-radius: 5px;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #000;
}
.ref-tip-cap {
  font-size: 11px;
  line-height: 1.35;
  margin-top: 5px;
  color: rgb(87 83 78);
  max-height: 3.4em;
  overflow: hidden;
}
.dark .ref-tip-cap { color: rgb(168 162 158); }

/* 参考图选择器（叠在 shot modal 之上，z 介于 modal-50 与 lightbox-100 之间）*/
.picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 10, 9, 0.55);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}
.picker-panel {
  background: white;
  border-radius: 10px;
  width: 880px;
  max-width: 94vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
}
.dark .picker-panel { background: rgb(28 25 23); }
.picker-search {
  width: 100%;
  padding: 8px 12px;
  font-size: 14px;
  border: 1px solid rgb(214 211 209);
  border-radius: 6px;
  background: rgb(250 250 249);
}
.dark .picker-search { background: rgb(41 37 36); border-color: rgb(68 64 60); color: rgb(231 229 228); }
.picker-search:focus { outline: none; box-shadow: 0 0 0 2px rgba(176, 134, 66, 0.5); }
.picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  grid-auto-rows: 156px;  /* 固定行高：lazy 未加载的 img 不参与轨道测高，否则整列被压成单行 */
  align-content: start;
  gap: 10px;
  overflow-y: auto;       /* 上下滑动列表 */
  padding: 2px 4px 2px 2px;
  margin-top: 8px;
  flex: 1 1 auto;
  min-height: 120px;      /* 关键：flex 子项 min-height 正值才会真正滚动而非撑高面板 */
}
.picker-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: rgb(168 162 158);
  font-size: 14px;
  padding: 40px 0;
}
.picker-card {
  position: relative;
  border: 1px solid rgb(231 229 228);
  border-radius: 7px;
  overflow: hidden;
  cursor: pointer;
  background: white;
  transition: border-color 100ms, box-shadow 100ms, transform 100ms;
}
.dark .picker-card { background: rgb(28 25 23); border-color: rgb(68 64 60); }
.picker-card:hover { border-color: var(--tw-gold, #b08642); box-shadow: 0 4px 14px -4px rgba(0,0,0,0.25); transform: translateY(-1px); }
.picker-card-cur { outline: 2px solid #b08642; outline-offset: -2px; }
/* 待确定的选中态：醒目蓝环 + 角标，区别于「当前」金环 */
.picker-card-sel { outline: 3px solid #2b7fff; outline-offset: -3px; box-shadow: 0 4px 16px -2px rgba(43,127,255,0.45); }
.picker-card-sel::after {
  content: '已选 ✓';
  position: absolute;
  top: 4px;
  left: 4px;
  background: #2b7fff;
  color: #fff;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
  z-index: 1;
}
.picker-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;     /* 默认 16:9 框 */
  object-fit: contain;      /* 整图显示、不裁剪（非 16:9 的图上下/左右留边）*/
  display: block;
  background: #0c0a09;
}
.picker-thumb-empty {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgb(168 162 158);
  font-size: 11px;
  background: rgb(245 245 244);
}
.dark .picker-thumb-empty { background: rgb(41 37 36); }
.picker-cap {
  font-size: 11px;
  line-height: 1.3;
  padding: 4px 6px 0;
  color: rgb(57 53 49);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.dark .picker-cap { color: rgb(214 211 209); }
.picker-sub {
  font-size: 10px;
  padding: 1px 6px 5px;
  color: rgb(168 162 158);
  font-family: var(--font-mono, monospace);
}
.picker-cur-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  background: #b08642;
  color: white;
  font-size: 9px;
  padding: 1px 5px;
  border-radius: 4px;
  letter-spacing: 0.03em;
}

/* Scrollbar slim */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: rgb(214 211 209); border-radius: 4px; }
.dark ::-webkit-scrollbar-thumb { background: rgb(68 64 60); }

/* Lightbox 全屏图片查看器 */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.lightbox-img {
  max-width: 95vw;
  max-height: 92vh;
  object-fit: contain;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  background: #0c0a09;
}
.lightbox-meta {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.7);
  color: #e7e5e4;
  padding: 6px 14px;
  border-radius: 6px;
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  letter-spacing: 0.03em;
  display: flex;
  align-items: center;
  gap: 12px;
}
.lightbox-meta a {
  color: #c9a36b;
  text-decoration: underline;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: rgba(255,255,255,0.7);
  font-size: 40px;
  width: 50px;
  height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
}
.lightbox-nav:hover { color: white; background: rgba(255,255,255,0.1); }
.lightbox-nav.prev { left: 20px; }
.lightbox-nav.next { right: 20px; }
.lightbox-close {
  position: absolute;
  top: 16px;
  right: 24px;
  color: rgba(255,255,255,0.7);
  font-size: 32px;
  cursor: pointer;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lightbox-close:hover { color: white; }

/* 可点击放大的图加 cursor */
.zoomable { cursor: zoom-in; }

/* lightbox 缩放控件 */
.lightbox-img { transition: transform .12s ease; }
.lightbox-zoom {
  position: absolute;
  bottom: 58px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.78);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 8px;
  padding: 6px 12px;
  color: #e7e5e4;
  font-family: var(--font-mono, monospace);
  font-size: 14px;
  cursor: default;
  z-index: 2;
  box-shadow: 0 2px 14px rgba(0,0,0,0.5);
}
.lightbox-zoom button {
  width: 32px;
  height: 32px;
  line-height: 1;
  font-size: 20px;
  color: rgba(255,255,255,0.9);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
}
.lightbox-zoom button:hover { background: rgba(255,255,255,0.22); color: #fff; }
.lightbox-zoom-label { min-width: 48px; text-align: center; }
