/* ========================================
   Y的世界 — Global Stylesheet
   参考：Notion-style minimalism × 日系杂志排版
   ======================================== */

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #faf9f7;
  --surface:   #ffffff;
  --border:    #e8e4de;
  --text:      #1a1a1a;
  --muted:     #888;
  --accent:    #2d2d2d;

  /* category colours */
  --c-finance:   #4a7c59;
  --c-journey:   #5b6abf;
  --c-emotion:   #bf5b6a;
  --c-bookmovie: #8a6bbf;
  --c-milestone: #99733d;

  --radius: 12px;
  --gap: 24px;
  --max-w: 1080px;
}

html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: "LXGW WenKai Screen", "Songti SC", "Noto Serif SC", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.75;
  letter-spacing: .02em;
}

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

/* ---- Header ---- */
.site-header {
  padding: 56px 24px 46px;
  text-align: center;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.header-inner { max-width: var(--max-w); margin: 0 auto; }
.site-title {
  display: inline-block;
  font-size: clamp(2.2rem, 6vw, 4.2rem);
  font-weight: 700;
  letter-spacing: .08em;
  margin-bottom: 14px;
}
.site-philosophy {
  font-size: clamp(.9rem, 2vw, 1.05rem);
  color: var(--muted);
  letter-spacing: .18em;
}
.site-bio {
  margin-top: 18px;
  color: #777;
  font-size: .92rem;
  line-height: 1.9;
}

/* ---- Category Nav ---- */
.category-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.nav-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.cat-list {
  list-style: none;
  display: flex;
  gap: 4px;
  margin: 0;
  padding: 0;
  overflow-x: auto;
}
.cat-btn {
  cursor: pointer;
  border: 1.5px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: .88rem;
  padding: 6px 18px;
  border-radius: 999px;
  color: var(--muted);
  transition: all .18s ease;
  white-space: nowrap;
}
.cat-btn:hover {
  border-color: var(--border);
  color: var(--text);
}
.cat-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.sort-control {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #f7f5f2;
}
.sort-btn {
  cursor: pointer;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: .78rem;
  padding: 5px 12px;
  border-radius: 999px;
  transition: all .18s ease;
}
.sort-btn:hover { color: var(--text); }
.sort-btn.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

/* ---- Article Grid ---- */
.article-grid {
  max-width: var(--max-w);
  margin: 48px auto;
  padding: 0 24px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--gap);
}
.article-loading {
  grid-column: 1 / -1;
  color: var(--muted);
  text-align: center;
  padding: 60px 0;
}

/* ---- Card ---- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
  transition: transform .2s ease, box-shadow .2s ease;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px rgba(0,0,0,.08);
}
.card.hidden { display: none; }
.card-link { display: block; padding: 28px 24px 24px; }
.card-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.date { font-size: .78rem; color: var(--muted); }
.card-title {
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1.45;
  margin-bottom: 10px;
  color: var(--text);
}
.pin-badge {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 2;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff7e8;
  color: #b27616;
  border: 1px solid #eed5a7;
  font-size: .76rem;
  line-height: 1;
  box-shadow: 0 3px 10px rgba(178, 118, 22, .12);
}
.card:hover .card-title { opacity: .8; }
.card-excerpt {
  font-size: .88rem;
  color: #555;
  margin-bottom: 20px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ---- Category Badge ---- */
.cat-badge {
  display: inline-block;
  font-size: .72rem;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  color: #fff;
  letter-spacing: .04em;
}
.cat-badge.finance   { background: var(--c-finance); }
.cat-badge.journey   { background: var(--c-journey); }
.cat-badge.emotion   { background: var(--c-emotion); }
.cat-badge.bookmovie { background: var(--c-bookmovie); }
.cat-badge.milestone { background: var(--c-milestone); }

/* ---- Philosophy Tags ---- */
.tag-row { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: .7rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--muted);
  background: var(--bg);
  letter-spacing: .05em;
}

/* ---- Site Footer ---- */
.site-footer {
  text-align: center;
  padding: 48px 24px;
  font-size: .82rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}
