/* ==========================================================================
   AI 說這樣可以 — Medium 風格部落格樣式
   ========================================================================== */

:root {
  --text: #242424;
  --text-secondary: #6b6b6b;
  --text-tertiary: #8b8b8b;
  --bg: #ffffff;
  --border: #e6e6e6;
  --border-strong: #d4d4d4;
  /* 系統色：藍色。原本沿用 Medium 的品牌綠，跟本站識別沒有關係。
     只用在連結、按鈕這類可互動或需要指路的元素，不作裝飾用。 */
  --accent: #1257c7;
  --accent-hover: #0e429a;
  --code-bg: #f2f2f2;
  --placeholder-bg: #f7f7f7;

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC",
               "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-serif: "Georgia", "Songti TC", "Noto Serif TC", serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  /* 內文欄寬：Medium 約 680px，中文字較寬，取 700px */
  --content-width: 700px;

  /* 頁面左右留白。導覽列、內文、頁尾共用同一個值，三者的內容才會
     對齊在同一條垂直線上；手機版在下方的斷點一次改這個變數即可。 */
  --gutter: 24px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

/* 頁面內容不足一個視窗高時，頁尾仍固定在視窗底部而不是浮在中間 —
   main 的 flex:1 吃掉剩餘空間，把 .site-footer 推到最下面。
   內容夠長時，這組規則不影響正常的文件流。 */
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
}

/* ==========================================================================
   頂部導覽列
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 57px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
  white-space: nowrap;
}

/* 水紋圖標：同心圓弧由內而外遞減不透明度，呼應 ripple 的擴散感。
   用 currentColor 上色，所以跟著 .brand 的文字色走（黑白，與商標文字一致）。 */
.brand-mark {
  flex: none;
  color: var(--text);
  transition: transform 200ms ease;
}

.brand:hover .brand-mark {
  transform: scale(1.08);
}

.brand-name {
  font-family: var(--font-serif);
  letter-spacing: -0.01em;
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.topbar-nav a {
  font-size: 14px;
  color: var(--text-secondary);
  text-decoration: none;
}

.topbar-nav a:hover {
  color: var(--text);
}

.topbar-cta {
  background: var(--accent);
  color: #fff !important;
  padding: 8px 16px;
  border-radius: 99px;
  font-size: 14px;
}

.topbar-cta:hover {
  background: var(--accent-hover);
}

/* ==========================================================================
   文章主體容器
   ========================================================================== */

main {
  /* flex:1 讓 main 吃掉視窗剩餘高度，把頁尾推到底（見 body 的註解）。 */
  flex: 1;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--gutter);
  /* flex 子元素的預設 min-width 是 auto，不會縮到比內容的固有寬度更小；
     再加上 max-width 只限制上限、不阻止內容把容器撐開，文章裡程式碼區塊的
     長行就會把 main 推得比視窗還寬，整頁因此可以左右捲動
     （.post-body pre 的 overflow-x 也永遠不會生效）。
     min-width:0 解除 flex 的下限，width:100% 把寬度釘在視窗上，
     長行才會留在程式碼區塊裡自己捲。 */
  min-width: 0;
  width: 100%;
}

/* ==========================================================================
   首頁
   ========================================================================== */

/* 首頁沒有標題區塊，文章列表直接接在導覽列下方 —
   這裡補上原本由 hero 提供的上方留白。 */
.home-posts {
  padding-top: 56px;
}

@media (max-width: 768px) {
  .home-posts {
    padding-top: 32px;
  }
}

/* 麵包屑 */

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 32px;
  font-size: 13px;
  color: var(--text-tertiary);
}

.breadcrumb a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--text);
  text-decoration: underline;
}

.breadcrumb [aria-current="page"] {
  color: var(--text-secondary);
}

.post-header {
  padding-top: 24px;
}

/* 標籤 */

.post-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.tag {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--placeholder-bg);
  padding: 5px 12px;
  border-radius: 99px;
  text-decoration: none;
}

.tag:hover {
  background: var(--border);
}

.tag-lg {
  font-size: 14px;
  padding: 7px 16px;
}

/* 標題與副標 */

