/* Clinical Pearls — 林耿億醫師的醫療筆記
   設計語言：日式診所網站風格（大面積留白、粉藍／深藍雙色、
   英文大標配小字中文副標、寬字距的細體英文）
   原則：手機優先，任何元素都不得超出視窗（防破格） */

:root {
  /* 版心 */
  --wide: 44rem;             /* 單一直欄：電腦版比照手機的版面結構 */
  --narrow: 44rem;           /* 內容文字區寬度，文章圖片不得超過 */

  /* 配色 */
  --navy: #1f3d6e;           /* 深藍：標題、強調、深色橫條 */
  --navy-deep: #172f55;
  --blue: #8fbedc;           /* 粉藍：主色塊 */
  --blue-soft: #b9d8ec;
  --blue-tint: #eaf4fa;      /* 極淺藍：區塊底色 */
  --blue-mist: #f5fafd;
  --white: #ffffff;
  --ink: #2c3742;            /* 內文 */
  --muted: #6b7b8a;
  --line: #dbe7f0;

  --radius: 4px;             /* 參考站偏方正，圓角克制 */
  --shadow: 0 2px 24px rgba(31, 61, 110, .07);

  /* 字型 */
  --font-en: "Jost", "Helvetica Neue", Arial, sans-serif;
  /* 尾端的韓文字型備援，供「구병원」等字使用 */
  --font-zh: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", "Hiragino Sans", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", sans-serif;
  --font-script: "Parisienne", cursive;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --navy: #9fc6e6;
    --navy-deep: #0f1a28;
    --blue: #3d6a91;
    --blue-soft: #2e5273;
    --blue-tint: #13202e;
    --blue-mist: #0f1a26;
    --white: #16222f;
    --ink: #dde6ee;
    --muted: #93a5b6;
    --line: #24374a;
    --shadow: 0 2px 24px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
  body { background: #0c141d; }
}

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

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

body {
  margin: 0;
  background: var(--white);
  color: var(--ink);
  font-family: var(--font-zh);
  font-size: 1rem;
  font-weight: 400;
  line-height: 2;
  letter-spacing: .02em;
  /* 防破格：長網址、長英文字串一律斷行 */
  overflow-wrap: break-word;
  word-break: break-word;
}

img, svg, video { max-width: 100%; height: auto; display: block; }

a { color: var(--navy); text-decoration-thickness: 1px; text-underline-offset: 3px; }

.skip { position: absolute; left: -9999px; background: var(--navy); color: #fff; padding: .6rem 1rem; }
.skip:focus { left: 0; top: 0; z-index: 100; }

/* 版心 */
.wrap { width: 100%; max-width: var(--wide); margin-inline: auto; padding-inline: 1.5rem; }
.wrap-narrow { width: 100%; max-width: var(--narrow); margin-inline: auto; padding-inline: 1.5rem; }

/* ================================================================ 站頭 */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
@media (prefers-color-scheme: dark) {
  .site-header { background: rgba(22, 34, 47, .92); }
}

.head-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
}

.brand { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: inherit; }

.brand-mark {
  flex: none;
  min-width: 2.1rem;          /* 三字母標記，寬度隨內容延展但不小於此 */
  height: 2.1rem;
  padding-inline: .45rem;
  display: grid;
  place-items: center;
  background: var(--navy);
  color: #fff;
  font-family: var(--font-en);
  font-size: .72rem;
  font-weight: 500;
  letter-spacing: .08em;
  text-indent: .08em;          /* 補掉字距造成的右側空白，讓字真正置中 */
}

.brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.brand-en {
  font-family: var(--font-en);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: .14em;
  color: var(--navy);
}
.brand-zh { font-size: .6875rem; color: var(--muted); letter-spacing: .06em; }

.pill {
  flex: none;
  font-family: var(--font-zh);
  font-size: .75rem;
  letter-spacing: .1em;
  padding: .5rem 1.15rem;
  border: 1px solid var(--navy);
  border-radius: 999px;
  color: var(--navy);
  text-decoration: none;
  transition: background .2s ease, color .2s ease;
}
.pill:hover { background: var(--navy); color: #fff; }

/* ================================================================ HERO */

.hero { position: relative; isolation: isolate; }

.hero-img {
  width: 100%;
  height: clamp(20rem, 62vh, 34rem);
  object-fit: cover;
  object-position: center 30%;
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: linear-gradient(180deg, rgba(31, 61, 110, .52) 0%, rgba(60, 110, 160, .42) 55%, rgba(143, 190, 220, .55) 100%);
}

.hero-inner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
}

.hero-kicker {
  margin: 0 0 1.25rem;
  font-size: .75rem;
  letter-spacing: .22em;
  opacity: .92;
}

.hero-title {
  margin: 0;
  font-size: clamp(1.75rem, 6.2vw, 2.25rem);
  font-weight: 400;
  line-height: 1.55;
  letter-spacing: .1em;
  text-shadow: 0 1px 18px rgba(23, 47, 85, .3);
}

.hero-script {
  margin: .6rem 0 0;
  font-family: var(--font-script);
  font-size: clamp(1.5rem, 4.5vw, 1.85rem);
  font-weight: 400;
  letter-spacing: .02em;
  opacity: .95;
}

/* ================================================================ 深藍橫條 */

.strip { background: var(--navy); color: #fff; }
.strip-inner {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .5rem 1.25rem;
  min-height: 3.25rem;
  font-family: var(--font-en);
  font-size: .75rem;
  letter-spacing: .16em;
}
.strip-sep { width: 1px; height: .85rem; background: rgba(255, 255, 255, .35); }

/* ================================================================ 區塊標題 */

.sec-head { margin-bottom: 2.5rem; }
.sec-en {
  margin: 0;
  font-family: var(--font-en);
  font-size: clamp(1.6rem, 5vw, 1.9rem);
  font-weight: 200;
  line-height: 1.2;
  letter-spacing: .18em;
  color: var(--navy);
}
.sec-zh {
  margin: .5rem 0 0;
  font-size: .75rem;
  letter-spacing: .16em;
  color: var(--muted);
}

/* ================================================================ ABOUT */

.about { padding: clamp(3.5rem, 9vw, 6rem) 0; }

/* 窄螢幕：照片在上、學經歷在下；有空間時照片移到左側並排 */
.about-body { display: grid; gap: clamp(1.75rem, 4vw, 2.5rem); }
@media (min-width: 34rem) {
  .about-body { grid-template-columns: 14rem 1fr; align-items: start; }
}

.portrait { margin: 0; max-width: 14rem; margin-inline: auto; width: 100%; }
.portrait img {
  width: 100%;
  height: auto;
  aspect-ratio: 3 / 4;      /* 與裁切後的檔案一致，載入前就不會跳版 */
  object-fit: cover;
  border-radius: var(--radius);
  background: var(--blue-tint);
}

.cv { display: grid; gap: clamp(2rem, 5vw, 2.75rem); }

/* 學經歷 */
.cv-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin: 0 0 1.1rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--line);
  font-size: .875rem;
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: .16em;
  color: var(--navy);
}
.cv-en {
  flex: none;
  font-family: var(--font-en);
  font-size: .625rem;
  font-weight: 300;
  letter-spacing: .2em;
  color: var(--muted);
}

