/* ============================================================
   Creawith Unified Authentication Design System
   路径：assets/css/creawith-auth.css
   说明：数字画廊美学架构，融合 72px 顶栏、48px 控件模数、微透面板与防抖基线
   ============================================================ */

/* --- 1. 核心变量与 Creawith 黑白画廊设计语言 --- */
:root {
    --cw-auth-bg: #ffffff;
    --cw-auth-surface: rgba(255, 255, 255, 0.96);
    --cw-auth-surface-solid: #ffffff;
    --cw-auth-text-main: #111111;
    --cw-auth-text-muted: #666666;
    --cw-auth-border: #e5e5e5;
    --cw-auth-border-hover: #111111;

    /* 画廊主按键：纯黑调性 */
    --cw-auth-btn-bg: #111111;
    --cw-auth-btn-bg-hover: #222222;
    --cw-auth-btn-text: #ffffff;

    /* 焦点与链接专用色：冰极冷青 (#72D5C8) */
    --cw-auth-accent: #72d5c8;
    --cw-auth-accent-light: rgba(114, 213, 200, 0.18);

    /* 状态与反馈 */
    --cw-auth-error: #dc2626;
    --cw-auth-success: #16a34a;

    /* 圆角与阴影（统一收拢至 8px） */
    --cw-auth-radius: 8px;
    --cw-auth-radius-sm: 8px;
    --cw-auth-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.03);

    /* 动效范围控制：精确属性过滤，禁止 transition: all */
    --cw-auth-transition-fast: background-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                               border-color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                               box-shadow 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                               color 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                               opacity 0.2s cubic-bezier(0.16, 1, 0.3, 1),
                               transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);

    /* 自由背景板默认空变量 */
    --cw-auth-bg-cover: none;
}

/* --- 2. 状态基线与显隐保护 --- */
.cw-auth-view[hidden] {
    display: none !important;
}

.cw-auth-dialog:not([open]) {
    display: none;
}

/* --- 3. 弹窗模式外壳 (Dialog Shell) --- */
.cw-auth-dialog {
    padding: 0;
    border: none;
    background: transparent;
    max-width: min(440px, 92vw);
    max-height: calc(100dvh - 24px);
    width: 100%;
    margin: auto;
    position: fixed;
    inset: 0;
    z-index: 1000;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.cw-auth-dialog::backdrop {
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    animation: cwAuthFadeIn 0.2s ease-out;
}

.cw-auth-dialog[open] {
    animation: cwAuthScaleUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.cw-auth-dialog__surface {
    position: relative;
    background: var(--cw-auth-surface-solid);
    border: 1px solid var(--cw-auth-border);
    border-radius: var(--cw-auth-radius);
    box-shadow: var(--cw-auth-shadow);
    padding: 32px 28px;
    box-sizing: border-box;
}

.cw-auth-dialog__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: transparent;
    color: var(--cw-auth-text-muted);
    font-size: 22px;
    line-height: 1;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--cw-auth-transition-fast);
    z-index: 2;
}

.cw-auth-dialog__close:hover {
    background: var(--cw-auth-border);
    color: var(--cw-auth-text-main);
}

/* --- 4. 独立页面模式外壳 (Standalone Page Shell) & 72px Header 视口联动 --- */
.cw-auth-document {
    margin-top: 0 !important;
    min-height: 100%;
    background: #f3f3f3;
}

body.cw-auth-standalone {
    min-width: 320px;
    min-height: 100svh;
    margin: 0;
    color: var(--cw-auth-text-main);
    background: #f3f3f3;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

body.cw-auth-standalone #wpadminbar {
    display: none !important;
}

/* Auth 专用 Header：固定 72px 紧凑高度 */
.cw-auth-page__header.creawith-header {
    position: fixed;
    inset: 0 0 auto;
    height:72px;
    z-index: 20;
    box-sizing: border-box;
    background: #ffffff;
    border-bottom: 1px solid var(--cw-auth-border);
}

.cw-auth-page__header .cw-container {
    position: relative;
    width: 100%;
    height: 100%;
}

.cw-auth-page__header .header-left {
    position: absolute;
    top: 50%;
    left: 40px;
    display: flex;
    align-items: center;
    transform: translateY(-50%);
}

.cw-auth-page__header .site-logo {
    color: #111111;
    font-size: 22px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0;
    text-decoration: none;
    transition: var(--cw-auth-transition-fast);
}

.cw-auth-page__header .site-logo:hover {
    opacity: 0.75;
    text-decoration: none;
}

.cw-auth-page__header .site-logo:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 6px;
}

