/* ========================
  トップページ 共通
======================== */

.topPage {
  background-color: #fff;
  overflow: hidden;
}

/* ========================
  KV
======================== */

.topKv {
  overflow: hidden;
  position: relative;
}

/*
  ファーストビューで学部ボタンの2段目まで見えるよう、高さの上限を「画面の高さ − KV下〜学部2段目の高さ（約295px）＋余白」にする
  （画面が低すぎる場合でも 15rem は確保する）
*/
.topKv__slider {
  aspect-ratio: 1200 / 472;
  max-height: max(calc(100svh - 19rem), 15rem);
  width: 100%;
}

.topKv__slide {
  height: 100%;
  width: 100%;
}

.topKv__slide img {
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.topKv__body {
  left: 50%;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 51%;
  z-index: 3;
}

.topKv__title img {
  height: auto;
  width: 100%;
}

@media screen and (max-width: 767px) {
  .topKv__slider {
    aspect-ratio: auto;
    height: 12.5rem;
  }

  .topKv__body {
    width: 82.8%;
  }
}

/* ========================
  検索
======================== */

.topSearch {
  background-color: #fff;
  padding: 2.5rem 0;
}

.topSearch__tabs {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, 1fr);
  margin-bottom: 1.5rem;
  padding-bottom: 0.625rem;
}

.topSearch__tabButton {
  background-color: var(--colorGray200);
  border-radius: 0.625rem;
  color: var(--colorBlack);
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  height: 3.25rem;
  line-height: 1.4;
  position: relative;
  text-align: center;
  transition: background-color 0.3s ease-out, color 0.3s ease-out;
  width: 100%;
}

.topSearch__tabButton--active {
  background-color: var(--colorPrimary);
  color: #fff;
}

@media (hover: hover) {
  .topSearch__tabButton:hover {
    background-color: var(--colorPrimary);
    color: #fff;
  }
}

.topSearch__tabButton--active::after {
  border-left: 0.75rem solid transparent;
  border-right: 0.75rem solid transparent;
  border-top: 0.625rem solid var(--colorPrimary);
  content: "";
  left: 50%;
  position: absolute;
  top: 100%;
  transform: translateX(-50%);
}

.topSearch__panel {
  align-items: center;
  background-color: var(--colorGray50);
  border-radius: 1rem;
  display: none;
  flex-direction: column;
  gap: 2rem;
  padding: 2.5rem;
}

.topSearch__panel--active {
  display: flex;
}

.topSearch__group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
}

.topSearch__group--center {
  align-items: center;
}

.topSearch__heading {
  align-items: center;
  display: flex;
  font-size: 1rem;
  font-weight: 700;
  gap: 0.625rem;
  line-height: 1.4;
  width: 100%;
}

.topSearch__heading::before {
  background-color: var(--colorPrimary);
  border-radius: 100px;
  content: "";
  flex-shrink: 0;
  height: 1.125rem;
  width: 3px;
}

.topSearch__faculties {
  display: grid;
  gap: 0.6875rem 0.75rem;
  grid-template-columns: repeat(5, 1fr);
}

.topSearch__facultyButton {
  align-items: center;
  background-color: #fff;
  border: 1px solid var(--colorBorder);
  border-radius: 0.25rem;
  color: var(--colorBlack);
  cursor: pointer;
  display: flex;
  font-size: 0.875rem;
  justify-content: center;
  line-height: 1.2;
  min-height: 2.5rem;
  padding: 0 0.75rem;
  text-align: center;
  transition: border-color 0.3s ease-out, color 0.3s ease-out;
  width: 100%;
}

@media (hover: hover) {
  .topSearch__facultyButton:hover {
    border-color: var(--colorPrimary);
    color: var(--colorPrimary);
  }
}

.topSearch__facultyButton--active {
  border-color: var(--colorPrimary);
  color: var(--colorPrimary);
  font-weight: 700;
}

.topSearch__select {
  max-width: 100%;
  position: relative;
  width: 37.5rem;
}

.topSearch__selectInput {
  appearance: none;
  background-color: #fff;
  border: 1px solid var(--colorBorder);
  border-radius: 0.25rem;
  color: var(--colorBlack);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.875rem;
  height: 3.5rem;
  line-height: 1.2;
  padding: 0.75rem 3.25rem 0.75rem 1.25rem;
  width: 100%;
}

.topSearch__selectIcon {
  color: var(--colorPrimary);
  pointer-events: none;
  position: absolute;
  right: 1.125rem;
  top: 50%;
  transform: translateY(-50%);
}

.topSearch__submit {
  align-items: center;
  background-color: var(--colorPrimary);
  border: 1px solid var(--colorPrimary);
  border-radius: 0.375rem;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  flex-shrink: 0;
  justify-content: center;
  min-width: 15rem;
  padding: 1rem 2.5rem;
  position: relative;
  transition: background-color 0.3s ease-out, color 0.3s ease-out;
}

@media (hover: hover) {
  .topSearch__submit:hover {
    background-color: #fff;
    color: var(--colorPrimary);
  }
}

.topSearch__submit:disabled {
  cursor: progress;
}