.post-title {
  margin: 0 0 12px;
  font-family: var(--font-serif);
  font-size: 42px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.post-subtitle {
  margin: 0 0 32px;
  font-size: 21px;
  line-height: 1.5;
  color: var(--text-secondary);
  font-weight: 400;
}

/* 作者資訊列 */

.post-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.avatar {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--text);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.avatar-lg {
  width: 64px;
  height: 64px;
  font-size: 20px;
}

.meta-text {
  min-width: 0;
}

.meta-line-1 {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.author-name {
  font-size: 15px;
  text-decoration: none;
}

.author-name:hover {
  text-decoration: underline;
}

.follow-btn {
  border: none;
  background: none;
  padding: 0;
  font-size: 14px;
  color: var(--accent);
  cursor: pointer;
  font-family: inherit;
}

.follow-btn:hover {
  color: var(--accent-hover);
}

.follow-btn-lg {
  background: var(--accent);
  color: #fff;
  padding: 9px 18px;
  border-radius: 99px;
  font-size: 14px;
}

.follow-btn-lg:hover {
  background: var(--accent-hover);
  color: #fff;
}

.meta-line-2 {
  font-size: 14px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.dot {
  margin: 0 6px;
}

/* 互動列 */

/* 拍手／留言／收藏都移除後，這一列只剩右側的分享鈕。
   原本的 space-between 是用來把左右兩組推到兩端的，現在只剩一組，
   會變成貼齊左邊，因此改成 flex-end 讓它靠右。 */
.post-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 12px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 40px;
}

.actions-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-tertiary);
  font-size: 14px;
  font-family: inherit;
}

.action-btn:hover {
  color: var(--text);
}

/* 複製成功後短暫轉成系統色，讓「已複製」有視覺回饋而不只是換字。 */
.action-btn.is-copied,
.action-btn.is-copied:hover {
  color: var(--accent);
}

/* ==========================================================================
   首圖
   ========================================================================== */

/* 首圖突破 700px 的內文欄寬，往兩側各延伸到最多 1040px。
   calc(50% - min(50vw, 520px)) 是負的左右外距，把元素從置中的欄位
   往外推回視窗邊；這張圖資訊密度高，需要這個寬度才看得清右側的工具呼叫。 */
.post-hero {
  width: 100vw;
  max-width: 1040px;
  margin: 0 calc(50% - min(50vw, 520px)) 44px;
}

/* img 的 width/height 屬性是實際像素（2400×1260），用來保留版面比例；
   這裡再把顯示寬度壓回容器寬，height:auto 維持比例不變形。 */
.post-hero img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

/* 手機上不做延伸，維持與內文同寬（頁面留白已經很窄了）。 */
@media (max-width: 768px) {
  .post-hero {
    width: auto;
    margin: 0 0 32px;
  }

  .post-hero img {
    border-radius: 5px;
  }
}

.post-hero figcaption {
  margin-top: 10px;
  text-align: center;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   內文
   ========================================================================== */

.post-body {
  font-family: var(--font-serif);
  font-size: 20px;
  line-height: 1.8;
  letter-spacing: 0.003em;
}

.placeholder-note {
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-tertiary);
  background: var(--placeholder-bg);
  border-left: 3px solid var(--border-strong);
  padding: 14px 18px;
  margin: 0 0 40px;
}

.post-body p {
  margin: 0 0 32px;
}

.post-body h2 {
  font-size: 30px;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 48px 0 12px;
}

.post-body h3 {
  font-size: 24px;
  line-height: 1.35;
  margin: 36px 0 8px;
}

.post-body a {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}

.post-body a:hover {
  color: var(--accent);
}

.post-body blockquote {
  margin: 32px 0;
  padding-left: 20px;
  border-left: 3px solid var(--text);
  font-style: italic;
  color: var(--text-secondary);
}

.post-body ul,
.post-body ol {
  margin: 0 0 32px;
  padding-left: 28px;
}

.post-body li {
  margin-bottom: 10px;
}

.post-body code {
  font-family: var(--font-mono);
  font-size: 0.82em;
  background: var(--code-bg);
  padding: 2px 6px;
  border-radius: 3px;
}

.post-body pre {
  background: var(--code-bg);
  border-radius: 4px;
  padding: 20px;
  overflow-x: auto;
  margin: 0 0 32px;
}

