/*
Theme Name: Ginger Blog
Author: 野薑設計
Description: Ginger 聊聊個人部落格的自刻主題。
Version: 0.3.0
Requires PHP: 8.0
Text Domain: ginger-blog
*/

/* ---------- 字型 ---------- */
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 400 700; font-display: swap; src: url("assets/fonts/opensans-400-normal.woff2") format("woff2"); }
@font-face { font-family: "Open Sans"; font-style: italic; font-weight: 400; font-display: swap; src: url("assets/fonts/opensans-400-italic.woff2") format("woff2"); }
@font-face { font-family: "Montserrat"; font-style: normal; font-weight: 700; font-display: swap; src: url("assets/fonts/montserrat-700-normal.woff2") format("woff2"); }

/* ---------- 變數（數值來源：docs/design-tokens.md） ---------- */
:root {
  --c-text: #313131; --c-muted: #888; --c-faint: #999; --c-line: #dedede; --c-line-soft: #ececec;
  --c-bg-soft: #f5f5f5; --c-rule: #818181; --c-bg: #fff;
  --w-container: 1170px; --w-main: 780px; --w-side: 340px; --gap: 20px;
  --font-cjk: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-latin: "Open Sans", var(--font-cjk);
  --font-heading: "Montserrat", var(--font-cjk);
  --i-search: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Ccircle cx='5.8' cy='5.8' r='4.6' fill='none' stroke='%23000' stroke-width='1.4'/%3E%3Cpath d='M9.2 9.2 13 13' stroke='%23000' stroke-width='1.4' stroke-linecap='round'/%3E%3C/svg%3E");
  --i-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 12'%3E%3Cpath d='M2 2l4 4-4 4' fill='none' stroke='%23000' stroke-width='1.3'/%3E%3C/svg%3E");
  --i-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12'%3E%3Ccircle cx='6' cy='6' r='5' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3Cpath d='M6 3v3.2l2 1.2' fill='none' stroke='%23000' stroke-width='1.2'/%3E%3C/svg%3E");
  --i-fb: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 14'%3E%3Cpath d='M5 14V7.6h2.2l.3-2.5H5V3.5c0-.7.2-1.2 1.2-1.2h1.3V.1C7.3.1 6.5 0 5.6 0 3.7 0 2.5 1.1 2.5 3.2v1.9H.3v2.5h2.2V14z'/%3E%3C/svg%3E");
  --i-mail: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 14'%3E%3Cpath d='M0 3.3V11a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V3.3L7 8.4zM13.6 2H.4L7 6.9z'/%3E%3C/svg%3E");
  --i-refresh: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 14'%3E%3Cpath d='M10.500 5A5 5 0 0 0 1.500 6M1.500 9a5 5 0 0 0 9-1M10.800 1.800V5H7.600M1.200 12.200V9h3.200' fill='none' stroke='%23000' stroke-width='1.3'/%3E%3C/svg%3E");
  --i-up: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1.500 6.500 6 2l4.500 4.500' fill='none' stroke='%23000' stroke-width='1.4'/%3E%3C/svg%3E");
}

