/* ============================================================================
   IBEX-01 · 质感层
   叠加在 style.css 之上：光、材质、微交互、新组件
   —— 不改动既有布局规则，只做增强
   ========================================================================== */

/* ---------------------------------------------------------------- 页面级光 */
body::after {
  content: ""; position: fixed; inset: 0; z-index: 400; pointer-events: none;
  opacity: .05; mix-blend-mode: soft-light;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/></filter><rect width='160' height='160' filter='url(%23n)'/></svg>");
}
html[data-theme="light"] body::after { opacity: .035; mix-blend-mode: multiply; }

/* 主题切换不闪烁地渐变 */
html.theme-anim, html.theme-anim body, html.theme-anim .topbar,
html.theme-anim .card, html.theme-anim .panel, html.theme-anim .seq__row,
html.theme-anim .syscard, html.theme-anim .figure, html.theme-anim .acc__item {
  transition: background-color .45s var(--ease), border-color .45s var(--ease), color .45s var(--ease);
}

/* --------------------------------------------------------------- 首屏光晕 */
.hero::before {
  content: ""; position: absolute; inset: -18% -12% auto -12%; height: 128%; z-index: 0;
  pointer-events: none; filter: blur(8px); opacity: .9;
  background:
    radial-gradient(40% 48% at 18% 12%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 72%),
    radial-gradient(34% 42% at 76% 4%, color-mix(in srgb, var(--info) 18%, transparent), transparent 70%),
    radial-gradient(40% 40% at 58% 66%, color-mix(in srgb, var(--accent-2) 10%, transparent), transparent 76%);
  animation: aurora 26s var(--ease) infinite alternate;
}
html[data-theme="light"] .hero::before { opacity: .5; }
@keyframes aurora {
  from { transform: translate3d(-1.2%, -1%, 0) scale(1.02); }
  to   { transform: translate3d(1.4%, 1.6%, 0) scale(1.08); }
}

/* 标题金属流光 */
.hero__name {
  background-image: linear-gradient(102deg,
    var(--fg) 0%, var(--fg) 34%,
    color-mix(in srgb, var(--accent) 42%, var(--fg)) 48%,
    var(--fg) 62%, var(--fg) 100%);
  background-size: 260% 100%;
  animation: sheen 16s linear infinite;
}
@keyframes sheen {
  0%   { background-position: 130% 0; }
  100% { background-position: -30% 0; }
}
@media (prefers-reduced-motion: reduce) { .hero__name, .hero::before { animation: none; } }

/* ------------------------------------------------------------- 首屏两栏 */
.hero__body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 408px; gap: 52px; align-items: center; min-width: 0; }
.hero__l { min-width: 0; }
.hero__viz { position: relative; padding: 18px 16px 14px; border: 1px solid var(--line-2); border-radius: 14px;
  background: linear-gradient(165deg, color-mix(in srgb, var(--surface) 92%, transparent), color-mix(in srgb, var(--bg) 72%, transparent));
  box-shadow: inset 0 1px 0 color-mix(in srgb, var(--fg) 6%, transparent), 0 30px 80px -50px #000;
  backdrop-filter: blur(6px);
}
html[data-theme="light"] .hero__viz { box-shadow: inset 0 1px 0 #fff, 0 20px 50px -40px rgba(70,60,30,.5); }
.hero__viz::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; border-radius: 14px 14px 0 0;
  background: linear-gradient(90deg, transparent, var(--accent-line), transparent);
}
.viz__h { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; padding: 0 4px 10px; }
.viz__h .mono { font-size: 9px; letter-spacing: .18em; color: var(--accent); }
.viz__h i { font-style: normal; font-size: 11px; color: var(--fg-3); letter-spacing: .06em; }
.viz__f { margin-top: 10px; padding: 9px 4px 0; border-top: 1px dashed var(--line-2); font-size: 11px; color: var(--fg-3); letter-spacing: .02em; }
.hero__viz svg { display: block; width: 100%; height: auto; overflow: visible; }

