/* ============================================================
   大呲花AI资源分享 — 前台样式
   设计基调：暖白纸感 / 细线卡片 / 单一暖橙强调色
   ============================================================ */

:root {
    --bg: #f7f6f3;
    --surface: #ffffff;
    --ink: #16161a;
    --ink-2: #45454e;
    --muted: #85858f;
    --line: #e8e6e0;
    --line-strong: #d6d3ca;
    --accent: #dd5a2f;
    --accent-soft: #fbeee8;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(22, 22, 26, .04);
    --shadow-hover: 0 16px 36px -20px rgba(22, 22, 26, .38);
    --ease: cubic-bezier(.2, .7, .3, 1);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(1000px 420px at 50% -180px, #ffffff 0%, rgba(255, 255, 255, 0) 72%),
        var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

a {
    color: inherit;
    text-decoration: none;
}

.wrap {
    max-width: 1040px;
    margin: 0 auto;
    padding: 0 24px;
}

/* 内页（文章类）用更窄的容器，整页居中 */
.wrap-doc {
    max-width: 792px;
}

/* ---------- 顶栏 ---------- */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 22px 0 0;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .06em;
    color: var(--ink-2);
}

.brand .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.topbar .meta {
    font-size: 12px;
    color: var(--muted);
    letter-spacing: .02em;
}

/* ---------- 头部 ---------- */

.hero {
    padding: clamp(44px, 8vw, 84px) 0 clamp(34px, 5vw, 52px);
}

.hero h1 {
    margin: 0;
    font-size: clamp(30px, 5.6vw, 50px);
    font-weight: 600;
    line-height: 1.08;
    letter-spacing: -.035em;
    text-wrap: balance;
}

.hero p {
    margin: 18px 0 0;
    max-width: 36em;
    font-size: clamp(13.5px, 1.5vw, 15.5px);
    line-height: 1.8;
    color: var(--ink-2);
    text-wrap: pretty;
}

/* ---------- 章节 ---------- */

.sec {
    margin-bottom: clamp(38px, 5.5vw, 58px);
    scroll-margin-top: 64px;
}

.sec-head {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding-bottom: 14px;
    margin-bottom: 18px;
    border-bottom: 1px solid var(--line);
}

.sec-idx {
    flex: none;
    padding-top: 3px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 11px;
    font-weight: 500;
    line-height: 1.7;
    letter-spacing: .1em;
    color: var(--accent);
}

.sec-title {
    margin: 0;
    font-size: 16.5px;
    font-weight: 600;
    letter-spacing: -.012em;
}

.sec-desc {
    margin: 3px 0 0;
    font-size: 12.5px;
    color: var(--muted);
}

/* ---------- 卡片网格 ---------- */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(228px, 1fr));
    gap: 10px;
}

/* 同一分类里按类型拆开时，段与段之间留出间距 */
.grid+.grid {
    margin-top: 12px;
}

.card {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px 16px 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: transform .3s var(--ease), box-shadow .3s var(--ease),
        border-color .3s var(--ease);
    will-change: transform;
}

a.card:hover,
.card.is-button:hover {
    transform: translateY(-3px);
    border-color: var(--line-strong);
    box-shadow: var(--shadow-hover);
}

a.card:active,
.card.is-button:active {
    transform: translateY(-1px);
}

.card-top {
    display: flex;
    align-items: center;
    gap: 9px;
}

.icon {
    display: grid;
    place-items: center;
    flex: none;
    width: 33px;
    height: 33px;
    border-radius: 10px;
    background: var(--bg);
    border: 1px solid var(--line);
    color: var(--ink-2);
    transition: color .3s var(--ease), background-color .3s var(--ease),
        border-color .3s var(--ease);
}

.icon svg {
    width: 16px;
    height: 16px;
    display: block;
}

a.card:hover .icon,
.card.is-button:hover .icon {
    color: var(--accent);
    background: var(--accent-soft);
    border-color: #f0d6ca;
}

.badge {
    margin-left: auto;
    padding: 2px 8px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: 10.5px;
    line-height: 1.7;
    letter-spacing: .03em;
    color: var(--muted);
    white-space: nowrap;
}

.card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 14.5px;
    font-weight: 550;
    line-height: 1.45;
    letter-spacing: -.008em;
}

