/* 設計 tokens：霧灰紙張、墨色文字、藍染靛藍作為唯一的強調色 */
:root {
  --paper: #eef1f2;
  --ink: #1c2430;
  --muted: #66707d;
  --indigo: #2d3f74;
  --rule: #cfd6dd;
  --code: #e2e7ea;
  --danger: #a33a3a;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --radius: 14px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #111419;
    --ink: #e3e7ed;
    --muted: #9aa4b1;
    --indigo: #9db0e6;
    --rule: #2c333d;
    --code: #1a1f27;
    --danger: #e08a8a;
  }
}

:root[data-theme="dark"] {
  --paper: #111419;
  --ink: #e3e7ed;
  --muted: #9aa4b1;
  --indigo: #9db0e6;
  --rule: #2c333d;
  --code: #1a1f27;
  --danger: #e08a8a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.0625rem;
  line-height: 1.95;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--indigo); text-decoration: none; text-underline-offset: 0.2em; }
a:hover { text-decoration: underline; }

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

/* ---------- 頁首 / 頁尾 ---------- */
/* 頁首是整條靛藍色橫幅；內容對齊閱讀欄寬，所以左右留白會隨螢幕寬度變化 */
.site-header {
  background: var(--indigo);
  color: var(--paper);
  padding: 2.75rem max(1.25rem, calc((100% - 60rem) / 2 + 1.25rem)) 2.25rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
  font-family: var(--sans);
}
.site-title {
  font-family: var(--serif);
  font-weight: 700;
  font-size: 2rem;
  line-height: 1.2;
  letter-spacing: 0.02em;
  color: var(--paper);
}
.site-title:hover { text-decoration: none; color: var(--paper); opacity: 0.85; }
.site-header nav {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  font-size: 0.9rem;
}
.site-header nav a { color: var(--paper); opacity: 0.8; }
.site-header nav a:hover { opacity: 1; text-decoration: underline; }
.site-header :focus-visible { outline-color: var(--paper); }

.container {
  max-width: 60rem;
  margin: 0 auto;
  padding: 2.75rem 1.25rem 3rem;
}

.site-footer {
  max-width: 60rem;
  margin: 4rem auto 0;
  padding: 1.5rem 1.25rem 2.5rem;
  border-top: 1px solid var(--rule);
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.8rem;
}
.site-footer p { margin: 0; }

/* ---------- 標題與首頁 ---------- */
h1 {
  font-size: 2rem;
  line-height: 1.35;
  font-weight: 700;
  margin: 0 0 0.75rem;
  letter-spacing: 0.01em;
}
h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
}

.intro { margin-bottom: 2.75rem; }
.intro p {
  margin: 0;
  color: var(--ink);
  font-size: 1.4rem;
  line-height: 1.6;
}

/* 文章列表：左側一條細線串起時間，每篇文章是一個圓點 */
.post-list {
  list-style: none;
  margin: 0;
  padding: 0 0 0 2rem;
  border-left: 1px solid var(--rule);
}
.post-list li {
  position: relative;
  display: grid;
  grid-template-columns: 6.5rem 1fr;
  gap: 0.2rem 1rem;
  align-items: baseline;
  padding: 0.9rem 0;
}
.post-list li::before {
  content: "";
  position: absolute;
  left: calc(-2rem - 5.5px);
  top: 1.45rem;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--indigo);
  box-shadow: 0 0 0 4px var(--paper);
}
.post-list time {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.post-list a {
  color: var(--ink);
  font-size: 1.25rem;
  line-height: 1.5;
}
.post-list a:hover { color: var(--indigo); }

/* ---------- 文章 ---------- */
.post h1 { margin-top: 0.25rem; font-size: 2.25rem; line-height: 1.3; }
.meta {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--muted);
  margin: 0;
}
.post-actions {
  margin-top: 3rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}

.prose p,
.prose li { font-size: 1.0625rem; }
.prose h2 { margin-top: 2.5rem; }
.prose h3 { font-size: 1.05rem; margin-top: 2rem; }
.prose del { color: var(--muted); }

.prose blockquote {
  margin: 1.75rem 0;
  padding: 0.1rem 0 0.1rem 1.1rem;
  border-left: 2px solid var(--indigo);
  color: var(--muted);
}

.prose img,
.prose video,
.prose iframe {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius);
}
.prose video { display: block; width: 100%; margin: 1.25rem 0; }
.prose audio { display: block; width: 100%; margin: 1.25rem 0; }

/* YouTube 等嵌入影片：維持 16:9 */
.embed {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  margin: 1.5rem 0;
}
.embed iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

pre {
  background: var(--code);
  border-left: 3px solid var(--indigo);
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.6;
}
code { font-family: ui-monospace, Consolas, monospace; font-size: 0.92em; }
p code, li code { background: var(--code); padding: 0.05em 0.35em; border-radius: var(--radius); }