/* 六层堆叠 */
.plate { cursor: pointer; }
.plate__top, .plate__l, .plate__r {
  transition: transform .38s var(--ease), fill .3s, stroke .3s, opacity .3s;
}
.plate__top { fill: color-mix(in srgb, var(--fg) 7%, var(--surface-2)); stroke: var(--line-3); stroke-width: 1; }
.plate__l { fill: color-mix(in srgb, var(--surface) 88%, #000); stroke: var(--line-2); stroke-width: .8; }
.plate__r { fill: color-mix(in srgb, var(--surface) 64%, #000); stroke: var(--line-2); stroke-width: .8; }
.plate.is-top .plate__top { stroke: color-mix(in srgb, var(--accent) 50%, var(--line-3)); }
.plate.is-top .plate__no { fill: var(--accent); }
.plate__engrave {
  font-family: var(--mono); font-size: 17px; letter-spacing: .06em;
  fill: color-mix(in srgb, var(--fg) 16%, transparent); transition: fill .3s;
}
.plate:hover .plate__engrave { fill: color-mix(in srgb, var(--accent) 55%, transparent); }
.plate__hit { cursor: pointer; }
.plate__hit:focus { outline: none; }
html[data-theme="light"] .plate__l { fill: color-mix(in srgb, var(--surface-2) 88%, #6b6450); }
html[data-theme="light"] .plate__r { fill: color-mix(in srgb, var(--surface-2) 74%, #6b6450); }
.plate:hover .plate__top { fill: color-mix(in srgb, var(--accent) 20%, var(--surface-2)); stroke: var(--accent); }
.plate:hover .plate__l, .plate:hover .plate__r { fill: color-mix(in srgb, var(--accent) 16%, var(--surface)); stroke: var(--accent-line); }
.plate:hover .plate__g { transform: translateY(-6px); }
.plate__g { transition: transform .38s var(--ease); }
.plate__no { font-family: var(--mono); font-size: 9.5px; letter-spacing: .06em; fill: var(--accent); }
.plate__zh { font-size: 13px; fill: var(--fg); letter-spacing: .04em; }
.plate__en { font-family: var(--mono); font-size: 7.5px; letter-spacing: .1em; fill: var(--fg-3); text-transform: uppercase; }
.plate__tick { stroke: var(--line-2); stroke-width: 1; stroke-dasharray: 2 3; transition: stroke .3s; }
.plate.is-hot .plate__no { fill: var(--accent); }
.plate.is-hot .plate__zh { fill: var(--fg); }
.plate.is-hot .plate__tick { stroke: var(--accent-line); }
.stack:has(.plate:hover) .plate:not(:hover) { opacity: .5; }
.plate__hint { font-family: var(--mono); font-size: 7.5px; letter-spacing: .14em; fill: var(--fg-3); }
.plate__arc { fill: none; stroke: var(--line-2); stroke-width: .8; stroke-dasharray: 2 4; }

/* 首页进度环 */
.ring__track { fill: none; stroke: var(--line-2); stroke-width: 3; }
.ring__prog { fill: none; stroke: url(#ringGrad); stroke-width: 3; stroke-linecap: round;
  transition: stroke-dashoffset 1s var(--ease); }
.ring__node circle { fill: var(--surface-2); stroke: var(--line-3); stroke-width: 1.2; transition: .3s var(--ease); }
.ring__node text { font-family: var(--mono); font-size: 10px; fill: var(--fg-3); transition: fill .3s; }
.ring__node.is-live circle { fill: color-mix(in srgb, var(--accent) 16%, var(--surface-2)); stroke: var(--accent); }
.ring__node.is-live text { fill: var(--accent); }
.ring__node { cursor: default; }
.ring__node.is-live { cursor: pointer; }
.ring__node:hover circle { stroke: var(--accent); transform: scale(1.12); transform-origin: center; }
.ring__node.is-dim { opacity: .5; }
.ring__c1 { font-family: var(--mono); font-size: 30px; fill: var(--fg); letter-spacing: -.02em; }
.ring__c2 { font-family: var(--mono); font-size: 8.5px; letter-spacing: .18em; fill: var(--fg-3); }
.ring__c3 { font-size: 11.5px; fill: var(--accent); }
.ring__inner { fill: none; stroke: var(--line); stroke-width: 1; stroke-dasharray: 1 7; }

/* --------------------------------------------------------------- 卡片质感 */
.card, .syscard, .sos, .sup, .mod, .cfg, .panel, .seq__row, .figure, .qc, .subi { position: relative; }
.card::after, .syscard::after, .panel::after, .figure::after, .seq__row::after {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px; border-radius: inherit;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 55%, transparent) 42%, transparent 88%);
  opacity: 0; transition: opacity .4s var(--ease); pointer-events: none;
}
.card:hover::after, .syscard:hover::after, .panel:hover::after,
.figure:hover::after, .seq__row:hover::after { opacity: 1; }

/* 跟随指针的光斑（z-index:-1 + isolation：只在底色之上、内容之下） */
.spot { isolation: isolate; }
.spot > .spot__layer {
  position: absolute; inset: 0; z-index: -1; border-radius: inherit; pointer-events: none; opacity: 0;
  transition: opacity .45s var(--ease);
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 0%),
    color-mix(in srgb, var(--accent) 14%, transparent), transparent 68%);
}
.spot:hover > .spot__layer { opacity: 1; }

/* 按钮光扫 */
.btn { position: relative; overflow: hidden; isolation: isolate; }
.btn::after {
  content: ""; position: absolute; inset: -1px; z-index: -1; pointer-events: none;
  background: linear-gradient(112deg, transparent 34%, color-mix(in srgb, #fff 26%, transparent) 50%, transparent 66%);
  transform: translateX(-130%); transition: transform .75s var(--ease);
}
.btn:hover::after { transform: translateX(130%); }
.btn--primary { box-shadow: 0 10px 30px -18px color-mix(in srgb, var(--accent) 90%, transparent); }
.btn--primary:hover { box-shadow: 0 14px 34px -16px color-mix(in srgb, var(--accent) 90%, transparent); }

/* 顶栏下沿细光 */
.topbar { position: sticky; }
.topbar::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; pointer-events: none;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 34%, transparent) 30%, transparent 70%);
  opacity: .8;
}

/* 数字等宽 */
.stat b, .spec b, .bclose b, .res__val, .mx-total { font-variant-numeric: tabular-nums; }
.stat { position: relative; transition: background .3s; }
.stat:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.stat b { transition: color .3s; }
.stat:hover b { color: var(--accent); }

/* 六层箭头：聚焦式交互 */
.chevrons:has(.chev:hover) .chev:not(:hover) { opacity: .42; }
.chev { transition: opacity .3s var(--ease), background .25s, border-color .25s, transform .25s; }
.chev:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* 层级编号水印：更精致 */
.layerhead__no { transition: color .4s, -webkit-text-stroke-color .4s; }
.sec:hover .layerhead__no { color: color-mix(in srgb, var(--accent) 10%, transparent); -webkit-text-stroke-color: var(--accent-line); }

/* --------------------------------------------------------------- 场景差异 */
.scen__cell { transition: background .3s, opacity .3s; }
.scen--t .scen__row { grid-template-columns: 118px repeat(3, 1fr); }
.scen--t .scen__tag b { color: var(--accent); }
.scen--t .scen__cell { font-size: 12.5px; }
.scen__row:hover .scen__cell { background: color-mix(in srgb, var(--fg) 3.5%, transparent); }
.scen__lbl { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line-2); border-radius: 100px; background: var(--surface); }
.seg button {
  padding: 5px 13px; border-radius: 100px; font-size: 11.5px; color: var(--fg-3);
  transition: .22s var(--ease); white-space: nowrap;
}
.seg button:hover { color: var(--fg); }
.seg button.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }

/* ------------------------------------------------------------- 权重预设 */
.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 14px; align-items: center; }
.presets > span { font-family: var(--mono); font-size: 9px; letter-spacing: .14em; color: var(--fg-3); margin-right: 4px; }
.preset {
  padding: 5px 11px; border: 1px solid var(--line-2); border-radius: 6px;
  font-size: 11.5px; color: var(--fg-2); background: var(--surface); transition: .2s var(--ease);
}
.preset:hover { border-color: var(--line-3); color: var(--fg); transform: translateY(-1px); }
.preset.on { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.mx-bar { transform-origin: left; transition: width .5s var(--ease); }

/* ------------------------------------------------------------- 快捷键提示 */
.kbd {
  display: inline-block; min-width: 18px; padding: 1px 5px; text-align: center;
  font-family: var(--mono); font-size: 9.5px; line-height: 1.6; color: var(--fg-2);
  border: 1px solid var(--line-3); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2);
}
.keyhint {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px;
  border: 1px dashed var(--line-3); border-radius: 100px; font-size: 11px; color: var(--fg-3);
  transition: .2s var(--ease); white-space: nowrap;
}
.keyhint:hover { color: var(--accent); border-color: var(--accent-line); }
.keyhint svg { width: 13px; height: 13px; }

#keyPanel {
  position: fixed; inset: 0; z-index: 260; display: none;
}
#keyPanel.on { display: block; }
#keyPanel .kp__mask { position: absolute; inset: 0; background: rgba(0,0,0,.55); backdrop-filter: blur(4px); }
.kp__box {
  position: relative; width: min(440px, calc(100vw - 32px)); margin: 14vh auto 0;
  padding: 22px 24px 20px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 14px; box-shadow: 0 40px 90px -50px #000;
  animation: kpIn .26s var(--ease);
}
@keyframes kpIn { from { opacity: 0; transform: translateY(-10px) scale(.98); } to { opacity: 1; transform: none; } }
.kp__box h4 { font-size: 15px; display: flex; justify-content: space-between; align-items: center; }
.kp__box h4 span { font-family: var(--mono); font-size: 9px; letter-spacing: .16em; color: var(--fg-3); }
.kp__list { margin-top: 14px; display: flex; flex-direction: column; }
.kp__list div { display: flex; justify-content: space-between; gap: 16px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--line-2); font-size: 12.5px; color: var(--fg-2); }
.kp__list div:first-child { border-top: 0; }
.kp__foot { margin-top: 14px; font-size: 11px; color: var(--fg-3); }

