/* 工程方格筆記本:方格紙、裝訂紅線、螢光筆小標;accent 由各站 _head.php 注入 */
:root {
    --paper: #fbfaf7;
    --card: #ffffff;
    --grid: rgba(70, 110, 130, 0.09);
    --grid-bold: rgba(70, 110, 130, 0.16);
    --bind: #c9564f;
    --ink: #22262b;
    --ink-soft: #565c64;
    --ink-faint: #969ba2;
    --rule: #e4e2db;
    --marker: #fde68a;
    --grid-size: 26px;
    /* 中文明體在螢幕上閱讀吃力,全面改黑體;層級靠字重、字級與字距拉開 */
    --display: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", system-ui, sans-serif;
    --body: "PingFang TC", "Noto Sans TC", "Noto Sans CJK TC", "Microsoft JhengHei", system-ui, sans-serif;
    --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { font-size: 17px; }

body {
    font-family: var(--body);
    color: var(--ink);
    line-height: 1.9;
    letter-spacing: 2px;
    background-color: var(--paper);
    background-image:
        repeating-linear-gradient(to right, var(--grid) 0 1px, transparent 1px var(--grid-size)),
        repeating-linear-gradient(to bottom, var(--grid) 0 1px, transparent 1px var(--grid-size));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 0.25em; }
:focus-visible { outline: 2px solid var(--bind); outline-offset: 2px; }

/* ---- 版面:紙頁 + 左側裝訂邊 ---- */
.page {
    max-width: 51.5rem;
    margin: 0 auto;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.72);
    border-left: 1px solid var(--rule);
    border-right: 1px solid var(--rule);
    position: relative;
    padding-left: 8.6rem;
    padding-right: 2.5rem;
}
/* 裝訂紅線 */
.page::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    left: 7.4rem;
    width: 1px;
    background: var(--bind);
    opacity: 0.5;
}
/* 打孔 */
.page::after {
    content: "";
    position: absolute;
    top: 4rem;
    bottom: 4rem;
    left: 1.5rem;
    width: 13px;
    background-image: radial-gradient(circle at 50% 6.5px, #efece5 5.5px, #e0ddd4 6px, transparent 6.5px);
    background-size: 13px 8rem;
    background-repeat: repeat-y;
}

.content { padding: 3.5rem 0 5rem; }

/* ---- 站名頁首 ---- */
.masthead { margin-bottom: 3rem; }
.masthead-domain {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--ink-faint);
    letter-spacing: 0.1em;
    margin-bottom: 0.6rem;
}
.masthead-title {
    font-family: var(--display);
    font-size: 2.2rem;
    font-weight: 900;
    line-height: 1.35;
    letter-spacing: -0.01em;
}
.masthead-title a { color: var(--ink); }
.masthead-title a:hover { text-decoration: none; color: var(--accent); }
.masthead-desc {
    margin-top: 0.9rem;
    font-size: 0.95rem;
    color: var(--ink-soft);
    max-width: 34rem;
}

/* ---- 文章列表 ---- */
.entry-list { border-top: 1px solid var(--rule); }
.entry-item {
    display: flex;
    gap: 1.4rem;
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--rule);
    position: relative;
}
/* 日期寫在裝訂線外的邊界欄:年份/月日兩行的日期戳 */
.entry-date {
    position: absolute;
    left: -5.2rem;
    top: 1.55rem;
    width: 3.6rem;
    text-align: right;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--ink-faint);
    line-height: 1.45;
}
.entry-date span { display: block; }
.entry-date .md {
    font-size: 0.82rem;
    color: var(--ink-soft);
    letter-spacing: -0.02em;
}
.entry-text { flex: 1; min-width: 0; }
.entry-title {
    font-family: var(--display);
    font-size: 1.15rem;
    font-weight: 700;
    line-height: 1.6;
    letter-spacing: -0.005em;
}
.entry-title a { color: var(--ink); }
.entry-title a:hover { color: var(--accent); text-decoration: none; }
.entry-excerpt {
    margin-top: 0.45rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
    line-height: 1.85;
}

