/* ============================================================
   芝麻影院 - 完整样式表
   设计风格：暗色科幻 + 毛玻璃 + 渐变光效
   响应式 + 暗色模式 + 动画
   ============================================================ */

/* ---------- CSS 变量 & 主题切换 ---------- */
:root {
    --primary: #6c5ce7;
    --primary-light: #a29bfe;
    --secondary: #fd79a8;
    --accent: #00cec9;
    --bg: #0f0f1a;
    --bg-soft: #1a1a2e;
    --bg-card: rgba(255, 255, 255, 0.06);
    --bg-glass: rgba(255, 255, 255, 0.08);
    --border-glass: rgba(255, 255, 255, 0.12);
    --text: #f0f0f5;
    --text-muted: #a0a0b8;
    --text-dark: #333;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --radius-sm: 10px;
    --transition: all 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    --font: 'PingFang SC', 'Microsoft YaHei', 'Helvetica Neue', Arial, sans-serif;
}

/* 亮色模式（自动适配） */
@media (prefers-color-scheme: light) {
    :root {
        --bg: #f5f6fa;
        --bg-soft: #ffffff;
        --bg-card: rgba(0, 0, 0, 0.04);
        --bg-glass: rgba(255, 255, 255, 0.7);
        --border-glass: rgba(0, 0, 0, 0.08);
        --text: #2d3436;
        --text-muted: #636e72;
        --shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    }
}

/* ---------- 基础重置 ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.7;
    overflow-x: hidden;
    transition: background 0.5s ease, color 0.5s ease;
}

/* 背景装饰 - 渐变光晕 */
body::before {
    content: '';
    position: fixed;
    top: -20%;
    left: -10%;
    width: 60vw;
    height: 60vw;
    background: radial-gradient(circle at center, rgba(108, 92, 231, 0.25), transparent 70%);
    z-index: -1;
    animation: floatGlow 20s ease-in-out infinite alternate;
}

body::after {
    content: '';
    position: fixed;
    bottom: -20%;
    right: -10%;
    width: 50vw;
    height: 50vw;
    background: radial-gradient(circle at center, rgba(253, 121, 168, 0.2), transparent 70%);
    z-index: -1;
    animation: floatGlow 25s ease-in-out infinite alternate-reverse;
}

@keyframes floatGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -30px) scale(1.1); }
}

img {
    max-width: 100%;
    display: block;
    border-radius: var(--radius-sm);
}

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

ul, ol {
    list-style: none;
}

h1, h2, h3, h4 {
    line-height: 1.3;
    font-weight: 700;
}

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

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

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 8px;
}

/* ---------- 通用容器 ---------- */
main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 2rem;
}

main > section {
    flex: 1 1 calc(100% - 320px);
    min-width: 300px;
}

aside {
    flex: 0 0 300px;
}

/* ---------- 头部导航 ---------- */
header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-glass);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

nav {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo h1 {
    font-size: 1.8rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    letter-spacing: 1px;
    animation: gradientShift 6s ease infinite;
    background-size: 200% 200%;
}

@keyframes gradientShift {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

.nav-links {
    display: flex;
    gap: 1.2rem;
    flex-wrap: wrap;
}

.nav-links a {
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--text);
    transition: var(--transition);
    border: 1px solid transparent;
    position: relative;
}

.nav-links a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: var(--transition);
    border-radius: 2px;
}

.nav-links a:hover {
    color: var(--primary-light);
    border-color: var(--border-glass);
    background: rgba(108, 92, 231, 0.1);
    transform: translateY(-2px);
}

.nav-links a:hover::after {
    width: 70%;
}

/* ---------- 通用 Section 标题 ---------- */
section > h2 {
    font-size: 2rem;
    margin-bottom: 2rem;
    position: relative;
    padding-bottom: 1rem;
    display: inline-block;
}

section > h2::before {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 50px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
}

section > h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 55px;
    width: 20px;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary), var(--accent));
    border-radius: 4px;
}

/* ---------- 热门漫画网格 ---------- */
.comic-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