.post-body pre code {
  background: none;
  padding: 0;
  font-size: 14px;
  line-height: 1.6;
}

.post-body hr {
  border: none;
  text-align: center;
  margin: 48px 0;
}

/* Medium 招牌的三點分隔線 */
.post-body hr::before {
  content: "* * *";
  letter-spacing: 0.6em;
  color: var(--text-tertiary);
  font-size: 20px;
}

/* ==========================================================================
   文末標籤
   ========================================================================== */

.post-footer {
  margin: 48px 0 0;
}

.footer-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

/* ==========================================================================
   作者簡介卡
   ========================================================================== */

.author-card {
  display: flex;
  gap: 20px;
  margin: 40px 0 56px;
  padding: 32px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.author-card-body {
  min-width: 0;
}

.author-card-name {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 700;
}

.author-card-bio {
  margin: 0 0 16px;
  font-size: 15px;
  color: var(--text-secondary);
}

/* ==========================================================================
   延伸閱讀
   ========================================================================== */

.more-posts {
  margin-bottom: 80px;
}

/* 文章底部的「回文章列表」區塊——目前只有一篇文章，
   用它取代會連到 404 的延伸閱讀卡片（見文章頁的註解）。 */
.back-home {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 28px 32px;
  background: var(--placeholder-bg);
  border-radius: 8px;
}

.back-home-text {
  margin: 0;
  font-size: 16px;
  color: var(--text-secondary);
}

.back-home-link {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}

.back-home-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 0 0 24px;
}

.post-list {
  display: grid;
  gap: 28px;
}

.post-card {
  display: flex;
  gap: 20px;
  text-decoration: none;
  align-items: flex-start;
}

.card-thumb {
  flex: none;
  width: 120px;
  aspect-ratio: 4 / 3;
  background: var(--placeholder-bg);
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
}

.card-body {
  min-width: 0;
}

.card-title {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  line-height: 1.35;
}

.post-card:hover .card-title {
  text-decoration: underline;
}

.card-excerpt {
  margin: 0 0 8px;
  font-size: 14px;
  color: var(--text-secondary);
  /* 限制兩行 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-meta {
  font-size: 13px;
  color: var(--text-tertiary);
}

/* ==========================================================================
   頁尾
   ========================================================================== */

.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
}

.site-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 13px;
  color: var(--text-tertiary);
}

/* 版權那行在文章頁是連回首頁的連結，在其他頁是純文字 —
   兩者外觀一致，不要因為是 <a> 就冒出底線。 */
.site-footer-inner > a {
  color: inherit;
  text-decoration: none;
}

.site-footer-inner > a:hover {
  color: var(--text);
}

.site-footer-nav {
  display: flex;
  gap: 20px;
}

.site-footer-nav a {
  color: var(--text-tertiary);
  text-decoration: none;
}

.site-footer-nav a:hover {
  color: var(--text);
}

/* ==========================================================================
   響應式
   ========================================================================== */

@media (max-width: 768px) {
  /* 手機螢幕窄，24px 的左右留白會把本來就不寬的中文內文再擠掉一截，
     縮到 18px；三個共用容器一起變動，對齊關係不受影響。 */
  :root {
    --gutter: 18px;
  }

  .breadcrumb {
    padding-top: 20px;
  }

  .post-header {
    padding-top: 20px;
  }

  .post-title {
    font-size: 32px;
  }

  .post-subtitle {
    font-size: 18px;
    margin-bottom: 24px;
  }

  .post-body {
    font-size: 18px;
  }

  .post-body h2 {
    font-size: 25px;
  }

  .post-body h3 {
    font-size: 21px;
  }

  /* 手機上導覽列只留品牌名與訂閱鈕 */
  .topbar-nav a:not(.topbar-cta) {
    display: none;
  }

  .card-thumb {
    width: 90px;
  }

  /* 這個區塊自己還有 32px 的左右內距，疊在頁面留白之上會讓裡面的文字
     被擠成很窄的一條；手機上收斂成 20/22px。 */
  .back-home {
    padding: 22px 20px;
  }

  /* 延伸閱讀與頁尾之間的 80px 在手機上過深，幾乎多出一個空白畫面。 */
  .more-posts {
    margin-bottom: 48px;
  }

  .site-footer {
    padding: 22px 0;
  }
}