.card-title .label {
    display: -webkit-box;
    min-width: 0;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.45;
}

.arrow {
    flex: none;
    margin-left: auto;
    color: var(--accent);
    opacity: 0;
    transform: translate(-3px, 3px);
    transition: opacity .3s var(--ease), transform .3s var(--ease);
}

.arrow svg {
    width: 13px;
    height: 13px;
    display: block;
}

a.card:hover .arrow {
    opacity: 1;
    transform: translate(0, 0);
}

.card-desc {
    margin: -6px 0 0;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--muted);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ---------- 优惠码卡片 ---------- */

.card.is-button {
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
    outline: none;
}

.code-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg);
    border: 1px dashed var(--line-strong);
    border-radius: 10px;
    transition: background-color .3s var(--ease), border-color .3s var(--ease);
}

.card.is-button:hover .code-box {
    background: #fffaf7;
    border-color: #edc8b6;
}

.code-val {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 14.5px;
    font-weight: 600;
    letter-spacing: .12em;
    color: var(--ink);
}

.code-hint {
    flex: none;
    font-size: 10.5px;
    letter-spacing: .04em;
    color: var(--muted);
    transition: color .25s var(--ease);
}

.card.is-button.is-copied .code-hint {
    color: var(--accent);
}

/* ---------- 内页（教程） ---------- */

.back-link {
    font-size: 12px;
    color: var(--muted);
    transition: color .25s var(--ease);
}

.back-link:hover {
    color: var(--ink-2);
}

.doc {
    max-width: none;
    margin-bottom: clamp(36px, 5vw, 56px);
    padding-top: clamp(34px, 5.5vw, 60px);
}

.doc h1 {
    margin: 0;
    font-size: clamp(24px, 3.6vw, 34px);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -.03em;
}

.doc-meta {
    margin: 12px 0 0;
    font-size: 12.5px;
    color: var(--muted);
    letter-spacing: .02em;
}

.doc h2 {
    margin: clamp(30px, 4vw, 40px) 0 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
    font-size: 15.5px;
    font-weight: 600;
    letter-spacing: -.01em;
}

.doc-sub {
    margin: 0 0 14px;
    font-size: 12.5px;
    color: var(--muted);
}

.note {
    margin: 26px 0 0;
    padding: 14px 16px;
    border: 1px solid #f0dcc4;
    border-radius: 12px;
    background: #fdf7ee;
    font-size: 13px;
    line-height: 1.75;
    color: #8a5a1e;
}

.doc-list {
    margin: 0;
    padding-left: 20px;
    font-size: 13.5px;
    line-height: 1.85;
    color: var(--ink-2);
}

.doc-list li {
    margin-bottom: 10px;
}

.doc-list li:last-child {
    margin-bottom: 0;
}

.doc-list strong {
    color: var(--ink);
    font-weight: 600;
}

.codes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
    gap: 10px;
}

.codes .card-title {
    margin: 0;
}

.doc-foot {
    margin: 32px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--muted);
}

/* ---------- 页脚 ---------- */

.foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 26px 0 44px;
    border-top: 1px solid var(--line);
    font-size: 12px;
    color: var(--muted);
}

.foot .admin-link {
    padding: 3px 9px;
    border: 1px solid transparent;
    border-radius: 7px;
    transition: color .25s var(--ease), border-color .25s var(--ease);
}

.foot .admin-link:hover {
    color: var(--ink-2);
    border-color: var(--line);
}

/* ---------- 提示条 ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 34px;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 999px;
    background: #1d1d21;
    color: #fff;
    font-size: 12.5px;
    letter-spacing: .02em;
    box-shadow: 0 18px 40px -18px rgba(0, 0, 0, .55);
    opacity: 0;
    transform: translate(-50%, 14px);
    pointer-events: none;
    transition: opacity .32s var(--ease), transform .32s var(--ease);
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- 载入与入场 ---------- */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

.reveal {
    animation: rise .52s var(--ease) both;
}

.state {
    padding: 60px 0;
    text-align: center;
    font-size: 13px;
    color: var(--muted);
}

/* ---------- 响应式 ---------- */

@media (max-width: 620px) {
    .wrap {
        padding: 0 18px;
    }

    .topbar .meta {
        display: none;
    }

    .grid {
        grid-template-columns: 1fr;
    }

    .sec-head {
        gap: 12px;
    }

    .foot {
        font-size: 11.5px;
    }
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 6px;
}