/* ---------- 輪播圖 ---------- */
.carousel {
  position: relative;
  margin: 1.75rem 0;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--code);
}
.carousel-track {
  display: flex;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.carousel-track::-webkit-scrollbar { display: none; }
.carousel .slide {
  flex: 0 0 100%;
  margin: 0;
  scroll-snap-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 360px;
}
.carousel .slide img {
  max-width: 100%;
  max-height: 360px;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 0;
}
.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 26, 36, 0.55);
  color: #fff;
  font-size: 1.4rem;
  line-height: 36px;
  text-align: center;
  cursor: pointer;
}
.carousel-btn:hover { background: rgba(20, 26, 36, 0.8); }
.carousel-btn.prev { left: 10px; }
.carousel-btn.next { right: 10px; }
.carousel-count {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 1px 9px;
  border-radius: 999px;
  background: rgba(20, 26, 36, 0.6);
  color: #fff;
  font-family: var(--sans);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

/* ---------- 表單 / 編輯器 ---------- */
input, textarea, button {
  font: inherit;
  color: inherit;
}
input[type="text"], input[type="password"], input[type="date"], input:not([type]), textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--sans);
  font-size: 0.95rem;
}
.title-input {
  font-family: var(--serif) !important;
  font-size: 1.6rem !important;
  font-weight: 700;
  padding: 0.25rem 0 !important;
  border: 0 !important;
  border-bottom: 1px solid var(--rule) !important;
  border-radius: 0 !important;
  background: transparent;
}
textarea {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.92rem;
  line-height: 1.7;
  resize: vertical;
}

button,
.btn-like {
  display: inline-block;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--sans);
  font-size: 0.88rem;
  cursor: pointer;
}
button:hover { border-color: var(--indigo); color: var(--indigo); }
button[type="submit"] {
  background: var(--indigo);
  border-color: var(--indigo);
  color: var(--paper);
}
button[type="submit"]:hover { color: var(--paper); filter: brightness(1.1); }
button.danger { color: var(--danger); }
button.link-btn {
  border: 0;
  padding: 0;
  color: var(--muted);
  margin-left: 0.5rem;
}
button.link-btn:hover { color: var(--indigo); background: none; }

.editor { display: grid; gap: 1rem; }
.row { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }
.editor label {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.88rem;
  color: var(--muted);
}
.editor .check { color: var(--ink); }
.toolbar { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.format-bar button { min-width: 2.4rem; padding: 0.35rem 0.6rem; }

.panel { display: grid; gap: 1rem; max-width: 22rem; }
.panel label { display: grid; gap: 0.4rem; font-family: var(--sans); font-size: 0.9rem; }

.preview {
  border-top: 1px dashed var(--rule);
  border-bottom: 1px dashed var(--rule);
  padding: 1rem 0;
}

.error { color: var(--danger); margin: 0; font-family: var(--sans); font-size: 0.9rem; }
.ok { color: var(--indigo); margin: 0; font-family: var(--sans); font-size: 0.9rem; }
.muted { color: var(--muted); }

/* 草稿：只用文字與細框，不做膠囊標籤 */
.tag {
  margin-left: 0.5rem;
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--indigo);
}

@media (max-width: 480px) {
  body { font-size: 1rem; }
  h1 { font-size: 1.65rem; }
  .post-list { padding-left: 1.5rem; }
  .post-list li { grid-template-columns: 1fr; gap: 0.1rem; }
  .post-list li::before { left: calc(-1.5rem - 5.5px); }
  .site-title { font-size: 1.6rem; }
  .intro p { font-size: 1.2rem; }
  .carousel .slide, .carousel .slide img { height: 240px; max-height: 240px; }
  .carousel-btn { width: 30px; height: 30px; line-height: 30px; font-size: 1.1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .carousel-track { scroll-behavior: auto; }
}

/* ---------- 版面：主欄 + 側欄 ---------- */
/* 文章內頁、編輯器維持約 40rem 的閱讀寬度 */
.post,
.editor,
.panel { max-width: 40rem; }

.layout {
  display: grid;
  grid-template-columns: minmax(0, 40rem) 15rem;
  gap: 3.5rem;
  align-items: start;
}
.sidebar {
  position: sticky;
  top: 1.5rem;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.sidebar h2 {
  font-family: var(--sans);
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.6rem;
}
.sidebar p { margin: 0 0 0.6rem; color: var(--muted); line-height: 1.7; }
.sidebar section + section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
.recent { list-style: none; margin: 0; padding: 0; }
.recent li { padding: 0.35rem 0; }
.recent a { color: var(--ink); line-height: 1.5; }
.recent a:hover { color: var(--indigo); }

/* 列表縮圖：有圖片的文章，右側顯示封面 */
.post-list li.has-cover {
  grid-template-columns: 6.5rem 1fr 4.5rem;
}
.post-list .thumb {
  grid-column: 3;
  grid-row: 1 / span 3;
  width: 4.5rem;
  height: 4.5rem;
  object-fit: cover;
  border-radius: var(--radius);
  align-self: start;
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; gap: 2.5rem; }
  .sidebar { position: static; }
}

@media (max-width: 480px) {
  .post-list li.has-cover { grid-template-columns: 1fr 4rem; }
  .post-list li.has-cover > time,
  .post-list li.has-cover > a { grid-column: 1; }
  .post-list .thumb { grid-column: 2; grid-row: 1 / span 3; width: 4rem; height: 4rem; }
}

/* ---------- 卡片列表 ---------- */
/* 卡片統一直角與細框，不用陰影；hover 只改邊框顏色 */
.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
  gap: 1.25rem;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--paper) 94%, var(--ink));
  overflow: hidden;
  transition: border-color 0.2s ease;
}
.card:hover { border-color: var(--indigo); }
.card:has(.card-title:focus-visible) { outline: 2px solid var(--indigo); outline-offset: 2px; }

