/* ============================================================
   components.css — Shared UI Components
   ============================================================ */

/* ══════════════════════════════════════════
   APP-CARD — 汎用カード
   使用箇所: 検索結果, 辞書項目, Study Panel セクション
══════════════════════════════════════════ */
.app-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.app-card:hover {
    border-color: var(--accent-mid);
    box-shadow: var(--shadow-card);
}

/* Card header row — ref + word + meta + arrow */
.app-card-head {
    display: flex; align-items: center; gap: var(--space-sm);
    min-height: 40px; cursor: pointer; user-select: none;
}
.app-card-ref {
    font-size: var(--text-caption); font-weight: 700;
    color: var(--accent); flex-shrink: 0; letter-spacing: 0.04em;
}
.app-card-word {
    font-family: var(--font-greek);
    font-size: var(--text-body-lg); color: var(--text);
    flex: 1; min-width: 0;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.app-card-meta { display: flex; gap: var(--space-xs); flex-wrap: wrap; align-items: center; }
.app-card-arrow {
    font-size: var(--text-caption); color: var(--text-hint);
    transition: transform var(--transition-fast); flex-shrink: 0;
}
.app-card.open .app-card-arrow { transform: rotate(90deg); }

/* Expandable body */
.app-card-body {
    display: none;
    padding-top: var(--space-sm);
    border-top: 1px solid var(--border);
    margin-top: var(--space-sm);
    animation: fadeUp var(--transition-fast);
}
.app-card.open .app-card-body { display: block; }

/* Japanese translation row */
.app-card-ja {
    font-size: var(--text-caption); color: var(--text-sub); line-height: 1.65;
    padding: var(--space-xs) var(--space-sm); background: var(--bg-panel);
    border-radius: var(--radius-s);
    border-left: 2px solid var(--border);
    margin-bottom: var(--space-sm);
}

/* ══════════════════════════════════════════
   APP-SECTION — セクションラッパー
   .section-block + .section-title のエイリアス
══════════════════════════════════════════ */
.app-section { margin-bottom: 40px; }
.app-section-title {
    font-size: var(--text-caption); font-weight: 600;
    letter-spacing: var(--tracking-section);
    color: var(--text-sub);
    margin-bottom: var(--space-md); padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border);
}

/* ══════════════════════════════════════════
   APP-CHIP — 汎用チップ
   使用箇所: フィルター, 品詞, 語形, 書物グループ
══════════════════════════════════════════ */
.app-chip {
    display: inline-flex; align-items: center; gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-l);
    font-size: var(--text-caption); font-weight: 500;
    border: 1px solid var(--border);
    background: var(--bg-panel); color: var(--text-sub);
    transition: all var(--transition-fast); cursor: default; user-select: none;
}
/* Active state */
.app-chip.active,
.app-chip--active {
    background: var(--accent-light);
    border-color: var(--accent-mid);
    color: var(--accent);
}
/* Clickable toggle */
.app-chip--toggle { cursor: pointer; }
.app-chip--toggle:hover { background: var(--accent-light); }
.app-chip--toggle.off {
    background: var(--bg); color: var(--text-hint);
    text-decoration: line-through;
}
.app-chip--toggle.off:hover { background: var(--bg-panel); text-decoration: none; }

/* ══════════════════════════════════════════
   APP-BADGE — インラインバッジ
   使用箇所: 集中度, 品詞ラベル, 頻度
══════════════════════════════════════════ */
.app-badge {
    display: inline-block; padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-l);
    font-size: var(--text-caption); font-weight: 700; letter-spacing: 0.06em;
    border: 1px solid; vertical-align: middle;
}
.app-badge--neutral {
    background: var(--bg-panel); border-color: var(--border);
    color: var(--text-sub);
}
.app-badge--accent {
    background: var(--accent-light); border-color: var(--accent-mid);
    color: var(--accent);
}
.app-badge--green {
    background: rgba(45,106,79,0.10); border-color: rgba(45,106,79,0.25);
    color: #2d6a4f;
}
.app-badge--amber {
    background: rgba(160,144,80,0.10); border-color: rgba(160,144,80,0.25);
    color: #a09050;
}
.app-badge--blue {
    background: rgba(26,95,168,0.08); border-color: rgba(26,95,168,0.25);
    color: #1a5fa8;
}

