/* ============================================================
   Evermore · Letters to You
   私人信件收藏室 —— Romantic Pearl 配色
   珍珠白页面 / 奶油象牙信纸 / 鼠尾草绿信封 / 香槟金细节
   ============================================================ */

.letters-page {
    background-color: var(--pearl);
    background-image:
        radial-gradient(circle at 10% 0%, rgba(198, 173, 131, 0.09), transparent 45%),
        radial-gradient(circle at 88% 6%, rgba(165, 178, 155, 0.13), transparent 42%),
        radial-gradient(circle at 65% 96%, rgba(215, 191, 192, 0.07), transparent 45%);
    color: var(--ink);
    font-family: var(--font-body);
}

.letters-page [hidden] {
    display: none !important;
}

/* ---------- 顶部 ---------- */

.letters-page > header {
    background: linear-gradient(180deg, rgba(251, 250, 247, 0.97), rgba(248, 246, 241, 0.78));
    border-bottom: 1px solid var(--line-gold);
    box-shadow: none;
}

.letters-page > header h1 {
    font-family: var(--font-serif);
    font-weight: 400;
    color: var(--olive);
    font-size: 30px;
    letter-spacing: 4px;
    margin-bottom: 12px;
}

.letters-page nav a {
    color: var(--ink-light);
    font-size: 14px;
    letter-spacing: 0.08em;
}

.letters-page nav a:hover {
    color: var(--olive);
}

.letters-page nav a.is-current {
    color: var(--olive);
    position: relative;
}

.letters-page nav a.is-current::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 1px;
    background-color: var(--champagne);
}

/* ---------- Hero ---------- */

.letters-hero {
    text-align: center;
    padding: 76px 22px 10px;
}

.hero-eyebrow {
    font-size: 11px;
    letter-spacing: 0.36em;
    text-transform: uppercase;
    color: var(--champagne);
}

.hero-title {
    font-family: var(--font-serif);
    font-style: italic;
    font-size: clamp(21px, 3.2vw, 29px);
    font-weight: 400;
    color: var(--olive);
    margin: 16px 0 22px;
    line-height: 1.5;
}

.hero-rule {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
    max-width: 380px;
    margin: 0 auto 16px;
}

.rule-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(198, 173, 131, 0.55), transparent);
}

.rule-stamp {
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(198, 173, 131, 0.55);
    border-radius: 50%;
    font-family: var(--font-serif);
    font-size: 12px;
    color: var(--champagne);
    box-shadow: inset 0 0 0 4px rgba(251, 250, 247, 0.9);
}

.hero-note {
    color: var(--ink-light);
    font-size: 13.5px;
    letter-spacing: 0.08em;
}

/* ---------- 工具栏 ---------- */

