/* ─────────────────────────────────────────────────────────────────────
 * theme.css — 急診熊心聲部落格 · shared design system
 * Locked per design.md (studied-DNA from every.to · light-paper pivot)
 * Used by: ai-learning.html · category.html · about.html
 * (index.html + post.html still inline for now — refactor when stable)
 * ───────────────────────────────────────────────────────────────────── */

:root {
  /* rgb/hex tokens (exact sRGB renderings of the original oklch values, kept in
     the trailing comments). Switched off oklch() because Disqus' embed.js samples
     the page's computed colours to auto-theme its widget and its parser throws on
     oklch(), which aborts the entire comment thread. Visually identical. */
  --color-paper:      #fbf8f3;  /* oklch(98% 0.008 80)  */
  --color-paper-2:    #f3eee6;  /* oklch(95% 0.012 80)  */
  --color-paper-3:    #e7e0d6;  /* oklch(91% 0.016 80)  */
  --color-ink:        #0b121a;  /* oklch(18% 0.020 250) */
  --color-ink-2:      #353b42;  /* oklch(35% 0.015 250) */
  --color-ink-3:      #6c7278;  /* oklch(55% 0.012 250) */
  --color-rule:       #d1cdc7;  /* oklch(85% 0.010 80)  */
  --color-rule-bold:  #a39e94;  /* oklch(70% 0.015 80)  */
  --color-accent:     #fe6a01;  /* oklch(70% 0.200 45)  */
  --color-accent-ink: #b22800;  /* oklch(50% 0.180 35)  */

  --font-display:    "Fraunces", "Noto Serif TC", ui-serif, Georgia, serif;
  --font-display-zh: "Noto Serif TC", "Fraunces", ui-serif, serif;
  --font-body:       "Inter Tight", "Noto Sans TC", ui-sans-serif, system-ui, sans-serif;
  --font-body-zh:    "Noto Sans TC", "Inter Tight", ui-sans-serif, system-ui, sans-serif;

  --space-2xs: 0.25rem;  --space-xs: 0.5rem;  --space-sm: 0.75rem;
  --space-md:  1.25rem;  --space-lg: 2rem;    --space-xl: 3.5rem;
  --space-2xl: 6rem;

  --text-xs:    0.75rem;   --text-sm:    0.875rem;  --text-base:  1rem;
  --text-lg:    1.125rem;  --text-xl:    1.375rem;  --text-2xl:   1.75rem;
  --text-3xl:   2.25rem;   --text-display-s: 3rem;  --text-display:   4rem;

  --measure:      56rem;
  --measure-wide: 64rem;

  --dur-short: 120ms;
  --ease-out:  cubic-bezier(.22, 1, .36, 1);
}

* { box-sizing: border-box; }
html { overflow-x: clip; scroll-behavior: smooth; }
body {
  overflow-x: clip;
  margin: 0;
  background: var(--color-paper);
  color: var(--color-ink);
  font-family: var(--font-body-zh);
  font-size: var(--text-base);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  font-feature-settings: "ss01", "kern";
}

a {
  color: var(--color-ink);
  text-decoration: none;
  transition: color var(--dur-short) var(--ease-out), border-color var(--dur-short) var(--ease-out);
}
a:hover { color: var(--color-accent-ink); }
a:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }

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

/* ─── Brand strip ─────────────────────────────────────────────────────── */
.brandstrip {
  position: sticky;
  top: 0;
  background: var(--color-paper);
  border-bottom: 1px solid var(--color-rule);
  z-index: 10;
}
.brandstrip-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: var(--space-sm) var(--space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
}
.brandstrip .wordmark {
  font-family: var(--font-display-zh);
  font-weight: 900;
  font-size: var(--text-lg);
  letter-spacing: -0.01em;
  color: var(--color-ink);
  white-space: nowrap;
  flex: 0 0 auto;
}
.brandstrip .wordmark .sub {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--color-ink-3);
  margin-left: 0.4em;
  font-size: var(--text-base);
}
.brandstrip .nav-row {
  display: flex;
  gap: var(--space-md);
  font-family: var(--font-body-zh);
  font-size: var(--text-sm);
  color: var(--color-ink-2);
  overflow-x: auto;
  scrollbar-width: none;
}
.brandstrip .nav-row::-webkit-scrollbar { display: none; }
.brandstrip .nav-row a { white-space: nowrap; }
.brandstrip .nav-row a:hover { color: var(--color-accent-ink); }
.brandstrip .nav-row a.is-active {
  color: var(--color-ink);
  border-bottom: 2px solid var(--color-accent);
  padding-bottom: 2px;
}
/* Narrower desktops: drop the italic subtitle and tighten nav spacing so the
   full nav (incl. 關於我) fits without horizontal scrolling. */
