/*
 * サイト内検索の新しいパネル（inc/search-panel.php・js/search-panel.js）
 * 色と寸法は改善仕様書 5章・7章、モックアップ「C6」に合わせる。
 * 文字はサイトの基準の rem で書く（THE THOR はスマホで 1rem＝12px、幅768px以上で 11px）。
 * THE THOR の見出し・リストなどの飾りが入らないよう、要素ごとに値を書き切る。
 */

/* --- ヘッダーの虫眼鏡（開閉を兼ねる）とハンバーガー（修正指示書 2026-11-04 修正C） ---
 * 赤い四角（#a83f3f）はどの瞬間も一つだけ。検索を開いている間だけ、赤がハンバーガーから虫眼鏡へ移る
 *   閉じている：虫眼鏡は白地に #191919。ハンバーガーは THE THOR のまま（PCは赤い四角、スマホは背景なし）
 *   開いている：虫眼鏡は赤地に白。PCのハンバーガーは白地に #191919（スマホは変えない）
 * 地の色は開閉の状態（虫眼鏡の aria-expanded／html.miena-sp-open。JSが同じ瞬間に切り替える）だけで決める。
 * マウスを乗せても、フォーカスがあっても変えない（フォーカスは枠線で示す）。
 * 切り替えの動きは THE THOR のまま両方 0.15秒（途中でも赤が二つそろうことはない） */
.l-header .searchBtn .searchBtn__link,
.l-header .searchBtn .searchBtn__link:hover,
.l-header .searchBtn .searchBtn__link:focus,
.l-header .searchBtn .searchBtn__link::before {
  background: #ffffff;
  color: #191919;
}
.l-header .searchBtn .searchBtn__link[aria-expanded="true"],
.l-header .searchBtn .searchBtn__link[aria-expanded="true"]:hover,
.l-header .searchBtn .searchBtn__link[aria-expanded="true"]:focus {
  background: #a83f3f;
  color: #ffffff;
}
.l-header .searchBtn .searchBtn__link[aria-expanded="true"]::before {
  background: transparent;
  color: #ffffff;
}
.l-header .searchBtn .searchBtn__link:focus {
  outline: none;
}
.l-header .searchBtn .searchBtn__link:focus-visible {
  outline: 3px solid #2c5e33;
  outline-offset: -3px;
}
@media (min-width: 992px) {
  html.miena-sp-open .l-header .menuBtn .menuBtn__link {
    background: #ffffff;
    color: #191919;
  }
}
/* スマホ・タブレット（THE THOR の小さいヘッダー） */
@media (max-width: 991px) {
  /* 虫眼鏡：押せる範囲を 56×55px の四角にする */
  .l-header .searchBtn .searchBtn__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 55px;
    margin: -18.5px 0;
    border-radius: 0;
  }
  /* ハンバーガー：見た目（18×18px のアイコン）は変えず、押せる範囲だけを広げる（修正D）。
   * 横は虫眼鏡の右端から画面の右端まで（どの幅でも 53px。虫眼鏡と重ねない）、縦は虫眼鏡と同じ 55px */
  .l-header .menuBtn .menuBtn__link {
    position: relative;
  }
  .l-header .menuBtn .menuBtn__link::after {
    content: "";
    position: absolute;
    top: -20.5px;
    right: -15px;
    bottom: -16.5px;
    left: -20px;
  }
}

/* --- パネル全体（ヘッダーの直下から下を覆う。ヘッダーは隠さない） --- */
.miena-sp {
  --miena-sp-top: 0px;
  position: fixed;
  top: var(--miena-sp-top);
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 9990;
  font-family: inherit;
  color: #1f2a22;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}
.miena-sp[hidden],
.miena-sp [hidden] {
  display: none !important;
}
.miena-sp *,
.miena-sp *::before,
.miena-sp *::after {
  box-sizing: border-box;
}
.miena-sp :focus-visible {
  outline: 3px solid #2c5e33;
  outline-offset: 2px;
}

/* パネルより下のグレー（押すと閉じる） */
.miena-sp .miena-sp__scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: rgba(20, 28, 22, 0.55);
  cursor: pointer;
  touch-action: none;
}

/* 幅いっぱいの白い帯。高さは中身なり、下に120px以上のグレーを残す */
.miena-sp .miena-sp__sheet {
  position: absolute;
  z-index: 1; /* グレー（HTMLでは後ろに置いている）より上 */
  top: 0;
  left: 0;
  right: 0;
  max-height: calc(100vh - var(--miena-sp-top) - 120px);
  max-height: calc(100dvh - var(--miena-sp-top) - 120px);
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  background: #ffffff;
  border-bottom: 1px solid #c9d1c7;
  box-shadow: 0 8px 20px rgba(20, 28, 22, 0.25);
}
.miena-sp .miena-sp__body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 12px 16px 16px;
}