.comic-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
    animation: fadeInUp 0.6s ease both;
    animation-delay: calc(var(--i, 0) * 0.05s);
    position: relative;
    overflow: hidden;
}

.comic-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--primary), var(--secondary), var(--accent));
    transform: scaleX(0);
    transform-origin: left;
    transition: var(--transition);
}

.comic-card:hover::before {
    transform: scaleX(1);
}

.comic-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow);
    border-color: rgba(108, 92, 231, 0.4);
    background: var(--bg-glass);
}

.comic-card img {
    width: 100%;
    height: 280px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    margin-bottom: 1rem;
}

.comic-card:hover img {
    transform: scale(1.05);
}

.comic-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.comic-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.2rem 0;
}

/* ---------- 精品推荐 ---------- */
.recommend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 2rem;
}

.recommend-card {
    background: linear-gradient(145deg, var(--bg-glass), var(--bg-card));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.5rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
    animation: fadeInUp 0.6s ease both;
    animation-delay: calc(var(--i, 0) * 0.05s);
}

.recommend-card:hover {
    transform: translateY(-6px);
    box-shadow: var(--shadow);
    border-color: rgba(253, 121, 168, 0.4);
}

.recommend-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    transition: var(--transition);
}

.recommend-card:hover img {
    transform: scale(1.03);
}

.recommend-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.8rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.recommend-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

/* ---------- 详细介绍 ---------- */
#detail article {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 2rem;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeInUp 0.8s ease both;
}

#detail article img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

#detail article h3 {
    font-size: 1.8rem;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

#detail article p {
    margin-bottom: 1.2rem;
    color: var(--text);
    line-height: 1.8;
}

/* ---------- 角色介绍 ---------- */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.5rem;
}

.character-card {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: var(--transition);
    animation: fadeInUp 0.6s ease both;
    animation-delay: calc(var(--i, 0) * 0.05s);
}

.character-card:hover {
    transform: translateY(-8px) rotate(1deg);
    box-shadow: var(--shadow);
    border-color: rgba(0, 206, 201, 0.4);
}

.character-card img {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 1rem;
    border: 3px solid var(--primary);
    padding: 3px;
    transition: var(--transition);
}

.character-card:hover img {
    border-color: var(--secondary);
    transform: scale(1.05);
}

.character-card h3 {
    font-size: 1.2rem;
    margin-bottom: 0.8rem;
    color: var(--primary-light);
}

.character-card p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.3rem 0;
}

/* ---------- 平台介绍 ---------- */
#platform article {
    background: linear-gradient(135deg, var(--bg-glass), var(--bg-card));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 2.5rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    animation: fadeInUp 0.8s ease both;
}

#platform article h3 {
    font-size: 1.6rem;
    margin-bottom: 1.5rem;
    color: var(--accent);
}

#platform article p {
    margin-bottom: 1rem;
    color: var(--text);
    line-height: 1.8;
}

/* ---------- APP 下载 ---------- */
#app article {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 2.5rem;
    text-align: center;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: fadeInUp 0.8s ease both;
}

#app article img {
    width: 200px;
    height: 200px;
    object-fit: cover;
    border-radius: 30px;
    margin: 0 auto 1.5rem;
    box-shadow: 0 20px 60px rgba(108, 92, 231, 0.3);
}

#app article p {
    max-width: 600px;
    margin: 0 auto 2rem;
    color: var(--text-muted);
}

#app button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 50px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    margin: 0 0.5rem;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.3);
}

#app button:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 30px rgba(108, 92, 231, 0.5);
}

#app button:nth-child(2) {
    background: linear-gradient(135deg, var(--accent), var(--primary));
}

#app button:nth-child(3) {
    background: linear-gradient(135deg, var(--secondary), var(--accent));
}

/* ---------- 用户评论 ---------- */
.reviews-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.review-item {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 1.2rem 1.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: var(--transition);
    animation: fadeInUp 0.5s ease both;
    animation-delay: calc(var(--i, 0) * 0.03s);
}

.review-item:hover {
    background: var(--bg-glass);
    transform: translateX(8px);
    border-color: rgba(108, 92, 231, 0.3);
}

