/* ============================================================
   TYNet 开发者工具箱 · 运维专题版式
   供 /tools/docker/ 与 /tools/nginx/ 共用：左侧分类树 + 右侧命令详情
   依赖 tools.css 的 :root 变量与基础组件，主题切换自动跟随
   ============================================================ */

/* ---------------- 两栏骨架 ---------------- */
.topic-wrap {
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
    margin-bottom: 26px;
}

/* ---------------- 左侧：分类树 ---------------- */
.topic-left {
    position: sticky;
    top: calc(var(--header-h) + 14px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - var(--header-h) - 30px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.topic-left-head {
    padding: 13px 13px 11px;
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
}

.topic-left-head h2 {
    margin: 0 0 2px;
    font-size: 14px;
    font-weight: 680;
    letter-spacing: -.1px;
    display: flex;
    align-items: center;
    gap: 7px;
}

.topic-left-head .meta {
    font-size: 11.5px;
    color: var(--muted);
    margin-bottom: 9px;
}
.topic-left-head .meta-verified {
    color: #0a7a4b;
    font-weight: 650;
}
html[data-theme="dark"] .topic-left-head .meta-verified { color: #5ee0a4; }

.topic-search {
    position: relative;
}

.topic-search svg {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.topic-search input {
    width: 100%;
    height: 32px;
    padding: 0 26px 0 28px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--ink);
    font-size: 12.5px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
}

.topic-search input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.topic-search .clr {
    position: absolute;
    right: 5px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: none;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
}

.topic-search .clr:hover {
    background: var(--line);
    color: var(--ink);
}

.topic-search.has-value .clr {
    display: flex;
}

.topic-tree {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 6px 6px 10px;
    overscroll-behavior: contain;
}

.topic-cat {
    margin-bottom: 1px;
}

.topic-cat-head {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 7px 7px;
    border: 0;
    border-radius: 8px;
    background: none;
    color: var(--ink-2);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 650;
    text-align: left;
    cursor: pointer;
}

.topic-cat-head:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.topic-cat-head .caret {
    flex: 0 0 auto;
    color: var(--muted);
    transition: transform .16s ease;
}

.topic-cat.open > .topic-cat-head .caret {
    transform: rotate(90deg);
}

.topic-cat-head .cname {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-cat-head .cnum {
    flex: 0 0 auto;
    font-family: var(--mono);
    font-size: 10.5px;
    font-weight: 500;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 0 6px;
    line-height: 16px;
}

.topic-cat-body {
    display: none;
    padding: 2px 0 4px;
}

.topic-cat.open > .topic-cat-body {
    display: block;
}

.topic-leaf {
    display: block;
    padding: 5px 8px 5px 27px;
    border-radius: 7px;
    color: var(--ink-2);
    font-size: 12.5px;
    line-height: 1.45;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    cursor: pointer;
}

.topic-leaf:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.topic-leaf.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 650;
}

.topic-tree-empty {
    padding: 34px 12px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}

/* ---------------- 右侧：命令详情 ---------------- */
.topic-right {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px 20px 20px;
}

.topic-right-head {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 14px;
}

.topic-crumb {
    font-size: 12px;
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-crumb b {
    color: var(--ink-2);
    font-weight: 600;
}

.topic-right-head .btn-row {
    margin-left: auto;
    flex: 0 0 auto;
}

.topic-title {
    margin: 0 0 5px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.35px;
    line-height: 1.35;
}

.topic-summary {
    margin: 0 0 12px;
    color: var(--muted);
    font-size: 13.5px;
    line-height: 1.7;
}

.topic-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 14px;
}

.topic-tag {
    font-size: 11px;
    color: var(--brand);
    background: var(--brand-soft);
    border-radius: 5px;
    padding: 1px 7px;
    line-height: 18px;
}

/* 参数区 */
.topic-params {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 12px 13px 13px;
    margin-bottom: 14px;
}

.topic-params-head {
    font-size: 11.5px;
    font-weight: 650;
    color: var(--muted);
    letter-spacing: .2px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.topic-param {
    display: grid;
    grid-template-columns: minmax(120px, 210px) minmax(0, 1fr);
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

/* 多行输入时标签与输入框顶部对齐 */
.topic-param:has(.topic-textarea) {
    align-items: start;
}

.topic-param:last-child {
    margin-bottom: 0;
}

.topic-param-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.topic-param-name {
    font-size: 12.5px;
    color: var(--ink-2);
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topic-param-key {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--muted);
}

/* 覆盖全局 .input-x 的 9px 垂直内边距：32px 高度 - 2px 边框 - 18px 垂直 padding，
   内容盒只剩 12px，12.5px 文字会被截断。
   输入框靠 padding 垂直归零 + 28px 行高（30px 内容盒内居中）修正 */
.topic-param .input-x {
    width: 100%;
    height: 32px;
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 0 9px;
    line-height: 28px;
}

/* select 与 input 共用尺寸；select 的垂直居中由 UA 原生完成，不要加 line-height
   （Chromium/Edge 对 <select> 强制 line-height: normal，声明会被忽略），
   真正修复文字截断的是 padding 垂直归零把内容盒从 12px 撑回 30px。
   右侧 26px 为原生下拉箭头预留空间，避免选中项文字被箭头压住。
   注意：topic.js 渲染的 select 同时带 .input-x 类，而 .topic-param .input-x
   的权重(0,2,0)高于 .topic-param select(0,1,1)，所以这里必须用
   select.input-x 提高权重，否则右侧 26px 预留会被 padding:0 9px 覆盖 */
.topic-param select,
.topic-param select.input-x {
    width: 100%;
    height: 32px;
    font-family: var(--mono);
    font-size: 12.5px;
    padding: 0 26px 0 9px;
    text-overflow: ellipsis;
}

/* 多行参数（如 upstream 节点列表）：保持换行，避免单行输入框吃掉格式 */
.topic-param .topic-textarea {
    height: auto;
    min-height: 66px;
    padding: 7px 9px;
    line-height: 1.55;
    resize: vertical;
}

.topic-param-help {
    grid-column: 2;
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.55;
    margin-top: -6px;
    padding-bottom: 2px;
}

/* 开关：保持自身尺寸，不被 grid 拉伸 */
.topic-switch {
    position: relative;
    justify-self: start;
    width: 38px;
    height: 21px;
    border: 0;
    border-radius: 22px;
    background: var(--line-strong);
    cursor: pointer;
    transition: background .16s;
    flex: 0 0 auto;
}

.topic-switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .28);
    transition: transform .16s;
}

.topic-switch[aria-checked="true"] {
    background: var(--brand);
}

.topic-switch[aria-checked="true"]::after {
    transform: translateX(17px);
}

/* 代码输出 */
.topic-code-box {
    position: relative;
    margin-bottom: 14px;
}

.topic-code-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: color-mix(in srgb, var(--code-bg) 88%, #fff 12%);
    border: 1px solid color-mix(in srgb, var(--code-bg) 70%, #fff 30%);
    border-bottom: 0;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    font-size: 11px;
    color: color-mix(in srgb, var(--code-ink) 62%, transparent);
    font-family: var(--mono);
}

.topic-code-bar .spacer {
    margin-left: auto;
}

.topic-code-bar button {
    border: 1px solid color-mix(in srgb, var(--code-ink) 22%, transparent);
    background: transparent;
    color: color-mix(in srgb, var(--code-ink) 78%, transparent);
    border-radius: 5px;
    font-size: 11px;
    padding: 1px 8px;
    cursor: pointer;
    font-family: inherit;
}

.topic-code-bar button:hover {
    background: color-mix(in srgb, var(--code-ink) 14%, transparent);
    color: var(--code-ink);
}

.topic-code {
    margin: 0;
    padding: 13px 14px;
    background: var(--code-bg);
    color: var(--code-ink);
    border-radius: 0 0 var(--radius-sm) var(--radius-sm);
    font-family: var(--mono);
    font-size: 12.5px;
    line-height: 1.68;
    white-space: pre;
    overflow-x: auto;
    tab-size: 4;
}

.topic-code code {
    font: inherit;
    color: inherit;
    background: none;
    padding: 0;
}

/* 注意块 */
.topic-note {
    display: flex;
    gap: 9px;
    padding: 10px 12px;
    background: #fffaeb;
    border: 1px solid #fde68a;
    border-left: 3px solid var(--warn);
    border-radius: 8px;
    font-size: 12.5px;
    line-height: 1.66;
    color: #7c5a12;
}

.topic-note .tag {
    flex: 0 0 auto;
    font-weight: 700;
    color: #b45309;
}

html[data-theme="dark"] .topic-note {
    background: rgba(245, 158, 11, .1);
    border-color: rgba(245, 158, 11, .32);
    border-left-color: var(--warn);
    color: #fcd34d;
}

html[data-theme="dark"] .topic-note .tag {
    color: var(--warn);
}

/* 空态 */
.topic-empty {
    padding: 60px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

/* ---------------- 底部：静态命令索引（SEO） ---------------- */
.topic-index {
    margin-top: 4px;
}

.topic-index-group {
    margin-bottom: 18px;
}

.topic-index-group h3 {
    margin: 0 0 7px;
    font-size: 13.5px;
    font-weight: 680;
    color: var(--ink);
    display: flex;
    align-items: baseline;
    gap: 7px;
}

.topic-index-group h3 .n {
    font-family: var(--mono);
    font-size: 11px;
    font-weight: 400;
    color: var(--muted);
}

.topic-index-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(268px, 1fr));
    gap: 3px 18px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.topic-index-list a {
    display: block;
    padding: 3px 0;
    font-size: 12.5px;
    color: var(--ink-2);
    border-bottom: 1px dashed transparent;
}

.topic-index-list a:hover {
    color: var(--brand);
    border-bottom-color: color-mix(in srgb, var(--brand) 40%, transparent);
}

.topic-index-list a b {
    font-weight: 600;
}

.topic-index-list a span {
    color: var(--muted);
    font-size: 11.5px;
    margin-left: 5px;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 940px) {
    .topic-wrap {
        grid-template-columns: minmax(0, 1fr);
    }

    .topic-left {
        position: static;
        max-height: none;
    }

    .topic-tree {
        max-height: 340px;
    }

    .topic-right {
        padding: 15px 15px 17px;
    }

    .topic-param {
        grid-template-columns: minmax(0, 1fr);
        gap: 5px;
    }

    .topic-param-help {
        grid-column: 1;
        margin-top: -2px;
    }
}

@media (max-width: 560px) {
    .topic-title {
        font-size: 17.5px;
    }

    .topic-code {
        font-size: 11.5px;
        padding: 11px 12px;
    }

    .topic-index-list {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---------------- 真机实测徽章 ----------------
   仅出现在已通过 Docker 容器逐条实测的专题页 tool-head 标题右侧。
   绿色胶囊 + 对勾，鼠标悬停 title 显示实测环境；深浅主题各一套配色。 */
.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: 999px;
    background: #e7f8f0;
    border: 1px solid #a7e8c9;
    color: #0a7a4b;
    font-size: 12.5px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .2px;
    white-space: nowrap;
    cursor: help;
    box-shadow: 0 1px 2px rgba(16, 185, 129, .12);
    vertical-align: middle;
}
.verified-badge svg {
    flex: 0 0 auto;
}
html[data-theme="dark"] .verified-badge {
    background: #0d2b21;
    border-color: #1c6e4e;
    color: #5ee0a4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

/* ---------------- 命令级真机实测标记（取代专题级大徽章） ----------------
   由 topic.js 依据 assets/verified-commands.js 按 command id 渲染。
   左树条目后是一枚极小绿勾，右侧详情标题旁是「真机实测」小胶囊。 */
.cmd-verified {
    display: inline-flex;
    align-items: center;
    color: #0a7a4b;
    cursor: help;
    vertical-align: middle;
}
.cmd-verified svg { flex: 0 0 auto; }

/* 左树：紧跟命令名的极小绿勾，不影响省略号布局 */
.cmd-verified-leaf {
    margin-left: 5px;
    opacity: .85;
}

/* 详情标题：小胶囊徽章 */
.cmd-verified-title {
    gap: 4px;
    margin-left: 9px;
    padding: 3px 9px;
    border-radius: 999px;
    background: #e7f8f0;
    border: 1px solid #a7e8c9;
    font-size: 11.5px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: .2px;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(16, 185, 129, .1);
}
html[data-theme="dark"] .cmd-verified { color: #5ee0a4; }
html[data-theme="dark"] .cmd-verified-title {
    background: #0d2b21;
    border-color: #1c6e4e;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .35);
}

/* 命令详解页入口（枢纽页详情标题下，指向独立长尾页） */
.topic-cmd-detail-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: -2px 0 10px;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    color: #4f46e5;
    background: #eef2ff;
    border: 1px solid #c7d2fe;
    border-radius: 999px;
    text-decoration: none;
}
.topic-cmd-detail-link:hover { background: #e0e7ff; }
html[data-theme="dark"] .topic-cmd-detail-link {
    color: #a5b4fc;
    background: #1e1b4b;
    border-color: #3730a3;
}