/* ══════════════════════════════════════════
   APP-BTN — 汎用ボタン
══════════════════════════════════════════ */
.app-btn {
    display: inline-flex; align-items: center; gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md); border-radius: var(--radius-s);
    font-size: var(--text-caption); font-weight: 600; font-family: inherit;
    border: 1px solid var(--border);
    background: var(--bg-panel); color: var(--text-sub);
    cursor: pointer; text-decoration: none;
    transition: all var(--transition-fast); user-select: none; white-space: nowrap;
}
.app-btn:hover {
    background: var(--accent-light); border-color: var(--accent-mid);
    color: var(--accent);
}
.app-btn--primary {
    background: var(--accent); color: #fff;
    border-color: var(--accent);
}
.app-btn--primary:hover { opacity: var(--opacity-primary); background: var(--accent); color: #fff; border-color: var(--accent); }
.app-btn--ghost {
    background: transparent; border-color: transparent;
    padding: var(--space-xs) var(--space-sm);
}
.app-btn--ghost:hover { background: var(--bg-panel); border-color: var(--border); color: var(--text); }

/* ══════════════════════════════════════════
   INFO-CARD — Study Panelセクションカード
   使用箇所: 意味, 語構成, 語源, Louw-Nida, 関連語
══════════════════════════════════════════ */
.info-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-m);
    overflow: hidden;
    margin-bottom: var(--space-sm);
    font-size: var(--text-caption);
}
.info-card-head {
    display: flex; align-items: center; gap: var(--space-sm);
    padding: var(--space-sm) var(--space-md); background: var(--bg-panel);
    cursor: pointer; user-select: none;
    transition: background var(--transition-fast); min-height: 44px;
}
.info-card-head:hover { background: #ebebed; }
.info-card-icon {
    font-size: var(--text-body-lg); flex-shrink: 0;
    color: var(--text-sub); line-height: 1;
}
/* Material Symbols アイコン対応 */
.info-card-icon.material-symbols-outlined {
    font-size: var(--text-body-lg);
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
}
.info-card-title {
    flex: 1; font-size: var(--text-caption); font-weight: 700;
    color: var(--text-sub); letter-spacing: 0.04em;
}
.info-card-arrow {
    font-size: var(--text-caption); color: var(--text-hint);
    transition: transform var(--transition-fast); flex-shrink: 0;
    display: inline-flex; align-items: center;
}
.info-card-arrow svg { width: 11px; height: 11px; display: block; }
.info-card.open .info-card-arrow { transform: rotate(180deg); }
.info-card-body {
    display: none; padding: var(--space-sm) var(--space-md);
    border-top: 1px solid var(--border);
    animation: fadeUp var(--transition-fast);
}
.info-card.open .info-card-body { display: block; }

/* ══════════════════════════════════════════
   DISCOVERY-CARD — 分析サマリーカード
   使用箇所: morph-search, syntax-search のトップ
══════════════════════════════════════════ */
.discovery-card {
    padding: var(--space-md) var(--space-md); background: var(--bg);
    border: 1.5px solid var(--accent-mid);
    border-radius: var(--radius-m); margin-bottom: var(--space-lg);
}
.discovery-card-title {
    font-size: var(--text-caption); font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--accent); margin-bottom: var(--space-sm);
}
.discovery-word {
    font-family: var(--font-greek);
    font-size: var(--text-headline); font-weight: 700;
    color: var(--text); line-height: 1.2; margin-bottom: var(--space-sm);
}
.discovery-rows { display: flex; flex-direction: column; gap: var(--space-xs); }
.discovery-row {
    display: flex; align-items: baseline; gap: var(--space-sm);
    font-size: var(--text-body); line-height: 1.5; color: var(--text-sub);
}
.discovery-arrow { color: var(--accent); font-size: var(--text-caption); flex-shrink: 0; margin-top: var(--space-xs); }
.discovery-text { color: var(--text); font-weight: 500; }
.discovery-text.muted { color: var(--text-sub); font-weight: 400; }

