/* === Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  max-width: 700px;
  margin: 0 auto;
  padding: 40px 20px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.7;
  color: #333;
  background: #fff;
}

/* === Typography === */
h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0.5rem 0 0.25rem;
}

h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin: 0 0 1rem;
}

p {
  margin: 0.5rem 0;
  color: #444;
}

a {
  color: #0066cc;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 2rem 0;
}

/* === Hero === */
.hero {
  text-align: center;
}

.profile-photo {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  object-fit: cover;
  background: #eee;
}

.tagline {
  font-size: 1.05rem;
  color: #666;
}

/* === Social Links === */
.social-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 1rem 0;
}

.social-links a {
  display: inline-flex;
  align-items: center;
}

.social-links svg {
  width: 22px;
  height: 22px;
  fill: #555;
  transition: fill 0.2s;
}

.social-links a:hover svg {
  fill: #111;
}

/* === Page Nav === */
.page-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
  font-size: 0.9rem;
}

.page-nav a {
  color: #888;
  text-decoration: none;
}

.page-nav a:hover {
  color: #0066cc;
}

/* === Substack Posts === */
#substack-posts ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#substack-posts li {
  margin-bottom: 0.6rem;
  line-height: 1.6;
}

.post-date {
  color: #888;
  font-size: 0.85rem;
  margin-left: 0.75rem;
  white-space: nowrap;
}

.view-all {
  margin-top: 0.8rem;
  font-size: 0.95rem;
}

.loading {
  color: #999;
}

/* === Timeline === */
.timeline {
  position: relative;
  padding-left: 28px;
}

.timeline::before {
  content: '';
  position: absolute;
  left: 6px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #ddd;
}

.timeline-item {
  position: relative;
  margin-bottom: 1.5rem;
}

.timeline-item::before {
  content: '';
  position: absolute;
  left: -24px;
  top: 7px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #555;
  border: 2px solid #fff;
}

.timeline-year {
  display: block;
  color: #888;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.timeline-detail {
  font-size: 0.95rem;
  color: #444;
  line-height: 1.6;
}

/* === Featured List === */
.featured-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.featured-list li {
  margin-bottom: 1rem;
  line-height: 1.5;
}

.featured-source {
  font-size: 0.85rem;
  color: #888;
}

/* === Talks === */
.talks {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.talk-item {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}

.talk-thumb {
  width: 200px;
  height: auto;
  border-radius: 4px;
  flex-shrink: 0;
  background: #eee;
}

.talk-info p {
  margin: 0.25rem 0 0;
  font-size: 0.9rem;
  color: #666;
}

/* === Status Tags === */
.status {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  vertical-align: middle;
  margin-left: 4px;
}

.status--active {
  background: #e6f4ea;
  color: #1e7e34;
}

.status--planning {
  background: #fff8e1;
  color: #b8860b;
}

.status--starting {
  background: #e3f2fd;
  color: #1565c0;
}

.status--blocked {
  background: #eeeeee;
  color: #777;
}

/* === Podcast === */
.podcast-desc {
  margin-bottom: 0.75rem;
}

.podcast-links {
  display: flex;
  gap: 1rem;
  margin-top: 0.75rem;
  flex-wrap: wrap;
}

.podcast-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #555;
  text-decoration: none;
  font-weight: 500;
}

.podcast-link:hover {
  color: #111;
  text-decoration: none;
}


/* === GitHub Section === */
.gh-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: #666;
}

.gh-repo-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.gh-repo-list li {
  margin-bottom: 0.8rem;
  line-height: 1.5;
}

.gh-repo-desc {
  font-size: 0.85rem;
  color: #666;
}

.gh-repo-meta {
  font-size: 0.8rem;
  color: #999;
}

/* === Footer === */
footer {
  text-align: center;
  font-size: 0.85rem;
  color: #999;
}

/* === GitHub Section === */
.gh-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.25rem;
  margin-bottom: 1rem;
}

.gh-stat-item {
  font-size: 0.85rem;
  color: #666;
  font-weight: 600;
}

.gh-repo-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.gh-repo-list li {
  margin-bottom: 0.9rem;
  line-height: 1.5;
}

.gh-repo-name {
  font-weight: 600;
  display: block;
}

.gh-repo-desc {
  display: block;
  font-size: 0.9rem;
  color: #555;
  margin: 0.1rem 0 0.15rem;
}

.gh-repo-meta {
  display: block;
  font-size: 0.8rem;
  color: #888;
}

