/*
Theme Name: HarPer Time-Line Blog
Theme URI:
Author: You
Description: 像素风日记博客：左侧时间线标尺 + 日记本式文章排版，暖棕琥珀配色，自适应手机/平板/桌面。
Version: 1.10.0
Requires at least: 5.0
Tested up to: 6.4
Requires PHP: 7.2
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: timeline-blog
Tags: blog, one-column, custom-logo, featured-images, translation-ready, custom-colors
*/

@font-face {
    font-family: "Press Start 2P";
    src: url("fonts/PressStart2P-Regular.ttf") format("truetype");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: "Fusion Pixel";
    src: url("fonts/FusionPixel-zh_hans.woff2") format("woff2");
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg-1: #241610;
    --bg-2: #2f1f13;
    --bg-3: #3d2a18;
    --text: #f4ead6;
    --text-soft: #dcc9a3;
    --muted: #ab9168;
    --accent: #e8a838;
    --accent-2: #f2c14e;
    --accent-3: #c8654b;
    --card-bg: #2e1d11;
    --shadow: #000000;
    --max-width: 760px;
    --line-grid: 32px; /* 日记横线间距：正文行高与横线共用同一节奏，保证文字逐行落在横线上 */
    --rule-lines: repeating-linear-gradient(to bottom, transparent 0 calc(var(--line-grid) - 2px), rgba(232,168,56,0.10) calc(var(--line-grid) - 2px) var(--line-grid));
    --font-head: "Press Start 2P", "Fusion Pixel", monospace;
    --font-body: "Fusion Pixel", "Press Start 2P", monospace;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--font-body);
    color: var(--text);
    background: var(--bg-1);
    line-height: 1.9;
    font-size: 16px;
    overflow-x: hidden;
}

/* ===== Pixel sky background (warm) ===== */
.dream-bg {
    position: fixed;
    inset: 0;
    z-index: -2;
    overflow: hidden;
    background: linear-gradient(180deg,
        var(--bg-1) 0%, var(--bg-1) 35%,
        var(--bg-2) 35%, var(--bg-2) 70%,
        var(--bg-3) 70%, var(--bg-3) 100%);
}
.dream-bg::after {
    content: "";
    position: absolute;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20width='80'%20height='80'%3E%3Crect%20x='6'%20y='10'%20width='2'%20height='2'%20fill='%23f4ead6'%20opacity='0.85'/%3E%3Crect%20x='30'%20y='22'%20width='2'%20height='2'%20fill='%23f4ead6'%20opacity='0.55'/%3E%3Crect%20x='60'%20y='40'%20width='2'%20height='2'%20fill='%23e8a838'%20opacity='0.75'/%3E%3Crect%20x='14'%20y='50'%20width='2'%20height='2'%20fill='%23f2c14e'%20opacity='0.65'/%3E%3Crect%20x='70'%20y='70'%20width='2'%20height='2'%20fill='%23c8654b'%20opacity='0.6'/%3E%3Crect%20x='44'%20y='60'%20width='2'%20height='2'%20fill='%23f4ead6'%20opacity='0.45'/%3E%3C/svg%3E");
    background-size: 80px 80px;
    background-repeat: repeat;
}

a { color: var(--accent-3); text-decoration: none; transition: color 0.15s; }
a:hover { color: var(--accent-2); }

.container {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0 24px;
    position: relative;
}

/* ===== Pixel box (card) ===== */
.pixel-box {
    background: var(--card-bg);
    border: 4px solid var(--accent);
    box-shadow: 6px 6px 0 0 var(--shadow);
    padding: 32px 36px;
    position: relative;
}
.entry-card { margin-bottom: 28px; }