/* 1段目：検索欄と検索ボタン（間は12px以上） */
.miena-sp .miena-sp__form {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin: 0;
}
.miena-sp .miena-sp__field {
  position: relative;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  min-width: 0;
}
.miena-sp .miena-sp__lead {
  position: absolute;
  left: 12px;
  pointer-events: none;
}
.miena-sp .miena-sp__input {
  width: 100%;
  min-height: 48px;
  margin: 0;
  padding: 10px 44px 10px 40px;
  border: 1.5px solid #77837a;
  border-radius: 10px;
  background: #ffffff;
  color: #1f2a22;
  font: inherit;
  font-size: 1.4rem; /* スマホで16.8px：iPhoneの自動拡大を防ぐ */
  line-height: 1.5;
  box-shadow: none;
  -webkit-appearance: none;
  appearance: none;
}
.miena-sp .miena-sp__input:focus {
  border: 2px solid #2c5e33;
  padding: 9.5px 43.5px 9.5px 39.5px;
  outline: none;
}
.miena-sp .miena-sp__input::-webkit-search-cancel-button,
.miena-sp .miena-sp__input::-webkit-search-decoration {
  display: none;
  -webkit-appearance: none;
}
.miena-sp .miena-sp__clear {
  position: absolute;
  top: 50%;
  right: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -22px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.miena-sp .miena-sp__submit {
  flex-shrink: 0;
  min-width: 64px;
  min-height: 48px;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 10px;
  background: #3d7f45;
  color: #ffffff;
  font: inherit;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.miena-sp .miena-sp__submit[aria-busy="true"] {
  cursor: progress;
}

/* 2段目：候補の言葉（見た目34px、押せる範囲は疑似要素で縦44pxに広げる） */
.miena-sp .miena-sp__words,
.miena-search-none .miena-sp__words {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 6px;
}
.miena-sp .miena-sp__word,
.miena-search-none .miena-sp__word {
  position: relative;
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px; /* 仕様は左右12px。幅375pxで6語を2段に収めるため10pxにする */
  border: 1.5px solid #77837a;
  border-radius: 999px;
  background: #f3f6f1;
  color: #2f4a33;
  font-size: 1.2rem;
  line-height: 1.4;
  letter-spacing: 0;
  text-decoration: none;
}
.miena-sp .miena-sp__word::after,
.miena-search-none .miena-sp__word::after {
  content: "";
  position: absolute;
  inset: -5px -3px;
}
.miena-sp .miena-sp__word:hover,
.miena-search-none .miena-sp__word:hover {
  color: #1f2a22;
  background: #e8eee5;
}

/* 区切り線の下：心のレイヤーから探す（カテゴリ一覧） */
.miena-sp .miena-sp__all,
.miena-search-none .miena-sp__all {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding-top: 4px;
  border-top: 1px solid #c9d1c7;
  color: #1f2a22;
  font-size: 1.3rem;
  font-weight: 500;
  line-height: 1.5;
  text-decoration: none;
}
.miena-sp .miena-sp__all svg,
.miena-search-none .miena-sp__all svg {
  flex-shrink: 0;
}
.miena-sp .miena-sp__all:hover,
.miena-search-none .miena-sp__all:hover {
  color: #2c5e33;
}

.miena-sp .miena-sp__vh,
.miena-search-launcher__vh {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* 検索結果ページ：0件のとき（改善仕様書 6章。候補の言葉と「心のレイヤー」はパネルと同じ見た目） */
.miena-search-none {
  display: flex;
  flex-direction: column;
  gap: 16px;
  text-align: left;
  color: #1f2a22;
  line-height: 1.5;
}
.miena-search-none .miena-search-none__lead {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

/* 検索結果ページ：語を分けて探し直した結果のときの一文（修正B） */
.miena-search-loose {
  margin: 0 0 16px;
  color: #4f5a52;
  font-size: 1.4rem;
  line-height: 1.6;
}

/* 開いている間は、裏のページをスクロールさせない */
html.miena-sp-open,
html.miena-sp-open body {
  overflow: hidden;
}

/* メニュー内の検索欄（押すと新しいパネルが開く） */
.miena-search-launcher {
  margin: 0;
}
.miena-search-launcher .widgetSearch__input {
  font-size: 1.4rem;
}
