/* HTS工作室官网样式 - 黑白灰简约扁平风格（支持浅色/深色/跟随系统） */

/* ============ 主题变量 ============ */
:root {
    --bg: #ffffff;
    --surface: #ffffff;
    --block: #f5f5f5;
    --border: #e5e5e5;
    --text: #1a1a1a;
    --text-soft: #555555;
    --text-muted: #888888;
    --text-faint: #999999;
    --primary: #1a1a1a;
    --on-primary: #ffffff;
    --footer-bg: #1a1a1a;
    --footer-text: #ffffff;
    --footer-muted: #999999;
    --shadow: rgba(0, 0, 0, 0.06);
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --switch-knob: #ffffff;
    --code-bg: #f5f5f5;
    --code-text: #555555;
    --code-max-height: 320px;
}

/* 显式浅色 */
html[data-theme="light"] {
    --bg: #ffffff;
    --surface: #ffffff;
    --block: #f5f5f5;
    --border: #e5e5e5;
    --text: #1a1a1a;
    --text-soft: #555555;
    --text-muted: #888888;
    --text-faint: #999999;
    --primary: #1a1a1a;
    --on-primary: #ffffff;
    --footer-bg: #1a1a1a;
    --footer-text: #ffffff;
    --footer-muted: #999999;
    --shadow: rgba(0, 0, 0, 0.06);
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --switch-knob: #ffffff;
    --code-bg: #f5f5f5;
    --code-text: #555555;
}

/* 显式深色 */
html[data-theme="dark"] {
    --bg: #141414;
    --surface: #1c1c1c;
    --block: #1e1e1e;
    --border: #2e2e2e;
    --text: #e8e8e8;
    --text-soft: #b0b0b0;
    --text-muted: #9a9a9a;
    --text-faint: #777777;
    --primary: #e8e8e8;
    --on-primary: #141414;
    --footer-bg: #0d0d0d;
    --footer-text: #e8e8e8;
    --footer-muted: #888888;
    --shadow: rgba(0, 0, 0, 0.35);
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --switch-knob: #f0f0f0;
    --code-bg: #1e1e1e;
    --code-text: #b0b0b0;
}

