/* style.css - 随机一言网站样式 */
:root {
    /* 日间主题颜色 */
    --primary-color: #1aaf5d;
    --primary-dark: #0d8f48;
    --primary-light: #e6f7ee;
    --secondary-color: #2c3e50;
    --accent-color: #9c27b0;
    --background-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-light: #adb5bd;
    --border-color: #e9ecef;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --shadow-hover: rgba(26, 175, 93, 0.15);
    --gradient-start: #f8f9fa;
    --gradient-end: #e9ecef;
    --overlay-color: rgba(255, 255, 255, 0.9);
    --toggle-bg: #e9ecef;
    --toggle-circle: #ffffff;
    --toggle-text: #6c757d;
    --toggle-sun-color: #f39c12;
    --toggle-moon-color: #34495e;
}

/* 夜间主题变量 */
.dark-theme {
    --primary-color: #20c997;
    --primary-dark: #17a589;
    --primary-light: rgba(32, 201, 151, 0.15);
    --secondary-color: #212529;
    --accent-color: #bb86fc;
    --background-color: #121212;
    --card-bg: #1e1e1e;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-light: #6c757d;
    --border-color: #2d3748;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --shadow-hover: rgba(32, 201, 151, 0.2);
    --gradient-start: #121212;
    --gradient-end: #0d0d0d;
    --overlay-color: rgba(30, 30, 30, 0.95);
    --toggle-bg: #2d3748;
    --toggle-circle: #4a5568;
    --toggle-text: #e9ecef;
    --toggle-sun-color: #f1c40f;
    --toggle-moon-color: #ecf0f1;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

html, body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', 'Noto Serif SC', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
    color: var(--text-primary);
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* 背景装饰元素 */
.bg-decoration {
    position: fixed;
    z-index: -1;
    opacity: 0.03;
    pointer-events: none;
}

.decoration-1 {
    top: 10%;
    right: 5%;
    font-size: 12rem;
    color: var(--primary-color);
}

.decoration-2 {
    bottom: 20%;
    left: 5%;
    font-size: 10rem;
    color: var(--accent-color);
    transform: rotate(-30deg);
}

.decoration-3 {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 15rem;
    color: var(--primary-color);
}

/* 容器 */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* 导航栏 */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: var(--overlay-color);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 1.2rem 0;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--text-primary);
}

.logo-icon {
    color: var(--primary-color);
    font-size: 1.8rem;
}

.logo-text {
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

/* 昼夜切换按钮 - 修正版 */
.theme-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 30px;
    background: var(--toggle-bg);
    position: relative;
    width: 70px;
    height: 34px;
}

.toggle-circle {
    position: absolute;
    width: 28px;
    height: 28px;
    background: var(--toggle-circle);
    border-radius: 50%;
    left: 3px;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}

.dark-theme .toggle-circle {
    transform: translateX(36px);
}

.toggle-icon {
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

/* 太阳图标 - 固定在左侧 */
.toggle-sun {
    position: absolute;
    left: 10px;
    color: var(--toggle-sun-color);
    z-index: 1;
}

/* 月亮图标 - 固定在右侧 */
.toggle-moon {
    position: absolute;
    right: 10px;
    color: var(--toggle-moon-color);
    z-index: 1;
}

/* 移动的图标（在圆圈内） */
.toggle-moving-icon {
    position: relative;
    z-index: 3;
}

/* API文档按钮 */
.api-btn {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 0.7rem 1.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(26, 175, 93, 0.25);
}

.api-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(26, 175, 93, 0.35);
}

/* 主内容区 - 修正居中问题 */
main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 100px 0 60px;
    position: relative;
}

.main-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.hero-card {
    background: var(--card-bg);
    border-radius: 24px;
    padding: 3.5rem;
    width: 100%;
    max-width: 1200px;
    position: relative;
    box-shadow: 0 20px 60px var(--shadow-color);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin: 0 auto;
}

.hero-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 5px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
}

.card-decoration {
    position: absolute;
    font-size: 8rem;
    color: var(--primary-color);
    opacity: 0.05;
    z-index: 0;
}

.decoration-left {
    top: 20px;
    left: 20px;
}

.decoration-right {
    bottom: 20px;
    right: 20px;
    transform: rotate(180deg);
}

