/* ============================================================
   style.css — 白紙紅字
   日間:白底 / 黑字 / 信號紅
   夜間:黑底 / 米白字 / 亮紅
   自訂顏色只要改 :root 與 [data-theme="dark"] 兩處
   ============================================================ */

:root {
  --bg: #ffffff;
  --ink: #000000;
  --red: #e60012;
  --muted: #6e6e6e;
  --card-line: #000000;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --w: 1160px;
}

[data-theme="dark"] {
  --bg: #000000;
  --ink: #f2efe9;
  --red: #ff2b1f;
  --muted: #9a9a9a;
  --card-line: #f2efe9;
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 17px;
  line-height: 1.9;
  transition: background-color .35s ease, color .35s ease;
}

img { display: block; max-width: 100%; }

a { color: inherit; text-decoration: none; }

:focus-visible {
  outline: 3px solid var(--red);
  outline-offset: 3px;
}

.wrap {
  max-width: var(--w);
  margin: 0 auto;
  padding: 0 28px;
}

.vert {
  writing-mode: vertical-rl;
  text-orientation: mixed;
}

/* ---------- 置頂導覽 ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg);
  border-bottom: 2px solid var(--ink);
  transition: background-color .35s ease, border-color .35s ease;
}

.topbar .wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  height: 64px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--serif);
  font-weight: 900;
  font-size: 1.25rem;
  letter-spacing: .12em;
}

.brand::before {
  content: "";
  width: 14px;
  height: 14px;
  background: var(--red);
  flex: none;
}

.topnav {
  display: flex;
  gap: 4px;
  margin-left: auto;
  font-family: var(--sans);
  font-size: .92rem;
  overflow-x: auto;
}

.topnav a {
  padding: 8px 12px;
  white-space: nowrap;
}

.topnav a:hover { color: var(--red); }

.theme-btn {
  flex: none;
  width: 40px;
  height: 40px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-family: var(--serif);
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

.theme-btn:hover {
  background: var(--ink);
  color: var(--bg);
}

/* ---------- 精選作品 ---------- */

.hero {
  padding: 72px 0 88px;
}

.hero .wrap {
  display: grid;
  grid-template-columns: auto 1fr minmax(250px, 330px);
  gap: 56px;
  align-items: start;
}

.hero-title {
  font-weight: 900;
  font-size: clamp(2.6rem, 5.4vw, 4.4rem);
  line-height: 1.28;
  letter-spacing: .06em;
  max-height: 480px;
}

.hero-title .ch { display: inline-block; }

.hero-body { padding-top: 10px; max-width: 34em; }

.hero-meta {
  font-family: var(--sans);
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 20px;
}

.hero-meta .status { color: var(--red); margin-left: 1em; }

.hero-rule {
  width: 56px;
  height: 5px;
  background: var(--red);
  margin-bottom: 26px;
}

.hero-excerpt {
  font-size: 1.12rem;
  margin-bottom: 36px;
}

.btn {
  display: inline-block;
  background: var(--red);
  color: #fff;
  font-family: var(--sans);
  font-weight: 700;
  font-size: .95rem;
  letter-spacing: .14em;
  padding: 13px 34px;
  border: none;
  cursor: pointer;
  transition: background-color .25s ease;
}

.btn:hover { background: var(--ink); color: var(--bg); }

.hero-cover {
  aspect-ratio: 3 / 4;
  box-shadow: 14px 14px 0 var(--red);
  margin-bottom: 14px;
}

.hero-cover img,
.hero-cover .text-cover { width: 100%; height: 100%; }

.hero-cover img { object-fit: cover; }

/* ---------- 最新更新 ---------- */

.latest { padding-bottom: 84px; }

.sec-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 30px;
}

.sec-head h2 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: .1em;
}

.sec-head .note {
  font-family: var(--sans);
  font-size: .85rem;
  color: var(--muted);
}

.latest-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 40px;
}

.latest-item { border-top: 2px solid var(--ink); padding-top: 16px; }

.latest-item time {
  display: block;
  font-family: var(--sans);
  font-size: .82rem;
  color: var(--red);
  margin-bottom: 6px;
}

.latest-item h3 { font-size: 1.1rem; font-weight: 700; line-height: 1.5; }

.latest-item:hover h3 { color: var(--red); }

.latest-item .cat {
  font-family: var(--sans);
  font-size: .82rem;
  color: var(--muted);
  margin-top: 6px;
}

/* ---------- 作品索引:頁籤 ---------- */