/* 跟随系统：未显式指定主题时生效 */
@media (prefers-color-scheme: dark) {
    html:not([data-theme]) {
        --bg: #141414;
        --surface: #1c1c1c;
        --block: #1e1e1e;
        --border: #2e2e2e;
        --text: #e8e8e8;
        --text-soft: #b0b0b0;
        --text-muted: #9a9a9a;
        --text-faint: #777777;
        --primary: #e8e8e8;
        --on-primary: #141414;
        --footer-bg: #0d0d0d;
        --footer-text: #e8e8e8;
        --footer-muted: #888888;
        --shadow: rgba(0, 0, 0, 0.35);
        --modal-overlay: rgba(0, 0, 0, 0.7);
        --switch-knob: #f0f0f0;
        --code-bg: #1e1e1e;
        --code-text: #b0b0b0;
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

section[id] {
    scroll-margin-top: 72px;
}

body {
    font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif;
    color: var(--text);
    background-color: var(--bg);
    line-height: 1.7;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 24px;
}

/* 主题切换瞬间禁用过渡，防止全页动画同时触发卡顿 */
html.theme-anim-off,
html.theme-anim-off *,
html.theme-anim-off *::before,
html.theme-anim-off *::after {
    transition: none !important;
    animation: none !important;
}

/* 顶部导航 */
.header {
    background-color: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 10;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
    margin-left: 12px; /* 左上角图标向右留白 */
}

.logo-icon {
    width: 28px;
    height: 28px;
}

/* 深浅主题图片切换：浅色用 .logo-light，深色用 .logo-dark
   注意用 img.logo-dark 提高优先级，压过后面的 .nav-logo{display:block} */
img.logo-dark { display: none; }

html[data-theme="dark"] .logo-light { display: none; }
html[data-theme="dark"] .logo-dark { display: inline-block; }

@media (prefers-color-scheme: dark) {
    html:not([data-theme]) .logo-light { display: none; }
    html:not([data-theme]) .logo-dark { display: inline-block; }
}

/* 导航栏图片链接：与文字导航同尺寸、同悬停下划线动效 */
.nav a.nav-img {
    display: flex;
    align-items: center;
}

.nav-logo {
    height: 17px;
    width: auto;
    display: block;
}

/* 图片较宽，下划线缩短为 60% 并居中展开；
   文字链接行框约 25px、图片锚点 17px，
   bottom 加大到 -8px 才能与文字下划线同一水平线 */
.nav a.nav-img::after {
    left: 20%;
    width: 60%;
    bottom: -8px;
}

.logo-text {
    font-size: 18px;
    font-weight: bold;
    letter-spacing: 1px;
}

.nav {
    display: flex;
    align-items: center;
    gap: 28px;
}

.nav a {
    position: relative;
    color: var(--text);
    text-decoration: none;
    font-size: 15px;
    white-space: nowrap;
    flex: none;
    transition: color 0.25s ease;
}

.nav a::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -4px;
    width: 100%;
    height: 1px;
    background-color: var(--primary);
    transform: scaleX(0);
    transition: transform 0.25s ease;
}

.nav a:hover {
    color: var(--text-muted);
}

.nav a:hover::after {
    transform: scaleX(1);
}

/* 主题下拉框 */
.theme-select {
    appearance: none;
    -webkit-appearance: none;
    flex: none;
    padding: 6px 28px 6px 12px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23888' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: border-color 0.25s ease, background-color 0.25s ease;
}

.theme-select:hover {
    border-color: var(--primary);
}

.theme-select:focus {
    outline: none;
    border-color: var(--primary);
}

/* 首屏 */
.hero {
    background-color: var(--block);
    border-bottom: 1px solid var(--border);
    text-align: center;
    padding: 110px 0 100px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.hero-title {
    font-size: 52px;
    font-weight: bold;
    letter-spacing: 4px;
}

.hero-en {
    margin-top: 14px;
    font-size: 22px;
    color: var(--text-soft);
    letter-spacing: 3px;
}

.hero-sub {
    margin-top: 8px;
    font-size: 17px;
    color: var(--text-muted);
    letter-spacing: 2px;
}

.btn {
    display: inline-block;
    margin-top: 40px;
    padding: 12px 44px;
    background-color: var(--primary);
    color: var(--on-primary);
    text-decoration: none;
    font-size: 15px;
    border-radius: 15px;
    border: 1px solid var(--primary);
    cursor: pointer;
    font-family: inherit;
    transition: background-color 0.25s ease, color 0.25s ease, transform 0.15s ease, border-color 0.25s ease;
}

.btn:hover {
    background-color: var(--bg);
    color: var(--primary);
}

.btn:active {
    transform: scale(0.97);
}

/* 内容区块 */
.section {
    padding: 80px 0;
    text-align: center;
    transition: background-color 0.3s ease;
}

/* 仅在 JS 可用时启用滚动渐显，避免脚本异常导致区块不可见 */
html.js .section {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease, transform 0.6s ease;
}

html.js .section.in-view {
    opacity: 1;
    transform: translateY(0);
}

/* 首屏入场 */
@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.hero .container {
    animation: fadeUp 0.6s ease both;
}

.section-gray {
    background-color: var(--block);
    border-top: 1px solid var(--border);
}

.section-title {
    font-size: 28px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 24px;
}

.section-text {
    max-width: 640px;
    margin: 0 auto;
    font-size: 16px;
    color: var(--text-soft);
}

.site {
    font-weight: bold;
    color: var(--primary);
    text-decoration: none;
}

.contact-line {
    margin-top: 8px;
}

.site:hover {
    text-decoration: underline;
}

/* 捐赠按钮 */
.donate-btn {
    margin-top: 32px;
    cursor: pointer;
    font-family: inherit;
}

/* 捐赠二维码弹窗 */
.modal-mask {
    visibility: hidden;
    opacity: 0;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--modal-overlay);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.modal-mask.show {
    visibility: visible;
    opacity: 1;
}

.modal-box {
    position: relative;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 36px 40px 30px;
    text-align: center;
    width: 300px;
    transform: scale(0.94);
    transition: transform 0.25s ease, background-color 0.3s ease, border-color 0.3s ease;
}

.modal-mask.show .modal-box {
    transform: scale(1);
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 14px;
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--text-faint);
    cursor: pointer;
    font-family: inherit;
    transition: color 0.25s ease, transform 0.25s ease;
}

.modal-close:hover {
    color: var(--primary);
    transform: rotate(90deg);
}

.modal-title {
    font-size: 20px;
    font-weight: bold;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

.donate-qr {
    width: 220px;
    height: 220px;
    display: block;
    margin: 0 auto;
    border: 1px solid var(--border);
}

.modal-tip {
    margin-top: 16px;
    font-size: 14px;
    color: var(--text-muted);
}

/* 页脚 */
.footer {
    background-color: var(--footer-bg);
    color: var(--footer-text);
    text-align: center;
    padding: 32px 0;
    font-size: 14px;
    transition: background-color 0.3s ease, color 0.3s ease;
}

.footer-site {
    margin-top: 6px;
    color: var(--footer-muted);
    letter-spacing: 1px;
}

.footer-link {
    color: var(--footer-muted);
    text-decoration: none;
    transition: color 0.25s ease;
}

.footer-link:hover {
    color: var(--footer-text);
}

/* 导航站 */
#nav {
    border-top: 1px solid var(--border);
}

.site-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    gap: 20px;
    margin-top: 40px;
    text-align: left;
}

