/* General Styles */

:root {
  /* 表示件数だけ変えたいなら --news-visible を編集 */
  --news-visible: 8;

  /* 既定値（必要に応じて調整可能） */
  --news-row-h: 3.25rem;     /* 1行の最小高さ */
  --news-gap: 0.25rem;       /* 行間 */
  --news-py: 0.75rem;        /* コンテナ上下パディング */

  /* 可視件数ぶんの高さ(= 5行相当)を自動計算 */
  --news-max-h: calc(
    var(--news-visible) * var(--news-row-h)
    + (var(--news-visible) - 1) * var(--news-gap)
    + 2 * var(--news-py)
  );
}

body {
  font-family: Arial, sans-serif;
  margin: 0;
  padding: 0;
  line-height: 1.6;
  background-color: #f9f9f9;
  color: #333;
}

/* Header */
header {
  background: url('images/MB_header.jpeg') no-repeat center center / cover;
  color: white;
  padding: 1.5em 0;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* タイトルだけ左寄せにする */
header #title {
  text-align: left;   /* 親(header)の center を上書き */
  margin: 0 0 0 16px; /* 必要なら左に少し余白 */
}


header h1 {
  margin: 0;
  font-size: 2em;
}

nav {
  margin-top: 1em;
}

nav ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  justify-content: center;
  gap: 15px;
}

nav ul li {
  margin: 0;
}

nav ul li a {
  color: white;
  text-decoration: none;
  font-size: 1em;
  padding: 10px 20px;
  border: 2px solid transparent;
  transition: all 0.3s ease;
}

nav ul li a:hover {
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid white;
  border-radius: 5px;
}

button#language-toggle {
  margin-top: 15px;
  padding: 10px 20px;
  font-size: 1em;
  background-color: white;
  color: #333;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

button#language-toggle:hover {
  background-color: #ddd;
}

/* Main Content */
main {
  padding: 20px;
}

section {
  margin: 30px 0;
  padding: 20px;
  background: white;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

section h2 {
  font-size: 2em;
  margin-bottom: 10px;
}

section p {
  font-size: 1.1em;
  color: #555;
}

/* Research Gallery */
#research-gallery {
  display: flex;
  gap: 15px;
  margin-top: 15px;
}

#research-gallery img {
  width: 100%;
  max-width: 300px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#research-gallery img:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Team Section */
#team-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.team-member {
  text-align: center;
  background: white;
  padding: 15px;
  border-radius: 10px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.team-member:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.team-photo {
  width: 100%;
  max-width: 150px;
  height: auto;
  border-radius: 50%;
  margin-bottom: 10px;
}

.team-member h3 {
  margin: 10px 0 5px;
  font-size: 1.2em;
}

.team-member p {
  margin: 0;
  font-size: 1em;
  color: #555;
}


/* Footer */
footer {
  background: #333;
  color: white;
  text-align: center;
  padding: 1em 0;
  position: fixed;
  bottom: 0;
  width: 100%;
  box-shadow: 0 -2px 4px rgba(0, 0, 0, 0.1);
}

footer p {
  margin: 0;
  font-size: 0.9em;
}

/* Responsive Design */
@media (max-width: 768px) {
  nav ul {
    flex-direction: column;
    align-items: center;
  }

  nav ul li {
    margin-bottom: 10px;
  }

  #research-gallery {
    flex-direction: column;
    align-items: center;
  }

  #research-gallery img {
    max-width: 90%;
  }
}

/* Language Toggle Button - Top Right */
#language-toggle {
  position: absolute;
  top: 15px;
  right: 15px;
  padding: 10px 20px;
  font-size: 1em;
  background-color: white;
  color: #333;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  transition: background-color 0.3s ease;
  z-index: 1000;
}

#language-toggle:hover {
  background-color: #ddd;
}

/* publications */
.author-underline {
  text-decoration: underline;
  text-underline-offset: 0.08em;
}


/* ===== スマホ専用の最小上書き。PC表示は不変 ===== */
/* 600px以下（多くのスマホ縦） */
@media (max-width: 600px) {
  /* ヘッダー：背景はcoverのまま、高さは上下余白で縮める */
  header { padding: 8px 0; background-position: center; background-size: cover; }
  header h1 { font-size: 1.4rem; } /* タイトル縮小 */
  nav { margin-top: .5rem; }
  nav ul { gap: 8px; }
  nav ul li a { font-size: .95rem; padding: 6px 10px; } /* ナビ縮小 */
  #language-toggle { top: 8px; right: 8px; padding: 6px 10px; font-size: .9rem; }

  /* 見出し/本文（スマホで少しだけ小さく） */
  #hero h2 { font-size: 1.25rem; }
  #hero .lead, section p { font-size: 1rem; }

  /* News：文字サイズとレイアウト（特異性を高めて上書き） */
  body #news .news-list { font-size: .95rem; max-height: 60vh; }
  body #news .news-row {
    grid-template-columns: 1fr; /* 日付→上、本文→下の縦積み */
    gap: .25rem;
    align-items: start;
  }
  body #news .news-row time { font-size: .9em; opacity: .9; }
  body #news .news-badge { font-size: .75rem; }
}