/* 标题区域 - 优化后的居中效果 */
.title-section {
    text-align: center;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.main-title {
    font-size: 2.8rem;
    font-weight: 800;
    margin-bottom: 0.8rem;
    color: var(--text-primary);
    position: relative;
    display: inline-block;
}

.main-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--accent-color));
    border-radius: 2px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.2rem;
    max-width: 500px;
    line-height: 1.6;
    margin-top: 1.2rem;
}

/* 句子展示区 */
.sentence-container {
    position: relative;
    z-index: 1;
    min-height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2rem 0;
    padding: 2.5rem;
    background: var(--primary-light);
    border-radius: 18px;
    border-left: 5px solid var(--primary-color);
}

.sentence {
    font-family: 'Noto Serif SC', serif;
    font-size: 2.4rem;
    line-height: 1.8;
    color: var(--text-primary);
    text-align: center;
    font-weight: 500;
    position: relative;
    padding: 0 1rem;
}

.sentence::before, .sentence::after {
    content: '"';
    font-size: 3rem;
    color: var(--primary-color);
    opacity: 0.5;
    position: absolute;
    font-family: 'Noto Serif SC', serif;
}

.sentence::before {
    top: -15px;
    left: -10px;
}

.sentence::after {
    bottom: -25px;
    right: -10px;
}

/* 标签区 - 修改为单个标签 */
.tags-container {
    display: flex;
    justify-content: center;
    margin: 2.5rem 0;
}

.tag {
    background: var(--card-bg);
    color: var(--primary-color);
    padding: 0.6rem 1.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid var(--primary-color);
    transition: all 0.3s ease;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.tag:hover {
    background: var(--primary-color);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px var(--shadow-hover);
}

/* 按钮组 */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 3rem;
}

.btn {
    padding: 1rem 2.5rem;
    border-radius: 30px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-width: 180px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: 0 8px 20px rgba(26, 175, 93, 0.3);
}

.btn-primary:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 25px rgba(26, 175, 93, 0.4);
}

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

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background: var(--primary-light);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px var(--shadow-hover);
}

.btn-icon {
    font-size: 1.1rem;
}

/* 加载动画 */
.loading {
    display: inline-block;
    width: 22px;
    height: 22px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* 页脚 */
footer {
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
    padding: 3rem 0 2rem;
    margin-top: auto;
}

.footer-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 2rem;
}

.copyright {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.footer-links {
    display: flex;
    gap: 2rem;
}

.footer-link {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-link:hover {
    color: var(--primary-color);
}

/* 响应式设计 */
@media (max-width: 992px) {
    .sentence {
        font-size: 2rem;
    }
    
    .hero-card {
        padding: 2.5rem;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 100%;
        max-width: 300px;
    }
    
    .main-title {
        font-size: 2.4rem;
    }
}

@media (max-width: 768px) {
    .navbar {
        padding: 1rem 0;
    }
    
    main {
        padding: 80px 0 40px;
    }
    
    .hero-card {
        padding: 2rem;
        margin: 0 1rem;
    }
    
    .sentence {
        font-size: 1.7rem;
    }
    
    .footer-container {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 1rem;
    }
    
    .bg-decoration {
        display: none;
    }
    
    .main-title {
        font-size: 2rem;
    }
    
    .subtitle {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .sentence {
        font-size: 1.5rem;
    }
    
    .hero-card {
        padding: 1.5rem;
    }
    
    .sentence-container {
        padding: 1.5rem;
    }
    
    .nav-right {
        gap: 1rem;
    }
    
    .api-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.85rem;
    }
    
    .main-title {
        font-size: 1.8rem;
    }
    
    .subtitle {
        font-size: 0.9rem;
    }
}

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

.fade-in-up {
    animation: fadeInUp 0.6s ease forwards;
}

/* 滚动条美化 */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--background-color);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* 提示消息 */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1001;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.4s ease, opacity 0.4s ease;
    border-left: 4px solid var(--primary-color);
    max-width: 350px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon {
    font-size: 1.3rem;
    color: var(--primary-color);
}

/* 统计数据 */
.stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Canvas 圆角矩形支持 */
CanvasRenderingContext2D.prototype.roundRect = function(x, y, width, height, radius) {
    if (width < 2 * radius) radius = width / 2;
    if (height < 2 * radius) radius = height / 2;
    
    this.beginPath();
    this.moveTo(x + radius, y);
    this.arcTo(x + width, y, x + width, y + height, radius);
    this.arcTo(x + width, y + height, x, y + height, radius);
    this.arcTo(x, y + height, x, y, radius);
    this.arcTo(x, y, x + width, y, radius);
    this.closePath();
    
    return this;
};