/* details.css —— 02 会话详情 #details（任务 4）。选择器只写本节：
   三组（配置 / 运行情况 / 诊断与额度）× 九张卡；≥768 两列、<768 一列。
   每组用 subgrid 把「标题 / 画面 / 说明」三轨对齐，画面框撑满剩余高度、内容垂直居中。
   静态标记即终态（R10）：推理强度 High 高亮、上下文 3%、统计终值、重试说明停在「最近一次重试」、
   权限静态「工作区可写」；details.js 在非减弱动效时倒回起点，卡片进入视口时把小画面播一次。 */

/* 居中容器取整：1441 宽下 .wrap 的 margin auto 会算出 .5px，连累卡内的像素字 */
@supports (width: round(1px, 1px)) {
  #details .wrap { margin-inline: max(0px, round(down, (100% - 1200px) / 2, 1px)); }
}

#details .d-body { display: flex; flex-direction: column; gap: 40px; margin-top: 48px; }
#details .d-group { display: flex; flex-direction: column; gap: 20px; }
#details .d-gh { display: flex; align-items: center; gap: 12px; color: var(--text-3); }
#details .d-gh::after { content: ""; flex: 1; height: 1px; background: var(--line-1); }

/* ── 网格 ── */
#details .d-grid { display: grid; grid-template-columns: minmax(0, 1fr); column-gap: 24px; row-gap: 24px; }
#details .d-card { display: grid; grid-template-rows: repeat(3, auto); row-gap: 24px; min-width: 0; }
/* 浮现间隔 60ms：800ms 的浮现过渡在 base.css，这里只排延迟 */
#details .d-card[data-reveal] { transition-delay: calc(var(--i, 0) * 60ms); }

@media (min-width: 768px) {
  /* 累计取整：前 N-1 列宽度 = 取整后的累计边界差分，末列 1fr 吃余数；右缘贴齐、列宽差 ≤1px */
  #details .d-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  @supports (grid-template-columns: round(1px, 1px)) {
    #details .d-grid {
      --s: calc(100% - 24px);
      --c1: round(down, calc(var(--s) * 1 / 2 + .05px), 1px);
      grid-template-columns: var(--c1) minmax(0, 1fr);
    }
  }
  /* 标题 / 画面 / 说明三轨 × 两个视觉行 = 6 轨；卡跨 3 轨 */
  #details .d-grid--config, #details .d-grid--run { grid-template-rows: repeat(6, auto); }
  #details .d-grid--diag { grid-template-rows: repeat(3, auto); }
  #details .d-card { grid-row: span 3; grid-template-rows: subgrid; }
  /* 运行情况：左列上下两张，右列统计卡跨两行，画面撑满 */
  #details .d-card[data-card="takeover"] { grid-area: 1 / 1 / 4 / 2; }
  #details .d-card[data-card="context"] { grid-area: 4 / 1 / 7 / 2; }
  #details .d-card[data-card="stats"] { grid-area: 1 / 2 / 7 / 3; }
  #details .d-card[data-card="stats"] .d-t { grid-row: 1; }
  #details .d-card[data-card="stats"] .d-shot { grid-row: 2 / 6; }
  #details .d-card[data-card="stats"] .d-d { grid-row: 6; }
}

/* ── 卡内三轨 ── */
#details .d-t { display: flex; align-items: center; gap: 8px; font-size: 17px; line-height: 24px; font-weight: 600; }
#details .d-aside, #details .d-pct { margin-left: auto; color: var(--text-4); font-size: 12px; line-height: 18px; font-weight: 400; font-variant-numeric: tabular-nums; }
#details .d-t .chip { font-weight: 400; }
#details .d-shot { display: flex; flex-direction: column; justify-content: center; padding: 14px; border: 1px solid var(--line-1); border-radius: 8px; background: var(--sidebar); color: var(--text-2); font-size: 13px; line-height: 20px; }
#details .d-shot > :first-child { margin-top: 0; }
#details .d-v { font-size: 15px; line-height: 22px; font-weight: 600; color: var(--text-1); }
#details .d-mono { margin-top: 2px; font-family: var(--f-mono); font-size: 12px; line-height: 18px; color: var(--text-4); }
#details .d-kv { display: flex; flex-direction: column; gap: 2px; margin: 10px 0 0; }
#details .d-r { display: flex; justify-content: space-between; gap: 12px; }
#details .d-r dt { color: var(--text-3); }
#details .d-r dd { margin: 0; color: var(--text-1); text-align: right; font-variant-numeric: tabular-nums; }
#details .d-d { color: var(--text-3); font-size: 15px; line-height: 24px; }