/* 400px以下（小さめ端末） */
@media (max-width: 400px) {
  header { padding: 6px 0; }
  header h1 { font-size: 1.2rem; }
  nav ul li a { padding: 4px 8px; font-size: .9rem; }
  #hero h2 { font-size: 1.1rem; }
  body #news .news-list { font-size: .9rem; }
}

/* ===== スマホでタブを横並びに戻す（style.css の末尾に追記） ===== */
@media (max-width: 600px) {
  /* 縦並び指定を打ち消して横並び */
  nav ul {
    flex-direction: row;      /* ← columnを上書き */
    flex-wrap: wrap;          /* 2段まで許容（スクロールなし） */
    justify-content: center;
    gap: 8px;
  }
  nav ul li { margin-bottom: 0; } /* 768pxルールの下マージンを打ち消し */
  nav ul li a {                   /* 少しだけ詰めると折返しにくい */
    padding: 6px 10px;
    font-size: .95rem;
  }
}

/* ▼“必ず1行で横並びにしたい”場合の代替（上とどちらか片方だけ使う） */
@media (max-width: 600px) {
  nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  nav ul {
    flex-direction: row;
    flex-wrap: nowrap;       /* 1行固定 */
    justify-content: flex-start;
    gap: 8px;
  }
  nav ul li { margin-bottom: 0; }
  nav ul li a { padding: 6px 10px; font-size: .95rem; }
}

/* ▼このページの <style> の末尾に“追記だけ”してください（PC表示は変わりません） */
@media (max-width: 600px) {
  /* 全文表示：高さ制限と省略を解除 */
  #news .news-list { max-height: none; }
  #news .news-text {
    display: block;               /* -webkit-box を解除 */
    -webkit-line-clamp: unset;
    -webkit-box-orient: unset;
    overflow: visible;
    grid-column: 1 / -1;          /* 2行目で全幅に */
    grid-row: 2;
    margin-top: .25rem;
  }

  /* 1行目：日付＋タグ、2行目：本文 */
  #news .news-row {
    grid-template-columns: auto auto 1fr; /* 日付 / タグ /（余白） */
    align-items: start;
    gap: .25rem .5rem;
  }
  #news .news-cell { display: contents; } /* 子を親グリッド直下に“昇格” */
  #news .news-row time { grid-column: 1; } /* 日付：1列目 */
  #news .news-badge { grid-column: 2; }    /* タグ：2列目（日付の右） */

  /* 見た目の微調整（任意） */
  #news .news-badge { font-size: .78rem; line-height: 1; }
	#news .news-row time { font-size: .95em; opacity: .9; }
}


/* ===== スマホ端末っぽい環境だけ適用（PCは不変／viewport固定でも発火） ===== */
@media (hover: none) and (pointer: coarse) {
  /* 1) 本文+10%（読みやすさだけ底上げ） */
  body { font-size: 110%; }

  /* 2) ヘッダーナビを“少し大きく”＆横並び維持（必要最低限だけ上書き） */
  nav ul {
    flex-direction: row;   /* 念のため横並びに戻す */
    flex-wrap: wrap;       /* 折返し許可（スクロールなし） */
    justify-content: center;
    gap: 10px;
  }
  nav ul li { margin-bottom: 0; }

  /* タブの可読性＆タップ領域を少し拡大（PCには影響しない） */
  nav ul li a {
    font-size: 1.4rem;     /* ご提示値でOK（≈17.6px相当） */
    padding: 10px 14px;
    line-height: 1.2;
    white-space: nowrap;
    min-height: 44px;      /* タップ領域の目安（任意） */
  }
}
/* ▼ このページの <head> 内 既存<style>ブロックの一番下に追加（PCは不変） */
@media (hover: none) and (pointer: coarse) {
  /* 日付の右にタグを置くための前提（未適用なら必須） */
  #news .news-cell { display: contents !important; }
  #news .news-row {
    grid-template-columns: auto auto 1fr !important; /* 日付 / タグ / 内容 */
    gap: 1.2rem !important;                            /* ← 距離を詰める肝 */
    align-items: start;
  }
  #news .news-row time { margin-right: 0; }
  #news .news-badge { margin-left: 0; font-size: .78rem; line-height: 1; }

  /* フィルタ（News直下）を約+20% */
  .news-filters { gap: .6rem; }
  .news-filter { font-size: 1.08rem; padding: .42rem .84rem; line-height: 1.15; }
}

/* スマホ端末だけ: タグを「日付の下」、本文は右側に */
@media (hover: none) and (pointer: coarse) {
  /* 子要素を親グリッドに直接配置できるようにする */
  #news .news-cell { display: contents !important; }

  /* 1行目: 日付 / 本文（右）
     2行目: タグ  / 本文（右） */
  #news .news-row {
    grid-template-columns: auto 1fr !important;         /* 左:日付/タグ, 右:本文 */
    grid-template-areas:
      "date text"
      "tag  text" !important;
    row-gap: .2rem;
    column-gap: .4rem;
    align-items: start;
  }

  #news .news-row time   { grid-area: date;  }
  #news .news-badge      { grid-area: tag;   margin-left: 0; }
  #news .news-text       { grid-area: text;  }
}
