/**
 * letters.css — Letters page (/letters): chronicle display, date range header.
 */
/* Extracted from style.css */

/* ==================== 来信页面容器 ==================== */
.letters-page {
    min-height: 100vh;
    padding-top: 80px;
    padding-bottom: 60px;
}

.letters-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
}
/* ==================== 页面标题 ==================== */
.letters-header {
    text-align: center;
    margin-bottom: 48px;
    animation: fadeInDown 0.6s ease-out;
}

.letters-title-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.letters-icon {
    font-size: 32px;
}

.letters-title {
    font-family: var(--font-mono);
    font-size: 28px;
    font-weight: 500;
    color: var(--text-primary);
    letter-spacing: 2px;
}

.letters-date-range {
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 1px;
}
/* ==================== 信封网格 ==================== */
.letters-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 32px;
    margin-bottom: 48px;
}

@media (max-width: 768px) {
    .letters-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}
/* ==================== 信封卡片 ==================== */
.envelope-card {
    position: relative;
    display: flex;
    flex-direction: column;
    cursor: pointer;
    animation: fadeInUp 0.6s ease-out backwards;
    transition: transform var(--transition-normal);
}

.envelope-card:nth-child(1) { animation-delay: 0.1s; }
.envelope-card:nth-child(2) { animation-delay: 0.2s; }
.envelope-card:nth-child(3) { animation-delay: 0.3s; }
.envelope-card:nth-child(4) { animation-delay: 0.4s; }
.envelope-card:nth-child(5) { animation-delay: 0.5s; }
.envelope-card:nth-child(n+6) { animation-delay: 0.6s; }

.envelope-card:hover {
    transform: translateY(-2px);
    filter: drop-shadow(0 8px 30px rgba(0, 0, 0, 0.5));
}

.envelope-body {
    position: relative;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    padding: 36px 24px 24px;
    min-height: 180px;
    transition: all var(--transition-normal);
    overflow: visible;
}

.envelope-card:hover .envelope-body {
    border-color: var(--border-accent);
}

.envelope-card:hover .envelope-bottom {
    border-color: var(--border-accent);
}
/* ==================== 信封翻盖 ==================== */
.envelope-flap {
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    height: 44px;
    overflow: visible;
    z-index: 3;
    transform-origin: top center;
    transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

.flap-triangle {
    width: 100%;
    height: 100%;
}

.flap-triangle polygon {
    fill: var(--bg-tertiary);
    stroke: var(--border-subtle);
    stroke-width: 1;
}

.envelope-card.expanded .envelope-flap {
    transform: rotateX(183deg);
}

@media (hover: hover) {
    .envelope-card:hover .envelope-flap {
        transform: rotateX(183deg);
    }
    .envelope-card.expanded:hover .envelope-flap {
        transform: rotateX(183deg);
    }
}
/* ==================== 邮戳日期 ==================== */
.envelope-postmark {
    position: absolute;
    top: 12px;
    left: 16px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6px 10px;
    background: rgba(123, 140, 222, 0.12);
    border: 2px solid rgba(123, 140, 222, 0.35);
    border-radius: 4px;
    transform: rotate(-5deg);
    transition: opacity 0.3s;
}

.postmark-date {
    font-family: var(--font-mono);
    font-size: 13px;
    font-weight: 700;
    color: #c4c8f0;
    letter-spacing: 0.5px;
    text-shadow: 0 0 6px rgba(123, 140, 222, 0.4);
}

:root[data-theme="light"] .envelope-postmark {
    background: rgba(74, 90, 158, 0.1);
    border-color: rgba(74, 90, 158, 0.4);
}

:root[data-theme="light"] .postmark-date {
    color: #3a4a7e;
    text-shadow: none;
}
/* ==================== 信封开口（翻盖尖端插入处） ==================== */
.envelope-lip {
    position: absolute;
    top: 39px;
    left: 50%;
    transform: translateX(-50%);
    width: 38%;
    height: 4px;
    z-index: 5;
    pointer-events: none;
}

.envelope-lip::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bg-card);
    border-bottom: 1px solid rgba(0,0,0,0.3);
    box-shadow: 0 2px 3px rgba(0,0,0,0.15);
}

.envelope-lip::after {
    content: '';
    position: absolute;
    top: 6px;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(0,0,0,0.25);
    border-bottom: 1px solid rgba(255,255,255,0.03);
}