/* ===== Header ===== */
.site-header {
    position: sticky;
    top: 0;
    z-index: 30;
    background: var(--bg-1);
    border-bottom: 4px solid var(--accent);
    box-shadow: 0 4px 0 0 var(--shadow);
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
}
.site-brand { display: flex; align-items: center; gap: 12px; }
.site-brand:hover { text-decoration: none; }
.custom-logo {
    width: 44px;
    height: 44px;
    border: 3px solid var(--accent);
    box-shadow: 3px 3px 0 var(--shadow);
    object-fit: cover;
    display: block;
}
.site-title {
    font-family: var(--font-head);
    font-size: 13px;
    color: var(--text);
    line-height: 1.4;
}
.site-nav { display: flex; gap: 18px; }
.site-nav a {
    font-family: var(--font-head);
    color: var(--text-soft);
    font-size: 10px;
    padding: 8px 12px;
    border: 3px solid transparent;
    transition: all 0.15s;
}
.site-nav a:hover {
    color: var(--bg-1);
    background: var(--accent);
    border-color: var(--shadow);
    box-shadow: 3px 3px 0 var(--shadow);
    text-decoration: none;
}

/* ===== Main ===== */
.site-main { padding: 56px 0 88px; }

.section-label {
    font-family: var(--font-head);
    font-size: 10px;
    color: var(--accent-2);
    letter-spacing: 0.12em;
    margin-bottom: 20px;
    text-transform: uppercase;
}

/* ===== Diary article ===== */
.diary { padding: 0; }
.diary-banner {
    background: var(--accent-2);
    color: var(--bg-1);
    border-bottom: 4px solid var(--shadow);
    padding: 14px 26px;
    display: flex;
    align-items: center;
    gap: 14px;
    font-family: var(--font-body);
}
.diary-tag {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: 0.04em;
}
.diary-date {
    font-size: 13px;
    margin-left: auto;
    opacity: 0.85;
}
.diary-body {
    padding: 28px 32px;
    position: relative;
}
.diary-body::before {
    content: "";
    position: absolute;
    left: 10px;
    top: 28px;
    bottom: 28px;
    width: 6px;
    background-image: repeating-linear-gradient(to bottom, var(--accent) 0 6px, transparent 6px 20px);
    opacity: 0.45;
}
/* 横线画在各文字元素自身上（见 post-content 系列规则），容器只负责缩进：
   任意高度的图片都不会把后面的文字挤离横线 */
.diary-body .post-content { padding-left: 18px; }

/* ===== Titles & content ===== */
.latest-post { animation: rise 0.6s ease both; }
@keyframes rise {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: translateY(0); }
}
.post-title {
    font-family: var(--font-body);
    font-size: 22px;
    line-height: 1.5;
    font-weight: 700;
    margin: 0 0 12px;
    color: var(--text);
    letter-spacing: 0;
}
.latest-post .post-title a { color: var(--text); }
.latest-post .post-title a:hover { color: var(--accent-2); text-decoration: none; }
.single-post .post-title { font-size: 24px; color: var(--text); }
.entry-card .post-title { font-size: 18px; }

.post-meta {
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 22px;
}

/* 正文行高统一 32px；横线画在每个文字元素自身上（而非容器），
   元素各自从头对齐网格：图片/代码块占多高都不会影响后面的文字落线 */
.post-content { font-size: 16px; line-height: var(--line-grid); color: var(--text-soft); }

.post-content p,
.post-content blockquote p {
    margin: 0;
    padding: 0 0 var(--line-grid);
    background-image: var(--rule-lines);
}
.post-content ul, .post-content ol {
    margin: 0;
    padding: 0 0 var(--line-grid) 1.4em;
    background-image: var(--rule-lines);
}
.post-content h2, .post-content h3 {
    font-family: var(--font-head);
    color: var(--accent);
    font-size: 13px;
    margin: 0;
    padding: var(--line-grid) 0 var(--line-grid);
    background-image: var(--rule-lines);
}
.post-content li { margin: 0; line-height: var(--line-grid); }
.post-content img {
    max-width: 100%;
    height: auto;
    border: 3px solid var(--accent);
    box-shadow: 4px 4px 0 var(--shadow);
}
/* 图片/图组/代码块：任意高度，占位后由后续元素自行重新对齐横线 */
.post-content img,
.post-content figure,
.post-content pre { margin: 0 0 var(--line-grid); }
.post-content blockquote {
    border-left: 4px solid var(--accent);
    margin: 0;
    padding: var(--line-grid) 0 0 1em;
    color: var(--text-soft);
}
.post-content code {
    background: rgba(0,0,0,0.4);
    border: 2px solid var(--accent);
    padding: 1px 6px;
    font-size: 0.9em;
    color: var(--accent-2);
}
.post-content pre {
    background: #1b1109; /* 实心底色：盖住横线，避免代码块里透出横线 */
    border: 3px solid var(--accent);
    box-shadow: 4px 4px 0 var(--shadow);
    padding: 16px;
    overflow-x: auto;
}
.post-content pre code { background: none; border: none; color: var(--text); padding: 0; }
.post-content a { color: var(--accent-3); text-decoration: underline; }