.card-cover {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
}
.card-bar {
  height: 0.3rem;
  background: var(--indigo);
}

.card-body {
  display: grid;
  gap: 0.4rem;
  padding: 1rem 1.1rem 1.2rem;
}
.card time {
  font-family: var(--sans);
  font-size: 0.8rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
/* 整張卡片都可以點：標題的連結延伸到整個卡片 */
.card-title {
  color: var(--ink);
  font-size: 1.1rem;
  line-height: 1.5;
}
.card-title::after {
  content: "";
  position: absolute;
  inset: 0;
}
.card-title:hover { color: var(--indigo); text-decoration: none; }
.card-title:focus-visible { outline: none; }
.card p {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--muted);
}
.card .tag { justify-self: start; }

/* ---------- 編輯器：封面圖 ---------- */
.cover-field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.6rem 1rem;
  align-items: center;
  font-family: var(--sans);
  font-size: 0.88rem;
}
.cover-label { color: var(--muted); }
.cover-box { min-width: 0; }
.cover-box img {
  display: block;
  width: 9rem;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
}
.cover-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
@media (max-width: 480px) {
  .cover-field { grid-template-columns: 1fr; }
}

/* ---------- 分類 ---------- */
.category-head { margin-bottom: 2.5rem; }
.category-head h1 { margin-bottom: 0.5rem; }
.category-head p { margin: 0; color: var(--muted); font-size: 1.1rem; }

.editor select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: transparent;
  font-family: var(--sans);
  font-size: 0.9rem;
}

/* ==========================================================
   首頁：遊戲官網式版面
   固定色彩不跟明暗模式變化，讓大封面與色塊的氣氛穩定
   ========================================================== */
:root {
  --brand: #2d3f74;
  --brand-hover: #3b508f;
  --brand-ink: #f4f6f8;
  --brand-accent: #f2b544;
}

/* 首頁：頁首透明疊在大封面上 */
body.home.has-hero .site-header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  background: transparent;
  border-bottom: 0;
  color: var(--brand-ink);
}
body.home.has-hero .site-title { color: var(--brand-ink); }
body.home.has-hero .site-header nav a { color: var(--brand-ink); opacity: 0.85; }
body.home.has-hero .site-header nav a:hover { opacity: 1; }
body.home.has-hero .container { padding-top: 0; }

/* 整幅封面：寬度撐滿整個視窗 */
.hero {
  position: relative;
  display: flex;
  align-items: flex-end;
  width: 100vw;
  margin: 0 0 0 calc(50% - 50vw);
  min-height: min(84vh, 46rem);
  background: var(--brand);
  color: var(--brand-ink);
  overflow: hidden;
  text-decoration: none;
}
.hero:hover { text-decoration: none; }
.hero-cover {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 0;
  margin: 0;
}
/* 文字區的壓暗遮罩：只為了讓白字看得清楚 */
.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8, 12, 22, 0.92) 0%, rgba(8, 12, 22, 0.5) 50%, rgba(8, 12, 22, 0.1) 100%);
}
.hero-plain::after { display: none; }