/* ------------------------------------------------------------- 抽屉增强 */
.dw__nav { display: flex; gap: 8px; margin-top: 22px; }
.dw__nav button {
  flex: 1; padding: 8px 10px; border: 1px solid var(--line-2); border-radius: 7px;
  font-family: var(--mono); font-size: 10.5px; letter-spacing: .08em; color: var(--fg-2); transition: .2s;
}
.dw__nav button:hover { border-color: var(--accent-line); color: var(--accent); }
.drawer__panel { scroll-behavior: smooth; }
.dw__hop { animation: hopIn .4s var(--ease) both; }
.dw__hop:nth-child(1) { animation-delay: .04s; }
.dw__hop:nth-child(2) { animation-delay: .1s; }
.dw__hop:nth-child(3) { animation-delay: .16s; }
.dw__hop:nth-child(4) { animation-delay: .22s; }
.dw__hop:nth-child(5) { animation-delay: .28s; }
.dw__hop:nth-child(6) { animation-delay: .34s; }
@keyframes hopIn { from { opacity: 0; transform: translateX(10px); } to { opacity: 1; transform: none; } }

/* 追溯链逐跳入场 */
.trace__body.is-swap .hop { animation: hopIn .45s var(--ease) both; }
.trace__body.is-swap .hop:nth-child(2) { animation-delay: .05s; }
.trace__body.is-swap .hop:nth-child(3) { animation-delay: .1s; }
.trace__body.is-swap .hop:nth-child(4) { animation-delay: .15s; }
.trace__body.is-swap .hop:nth-child(5) { animation-delay: .2s; }
.trace__body.is-swap .hop:nth-child(6) { animation-delay: .25s; }

