/* ==========================================================================
   消化內科個人衛教網頁樣式表
   設計原則：醫療信賴感、手機優先、長輩友善大字體、極速載入、支援列印
   ========================================================================== */

:root {
  --bg: #fafbf9;
  --surface: #ffffff;
  --surface-tint: #f1f7f6;
  --primary: #0f6b63;
  --primary-dark: #0b4f49;
  --primary-soft: #e4f3f1;
  --text: #1e293b;
  --text-muted: #475569;
  --border: #dce6e4;
  --warning-bg: #fff7ed;
  --warning-border: #fdba74;
  --warning-text: #9a3412;
  --radius: 14px;
  --shadow: 0 4px 20px rgba(15, 107, 99, 0.06);
  --font-base: 17px;
}

/* 大字模式（長輩友善） */
html.large-font {
  --font-base: 20px;
}

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

html {
  scroll-behavior: smooth;
  font-size: var(--font-base);
}

body {
  margin: 0;
  font-family: "Noto Sans TC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1.25rem;
}

/* 導覽列 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  text-decoration: none;
  color: var(--primary-dark);
  font-weight: 700;
  font-size: 1.05rem;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.main-nav {
  display: flex;
  gap: 1.25rem;
}

.main-nav a {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.95rem;
  transition: color 0.15s;
}

.main-nav a:hover {
  color: var(--primary);
}

.font-toggle {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--primary-dark);
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 38px;
}

.font-toggle[aria-pressed="true"] {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Hero 區 */
.hero {
  padding: 3rem 0 2.75rem;
  background: linear-gradient(180deg, #eef7f5 0%, var(--bg) 100%);
  border-bottom: 1px solid var(--border);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1.35fr 0.85fr;
  gap: 2.25rem;
  align-items: center;
}

.hero-pill {
  display: inline-block;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.35rem 0.85rem;
  border-radius: 999px;
  margin-bottom: 0.9rem;
}

.hero-title {
  margin: 0 0 0.75rem;
  font-size: 2.1rem;
  line-height: 1.25;
  color: var(--text);
}

.hero-role {
  display: block;
  font-size: 1.15rem;
  font-weight: 500;
  color: var(--primary);
  margin-top: 0.35rem;
}

.hero-tagline {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 540px;
}

.quick-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

/* 按鈕 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.7rem 1.2rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  border: 1.5px solid transparent;
  min-height: 46px;
  transition: transform 0.1s, background-color 0.15s, border-color 0.15s;
}

.btn:active {
  transform: translateY(1px);
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.btn-secondary:hover {
  background: #d3ebe8;
}

.btn-outline {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.btn-sm {
  padding: 0.5rem 1rem;
  min-height: 42px;
  font-size: 0.9rem;
}

/* 醫師卡片 */
.doctor-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--shadow);
}

.doctor-avatar {
  width: 148px;
  height: 148px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.95rem;
  border: 4px solid #fff;
  box-shadow: 0 4px 14px rgba(15, 107, 99, 0.12);
  overflow: hidden;
}

.doctor-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.doctor-card-meta strong {
  display: block;
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.doctor-card-meta p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

/* 區塊通用 */
.section {
  padding: 3.25rem 0;
}

.section-tinted {
  background: var(--surface-tint);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.section-head {
  margin-bottom: 1.75rem;
}

.section-head h2 {
  margin: 0 0 0.4rem;
  font-size: 1.55rem;
  color: var(--primary-dark);
}

.section-head p {
  margin: 0;
  color: var(--text-muted);
}

/* 衛教文章控制與卡片 */
.article-controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tab-btn {
  padding: 0.45rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  min-height: 40px;
}

.tab-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  font-weight: 700;
}

.search-box input {
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  font-size: 0.92rem;
  font-family: inherit;
  min-width: 260px;
  min-height: 42px;
  background: var(--surface);
}

.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

.article-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.15s;
}

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

.article-cat {
  display: inline-block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--primary);
  background: var(--primary-soft);
  padding: 0.2rem 0.65rem;
  border-radius: 6px;
  margin-bottom: 0.65rem;
}

.article-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.12rem;
  line-height: 1.4;
}

.article-excerpt {
  margin: 0 0 1.1rem;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.article-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.85rem;
  border-top: 1px solid #eef2f1;
}

.read-time {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* 互動小工具 */
.tools-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.tool-header {
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  margin-bottom: 1.1rem;
}

.tool-icon {
  font-size: 1.6rem;
  line-height: 1;
}

.tool-header h3 {
  margin: 0 0 0.2rem;
  font-size: 1.12rem;
}

.tool-header p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.tool-form, .tool-form-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
  margin-bottom: 1rem;
}