.letters-toolbar {
    max-width: 1080px;
    margin: 38px auto 0;
    padding: 0 22px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.letter-filter {
    border: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    letter-spacing: 0.04em;
    color: var(--ink-light);
    padding: 9px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: color 0.25s, background-color 0.25s, box-shadow 0.25s;
}

.letter-filter:hover {
    color: var(--olive);
    background-color: var(--sage-mist);
}

.letter-filter.is-active {
    color: var(--pearl);
    background-color: var(--olive);
    box-shadow: 0 8px 18px rgba(104, 118, 95, 0.22);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 250px;
    padding: 9px 16px;
    background-color: var(--pearl-soft);
    border: 1px solid var(--line);
    border-radius: 999px;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.search-box:focus-within {
    border-color: rgba(198, 173, 131, 0.65);
    box-shadow: 0 0 0 3px rgba(165, 178, 155, 0.14);
}

.search-icon {
    color: var(--ink-light);
    font-size: 15px;
}

.search-box input {
    width: 100%;
    border: none;
    outline: none;
    background: none;
    font-family: inherit;
    font-size: 14px;
    color: var(--ink);
}

.search-box input::placeholder {
    color: var(--ink-light);
}

/* ---------- 标签筛选 ---------- */

.tag-filter {
    max-width: 1080px;
    margin: 16px auto 0;
    padding: 0 22px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-chip {
    border: 1px solid var(--line);
    background-color: transparent;
    color: var(--ink-soft);
    font-family: inherit;
    font-size: 12.5px;
    padding: 5px 12px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.22s;
}

.tag-chip:hover {
    border-color: rgba(165, 178, 155, 0.75);
    color: var(--olive);
}

.tag-chip.is-active {
    background-color: var(--sage-mist);
    border-color: rgba(165, 178, 155, 0.8);
    color: var(--olive);
}

/* ---------- 信封列表 ---------- */

.letters-grid {
    max-width: 1080px;
    margin: 34px auto 90px;
    padding: 0 22px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 36px 30px;
}

.letter-card {
    outline: none;
    animation: letter-in 0.5s ease both;
}

.letter-card .envelope {
    position: relative;
    display: block;
    overflow: hidden;
    padding: 122px 24px 26px;
    background: linear-gradient(168deg, var(--pearl-soft) 0%, var(--ivory) 100%);
    border: 1px solid var(--line-gold);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.letter-card:hover .envelope,
.letter-card:focus-visible .envelope {
    transform: translateY(-7px);
    box-shadow: var(--shadow-lift);
    border-color: rgba(198, 173, 131, 0.85);
}

.letter-card:focus-visible .envelope {
    outline: 2px solid rgba(104, 118, 95, 0.45);
    outline-offset: 3px;
}

/* 信封盖：鼠尾草绿 */
.envelope-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 92px;
    background: linear-gradient(180deg, #D5DCCB 0%, #BFC9B4 100%);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    z-index: 1;
}

.letter-card:nth-child(3n + 2) .envelope {
    background: linear-gradient(168deg, #FCFBF8 0%, #EFEAE1 100%);
}

.letter-card:nth-child(3n + 2) .envelope-flap {
    background: linear-gradient(180deg, #DDD8CE 0%, #C9C2B3 100%);
}

.letter-card:nth-child(3n) .envelope {
    background: linear-gradient(168deg, #FCFBF8 0%, #E9EDE3 100%);
}

.letter-card:nth-child(3n) .envelope-flap {
    background: linear-gradient(180deg, #CBD4BF 0%, #B4C0A8 100%);
}

/* 邮票 */
.envelope-stamp {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 42px;
    height: 64px;
    display: grid;
    place-items: center;
    background-color: var(--pearl-soft);
    border: 1px solid rgba(198, 173, 131, 0.6);
    box-shadow: inset 0 0 0 3px var(--pearl-soft), inset 0 0 0 4px rgba(198, 173, 131, 0.3);
    transform: rotate(3deg);
    font-family: var(--font-serif);
    font-size: 6.5px;
    letter-spacing: 0.06em;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    color: var(--olive);
    z-index: 3;
}

/* 火漆印：深橄榄绿 */
.envelope-seal {
    position: absolute;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #82907A, #55614D 72%);
    box-shadow: 0 3px 9px rgba(85, 97, 77, 0.32), inset 0 1px 2px rgba(255, 255, 255, 0.28);
    color: #F2F0E9;
    font-family: var(--font-serif);
    font-size: 14px;
    z-index: 4;
}

/* 部分信封用低饱和灰玫瑰火漆，作为少量浪漫点缀 */
.letter-card:nth-child(3n + 2) .envelope-seal {
    background: radial-gradient(circle at 32% 28%, #D2B6B7, #B08E90 72%);
}

.envelope-face {
    position: relative;
    z-index: 2;
    text-align: center;
}

.envelope-cat {
    font-size: 10.5px;
    letter-spacing: 0.26em;
    text-transform: uppercase;
    color: var(--champagne);
    margin-bottom: 12px;
}

.envelope-title {
    font-family: var(--font-serif);
    font-size: 21px;
    font-weight: 400;
    line-height: 1.5;
    color: var(--ink);
    margin-bottom: 12px;
    word-break: break-word;
}

.envelope-excerpt {
    font-size: 13.5px;
    line-height: 1.9;
    color: var(--ink-soft);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.envelope-date {
    margin-top: 18px;
    font-size: 11px;
    letter-spacing: 0.2em;
    color: var(--ink-light);
}

/* ---------- 空状态 ---------- */

.letters-empty {
    text-align: center;
    padding: 30px 22px 100px;
    animation: letter-in 0.5s ease both;
}

.empty-envelope {
    position: relative;
    width: 190px;
    height: 122px;
    margin: 0 auto 26px;
    background: linear-gradient(168deg, var(--pearl-soft), var(--ivory));
    border: 1px solid var(--line-gold);
    border-radius: 8px;
    overflow: hidden;
}

.empty-flap {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 74px;
    background: linear-gradient(180deg, #D5DCCB, #BFC9B4);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
}

.empty-seal {
    position: absolute;
    top: 54px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: radial-gradient(circle at 32% 28%, #82907A, #55614D 72%);
    color: #F2F0E9;
    font-family: var(--font-serif);
    font-size: 12px;
}

.letters-empty h3 {
    font-family: var(--font-serif);
    font-size: 20px;
    font-weight: 400;
    color: var(--olive);
    margin-bottom: 8px;
}

.letters-empty p {
    color: var(--ink-light);
    font-size: 14px;
    line-height: 1.9;
}

/* ---------- 阅读视图 ---------- */

.letter-view {
    max-width: 780px;
    margin: 44px auto 90px;
    padding: 0 22px;
    animation: paper-in 0.45s ease both;
}

.letter-paper {
    position: relative;
    background-color: var(--pearl-soft);
    background-image:
        radial-gradient(circle at 18% 8%, rgba(198, 173, 131, 0.10), transparent 55%),
        radial-gradient(circle at 86% 82%, rgba(165, 178, 155, 0.10), transparent 60%);
    border: 1px solid var(--line-gold);
    border-radius: 6px;
    box-shadow: 0 22px 55px rgba(104, 118, 95, 0.14);
    padding: 44px clamp(22px, 5vw, 62px) 58px;
}

.back-link {
    border: none;
    background: none;
    font-family: inherit;
    font-size: 13px;
    letter-spacing: 0.06em;
    color: var(--ink-light);
    cursor: pointer;
    padding: 4px 0;
    margin-bottom: 30px;
    transition: color 0.22s;
}

.back-link:hover {
    color: var(--olive);
}

.letter-head {
    padding-bottom: 26px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 34px;
    text-align: center;
}

.letter-kicker {
    font-size: 10.5px;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--champagne);
    margin-bottom: 14px;
}

.letter-title {
    font-family: var(--font-serif);
    font-size: clamp(24px, 4vw, 33px);
    font-weight: 400;
    line-height: 1.45;
    color: var(--olive);
    margin-bottom: 14px;
    word-break: break-word;
}

.letter-meta {
    font-size: 12px;
    letter-spacing: 0.18em;
    color: var(--ink-light);
}

.letter-tags {
    margin-top: 16px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.letter-tags span {
    font-size: 12px;
    color: var(--olive);
    border: 1px solid rgba(165, 178, 155, 0.55);
    background-color: rgba(165, 178, 155, 0.10);
    border-radius: 999px;
    padding: 3px 11px;
    letter-spacing: 0.04em;
}

/* ---------- 正文 ---------- */

.letter-body {
    font-size: 16.5px;
    line-height: 2.05;
    color: var(--ink);
    word-break: break-word;
}

.letter-body > :first-child {
    margin-top: 0;
}

.letter-body p {
    margin: 0 0 1.2em;
}

.letter-body h2,
.letter-body h3,
.letter-body h4,
.letter-body h5,
.letter-body h6 {
    font-family: var(--font-serif);
    font-weight: 400;
    color: var(--olive);
    line-height: 1.5;
    margin: 1.9em 0 0.7em;
}

.letter-body h2 { font-size: 24px; }
.letter-body h3 { font-size: 20.5px; margin-top: 2em; }
.letter-body h4 { font-size: 18px; }

.letter-body strong {
    color: var(--olive-deep);
}

.letter-body em {
    font-style: italic;
}

.letter-body a {
    color: var(--olive);
    text-decoration: underline;
    text-decoration-color: rgba(165, 178, 155, 0.8);
    text-underline-offset: 3px;
}

.letter-body blockquote {
    margin: 1.5em 0;
    padding: 0.2em 0 0.2em 20px;
    border-left: 2px solid rgba(165, 178, 155, 0.85);
    color: var(--ink-soft);
    font-style: italic;
}

.letter-body ul,
.letter-body ol {
    margin: 0 0 1.3em 1.3em;
    padding-left: 0.6em;
}

.letter-body li {
    margin-bottom: 0.4em;
}

.letter-body code {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.9em;
    background-color: var(--sage-mist);
    padding: 2px 6px;
    border-radius: 4px;
}

.letter-body pre {
    background-color: var(--ivory);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 16px 18px;
    overflow-x: auto;
    margin: 0 0 1.4em;
}

.letter-body pre code {
    background: none;
    padding: 0;
}

.letter-body hr {
    border: none;
    border-top: 1px solid var(--line-gold);
    margin: 2.2em auto;
    width: 60%;
}

.letter-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 26px auto;
    border-radius: 6px;
    box-shadow: 0 8px 24px rgba(104, 118, 95, 0.16);
}

.md-figure {
    margin: 30px 0;
    text-align: center;
}

.md-figure img {
    margin: 0 auto 10px;
}

.md-figure figcaption {
    font-size: 12.5px;
    color: var(--ink-light);
    font-style: italic;
    letter-spacing: 0.04em;
}

.md-img-error {
    margin: 22px 0;
    padding: 24px;
    border: 1px dashed var(--line);
    border-radius: 6px;
    text-align: center;
    color: var(--ink-light);
    font-size: 13px;
}

.letter-signature {
    margin-top: 46px;
    padding-top: 22px;
    border-top: 1px solid var(--line);
    font-family: var(--font-hand);
    font-size: 20px;
    color: var(--olive);
    text-align: right;
    line-height: 1.7;
}

/* ---------- 动画 ---------- */

@keyframes letter-in {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes paper-in {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ---------- 小屏 ---------- */

@media (max-width: 720px) {
    .letters-page > header h1 {
        font-size: 25px;
        letter-spacing: 3px;
    }

    .letters-hero {
        padding: 54px 20px 6px;
    }

    .letters-toolbar {
        margin-top: 28px;
        gap: 12px;
    }

    .search-box {
        min-width: 0;
        width: 100%;
    }

    .letters-grid {
        grid-template-columns: 1fr;
        gap: 26px;
        margin-top: 26px;
        margin-bottom: 60px;
    }

    .letter-card .envelope {
        padding: 112px 20px 24px;
    }

    .letter-view {
        margin: 30px auto 60px;
    }

    .letter-paper {
        padding: 30px 20px 40px;
    }

    .letter-body {
        font-size: 16px;
        line-height: 2;
    }

    .letter-title {
        font-size: 24px;
    }

    .letter-signature {
        font-size: 18px;
    }
}

/* ---------- 减少动态效果 ---------- */

@media (prefers-reduced-motion: reduce) {
    .letter-card,
    .letters-empty,
    .letter-view {
        animation: none !important;
    }

    .letter-card .envelope,
    .letter-filter,
    .tag-chip,
    .back-link {
        transition: none !important;
    }

    .letter-card:hover .envelope,
    .letter-card:focus-visible .envelope {
        transform: none;
    }
}