/* === Responsive === */
@media (max-width: 600px) {
  body {
    padding: 24px 16px;
  }

  h1 {
    font-size: 1.5rem;
  }

  .profile-photo {
    width: 160px;
    height: 160px;
  }

  .timeline-item {
    flex-direction: column;
    gap: 0.15rem;
  }

  .timeline-year {
    width: auto;
  }

  .talk-item {
    flex-direction: column;
  }

  .talk-thumb {
    width: 100%;
    max-width: 320px;
  }
}

/* === Long Bets === */
.bets-desc {
  margin-bottom: 0.75rem;
}

.bets-list {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.bet-item {
  border: 1px solid #eee;
  border-radius: 8px;
  padding: 1rem 1.1rem;
}

.bet-question {
  font-size: 0.95rem;
  font-weight: 600;
  color: #222;
  margin: 0 0 0.8rem;
}

.bet-outcomes {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.bet-outcome {
  display: grid;
  grid-template-columns: 2.8rem 1fr 2.5rem;
  align-items: center;
  gap: 0.5rem;
}

.bet-label {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-align: center;
}

.bet-label--yes {
  background: #e6f4ea;
  color: #1e7e34;
}

.bet-label--no {
  background: #fce8e8;
  color: #b71c1c;
}

.bet-bar {
  height: 7px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}

.bet-fill {
  height: 100%;
  border-radius: 4px;
}

.bet-fill--yes { background: #34a853; }
.bet-fill--no  { background: #e05252; }

.bet-pct {
  font-size: 0.82rem;
  font-weight: 600;
  color: #555;
  text-align: right;
}

/* === Back Link === */
.back-link {
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* === Project Entry (collapsible) === */
details.project-entry > summary { list-style: none; }
details.project-entry > summary::-webkit-details-marker { display: none; }

.project-summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.95rem;
  color: #333;
  padding: 0.35rem 0 0.35rem 1.4rem;
  border-radius: 4px;
  position: relative;
  user-select: none;
}

.project-summary::before {
  content: '▶';
  position: absolute;
  left: 0;
  font-size: 0.6rem;
  color: #aaa;
  top: 50%;
  transform: translateY(-50%);
  transition: transform 0.15s ease;
}

details[open] > .project-summary::before {
  transform: translateY(-50%) rotate(90deg);
}

.project-summary:hover { color: #0066cc; }
.project-summary:hover::before { color: #0066cc; }
.project-summary:focus-visible { outline: 2px solid #0066cc; outline-offset: 2px; }

.project-body {
  padding: 0.6rem 0 0.4rem 1.4rem;
  border-left: 2px solid #eee;
  margin-left: 0.1rem;
  margin-top: 0.3rem;
}

.project-body p {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: #555;
}

/* === Project Resources (file-list) === */
.project-resources {
  list-style: none;
  padding: 0;
  margin: 0.4rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.project-resources li {
  display: grid;
  grid-template-columns: 1.2rem 1fr;
  grid-template-rows: auto auto;
  column-gap: 0.4rem;
  font-size: 0.875rem;
  line-height: 1.5;
}

.resource-icon { grid-row: 1; grid-column: 1; color: #aaa; }
.resource-link { grid-row: 1; grid-column: 2; font-weight: 500; }
span.resource-link--note { color: #444; font-weight: 500; }
.resource-note { grid-row: 2; grid-column: 2; color: #888; font-size: 0.8rem; margin-top: 0.1rem; }

/* === Projects Teaser (index.html) === */
.projects-teaser {
  list-style: none;
  padding: 0;
  margin: 0;
}

.projects-teaser li {
  display: grid;
  grid-template-columns: 5.5rem 1fr 130px auto;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  font-size: 0.95rem;
  border-bottom: 1px solid #f0f0f0;
}

.projects-teaser li:last-child { border-bottom: none; }

.projects-teaser .teaser-year {
  color: #aaa;
  font-size: 0.8rem;
}

.teaser-progress { display: flex; align-items: center; gap: 0.4rem; }
.teaser-progress-bar {
  flex: 1;
  height: 5px;
  background: #f0f0f0;
  border-radius: 3px;
  overflow: hidden;
}
.teaser-progress-fill {
  height: 100%;
  background: #34a853;
  border-radius: 3px;
}
.teaser-progress-pct {
  font-size: 0.72rem;
  color: #888;
  min-width: 2.4rem;
  text-align: right;
}

@media (max-width: 600px) {
  .projects-teaser li {
    grid-template-columns: 5.5rem 1fr auto;
    row-gap: 0.3rem;
  }
  .teaser-progress { grid-column: 1 / -1; }
}

/* === Kanban (projects.html) === */
.kanban { display: flex; flex-direction: column; gap: 0.8rem; }
.kanban-col {
  border: 1px solid #eee;
  border-radius: 6px;
  overflow: hidden;
  background: #fafafa;
}
.kanban-col-head {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.9rem;
  cursor: pointer;
  list-style: none;
  font-weight: 600;
  background: #f5f5f5;
}
.kanban-col-head::-webkit-details-marker { display: none; }
.kanban-col-head::before {
  content: '▶';
  font-size: 0.65rem;
  color: #888;
  margin-right: 0.55rem;
  transition: transform 0.15s ease;
}
.kanban-col[open] > .kanban-col-head::before { transform: rotate(90deg); }
.kanban-col-title { flex: 1; font-size: 0.92rem; }
.kanban-col-count {
  font-size: 0.72rem;
  color: #888;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 1px 8px;
  min-width: 1.5rem;
  text-align: center;
}
.kanban-col-body { padding: 0.8rem 1rem; }
.kanban-empty { color: #aaa; font-size: 0.9rem; margin: 0; }
.kanban-col-body .timeline-item { margin-bottom: 0.8rem; }
.kanban-col-body .timeline-item:last-child { margin-bottom: 0; }

@media (min-width: 768px) {
  .kanban {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
    gap: 0.75rem;
  }
  .kanban-col-head { cursor: default; }
  .kanban-col-head::before { display: none; }
  .kanban-col-body { padding: 0.7rem 0.8rem; }
  .kanban-col-body .timeline-year { font-size: 0.75rem; }
}

/* === Dark Mode === */
@media (prefers-color-scheme: dark) {
  body {
    background: #1a1a1a;
    color: #e0e0e0;
  }

  p {
    color: #ccc;
  }

  a {
    color: #6db3f2;
  }

  hr {
    border-color: #444;
  }

  .tagline {
    color: #aaa;
  }

  .social-links svg {
    fill: #aaa;
  }

  .social-links a:hover svg {
    fill: #fff;
  }

  .post-date {
    color: #999;
  }

  .loading {
    color: #777;
  }

  .featured-source {
    color: #999;
  }

  .timeline::before {
    background: #444;
  }

  .timeline-item::before {
    background: #aaa;
    border-color: #1a1a1a;
  }

  .timeline-year {
    color: #999;
  }

  .timeline-detail {
    color: #ccc;
  }

  .talk-info p {
    color: #999;
  }

  footer {
    color: #666;
  }

  .profile-photo {
    background: #333;
  }

  .talk-thumb {
    background: #333;
  }

  .status--active {
    background: #1b3a26;
    color: #6fcf97;
  }

  .status--planning {
    background: #3a3520;
    color: #f0c040;
  }

  .status--starting {
    background: #1a2a3a;
    color: #64b5f6;
  }

  .status--blocked {
    background: #2a2a2a;
    color: #999;
  }

  .podcast-link {
    color: #aaa;
  }

  .podcast-link:hover {
    color: #fff;
  }

  .gh-stats {
    color: #999;
  }

  .gh-repo-desc {
    color: #999;
  }

  .gh-repo-meta {
    color: #777;
  }

  /* --- Dark: long bets --- */
  .bet-item {
    border-color: #333;
  }

  .bet-question {
    color: #e0e0e0;
  }

  .bet-label--yes {
    background: #1b3a26;
    color: #6fcf97;
  }

  .bet-label--no {
    background: #3a1b1b;
    color: #f48484;
  }

  .bet-bar {
    background: #2a2a2a;
  }

  .bet-pct {
    color: #aaa;
  }

  /* --- Dark: project entries --- */
  .project-summary { color: #e0e0e0; }
  .project-summary::before { color: #666; }
  .project-summary:hover { color: #6db3f2; }
  .project-summary:hover::before { color: #6db3f2; }
  .project-summary:focus-visible { outline-color: #6db3f2; }
  .project-body { border-left-color: #333; }
  .project-body p { color: #bbb; }
  .resource-icon { color: #666; }
  span.resource-link--note { color: #ccc; }
  .resource-note { color: #777; }

  /* --- Dark: index teaser list --- */
  .projects-teaser li { border-bottom-color: #2a2a2a; }
  .projects-teaser .teaser-year { color: #666; }
  .teaser-progress-bar { background: #2a2a2a; }
  .teaser-progress-pct { color: #888; }

  /* --- Dark: kanban --- */
  .kanban-col { border-color: #2a2a2a; }
  .kanban-col-head { background: #1a1a1a; color: #e0e0e0; }
  .kanban-col[open] { background: #141414; }
  .kanban-col-head::before { color: #888; }
  .kanban-col-count { background: #222; color: #aaa; }
  .kanban-empty { color: #555; }
}

/* === Wide-page (projects.html) === */
@media (min-width: 768px) {
  body.wide-page { max-width: 1040px; }
}