@media (max-width: 1400px) {
  .brandstrip .wordmark .sub { display: none; }
}
@media (max-width: 1120px) {
  .brandstrip .nav-row { gap: var(--space-sm); }
}

/* ─── Page masthead (shared by all non-index pages) ───────────────────── */
.page-masthead {
  max-width: var(--measure-wide);
  margin: 0 auto;
  padding: var(--space-2xl) var(--space-lg) var(--space-xl);
}
.page-masthead .breadcrumb {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent-ink);
  margin: 0 0 var(--space-md);
}
.page-masthead h1 {
  font-family: var(--font-display-zh);
  font-weight: 600;
  font-size: clamp(2rem, 5vw, var(--text-display));
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin: 0 0 var(--space-md);
  color: var(--color-ink);
}
.page-masthead .deck {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: var(--text-xl);
  line-height: 1.45;
  color: var(--color-ink-2);
  margin: 0;
  max-width: var(--measure);
}
.page-masthead .meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-md);
  align-items: center;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  padding-top: var(--space-md);
  margin-top: var(--space-lg);
  border-top: 1px solid var(--color-rule);
}
.page-masthead .meta .dot { color: var(--color-rule-bold); }

/* ─── Eyebrow (section divider) ───────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--color-accent-ink);
  padding-bottom: var(--space-xs);
  border-bottom: 2px solid var(--color-ink);
  margin: var(--space-2xl) 0 var(--space-lg);
}

/* ─── Wrap container ──────────────────────────────────────────────────── */
.wrap {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 var(--space-lg);
}

/* ─── Newsletter band ─────────────────────────────────────────────────── */
.newsletter {
  border-top: 2px solid var(--color-ink);
  padding: var(--space-2xl) 0;
  margin-top: var(--space-2xl);
  text-align: center;
}
.newsletter .label {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--color-accent-ink);
  margin: 0 0 var(--space-md);
}
.newsletter h2 {
  font-family: var(--font-display-zh);
  font-weight: 600;
  font-size: clamp(1.75rem, 3.5vw, var(--text-display-s));
  line-height: 1.15;
  letter-spacing: -0.015em;
  margin: 0 auto var(--space-sm);
  max-width: 38rem;
  color: var(--color-ink);
}
.newsletter p {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-ink-2);
  max-width: 32rem;
  margin: 0 auto var(--space-lg);
  line-height: 1.5;
}
.newsletter form {
  display: flex;
  gap: var(--space-xs);
  max-width: 28rem;
  margin: 0 auto;
}
.newsletter input[type="email"] {
  flex: 1;
  border: 1px solid var(--color-ink);
  background: var(--color-paper);
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-body-zh);
  font-size: var(--text-base);
  color: var(--color-ink);
  border-radius: 0;
}
.newsletter input[type="email"]:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}
.newsletter button {
  border: 1px solid var(--color-ink);
  background: var(--color-ink);
  color: var(--color-paper);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: 0;
  white-space: nowrap;
  transition: background 120ms var(--ease-out);
}
.newsletter button:hover { background: var(--color-accent-ink); border-color: var(--color-accent-ink); }
.newsletter .small {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  letter-spacing: 0.08em;
  margin-top: var(--space-md);
}

