/* =========
   全站設定
   :root 是最適合新手修改顏色的地方；改這裡會影響整個網站。
   ========= */
:root {
  --color-primary: #7fa07a;
  --color-primary-dark: #4f6f51;
  --color-accent: #b66f4b;
  --color-ink: #263029;
  --color-muted: #67736a;
  --color-line: #dfe7dd;
  --color-bg: #f7faf6;
  --color-surface: #ffffff;
  --color-surface-soft: #eef5ec;
  --shadow-soft: 0 14px 32px rgba(38, 48, 41, 0.11);
  --font-serif: "Noto Serif TC", "Source Han Serif TC", "PMingLiU", Georgia, serif;
  --font-sans: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
  --content-width: 1080px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.75;
}

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

a {
  color: var(--color-primary-dark);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
}

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

/* =========
   中英文切換
   預設顯示中文；body 加上 lang-en 後顯示英文。
   ========= */
.en {
  display: none;
}

.block {
  display: none;
}

body.lang-en .zh {
  display: none;
}

body.lang-en .en {
  display: inline;
}

body.lang-en .en.block {
  display: block;
}

/* =========
   頁首與導覽列
   四個 HTML 檔的 header 內容一樣，只是 active 位置不同。
   ========= */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 24px;
  align-items: center;
  padding: 16px max(24px, calc((100vw - var(--content-width)) / 2));
  border-bottom: 1px solid var(--color-line);
  background: rgba(247, 250, 246, 0.94);
  backdrop-filter: blur(12px);
}

.site-title {
  color: var(--color-ink);
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
  text-decoration: none;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.site-nav a,
.lang-toggle {
  min-height: 38px;
  border-radius: 8px;
  font-size: 0.92rem;
  line-height: 1.2;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  color: var(--color-muted);
  text-decoration: none;
}

.site-nav a:hover,
.site-nav a.active {
  background: var(--color-surface-soft);
  color: var(--color-primary-dark);
}

.lang-toggle {
  border: 1px solid var(--color-primary);
  background: var(--color-surface);
  color: var(--color-primary-dark);
  cursor: pointer;
  font-weight: 700;
  padding: 8px 12px;
}

.lang-toggle:hover {
  background: var(--color-primary);
  color: #ffffff;
}

/* =========
   首頁主圖
   若要換主圖，請替換 assets/hero-lab.jpg，不需要改 CSS。
   ========= */
.hero {
  position: relative;
  min-height: 74vh;
  display: grid;
  align-items: end;
  overflow: hidden;
  border-bottom: 1px solid var(--color-line);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(20, 31, 24, 0.76) 0%, rgba(20, 31, 24, 0.55) 36%, rgba(20, 31, 24, 0.12) 76%);
}

.hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.hero-content {
  position: relative;
  z-index: 1;
  width: min(var(--content-width), calc(100% - 48px));
  margin: 0 auto;
  padding: 88px 0 72px;
  color: #ffffff;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--color-primary-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #dbead8;
}

h1,
h2,
h3 {
  font-family: var(--font-serif);
  line-height: 1.35;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(2.2rem, 6vw, 4.4rem);
  font-weight: 800;
}

h2 {
  margin: 0 0 18px;
  color: var(--color-primary-dark);
  font-size: 1.72rem;
}

h3 {
  margin: 0 0 10px;
  color: var(--color-ink);
  font-size: 1.16rem;
}

p {
  margin: 0 0 18px;
}

.lead {
  max-width: 760px;
  margin-top: 24px;
  font-size: 1.15rem;
  line-height: 1.85;
}

/* =========
   主要版面
   section 的寬度一致，讀起來像 Markdown 文件。
   ========= */
.section,
.page-heading {
  width: min(var(--content-width), calc(100% - 48px));
  margin: 0 auto;
}

.section {
  padding: 58px 0;
  border-bottom: 1px solid var(--color-line);
}

.page {
  padding-top: 48px;
}

.page-heading {
  padding: 30px 0 44px;
  border-bottom: 1px solid var(--color-line);
}

.page-heading-photo {
  position: relative;
  width: 100%;
  min-height: clamp(210px, 28vw, 340px);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  margin-top: -48px;
  overflow: hidden;
  border-right: 0;
  border-left: 0;
  border-radius: 0;
  background: var(--color-primary-dark);
  padding: 70px max(24px, calc((100vw - var(--content-width)) / 2)) 58px;
}

.page-heading-photo::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(20, 31, 24, 0.74) 0%, rgba(20, 31, 24, 0.48) 52%, rgba(20, 31, 24, 0.18) 100%);
}

.page-heading-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.page-heading-photo > :not(.page-heading-image) {
  position: relative;
  z-index: 1;
}

.page-heading-photo .eyebrow,
.page-heading-photo h1,
.page-heading-photo .lead,
.page-heading-photo a {
  color: #ffffff;
}

.page-heading-photo .lead {
  max-width: 760px;
}

.page-heading-photo.photo-empty::before {
  content: "Banner Photo";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.68);
  font-weight: 700;
}

.intro-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 48px;
  align-items: start;
}