/* ---------- 基礎 ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--c-bg); color: var(--c-text); font: 400 15px/27px var(--font-latin); overflow-wrap: anywhere; }
img, video, iframe { max-width: 100%; }
img { height: auto; display: block; }
a { color: inherit; text-decoration: none; }
a:hover { opacity: .75; }
a:focus-visible, button:focus-visible, input:focus-visible { outline: 2px solid var(--c-text); outline-offset: 2px; }
h1, h2, h3, h4, p, ul, ol, figure { margin: 0; }
ul { padding: 0; list-style: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
.screen-reader-text { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip-link { position: absolute; left: -9999px; top: 0; background: var(--c-text); color: #fff; padding: 8px 16px; z-index: 100; }
.skip-link:focus { left: 0; }
.site-container { width: var(--w-container); max-width: calc(100% - 48px); margin-inline: auto; }

/* ---------- 頁首 ---------- */
.site-branding { padding: 40px 0; display: flex; justify-content: center; }
.site-branding-title { margin: 0; line-height: 0; }
.site-title img { width: 240px; height: 49px; }
.site-nav-bar { border-block: 1px solid var(--c-line-soft); background: var(--c-bg); }
.site-nav-inner { display: flex; align-items: center; justify-content: space-between; min-height: 58px; position: relative; }
.site-nav ul { display: flex; gap: 30px; }
.site-nav li { position: relative; }
.site-nav a { display: block; font: 700 12px/58px var(--font-heading); text-transform: uppercase; white-space: nowrap; }
.site-nav .menu-item-has-children > a::after { content: ""; display: inline-block; width: 7px; height: 10px; margin-left: 6px; background: currentColor; -webkit-mask: var(--i-chevron) center/contain no-repeat; mask: var(--i-chevron) center/contain no-repeat; transform: rotate(90deg); vertical-align: -1px; }
.site-nav .sub-menu { display: none; position: absolute; left: -20px; top: 100%; z-index: 20; min-width: 200px; padding: 8px 20px; background: var(--c-bg); border: 1px solid var(--c-line-soft); flex-direction: column; gap: 0; }
.site-nav li:hover > .sub-menu, .site-nav li:focus-within > .sub-menu { display: flex; }
.site-nav .sub-menu a { line-height: 40px; }
.nav-toggle { display: none; width: 44px; height: 44px; position: relative; }
.nav-toggle span, .nav-toggle span::before, .nav-toggle span::after { content: ""; position: absolute; left: 11px; width: 22px; height: 2px; background: var(--c-text); }
.nav-toggle span { top: 21px; } .nav-toggle span::before { left: 0; top: -7px; } .nav-toggle span::after { left: 0; top: 7px; }
.search-toggle { width: 44px; height: 58px; margin-right: -15px; position: relative; }
.search-toggle::before { content: ""; position: absolute; inset: 22px 15px; background: var(--c-text); -webkit-mask: var(--i-search) center/14px no-repeat; mask: var(--i-search) center/14px no-repeat; }
.site-search { position: absolute; right: 0; top: 100%; z-index: 30; width: 320px; max-width: 100%; padding: 12px; background: var(--c-bg); border: 1px solid var(--c-line-soft); }
.search-form { display: flex; gap: 8px; }
.search-form input[type="search"] { flex: 1; min-width: 0; height: 37px; padding: 0 10px; border: 1px solid var(--c-line); border-radius: 5px; font: 400 13px var(--font-latin); }
.search-form button { padding: 0 12px; font: 700 12px var(--font-heading); border: 1px solid var(--c-line); }

/* ---------- 版面 ---------- */
.site-layout { display: grid; grid-template-columns: minmax(0, var(--w-main)) var(--w-side); justify-content: space-between; column-gap: 50px; padding: 60px 0 52px; }
.site-main { min-width: 0; }

/* ---------- 共用：分類、標題、內文 ---------- */
.post-cats { font-size: 11px; line-height: 13.2px; padding-bottom: 5px; }
.post-title { font: 700 18px/24.3px var(--font-heading); text-transform: uppercase; }
time, .post-byline { color: var(--c-muted); font-size: 13px; line-height: 1.4; }
.entry-content > * + * { margin-top: 17px; }
.entry-content h2, .entry-content h3, .entry-content h4 { font-family: var(--font-heading); font-weight: 700; margin-top: 34px; }
.entry-content h2 { font-size: 22px; line-height: 1.4; } .entry-content h3 { font-size: 18px; line-height: 1.45; } .entry-content h4 { font-size: 16px; line-height: 1.5; }
.entry-content a { text-decoration: underline; text-underline-offset: 3px; }
.entry-content ul, .entry-content ol { padding-left: 1.4em; } .entry-content ul { list-style: disc; } .entry-content li + li { margin-top: 6px; }
.entry-content blockquote { margin: 17px 0 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--c-text); color: #555; }
.entry-content blockquote cite { display: block; margin-top: 8px; font-size: 13px; color: var(--c-muted); }
.entry-content hr { border: 0; border-top: 1px solid var(--c-line); margin: 34px auto; }
.entry-content figure { margin-top: 24px; } .entry-content figcaption { margin-top: 8px; text-align: center; font-size: 13px; color: var(--c-muted); }
.entry-content img.emoji, .entry-content img[src*="fbcdn"] { display: inline; width: 1em; height: 1em; vertical-align: -.1em; }
.entry-content table { display: block; overflow-x: auto; border-collapse: collapse; } .entry-content td, .entry-content th { border: 1px solid var(--c-line); padding: 6px 10px; }
.entry-content .wp-block-button__link { display: inline-block; padding: 10px 24px; border: 1px solid var(--c-text); font: 700 12px/1.4 var(--font-heading); text-transform: uppercase; text-decoration: none; }
.entry-content iframe { width: 100%; aspect-ratio: 16/9; height: auto; border: 0; }
.entry-content .aligncenter { margin-inline: auto; text-align: center; }