/* ══════════════════════════════════════════
   NAV-NEXT — 次の分析ナビゲーション
   使用箇所: morph-search, syntax-search のフッター
══════════════════════════════════════════ */
.nav-next-list { display: flex; flex-direction: column; gap: var(--space-sm); margin-bottom: var(--space-sm); }
.nav-next-btn {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--space-md) var(--space-md); background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-m);
    text-decoration: none; color: var(--text);
    transition: background var(--transition-fast), border-color var(--transition-fast);
}
.nav-next-btn:hover { background: var(--accent-light); border-color: var(--accent-mid); }
.nav-next-body { flex: 1; }
.nav-next-title { font-size: var(--text-body); font-weight: 700; color: var(--accent); margin-bottom: var(--space-xs); }
.nav-next-sub { font-size: var(--text-caption); color: var(--text-sub); }
.nav-next-arrow { font-size: var(--text-body-lg); color: var(--text-hint); margin-left: var(--space-sm); flex-shrink: 0; }

/* Inherit card */
.nav-inherit-card {
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius-s); padding: var(--space-sm) var(--space-md);
}
.nav-inherit-label {
    font-size: var(--text-caption); font-weight: 600;
    letter-spacing: 0.08em;
    color: var(--text-hint); margin-bottom: var(--space-sm);
}
.nav-inherit-chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); margin-bottom: var(--space-sm); }
.nav-inherit-chip {
    display: inline-flex; align-items: center; gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm); background: var(--bg);
    border: 1px solid var(--border); border-radius: var(--radius-l); font-size: var(--text-caption);
}
.nav-inherit-chip-key { color: var(--text-hint); font-size: var(--text-caption); }
.nav-inherit-chip-val { font-weight: 600; color: var(--text); }
.nav-inherit-chip-val.greek { font-family: var(--font-greek); font-size: var(--text-caption); }
.nav-inherit-note { font-size: var(--text-caption); color: var(--text-hint); }