/* 縮圖:像貼在筆記上的照片 */
.entry-thumb {
    flex: 0 0 9rem;
    align-self: flex-start;
    margin-top: 0.4rem;
    padding: 4px;
    background: #fff;
    border: 1px solid var(--rule);
    box-shadow: 0 1px 3px rgba(34, 38, 43, 0.09);
    transform: rotate(-0.5deg);
}
.entry-thumb svg { display: block; width: 100%; height: auto; }
.entry-thumb:hover { transform: rotate(0deg); }

/* 翻頁:書口上的左右索引標籤,重點邊指出翻頁方向 */
.pager {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 2.6rem;
    padding-top: 1.4rem;
    border-top: 1px dashed var(--rule);
}
.pager a {
    display: inline-block;
    padding: 0.45rem 1rem;
    font-family: var(--display);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule);
}
.pager a:hover { text-decoration: none; color: var(--accent); background: #fff; }
.pager a.pager-prev { border-left: 2px solid var(--accent); }
.pager a.pager-next { margin-left: auto; border-right: 2px solid var(--accent); }

.empty {
    border: 1px dashed var(--bind);
    background: rgba(255, 255, 255, 0.8);
    padding: 2.5rem;
    text-align: center;
    color: var(--ink-soft);
    font-size: 0.95rem;
}

/* ---- 文章頁 ---- */
/* 回站台:貼在頁首的索引標籤(重點邊在上,與文末標籤的下緣呼應) */
.crumb { margin-bottom: 2.2rem; }
.crumb a {
    display: inline-block;
    padding: 0.3rem 0.85rem;
    font-family: var(--display);
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule);
    border-top: 2px solid var(--accent);
}
.crumb a::before {
    content: "←";
    margin-right: 0.4em;
    color: var(--accent);
}
.crumb a:hover { text-decoration: none; color: var(--accent); background: #fff; }

.article-hero {
    margin-bottom: 2.2rem;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--rule);
    box-shadow: 0 1px 4px rgba(34, 38, 43, 0.1);
}
.article-hero svg { display: block; width: 100%; height: auto; }

.article-head { margin-bottom: 2.4rem; }
.article-date {
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--ink-faint);
    letter-spacing: 0.1em;
}
.article-title {
    font-family: var(--display);
    font-size: 1.85rem;
    font-weight: 900;
    line-height: 1.5;
    letter-spacing: -0.015em;
    margin: 0.6rem 0 1.2rem;
}
/* 摘要:索引卡 */
.article-lead {
    font-size: 0.92rem;
    line-height: 1.85;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule);
    border-left: 4px solid var(--accent);
    padding: 0.9rem 1.1rem;
}

.article-body {
    text-align: justify;
    font-size: 1.02rem;
    line-height: 1.95;
    color: #2b3037;
}
.article-body p { margin: 1.3rem 0; }

/* 簽名元素:螢光筆劃過的小標 */
.article-body h2 {
    font-family: var(--display);
    font-size: 1.25rem;
    font-weight: 900;
    line-height: 1.7;
    margin: 2.8rem 0 0.9rem;
    letter-spacing: -0.01em;
}
.article-body h2 span {
    background-image: linear-gradient(transparent 60%, var(--marker) 60%, var(--marker) 93%, transparent 93%);
    background-repeat: no-repeat;
    padding: 0 0.18em;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}
