/**
 * COLIN Blog - Common CSS
 * Shared styles across all pages
 */

/* ===== CSS 变量 ===== */
:root {
    /* 浅色模式 */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --bg-card: #ffffff;
    --text-primary: #000000;
    --text-secondary: #666666;
    --accent: #000000;
    --accent-hover: #333333;
    --border: #e5e5e5;
    --button-bg-dark: #000000;
    --button-text-dark: #ffffff;
    --success: #27ae60;
    --warning: #f39c12;
    --error: #e74c3c;
    --info: #3498db;
}

/* 深色模式 */
[data-theme="dark"] {
    --bg-primary: #0a0a0a;
    --bg-secondary: #141414;
    --bg-card: #1a1a1a;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --accent: #ffffff;
    --accent-hover: #e0e0e0;
    --border: #2a2a2a;
    --button-bg-dark: #ffffff;
    --button-text-dark: #000000;
}

/* ===== 全局重置 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ===== 导航栏样式 ===== */
.nav-header {
    background: rgba(255, 255, 255, 0.98);
    padding: 1rem 2rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    transition: background-color 0.3s ease;
}

[data-theme="dark"] .nav-header {
    background: rgba(10, 10, 10, 0.98);
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-logo {
    color: #000000;
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: bold;
    font-family: Georgia, serif;
    transition: color 0.3s ease;
}

[data-theme="dark"] .nav-logo {
    color: #ffffff;
}

.nav-links {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.nav-link {
    color: #000000;
    text-decoration: none;
    font-size: 0.95rem;
    transition: color 0.3s ease;
    position: relative;
}

[data-theme="dark"] .nav-link {
    color: #ffffff;
}

.nav-link:hover {
    color: var(--text-secondary);
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--accent);
    transition: width 0.3s ease;
}

.nav-link:hover::after {
    width: 100%;
}

/* ===== 主题切换按钮 ===== */
.theme-switcher {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.theme-switcher:hover {
    background: var(--accent);
    border-color: var(--accent);
    transform: rotate(180deg);
    color: var(--button-text-dark);
}

.theme-switcher:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== 语言切换按钮 ===== */
.lang-switcher {
    display: flex;
    gap: 0.5rem;
}

.lang-btn {
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--border);
    background: var(--bg-card);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.lang-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.lang-btn.active {
    background: var(--accent);
    color: var(--button-text-dark);
    border-color: var(--accent);
}

.lang-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== 返回顶部按钮 ===== */
.back-to-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background: var(--button-bg-dark);
    color: var(--button-text-dark);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-to-top.visible {
    opacity: 1;
    visibility: visible;
}

.back-to-top.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px);
}

.back-to-top:hover {
    background: var(--accent-hover);
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.back-to-top:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== 可访问性辅助类 ===== */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border-width: 0 !important;
}

/* ===== 焦点可见性 ===== */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== 跳过导航链接 ===== */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--button-bg-dark);
    color: var(--button-text-dark);
    padding: 8px 16px;
    z-index: 10000;
    transition: top 0.3s ease;
    text-decoration: none;
    font-weight: 600;
}

.skip-link:focus {
    top: 0;
}

/* ===== 按钮通用样式 ===== */
button {
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* ===== 链接通用样式 ===== */
a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

a:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ===== 响应式设计 ===== */
@media (max-width: 768px) {
    .nav-header {
        padding: 1rem;
    }

    .nav-content {
        flex-direction: row;
        gap: 1rem;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
        gap: 1rem;
    }

    .nav-link {
        font-size: 0.85rem;
    }

    .back-to-top {
        width: 40px;
        height: 40px;
        font-size: 20px;
        bottom: 20px;
        right: 20px;
    }

    .lang-btn {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }

    .theme-switcher {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ===== 动画效果 ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== 打印样式 ===== */
@media print {
    .back-to-top,
    .theme-switcher,
    .lang-switcher,
    .skip-link {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }
}

/* ===== 深色模式适配 ===== */
[data-theme="dark"] a:hover {
    color: rgba(255, 255, 255, 0.7);
}

[data-theme="dark"] .nav-link::after {
    background: var(--text-primary);
}