/* 全屏视口背景板：同步 72px 顶部扣减留白 */
.cw-auth-page__main {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(72px, env(safe-area-inset-top)) 24px
             max(40px, env(safe-area-inset-bottom));
    box-sizing: border-box;
    position: relative;
    isolation: isolate;
    overflow: hidden;
    background-color: #f3f3f3;
    background-image: var(--cw-auth-bg-cover);
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 背景图遮罩：保证任意背景图上的文字与面板可读性 */
.cw-auth-page__main--has-media::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: rgba(10, 10, 10, 0.28);
}

/* 面板 Shell：保留 96% 穿透呼吸感底色 */
.cw-auth-page__shell {
    width: 100%;
    max-width: 440px;
    max-height: calc(100svh - 112px); /* 对应 72px Header + 40px 底部 Padding */
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--cw-auth-surface);
    border: 1px solid var(--cw-auth-border);
    border-radius: var(--cw-auth-radius);
    box-shadow: var(--cw-auth-shadow);
    padding: 36px 32px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    scrollbar-gutter: stable;
}

/* --- 5. 认证面板内部排版与视图规范 --- */
.cw-auth-panel {
    width: 100%;
    text-align: left;
}

.cw-auth-panel * {
    box-sizing: border-box;
}

.cw-auth-view {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cw-auth-panel__header {
    text-align: center;
    margin-bottom: 24px;
}

/* 弹窗标题避让关闭按钮 */
.cw-auth-dialog .cw-auth-panel__header {
    padding-inline: 44px;
}

.cw-auth-panel__brand {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--cw-auth-text-main);
    margin: 0 0 6px 0;
}

.cw-auth-panel__title {
    font-size: 22px;
    font-weight: 700;
    color: var(--cw-auth-text-main);
    margin: 0 0 6px 0;
    line-height: 1.3;
}

.cw-auth-panel__intro {
    font-size: 13.5px;
    color: var(--cw-auth-text-muted);
    margin: 0;
    line-height: 1.5;
}

/* 找回密码 / 设置新密码 / 邮箱验证视图底部的居中辅助链接 */
a.cw-auth-panel__intro {
    display: block;
    text-align: center;
    color: var(--cw-auth-text-muted);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 500;
    margin-top: 4px;
    transition: var(--cw-auth-transition-fast);
}

a.cw-auth-panel__intro:hover {
    color: var(--cw-auth-text-main);
    text-decoration: none;
}

a.cw-auth-panel__intro:focus-visible {
    outline: 2px solid var(--cw-auth-accent);
    outline-offset: 4px;
    border-radius: 2px;
}

/* --- 6. 分段选项卡 (Tab Segment) --- */
.cw-auth-tabs {
    display: flex;
    background: #f5f5f5;
    padding: 3px;
    border-radius: var(--cw-auth-radius-sm);
    margin-bottom: 22px;
    gap: 2px;
}

.cw-auth-tabs__button {
    flex: 1;
    height: 38px;
    padding: 0 16px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--cw-auth-text-muted);
    background: transparent;
    border: none;
    border-radius: calc(var(--cw-auth-radius-sm) - 2px);
    cursor: pointer;
    transition: var(--cw-auth-transition-fast);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cw-auth-tabs__button:hover {
    color: var(--cw-auth-text-main);
}

.cw-auth-tabs__button[aria-selected="true"] {
    background: var(--cw-auth-surface-solid);
    color: var(--cw-auth-text-main);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.cw-auth-tabs__button:focus-visible {
    outline: 2px solid var(--cw-auth-accent);
    outline-offset: 1px;
}

/* --- 7. 表单控件与 Field (统一 48px 模数) --- */
.cw-auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cw-auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cw-auth-field label {
    font-size: 13px;
    font-weight: 600;
    color: var(--cw-auth-text-main);
}

.cw-auth-field input[type="text"],
.cw-auth-field input[type="email"],
.cw-auth-field input[type="password"] {
    width: 100%;
    height: 48px; /* 统一 48px 高度 */
    padding: 0 14px;
    font-size: 14px;
    color: var(--cw-auth-text-main);
    background: var(--cw-auth-bg);
    border: 1px solid var(--cw-auth-border);
    border-radius: var(--cw-auth-radius-sm);
    box-sizing: border-box;
    transition: var(--cw-auth-transition-fast);
    outline: none;
}

.cw-auth-field input:hover {
    border-color: var(--cw-auth-border-hover);
}

/* 冰极冷青折射高光 Focus 聚焦状态 */
.cw-auth-field input:focus {
    border-color: var(--cw-auth-accent);
    box-shadow: 0 0 0 3px var(--cw-auth-accent-light);
}

.cw-auth-field small {
    font-size: 12px;
    color: var(--cw-auth-text-muted);
    line-height: 1.4;
}

/* 彻底解决 Chrome / Safari 原生自动填充变蓝色/黄色块的问题 */
.cw-auth-field input:-webkit-autofill,
.cw-auth-field input:-webkit-autofill:hover,
.cw-auth-field input:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--cw-auth-text-main) !important;
    -webkit-box-shadow: 0 0 0px 1000px var(--cw-auth-bg) inset !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* --- 8. 表单辅助组件 (多行解耦排版) --- */