.tool-form label, .tool-form-inline label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.88rem;
  font-weight: 700;
}

.tool-form input[type="date"],
.tool-form-inline select {
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.95rem;
  min-height: 42px;
}

.prep-result {
  background: var(--surface-tint);
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 0.85rem;
}

.prep-step {
  padding: 0.65rem 0;
  border-bottom: 1px dashed var(--border);
}

.prep-step:last-child {
  border-bottom: none;
}

.prep-step strong {
  color: var(--primary-dark);
  display: block;
  margin-bottom: 0.2rem;
}

.prep-step p {
  margin: 0;
  font-size: 0.9rem;
}

.tool-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.symptom-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.chip-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  font-size: 0.88rem;
  cursor: pointer;
}

.chip-check input:checked + span {
  color: var(--primary-dark);
  font-weight: 700;
}

.summary-box {
  background: #f8fafc;
  border: 1.5px solid var(--primary);
  border-radius: 10px;
  padding: 1rem;
  font-size: 0.92rem;
}

/* 門診表 */
.schedule-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
}

.schedule-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.schedule-card h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: var(--primary-dark);
}

.schedule-location {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.schedule-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.15rem;
  font-size: 0.9rem;
}

.schedule-table th, .schedule-table td {
  border: 1px solid var(--border);
  padding: 0.55rem 0.45rem;
  text-align: center;
}

.schedule-table th {
  background: var(--surface-tint);
  color: var(--primary-dark);
}

.slot-active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-weight: 700;
}

/* 醫師簡介 */
.about-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1.5rem;
}

.about-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.about-card h3 {
  margin: 0 0 0.9rem;
  font-size: 1.12rem;
  color: var(--primary-dark);
}

.clean-list {
  margin: 0;
  padding-left: 1.25rem;
}

.clean-list li {
  margin-bottom: 0.45rem;
}

/* 頁尾 */
.site-footer {
  background: #132a27;
  color: #d6e4e2;
  padding: 2.25rem 0;
  font-size: 0.88rem;
}

.disclaimer-box {
  background: rgba(255, 255, 255, 0.07);
  border-left: 4px solid #2dd4bf;
  padding: 1rem 1.15rem;
  border-radius: 8px;
  margin-bottom: 1.25rem;
  line-height: 1.65;
}

.footer-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem;
  color: #9cb8b4;
}

/* 文章閱讀 Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(15, 23, 42, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-dialog {
  background: var(--surface);
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
}

.modal-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-tint);
}

.modal-cat {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--primary-dark);
}

.modal-actions {
  display: flex;
  gap: 0.4rem;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 0.35rem 0.7rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
}

.icon-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.close-btn {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.close-btn:hover {
  background: var(--primary-dark);
  color: #fff;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-body h2 {
  margin: 0 0 1rem;
  font-size: 1.45rem;
  line-height: 1.35;
}

.tldr-box {
  background: var(--primary-soft);
  border-left: 4px solid var(--primary);
  padding: 1rem 1.15rem;
  border-radius: 8px;
  margin-bottom: 1.35rem;
}

.tldr-box h4 {
  margin: 0 0 0.45rem;
  color: var(--primary-dark);
}

.tldr-box ul {
  margin: 0;
  padding-left: 1.2rem;
}

.redflag-box {
  background: var(--warning-bg);
  border: 1px solid var(--warning-border);
  color: var(--warning-text);
  padding: 1rem 1.15rem;
  border-radius: 8px;
  margin-top: 1.35rem;
}

.redflag-box h4 {
  margin: 0 0 0.4rem;
}

.article-section h3 {
  margin: 1.35rem 0 0.5rem;
  font-size: 1.12rem;
  color: var(--primary-dark);
}

/* 響應式調整 */
@media (max-width: 768px) {
  .main-nav {
    display: none;
  }
  .hero-grid {
    grid-template-columns: 1fr;
    text-align: left;
  }
  .hero-title {
    font-size: 1.75rem;
  }
  .search-box input {
    min-width: 100%;
    width: 100%;
  }
}

/* 列印模式（方便印出衛教單張） */
@media print {
  .site-header, .hero, #articles, #tools, #schedule, #about, .site-footer, .modal-topbar {
    display: none !important;
  }
  .modal-backdrop {
    position: static;
    background: none;
    padding: 0;
  }
  .modal-dialog {
    max-height: none;
    box-shadow: none;
  }
}