.review-item p:first-child {
    font-size: 0.9rem;
    color: var(--primary-light);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.review-item p:last-child {
    color: var(--text);
    line-height: 1.6;
}

/* ---------- 侧边栏 ---------- */
aside {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius);
    padding: 1.8rem;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    align-self: flex-start;
}

aside h2 {
    font-size: 1.2rem;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--border-glass);
    color: var(--primary-light);
}

aside ol {
    margin-bottom: 2rem;
    counter-reset: rank;
}

aside ol li {
    counter-increment: rank;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: var(--text);
    transition: var(--transition);
    border-bottom: 1px dashed var(--border-glass);
}

aside ol li::before {
    content: counter(rank);
    display: inline-block;
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    margin-right: 0.8rem;
}

aside ol li:hover {
    color: var(--secondary);
    transform: translateX(5px);
}

aside p {
    font-size: 0.9rem;
    color: var(--text-muted);
    padding: 0.3rem 0;
}

/* ---------- 页脚 ---------- */
footer {
    background: var(--bg-soft);
    border-top: 1px solid var(--border-glass);
    padding: 3rem 1.5rem 2rem;
    text-align: center;
    margin-top: 3rem;
}

footer h2 {
    font-size: 1.3rem;
    margin-bottom: 1.5rem;
    color: var(--primary-light);
}

footer ul {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

footer ul a {
    color: var(--text-muted);
    transition: var(--transition);
    font-size: 0.9rem;
}

footer ul a:hover {
    color: var(--secondary);
    text-decoration: underline;
}

footer p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0.3rem 0;
}

/* ---------- 动画关键帧 ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 滚动动画 - 使用 Intersection Observer 实现（CSS fallback） */
@media (prefers-reduced-motion: no-preference) {
    .comic-card, .recommend-card, .character-card, .review-item, section > h2 {
        animation: fadeInUp 0.6s ease both;
        animation-timeline: view();
        animation-range: entry 0% entry 100%;
    }
}

/* ---------- 响应式布局 ---------- */
@media (max-width: 1200px) {
    main {
        flex-direction: column;
    }

    aside {
        flex: 1 1 100%;
        position: static;
        max-height: none;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 1.5rem;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }

    nav {
        flex-direction: column;
        align-items: center;
        padding: 1rem;
    }

    .nav-links {
        justify-content: center;
        gap: 0.5rem;
    }

    .nav-links a {
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    main {
        padding: 1rem;
    }

    .comic-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1rem;
    }

    .comic-card img {
        height: 200px;
    }

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

    #detail article, #platform article, #app article {
        padding: 1.5rem;
    }

    #app button {
        margin: 0.5rem;
        padding: 0.7rem 1.5rem;
        font-size: 0.9rem;
    }

    aside {
        display: block;
        position: static;
        margin-top: 2rem;
    }

    footer ul {
        gap: 0.8rem;
    }
}

@media (max-width: 480px) {
    .comic-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.8rem;
    }

    .comic-card {
        padding: 0.8rem;
    }

    .comic-card img {
        height: 160px;
    }

    .comic-card p {
        font-size: 0.75rem;
    }

    .character-grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    .character-card img {
        width: 100px;
        height: 100px;
    }

    section > h2 {
        font-size: 1.5rem;
    }

    #detail article h3 {
        font-size: 1.4rem;
    }
}

/* ---------- 暗色模式强制优化 ---------- */
@media (prefers-color-scheme: dark) {
    .comic-card, .recommend-card, .character-card, .review-item, aside, #detail article, #platform article, #app article {
        background: rgba(255, 255, 255, 0.05);
    }

    img {
        filter: brightness(0.95) contrast(1.05);
    }
}

/* ---------- 打印样式 ---------- */
@media print {
    header, aside, footer, #app, .nav-links {
        display: none;
    }

    body {
        background: white;
        color: black;
    }

    main {
        display: block;
    }

    section {
        page-break-inside: avoid;
    }
}

/* ---------- 无障碍 ---------- */
:focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}