/* ---------- 資訊列與分享 ---------- */
.post-meta-bar { display: flex; align-items: center; gap: 20px; margin-top: 30px; padding: 15px 0; border-block: 1px solid var(--c-line); color: var(--c-muted); font-size: 13px; line-height: 19px; }
.post-meta-bar time::before { content: ""; display: inline-block; width: 11px; height: 13px; margin-right: 5px; background: currentColor; -webkit-mask: var(--i-clock) center/contain no-repeat; mask: var(--i-clock) center/contain no-repeat; vertical-align: -2px; }
.post-meta-bar .post-views { padding-left: 20px; border-left: 1px solid rgba(136,136,136,.7); line-height: 10px; }
.post-meta-bar .share { margin-left: auto; }
.share { display: flex; align-items: center; gap: 10px; }
.share a { width: 24px; height: 24px; margin: -5px; position: relative; color: var(--c-text); }
.share a::before { content: ""; position: absolute; inset: 5px; background: currentColor; }
.share-fb::before { -webkit-mask: var(--i-fb) center/8px 14px no-repeat; mask: var(--i-fb) center/8px 14px no-repeat; }
.share-mail::before { -webkit-mask: var(--i-mail) center/14px no-repeat; mask: var(--i-mail) center/14px no-repeat; }

/* ---------- 首頁：首篇全文 ---------- */
.post-full { margin-bottom: 60px; }
.post-full-thumb { display: block; background: var(--c-bg-soft); } .post-full-thumb img { width: 100%; }
.post-full-header { position: relative; margin-top: 19px; padding: 7px 0 17px; text-align: center; }
.post-full-header::after, .single-header.has-rule::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 60px; height: 1px; margin-left: -30px; background: var(--c-text); }
.post-full .post-title { font-size: 24px; line-height: 32.4px; margin-top: 5px; }
.post-full .entry-content { margin-top: 37px; }

/* ---------- 文章列表 ---------- */
.post-item { display: grid; grid-template-columns: 360.73px minmax(0, 1fr); padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--c-line); }
.post-item.no-thumb { grid-template-columns: minmax(0, 1fr); } .post-item.no-thumb .post-item-body { padding-left: 0; }
.post-item-thumb { display: block; aspect-ratio: 3/2; background: var(--c-bg-soft); overflow: hidden; } .post-item-thumb img { width: 100%; height: 100%; object-fit: cover; }
.post-item-body { padding-left: 30px; display: flex; flex-direction: column; }
.post-item .post-title { margin: 3px 0 12px; }
.post-excerpt { margin-top: 16px; font-size: 13px; line-height: 23.4px; }
.post-item .share { margin-top: 16px; justify-content: center; position: relative; }
.post-item .share::before, .post-item .share::after { content: ""; flex: 1; height: 1px; background: var(--c-line); }
.post-item .share a:first-of-type { margin-left: 5px; } .post-item .share a:last-of-type { margin-right: 5px; }
.post-list > .post-item:last-child { border-bottom: 0; margin-bottom: 0; }
.pagination { display: flex; justify-content: center; }
.load-more { display: flex; align-items: center; justify-content: center; gap: 8px; width: 400px; max-width: 100%; height: 41px; border: 1px solid var(--c-line); color: var(--c-faint); font: 700 12px/16.8px var(--font-heading); text-transform: uppercase; }
.load-more::after { content: ""; width: 12px; height: 14px; background: currentColor; -webkit-mask: var(--i-refresh) center/contain no-repeat; mask: var(--i-refresh) center/contain no-repeat; }
.load-more.is-loading { opacity: .5; pointer-events: none; }
.no-results { padding: 40px 0; text-align: center; } .no-results .search-form { max-width: 400px; margin: 20px auto 0; }