.article-body h3 {
    font-family: var(--display);
    font-size: 1.02rem;
    font-weight: 700;
    margin: 1.9rem 0 0.5rem;
}
.article-body h3::before {
    content: "▍";
    color: var(--accent);
    margin-right: 0.35em;
    font-size: 0.85em;
}
.article-body ul, .article-body ol { margin: 1.25rem 0 1.25rem 1.5rem; }
.article-body li { margin: 0.4rem 0; }
.article-body ul li::marker { color: var(--bind); }
.article-body blockquote {
    border-left: 3px solid var(--accent);
    background: rgba(255, 255, 255, 0.85);
    padding: 0.85rem 1.2rem;
    margin: 1.4rem 0;
    color: var(--ink-soft);
    font-size: 0.94rem;
}
.article-body code {
    font-family: var(--mono);
    font-size: 0.85em;
    background: rgba(70, 110, 130, 0.1);
    padding: 0.1em 0.4em;
}
.article-body a { text-decoration: underline; text-underline-offset: 0.25em; }
.article-body hr {
    border: 0;
    border-top: 1px dashed var(--rule);
    margin: 2.2rem 0;
}
/* 內文截圖:貼上去的感覺 */
.article-body img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 1.6rem auto;
    padding: 5px;
    background: #fff;
    border: 1px solid var(--rule);
    box-shadow: 0 1px 4px rgba(34, 38, 43, 0.1);
}

/* ---- 標籤:索引標籤 ---- */
.tag-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 2.4rem;
    padding-top: 1.4rem;
    border-top: 1px dashed var(--rule);
}
.tag-list a {
    display: inline-block;
    padding: 0.2rem 0.7rem;
    font-family: var(--display);
    font-size: 0.78rem;
    color: var(--ink-soft);
    background: var(--card);
    border: 1px solid var(--rule);
    border-bottom: 2px solid var(--accent);
}
.tag-list a:hover { text-decoration: none; color: var(--accent); background: #fff; }

/* ---- 上下篇 ---- */
.adjacent {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1px;
    background: var(--rule);
    border: 1px solid var(--rule);
    margin-top: 3rem;
}
.adjacent-item {
    background: var(--card);
    padding: 1rem 1.2rem;
    display: block;
    color: var(--ink);
}
.adjacent-item:hover { text-decoration: none; background: rgba(255, 255, 255, 0.6); }
.adjacent-item:only-child { grid-column: 1 / -1; }
.adjacent-label {
    display: block;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--ink-faint);
    letter-spacing: 0.12em;
    margin-bottom: 0.3rem;
}
.adjacent-title { font-family: var(--display); font-size: 0.88rem; line-height: 1.65; }