/* ─── Footer ──────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--color-ink);
  padding: var(--space-2xl) 0 var(--space-xl);
  margin-top: var(--space-2xl);
  text-align: center;
}
.footer .wordmark {
  font-family: var(--font-display-zh);
  font-weight: 900;
  font-size: clamp(2.5rem, 6vw, 4.5rem);
  letter-spacing: -0.02em;
  line-height: 0.95;
  margin: 0 0 var(--space-md);
  color: var(--color-ink);
}
.footer .mission {
  font-family: var(--font-display);
  font-style: italic;
  font-size: var(--text-lg);
  color: var(--color-ink-2);
  max-width: 36rem;
  margin: 0 auto var(--space-lg);
  line-height: 1.5;
}
.footer .social {
  display: flex;
  justify-content: center;
  gap: var(--space-lg);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-ink-3);
}
.footer .social a {
  color: var(--color-ink-2);
  border-bottom: 1px solid var(--color-rule-bold);
  padding-bottom: 2px;
}
.footer .copyright {
  margin-top: var(--space-xl);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-ink-3);
}

/* ─── Article card · text stamp fallback (when no thumbnail) ──────────── */
article.card .image.image-stamp {
  width: 100%;
  height: 100%;
  aspect-ratio: 3 / 1;
  background: var(--color-paper-2);
  position: relative;
  display: flex;
  flex-direction: row;
  align-items: baseline;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-md);
  overflow: hidden;
}
/* Hook variant — taller tile, pull-quote as main visual */
article.card .image.image-stamp--hook {
  aspect-ratio: 5 / 2;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: var(--space-md);
  gap: var(--space-sm);
}
article.card .image.image-stamp--hook .stamp-hook {
  font-family: var(--font-display-zh);
  font-weight: 600;
  font-size: clamp(1rem, 1.6vw, 1.25rem);
  line-height: 1.4;
  color: var(--color-ink);
  margin: 0;
  letter-spacing: -0.005em;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
article.card .image.image-stamp--hook .stamp-hook::before {
  content: "“";
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--color-accent);
  margin-right: 0.1em;
}
article.card .image.image-stamp--hook .stamp-hook::after {
  content: "”";
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  color: var(--color-accent);
  margin-left: 0.05em;
}
article.card .image.image-stamp--hook .stamp-byline {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  align-self: flex-end;
}
article.card .image.image-stamp::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--color-accent);
}
article.card .image.image-stamp::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(135deg, transparent 0%, transparent 50%, rgba(0,0,0,0.02) 100%);
  pointer-events: none;
}
article.card .image.image-stamp .stamp-eyebrow {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent-ink);
  position: absolute;
  top: var(--space-sm);
  left: var(--space-md);
  right: var(--space-md);
}
article.card .image.image-stamp .stamp-date {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: clamp(1.5rem, 2.8vw, 2rem);
  line-height: 1;
  color: var(--color-ink);
  letter-spacing: -0.02em;
}
article.card .image.image-stamp .stamp-year {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--color-ink-3);
}
article.card a:hover .image.image-stamp { background: var(--color-paper-3); }
article.card a:hover .image.image-stamp::before { background: var(--color-accent-ink); }

/* ─── Responsive ──────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .newsletter form { flex-direction: column; }
  .page-masthead { padding: var(--space-xl) var(--space-md) var(--space-lg); }
}

/* Mobile — brand strip stack + hide italic subtitle to avoid wordmark wrap */
@media (max-width: 720px) {
  .brandstrip-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
    padding: var(--space-sm) var(--space-md);
  }
  .brandstrip .wordmark {
    font-size: var(--text-base);
    white-space: nowrap;
  }
  .brandstrip .wordmark .sub {
    display: none;
  }
  .brandstrip .nav-row {
    width: 100%;
    font-size: var(--text-xs);
    gap: var(--space-sm);
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition: opacity 120ms ease, color 120ms ease !important;
  }
}

/* ─── Search ──────────────────────────────────────────────────────────── */
/* Brand-strip right cluster (nav + search trigger) */
.brandstrip-actions {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  min-width: 0;
}
.brandstrip .nav-row { min-width: 0; }

/* Search trigger — reads like a compact search box */
.search-trigger {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: 0.3rem 0.75rem;
  background: var(--color-paper-2);
  border: 1px solid var(--color-rule);
  border-radius: 999px;
  font-family: var(--font-body-zh);
  font-size: var(--text-xs);
  color: var(--color-ink-3);
  cursor: pointer;
  transition: border-color var(--dur-short) var(--ease-out),
              color var(--dur-short) var(--ease-out),
              background var(--dur-short) var(--ease-out);
}
.search-trigger:hover {
  border-color: var(--color-accent);
  color: var(--color-accent-ink);
  background: var(--color-paper);
}
.search-trigger-icon { width: 14px; height: 14px; flex: 0 0 auto; }