/* ---------- 側欄 ---------- */
.site-sidebar { min-width: 0; }
.widget + .widget { margin-top: 16px; }
.widget-title { margin-bottom: 30px; padding: 8px 12px 7px; background: var(--c-bg-soft); border: 1px solid var(--c-bg-soft); font: 700 13px/16.9px var(--font-heading); text-align: center; text-transform: uppercase; }
.about-image { width: 100%; aspect-ratio: 340/425; object-fit: cover; }
.about-name { position: relative; margin-top: 18px; padding: 1px 0 16px; font-weight: 700; font-size: 18px; line-height: 23.4px; text-align: center; }
.about-name::after { content: ""; position: absolute; left: 50%; bottom: 0; width: 60px; height: 1px; margin-left: -30px; background: var(--c-rule); }
.about-text { margin-top: 18px; font-size: 13px; line-height: 23.4px; text-align: center; } .about-text p + p { margin-top: 0; }
.widget-subscribe .widget-title { margin-bottom: 16px; }
.subscribe-form { display: flex; align-items: center; gap: 16px; }
.subscribe-form input { flex: 1; min-width: 0; height: 37px; padding: 0 10px; border: 1px solid var(--c-line); border-radius: 5px; font: 400 13px var(--font-latin); }
.subscribe-form button { font-size: 12px; line-height: 1.3; white-space: nowrap; color: #000; }
.widget-categories li { display: flex; align-items: baseline; gap: 10px; padding-bottom: 12px; margin-bottom: 11px; border-bottom: 1px solid var(--c-line); font-size: 13px; line-height: 18.2px; }
.widget-categories li:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.widget-categories li::before { content: ""; width: 4.19px; height: 12px; background: currentColor; -webkit-mask: var(--i-chevron) center/contain no-repeat; mask: var(--i-chevron) center/contain no-repeat; align-self: center; }
.widget-categories .count { margin-left: auto; color: var(--c-muted); }
.recent-item { display: flex; gap: 20px; padding-bottom: 20px; margin-bottom: 20px; border-bottom: 1px solid var(--c-line); }
.recent-item:last-child { border-bottom: 0; margin-bottom: 0; padding-bottom: 0; }
.recent-thumb { flex: 0 0 120px; height: 80px; background: var(--c-bg-soft); overflow: hidden; } .recent-thumb img { width: 100%; height: 100%; object-fit: cover; }
.recent-item h3 { font: 700 16px/22.4px var(--font-heading); margin-top: -1px; }
.recent-item time { display: block; margin-top: 3px; line-height: 15.6px; }
.widget-banner { display: flex; justify-content: center; } .widget-banner img { width: 300px; }

/* ---------- 文章頁（數值來源：Figma 2:1318） ---------- */
.single-header { text-align: center; }
.single-header .post-cats { padding-bottom: 5px; }
.single-header .post-title { font-size: 32px; line-height: 43.2px; padding-top: 6px; }
.post-byline { margin-top: 6px; line-height: 18.5px; } .post-byline .author { color: var(--c-text); } .post-byline .sep { margin: 0 10px; opacity: .7; }
.single-thumb { margin-top: 26px; background: var(--c-bg-soft); } .single-thumb img { width: 100%; }
.single-post-article .entry-content { margin-top: 43px; }
.single-post-article .post-meta-bar { justify-content: center; gap: 29px; margin-top: 33px; border-bottom: 0; }
.single-post-article .post-meta-bar .post-views { border: 0; padding: 0; line-height: 19px; }
.single-post-article .post-meta-bar .share { margin-left: 0; }
.post-views strong { color: var(--c-text); font-style: italic; font-weight: 700; margin-left: 6px; }
.author-box { display: flex; gap: 20px; align-items: flex-start; padding: 38px 0 36px; border-top: 1px solid var(--c-line); }
.author-avatar { flex: 0 0 100px; width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.author-name { font: 700 14px/18.9px var(--font-heading); text-transform: uppercase; }
.author-bio { margin-top: 15px; font-size: 13px; line-height: 23.4px; } .author-bio a { text-decoration: underline; }
.related { padding: 36px 0; border-top: 1px solid var(--c-line); }
.related-title { font: 700 18px/24.3px var(--font-heading); text-align: center; text-transform: uppercase; margin-bottom: 30px; }
.related-track { display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 2 * var(--gap)) / 3); gap: var(--gap); overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.related-track::-webkit-scrollbar { display: none; }
.related-item { scroll-snap-align: start; text-align: center; min-width: 0; }
.related-item img, .related-placeholder { display: block; width: 100%; aspect-ratio: 247/164; object-fit: cover; background: var(--c-bg-soft); }
.related-item h3 { margin-top: 17px; font: 700 12px/16.8px var(--font-heading); text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.related-item time { display: block; margin-top: 6px; }
.related-dots { display: flex; justify-content: center; gap: 12px; margin-top: 18px; }
.related-dots button { width: 8px; height: 8px; border-radius: 50%; border: 1px solid var(--c-muted); position: relative; }
.related-dots button::after { content: ""; position: absolute; inset: -10px; }
.related-dots button.is-active { background: var(--c-text); border-color: var(--c-text); }

/* ---------- 彙整、404 ---------- */
.archive-header { margin-bottom: 40px; }
.archive-title { padding: 8px 12px 7px; background: var(--c-bg-soft); font: 700 16px/1.5 var(--font-heading); text-align: center; text-transform: uppercase; }
.error-404 { text-align: center; padding: 20px 0 40px; } .error-404 .post-title { font-size: 24px; line-height: 1.4; margin-bottom: 16px; } .error-404 .search-form { max-width: 400px; margin: 20px auto 0; }

/* ---------- 頁尾 ---------- */
.site-footer { background: var(--c-bg-soft); padding: 20px 24px 22px; text-align: center; color: var(--c-faint); }
.site-copyright { font-size: 13px; line-height: 18.2px; } .site-copyright em { font-style: italic; }
.back-to-top { display: inline-block; margin-top: 16px; padding: 4px 8px; font: 700 12px/12px var(--font-heading); text-transform: uppercase; }
.back-to-top::before { content: ""; display: block; width: 12px; height: 8px; margin: 0 auto 6px; background: currentColor; -webkit-mask: var(--i-up) center/contain no-repeat; mask: var(--i-up) center/contain no-repeat; }

/* ---------- 平板與手機 ---------- */
@media (max-width: 1218px) {
  .site-layout { grid-template-columns: minmax(0, 1fr) min(var(--w-side), 32%); column-gap: 40px; }
  .post-item { grid-template-columns: 46% minmax(0, 1fr); }
}
@media (max-width: 960px) {
  .site-layout { grid-template-columns: minmax(0, 1fr); row-gap: 56px; padding-top: 40px; }
  .site-sidebar { width: 100%; max-width: 560px; margin-inline: auto; }
  .nav-toggle { display: block; margin-left: -11px; }
  .site-nav { display: none; position: absolute; left: -24px; right: -24px; top: 100%; z-index: 20; padding: 8px 24px 16px; background: var(--c-bg); border-bottom: 1px solid var(--c-line-soft); }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; gap: 0; }
  .site-nav a { line-height: 44px; font-size: 14px; }
  .site-nav .sub-menu, .site-nav li:hover > .sub-menu { display: flex; position: static; border: 0; padding: 0 0 0 16px; min-width: 0; }
  .site-nav .menu-item-has-children > a::after { display: none; }
}
@media (max-width: 600px) {
  .site-container { max-width: calc(100% - 32px); }
  .site-nav { left: -16px; right: -16px; padding-inline: 16px; }
  .site-branding { padding: 28px 0; } .site-title img { width: 200px; height: auto; }
  body { font-size: 16px; line-height: 1.8; }
  .post-full .post-title { font-size: 22px; line-height: 1.4; }
  .single-header .post-title { font-size: 24px; line-height: 1.4; }
  .post-item { grid-template-columns: minmax(0, 1fr); padding-bottom: 28px; margin-bottom: 28px; }
  .post-item-body { padding: 18px 0 0; }
  .post-excerpt { font-size: 14px; line-height: 1.75; }
  .post-meta-bar { flex-wrap: wrap; row-gap: 8px; }
  .related-track { grid-auto-columns: calc((100% - var(--gap)) / 2); }
  .author-box { gap: 16px; } .author-avatar { flex-basis: 64px; width: 64px; height: 64px; }
  .site-search { left: 0; width: auto; }
  .entry-content h2 { font-size: 20px; } .entry-content h3 { font-size: 18px; }
}
