/* ===================================================
   言葉屋（KOTOBA-YA）サイト内検索 スタイルシート
   Design: 和モダン × AI × ミニマル
   =================================================== */

/* 1. モーダルオーバーレイ */
.kotobaya-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 99999;
  background: rgba(18, 34, 56, 0.48);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1),
              visibility 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.kotobaya-search-overlay.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 2. 検索カードウィンドウ */
.kotobaya-search-card {
  width: 100%;
  max-width: 660px;
  background: #ffffff;
  border-radius: 16px;
  border: 1px solid rgba(226, 230, 232, 0.9);
  box-shadow: 0 24px 64px rgba(18, 34, 56, 0.16),
              0 6px 20px rgba(18, 34, 56, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 80px);
  transform: translateY(-8px) scale(0.99);
  transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1);
}

.kotobaya-search-overlay.is-active .kotobaya-search-card {
  transform: translateY(0) scale(1);
}

/* 3. 検索入力ヘッダー */
.kotobaya-search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid #edf0f2;
  background: #ffffff;
}

.kotobaya-search-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  gap: 12px;
}

.kotobaya-search-icon {
  flex-shrink: 0;
  color: #3a7594;
  opacity: 0.85;
}

.kotobaya-search-input {
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 1.05rem;
  color: #122238;
  line-height: 1.5;
  padding: 4px 0;
}

.kotobaya-search-input::placeholder {
  color: #8c9ba5;
  font-size: 0.95rem;
}

.kotobaya-search-clear {
  border: none;
  background: #edf1f4;
  color: #5c6b78;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 0.72rem;
  padding: 0;
  line-height: 1;
  transition: background 0.15s ease, color 0.15s ease;
}

.kotobaya-search-clear:hover {
  background: #dfe5e9;
  color: #122238;
}

.kotobaya-search-close {
  border: 1px solid #e2e6e8;
  background: #f7f9fa;
  color: #5c6b78;
  padding: 4px 8px;
  border-radius: 6px;
  font-family: "DM Mono", monospace;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1.2;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.kotobaya-search-close:hover {
  background: #eef2f5;
  border-color: #cad2d6;
  color: #122238;
}

/* 4. クイックタグエリア */
.kotobaya-search-quicktags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 20px;
  background: #f9fbfb;
  border-bottom: 1px solid #edf0f2;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.kotobaya-search-quicktags::-webkit-scrollbar {
  display: none;
}

.quicktag-label {
  font-size: 0.76rem;
  color: #718290;
  font-weight: 500;
  margin-right: 4px;
}

.quicktag-btn {
  border: 1px solid #e1e7ea;
  background: #ffffff;
  color: #2a3b4c;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.quicktag-btn:hover {
  border-color: #3a7594;
  color: #3a7594;
  background: #f0f6fa;
  transform: translateY(-1px);
}

/* 5. 検索結果ボディ */
.kotobaya-search-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px 12px 14px;
  min-height: 220px;
  max-height: 52vh;
}

.results-heading {
  font-size: 0.75rem;
  font-family: "DM Mono", monospace;
  letter-spacing: 0.08em;
  color: #718290;
  padding: 8px 10px 6px;
  text-transform: uppercase;
}

/* 結果アイテム */
.search-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: background 0.15s ease, transform 0.15s ease;
  margin-bottom: 4px;
  border: 1px solid transparent;
}

.search-result-item:hover,
.search-result-item.is-selected {
  background: #f0f6fa;
  border-color: #d8e5ee;
  transform: translateX(2px);
}

.result-item-main {
  flex: 1;
  min-width: 0;
}

.result-item-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.result-badge {
  display: inline-block;
  font-family: "DM Mono", monospace;
  font-size: 0.68rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: rgba(58, 117, 148, 0.08);
  color: #3a7594;
  font-weight: 500;
  letter-spacing: 0.04em;
}

.result-title {
  margin: 0 0 4px;
  font-size: 0.98rem;
  font-weight: 600;
  color: #122238;
  line-height: 1.4;
}

.search-result-item:hover .result-title,
.search-result-item.is-selected .result-title {
  color: #3a7594;
}

.result-summary {
  margin: 0;
  font-size: 0.84rem;
  color: #5c6b78;
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.result-arrow {
  color: #a4b3be;
  font-size: 1.05rem;
  flex-shrink: 0;
  transition: color 0.15s ease, transform 0.15s ease;
}

.search-result-item:hover .result-arrow,
.search-result-item.is-selected .result-arrow {
  color: #3a7594;
  transform: translateX(3px);
}

/* マッチ語ハイライト */
.search-mark {
  background: rgba(58, 117, 148, 0.18);
  color: #122238;
  font-weight: 700;
  padding: 0 2px;
  border-radius: 2px;
  box-shadow: 0 1px 0 #3a7594;
}

/* 6. 空状態（見つからなかった時） */
.kotobaya-search-empty {
  padding: 36px 20px 28px;
  text-align: center;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: #122238;
  margin: 0 0 8px;
}

.empty-desc {
  font-size: 0.88rem;
  color: #5c6b78;
  line-height: 1.6;
  max-width: 440px;
  margin: 0 auto 20px;
}

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.empty-contact-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: 8px;
  background: #3a7594;
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  transition: background 0.15s ease;
}