.site-counter { margin-top: 8px; font-size: .78rem; color: #bbb; }

/* ---- Article Page ---- */
.article-page { max-width: 720px; margin: 60px auto; padding: 0 24px 80px; }
.article-page .back-link {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--muted); margin-bottom: 40px;
}
.article-page .back-link:hover { color: var(--text); }
.article-header { margin-bottom: 48px; border-bottom: 1px solid var(--border); padding-bottom: 32px; }
.article-header .cat-badge { margin-bottom: 16px; }
.article-header h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); line-height: 1.35; margin-bottom: 12px; }
.article-header .article-date { font-size: .82rem; color: var(--muted); }
.article-body { font-size: 1rem; line-height: 1.9; color: #333; }
.article-body p { margin-bottom: 1.1em; }
.article-body h2 { font-size: 1.15rem; font-weight: 700; margin-top: 2.4em; margin-bottom: 0.4em; color: var(--text); }
.article-body h3 { font-size: 1rem; font-weight: 600; margin-top: 1.4em; margin-bottom: 0.3em; color: var(--text); }
.article-body img { max-width: 100%; height: auto; border-radius: 8px; margin: 16px 0; display: block; }
.article-body hr { border: none; border-top: 1px solid var(--border); margin: 2.4em 0; }
.article-body ul,
.article-body ol { padding-left: 1.4em; margin-bottom: 1.2em; }
.article-body li { margin-bottom: 0.35em; }
.article-body > table {
  display: block;
  width: 100%;
  margin: 24px 0;
  overflow-x: auto;
  border-collapse: collapse;
  font-size: .9rem;
}
.article-body > table th,
.article-body > table td {
  padding: 10px 16px;
  border: 1px solid var(--border);
  text-align: center;
}
.article-body > table th {
  background: #f5f3f0;
  font-weight: 600;
  white-space: nowrap;
}
.article-body > table td:first-child { white-space: nowrap; }
.article-body > table tbody tr:hover { background: #f5f3f0; }
.article-body .placeholder-note {
  background: #f5f3f0;
  border-left: 3px solid var(--border);
  padding: 20px 24px;
  border-radius: 0 8px 8px 0;
  color: var(--muted);
  font-style: italic;
}
.article-body .research-table-wrap {
  width: min(100vw - 48px, 1080px);
  margin: 32px 50% 40px;
  transform: translateX(-50%);
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 30px rgba(0, 0, 0, .05);
}
.article-body .research-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: .84rem;
  line-height: 1.65;
}
.article-body .research-table th,
.article-body .research-table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: top;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.article-body .research-table th:last-child,
.article-body .research-table td:last-child { border-right: 0; }
.article-body .research-table tbody tr:last-child th,
.article-body .research-table tbody tr:last-child td { border-bottom: 0; }
.article-body .research-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f5f3f0;
  color: var(--text);
  font-weight: 700;
  white-space: nowrap;
}
.article-body .research-table tbody th {
  position: sticky;
  left: 0;
  z-index: 1;
  width: 150px;
  min-width: 150px;
  background: #fbfaf8;
  color: var(--text);
  font-weight: 700;
}
.article-body .research-table tbody tr:hover td,
.article-body .research-table tbody tr:hover th { background: #f7f5f2; }
.article-body .research-table strong { color: var(--text); }
.article-footer {
  margin-top: 56px;
  padding-top: 28px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.article-footer .label { font-size: .8rem; color: var(--muted); margin-right: 4px; }
.article-footer .tag { font-size: .8rem; }

/* ---- Movie Table ---- */
.movie-table-wrap, .journey-table-wrap { margin: 32px 0; overflow-x: auto; }
.movie-sort-bar { font-size: .85rem; color: var(--muted); margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.movie-sort-btn {
  cursor: pointer;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-family: inherit;
  font-size: .82rem;
  padding: 4px 14px;
  border-radius: 999px;
  color: var(--muted);
  transition: all .15s ease;
}
.movie-sort-btn:hover { border-color: var(--accent); color: var(--accent); }
.movie-sort-btn.sort-asc,
.movie-sort-btn.sort-desc { background: var(--accent); color: #fff; border-color: var(--accent); }
.movie-sort-btn.sort-asc::after  { content: ' ↑'; }
.movie-sort-btn.sort-desc::after { content: ' ↓'; }
.movie-table, .journey-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .92rem;
}
.movie-table th,
.movie-table td,
.journey-table th,
.journey-table td {
  padding: 10px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.movie-table th,
.journey-table th {
  font-size: .78rem;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .06em;
  background: var(--bg);
}
.movie-table tbody tr:hover,
.journey-table tbody tr:hover { background: #f5f3f0; }
.movie-table td:first-child,
.movie-table th:first-child { color: var(--muted); font-size: .78rem; width: 36px; }
.milestone-table { min-width: 620px; }
.milestone-table th,
.milestone-table td { text-align: center; }
.milestone-table th,
.milestone-table td:first-child { white-space: nowrap; }
.milestone-table td { font-variant-numeric: tabular-nums; }
.journey-table .journey-quote { font-weight: 500; color: var(--text); width: 45%; line-height: 1.65; }
.journey-table .journey-story { color: #666; font-size: .88rem; line-height: 1.65; }
.journey-table .journey-year { color: var(--muted); font-size: .82rem; white-space: nowrap; width: 56px; text-align: center; }

/* ---- Asset Allocation Chart ---- */
.asset-card {
  margin: 32px 0;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.asset-chart-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin-bottom: 22px;
}
.asset-pie-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 18px 14px;
  border-radius: 10px;
  background: #fbfaf8;
}
.asset-pie-panel h3 {
  margin: 0;
  color: var(--muted);
  font-size: .86rem;
  letter-spacing: .08em;
}
.asset-pie {
  width: 300px;
  height: 300px;
  overflow: visible;
  filter: drop-shadow(0 8px 20px rgba(0,0,0,.08));
}
.asset-pie path {
  stroke: var(--surface);
  stroke-width: 1.5;
}
.asset-label-line {
  fill: none;
  stroke: #b8b1a8;
  stroke-width: 1;
}
.asset-pie-label {
  fill: #555;
  font-family: inherit;
  font-size: 10px;
  font-weight: 700;
  dominant-baseline: auto;
}
.asset-legend-wrap { overflow-x: auto; }
.asset-legend {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.asset-legend th,
.asset-legend td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.asset-legend th {
  color: var(--muted);
  font-size: .76rem;
  font-weight: 600;
  background: var(--bg);
}
.asset-color {
  width: 10px;
  height: 10px;
  display: inline-block;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
}
.asset-diff { font-weight: 700; }
.asset-diff.positive { color: #4a7c59; }
.asset-diff.negative { color: #bf5b6a; }
.asset-diff.zero { color: var(--muted); }

/* ---- KaTeX math ---- */
.article-body .katex-display {
  margin: 1.2em 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 0;
}

/* ---- Responsive ---- */
@media (max-width: 600px) {
  .article-grid { grid-template-columns: 1fr; }
  .nav-inner { align-items: stretch; flex-direction: column; gap: 10px; }
  .cat-list { gap: 2px; }
  .cat-btn { padding: 5px 13px; }
  .sort-control { justify-content: flex-end; align-self: flex-end; }
  .asset-chart-grid { grid-template-columns: 1fr; }
  .asset-pie { width: 260px; height: 260px; }
}