.cv-list { list-style: none; margin: 0; padding: 0; }
.cv-list li {
  position: relative;
  margin: 0 0 .35rem;
  padding-left: 1.25rem;
  font-size: .9375rem;
  line-height: 1.95;
  color: var(--ink);
}
.cv-list li:last-child { margin-bottom: 0; }
/* 以一段細藍橫線當項目符號，呼應整體的細線語彙 */
.cv-list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: .95em;
  width: .5rem;
  height: 1px;
  background: var(--blue);
}


/* ================================================================ 筆記卡片 */

.notes { background: var(--blue-tint); padding: clamp(3.5rem, 9vw, 6rem) 0; }

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

.card { display: flex; }
.card-link {
  display: block;
  width: 100%;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  position: relative;
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.card-body { display: block; padding: 1.75rem; }

/* 影片縮圖：僅為預覽，點擊任何位置都是進入文章頁 */
.card-thumb {
  display: block;
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--navy-deep);
  overflow: hidden;
}
.card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.card-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 3.25rem;
}
.card-play svg { width: 100%; height: auto; }
.card-link:hover .card-play .video-play-bg { fill: #c00; opacity: 1; }
.card-link:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
  border-color: var(--blue);
}

.card-no {
  display: block;
  font-family: var(--font-en);
  font-size: .8125rem;
  font-weight: 300;
  letter-spacing: .16em;
  color: var(--blue);
  margin-bottom: .75rem;
}

.card-title {
  margin: 0 0 .75rem;
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1.75;
  letter-spacing: .04em;
  color: var(--navy);
}