.works { padding-bottom: 60px; }

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--ink);
  margin-bottom: 56px;
  overflow-x: auto;
}

.tab {
  font-family: var(--sans);
  font-size: .98rem;
  font-weight: 500;
  background: none;
  border: none;
  color: var(--ink);
  padding: 12px 20px 14px;
  cursor: pointer;
  position: relative;
  white-space: nowrap;
}

.tab::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 4px;
  background: transparent;
}

.tab:hover { color: var(--red); }

.tab[aria-selected="true"] {
  color: var(--red);
  font-weight: 700;
}

.tab[aria-selected="true"]::after { background: var(--red); }

/* ---------- 作品索引:分區與卡片 ---------- */

.group { margin-bottom: 72px; }

.group-head {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 28px;
}

.group-head h2 { font-size: 1.35rem; font-weight: 900; letter-spacing: .1em; }

.group-head .note { font-family: var(--sans); font-size: .85rem; color: var(--muted); }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 44px 28px;
}

.card { display: block; }

.card .cover-box {
  aspect-ratio: 3 / 4;
  margin-bottom: 14px;
  overflow: hidden;
}

.card .cover-box img { width: 100%; height: 100%; object-fit: cover; }

.card:hover .cover-box { box-shadow: 8px 8px 0 var(--red); }

.card h3 { font-size: 1.06rem; font-weight: 700; line-height: 1.5; }

.card:hover h3 { color: var(--red); }

.card .meta {
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--muted);
  margin-top: 5px;
}

.card .meta .status { color: var(--red); margin-left: .9em; }

.card .ex {
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.75;
  margin-top: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---------- 文字封面(無圖作品) ---------- */

.text-cover {
  width: 100%;
  height: 100%;
  position: relative;
  display: flex;
  overflow: hidden;
}

.text-cover .tc-title {
  writing-mode: vertical-rl;
  text-orientation: mixed;
  font-weight: 900;
  font-size: clamp(1.15rem, 1.6vw, 1.5rem);
  line-height: 1.4;
  letter-spacing: .14em;
  max-height: 78%;
  margin: 11% 13% 0 auto;
}

.text-cover .seal {
  position: absolute;
  left: 11%;
  bottom: 8%;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  font-family: var(--sans);
  font-weight: 700;
  font-size: .85rem;
  background: var(--red);
  color: #fff;
}

/* 樣式一:紙面直排 */
.tcv1 {
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--card-line);
}