.cw-auth-form__options {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px 0;
    font-size: 13px;
}

.cw-auth-form__options a {
    color: var(--cw-auth-text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: var(--cw-auth-transition-fast);
}

.cw-auth-form__options a:hover {
    color: var(--cw-auth-text-main);
    text-decoration: none;
}

.cw-auth-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--cw-auth-text-muted);
    cursor: pointer;
    user-select: none;
    transition: var(--cw-auth-transition-fast);
}

.cw-auth-check:hover {
    color: var(--cw-auth-text-main);
}

.cw-auth-check input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--cw-auth-btn-bg);
    border-radius: 4px;
    cursor: pointer;
}

/* 独立占一行的密码显隐开关 */
.cw-auth-password-toggle {
    width: 100%;
    margin-top: -2px;
}

/* --- 9. Turnstile 容器防抖位 --- */
.cw-auth-turnstile {
    min-height: 65px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 2px 0;
}

/* --- 10. 状态提示反馈 (24px 预留防抖) --- */
.cw-auth-status {
    min-height: 24px; /* 升级至 24px 彻底消除像素级防抖 */
    margin: 0;
    font-size: 13px;
    line-height: 1.4;
    text-align: center;
    color: var(--cw-auth-error);
    transition: var(--cw-auth-transition-fast);
    word-break: break-word;
}

/* 空状态占位防跳动 */
.cw-auth-status:empty {
    visibility: hidden;
}

.cw-auth-status.is-success {
    color: var(--cw-auth-success);
}

/* --- 11. 提交按钮与 Loading 动态控制 (48px 高度) --- */
.cw-auth-submit {
    width: 100%;
    height: 48px; /* 统一 48px 高度 */
    background: var(--cw-auth-btn-bg);
    color: var(--cw-auth-btn-text);
    font-size: 14.5px;
    font-weight: 600;
    border: none;
    border-radius: var(--cw-auth-radius-sm);
    cursor: pointer;
    transition: var(--cw-auth-transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.cw-auth-submit:hover:not(:disabled) {
    background: var(--cw-auth-btn-bg-hover);
    box-shadow: 0 0 12px var(--cw-auth-accent-light);
}

.cw-auth-submit:active:not(:disabled) {
    transform: scale(0.99);
}

.cw-auth-submit:disabled,
.cw-auth-form[aria-busy="true"] .cw-auth-submit,
.cw-auth-tabs__button:disabled {
    opacity: 0.65;
    cursor: wait !important;
}

/* 键盘焦点环无障碍支持 */
.cw-auth-dialog__close:focus-visible,
.cw-auth-submit:focus-visible,
.cw-auth-form__options a:focus-visible {
    outline: 2px solid var(--cw-auth-accent);
    outline-offset: 2px;
}

/* --- 12. 减弱动画模式 (prefers-reduced-motion) --- */
@media (prefers-reduced-motion: reduce) {
    .cw-auth-dialog,
    .cw-auth-dialog::backdrop,
    .cw-auth-dialog * {
        animation: none !important;
        transition: none !important;
    }
}

/* --- 13. Keyframes 帧动画 --- */
@keyframes cwAuthScaleUp {
    from {
        opacity: 0;
        transform: scale(0.96) translateY(8px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes cwAuthFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- 14. 移动端响应式适配 --- */
@media (max-width: 480px) {
    .cw-auth-dialog__surface,
    .cw-auth-page__shell {
        padding: 24px 20px;
        border-radius: 8px;
    }

    .cw-auth-tabs__button {
        height: 44px;
    }

    .cw-auth-panel__title {
        font-size: 20px;
    }

    .cw-auth-page__main {
        align-items: flex-start;
        padding: max(72px, env(safe-area-inset-top)) 12px
                 max(20px, env(safe-area-inset-bottom));
    }

    .cw-auth-page__header .header-left {
        left: max(20px, env(safe-area-inset-left));
    }

    .cw-auth-page__header .site-logo {
        font-size: 20px;
    }

    .cw-auth-page__shell {
        max-height: none;
    }
}