.site-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 15px;
    padding: 20px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease, background-color 0.3s ease;
}

.site-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 6px 18px var(--shadow);
}

.site-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    flex: none;
    object-fit: contain;
    background-color: var(--surface);
}

.site-letter {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    background-color: var(--primary);
    color: var(--on-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    flex: none;
}

.site-info {
    min-width: 0;
}

.site-name {
    font-size: 16px;
    font-weight: bold;
}

.site-desc {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
    word-break: break-all;
}

/* ============ 通用 UI 组件（各网站统一使用，规范见 ui/） ============ */

.btn-plain {
    background-color: var(--surface);
    color: var(--primary);
}

.btn-plain:hover {
    background-color: var(--primary);
    color: var(--on-primary);
}

.btn-sm {
    padding: 8px 24px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background-color: var(--surface);
    outline: none;
    transition: border-color 0.25s ease, background-color 0.25s ease;
}

.select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%23888' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 34px;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);
}

.input:disabled,
.select:disabled,
.textarea:disabled {
    background-color: var(--block);
    color: var(--text-faint);
    cursor: not-allowed;
}

.textarea {
    min-height: 88px;
    resize: vertical;
}

input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.switch {
    position: relative;
    width: 44px;
    height: 24px;
    border: none;
    border-radius: 12px;
    background-color: var(--border);
    cursor: pointer;
    transition: background-color 0.25s ease;
    flex: none;
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background-color: var(--switch-knob);
    box-shadow: 0 1px 3px var(--shadow);
    transition: transform 0.25s ease, background-color 0.25s ease;
}

.switch.on {
    background-color: var(--primary);
}

.switch.on::after {
    transform: translateX(20px);
    background-color: var(--on-primary);
}

.tag {
    display: inline-block;
    padding: 4px 14px;
    border: 1px solid var(--border);
    border-radius: 15px;
    font-size: 13px;
    color: var(--text-soft);
    background-color: var(--surface);
}

.tag-dark {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--on-primary);
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background-color: var(--surface);
    text-align: left;
}

/* 表格防溢出：table 不会收缩到内容宽度以下，
   窄屏由外层容器横向滚动，整页不左右滑 */
.table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-wrap .table {
    min-width: 480px;
}

.table th,
.table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-weight: normal;
    font-size: 13px;
    color: var(--text-muted);
}

.table tbody tr {
    transition: background-color 0.2s ease;
}

.table tbody tr:hover {
    background-color: var(--block);
}

.divider {
    height: 1px;
    border: none;
    background-color: var(--border);
}

.progress {
    height: 6px;
    background-color: var(--block);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0;
    background-color: var(--primary);
    border-radius: 3px;
    transition: width 0.6s ease;
}

/* 可拖动进度条：拖动时实时跟随，取消过渡避免迟滞 */
.progress-drag {
    cursor: pointer;
    touch-action: none;
    overflow: visible; /* 让小球能超出 6px 轨道显示 */
}

.progress-drag .progress-bar {
    transition: none;
    position: relative;
}

/* 拖动手柄小球：跟随填充末端，悬停/拖动时显示 */
.progress-thumb {
    position: absolute;
    right: -8px;
    top: 50%;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background-color: var(--primary);
    border: 2px solid var(--bg);
    box-sizing: border-box;
    transform: translateY(-50%) scale(0.4);
    opacity: 0;
    transition: transform 0.2s ease, opacity 0.2s ease;
    pointer-events: none;
}

.progress-drag:hover .progress-thumb,
.progress-drag.dragging .progress-thumb {
    transform: translateY(-50%) scale(1);
    opacity: 1;
}

.progress-drag.dragging .progress-thumb {
    transform: translateY(-50%) scale(1.2);
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    transform: translate(-50%, 16px);
    background-color: var(--primary);
    color: var(--on-primary);
    padding: 10px 26px;
    border-radius: 15px;
    font-size: 14px;
    opacity: 0;
    visibility: hidden;
    z-index: 200;
    transition: opacity 0.25s ease, transform 0.25s ease, visibility 0.25s ease;
}

.toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* 代码框 */
.code-box {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-top: 16px;
    background-color: var(--code-bg);
}

.code-box-head {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 40px 8px 14px;
    background-color: var(--surface);
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    user-select: none;
    transition: background-color 0.3s ease;
}

.code-box-head:hover {
    background-color: var(--block);
}

/* 展开箭头 */
.code-box-head::after {
    content: "▶";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
    color: var(--text-faint);
    transition: transform 0.25s ease;
}

.code-box.expanded .code-box-head::after {
    transform: translateY(-50%) rotate(90deg);
}

.code-box-lang {
    font-size: 12px;
    color: var(--text-muted);
    font-family: "Consolas", "Monaco", monospace;
    letter-spacing: 0.5px;
}

.code-copy {
    padding: 4px 12px;
    font-size: 12px;
    font-family: inherit;
    color: var(--text-soft);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, color 0.2s ease, border-color 0.2s ease;
}

.code-copy:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* 展开后才显示复制按钮 */
.code-box.expanded .code-copy {
    opacity: 1;
    pointer-events: auto;
}

.code-box pre {
    margin: 0;
    padding: 0 18px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.25s ease, padding 0.3s ease;
}

.code-box.expanded pre {
    max-height: var(--code-max-height);
    padding: 16px 18px;
    opacity: 1;
    overflow: auto;
}

.code-box code {
    display: block;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--code-text);
    white-space: pre;
    counter-reset: line;
}

/* 代码行（行号由 CSS 计数器生成） */
.code-line {
    display: block;
    counter-increment: line;
}

.code-line::before {
    content: counter(line);
    position: sticky;
    left: 0;
    display: inline-block;
    width: 2.2em;
    padding-right: 12px;
    margin-right: 12px;
    text-align: right;
    color: var(--text-faint);
    background-color: var(--code-bg);
    border-right: 1px solid var(--border);
    user-select: none;
}

/* ============ 平板优化（宽断点在前，窄断点在后，保证覆盖顺序） ============ */
@media (max-width: 900px) {
    .hero { padding: 90px 0 80px; }

    .hero-title { font-size: 42px; }

    .section { padding: 64px 0; }

    .ui-demo { padding: 20px; }

    .nav { gap: 20px; }
}

/* ============ 手机适配 ============ */
@media (max-width: 640px) {
    .container { padding: 0 16px; }

    .header-inner {
        height: auto;
        min-height: 56px;
        padding: 10px 0;
    }

    /* 单行优先：隐藏 Logo 文字、逐级压缩，尽量不换行 */
    .logo-text { display: none; }

    /* 手机端 Logo 图标额外右移 */
    .logo { margin-left: 20px; }

    .nav { gap: 14px; }

    .nav a { font-size: 13px; }

    .nav-logo { height: 15px; }

    .theme-select {
        font-size: 12px;
        padding: 5px 24px 5px 10px;
        background-position: right 8px center;
    }

    .hero { padding: 70px 0 60px; }

    .hero-title {
        font-size: 34px;
        letter-spacing: 2px;
    }

    .hero-en {
        font-size: 16px;
        letter-spacing: 2px;
    }

    .section { padding: 56px 0; }

    .section-title { font-size: 22px; }

    .section-text { font-size: 15px; }

    .modal-box {
        width: auto;
        max-width: 300px;
        margin: 0 20px;
    }

    .ui-head { padding: 40px 0 32px; }

    .ui-head h1 {
        font-size: 26px;
        letter-spacing: 2px;
    }

    .ui-head p { font-size: 13px; }

    .ui-block h2 { font-size: 20px; }

    .ui-demo { padding: 16px; }
}

/* 极窄屏兜底：进一步压缩导航间距 */
@media (max-width: 400px) {
    .nav { gap: 10px; }

    .theme-select { font-size: 11px; padding: 4px 20px 4px 8px; }
}

/* 320px 级设备：极限压缩，保证单行不溢出 */
@media (max-width: 360px) {
    .nav { gap: 6px; }

    .nav-logo { height: 13px; }

    .theme-select {
        font-size: 11px;
        padding: 4px 18px 4px 6px;
        background-position: right 6px center;
    }
}

/* 尊重系统减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    body {
        transition: none;
    }

    .hero .container {
        animation: none;
    }

    html.js .section {
        opacity: 1;
        transform: none;
        transition: none;
    }

    .modal-mask,
    .modal-box,
    .btn,
    .nav a,
    .nav a::after,
    .modal-close,
    .switch,
    .switch::after,
    .toast,
    .progress-bar,
    .progress-thumb,
    .site-card {
        transition: none;
    }
}