:root[data-theme="light"] .envelope-lip::before {
    background: #f5f0e8;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

:root[data-theme="light"] .envelope-lip::after {
    background: rgba(0,0,0,0.08);
    border-bottom: 1px solid rgba(0,0,0,0.02);
}
/* ==================== 信封标题 ==================== */
.envelope-title {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 500;
    color: var(--text-primary);
    margin-top: 28px;
    margin-bottom: 12px;
    line-height: 1.4;
    text-align: center;
}
/* ==================== 信封标签 ==================== */
.envelope-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 16px;
}

.envelope-tag {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 4px 8px;
    border-radius: 4px;
}
/* ==================== 数字签名封 ==================== */
.envelope-seal {
    position: absolute;
    bottom: 10px;
    right: 18px;
    width: 40px;
    height: 40px;
    z-index: 10;
    transition: transform 0.3s ease;
}

.envelope-card:hover .envelope-seal {
    transform: scale(1.1) rotate(5deg);
}

.seal-icon {
    width: 100%;
    height: 100%;
    position: relative;
    background: var(--bg-card);
    clip-path: polygon(50% 2%, 93% 13%, 93% 87%, 50% 98%, 7% 87%, 7% 13%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: filter 0.3s ease;
}

.seal-icon::before {
    content: '';
    position: absolute;
    inset: 1.5px;
    background: var(--bg-card);
    clip-path: polygon(50% 5%, 90% 15%, 90% 85%, 50% 95%, 10% 85%, 10% 15%);
    pointer-events: none;
    z-index: 0;
}

.seal-icon svg {
    position: relative;
    z-index: 1;
    width: 24px;
    height: 24px;
    color: var(--accent-primary);
    filter: drop-shadow(0 0 5px rgba(var(--accent-primary-rgb), 0.6));
}

.seal-icon svg path,
.seal-icon svg circle,
.seal-icon svg line {
    stroke: currentColor;
    fill: none;
}

.envelope-card:hover .seal-icon svg {
    filter: drop-shadow(0 0 8px rgba(var(--accent-primary-rgb), 0.8));
}

.envelope-seal[data-has-inspiration="true"] .seal-icon svg {
    color: var(--accent-warning);
    filter: drop-shadow(0 0 5px rgba(var(--accent-warning-rgb), 0.6));
}

.envelope-card:hover .envelope-seal[data-has-inspiration="true"] .seal-icon svg {
    filter: drop-shadow(0 0 8px rgba(var(--accent-warning-rgb), 0.8));
}

.seal-glow {
    position: absolute;
    inset: -4px;
    background: transparent;
    border-radius: 4px;
    animation: sealPulse 2s ease-in-out infinite;
    pointer-events: none;
    box-shadow:
        inset 0 0 8px rgba(var(--accent-primary-rgb), 0.08),
        0 0 12px rgba(var(--accent-primary-rgb), 0.06);
}

.envelope-seal[data-has-inspiration="true"] .seal-glow {
    box-shadow:
        inset 0 0 8px rgba(var(--accent-warning-rgb), 0.08),
        0 0 12px rgba(var(--accent-warning-rgb), 0.06);
}

@keyframes sealPulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}
/* ==================== 信封底部装饰 ==================== */
.envelope-bottom {
    position: relative;
    height: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-top: none;
    border-radius: 0 0 8px 8px;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.envelope-texture {
    position: absolute;
    inset: 0;
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(var(--accent-primary-rgb), 0.02) 2px,
            rgba(var(--accent-primary-rgb), 0.02) 4px
        );
    opacity: 0.5;
}
/* ==================== 展开状态 ==================== */
.envelope-card.expanded .envelope-body {
    min-height: auto;
}

.envelope-card.expanded .letter-paper {
    max-height: 2000px;
    padding: 20px 20px 24px;
    opacity: 1;
}
/* ==================== 信件纸（从信封中拉出） ==================== */
.letter-paper {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-subtle);
    border-right: 1px solid var(--border-subtle);
    margin: 0;
    padding: 0 20px;
    transition: max-height 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.55s cubic-bezier(0.4, 0, 0.2, 1),
                opacity 0.4s ease-out;
}

:root[data-theme="light"] .letter-paper {
    background: #faf8f3;
    border-color: rgba(0, 0, 0, 0.06);
}
/* ==================== 信件内容 ==================== */
.letter-content {
    animation: letterReveal 0.4s ease-out;
}