/* ------------------------------------------------------------- 序列行增强 */
.seq__row { isolation: isolate; }
.seq__no { transition: transform .35s var(--ease), -webkit-text-stroke-color .3s, color .3s; }
a.seq__row:hover .seq__no { transform: translateY(-2px); -webkit-text-stroke: 1px var(--accent); }
.seq__i.is-live .seq__row { box-shadow: 0 26px 60px -48px color-mix(in srgb, var(--accent) 90%, transparent); }
.seq__row .seq__go svg { transition: transform .3s var(--ease); }
.seq__i.is-plan .seq__row { opacity: .82; transition: opacity .3s; }
.seq__i.is-plan .seq__row:hover { opacity: 1; }

/* 进度条 / 进度环 */
.prog__bar { position: relative; }
.prog__bar::after {
  content: ""; position: absolute; inset: 0; border-radius: 3px;
  background: linear-gradient(90deg, transparent 40%, color-mix(in srgb, #fff 40%, transparent) 60%, transparent 80%);
  animation: progSweep 2.8s linear infinite;
}
@keyframes progSweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }

/* ------------------------------------------------------------- 层级侧栏 */
.rail { isolation: isolate; }
.rail__i { position: relative; overflow: hidden; }
.rail__i::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px;
  background: var(--accent); opacity: 0; transform: scaleY(.3); transition: .3s var(--ease);
}
.rail__i.is-on::before { opacity: 1; transform: none; }