.empty-contact-btn:hover {
  background: #315f7a;
}

.empty-guide-btn {
  display: inline-flex;
  align-items: center;
  padding: 9px 18px;
  border-radius: 8px;
  background: #f2f5f7;
  color: #2a3b4c;
  font-size: 0.86rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid #e1e7ea;
  transition: background 0.15s ease;
}

.empty-guide-btn:hover {
  background: #e6ebef;
}

/* 7. フッター */
.kotobaya-search-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  background: #f7f9fa;
  border-top: 1px solid #edf0f2;
  font-size: 0.74rem;
  color: #718290;
}

.search-shortcuts-help {
  display: flex;
  align-items: center;
  gap: 14px;
}

.search-shortcuts-help kbd {
  display: inline-block;
  padding: 2px 5px;
  border-radius: 4px;
  border: 1px solid #d2dbe0;
  background: #ffffff;
  color: #3b4d5d;
  font-family: "DM Mono", monospace;
  font-size: 0.7rem;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  margin-right: 3px;
}

.search-powered-by {
  font-family: "Noto Serif JP", serif;
  letter-spacing: 0.06em;
  color: #8c9ba5;
}

/* ===================================================
   トリガーボタン（ヘッダー用 & ヒーロー用）
   =================================================== */

/* 8. ヘッダー内の検索ボタントリガー */
.header-search-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-line, #e2e6e8);
  background: rgba(255, 255, 255, 0.85);
  color: var(--color-muted, #5c6b78);
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 1px 4px rgba(18, 34, 56, 0.04);
}

.header-search-btn:hover {
  border-color: var(--color-blue-accent, #3a7594);
  background: var(--color-paper-card, #ffffff);
  color: var(--color-ink, #122238);
  box-shadow: 0 3px 10px rgba(58, 117, 148, 0.12);
  transform: translateY(-1px);
}

.header-search-btn svg {
  color: var(--color-blue-accent, #3a7594);
  flex-shrink: 0;
}

.search-btn-text {
  font-weight: 500;
  color: var(--color-ink-soft, #2a3b4c);
}

.search-key-badge {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 2px;
}

.search-key-badge kbd {
  font-family: var(--font-mono, "DM Mono", monospace);
  font-size: 0.68rem;
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid #d2dbe0;
  background: #f7f9fa;
  color: #718290;
  line-height: 1.2;
}

/* 9. ヒーローセクション内のクイック検索バー */
.v2-hero-search-bar {
  margin-top: 22px;
  max-width: 520px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  background: #ffffff;
  border: 1px solid #dae1e5;
  border-radius: 12px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(18, 34, 56, 0.05);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.v2-hero-search-bar:hover {
  border-color: var(--color-blue-accent, #3a7594);
  box-shadow: 0 6px 22px rgba(58, 117, 148, 0.14);
  transform: translateY(-2px);
}

.v2-hero-search-bar .search-icon {
  color: var(--color-blue-accent, #3a7594);
  flex-shrink: 0;
}

.v2-hero-search-bar .search-placeholder {
  flex: 1;
  font-size: 0.88rem;
  color: #6a7c8b;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.v2-hero-search-bar .search-badge {
  font-family: var(--font-mono, monospace);
  font-size: 0.72rem;
  padding: 3px 8px;
  border-radius: 6px;
  background: #f0f6fa;
  color: #3a7594;
  border: 1px solid #d6e4ed;
  flex-shrink: 0;
}

/* ===================================================
   レスポンシブ対応
   =================================================== */

@media (max-width: 991px) {
  .header-search-btn .search-key-badge {
    display: none;
  }
}

@media (max-width: 768px) {
  .kotobaya-search-overlay {
    padding: 16px 10px;
    align-items: flex-start;
  }

  .kotobaya-search-card {
    max-height: calc(100vh - 32px);
    border-radius: 14px;
  }

  .kotobaya-search-header {
    padding: 14px 14px;
  }

  .kotobaya-search-input {
    font-size: 0.95rem;
  }

  .kotobaya-search-quicktags {
    padding: 8px 12px;
    gap: 5px;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  .quicktag-label {
    flex-shrink: 0;
  }

  .quicktag-btn {
    flex-shrink: 0;
  }

  .kotobaya-search-body {
    max-height: 58vh;
    padding: 6px 8px 12px;
  }

  .search-result-item {
    padding: 10px 10px;
    gap: 10px;
  }

  .result-title {
    font-size: 0.92rem;
  }

  .result-summary {
    font-size: 0.8rem;
  }

  .kotobaya-search-footer {
    padding: 8px 14px;
  }

  .search-shortcuts-help {
    display: none;
  }

  .v2-hero-search-bar {
    width: 100%;
    margin-top: 20px;
  }
}
