/* ===================================================================
   Renal Stone Surgery — RIRS 衛教部落格
   行動優先（mobile-first）；所有區塊都以避免破框為前提設計
   =================================================================== */

:root {
  --bg: #f7f9fa;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #16232b;
  --ink-soft: #4a5f6b;
  --ink-faint: #71858f;
  --line: #dde5e9;
  --accent: #0f7a6c;
  --accent-soft: #e3f2ef;
  --accent-ink: #0a5f54;
  --radius: 14px;
  --wrap: 44rem;
  --pad: 1.25rem;
  --shadow: 0 1px 2px rgba(16, 35, 43, 0.05), 0 8px 24px rgba(16, 35, 43, 0.06);
  --font: "Noto Sans TC", "Source Han Sans TC", "PingFang TC", "Microsoft JhengHei",
    system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1619;
    --surface: #172126;
    --surface-2: #1d2a30;
    --ink: #e7eef1;
    --ink-soft: #b0c2ca;
    --ink-faint: #8298a2;
    --line: #2a3940;
    --accent: #4ecdb8;
    --accent-soft: #16302c;
    --accent-ink: #7fe0cf;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  }
}

/* ------------------------------------------------------------- 基礎 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.85;
  /* 長網址／長英文字串不會撐破版面 */
  overflow-wrap: anywhere;
  word-break: break-word;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

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

/* 內容欄：所有區塊共用同一個寬度上限，HERO 圖也不會超過文字區寬度 */
.wrap {
  width: 100%;
  max-width: var(--wrap);
  margin-inline: auto;
  padding-inline: var(--pad);
}

.skip {
  position: absolute;
  left: -9999px;
}

.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 10;
  background: var(--surface);
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

/* ------------------------------------------------------------- 頁首 */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: saturate(180%) blur(6px);
}

.site-header .wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding-block: 0.85rem;
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.site-nav {
  display: flex;
  flex: none;
  gap: 0.15rem;
}

.site-nav a {
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  color: var(--ink-soft);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}

.site-nav a:hover {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

/* 極窄螢幕收掉副標，保住導覽列不擠壓 */
@media (max-width: 26rem) {
  .brand-text small {
    display: none;
  }
}

.brand-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-text strong {
  font-size: 1rem;
  line-height: 1.35;
}

.brand-text small {
  color: var(--ink-faint);
  font-size: 0.78rem;
  line-height: 1.35;
}

/* ------------------------------------------------------------- HERO */

.hero {
  padding-block: 2.5rem 1.5rem;
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-ink);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.7rem, 6vw, 2.5rem);
  line-height: 1.3;
  letter-spacing: -0.01em;
}

.lede {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

/* HERO 圖片：等比例縮放，寬度不超過內容文字區 */
.hero-figure {
  margin: 1.5rem 0 0;
  padding: 0;
}

/* 等比例縮放、完整顯示（不裁切），寬度以內容文字區為上限 */
.hero-figure img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto; /* 維持原始長寬比 */
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-2);
}

/* 直式照片再收窄一些並置中，避免在桌機上整頁都是圖 */
.hero-figure.is-portrait img {
  max-width: 26rem;
  margin-inline: auto;
}

.hero-figure figcaption {
  margin-top: 0.6rem;
  color: var(--ink-faint);
  font-size: 0.8rem;
  line-height: 1.6;
}

/* ------------------------------------------------------------- 文章卡片 */

.posts {
  padding-block: 1.5rem 3rem;
}

.section-h {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0 0 1.25rem;
  font-size: 1.15rem;
}

.section-h .count {
  display: inline-grid;
  place-items: center;
  min-width: 1.7rem;
  height: 1.7rem;
  padding-inline: 0.4rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-size: 0.85rem;
}

.card-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.2rem;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.card-title {
  margin: 0 0 0.5rem;
  font-size: 1.12rem;
  line-height: 1.45;
  color: var(--ink);
}

.card-link:hover .card-title {
  color: var(--accent-ink);
}

.card-summary {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.93rem;
  line-height: 1.75;
}