.card-summary { margin: 0 0 1.25rem; font-size: .875rem; line-height: 1.95; color: var(--muted); }

.card-more {
  display: inline-block;
  margin-top: 1.1rem;
  font-family: var(--font-zh);
  font-size: .75rem;
  letter-spacing: .12em;
  color: var(--navy);
}
.card-link:hover .card-more { text-decoration: underline; text-underline-offset: 4px; }

/* ================================================================ meta 列 */

.meta {
  margin: 0;
  font-family: var(--font-zh);
  font-size: .6875rem;
  line-height: 2.1;
  letter-spacing: .06em;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0 .6rem;
}
.meta .byline { color: var(--ink); font-weight: 500; }
.meta .sep { opacity: .4; }

/* ================================================================ 全出血圖帶 */

.band { position: relative; isolation: isolate; overflow: hidden; }
.band img { width: 100%; height: clamp(11rem, 26vw, 17rem); object-fit: cover; object-position: center 35%; filter: saturate(.65); }
.band::after {
  content: "";
  position: absolute; inset: 0; z-index: 1;
  background: linear-gradient(180deg, rgba(31, 61, 110, .48), rgba(143, 190, 220, .5));
}
.band-text {
  position: absolute; inset: 0; z-index: 2;
  margin: 0;
  display: grid; place-items: center;
  padding-inline: 1rem;
  text-align: center;
  font-family: var(--font-en);
  font-size: clamp(1rem, 3.6vw, 2rem);
  font-weight: 300;
  letter-spacing: .3em;
  color: #fff;
  text-shadow: 0 1px 16px rgba(23, 47, 85, .35);
}

/* ================================================================ 文章頁 */

.post-head { background: var(--blue-tint); padding: clamp(2.5rem, 7vw, 4.5rem) 0 clamp(2rem, 5vw, 3rem); }

.crumb {
  margin: 0 0 1.5rem;
  font-family: var(--font-en);
  font-size: .6875rem;
  letter-spacing: .18em;
  color: var(--muted);
}
.crumb a { color: var(--muted); text-decoration: none; }
.crumb a:hover { color: var(--navy); }

.post-title {
  margin: 0 0 1.25rem;
  font-size: clamp(1.5rem, 5vw, 2.125rem);
  font-weight: 500;
  line-height: 1.7;
  letter-spacing: .05em;
  color: var(--navy);
}

.post { padding: clamp(2.5rem, 7vw, 4rem) 0 clamp(3.5rem, 9vw, 5.5rem); }

/* HERO 圖片：等比例縮放，寬度不超過內容文字區 */
.post-hero { margin: 0 0 clamp(2rem, 5vw, 3rem); }
.post-hero img {
  width: 100%;
  height: auto;
  aspect-ratio: 1280 / 853;
  object-fit: cover;
  border-radius: var(--radius);
}

.post-body > :first-child { margin-top: 0; }

.post-body h2 {
  margin: 3rem 0 1rem;
  padding-bottom: .6rem;
  border-bottom: 1px solid var(--line);
  font-size: 1.1875rem;
  font-weight: 500;
  line-height: 1.75;
  letter-spacing: .06em;
  color: var(--navy);
}
.post-body h3 {
  margin: 2.25rem 0 .75rem;
  font-size: 1.0625rem;
  font-weight: 500;
  letter-spacing: .05em;
  color: var(--navy);
}
.post-body h4 { margin: 1.75rem 0 .5rem; font-size: .9375rem; font-weight: 500; color: var(--muted); letter-spacing: .05em; }

.post-body p { margin: 0 0 1.5rem; }
.post-body ul, .post-body ol { margin: 0 0 1.5rem; padding-left: 1.3rem; }
.post-body li { margin-bottom: .5rem; }
.post-body li::marker { color: var(--blue); }

.post-body blockquote {
  margin: 2rem 0;
  padding: 1.25rem 1.5rem;
  background: var(--blue-mist);
  border-left: 2px solid var(--blue);
}
.post-body blockquote > :last-child { margin-bottom: 0; }

.post-body hr { border: 0; border-top: 1px solid var(--line); margin: 3rem 0; }

.post-body img { border-radius: var(--radius); margin: 2rem 0; }

/* 影片：先只載縮圖，點擊後原地換成播放器 */
.video {
  position: relative;
  margin: 0 0 2rem;
  aspect-ratio: 16 / 9;
  background: var(--navy-deep);
  border-radius: var(--radius);
  overflow: hidden;
}
.post-body > .video:first-child { margin-top: 0; }