.contact-panel,
.theme-card,
.news-item,
.member-card {
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-surface);
}

.contact-panel {
  padding: 26px;
  box-shadow: var(--shadow-soft);
}

.contact-panel h2 {
  font-size: 1.25rem;
}

.news-list {
  display: grid;
  gap: 18px;
}

.news-item {
  padding: 24px;
}

.news-item time {
  display: block;
  margin-bottom: 8px;
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 800;
}

.theme-grid,
.member-grid,
.activity-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.theme-card,
.member-card,
.activity-card {
  padding: 24px;
}

.activity-card {
  overflow: hidden;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-surface);
}

.theme-card-media {
  overflow: hidden;
  padding: 0;
}

.theme-card-media h3,
.theme-card-media p {
  padding: 0 22px;
}

.theme-card-media h3 {
  margin-top: 20px;
}

.theme-card-media p {
  padding-bottom: 22px;
}

.theme-card-media h3 a {
  color: var(--color-ink);
  text-decoration: none;
}

.theme-card-media h3 a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
  text-underline-offset: 0.18em;
}

.activity-photo,
.theme-photo,
.research-photo,
.gallery-item {
  position: relative;
  width: 100%;
  margin: 0;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-surface-soft);
}

.activity-photo img,
.theme-photo img,
.research-photo img,
.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  color: var(--color-muted);
  font-size: 0.95rem;
  font-weight: 700;
}

/* 沒有照片檔時顯示預留框，避免出現破圖圖示。 */
.photo-empty .photo-placeholder {
  display: grid;
}

.activity-body {
  padding: 22px;
}

.activity-body time {
  display: block;
  margin-bottom: 8px;
  color: var(--color-accent);
  font-size: 0.9rem;
  font-weight: 800;
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.gallery-item {
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-surface);
}

.gallery-item figcaption {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 24px 18px 14px;
  background: linear-gradient(180deg, rgba(38, 48, 41, 0) 0%, rgba(38, 48, 41, 0.76) 100%);
  color: #ffffff;
  font-size: 0.95rem;
  font-weight: 700;
}

.research-topic {
  max-width: 900px;
}

.research-visual-card {
  max-width: var(--content-width);
}

.research-photo {
  border: 1px solid var(--color-line);
  border-radius: 8px;
}

.research-copy {
  max-width: 860px;
  padding-top: 26px;
}

ul,
ol {
  padding-left: 1.3em;
}

li {
  margin-bottom: 10px;
}

.featured-member {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) auto;
  gap: 24px;
  align-items: center;
}

.member-photo {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 5;
  margin: 0 0 18px;
  overflow: hidden;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  background: var(--color-surface-soft);
}

.featured-member .member-photo {
  margin-bottom: 0;
}

.member-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 沒有照片檔時顯示預留框，避免出現破圖圖示。 */
.member-photo.photo-empty::after {
  content: "Photo";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--color-muted);
  font-size: 0.95rem;
  font-weight: 700;
}

.member-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.member-links a,
.profile-link a {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  border: 1px solid var(--color-primary);
  border-radius: 8px;
  padding: 8px 12px;
  color: var(--color-primary-dark);
  font-weight: 700;
  text-decoration: none;
}

.member-links a:hover,
.profile-link a:hover {
  background: var(--color-primary);
  color: #ffffff;
}

.note-section {
  max-width: 820px;
}

.publication-list {
  max-width: 860px;
}

/* =========
   頁尾
   ========= */
.site-footer {
  padding: 36px 24px;
  background: #233028;
  color: #f4f7f3;
  text-align: center;
}

.site-footer p {
  margin: 0 0 8px;
}

.site-footer a {
  color: #dbead8;
}

/* =========
   手機版排版
   ========= */
@media (max-width: 820px) {
  .site-header {
    grid-template-columns: 1fr auto;
    gap: 12px;
  }

  .site-nav {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .hero {
    min-height: 78vh;
  }

  .hero::after {
    background: linear-gradient(180deg, rgba(20, 31, 24, 0.78) 0%, rgba(20, 31, 24, 0.58) 55%, rgba(20, 31, 24, 0.2) 100%);
  }

  .hero-content {
    width: min(100% - 32px, var(--content-width));
    padding-bottom: 54px;
  }

  .section,
  .page-heading:not(.page-heading-photo) {
    width: min(100% - 32px, var(--content-width));
  }

  .page-heading-photo {
    min-height: 240px;
    padding: 54px 16px 38px;
  }

  .intro-section,
  .featured-member {
    grid-template-columns: 1fr;
  }

  .featured-member .member-photo {
    max-width: 220px;
    margin-bottom: 0;
  }

  .theme-grid,
  .member-grid,
  .activity-grid,
  .gallery-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  body {
    font-size: 16px;
  }

  .site-title {
    font-size: 0.95rem;
  }

  .site-nav a {
    padding: 8px 10px;
  }

  h1 {
    font-size: 2.35rem;
  }

  h2 {
    font-size: 1.45rem;
  }

  .lead {
    font-size: 1.04rem;
  }
}