/* ── 推理强度：五档一行，当前档火漆红，模型没有的档虚线；<480 收窄内边距让五档一行 ── */
#details .d-efforts { display: flex; flex-wrap: wrap; gap: 4px; }
#details .d-ef { padding: 2px 8px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--text-3); }
@media (max-width: 479px) { #details .d-ef { padding-inline: 6px; } }
#details .d-ef.is-on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-soft-text); }
#details .d-ef.is-na { border-style: dashed; border-color: var(--line-1); color: var(--text-4); }

/* ── 进度条与两段读数：填充只动 transform；阈值刻度闪一下用透明度 ── */
#details .d-meter { position: relative; height: 8px; border: 1px solid var(--line-2); border-radius: 4px; background: var(--raised); }
#details .d-meter-fill { position: absolute; inset: 0; border-radius: 3px; background: var(--text-2); transform: scaleX(var(--p, .03)); transform-origin: 0 50%; transition: transform var(--t-l) var(--ease-out); }
#details .d-tick { position: absolute; top: -4px; bottom: -4px; width: 2px; border-radius: 1px; background: var(--line-3); }
#details .d-tick::after { content: ""; position: absolute; inset: -2px; border-radius: 2px; background: var(--accent); opacity: 0; }
#details .d-tick.is-flash::after { animation: d-flash var(--t-m) var(--ease-out) 1; }
@keyframes d-flash { 0%, 100% { opacity: 0; } 35% { opacity: .9; } }
#details .d-meter-row { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 8px; margin-top: 8px; color: var(--text-3); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }
#details .d-note { margin-top: 8px; color: var(--text-3); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }

/* ── 最近失败：失败行（靠右 ×1）+ 重试说明 ── */
#details .d-fail { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
#details .d-n { margin-left: auto; color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }

/* ── 接管：运行说明 + 按钮样子的「暂停工作区」（不可点） ── */
#details .d-btn { align-self: flex-start; margin-top: 12px; padding: 4px 12px; border: 1px solid var(--line-2); border-radius: 4px; color: var(--text-1); font-size: 12px; line-height: 20px; }

/* ── 额度：账户名 + 币种余额行 ── */
#details .d-q { font-size: 14px; line-height: 20px; }
#details .d-q-row { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; color: var(--text-3); font-size: 12px; line-height: 18px; font-variant-numeric: tabular-nums; }

/* ── 权限模式：悬停只在有悬停能力的设备上；键盘聚焦、触屏点按（.is-full）照旧。
   警示条始终在流内（visibility 切换），两种状态卡片高度完全相同。 ── */
#details .d-perm-shot { gap: 12px; }
#details .d-perm .d-perm-full { display: none; }
#details .d-warn { visibility: hidden; padding: 8px 12px; border-radius: 4px; background: var(--danger-soft); color: var(--danger); font-size: 12px; line-height: 18px; }
@media (hover: hover) {
  #details .d-perm:hover .d-perm-base { display: none; }
  #details .d-perm:hover .d-perm-full { display: inline; }
  #details .d-perm:hover .d-warn { visibility: visible; }
  #details .d-perm:hover .d-perm-v { color: var(--danger); }
}
#details .d-perm:focus-visible .d-perm-base { display: none; }
#details .d-perm:focus-visible .d-perm-full { display: inline; }
#details .d-perm:focus-visible .d-warn { visibility: visible; }
#details .d-perm:focus-visible .d-perm-v { color: var(--danger); }
#details .d-perm.is-full .d-perm-base { display: none; }
#details .d-perm.is-full .d-perm-full { display: inline; }
#details .d-perm.is-full .d-warn { visibility: visible; }
#details .d-perm.is-full .d-perm-v { color: var(--danger); }

/* ── 小画面入场：挂在共用的浮现状态 .is-in 上（main.js 的约定），和卡片浮现同时起步；
   未浮现（html.io 已生效但还没 .is-in）时内容一律透明，避免卡先露、内容后闪。
   延迟排在卡片错峰（--i × 60ms）之后，子项再逐个 +60ms。静态标记不加 .is-in，不播。 ── */
@media (prefers-reduced-motion: no-preference) {
  html.io #details .d-card[data-reveal]:not(.is-in) .d-shot > * { opacity: 0; }
  #details .d-card.is-in .d-shot > * { animation: d-rise var(--t-m) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 60ms + 120ms); }
  #details .d-card.is-in .d-shot > *:nth-child(2) { animation-delay: calc(var(--i, 0) * 60ms + 180ms); }
  #details .d-card.is-in .d-shot > *:nth-child(3) { animation-delay: calc(var(--i, 0) * 60ms + 240ms); }
  #details .d-card.is-in .d-shot > *:nth-child(4) { animation-delay: calc(var(--i, 0) * 60ms + 300ms); }
}
@keyframes d-rise { from { opacity: 0; transform: translate3d(0, 8px, 0); } to { opacity: 1; transform: none; } }
