/* assets/css/style.css */

/* --- Base Styles --- */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family:
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    sans-serif;
}

:root {
  --main-green: #1b5e20;
  --dark-green: #0d3b12;
  --glass: rgba(255, 255, 255, 0.75);
}

html {
  scroll-behavior: smooth;
}

body {
  position: relative;
  color: #222;
  line-height: 1.8;
  overflow-x: hidden;
}

/* すべての画像を親要素の幅に収める */
img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 10px auto;
}

/* PCやタブレットでは画像の幅を絞る */
@media (min-width: 769px) {
  img {
    width: 60%;
  }
}

/* --- Animated Background --- */

body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: -2;
  width: 100%;
  height: 100%;
  background-image:
    url("../images/background.jpg");
  background-size: cover;
  background-position: center;
  transform: scale(1.05);
  animation:
    bgMove
    30s
    ease-in-out
    infinite
    alternate;
}

@keyframes bgMove {
  from {
    transform:
      scale(1.05)
      translateY(0);
  }

  to {
    transform:
      scale(1.1)
      translateY(-20px);
  }
}

body::after {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  z-index: -1;
  width: 100%;
  height: 100%;
  background:
    rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(3px);
}

/* --- Layout Parts --- */

header {
  padding: 60px 20px 40px;
  text-align: center;
}

header h1 {
  color: var(--main-green);
  font-size: 3rem;
  letter-spacing: 4px;
  animation: fadeDown 1s ease;
}

header h1 a {
  color: inherit;
  text-decoration: none;
}

header p {
  margin-bottom: 15px;
  font-size: 1.2rem;
  opacity: 0.8;
}

main {
  width: 100%;
  max-width: 1100px;
  margin: auto;
  padding: 20px;
}

footer {
  padding: 40px 10px;
  color: #333;
  font-size: 0.85rem;
  text-align: center;
  opacity: 0.8;
}

/* --- Components --- */

.card {
  width: 100%;
  min-width: 0;
  padding: 30px;
  margin-bottom: 40px;
  background: var(--glass);
  border-radius: 16px;
  box-shadow:
    0 15px 40px
    rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  transition: 0.4s ease;
  animation: fadeUp 1s ease both;
}

.card:hover {
  transform: translateY(-6px);
  box-shadow:
    0 20px 50px
    rgba(0, 0, 0, 0.12);
}

.card h2 {
  padding-left: 12px;
  margin-bottom: 20px;
  border-left:
    6px solid
    var(--main-green);
  font-size: 1.4rem;
}

.nav-links a {
  position: relative;
  display: inline-block;
  padding: 10px 18px;
  margin: 6px 12px 6px 0;
  overflow: hidden;
  color: white;
  font-size: 0.9rem;
  text-decoration: none;
  background:
    linear-gradient(
      135deg,
      var(--main-green),
      var(--dark-green)
    );
  border-radius: 30px;
  transition: 0.3s ease;
}

.nav-links a:hover {
  transform: translateY(-3px);
  box-shadow:
    0 8px 20px
    rgba(0, 0, 0, 0.2);
}

/* --- List Styles --- */

ul {
  list-style: none;
}

ul li {
  padding: 10px 0;
  border-bottom:
    1px solid
    rgba(0, 0, 0, 0.08);
  transition: 0.3s;
}

ul li:hover {
  padding-left: 8px;
  color: var(--main-green);
}

/* --- Animations --- */

