/*
Theme Name: Aiphoto
Theme URI: https://aiphoto.ra0.cn
Author: Aiphoto Team
Author URI: https://aiphoto.ra0.cn
Description: AI图片展示主题 - 在线AI图片生成、瀑布流画廊展示。基于 Agnes AI 引擎。
Version: 2.4.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: LICENSE
Text Domain: aiphoto
Tags: gallery, masonry, ai-image, responsive, one-column, translation-ready
*/

/* ============================================
   CSS 变量（纯白色主题）
   ============================================ */
:root {
    --color-primary: #8b2e2e;
    --color-primary-light: #b53d3d;
    --color-accent: #f97316;
    --color-foreground: #0f172a;
    --color-foreground-muted: #64748b;
    --color-foreground-dim: #94a3b8;
    --color-border: #e2e8f0;
    --color-border-light: #cbd5e1;
    --color-bg-base: #ffffff;
    --color-bg-surface: #f8fafc;
    --color-bg-card: #ffffff;
    --color-bg-hover: #f1f5f9;

    /* 光影志 design tokens (unified header) */
    --ink: #1c1c1c;
    --ink-soft: #3a3a3a;
    --ink-mute: #6b6b6b;
    --ink-dim: #9a9a9a;
    --paper: #ffffff;
    --paper-warm: #faf8f3;
    --paper-mute: #f4f2ec;
    --vermilion: #8b2e2e;
    --vermilion-bright: #b53d3d;
    --vermilion-deep: #6b1f1f;
    --vermilion-soft: rgba(139, 46, 46, 0.06);
    --vermilion-glow: rgba(181, 61, 61, 0.15);
    --gold: #c9a961;
    --gyz-border: rgba(28, 28, 28, 0.06);
    --serif: 'Noto Serif SC', serif;
    --mono: 'JetBrains Mono', monospace;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-full: 9999px;

    --easing: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: 150ms var(--easing);
    --transition-normal: 200ms var(--easing);
    --transition-slow: 300ms var(--easing);

    --font-primary: "DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

/* 全站选中文字颜色改为白色 */
::selection {
    background: #8b2e2e;
    color: #fff;
}
::-moz-selection {
    background: #8b2e2e;
    color: #fff;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-primary);
    font-size: 1rem;
    line-height: 1.6;
    color: var(--color-foreground);
    background-color: var(--color-bg-base);
    overflow-x: hidden;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover { color: var(--color-primary-light); }

img {
    max-width: 100%;
    height: auto;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

/* 无障碍 */
.sr-only {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border-width: 0;
}

:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

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

/* ============================================
   排版
   ============================================ */
h1, h2, h3, h4 {
    font-family: var(--font-primary);
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-foreground);
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); letter-spacing: -0.03em; }
h2 { font-size: clamp(1.5rem, 4vw, 2.5rem); }
h3 { font-size: clamp(1.125rem, 2.5vw, 1.375rem); }

p { color: var(--color-foreground-muted); line-height: 1.7; }

/* ============================================
   布局
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}

.section { padding: 80px 0; }

/* ============================================
   导航栏
   ============================================ */
.site-header {
    position: fixed;
    top: 19px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    width: calc(100% - 48px);
    max-width: 1248px;
    background: rgba(250, 248, 243, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--gyz-border);
    border-radius: var(--radius-xl);
    padding: 0 8px;
    height: 64px;
    transition: background var(--transition-normal), box-shadow var(--transition-normal);
}

.site-header.scrolled {
    background: rgba(250, 248, 243, 0.95);
    box-shadow: 0 4px 24px rgba(28, 20, 10, 0.06);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
}

.site-logo {
    display: flex;
    align-items: center;
    gap: 18px;
    text-decoration: none;
    margin-left: 10px;
}

.site-logo-img {
    height: 44px;
    width: auto;
    object-fit: contain;
}

.site-logo svg { width: 28px; height: 28px; }
.site-logo .logo-accent { color: var(--vermilion); }

.main-navigation ul {
    display: flex;
    list-style: none;
    gap: 4px;
    align-items: center;
}

.main-navigation a {
    display: block;
    padding: 8px 18px;
    border-radius: var(--radius-full);
    font-size: 1.125rem;
    font-weight: 500;
    color: var(--ink-soft);
    transition: all var(--transition-fast);
    position: relative;
    letter-spacing: 0.15em;
}

.main-navigation a::after {
    content: '';
    position: absolute;
    bottom: 2px;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--vermilion), var(--vermilion-bright));
    border-radius: 2px;
    transition: width 0.25s ease, left 0.25s ease;
}