/* ══════════════════════════════════════════
   HELP POPUP
   使用箇所: morph-search, syntax-search のブレッドクラム
══════════════════════════════════════════ */
.help-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 16px; height: 16px; border-radius: 50%;
    border: 1.5px solid var(--text-hint); background: transparent;
    color: var(--text-hint); font-size: var(--text-caption); font-weight: 700; font-family: inherit;
    cursor: pointer; padding: 0; line-height: 1; flex-shrink: 0;
    vertical-align: middle; margin-left: var(--space-xs);
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.help-btn:hover,
.help-btn[aria-expanded="true"] {
    border-color: var(--accent); color: var(--accent); background: var(--accent-light);
}
.breadcrumb-tail {
    position: relative; display: inline-flex;
    align-items: center; gap: 0; flex-shrink: 0;
}
.help-popup {
    display: none; position: fixed; z-index: 1000;
    min-width: 200px; max-width: min(260px, calc(100vw - 32px));
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-m);
    box-shadow: 0 4px 20px rgba(0,0,0,0.10);
    padding: var(--space-md) var(--space-md); animation: fadeUp var(--transition-fast);
}
.help-popup.open { display: block; }
.help-popup-title {
    font-size: var(--text-caption); font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--accent); margin-bottom: var(--space-sm);
}
.help-popup-body { font-size: var(--text-caption); color: var(--text-sub); line-height: 1.6; margin-bottom: var(--space-sm); }
.help-popup-examples { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.help-popup-tag {
    font-size: var(--text-caption); padding: var(--space-xs) var(--space-sm);
    background: var(--bg-panel); border: 1px solid var(--border);
    border-radius: var(--radius-l); color: var(--text-sub);
}

/* ══════════════════════════════════════════
   SYNTAX-PANEL — 構文パターン検索セクション
   使用箇所: search-tool.html 結果パネル内
══════════════════════════════════════════ */
#syntax-panel { display: none; margin-top: var(--space-lg); }
.syn-section-title {
    font-size: var(--text-caption); font-weight: 600;
    letter-spacing: 0.14em;
    color: var(--accent); padding-bottom: var(--space-sm); margin-bottom: var(--space-md);
    border-bottom: 2px solid var(--accent-mid);
}
.syn-header { margin-bottom: var(--space-md); }
.syn-label  { display: block; font-size: var(--text-body); font-weight: 700; color: var(--text); margin-bottom: var(--space-xs); }
.syn-sublabel { font-size: var(--text-caption); color: var(--text-sub); }
.syn-count {
    display: none; margin-top: var(--space-xs);
    font-size: var(--text-caption); font-weight: 700; color: var(--accent);
    background: var(--accent-light); border: 1px solid var(--accent-mid);
    border-radius: var(--radius-l); padding: var(--space-xs) var(--space-sm);
}
.syn-status { font-size: var(--text-caption); color: var(--text-hint); margin-bottom: var(--space-sm); min-height: 18px; }

/* フィルターアコーディオン */
.syn-filter {
    margin-bottom: var(--space-md); border: 1px solid var(--border);
    border-radius: var(--radius-m); overflow: hidden;
}
.syn-filter summary {
    display: flex; align-items: center; gap: var(--space-sm); padding: var(--space-sm) var(--space-md);
    font-size: var(--text-caption); font-weight: 700; color: var(--text-sub);
    cursor: pointer; user-select: none; background: var(--bg-panel); list-style: none;
}
.syn-filter summary::-webkit-details-marker { display: none; }
.syn-filter summary::before { content: '▶'; font-size: var(--text-caption); transition: transform var(--transition-fast); }
.syn-filter[open] summary::before { transform: rotate(90deg); }
.syn-filter-body { padding: var(--space-sm) var(--space-md); border-top: 1px solid var(--border); }
.syn-filter-row { margin-bottom: var(--space-sm); }
.syn-filter-row:last-child { margin-bottom: 0; }
.syn-filter-label {
    font-size: var(--text-caption); font-weight: 700; color: var(--text-hint);
    letter-spacing: 0.08em; margin-bottom: var(--space-xs);
}

/* 書物グループチップ / ソートボタン */
/* filter-chip-toggle — morph-search.html / syntax-search.html と統一スタイル */
.book-chips { display: flex; flex-wrap: wrap; gap: var(--space-xs); }
.filter-chip-toggle {
    display: inline-flex; align-items: center; gap: var(--space-xs);
    padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-l);
    font-size: var(--text-caption); cursor: pointer; user-select: none;
    border: 1px solid var(--border); transition: all var(--transition-fast);
}
.filter-chip-toggle.on {
    background: var(--accent-light); border-color: var(--accent-mid);
    color: var(--accent); font-weight: 600;
}
.filter-chip-toggle.off {
    background: var(--bg); border-color: var(--border); color: var(--text-hint);
}
.filter-chip-toggle:hover.off { background: var(--bg-panel); }
.filter-chip-dot {
    width: 10px; height: 10px; border-radius: 50%;
    border: 1.5px solid currentColor;
    display: flex; align-items: center; justify-content: center;
    font-size: var(--text-caption); flex-shrink: 0;
}
.filter-chip-toggle.on .filter-chip-dot { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-chip-toggle.off .filter-chip-dot { background: transparent; color: #ccc; }
.sort-btns { display: flex; gap: var(--space-xs); flex-wrap: wrap; }
.sort-btn {
    padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-l); font-family: inherit;
    font-size: var(--text-caption); font-weight: 600; cursor: pointer; user-select: none;
    border: 1px solid var(--border); background: var(--bg); color: var(--text-sub);
    transition: all var(--transition-fast);
}
.sort-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* 確信度スライダー / スタブトグル */
.conf-row { display: flex; align-items: center; gap: var(--space-sm); }
.conf-slider { flex: 1; accent-color: var(--accent); }
.conf-value { font-size: var(--text-caption); font-weight: 700; color: var(--accent); min-width: 36px; }
.stub-toggle { display: flex; align-items: center; gap: var(--space-sm); cursor: pointer; font-size: var(--text-caption); color: var(--text-sub); }
.stub-toggle input { accent-color: var(--accent); }

/* 書物見出し */
.book-heading {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: var(--space-sm);
    padding: var(--space-xs) 0 var(--space-xs); background: var(--bg);
    border-bottom: 1px solid var(--border);
    margin-bottom: var(--space-xs); margin-top: var(--space-md);
}
.book-heading:first-child { margin-top: 0; }
.book-heading-name {
    font-size: var(--text-caption); font-weight: 600; letter-spacing: 0.1em; color: var(--accent);
}
.book-heading-count {
    font-size: var(--text-caption); padding: var(--space-xs) var(--space-sm); border-radius: var(--radius-m);
    background: var(--accent-light); color: var(--accent); font-weight: 700;
}

/* 確信度バッジ / コンテキスト表示 */
.result-conf { font-size: var(--text-caption); font-weight: 700; flex-shrink: 0; }
.result-conf.high   { color: #4a7a5a; }
.result-conf.medium { color: #a09050; }
.result-conf.low    { color: #b05050; }
.context-snippet {
    display: flex; flex-wrap: wrap; gap: var(--space-xs) var(--space-sm);
    font-family: var(--font-greek);
    font-size: var(--text-body-lg); margin-bottom: var(--space-xs); padding: var(--space-sm) 0;
}
.snippet-token { color: var(--text-sub); }
.snippet-token.hit {
    color: var(--accent); font-weight: 700;
    background: var(--accent-light); border-radius: var(--radius-s); padding: 0 var(--space-xs);
}
.ctx-loading { font-size: var(--text-caption); color: var(--text-hint); padding: var(--space-xs) 0; }
.result-lemma { font-size: var(--text-caption); color: var(--text-hint); margin-bottom: var(--space-xs); padding-top: var(--space-sm); }
.result-ja {
    font-size: var(--text-caption); color: var(--text-sub); line-height: 1.7;
    padding: var(--space-xs) var(--space-sm); background: var(--bg-panel);
    border-radius: var(--radius-s); border-left: 2px solid var(--border); margin-bottom: var(--space-sm);
}
.result-ja-empty { font-style: italic; color: var(--text-hint); }
.load-more-btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%; padding: var(--space-sm); margin-top: var(--space-sm);
    font-size: var(--text-caption); color: var(--accent); font-family: inherit;
    background: var(--bg-inset); border: 1px solid var(--border);
    border-radius: var(--radius-s); cursor: pointer; transition: background var(--transition-fast); min-height: 44px;
}
.load-more-btn:hover { background: var(--accent-light); }

/* ── hits overflow collapse ── */
.hits-overflow { overflow: hidden; }
.hits-overflow.closed { display: none; }
.expand-btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: var(--space-xs);
    min-height: 36px;
    padding: var(--space-xs) var(--space-sm);
    border: 1px dashed var(--border-soft);
    border-radius: var(--radius-s);
    background: transparent; color: var(--text-sub);
    font: inherit; font-size: var(--text-caption); line-height: 1.4;
    cursor: pointer;
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}
.expand-btn:hover { background: var(--accent-light); color: var(--highlight); border-color: var(--highlight); }
.expand-btn--block { width: 100%; }
.hits-toggle-btn {
    display: flex; gap: var(--space-xs); justify-content: center;
    width: 100%; margin: var(--space-xs) 0;
}
.hits-toggle-btn .mat-icon { font-size: var(--text-body-lg); line-height: 1; transition: transform var(--transition-base); }
.hits-toggle-btn.open .mat-icon { transform: rotate(180deg); }

/* ══════════════════════════════════════════
   CSS FREEZE — Phase 8
   新規インラインCSSは禁止。スタイル変更は
   tokens.css / layout.css / components.css のみ。
   アイコンは Material Symbols Outlined のみ使用。
   Font Awesome / 絵文字アイコン 禁止。
══════════════════════════════════════════ */
