/* ==========================================================================
   course-search.css — 「コース名から検索」（ヘッダー Figma 312:34 / トップ Figma 63:170）
   --------------------------------------------------------------------------
   部品は js/components/course-name-search.js。ヘッダーの入力欄は index.html に静的に置いてあり、
   プリレンダの全ページへ写る。**このファイルはどのページでも後回しにしない**（起動前の静的HTMLで
   ヘッダーの形が決まらないと、起動時にヘッダーの中身がずれる）。
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. 部品の共通形（ガラスのピル＋右端の白い丸ボタン）
   -------------------------------------------------------------------------- */
.course-search {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
  border-radius: var(--radius-pill);
}

.course-search__input {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  line-height: 24px;
  letter-spacing: 0.04em;
  color: inherit;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

/* 入力欄の既定の×ボタン（type="search"）は使わない。白い丸ボタンと並んで紛らわしい */
.course-search__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
}

.course-search__submit {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 50%;
  cursor: pointer;
}

/* フォーカスは枠全体に出す（入力欄の outline は消している） */
.course-search:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* 写真の上では緑の枠が沈むので白にする */
.course-search--hero:focus-within,
body.has-hero-header .course-search--header:focus-within {
  outline-color: rgba(255, 255, 255, 0.8);
}

/* 候補の一覧（白いカード。写真の上でも読めるように地は不透明） */
.course-search__panel {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  z-index: 60;
  max-height: min(60vh, 440px);
  overflow-y: auto;
  padding: var(--space-2) 0;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  color: var(--ink-900);
  text-align: left;
}

.course-search__list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.course-search__option {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  padding: 10px var(--space-4);
  color: var(--ink-900);
  text-decoration: none;
}

.course-search__option:hover,
.course-search__option[aria-selected='true'] {
  background: var(--accent-light);
}

.course-search__name {
  min-width: 0;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.5;
}

.course-search__pref {
  flex: 0 0 auto;
  font-size: var(--text-xs);
  color: var(--ink-500);
}

.course-search__note {
  margin: 0;
  padding: 6px var(--space-4);
  font-size: var(--text-xs);
  color: var(--ink-500);
}

.course-search__note:empty {
  display: none;
}

/* --------------------------------------------------------------------------
   2. ヘッダー（高さ40px・右端に32pxの丸ボタン）
   通常のヘッダー（白帯）では白地に灰色の枠。写真の上（has-hero-header）では Figma どおりのガラス。
   -------------------------------------------------------------------------- */
.course-search--header {
  height: 40px;
  padding: 0 3px 0 15px;
  border: 1px solid var(--border-color-strong);
  background: var(--surface);
  color: var(--ink-900);
}

.course-search--header .course-search__input::placeholder {
  color: var(--ink-500);
}

.course-search--header .course-search__submit {
  width: 32px;
  height: 32px;
  border: 0;
  background: var(--surface-sunken);
  color: var(--ink-900);
}

.course-search--header .course-search__submit:hover {
  background: var(--accent-light);
}

body.has-hero-header .course-search--header {
  padding: 0 2px 0 14px;
  border: 2px solid rgba(255, 255, 255, 0.32);
  background: rgba(0, 0, 0, 0.16);
  color: #fff;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}

body.has-hero-header .course-search--header .course-search__input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}

body.has-hero-header .course-search--header .course-search__submit {
  border: 0.875px solid #fff;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

body.has-hero-header .course-search--header .course-search__submit:hover {
  background: rgba(255, 255, 255, 0.97);
}

/* スマホ幅で開く虫眼鏡ボタン（検討リストのピルと同じ見た目の丸） */
.site-header__search-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-color-strong);
  background: var(--surface);
  color: var(--ink-800);
  cursor: pointer;
}

body.has-hero-header .site-header__search-toggle {
  border: 2px solid rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

/* 狭い幅: 入力欄はヘッダーの下に開く。
   【境目は960px】3列にすると左右の列は (幅 − 余白 − 464) ÷ 2 しか残らず、960px未満ではロゴ（194px）と
   検討リスト（約160px）が収まらない（768pxでロゴが120pxに潰れ、検討リストが3行に折れた・2026-10-31 実測） */
@media (max-width: 959px) {
  .site-header__search {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: var(--space-4);
    right: var(--space-4);
  }

  .site-header.is-search-open .site-header__search {
    display: flex;
  }

  /* 写真の上で開いたときは地を濃くする（下の写真で文字が沈まないように） */
  body.has-hero-header .site-header.is-search-open .site-header__search {
    background: rgba(0, 0, 0, 0.8);
  }
}

/* 広い幅: ロゴ・入力欄・検討リストの3列。入力欄は真ん中に置く（Figma は左右の欄が同じ320px） */
@media (min-width: 960px) {
  .site-header__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 464px) minmax(0, 1fr);
  }

  /* 列は固定する。トップでは入力欄を display:none にするので、固定しないと検討リストが
     真ん中の列へ詰めて入る（右端から中央寄りへずれた・2026-10-31） */
  .site-header__logo {
    grid-column: 1;
    justify-self: start;
  }

  .site-header__search {
    grid-column: 2;
  }

  .site-header__nav {
    grid-column: 3;
    justify-self: end;
  }

  .site-header__search-toggle {
    display: none;
  }
}

/* 狭い幅: 虫眼鏡ボタンのぶん（52px）ヘッダーが詰まる。ロゴを小さくして収める。
   写真の上のロゴの高さは home.css の `body.has-hero-header …`（詳細度 0,2,1。プリレンダはインラインの
   style にも同じ規則がある）が決めるので、それより強く書く（0,2,2）。弱いと幅だけ縮んでロゴが
   横に潰れていた（320px で 138×24・2026-10-31 実測） */
.site-header__logo-img {
  object-fit: contain; /* 縮められても縦横比は崩さない（最後の砦） */
}

@media (max-width: 399px) {
  html body.has-hero-header .site-header__logo-img,
  html body .site-header__logo-img {
    height: 20px;
  }
}

@media (max-width: 359px) {
  html body.has-hero-header .site-header__logo-img,
  html body .site-header__logo-img {
    height: 16px;
  }
}

/* トップはヒーローに大きな入力欄があるので、ヘッダーには出さない */
body.is-home .site-header__search,
body.is-home .site-header__search-toggle {
  display: none;
}

/* --------------------------------------------------------------------------
   3. トップページ（検索カードの下・幅720px・高さ76px・右端に44pxの丸ボタン）
   -------------------------------------------------------------------------- */
.course-search--hero {
  width: 100%;
  height: 76px;
  padding: 0 14px 0 30px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.16);
  color: #fff;
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}

/* 検索カードとの間は32px（Figma 63:206 の gap）。ヒーローの縦の間隔は48px（.home-hero__inner）なので詰める */
.home-hero__inner > .course-search--hero {
  margin-top: calc(32px - var(--space-7));
}

.course-search--hero .course-search__input::placeholder {
  color: rgba(255, 255, 255, 0.65);
}

.course-search--hero .course-search__submit {
  width: 44px;
  height: 44px;
  border: 0.875px solid #fff;
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink-900);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
}

.course-search--hero .course-search__submit:hover {
  background: rgba(255, 255, 255, 0.97);
}

@media (max-width: 719px) {
  .course-search--hero {
    height: 60px;
    padding: 0 8px 0 22px;
  }
}