@media (prefers-reduced-motion: reduce) {

    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}

/* ---------- 顶部提示 ---------- */

.hero-doclib {
    margin: 20px 0 0;
    font-size: 12.5px;
    letter-spacing: .01em;
}

.hero-doclib a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding-bottom: 2px;
    border-bottom: 1px solid rgba(221, 90, 47, .3);
    color: var(--accent);
    transition: border-color .2s var(--ease), opacity .2s var(--ease);
}

.hero-doclib a:hover {
    border-bottom-color: var(--accent);
}

.notice {
    margin: 16px 0 0;
    padding-left: 12px;
    border-left: 2px solid var(--accent);
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--muted);
}

/* ---------- 分类侧边导航 ---------- */

.layout {
    display: flex;
    align-items: flex-start;
    gap: clamp(26px, 3.6vw, 46px);
}

.layout > main {
    flex: 1;
    min-width: 0;
}

.sidenav {
    flex: 0 0 216px;
    min-width: 0;
    position: sticky;
    top: 26px;
}

.side-cap {
    margin: 0 0 10px;
    padding-left: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .14em;
    color: var(--muted);
}

.side-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    max-height: calc(100vh - 130px);
    overflow-y: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.side-list::-webkit-scrollbar {
    display: none;
}

.chip {
    border: 1px solid var(--line);
    line-height: 1.6;
    cursor: pointer;
    transition: color .22s var(--ease), border-color .22s var(--ease),
        background-color .22s var(--ease);
}

.side-list .chip {
    display: block;
    width: 100%;
    padding: 7px 12px;
    border-color: transparent;
    border-radius: 10px;
    background: transparent;
    font-size: 13px;
    text-align: left;
    color: var(--ink-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.side-list .chip:hover {
    background: #fff;
    border-color: var(--line);
    color: var(--ink);
}

.side-list .chip.on {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

/* 窄屏：侧栏回退为顶部横滑条 */
@media (max-width: 959px) {
    .layout {
        display: block;
    }

    .sidenav {
        position: sticky;
        top: 0;
        z-index: 30;
        margin: 0 -24px clamp(24px, 3.5vw, 36px);
        background: rgba(247, 246, 243, .93);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-bottom: 1px solid var(--line);
    }

    .side-cap {
        display: none;
    }

    .side-list {
        flex-direction: row;
        max-height: none;
        gap: 6px;
        padding: 9px 24px;
        overflow-y: hidden;
        overflow-x: auto;
    }

    .side-list .chip {
        display: inline-block;
        width: auto;
        flex: none;
        padding: 5px 11px;
        border-color: var(--line);
        border-radius: 999px;
        background: #fff;
        font-size: 12px;
        color: var(--muted);
        white-space: nowrap;
    }

    .side-list .chip:hover {
        background: #fff;
        border-color: var(--line-strong);
    }

    .side-list .chip.on {
        background: var(--ink);
        border-color: var(--ink);
        color: #fff;
    }

    /* 右侧渐隐，暗示还能横向滑 */
    .sidenav::after {
        content: "";
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        width: 34px;
        background: linear-gradient(to right, rgba(247, 246, 243, 0), rgba(247, 246, 243, .96));
        pointer-events: none;
    }

    .sec {
        scroll-margin-top: 64px;
    }
}

/* 桌面端锚点偏移只需少量余量 */
@media (min-width: 960px) {
    .sec {
        scroll-margin-top: 24px;
    }
}

/* 窄屏下 .wrap 内边距是 18px，横滑条与内容对齐（须置于 959px 查询之后） */
@media (max-width: 620px) {
    .sidenav {
        margin-left: -18px;
        margin-right: -18px;
    }

    .side-list {
        padding-left: 18px;
        padding-right: 18px;
    }
}

/* ---------- 无链接条目 ---------- */

.card.is-flat {
    background: #fbfaf8;
    border-style: dashed;
    box-shadow: none;
    cursor: default;
}

.card.is-flat:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--line);
}

.card.is-flat .arrow {
    display: none;
}

.card.is-flat .card-title {
    font-weight: 500;
    color: var(--ink-2);
}
