/* 互动演示的样式。只在有演示的课程页载入（见 includes/shell.php）。
   颜色全部走 style.css 的变量，所以随软件标签色、亮暗色自动换。 */

.demo { margin: 0 0 32px; max-width: var(--read-w); background: var(--card); border: 2px solid var(--a); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden; }
.demo-head { padding: 16px 20px 14px; background: var(--a-soft); border-bottom: 2px solid var(--a); }
.demo-badge { display: inline-block; font-size: 13px; font-weight: 700; color: var(--a-on); background: var(--a); padding: 0 12px; border-radius: 999px; line-height: 1.9; }
.demo-title { font-size: 21px; font-weight: 800; margin: 6px 0 2px; }
.demo-intro { margin: 0; font-size: 16px; color: var(--ink-2); line-height: 1.7; }
.demo-stage { padding: 18px 20px 20px; font-size: 16px; line-height: 1.6; }
.demo-note { margin: 12px 0 0; padding: 10px 14px; border-radius: 10px; background: var(--paper-2); font-size: 15.5px; line-height: 1.7; color: var(--ink-2); }
.demo-note b { color: var(--ink); }
.demo-note.is-bad { background: var(--bad-soft); color: var(--bad); }
.demo-note.is-good { background: var(--good-soft); color: var(--good); }
.demo-row { display: flex; gap: 10px 16px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.demo-row label { font-weight: 700; font-size: 15px; display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.demo select, .demo input[type=number], .demo input[type=text] {
  min-height: 44px; padding: 6px 12px; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 2px solid var(--line); border-radius: 10px;
}
.demo select:focus, .demo input:focus { outline: 0; border-color: var(--a); }
.demo input[type=range] { width: min(320px, 100%); accent-color: var(--a); height: 32px; }
.dbtn {
  min-height: 44px; padding: 0 18px; border-radius: 999px; border: 2px solid var(--a);
  background: var(--card); color: var(--a); font-weight: 700; font-size: 15.5px; cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}
.dbtn:hover { background: var(--a-soft); }
.dbtn:active { transform: scale(.97); }
.dbtn.primary { background: var(--a); color: var(--a-on); }
.dbtn.primary:hover { filter: brightness(1.08); }
.dbtn:disabled { opacity: .45; cursor: not-allowed; }

/* 迷你表格 */
.xl { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.xl-fx { display: flex; gap: 8px; align-items: center; padding: 8px; border-bottom: 1px solid var(--line); background: var(--paper); }
.xl-fx .xl-name { min-width: 56px; text-align: center; padding: 4px 8px; border: 1px solid var(--line); border-radius: 6px; background: var(--card); font-family: var(--font-mono); font-size: 14.5px; }
.xl-fx .fx { font-style: italic; color: var(--ink-3); font-family: var(--font-body); padding: 0 4px; }
.xl-fx input.xl-input { flex: 1; min-width: 0; min-height: 40px; font-family: var(--font-mono); font-size: 15.5px; border-radius: 8px; }
table.xl-table { border-collapse: collapse; width: 100%; min-width: 440px; font-size: 15.5px; user-select: none; }
.xl-table th, .xl-table td { border: 1px solid var(--line-soft); padding: 0; height: 44px; }
.xl-table th { background: var(--paper-2); color: var(--ink-3); font-size: 13px; font-weight: 600; text-align: center; }
.xl-table th.row { width: 34px; }
.xl-table td { position: relative; padding: 0 10px; cursor: cell; background: var(--card); white-space: nowrap; }
.xl-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.xl-table td.is-sel { outline: 3px solid var(--a); outline-offset: -3px; background: var(--a-soft); z-index: 1; }
.xl-table td.is-ref { outline: 2px dashed #D9730D; outline-offset: -2px; background: color-mix(in srgb, #D9730D 12%, var(--card)); }
.xl-table td.is-ref-2 { outline: 2px dashed #7A3DB4; outline-offset: -2px; background: color-mix(in srgb, #7A3DB4 12%, var(--card)); }
.xl-table td.is-match { background: color-mix(in srgb, #FFD84D 45%, var(--card)); }
.xl-table td.is-result { background: var(--good-soft); outline: 3px solid var(--good); outline-offset: -3px; font-weight: 700; }
.xl-table td.is-new { animation: cell-pop .5s ease; }
.xl-table td.is-bad { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.xl-table td.hdr { background: var(--paper-2); font-weight: 700; cursor: default; }
.xl-table td.is-pick { cursor: pointer; }
.xl-table tr.is-hidden-row { display: none; }
.xl-table th.row.is-skip { color: #2257C4; font-weight: 800; }
.xl-table th.sortable { cursor: pointer; user-select: none; background: var(--a-soft); color: var(--a); font-weight: 700; font-size: 14.5px; }
.xl-table th.sortable:hover { filter: brightness(.96); }
.xl-handle { position: absolute; right: -5px; bottom: -5px; width: 14px; height: 14px; background: var(--a); border: 2px solid var(--card); border-radius: 3px; cursor: crosshair; touch-action: none; z-index: 3; animation: handle-pulse 1.6s ease infinite; }
.xl-handle::before { content: ""; position: absolute; inset: -14px; }
@keyframes handle-pulse { 0%,100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--a) 50%, transparent); } 50% { box-shadow: 0 0 0 7px transparent; } }
@keyframes cell-pop { from { background: #FFD84D; transform: scale(1.05); } }
.xl-table code, .demo code { font-family: var(--font-mono); font-size: .92em; }
.xl-hint { font-size: 14.5px; color: var(--ink-3); margin: 8px 2px 0; }

/* 公式说明条 */
.formula-line { font-family: var(--font-mono); font-size: 16px; padding: 10px 14px; background: #14201A; color: #E7F6EC; border-radius: 10px; margin: 10px 0; overflow-x: auto; white-space: nowrap; }
.formula-line .hl { background: #D9730D; color: #fff; border-radius: 4px; padding: 0 4px; }
.formula-line .hl2 { background: #7A3DB4; color: #fff; border-radius: 4px; padding: 0 4px; }
.formula-line .hl3 { background: #157347; color: #fff; border-radius: 4px; padding: 0 4px; }

/* IF 演示 */
.if-flow { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
.if-branches { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.if-branch { padding: 12px 14px; border-radius: 12px; border: 2px dashed var(--line); text-align: center; opacity: .5; transition: all .25s ease; }
.if-branch b { display: block; }
.if-branch.is-on { opacity: 1; border-style: solid; transform: scale(1.02); }
.if-branch.t.is-on { border-color: var(--good); background: var(--good-soft); color: var(--good); }
.if-branch.f.is-on { border-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.if-cond { text-align: center; padding: 12px; border-radius: 12px; background: var(--a-soft); font-family: var(--font-mono); font-weight: 600; }

/* 数据透视表 */
.pv-fields { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.pv-chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: var(--paper); cursor: pointer; font-weight: 700; }
.pv-chip[data-area="rows"] { border-color: #D9730D; background: color-mix(in srgb, #D9730D 12%, var(--card)); }
.pv-chip[data-area="cols"] { border-color: #7A3DB4; background: color-mix(in srgb, #7A3DB4 12%, var(--card)); }
.pv-chip[data-area="vals"] { border-color: var(--good); background: var(--good-soft); }
.pv-chip small { margin-left: 6px; font-weight: 500; color: var(--ink-3); }
.pv-areas { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.pv-area { border: 2px dashed var(--line); border-radius: 10px; padding: 8px 10px; min-height: 64px; font-size: 14.5px; }
.pv-area b { display: block; font-size: 13px; color: var(--ink-3); }
.pv-area.rows b { color: #D9730D; } .pv-area.cols b { color: #7A3DB4; } .pv-area.vals b { color: var(--good); }

/* 闪卡 */
.fc-wrap { perspective: 900px; }
.fc { position: relative; height: 190px; cursor: pointer; transform-style: preserve-3d; transition: transform .55s cubic-bezier(.2,.8,.2,1); }
.fc.is-flipped { transform: rotateY(180deg); }
.fc-face { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; display: grid; place-items: center; text-align: center; padding: 20px; border-radius: 16px; border: 2px solid var(--a); font-size: 20px; font-weight: 700; }
.fc-front { background: var(--a-soft); }
.fc-back { background: var(--a); color: var(--a-on); transform: rotateY(180deg); }
.fc-back kbd { font-size: 22px; background: rgba(255,255,255,.95); color: #1B2230; border-color: rgba(0,0,0,.2); }
.fc-count { font-size: 14.5px; color: var(--ink-3); }

/* 功能区 */
.rb { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.rb-tabs { display: flex; gap: 2px; overflow-x: auto; background: var(--a); padding: 6px 8px 0; scrollbar-width: none; }
.rb-tab { flex: none; min-height: 40px; padding: 0 16px; border: 0; border-radius: 8px 8px 0 0; background: transparent; color: var(--a-on); font-weight: 600; cursor: pointer; opacity: .85; }
.rb-tab.is-on { background: var(--paper); color: var(--a); opacity: 1; font-weight: 800; }
.rb-panel { display: flex; gap: 0; overflow-x: auto; padding: 10px 6px; background: var(--paper); }
.rb-group { flex: none; padding: 4px 12px 6px; border-right: 1px solid var(--line); text-align: center; }
.rb-group:last-child { border-right: 0; }
.rb-btns { display: flex; gap: 6px; }
.rb-btn { min-width: 64px; min-height: 64px; padding: 6px 8px; border-radius: 10px; border: 2px solid transparent; background: transparent; cursor: pointer; display: grid; gap: 2px; place-items: center; font-size: 13.5px; line-height: 1.3; }
.rb-btn:hover { background: var(--a-soft); }
.rb-btn.is-on { border-color: var(--a); background: var(--a-soft); }
.rb-btn .ic { font-size: 24px; line-height: 1; }
.rb-gname { margin-top: 2px; font-size: 12.5px; color: var(--ink-3); }
.rb-info { padding: 14px 18px; border-top: 1px solid var(--line); background: var(--card); min-height: 88px; }
.rb-info b { font-size: 17px; }
.rb-info p { margin: 4px 0 0; font-size: 16px; color: var(--ink-2); line-height: 1.7; }

/* 样式对比（左右并排） */
.cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; color: #1B2230; }
.cmp-doc { position: relative; padding: 38px 20px 16px; font-size: 15.5px; line-height: 1.7; background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.cmp-styled h4 { font-family: var(--font-head); font-size: 22px; margin: 0 0 6px; color: var(--hcolor, #2257C4); border-bottom: 3px solid var(--hcolor, #2257C4); padding-bottom: 4px; transition: color .3s ease, border-color .3s ease; }
.cmp-styled h5 { font-size: 17px; margin: 14px 0 2px; color: var(--hcolor, #2257C4); transition: color .3s ease; }
.cmp-styled p, .cmp-manual p { margin: 0 0 8px; }
.cmp-manual .fake-h1 { font-size: 22px; font-weight: 700; margin-bottom: 6px; transition: color .3s ease; }
.cmp-manual .fake-h2 { font-size: 17px; font-weight: 700; margin: 14px 0 2px; transition: color .3s ease; }
.cmp-tag { position: absolute; top: 10px; left: 12px; padding: 1px 12px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: #1B2230; color: #fff; }
.cmp-tag.r { background: var(--a); color: var(--a-on); }
@media (max-width: 640px) { .cmp { grid-template-columns: 1fr; } }
.swatches { display: flex; gap: 8px; align-items: center; }
.swatch { width: 40px; height: 40px; border-radius: 50%; border: 3px solid var(--card); box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.swatch.is-on { box-shadow: 0 0 0 3px var(--ink); }

/* 邮件规则 */
.ml-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.ml-box { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--card); }
.ml-box h4 { margin: 0; padding: 8px 12px; background: var(--paper-2); font-size: 14.5px; border-bottom: 1px solid var(--line); }
.ml-item { padding: 8px 12px; border-bottom: 1px solid var(--line-soft); font-size: 15px; line-height: 1.45; transition: opacity .35s ease, transform .35s ease; }
.ml-item small { display: block; color: var(--ink-3); }
.ml-item.is-moving { opacity: 0; transform: translateX(40px); }
.ml-folders { display: grid; gap: 8px; }
.ml-folder { padding: 8px 12px; border: 2px dashed var(--line); border-radius: 12px; min-height: 52px; font-size: 14.5px; }
.ml-folder b { display: block; font-size: 14px; margin-bottom: 2px; }
.ml-folder .ml-item { padding: 4px 6px; border: 0; background: var(--a-soft); border-radius: 6px; margin-top: 4px; }
.ml-count { font-weight: 500; color: var(--ink-3); }

@media (max-width: 640px) {
  .pv-areas { grid-template-columns: 1fr; }
  .ml-grid { grid-template-columns: 1fr; }
  .if-branches { grid-template-columns: 1fr; }
  .demo-stage { padding: 14px; }
  .fc { height: 210px; }
}
@media (prefers-reduced-motion: reduce) {
  .xl-handle { animation: none; }
  .fc { transition: none; }
}

/* 演示在 .note-body 里，要盖掉正文 h2 的绿色竖条和大边距 */
.note-body .demo-title { font-size: 21px; margin: 8px 0 4px; padding: 0; }
.note-body .demo-title::before { display: none; }
.note-body .demo .xl-table th, .note-body .demo .xl-table td { line-height: 1.4; }
.note-body .demo ol.steps { margin: 12px 0 0; }
.note-body .demo ol.steps > li { margin: 8px 0; padding: 10px 14px 10px 58px; }
.note-body .demo ol.steps > li::before { top: 8px; }