/* Overlay */
.site-search[hidden] { display: none; }
.site-search {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 12vh var(--space-md) var(--space-md);
}
.site-search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 18, 26, 0.42);
  backdrop-filter: blur(3px);
  animation: site-search-fade var(--dur-short) var(--ease-out);
}
@keyframes site-search-fade { from { opacity: 0; } to { opacity: 1; } }
.site-search-panel {
  position: relative;
  width: 100%;
  max-width: 640px;
  max-height: 76vh;
  display: flex;
  flex-direction: column;
  background: var(--color-paper);
  border: 1px solid var(--color-rule-bold);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(11, 18, 26, 0.28);
  overflow: hidden;
  animation: site-search-rise 180ms var(--ease-out);
}
@keyframes site-search-rise {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.site-search-head {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-rule);
}
.site-search-icon { width: 18px; height: 18px; flex: 0 0 auto; color: var(--color-ink-3); }
.site-search-input {
  flex: 1 1 auto;
  min-width: 0;
  border: none;
  outline: none;
  background: transparent;
  font-family: var(--font-display-zh);
  font-size: var(--text-xl);
  color: var(--color-ink);
  padding: var(--space-2xs) 0;
}
.site-search-input::placeholder { color: var(--color-ink-3); }
.site-search-close {
  flex: 0 0 auto;
  border: 1px solid var(--color-rule);
  border-radius: 6px;
  background: var(--color-paper-2);
  color: var(--color-ink-3);
  font-family: var(--font-body);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  padding: 0.2rem 0.45rem;
  cursor: pointer;
}
.site-search-close:hover { color: var(--color-accent-ink); border-color: var(--color-accent); }
.site-search-status {
  padding: var(--space-xs) var(--space-md);
  font-family: var(--font-body);
  font-size: var(--text-xs);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-ink-3);
  border-bottom: 1px solid var(--color-rule);
}
.site-search-results {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.s-result {
  display: block;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-rule);
  cursor: pointer;
}
.s-result:last-child { border-bottom: none; }
.s-result.is-active,
.s-result:hover { background: var(--color-paper-2); }
.s-result-kicker {
  display: block;
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-accent-ink);
  margin-bottom: var(--space-2xs);
}
.s-result-title {
  display: block;
  font-family: var(--font-display-zh);
  font-weight: 600;
  font-size: var(--text-lg);
  line-height: 1.3;
  color: var(--color-ink);
}
.s-result-snip {
  display: block;
  margin-top: var(--space-2xs);
  font-family: var(--font-body-zh);
  font-size: var(--text-sm);
  line-height: 1.55;
  color: var(--color-ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.s-result mark {
  background: rgba(254, 106, 1, 0.28);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}
.site-search-open { overflow: hidden; }

@media (max-width: 720px) {
  .brandstrip-actions { width: 100%; }
  .search-trigger-text { display: none; }
  .search-trigger { padding: 0.35rem; }
  .site-search { padding-top: 8vh; }
  .site-search-input { font-size: var(--text-lg); }
}

/* 急診心臟週報：首頁與分類頁共用入口。 */
.ercw-promo { display:grid;grid-template-columns:180px minmax(0,1fr) 120px;gap:28px;align-items:center;border-top:2px solid var(--color-accent);border-bottom:1px solid var(--color-rule);padding:26px 0;margin:32px 0 42px; }
.ercw-promo-label {display:flex;flex-direction:column;gap:6px;font-family:var(--font-body-zh);}
.ercw-promo-label>span {font-size:11px;letter-spacing:.15em;color:var(--color-accent-ink);}
.ercw-promo-label>a {font-family:var(--font-display-zh);font-size:21px;font-weight:600;}
.ercw-promo-label small {font-size:12px;color:var(--color-ink-3);}
.ercw-promo-story h2 {font-family:var(--font-display-zh);font-size:clamp(21px,2.2vw,29px);line-height:1.4;margin:0 0 8px;}
.ercw-promo-story p {font-family:var(--font-body-zh);font-size:14px;line-height:1.7;color:var(--color-ink-2);margin:0;}
.ercw-promo-links {display:flex;flex-direction:column;gap:12px;align-items:flex-start;font-size:13px;white-space:nowrap;}
.ercw-promo-links .ercw-promo-read {border-bottom:1px solid var(--color-accent);padding:8px 0;color:var(--color-accent-ink);font-weight:600;}
.ercw-category-promo {max-width:1240px;padding:0 var(--space-lg);margin:0 auto;}
@media(max-width:700px){.ercw-promo{grid-template-columns:minmax(0,1fr);gap:15px;padding:22px 0;}.ercw-promo-label small{margin-top:2px;}.ercw-promo-links{flex-direction:row;align-items:center;gap:24px;}.ercw-promo-story p{font-size:14px;}.ercw-promo-links a{padding:10px 0;}}
.ercw-promo{scroll-margin-top:110px;}

/* 心電圖分類：區分定期週報與獨立專文。 */
.ecg-articles-heading {
  max-width:1240px;
  margin:52px auto 22px;
  padding:0 var(--space-lg);
  scroll-margin-top:110px;
}
.ecg-articles-heading h2 {
  margin:0 0 8px;
  font-family:var(--font-display-zh);
  font-size:26px;
  font-weight:600;
  line-height:1.4;
  color:var(--color-ink);
}
.ecg-articles-heading p {
  margin:0;
  font-family:var(--font-body-zh);
  font-size:14px;
  line-height:1.7;
  color:var(--color-ink-3);
}
@media(max-width:700px){.ecg-articles-heading{margin-top:36px;}.ecg-articles-heading h2{font-size:23px;}}
