/*!
 * CookieConsent for Typecho — 与博客风格一致的 Cookie 同意横幅
 * 设计语言：圆角卡片 / 毛玻璃 / 柔和投影 / 轻微上浮动画
 */

/* --------------------------------------------------------------------------
 * 1. 设计变量
 * ----------------------------------------------------------------------- */

.cc-root {
    /* 强调色：优先读取 Joe 等主题的 --theme，其次 --main / --accent */
    --cc-accent: var(--theme, var(--main, var(--accent, #425aef)));

    --cc-surface: rgba(255, 255, 255, 0.82);
    --cc-surface-solid: #ffffff;
    --cc-surface-strong: rgba(255, 255, 255, 0.96);
    --cc-fg: #1c2333;
    --cc-muted: #6b7488;
    --cc-border: rgba(24, 34, 56, 0.09);
    --cc-line: rgba(24, 34, 56, 0.07);
    --cc-chip: rgba(24, 34, 56, 0.045);
    --cc-track: rgba(24, 34, 56, 0.16);
    --cc-shadow: 0 24px 60px -22px rgba(17, 26, 48, 0.38), 0 6px 18px -10px rgba(17, 26, 48, 0.16);
    --cc-radius: 20px;

    --cc-accent-soft: rgba(66, 90, 239, 0.1);

    color-scheme: light;
    font-family: inherit;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    line-height: 1.5;
    color: var(--cc-fg);
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .cc-root {
        --cc-accent-soft: color-mix(in srgb, var(--cc-accent) 11%, transparent);
    }
}

/* 深色模式：由脚本根据页面实际明暗切换 .cc-dark（不盲目跟随系统） */
.cc-root.cc-dark {
    color-scheme: dark;
    --cc-surface: rgba(26, 31, 44, 0.84);
    --cc-surface-solid: #1a1f2c;
    --cc-surface-strong: rgba(26, 31, 44, 0.97);
    --cc-fg: #e9edf7;
    --cc-muted: #98a2b8;
    --cc-border: rgba(255, 255, 255, 0.1);
    --cc-line: rgba(255, 255, 255, 0.075);
    --cc-chip: rgba(255, 255, 255, 0.06);
    --cc-track: rgba(255, 255, 255, 0.22);
    --cc-shadow: 0 26px 70px -24px rgba(0, 0, 0, 0.8), 0 6px 20px -12px rgba(0, 0, 0, 0.6);
}

/* --------------------------------------------------------------------------
 * 2. 横幅
 * ----------------------------------------------------------------------- */

.cc-banner {
    --cc-x: -50%;
    --cc-enter-y: 22px;

    position: fixed;
    z-index: 99990;
    box-sizing: border-box;
    width: min(680px, calc(100vw - 32px));
    padding: 20px 22px 18px;
    border: 1px solid var(--cc-border);
    border-radius: var(--cc-radius);
    background: var(--cc-surface);
    box-shadow: var(--cc-shadow);
    -webkit-backdrop-filter: blur(22px) saturate(180%);
    backdrop-filter: blur(22px) saturate(180%);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translate(var(--cc-x), var(--cc-enter-y));
    transition: opacity 0.45s cubic-bezier(0.22, 1, 0.36, 1), transform 0.55s cubic-bezier(0.22, 1, 0.36, 1),
        visibility 0.45s;
}

.cc-root[data-position="bottom"] .cc-banner {
    left: 50%;
    bottom: 24px;
}

.cc-root[data-position="bottom-left"] .cc-banner {
    --cc-x: 0px;
    left: 24px;
    bottom: 24px;
}

.cc-root[data-position="bottom-right"] .cc-banner {
    --cc-x: 0px;
    left: auto;
    right: 24px;
    bottom: 24px;
}

.cc-root[data-position="top"] .cc-banner {
    --cc-enter-y: -22px;
    left: 50%;
    top: 20px;
    bottom: auto;
    width: min(920px, calc(100vw - 32px));
}

.cc-banner.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translate(var(--cc-x), 0);
}

/* 已同意时彻底隐藏，避免检查 Cookie 与显示横幅之间闪一下 */
.cc-consented .cc-banner {
    display: none !important;
}

/* 偏好面板打开时锁定背景滚动 */
html.cc-modal-open {
    overflow: hidden !important;
}

.cc-banner-glow {
    position: absolute;
    top: -70px;
    right: -40px;
    width: 220px;
    height: 200px;
    pointer-events: none;
    border-radius: 50%;
    background: radial-gradient(circle, var(--cc-accent-soft) 0%, transparent 68%);
    opacity: 0.9;
}

.cc-banner-head {
    position: relative;
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.cc-icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: var(--cc-accent-soft);
    color: var(--cc-accent);
    box-shadow: inset 0 0 0 1px var(--cc-border);
}

.cc-icon-sm {
    width: 38px;
    height: 38px;
    border-radius: 12px;
}

.cc-text {
    min-width: 0;
    padding-top: 1px;
}

.cc-title {
    margin: 0;
    font-family: inherit;
    font-size: 15px;
    font-weight: 650;
    letter-spacing: 0.01em;
    line-height: 1.45;
    color: var(--cc-fg);
}

.cc-desc {
    margin: 5px 0 0;
    font-family: inherit;
    font-size: 13px;
    font-weight: 400;
    line-height: 1.72;
    color: var(--cc-muted);
}

.cc-link {
    color: var(--cc-accent);
    text-decoration: none;
    border-bottom: 1px dashed color-mix(in srgb, var(--cc-accent) 45%, transparent);
    transition: border-color 0.2s, opacity 0.2s;
}

.cc-link:hover {
    border-bottom-color: var(--cc-accent);
    opacity: 0.85;
}

.cc-banner-foot {
    position: relative;
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    align-items: center;
    margin-top: 16px;
}

/* --------------------------------------------------------------------------
 * 3. 按钮
 * ----------------------------------------------------------------------- */

.cc-btn {
    appearance: none;
    -webkit-appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 38px;
    padding: 0 17px;
    border: 1px solid transparent;
    border-radius: 11px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.22s ease, background-color 0.22s ease, border-color 0.22s ease,
        color 0.22s ease;
}

.cc-btn:active {
    transform: translateY(1px);
}

.cc-btn-primary {
    background: var(--cc-accent);
    color: #fff;
    box-shadow: 0 10px 22px -10px var(--cc-accent);
}

@supports (background: color-mix(in srgb, red 10%, transparent)) {
    .cc-btn-primary {
        background: linear-gradient(
            135deg,
            var(--cc-accent) 0%,
            color-mix(in srgb, var(--cc-accent) 72%, #8b5cf6) 100%
        );
    }
}

.cc-btn-primary:hover {
    box-shadow: 0 14px 26px -10px var(--cc-accent);
    transform: translateY(-1px);
}

.cc-btn-ghost {
    background: var(--cc-chip);
    border-color: var(--cc-border);
    color: var(--cc-fg);
}

.cc-btn-ghost:hover {
    background: var(--cc-accent-soft);
    border-color: color-mix(in srgb, var(--cc-accent) 32%, var(--cc-border));
    color: var(--cc-accent);
}

.cc-btn-quiet {
    background: transparent;
    color: var(--cc-muted);
    padding: 0 10px;
    margin-right: auto;
}

.cc-btn-quiet:hover {
    color: var(--cc-accent);
}

.cc-btn:focus-visible,
.cc-close:focus-visible,
.cc-reopen:focus-visible {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
}

/* --------------------------------------------------------------------------
 * 4. 偏好面板
 * ----------------------------------------------------------------------- */

.cc-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(14, 20, 34, 0.44);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    opacity: 0;
    transition: opacity 0.26s ease;
}

.cc-overlay[hidden] {
    display: none !important;
}

.cc-overlay.is-visible {
    opacity: 1;
}

.cc-modal {
    display: flex;
    flex-direction: column;
    width: min(560px, 100%);
    max-height: min(86vh, 720px);
    border: 1px solid var(--cc-border);
    border-radius: 22px;
    background: var(--cc-surface-strong);
    box-shadow: 0 40px 90px -24px rgba(10, 16, 32, 0.55);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    backdrop-filter: blur(28px) saturate(180%);
    overflow: hidden;
    transform: translateY(14px) scale(0.985);
    transition: transform 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

.cc-overlay.is-visible .cc-modal {
    transform: none;
}

.cc-modal-head {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    padding: 22px 22px 14px;
}

.cc-modal-heading {
    flex: 1;
    min-width: 0;
    padding-top: 1px;
}

.cc-modal-title {
    margin: 0;
    font-family: inherit;
    font-size: 17px;
    font-weight: 650;
    line-height: 1.4;
    color: var(--cc-fg);
}

.cc-modal-sub {
    margin: 4px 0 0;
    font-family: inherit;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--cc-muted);
}

.cc-close {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin: -2px -4px 0 0;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--cc-muted);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.cc-close:hover {
    background: var(--cc-chip);
    color: var(--cc-fg);
}

.cc-modal-body {
    flex: 1;
    padding: 0 22px 4px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.cc-cat {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 15px 0;
    border-top: 1px solid var(--cc-line);
}

.cc-cat:first-child {
    border-top: 0;
}

.cc-cat-text {
    flex: 1;
    min-width: 0;
}

.cc-cat-name {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.5;
    color: var(--cc-fg);
}

.cc-cat-desc {
    margin: 4px 0 0;
    font-size: 12.5px;
    line-height: 1.68;
    color: var(--cc-muted);
}

.cc-tag {
    display: inline-flex;
    align-items: center;
    height: 18px;
    padding: 0 7px;
    border-radius: 999px;
    background: var(--cc-accent-soft);
    color: var(--cc-accent);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.cc-switch {
    position: relative;
    flex: 0 0 auto;
    width: 44px;
    height: 26px;
    margin-top: 1px;
    cursor: pointer;
}

.cc-switch input {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.cc-switch-track {
    position: absolute;
    inset: 0;
    border-radius: 999px;
    background: var(--cc-track);
    box-shadow: inset 0 0 0 1px var(--cc-border);
    transition: background-color 0.22s ease;
}

.cc-switch-dot {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(12, 20, 40, 0.28);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

.cc-switch input:checked + .cc-switch-track {
    background: var(--cc-accent);
}

.cc-switch input:checked + .cc-switch-track .cc-switch-dot {
    transform: translateX(18px);
}

.cc-switch input:focus-visible + .cc-switch-track {
    outline: 2px solid var(--cc-accent);
    outline-offset: 2px;
}

.cc-switch.is-locked {
    cursor: not-allowed;
}

.cc-switch.is-locked .cc-switch-track {
    background: var(--cc-accent);
    opacity: 0.55;
}

.cc-switch.is-locked .cc-switch-dot {
    transform: translateX(18px);
}

.cc-modal-foot {
    display: flex;
    gap: 12px;
    align-items: center;
    justify-content: space-between;
    padding: 14px 22px 18px;
    border-top: 1px solid var(--cc-line);
    background: var(--cc-chip);
}

.cc-foot-note {
    margin: 0;
    max-width: 230px;
    font-size: 11.5px;
    line-height: 1.55;
    color: var(--cc-muted);
}

.cc-buttons {
    display: flex;
    flex: 0 0 auto;
    gap: 8px;
}

/* --------------------------------------------------------------------------
 * 5. 悬浮重开按钮
 * ----------------------------------------------------------------------- */

.cc-reopen {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 99980;
    display: grid;
    box-sizing: border-box;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    border: 1px solid var(--cc-border);
    border-radius: 50%;
    background: var(--cc-surface);
    color: var(--cc-muted);
    box-shadow: 0 10px 26px -12px rgba(12, 20, 40, 0.4);
    -webkit-backdrop-filter: blur(14px) saturate(160%);
    backdrop-filter: blur(14px) saturate(160%);
    cursor: pointer;
    opacity: 0.75;
    transition: opacity 0.22s, transform 0.22s, color 0.22s;
}

.cc-reopen[hidden] {
    display: none !important;
}

.cc-reopen:hover {
    opacity: 1;
    color: var(--cc-accent);
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
 * 6. 外观变体
 * ----------------------------------------------------------------------- */

.cc-root[data-style="solid"] .cc-banner,
.cc-root[data-style="solid"] .cc-reopen {
    background: var(--cc-surface-solid);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.cc-root[data-style="solid"] .cc-banner {
    box-shadow: 0 20px 50px -24px rgba(17, 26, 48, 0.35), 0 4px 14px -8px rgba(17, 26, 48, 0.14);
}

.cc-root[data-style="minimal"] .cc-banner {
    --cc-radius: 14px;
    background: var(--cc-surface-solid);
    box-shadow: none;
    border: 1.5px solid var(--cc-border);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
}

.cc-root[data-style="minimal"] .cc-banner-glow,
.cc-root[data-style="minimal"] .cc-icon {
    display: none;
}

.cc-root[data-style="minimal"] .cc-btn-primary {
    background: var(--cc-accent);
    box-shadow: none;
}

.cc-root[data-style="minimal"] .cc-btn-primary:hover {
    box-shadow: none;
    filter: brightness(1.06);
}

.cc-root[data-style="minimal"] .cc-reopen {
    background: var(--cc-surface-solid);
    box-shadow: none;
    border-width: 1.5px;
}

/* --------------------------------------------------------------------------
 * 7. 响应式
 * ----------------------------------------------------------------------- */

@media (max-width: 640px) {
    .cc-root[data-position] .cc-banner {
        --cc-x: 0px;
        --cc-enter-y: 100%;

        left: 0;
        right: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        max-width: none;
        border-right: 0;
        border-bottom: 0;
        border-radius: 20px 20px 0 0;
        padding: 18px 18px calc(16px + env(safe-area-inset-bottom));
    }

    .cc-banner-head {
        gap: 12px;
    }

    .cc-banner-foot {
        margin-top: 14px;
        gap: 7px;
    }

    .cc-banner-foot .cc-btn {
        flex: 1 1 auto;
        padding: 0 12px;
    }

    .cc-banner-foot .cc-btn-quiet {
        flex: 0 0 auto;
        margin-right: 0;
    }

    .cc-modal {
        width: 100%;
        max-height: calc(100vh - 48px);
        border-radius: 20px;
    }

    .cc-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .cc-modal-head {
        padding: 18px 18px 12px;
    }

    .cc-modal-body {
        padding: 0 18px 2px;
    }

    .cc-modal-foot {
        padding: 12px 18px 16px;
        flex-wrap: wrap;
    }

    .cc-foot-note {
        max-width: none;
        flex: 1 1 100%;
    }

    .cc-buttons {
        width: 100%;
    }

    .cc-buttons .cc-btn {
        flex: 1;
    }

    .cc-reopen {
        left: 14px;
        bottom: calc(14px + env(safe-area-inset-bottom));
        width: 38px;
        height: 38px;
    }
}

/* --------------------------------------------------------------------------
 * 8. 动效与打印
 * ----------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    .cc-banner,
    .cc-overlay,
    .cc-modal,
    .cc-btn,
    .cc-switch-track,
    .cc-switch-dot,
    .cc-reopen {
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}

@media print {
    .cc-root {
        display: none !important;
    }
}
