/* ============================================================
   テーマ発見セクション（components/theme_discovery.php）
   /recommend 着地客の回遊導線: 全幅検索 + 急上昇/人気/近いカテゴリの棚。
   色は style/tokens.css のトークン（--c-*）を参照する。
   ============================================================ */

/* サイトのグローバル section{display:flex;justify-content:center} を打ち消す
   （既存 .recommend-ranking-section と同様） */
.theme-disco {
  display: block;
  text-align: left;
  margin-top: 10px;
  padding: 18px 1rem 6px;
  border-top: 1px solid var(--c-cool-border-soft);
}

.theme-disco--search-only {
  border-top: 0;
  margin-top: 6px;
  padding-top: 2px;
}

.theme-disco__title {
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--c-cool-text-deep);
  letter-spacing: 0.02em;
}

.theme-disco__title::before {
  content: '';
  flex: 0 0 auto;
  width: 3px;
  height: 15px;
  background: var(--c-brand);
  border-radius: 2px;
  margin-right: 8px;
}

/* ---------- 検索ボックス ---------- */

.theme-disco__search {
  position: relative;
  display: block;
  width: 100%;
}

.theme-disco__icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  fill: var(--c-cool-text-weak);
  pointer-events: none;
}

/* font-size は必ず16px以上: iOS Safari のフォーカス時オートズーム回避 */
.theme-disco__input {
  display: block;
  width: 100%;
  box-sizing: border-box;
  height: 48px;
  margin: 0;
  padding: 0 44px 0 44px;
  font-size: 16px;
  color: var(--c-cool-text-deep);
  background: var(--c-cool-surface);
  border: 1.5px solid var(--c-border-2);
  border-radius: 12px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  transition:
    border-color 0.15s,
    background 0.15s,
    box-shadow 0.15s;
}

.theme-disco__input::placeholder {
  color: var(--c-cool-text-weak);
}

/* type=search のネイティブ取消ボタンを抑止（自作✕と二重表示になるため）。iOS は元々非表示 */
.theme-disco__input::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  display: none;
}

.theme-disco__input:focus {
  background: var(--c-bg);
  border-color: var(--c-brand);
  box-shadow: 0 0 0 3px var(--c-brand-ring);
}

.theme-disco__clear {
  position: absolute;
  right: 6px;
  top: 0;
  bottom: 0;
  width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-cool-text-weak);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

.theme-disco__clear:hover {
  color: var(--c-cool-text);
}

.theme-disco__clear[hidden] {
  display: none;
}

.theme-disco__spinner {
  width: 20px;
  height: 20px;
  border: 2.5px solid var(--c-cool-border);
  border-top-color: var(--c-brand);
  border-radius: 50%;
  animation: theme-disco-spin 0.7s linear infinite;
  margin: 8px 2px;
}

@keyframes theme-disco-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------- 結果・棚 ---------- */

.theme-disco__results {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  align-content: flex-start;
  gap: 8px;
  margin-top: 14px;
}

.theme-disco__shelves {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 16px;
}

/* [hidden] を確実に優先（display:flex に勝たせる） */
.theme-disco__results[hidden],
.theme-disco__shelves[hidden] {
  display: none;
}

.theme-disco__shelf {
  animation: theme-disco-fade 0.4s ease both;
  animation-delay: calc(var(--i, 0) * 60ms);
}

@keyframes theme-disco-fade {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .theme-disco__shelf {
    animation: none;
  }
}

.theme-disco__shelf-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-cool-text);
  margin-bottom: 9px;
}

.theme-disco__shelf-ico {
  font-size: 13px;
  line-height: 1;
}

.theme-disco__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---------- テーマチップ ---------- */

.theme-disco-chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--c-cool-text-strong);
  background: var(--c-cool-surface);
  border: 1px solid var(--c-border-2);
  border-radius: 999px;
  padding: 8px 14px;
  line-height: 1.15;
  transition:
    transform 0.08s ease,
    background 0.12s,
    border-color 0.12s;
}

.theme-disco-chip:hover {
  background: var(--c-cool-surface-hover);
  border-color: var(--c-cool-border);
}

.theme-disco-chip:active {
  transform: scale(0.96);
}

.theme-disco-chip--hot {
  color: var(--c-chip-hot-text);
  background: var(--c-chip-hot-bg);
  border-color: var(--c-chip-hot-border);
  font-weight: 700;
}

.theme-disco-chip--hot:hover {
  background: var(--c-chip-hot-bg-hover);
  border-color: var(--c-chip-hot-border-hover);
}

.theme-disco__empty {
  font-size: 13px;
  color: var(--c-cool-text-weak);
  padding: 6px 2px;
}

/* ---------- テーマ0件時のフォールバック
     （一致するオープンチャット＝部屋。チップでなくリスト行で“部屋”と分かる見せ方） ---------- */

.theme-disco__rooms {
  display: block;
  width: 100%;
}

.theme-disco__note {
  font-size: 13px;
  color: var(--c-cool-text-weak);
  padding: 2px 2px 0;
}

.theme-disco__rooms-h {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--c-cool-text);
  margin: 10px 0 8px;
}

.theme-disco__rooms-h::before {
  content: '💬';
  font-size: 12px;
}

.theme-disco__room {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 11px;
  margin-bottom: 8px;
  background: var(--c-bg);
  border: 1px solid var(--c-cool-border-soft);
  border-radius: 10px;
  text-decoration: none;
}

.theme-disco__room:active {
  background: var(--c-cool-surface);
}

.theme-disco__room-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--c-cool-text-heading);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-disco__room-meta {
  font-size: 12px;
  color: var(--c-cool-text);
}