/* 中繼資訊：小螢幕自動換行，不會擠成一列破框 */
.card-meta,
.byline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0.9rem 0 0;
  color: var(--ink-faint);
  font-size: 0.8rem;
  line-height: 1.6;
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  white-space: nowrap;
}

.counter {
  font-variant-numeric: tabular-nums;
  min-width: 1.2em;
  display: inline-block;
}

.tags {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
  padding: 0;
}

.tags li {
  background: var(--surface-2);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 0.15rem 0.7rem;
  font-size: 0.75rem;
}

.tags-post {
  margin-top: 2rem;
}

/* ------------------------------------------------------------- 文章頁 */

.post {
  padding-block: 1.5rem 3rem;
}

.breadcrumb {
  margin-bottom: 1.25rem;
  font-size: 0.88rem;
}

.breadcrumb a {
  text-decoration: none;
}

.post-header h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.55rem, 5.5vw, 2.15rem);
  line-height: 1.35;
}

.post-header .byline {
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
}

.post-header .lede {
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* 內文排版 */
.prose {
  font-size: 1.02rem;
}

.prose h2 {
  margin: 2.4rem 0 0.8rem;
  padding-top: 0.6rem;
  border-top: 2px solid var(--accent-soft);
  font-size: 1.3rem;
  line-height: 1.45;
}

.prose h3 {
  margin: 1.8rem 0 0.6rem;
  font-size: 1.08rem;
  line-height: 1.5;
  color: var(--accent-ink);
}

.prose p {
  margin: 0 0 1.1rem;
}

.prose ul,
.prose ol {
  margin: 0 0 1.1rem;
  padding-left: 1.4rem;
}

.prose li {
  margin-bottom: 0.45rem;
}

.prose blockquote {
  margin: 1.4rem 0;
  padding: 0.9rem 1.1rem;
  border-left: 4px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--accent-soft);
  color: var(--ink-soft);
}

.prose blockquote p:last-child {
  margin-bottom: 0;
}

.prose code {
  background: var(--surface-2);
  padding: 0.1rem 0.35rem;
  border-radius: 5px;
  font-size: 0.9em;
}

.prose pre {
  overflow-x: auto; /* 程式碼自己捲，不撐破版面 */
  background: var(--surface-2);
  padding: 1rem;
  border-radius: 10px;
}

.prose pre code {
  background: none;
  padding: 0;
}

/* 表格：小螢幕水平捲動而非破框 */
.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.2rem;
  font-size: 0.92rem;
  white-space: nowrap;
}

.prose th,
.prose td {
  border: 1px solid var(--line);
  padding: 0.55rem 0.8rem;
  text-align: left;
}

.prose th {
  background: var(--surface-2);
  font-weight: 700;
}

.prose img {
  border-radius: 10px;
  border: 1px solid var(--line);
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
}

.post-nav {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--line);
}

.btn {
  display: inline-block;
  background: var(--accent-soft);
  color: var(--accent-ink);
  border-radius: 999px;
  padding: 0.5rem 1.1rem;
  font-size: 0.9rem;
  text-decoration: none;
}

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

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

.site-footer {
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-block: 2rem 2.5rem;
  font-size: 0.85rem;
  color: var(--ink-soft);
}

.footer-h {
  margin: 0 0 0.6rem;
  font-size: 0.95rem;
  color: var(--ink);
}

.site-footer .credit,
.site-footer .disclaimer,
.site-footer .copyright {
  margin: 0 0 0.9rem;
  line-height: 1.75;
}

.site-footer hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 1.2rem 0;
}

.site-footer .copyright {
  margin-bottom: 0;
  color: var(--ink-faint);
  font-size: 0.8rem;
}

/* ------------------------------------------------------------- 桌機加強 */

@media (min-width: 40rem) {
  :root {
    --pad: 2rem;
  }

  body {
    font-size: 1.05rem;
  }

  .hero {
    padding-block: 3.5rem 2rem;
  }

  .card {
    padding: 1.5rem;
  }

  .prose table {
    display: table;
    white-space: normal;
  }
}

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