@keyframes fadeDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(40px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Table Styles（全ページ共通） --- */

.lecture-table-wrapper {
  width: 100%;
  max-width: 100%;
  margin-top: 10px;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  background:
    rgba(255, 255, 255, 0.4);
  border-radius: 8px;
  overflow: hidden;
}

th {
  padding: 12px 15px;
  color: white;
  font-weight: bold;
  text-align: center;
  white-space: nowrap;
  background-color:
    var(--main-green);
}

td {
  padding: 12px 15px;
  border-bottom:
    1px solid
    rgba(0, 0, 0, 0.05);
  vertical-align: middle;
  text-align: left;
}

tr:hover {
  background-color:
    rgba(255, 255, 255, 0.6);
}

/*
 * リサーチクエスチョン表以外の表にだけ
 * 短い列を改行しない設定を適用する。
 */
table:not(.research-question-table)
td:nth-child(1),
table:not(.research-question-table)
td:nth-child(2),
table:not(.research-question-table)
td:nth-child(3),
table:not(.research-question-table)
td:nth-child(4) {
  white-space: nowrap;
}

/*
 * リサーチクエスチョン表以外の
 * 一番右の列。
 */
table:not(.research-question-table)
td:last-child {
  width: auto;
  min-width: 15em;
  text-align: left;
}

/* --- リサーチ・クエスチョン表専用 --- */

/*
 * 質問文を横スクロールさせず、
 * カード内で折り返す。
 */
.research-question-table-wrapper {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/*
 * 列幅を固定して、
 * 質問列を残り幅に収める。
 */
.research-question-table {
  width: 100%;
  max-width: 100%;
  table-layout: fixed;
}

/* 学年列 */
.research-question-table
.research-grade-column {
  width: 5.5em;
}

/* 氏名列 */
.research-question-table
.research-name-column {
  width: 8em;
}

/* 質問列 */
.research-question-table
.research-question-column {
  width: auto;
}

/*
 * ヘッダの学年列・氏名列は
 * 改行しない。
 */
.research-question-table
th:nth-child(1),
.research-question-table
th:nth-child(2) {
  white-space: nowrap;
}

/*
 * 質問列のヘッダは
 * 必要なら改行する。
 */
.research-question-table
th:nth-child(3) {
  white-space: normal;
}

/*
 * 学年セル。
 */
.research-question-table
.research-grade-cell {
  white-space: nowrap;
  vertical-align: middle;
}

/*
 * 氏名セル。
 */
.research-question-table
.research-name-cell {
  white-space: nowrap;
  vertical-align: middle;
}

/*
 * リサーチクエスチョンのセル。
 *
 * rowspanによって列番号が変化しても、
 * クラス名で指定しているため影響を受けない。
 */
.research-question-table
.research-question-cell {
  width: auto;
  min-width: 0;
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: normal;
  line-break: strict;
  text-align: left;
  vertical-align: top;
}

/*
 * 各行の最後のセルは質問セルなので、
 * 念のため折り返しを明示する。
 */
.research-question-table
tbody
td:last-child {
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  word-break: normal;
}

/*
 * 読み込み中、エラー、
 * データなし表示用のセル。
 */
.research-question-table
.research-message-cell,
.research-question-table
td[colspan="3"] {
  width: auto;
  min-width: 0;
  white-space: normal;
  overflow-wrap: anywhere;
  text-align: center;
}

/* --- Components（Badges & Buttons） --- */

.badge {
  display: inline-block;
  padding: 2px 10px;
  color: var(--main-green);
  font-size: 0.85rem;
  white-space: nowrap;
  background: #e8f5e9;
  border:
    1px solid
    var(--main-green);
  border-radius: 4px;
}

/* --- Research Content Styles（nowstudy.html用） --- */

.study-list,
main ul {
  margin-bottom: 20px;
  list-style: none;
}

.study-list li,
main ul li {
  position: relative;
  padding:
    12px
    10px
    12px
    30px;
  border-bottom:
    1px solid
    rgba(0, 0, 0, 0.08);
  transition: 0.3s ease;
}

.study-list li::before,
main ul li::before {
  content: "";
  position: absolute;
  top: 1.1em;
  left: 8px;
  width: 8px;
  height: 8px;
  background-color:
    var(--main-green);
  border-radius: 50%;
  box-shadow:
    0 0 5px
    rgba(27, 94, 32, 0.3);
}

.study-list li:hover,
main ul li:hover {
  padding-left: 35px;
  background-color:
    rgba(27, 94, 32, 0.05);
}

/* --- Back Link --- */

.back-link {
  margin: 20px 0 40px;
  text-align: center;
}

.back-link a {
  display: inline-block;
  padding: 12px 30px;
  color: #333;
  font-size: 0.9rem;
  text-decoration: none;
  background: #fff;
  border-radius: 30px;
  box-shadow:
    0 2px 8px
    rgba(0, 0, 0, 0.1);
  transition: 0.3s;
}

.back-link a:hover {
  color: #000;
  background: #fdfdfd;
  transform: translateY(-2px);
  box-shadow:
    0 5px 15px
    rgba(0, 0, 0, 0.15);
}

/* --- Staff Page Styles（staff.html用） --- */

.staff-card {
  display: flex;
  gap: 40px;
  padding: 40px;
  margin-bottom: 40px;
  background: var(--glass);
  border-radius: 16px;
  box-shadow:
    0 15px 40px
    rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(10px);
  transition: 0.4s ease;
  animation: fadeUp 1s ease both;
}

.staff-card:hover {
  transform: translateY(-5px);
  box-shadow:
    0 20px 50px
    rgba(0, 0, 0, 0.12);
}

.staff-photo-wrap {
  flex: 0 0 220px;
}

.staff-photo {
  width: 220px;
  height: 280px;
  overflow: hidden;
  background: #fff;
  border-radius: 12px;
  box-shadow:
    0 5px 15px
    rgba(0, 0, 0, 0.1);
}

.staff-photo img {
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: cover;
}

.staff-info {
  flex: 1;
  min-width: 0;
}

.staff-info h2 {
  display: inline-block;
  padding-right: 20px;
  margin-bottom: 10px;
  color: var(--dark-green);
  font-size: 2rem;
  border-bottom:
    2px solid
    var(--main-green);
}

ruby {
  ruby-align: space-around;
}

rt {
  color: var(--main-green);
  font-size: 0.4em;
  font-weight: normal;
  letter-spacing: 0.15em;
  transform: translateY(-2px);
}

.name-spacer {
  display: inline-block;
  width: 0.5em;
}

.staff-role {
  display: block;
  margin-bottom: 20px;
  color: var(--main-green);
  font-size: 1.1rem;
  font-weight: bold;
}

.staff-detail-item {
  margin-bottom: 15px;
}

.staff-detail-item b {
  display: block;
  margin-bottom: 3px;
  color: var(--dark-green);
  font-size: 0.95rem;
}

.btn-link {
  display: inline-block;
  padding: 8px 18px;
  margin-top: 10px;
  color: white;
  font-size: 0.85rem;
  text-decoration: none;
  background:
    linear-gradient(
      135deg,
      var(--main-green),
      var(--dark-green)
    );
  border-radius: 30px;
  transition: 0.3s;
}

.btn-link:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

/* --- Topics Page Styles（topics.html用） --- */

#news-container {
  max-height: 70vh;
  padding: 10px;
  overflow-y: auto;
  border-radius: 8px;
}

.news-item {
  padding: 20px;
  margin-bottom: 15px;
  background: white;
  border-radius: 10px;
  box-shadow:
    0 4px 10px
    rgba(0, 0, 0, 0.05);
  opacity: 0;
  transform: translateY(30px);
  transition:
    all
    0.6s
    cubic-bezier(
      0.23,
      1,
      0.32,
      1
    );
}

.news-item.show {
  opacity: 1;
  transform: translateY(0);
}

#news-container::-webkit-scrollbar {
  width: 6px;
}

#news-container::-webkit-scrollbar-thumb {
  background-color:
    rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

/* --- Responsive --- */

@media (max-width: 768px) {
  header {
    padding:
      40px
      15px
      30px;
  }

  header h1 {
    font-size: 2.2rem;
  }

  header p {
    font-size: 1rem;
  }

  main {
    padding: 12px;
  }

  .card {
    padding: 20px;
  }

  th,
  td {
    padding: 10px;
    font-size: 0.9rem;
  }

  /*
   * スマホでは学年列を狭くする。
   */
  .research-question-table
  .research-grade-column {
    width: 3.5em;
  }

  /*
   * スマホでは氏名列を狭くする。
   */
  .research-question-table
  .research-name-column {
    width: 5.5em;
  }

  .research-question-table th,
  .research-question-table td {
    padding: 8px 6px;
  }

  .research-question-table
  .research-question-cell {
    font-size: 0.86rem;
    line-height: 1.7;
  }

  .staff-card {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 30px 20px;
  }

  .staff-photo-wrap {
    flex: 0 0 auto;
  }

  .staff-info {
    width: 100%;
  }

  .staff-info h2 {
    display: block;
    padding-right: 0;
    text-align: center;
  }

  .staff-role {
    text-align: center;
  }
}