/* 右侧图示跟随滚动（宽屏） */
@media (min-width: 1081px) {
  .figure--plat { position: sticky; top: 86px; }
}

/* 随机抽样高亮 */
.tbl--mods tbody tr.is-pick td { background: color-mix(in srgb, var(--accent) 13%, transparent); color: var(--fg); }
.tbl--mods tbody tr.is-pick .mid { color: var(--accent); }

/* ------------------------------------------------------------- 小工具条 */
.tools { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 16px; align-items: center; }
.tools .search { min-width: 0; }
.tools__meta { margin-left: 0; text-align: right; }
.tools__row { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tool-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px;
  border: 1px solid var(--line-2); border-radius: 7px; background: var(--surface);
  font-size: 11.5px; color: var(--fg-2); transition: .2s var(--ease); white-space: nowrap;
}
.tool-btn svg { width: 13px; height: 13px; }
.tool-btn:hover { border-color: var(--accent-line); color: var(--accent); transform: translateY(-1px); }
.tool-btn:active { transform: translateY(0); }

/* 页脚上沿光 */
.foot { position: relative; }
.foot::before {
  content: ""; position: absolute; inset: 0 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-3) 30%, var(--line-3) 70%, transparent);
}

/* --------------------------------------------------------------- reveal */
.rv { transition-delay: calc(var(--i, 0) * 70ms); }
.rv.in { transition-delay: calc(var(--i, 0) * 70ms); }

/* 页面转场 */
body { transition: opacity .18s var(--ease), filter .18s var(--ease); }
body.leaving { opacity: 0; filter: blur(2px); }

/* 主题图标切换 */
.ico-moon { display: none; }
html[data-theme="light"] .ico-sun { display: none; }
html[data-theme="light"] .ico-moon { display: block; }
#themeBtn svg { transition: transform .5s var(--ease); }
html[data-theme="light"] #themeBtn .ico-moon { transform: rotate(-18deg); }

/* --------------------------------------------------------------- 响应 */
@media (max-width: 1180px) {
  .hero__body { grid-template-columns: minmax(0, 1fr) 340px; gap: 34px; }
}
@media (max-width: 980px) {
  .hero__body { grid-template-columns: 1fr; gap: 28px; }
  .hero__viz { max-width: 460px; }
}
@media (max-width: 900px) {
  .scen--t .scen__row { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .hero__viz { display: none; }
  .presets > span { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  .prog__bar::after, .hero__name { animation: none; }
  .dw__hop, .trace__body.is-swap .hop { animation: none; }
}
@media print {
  body::after, .hero::before, .hero__viz, #keyPanel { display: none !important; }
  .card::after, .syscard::after, .panel::after, .figure::after, .seq__row::after { display: none; }
}

/* ------------------------------------------------------------ 宽表窄屏 */
/* 固定列宽较多的表，在窄屏保持最小可读宽度，避免末列被压成竖条 */
@media (max-width: 760px) {
  .table-wrap > .tbl.tbl--budget { min-width: 900px; }
  .table-wrap > .tbl.tbl--salience { min-width: 840px; }
  .table-wrap > .tbl.tbl--method { min-width: 780px; }
}