/* ---- 其他筆記本的相關文章:每張卡帶該站的書背色 ---- */
.cross { margin-top: 2.8rem; }
.cross-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--ink-faint);
    letter-spacing: 0.16em;
    margin-bottom: 0.7rem;
}
.cross-list { list-style: none; }
.cross-list li { border-top: 1px dashed var(--rule); }
.cross-list li:last-child { border-bottom: 1px dashed var(--rule); }
.cross-list a {
    display: flex;
    align-items: baseline;
    gap: 1rem;
    padding: 0.65rem 0.2rem;
    color: var(--ink);
}
.cross-list a:hover { text-decoration: none; background: rgba(255, 255, 255, 0.75); }
.cross-list a:hover .cross-headline { text-decoration: underline; text-underline-offset: 0.25em; }
.cross-book {
    flex: 0 0 7.6rem;
    font-family: var(--display);
    font-size: 0.74rem;
    font-weight: 700;
    color: var(--book, var(--accent));
    letter-spacing: 0.02em;
    line-height: 1.6;
}
.cross-headline {
    flex: 1;
    min-width: 0;
    font-family: var(--display);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ---- 書架:所有筆記本 ---- */
.shelf-group { margin-bottom: 2.4rem; }
.shelf-group-title {
    font-family: var(--display);
    font-size: 0.95rem;
    font-weight: 900;
    letter-spacing: 0.02em;
    padding-bottom: 0.4rem;
    margin-bottom: 0.9rem;
    border-bottom: 1px dashed var(--rule);
}
.shelf-list {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 2rem;
}
.shelf-book { border-top: 1px dashed var(--rule); }
.shelf-book a {
    display: block;
    padding: 0.7rem 0.2rem 0.8rem;
    color: var(--ink);
}
.shelf-book a:hover { text-decoration: none; background: rgba(255, 255, 255, 0.75); }
.shelf-book a:hover .shelf-name { text-decoration: underline; text-underline-offset: 0.25em; }
.shelf-name {
    display: block;
    font-family: var(--display);
    font-size: 0.95rem;
    font-weight: 700;
}
/* 站台識別改用封面色小方塊,不用左側色棒 */
.shelf-name::before {
    content: "";
    display: inline-block;
    width: 0.6rem;
    height: 0.6rem;
    background: var(--book);
    margin-right: 0.5rem;
    vertical-align: 0.02em;
}
.shelf-book.is-here .shelf-name { color: var(--book); }
.shelf-desc {
    display: block;
    font-size: 0.82rem;
    color: var(--ink-soft);
    margin-top: 0.2rem;
    line-height: 1.7;
}
.shelf-meta {
    display: block;
    font-family: var(--mono);
    font-size: 0.68rem;
    color: var(--ink-faint);
    margin-top: 0.35rem;
    letter-spacing: 0.04em;
}

/* ---- 最新文章 ---- */
.more { margin-top: 2.8rem; }
.more-title {
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 400;
    color: var(--ink-faint);
    letter-spacing: 0.16em;
    margin-bottom: 0.7rem;
}
.more-list { list-style: none; }
.more-list li {
    border-top: 1px solid var(--rule);
    padding: 0.55rem 0;
    font-family: var(--display);
    font-size: 0.88rem;
}
.more-list a { color: var(--ink); }
.more-list a:hover { color: var(--accent); }

/* ---- 404 ---- */
.notfound { padding-top: 3rem; }
.notfound-code {
    font-family: var(--mono);
    font-size: 0.8rem;
    color: var(--ink-faint);
    letter-spacing: 0.2em;
}
.notfound-title {
    font-family: var(--display);
    font-size: 1.9rem;
    font-weight: 900;
    margin: 0.5rem 0 1rem;
}

/* ---- 頁尾 ---- */
.site-foot {
    max-width: 51.5rem;
    margin: 0 auto;
    padding: 1.4rem 2.5rem 2.5rem 8.6rem;
    font-family: var(--mono);
    font-size: 0.72rem;
    color: var(--ink-faint);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--rule);
    border-top: 1px dashed var(--rule);
    border-bottom: 0;
}
.site-foot a { color: var(--ink-faint); }

/* ---- 行動版:收掉裝訂邊 ---- */
@media (max-width: 760px) {
    html { font-size: 17px; }
    :root { --grid-size: 22px; }
    .article-body { font-size: 1rem; line-height: 1.9; }
    .page {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
        border-left: 0;
        border-right: 0;
    }
    .page::before, .page::after { display: none; }
    .content { padding-top: 2rem; }
    .masthead-title { font-size: 1.75rem; }
    .article-title { font-size: 1.5rem; }
    .entry-item { flex-direction: column; gap: 0.3rem; }
    .entry-date {
        position: static;
        width: auto;
        text-align: left;
        margin-bottom: 0.2rem;
    }
    .entry-date span { display: inline; }
    .entry-date .md { font-size: 0.7rem; color: var(--ink-faint); margin-left: 0.25rem; }
    .entry-thumb { display: none; }
    .adjacent { grid-template-columns: 1fr; }
    .shelf-list { grid-template-columns: 1fr; }
    .cross-list a { flex-direction: column; gap: 0.15rem; }
    .cross-book { flex: none; }
    .article-body { text-align: left; }
    .site-foot { padding-left: 1.25rem; padding-right: 1.25rem; border-left: 0; border-right: 0; }
}

@media (prefers-reduced-motion: no-preference) {
    a, .adjacent-item, .entry-thumb { transition: color 0.15s ease, background 0.15s ease, transform 0.2s ease; }
}
@media (prefers-reduced-motion: reduce) {
    .entry-thumb { transform: none; }
}