.main-navigation a:hover {
    color: var(--vermilion);
}

.main-navigation a:hover::after {
    width: 60%;
    left: 20%;
}

.main-navigation .current-menu-item > a,
.main-navigation .current_page_item > a {
    color: var(--vermilion);
    font-weight: 600;
}

.main-navigation .current-menu-item > a::after,
.main-navigation .current_page_item > a::after {
    width: 60%;
    left: 20%;
}

/* 主题切换按钮 */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius-md);
    color: var(--color-foreground-muted);
    border: 1px solid var(--color-border);
    background: var(--color-bg-card);
    margin-left: 4px;
    position: relative;
    overflow: hidden;
    transition: all var(--transition-fast);
}

.theme-toggle:hover {
    color: var(--color-foreground);
    border-color: var(--color-border-light);
}

.theme-toggle svg {
    position: absolute;
    width: 18px; height: 18px;
    transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.theme-toggle .icon-sun {
    opacity: 0;
    transform: rotate(90deg) scale(0.5);
}

.theme-toggle .icon-moon {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

/* ============================================
   移动端菜单
   ============================================ */
.menu-toggle {
    display: none;
    flex-direction: column;
    gap: 4px;
    padding: 8px;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.menu-toggle span {
    display: block;
    width: 20px; height: 2px;
    background: var(--color-foreground);
    border-radius: 2px;
    transition: all var(--transition-normal);
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translateY(6px);
}
.menu-toggle.active span:nth-child(2) { opacity: 0; }
.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translateY(-6px);
}

/* ============================================
   瀑布流网格
   ============================================ */
.masonry-grid {
    columns: 4;
    column-gap: 16px;
}

.masonry-item {
    break-inside: avoid;
    margin-bottom: 16px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: transform var(--transition-normal);
    background: #fff;
    border: 1px solid var(--color-border);
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.masonry-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.08);
}

.masonry-item img {
    width: 100%;
    display: block;
    transition: transform var(--transition-slow);
}

.masonry-item:hover img {
    transform: scale(1.03);
}

.masonry-overlay {
    display: none;
}

/* ============================================
   分页 / 加载更多
   ============================================ */
.load-more-wrapper {
    text-align: center;
    margin-top: 48px;
    padding-bottom: 48px;
}

.load-more-btn {
    padding: 14px 40px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    color: var(--color-foreground);
    font-size: 0.9375rem;
    font-weight: 600;
    min-height: 48px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}

.load-more-btn:hover {
    background: var(--color-bg-hover);
    border-color: var(--color-border-light);
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.load-more-btn.loading {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ============================================
   空状态
   ============================================ */
.empty-state {
    text-align: center;
    padding: 96px 24px;
}

.empty-state svg {
    width: 48px; height: 48px;
    margin: 0 auto 16px;
    color: var(--color-foreground-dim);
}

.empty-state h3 {
    margin-bottom: 4px;
    color: var(--color-foreground-muted);
}

.empty-state p {
    color: var(--color-foreground-dim);
}

/* ============================================
   加载动画
   ============================================ */
/* 三个点跳动动画 */
.dots-loading::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}
@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* ============================================
   状态消息
   ============================================ */
.status-message.error {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    margin-top: 12px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.api-warning {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    padding: 12px 16px;
    margin: 20px auto;
    max-width: 640px;
    text-align: center;
    color: #dc2626;
    font-size: 0.875rem;
}

.api-warning a {
    color: #dc2626;
    text-decoration: underline;
}

/* ============================================
   响应式
   ============================================ */
@media (max-width: 1200px) {
    .masonry-grid { columns: 3; }
}

@media (max-width: 768px) {
    .masonry-grid { columns: 2; }

    .menu-toggle { display: flex; }

    .main-navigation {
        position: fixed;
        top: 72px;
        left: 16px;
        right: 16px;
        background: rgba(255,255,255,0.98);
        backdrop-filter: blur(16px);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: 16px;
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all var(--transition-normal);
    }

    .main-navigation.is-open {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }

    .main-navigation ul {
        flex-direction: column;
        gap: 4px;
    }

    .main-navigation a {
        padding: 12px;
        border-radius: var(--radius-md);
    }
}

@media (max-width: 480px) {
    .masonry-grid { columns: 1; }
}

/* ============================================
   页脚
   ============================================ */
.site-footer {
    background: #0f172a;
    padding: 48px 0 0;
    margin-top: 80px;
}

.footer-top {
    display: flex;
    justify-content: space-between;
    gap: 40px;
    padding-bottom: 32px;
    border-bottom: 1px solid #1e293b;
}

.footer-brand {
    max-width: 280px;
}

.footer-brand .footer-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.footer-logo-img {
    height: 58px;
    width: auto;
    object-fit: contain;
}

.footer-tagline {
    font-size: 0.875rem;
    color: #94a3b8;
    margin: 0;
}

.footer-cols {
    display: flex;
    gap: 60px;
}

.footer-col h4 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 16px;
}

.footer-col ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-col li {
    margin-bottom: 10px;
}

.footer-col a {
    font-size: 0.875rem;
    color: #cbd5e1;
    text-decoration: none;
    transition: color 150ms ease;
}

.footer-col a:hover {
    color: #fff;
}

.footer-bottom {
    padding: 20px 0;
    text-align: center;
}

.footer-bottom p {
    font-size: 0.8125rem;
    color: #64748b;
    margin: 0 0 8px;
}

.footer-copyright {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px;
}

.footer-bottom a {
    color: #94a3b8;
    text-decoration: none;
}

.footer-bottom a:hover {
    color: #fff;
}

.footer-links {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 0.75rem;
    color: #64748b;
}

.footer-links a {
    color: #64748b;
    text-decoration: none;
    transition: color 150ms ease;
}

.footer-links a:hover {
    color: #cbd5e1;
}

.footer-divider {
    color: #475569;
}

@media (max-width: 768px) {
    .footer-top {
        flex-direction: column;
        gap: 32px;
    }
    .footer-brand {
        max-width: 100%;
    }
    .footer-cols {
        gap: 40px;
    }
}

/* ============================================
   灯箱
   ============================================ */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(255, 252, 247, 0.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.lightbox.is-open {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 50%;
    color: #0f172a;
    font-size: 0;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.lightbox-close::before,
.lightbox-close::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 2px;
    background: #0f172a;
    border-radius: 1px;
    transition: background 0.2s ease;
}

.lightbox-close::before {
    transform: rotate(45deg);
}

.lightbox-close::after {
    transform: rotate(-45deg);
}

.lightbox-close:hover {
    background: #0f172a;
    border-color: #0f172a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.lightbox-close:hover::before,
.lightbox-close:hover::after {
    background: #fff;
}

.lightbox-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
}

/* 灯箱上一张/下一张导航按钮 */
.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 50%;
    color: #1c1c1c;
    font-size: 28px;
    font-family: Arial, sans-serif;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    z-index: 10;
    user-select: none;
}

.lightbox-prev { left: 24px; }
.lightbox-next { right: 24px; }

.lightbox-prev:hover,
.lightbox-next:hover {
    background: #fff;
    transform: translateY(-50%) scale(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
}

.lightbox-prev:active,
.lightbox-next:active {
    transform: translateY(-50%) scale(0.95);
}

@media (max-width: 768px) {
    .lightbox-prev,
    .lightbox-next {
        width: 42px;
        height: 42px;
        font-size: 22px;
    }
    .lightbox-prev { left: 12px; }
    .lightbox-next { right: 12px; }
}

.lightbox-caption {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    text-align: center;
    max-width: 80%;
}

/* 提示词标题已关闭显示,隐藏元素避免空框出现 */
.lightbox-title {
    display: none !important;
}

.lightbox-expand-btn {
    display: none !important;
}

.lightbox-caption p {
    color: #0f172a;
    font-size: 1rem;
    font-weight: 500;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 12px 20px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    max-height: 3.8em;
    transition: max-height 0.3s ease;
    cursor: pointer;
    line-height: 1.8;
}

.lightbox-caption p.expanded {
    -webkit-line-clamp: unset;
    max-height: 500px;
    overflow-y: auto;
    text-align: left;
}