.topSearch__submitIcon {
  left: 1rem;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

/* 処理中：アイコンをスピナーに差し替え */
.topSearch__submit--loading .topSearch__submitIcon {
  visibility: hidden;
}

.topSearch__submit--loading::before {
  animation: loadingSpin 0.8s linear infinite;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  content: "";
  height: 1.125rem;
  left: 1.0625rem;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.125rem;
}

@keyframes loadingSpin {
  to {
    transform: translateY(-50%) rotate(360deg);
  }
}

.topSearch__submitText {
  color: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.topSearch__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.5625rem;
  width: 100%;
}

.topSearch__tagItem--hidden {
  display: none;
}

.topSearch__tagButton {
  background-color: #fff;
  border: 1px solid var(--colorBorder);
  border-radius: 0.25rem;
  color: var(--colorBlack);
  cursor: pointer;
  font-size: 0.875rem;
  line-height: 1.2;
  min-height: 1.75rem;
  min-width: 4.875rem;
  padding: 0.25rem 0.75rem;
  text-align: center;
  transition: border-color 0.3s ease-out, color 0.3s ease-out;
}

@media (hover: hover) {
  .topSearch__tagButton:hover {
    border-color: var(--colorPrimary);
    color: var(--colorPrimary);
  }
}

.topSearch__tagButton--active {
  border-color: var(--colorPrimary);
  color: var(--colorPrimary);
  font-weight: 700;
}

.topSearch__tagMore {
  align-items: center;
  color: var(--colorCaption);
  cursor: pointer;
  display: flex;
  gap: 0.5rem;
  transition: opacity 0.3s ease-out;
}

@media (hover: hover) {
  .topSearch__tagMore:hover {
    opacity: 0.7;
  }
}

.topSearch__tagMoreIcon {
  align-items: center;
  border: 1px solid var(--colorCaption);
  border-radius: 50%;
  display: flex;
  flex-shrink: 0;
  height: 1.5rem;
  justify-content: center;
  width: 1.5rem;
}

.topSearch__tagMoreText {
  color: var(--colorCaption);
  font-size: 1rem;
  line-height: 1.4;
}

.topSearch__form {
  align-items: stretch;
  display: flex;
  width: 100%;
}

.topSearch__formLabel {
  clip: rect(0, 0, 0, 0);
  height: 1px;
  overflow: hidden;
  position: absolute;
  width: 1px;
}

.topSearch__formInput {
  background-color: #fff;
  border: 1px solid var(--colorBorder);
  border-radius: 0.25rem 0 0 0.25rem;
  border-right: none;
  flex: 1;
  font-family: inherit;
  font-size: 0.875rem;
  height: 3.5rem;
  line-height: 1.2;
  min-width: 0;
  padding: 0 1rem;
}

.topSearch__formInput::placeholder {
  color: var(--colorCaption);
}

.topSearch__formButton {
  align-items: center;
  background-color: var(--colorPrimary);
  border: 1px solid var(--colorPrimary);
  border-radius: 0 0.25rem 0.25rem 0;
  color: #fff;
  cursor: pointer;
  display: flex;
  flex-shrink: 0;
  height: 3.5rem;
  justify-content: center;
  position: relative;
  transition: background-color 0.3s ease-out, color 0.3s ease-out;
  width: 3.5rem;
}

@media (hover: hover) {
  .topSearch__formButton:hover {
    background-color: #fff;
    color: var(--colorPrimary);
  }
}

.topSearch__formButton:disabled {
  cursor: progress;
}

/* 処理中：アイコンをスピナーに差し替え */
.topSearch__formButton--loading .topSearch__formIcon {
  visibility: hidden;
}

.topSearch__formButton--loading::before {
  animation: loadingSpin 0.8s linear infinite;
  border: 2px solid currentColor;
  border-radius: 50%;
  border-right-color: transparent;
  content: "";
  height: 1.25rem;
  left: calc(50% - 0.625rem);
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 1.25rem;
}

@media screen and (max-width: 1080px) {
  .topSearch__faculties {
    grid-template-columns: repeat(3, 1fr);
  }
}

/*
  SP：タブとパネルを交互に並べ替えてアコーディオンにする（1つ開くと他は閉じる）
  （開閉は --spOpen を page.top.js で付け外し。PCのタブ選択状態 --active とは別管理）
*/
@media screen and (max-width: 767px) {
  .topSearch {
    padding: 2rem 0;
  }

  .topSearch__inner {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
  }

  /* タブのリストを解除し、ボタンとパネルを同じ並びに置いて order で交互にする */
  .topSearch__tabs,
  .topSearch__tab {
    display: contents;
  }

  .topSearch__tab:nth-child(1) {
    order: 1;
  }

  .topSearch__panel:nth-of-type(1) {
    order: 2;
  }

  .topSearch__tab:nth-child(2) {
    order: 3;
  }

  .topSearch__panel:nth-of-type(2) {
    order: 4;
  }

  .topSearch__tab:nth-child(3) {
    order: 5;
  }

  .topSearch__panel:nth-of-type(3) {
    order: 6;
  }

  .topSearch__tabButton,
  .topSearch__tabButton:hover,
  .topSearch__tabButton--active {
    background-color: var(--colorGray200);
    color: var(--colorBlack);
    height: 3.5rem;
    padding: 0 3rem 0 1.25rem;
    text-align: left;
  }

  .topSearch__tabButton.topSearch__tabButton--spOpen {
    background-color: var(--colorPrimary);
    color: #fff;
  }

  .topSearch__tabButton::after,
  .topSearch__tabButton--active::after {
    border: none;
    border-right: 2px solid currentColor;
    border-top: 2px solid currentColor;
    content: "";
    height: 0.5rem;
    left: auto;
    position: absolute;
    right: 1.25rem;
    top: calc(50% - 0.125rem);
    transform: translateY(-50%) rotate(135deg);
    transition: transform 0.3s ease-out;
    width: 0.5rem;
  }

  .topSearch__tabButton--spOpen::after {
    top: calc(50% + 0.125rem);
    transform: translateY(-50%) rotate(-45deg);
  }

  .topSearch__panel,
  .topSearch__panel--active {
    align-items: stretch;
    border-radius: 0.625rem;
    display: none;
    gap: 1.5rem;
    overflow: hidden;
    padding: 1.5rem 1rem;
  }

  .topSearch__panel--spOpen {
    display: flex;
  }

  /* 開閉アニメーション中に中身が縮まないようにする */
  .topSearch__panel > * {
    flex-shrink: 0;
  }

  .topSearch__faculties {
    gap: 0.5rem;
    grid-template-columns: repeat(2, 1fr);
  }

  .topSearch__facultyButton {
    min-height: 3rem;
    padding: 0 0.5rem 2px;
  }

  .topSearch__select {
    width: 100%;
  }

  .topSearch__tagMore {
    align-self: center;
  }

  .topSearch__submit {
    min-width: 0;
    width: 100%;
  }
}

/* ========================
  教員一覧
======================== */

.topTeacher {
  background-color: var(--colorBgPink);
  padding: 4rem 0;
}

.topTeacher__heading {
  align-items: center;
  color: var(--colorPrimary);
  display: flex;
  font-size: 2rem;
  font-weight: 700;
  gap: 1rem;
  justify-content: center;
  line-height: 1.4;
  padding-bottom: 2.5rem;
}

.topTeacher__heading::after,
.topTeacher__heading::before {
  background-color: var(--colorPrimary);
  content: "";
  height: 1px;
  width: 1.25rem;
}

.topTeacher__headingInner {
  align-items: center;
  display: flex;
  gap: 0.5rem;
}

.topTeacher__headingCount[hidden] {
  display: none;
}

.topTeacher__list {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(3, 1fr);
  transition: opacity 0.3s ease-out;
}

/* カード内の3行（キープ / 灰色の情報部分 / 研究内容）を同じ行のカードで揃える */
.topTeacher__item {
  display: grid;
  grid-row: span 3;
  grid-template-rows: subgrid;
  row-gap: 0;
}

.topTeacher[aria-busy="true"] .topTeacher__list {
  opacity: 0.4;
}

.topTeacher__empty {
  font-size: 0.875rem;
  line-height: 1.6;
  text-align: center;
}

.topTeacher__empty--hidden {
  display: none;
}

.topTeacher__moreWrap {
  display: flex;
  justify-content: center;
  padding-top: 1.5rem;
}

.topTeacher__moreWrap--hidden {
  display: none;
}

.topTeacher__more {
  align-items: center;
  background-color: #fff;
  border: 1px solid var(--colorPrimary);
  border-radius: 0.375rem;
  cursor: pointer;
  display: flex;
  height: 3.5rem;
  justify-content: center;
  min-width: 15rem;
  padding: 0.625rem 2.5rem;
  position: relative;
  transition: background-color 0.3s ease-out;
}

@media (hover: hover) {
  .topTeacher__more:hover {
    background-color: var(--colorAccentBg);
  }
}

.topTeacher__moreText {
  color: var(--colorPrimary);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.4;
}

.topTeacher__more:disabled {
  cursor: progress;
}

/* 処理中：＋アイコンをスピナーに差し替え（keyframes は検索エリアの loadingSpin を共用） */
.topTeacher__more--loading .topTeacher__moreIcon {
  visibility: hidden;
}

.topTeacher__more--loading::after {
  animation: loadingSpin 0.8s linear infinite;
  border: 2px solid var(--colorPrimary);
  border-radius: 50%;
  border-right-color: transparent;
  content: "";
  height: 1.125rem;
  position: absolute;
  right: 1.0625rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.125rem;
}

.topTeacher__moreIcon {
  color: var(--colorPrimary);
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
}

@media screen and (max-width: 1280px) {
  .topTeacher__list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media screen and (max-width: 767px) {
  .topTeacher {
    padding: 2rem 0;
  }

  .topTeacher__heading {
    font-size: 1.5rem;
    padding-bottom: 1.75rem;
  }

  .topTeacher__list {
    grid-template-columns: 1fr;
  }
}