/* 樣式二:紅底反白 */
.tcv2 { background: var(--red); color: #fff; }
.tcv2 .seal { background: #fff; color: var(--red); }

/* 樣式三:黑底紅字 */
.tcv3 { background: #000; color: #ff2b1f; }
[data-theme="dark"] .tcv3 { border: 2px solid var(--red); }

/* 樣式四:巨型首字 */
.tcv4 {
  background: var(--bg);
  color: var(--ink);
  border: 2px solid var(--card-line);
}

.tcv4 .tc-initial {
  position: absolute;
  top: -0.12em;
  right: 2%;
  font-weight: 900;
  font-size: 8.5rem;
  line-height: 1;
  color: var(--red);
}

.tcv4 .tc-title {
  writing-mode: horizontal-tb;
  font-size: 1rem;
  letter-spacing: .1em;
  max-height: none;
  margin: auto 12% 16% 12%;
  align-self: flex-end;
}

/* ---------- 關於作者 ---------- */

.about {
  background: var(--red);
  color: #fff;
  padding: 76px 0;
  margin-top: 40px;
}

.about .wrap {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 56px;
  align-items: start;
}

.about h2 {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: .12em;
  max-height: 300px;
}

.about p { max-width: 34em; font-size: 1.05rem; margin-bottom: 20px; }

.about .contact {
  font-family: var(--sans);
  font-size: .92rem;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.about .contact a {
  border-bottom: 2px solid rgba(255, 255, 255, .55);
  padding-bottom: 2px;
}

.about .contact a:hover { border-color: #fff; }

/* ---------- 頁尾 ---------- */

.footer {
  background: #000;
  color: #f2efe9;
  padding: 56px 0 40px;
}

[data-theme="dark"] .footer { border-top: 2px solid var(--red); }

.footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 32px;
  align-items: baseline;
  justify-content: space-between;
}

.footer .f-brand {
  font-weight: 900;
  font-size: 1.15rem;
  letter-spacing: .12em;
}

.footer .f-brand::before {
  content: "";
  display: inline-block;
  width: 11px;
  height: 11px;
  background: var(--red);
  margin-right: 10px;
}

.footer nav {
  display: flex;
  gap: 22px;
  font-family: var(--sans);
  font-size: .88rem;
}

.footer nav a:hover { color: #ff2b1f; }

.footer .copy {
  width: 100%;
  font-family: var(--sans);
  font-size: .78rem;
  color: #8b8b8b;
  margin-top: 8px;
}

/* ---------- 閱讀頁 ---------- */

.article { padding: 72px 0 40px; }

.article-head { max-width: 720px; margin: 0 auto 48px; }

.article-head .meta {
  font-family: var(--sans);
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 18px;
}

.article-head .meta .status { color: var(--red); margin-left: 1em; }

.article-head h1 {
  font-size: clamp(1.9rem, 4.5vw, 3rem);
  font-weight: 900;
  line-height: 1.45;
  letter-spacing: .04em;
  margin-bottom: 24px;
}

.article-head .rule { width: 56px; height: 5px; background: var(--red); }

.article-cover {
  max-width: 720px;
  margin: 0 auto 48px;
}

.article-body {
  max-width: 660px;
  margin: 0 auto;
  font-size: 1.08rem;
  line-height: 2.1;
}

.article-body p { margin-bottom: 1.6em; text-align: justify; }

.article-body h2 {
  font-size: 1.3rem;
  font-weight: 900;
  margin: 2.4em 0 1em;
}

.article-body .load-error {
  font-family: var(--sans);
  font-size: .95rem;
  border: 2px solid var(--red);
  padding: 20px 24px;
}

/* 章節目錄 */
.toc {
  max-width: 660px;
  margin: 0 auto;
  list-style: none;
}

.toc li { border-top: 2px solid var(--ink); }

.toc li:last-child { border-bottom: 2px solid var(--ink); }

.toc a {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 18px 6px;
}

.toc a:hover { color: var(--red); }

.toc .no {
  font-family: var(--sans);
  font-weight: 700;
  font-size: .85rem;
  color: var(--red);
  flex: none;
}

.toc .t { font-weight: 700; font-size: 1.1rem; }

/* 上下篇/上下章 */
.pager {
  max-width: 660px;
  margin: 72px auto 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  border-top: 2px solid var(--ink);
  padding-top: 28px;
}

.pager a { display: block; }

.pager .dir {
  font-family: var(--sans);
  font-size: .8rem;
  color: var(--red);
  margin-bottom: 6px;
}

.pager .pt { font-weight: 700; line-height: 1.5; }

.pager a:hover .pt { color: var(--red); }

.pager .next { text-align: right; }

.back-index {
  max-width: 660px;
  margin: 40px auto 0;
  font-family: var(--sans);
  font-size: .9rem;
  text-align: center;
}

.back-index a { border-bottom: 2px solid var(--red); padding-bottom: 2px; }

.article-foot { padding-bottom: 96px; }

/* ---------- 進場動畫(僅首頁一次) ---------- */

@media (prefers-reduced-motion: no-preference) {
  .hero-title .ch {
    opacity: 0;
    transform: translateY(8px);
    animation: chin .5s ease forwards;
  }
  @keyframes chin {
    to { opacity: 1; transform: none; }
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

/* ---------- 響應式 ---------- */

@media (max-width: 980px) {
  .hero .wrap {
    grid-template-columns: 1fr minmax(220px, 280px);
    gap: 40px;
  }
  .hero-title {
    writing-mode: horizontal-tb;
    grid-column: 1 / -1;
    max-height: none;
    margin-bottom: 8px;
  }
  .latest-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 700px) {
  body { font-size: 16px; }
  .hero { padding: 48px 0 64px; }
  .hero .wrap { grid-template-columns: 1fr; }
  .hero-cover { max-width: 320px; }
  .latest-grid { grid-template-columns: 1fr; gap: 24px; }
  .cards { grid-template-columns: repeat(2, 1fr); gap: 32px 18px; }
  .about .wrap { grid-template-columns: 1fr; gap: 28px; }
  .about h2 { writing-mode: horizontal-tb; max-height: none; }
  .topnav { gap: 0; }
  .topnav a { padding: 8px 9px; font-size: .88rem; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { text-align: left; }
}

@media (max-width: 420px) {
  .cards { grid-template-columns: 1fr 1fr; gap: 24px 14px; }
  .card .ex { display: none; }
  .tcv4 .tc-initial { font-size: 6.5rem; }
}