@keyframes letterReveal {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.letter-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 12px;
}

.letter-date {
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--text-muted);
}

.letter-close {
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-subtle);
    border-radius: 50%;
    background: transparent;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.letter-close:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.letter-title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.letter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.letter-excerpt {
    font-family: var(--font-serif);
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.letter-excerpt p {
    margin-bottom: 12px;
}

.letter-excerpt p:last-child {
    margin-bottom: 0;
}
/* ==================== 阅读更多按钮 ==================== */
.letter-read-more {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-mono);
    font-size: 13px;
    color: var(--accent-primary);
    text-decoration: none;
    padding: 10px 20px;
    border: 1px solid var(--accent-primary);
    border-radius: 6px;
    transition: all var(--transition-fast);
}

.letter-read-more:hover {
    background: rgba(var(--accent-primary-rgb), 0.1);
    transform: translateX(4px);
}

.letter-read-more svg {
    transition: transform var(--transition-fast);
}

.letter-read-more:hover svg {
    transform: translateX(4px);
}
/* ==================== 空信箱状态 ==================== */
.letters-empty {
    text-align: center;
    padding: 80px 24px;
    animation: fadeIn 0.6s ease-out;
}

.empty-mailbox {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.empty-icon {
    font-size: 64px;
    opacity: 0.5;
    animation: emptyBounce 2s ease-in-out infinite;
}

@keyframes emptyBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.empty-text {
    font-family: var(--font-serif);
    font-size: 18px;
    color: var(--text-muted);
}
/* ==================== 扩展按钮 ==================== */
.letters-expand {
    text-align: center;
    padding: 24px;
}

.expand-days-btn {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
    background: transparent;
    border: 1px dashed var(--border-subtle);
    border-radius: 8px;
    padding: 14px 28px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.expand-days-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.05);
}

.expand-icon {
    font-size: 16px;
    animation: expandBounce 1.5s ease-in-out infinite;
}

@keyframes expandBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(4px); }
}

.expand-range {
    font-size: 12px;
    color: var(--text-muted);
    padding: 2px 8px;
    background: var(--bg-hover);
    border-radius: 4px;
}
/* ==================== 加载动画 ==================== */
.letters-loading {
    text-align: center;
    padding: 40px;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-subtle);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}
/* ==================== 浅色主题 - 信封 ==================== */
:root[data-theme="light"] .envelope-card:hover {
    filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.08));
}

:root[data-theme="light"] .envelope-body {
    background: #f5f0e8;
    border-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="light"] .envelope-card:hover .envelope-body {
    border-color: rgba(0, 0, 0, 0.18);
}

:root[data-theme="light"] .flap-triangle polygon {
    fill: #e8e0d5;
    stroke: rgba(0, 0, 0, 0.1);
}

:root[data-theme="light"] .envelope-bottom {
    background: #f5f0e8;
    border-color: rgba(0, 0, 0, 0.08);
}

:root[data-theme="light"] .envelope-title,
:root[data-theme="light"] .letter-title {
    color: #1a1a2e;
}

:root[data-theme="light"] .envelope-tag {
    background: rgba(0, 0, 0, 0.05);
    color: #666;
}

:root[data-theme="light"] .letter-read-more {
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

:root[data-theme="light"] .letter-excerpt {
    color: #4a4a68;
}

:root[data-theme="light"] .seal-icon {
    background: #f5f0e8;
}

:root[data-theme="light"] .seal-icon::before {
    background: #f5f0e8;
}

:root[data-theme="light"] .seal-icon svg {
    filter: drop-shadow(0 0 4px rgba(var(--accent-primary-rgb), 0.5));
}

:root[data-theme="light"] .envelope-card:hover .seal-icon svg {
    filter: drop-shadow(0 0 6px rgba(var(--accent-primary-rgb), 0.7));
}

:root[data-theme="light"] .seal-glow {
    box-shadow:
        inset 0 0 6px rgba(var(--accent-primary-rgb), 0.06),
        0 0 8px rgba(var(--accent-primary-rgb), 0.04);
}

:root[data-theme="light"] .envelope-texture {
    background-image: 
        repeating-linear-gradient(
            45deg,
            transparent,
            transparent 2px,
            rgba(0, 0, 0, 0.03) 2px,
            rgba(0, 0, 0, 0.03) 4px
        );
}