.video-facade {
  position: absolute;
  inset: 0;
  display: block;
  cursor: pointer;
}
.video-facade img {
  width: 100%;
  height: 100%;
  margin: 0;
  border-radius: 0;
  object-fit: cover;
}

.video-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 4.25rem;
  pointer-events: none;
}
.video-play svg { width: 100%; height: auto; }
.video-play-bg { fill: #1f1f1f; opacity: .78; transition: opacity .2s ease, fill .2s ease; }
.video-facade:hover .video-play-bg,
.video-facade:focus-visible .video-play-bg { fill: #c00; opacity: 1; }

.video-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

.post-body strong { font-weight: 600; color: var(--navy); }

/* 程式碼：橫向捲動，絕不撐破版面 */
.post-body code {
  font-family: var(--font-mono);
  font-size: .8125em;
  background: var(--blue-tint);
  color: var(--navy);
  padding: .15em .45em;
  border-radius: 2px;
}
.post-body pre {
  margin: 2rem 0;
  padding: 1.25rem;
  background: var(--blue-mist);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.post-body pre code { background: none; padding: 0; font-size: .78rem; line-height: 1.9; color: var(--ink); }

/* 表格：包一層捲動容器，窄螢幕不破格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 2rem 0; }
.post-body table { border-collapse: collapse; width: 100%; min-width: 22rem; font-size: .875rem; }
.post-body th, .post-body td { border-bottom: 1px solid var(--line); padding: .75rem .9rem; text-align: left; line-height: 1.8; }
.post-body th { background: var(--blue-tint); color: var(--navy); font-weight: 500; letter-spacing: .06em; border-bottom-color: var(--blue-soft); }

.back { margin: clamp(3rem, 7vw, 4rem) 0 0; font-size: .8125rem; letter-spacing: .1em; }
.back a { text-decoration: none; }
.back a:hover { text-decoration: underline; text-underline-offset: 4px; }

/* ================================================================ 404 */

.notfound { padding: clamp(4rem, 12vw, 7rem) 0 clamp(4rem, 10vw, 6rem); text-align: center; }
.nf-code {
  margin: 0 0 1rem;
  font-family: var(--font-en);
  font-size: clamp(3.5rem, 16vw, 5.5rem);
  font-weight: 200;
  line-height: 1;
  letter-spacing: .16em;
  text-indent: .16em;
  color: var(--blue);
}
.nf-title {
  margin: 0 0 .9rem;
  font-size: clamp(1.25rem, 5vw, 1.6rem);
  font-weight: 500;
  letter-spacing: .06em;
  color: var(--navy);
}
.nf-text { margin: 0; color: var(--muted); font-size: .9375rem; }
.notfound .back { margin-top: 2.5rem; }

/* ================================================================ footer */

.site-footer {
  background: var(--blue-mist);
  border-top: 1px solid var(--line);
  padding: clamp(2.5rem, 6vw, 3.5rem) 0 clamp(2rem, 5vw, 3rem);
  font-size: .75rem;
  line-height: 2;
  color: var(--muted);
}

.foot-top { display: grid; gap: 1.5rem; margin-bottom: 1.75rem; }

.foot-brand { display: flex; align-items: center; gap: .75rem; }
.foot-en { margin: 0; font-family: var(--font-en); font-size: .9375rem; letter-spacing: .14em; color: var(--navy); line-height: 1.4; }
.foot-zh { margin: 0; font-size: .6875rem; letter-spacing: .06em; line-height: 1.6; }

.credit { margin: 0; }

.disclaimer {
  margin: 0 0 1.25rem;
  padding: 1rem 1.15rem;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.disclaimer strong { color: var(--navy); font-weight: 600; }

.copyright {
  margin: 0;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
  font-family: var(--font-en);
  letter-spacing: .1em;
  font-size: .6875rem;
}

/* ================================================================ 桌機微調 */

@media (min-width: 48rem) {
  body { font-size: 1.0625rem; }
  .wrap, .wrap-narrow { padding-inline: 2.5rem; }
}

/* 窄螢幕：meta 列換行時行尾會留下孤立分隔符，直接隱藏改用間距區隔 */
@media (max-width: 30rem) {
  .meta { gap: 0 .85rem; }
  .meta .sep { display: none; }
  .meta .views { flex-basis: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
  .card-link:hover { transform: none; }
}