.hero-text {
  position: relative;
  z-index: 1;
  width: 100%;
  padding: 0 max(1.25rem, calc((100% - 60rem) / 2 + 1.25rem)) 3.5rem;
}
.hero-text time {
  display: block;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: rgba(244, 246, 248, 0.8);
  font-variant-numeric: tabular-nums;
}
.hero-title {
  margin: 0.4rem 0 1rem;
  max-width: 16em;
  font-family: var(--sans);
  font-weight: 900;
  font-size: clamp(2.4rem, 6vw, 4.6rem);
  line-height: 1.12;
  letter-spacing: -0.01em;
  color: var(--brand-ink);
}
.hero:hover .hero-title { color: var(--brand-accent); }
.hero-text p {
  max-width: 34rem;
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.7;
  color: rgba(244, 246, 248, 0.88);
}
.hero-cta {
  display: inline-block;
  margin-top: 1.5rem;
  padding: 0.8rem 1.4rem;
  border-radius: var(--radius);
  background: var(--brand-accent);
  color: #1a1405;
  font-family: var(--sans);
  font-weight: 700;
}

/* 標題只做一次進場動畫，其他元素不動 */
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: none; }
}
.hero-text > * { animation: rise 0.9s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.hero-text > *:nth-child(2) { animation-delay: 0.12s; }
.hero-text > *:nth-child(3) { animation-delay: 0.22s; }
.hero-text > *:nth-child(4) { animation-delay: 0.32s; }

/* 分類色塊 */
.tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 3.5rem;
}
.tile {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 13rem;
  padding: 1.75rem 1.5rem 1.5rem;
  background: var(--brand);
  color: var(--brand-ink);
  text-decoration: none;
  transition: background-color 0.2s ease;
}
.tile + .tile { border-left: 1px solid rgba(255, 255, 255, 0.12); }
.tile:hover { background: var(--brand-hover); text-decoration: none; }
.tile:focus-visible { outline-offset: -4px; }
.tile-name {
  margin-top: auto;
  font-family: var(--sans);
  font-weight: 900;
  font-size: 2.2rem;
  line-height: 1.1;
}
.tile-desc { font-size: 0.95rem; line-height: 1.6; opacity: 0.8; }
.tile-count {
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--brand-accent);
}

/* 年份標題也改用粗體無襯線，和首頁的氣氛一致 */
.year-num {
  font-family: var(--sans);
  font-weight: 900;
  font-size: 4.2rem;
}

@media (max-width: 700px) {
  .tiles { grid-template-columns: 1fr; }
  .tile + .tile { border-left: 0; border-top: 1px solid rgba(255, 255, 255, 0.12); }
  .tile { min-height: 0; }
  .tile-name { font-size: 1.8rem; }
  .hero { min-height: 30rem; }
  .year-num { font-size: 3.2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .hero-text > * { animation: none; }
}

/* 首頁左欄的圖片 */
.side-art { margin: 0 0 2.75rem; }
.side-art img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--radius);
}

/* ==========================================================
   圓角與分類色塊（後面的規則會蓋過前面的同名設定）
   ========================================================== */

/* 按鈕改成膠囊形 */
button,
.btn-like { border-radius: 999px; }

/* 頁首在非首頁時，下緣做圓角 */
body:not(.home) .site-header {
  border-radius: 0 0 28px 28px;
}

/* 首頁的 CTA 按鈕也是膠囊形 */
.hero-cta { border-radius: 999px; }

/* 分類色塊：獨立的圓角卡片，彼此有間距，各自有顏色 */
.tiles { gap: 1rem; }
.tile {
  border-radius: 22px;
  border: 0;
  background: var(--tile);
  color: var(--tile-ink);
}
.tile + .tile { border: 0; }
.tile:hover {
  background: var(--tile);
  filter: brightness(1.08);
}
.tile-count { color: inherit; opacity: 0.85; }

.tile-life { --tile: #c4553a; --tile-ink: #ffffff; }
.tile-invest { --tile: #1f7a6d; --tile-ink: #ffffff; }
.tile-projects { --tile: #c9962a; --tile-ink: #1a1405; }

@media (max-width: 700px) {
  .tiles { gap: 0.75rem; }
  .tile + .tile { border-top: 0; }
}

/* ---------- 市場資料區塊（投資分類頁） ---------- */
.market {
  margin: 0 0 3rem;
  padding: 1.75rem 1.75rem 1.5rem;
  border-radius: 22px;
  background: color-mix(in srgb, var(--paper) 92%, var(--ink));
  border: 1px solid var(--rule);
}
.market-label {
  margin: 0;
  font-family: var(--sans);
  font-size: 0.9rem;
  color: var(--muted);
}
.market-value {
  margin: 0.25rem 0 0.5rem;
  font-family: var(--sans);
  font-weight: 900;
  font-size: 3.6rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  color: var(--indigo);
}
.market-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.25rem;
  margin: 0;
  font-family: var(--sans);
  font-size: 0.9rem;
}
.market-source {
  margin: 0.9rem 0 0;
  font-family: var(--sans);
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.6;
}

/* 多個市場指標並排時，用分隔線區分 */
.market-item + .market-item {
  margin-top: 1.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
}