.page-title {
    font-family: var(--font-body);
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-2);
    margin: 0 0 28px;
}

.post-nav {
    margin: 0;
    padding: 20px 32px;
    border-top: 4px solid var(--accent);
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-family: var(--font-head);
    font-size: 10px;
}
.post-nav a { color: var(--text-soft); }
.post-nav a:hover { color: var(--accent-2); text-decoration: none; }

/* ===== Footer ===== */
.site-footer {
    border-top: 4px solid var(--accent);
    box-shadow: 0 -4px 0 0 var(--shadow);
    padding: 26px 0;
    background: var(--bg-1);
    font-family: var(--font-body);
    font-size: 13px;
    color: var(--muted);
}
.site-footer .container { text-align: center; }
.site-footer a { color: var(--text-soft); }

/* ===== Timeline ===== */
/* mobile-first：抽屉（默认屏外，FAB 唤出） */
.timeline-rail {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 300px;
    max-width: 84vw;
    padding: 84px 20px 32px 24px;
    overflow-y: auto;
    scroll-snap-type: y proximity; /* 松手后把最近的条目吸附到中央 */
    z-index: 60;
    background: rgba(36, 22, 16, 0.95);
    border-right: 4px solid var(--accent);
    box-shadow: 6px 0 0 var(--shadow);
    transform: translateX(-100%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.35s ease;
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}
.timeline-rail.is-open { transform: translateX(0); opacity: 1; }
.timeline-rail::-webkit-scrollbar { width: 5px; }
.timeline-rail::-webkit-scrollbar-thumb { background: var(--accent); }
.rail-head { margin-bottom: 22px; }

/* 中央指示线（仅手机抽屉）：标记「居中即选中」的焦点行 */
.rail-guide {
    position: sticky;
    top: 50%;
    height: 0;
    z-index: 0;
    pointer-events: none;
}
.rail-guide::before {
    content: "";
    position: absolute;
    left: 8px;
    right: 8px;
    top: -1px;
    height: 2px;
    background: repeating-linear-gradient(90deg, var(--accent) 0 6px, transparent 6px 12px);
    opacity: 0.35;
}

/* FAB + 遮罩（仅手机） */
.timeline-fab {
    position: fixed;
    right: 16px;
    bottom: 16px;
    z-index: 55;
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: var(--font-head);
    font-size: 9px;
    color: var(--bg-1);
    background: var(--accent-2);
    border: 3px solid var(--shadow);
    box-shadow: 4px 4px 0 var(--shadow);
    padding: 12px 14px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.timeline-fab:hover { transform: translate(-2px, -2px); box-shadow: 6px 6px 0 var(--shadow); }
.timeline-fab.is-open { background: var(--accent-3); color: var(--text); }
.timeline-backdrop {
    position: fixed;
    inset: 0;
    z-index: 58;
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.timeline-backdrop.is-show { opacity: 1; pointer-events: auto; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before {
    content: "";
    position: absolute;
    left: 4px; top: 4px; bottom: 4px;
    width: 3px;
    background: var(--accent);
    opacity: 0.6;
}
.timeline-group { margin-bottom: 24px; }
.timeline-group:last-child { margin-bottom: 0; }
.timeline-group h3 {
    position: relative;
    font-family: var(--font-head);
    font-size: 10px;
    color: var(--accent-2);
    margin: 0 0 14px;
    letter-spacing: 0.06em;
    padding-left: 2px;
}
.timeline-group h3::before {
    content: "";
    position: absolute;
    left: -18px; top: 50%;
    width: 11px; height: 3px;
    background: var(--accent-2);
    transform: translateY(-50%);
}

.timeline-item {
    position: relative;
    display: block;
    padding: 6px 0 14px 4px;
    color: var(--text);
    transform-origin: left center;
    transition: transform 0.25s ease;
    scroll-snap-align: center; /* 吸附目标：条目中心对齐抽屉中心 */
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
}
.timeline-item:last-child { padding-bottom: 0; }
/* 选中态（手机抽屉：垂直居中的条目，永远只有一个放大高亮） */
.timeline-item.is-selected { transform: scale(1.12); text-decoration: none; }
.timeline-item::before {
    content: "";
    position: absolute;
    left: -18px; top: 8px;
    width: 9px; height: 9px;
    background: var(--card-bg);
    border: 2px solid var(--accent);
    box-sizing: border-box;
    transition: transform 0.25s ease, background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.timeline-item.is-selected::before {
    transform: scale(1.5);
    background: var(--accent-2);
    border-color: var(--accent-2);
    box-shadow: 2px 2px 0 var(--shadow);
}
.timeline-item .t-date {
    display: block;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.02em;
    transition: font-size 0.25s ease, color 0.25s ease;
}
.timeline-item .t-title {
    display: block;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    transition: font-size 0.25s ease, color 0.25s ease;
}
.timeline-item.is-selected .t-date { font-size: 13px; color: var(--text-soft); }
.timeline-item.is-selected .t-title { font-size: 17px; color: var(--accent-2); }

/* 悬停态：仅限真正支持鼠标悬停的设备。
   触屏上 :hover 会「粘」在摸过的条目上，造成多个假高亮 */
@media (hover: hover) {
    .timeline-item:hover { transform: scale(1.12); text-decoration: none; }
    .timeline-item:hover::before {
        transform: scale(1.5);
        background: var(--accent-2);
        border-color: var(--accent-2);
        box-shadow: 2px 2px 0 var(--shadow);
    }
    .timeline-item:hover .t-date { font-size: 13px; color: var(--text-soft); }
    .timeline-item:hover .t-title { font-size: 17px; color: var(--accent-2); }
}

/* 当前正在阅读的文章：仅圆点常驻标记，不与居中高亮抢焦点 */
.timeline-item.is-current::before {
    background: var(--accent-2);
    border-color: var(--accent-2);
    box-shadow: 2px 2px 0 var(--shadow);
    transform: scale(1.3);
}
.timeline-item.is-current .t-date { color: var(--text-soft); }

/* 平板/桌面：左侧常驻标尺（沉浸↔悬停凸显） */
@media (min-width: 768px) {
    .timeline-rail {
        width: 200px;
        max-width: none;
        padding: 92px 16px 32px 24px;
        z-index: 20;
        background: transparent;
        border-right: none;
        box-shadow: none;
        transform: none;
        opacity: 0.45;
        transition: opacity 0.5s ease;
        scroll-snap-type: none; /* 桌面不吸附 */
    }
    .timeline-rail:hover { opacity: 1; }
    .timeline-rail.is-open { transform: none; }
    .timeline-fab, .timeline-backdrop, .rail-guide { display: none; }
    .timeline-item { scroll-snap-align: none; }
    .site-main { padding-left: 216px; }
}
@media (min-width: 1280px) {
    .timeline-rail { width: 220px; }
    .site-main { padding-left: 0; }
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
    .container { padding: 0 16px; }
    .pixel-box { padding: 20px 16px; box-shadow: 4px 4px 0 var(--shadow); }
    .diary-banner { padding: 12px 18px; gap: 10px; }
    .diary-tag { font-size: 13px; }
    .diary-date { font-size: 12px; }
    .diary-body { padding: 22px 16px; }
    .diary-body::before { left: 6px; top: 22px; bottom: 22px; }
    .diary-body .post-content { padding-left: 14px; }
    .post-nav { padding: 16px 16px; flex-direction: column; gap: 10px; }
    .site-title { font-size: 11px; }
    .custom-logo { width: 38px; height: 38px; }
    .single-post .post-title { font-size: 20px; }
    .latest-post .post-title { font-size: 19px; }
    .page-title { font-size: 20px; }
    .site-main { padding: 32px 0 96px; }
    .timeline-item .t-date { font-size: 10px; }
}

@media (prefers-reduced-motion: reduce) {
    .latest-post { animation: none; }
    .timeline-rail { transition: none; }
    .timeline-item, .timeline-item::before,
    .timeline-item .t-date, .timeline-item .t-title { transition: none; }
}
