/**
 * public-media-search.css
 * =============================================================================
 * 一般読者向け AI意味検索 ＆ 図解・画像検索ポップアップスタイル (Cocoon連動)
 * 【AGENTS.md ガバナンス準拠】
 * - Flexbox / Grid 横並びコンテナ内には必ず min-width: 0; を配備しテキスト突き抜けを完全防止
 * - overflow: hidden; text-overflow: ellipsis; による三点リーダー多層防護
 * =============================================================================
 */

.sugano-public-search-popup {
    position: absolute;
    z-index: 99999;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    overflow: hidden;
    max-width: calc(100vw - 20px);
}

/* ヘッダー・タブ */
.sugano-psp-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    min-width: 0; /* 🛡️ Flexboxオーバーフロー多層防護 */
}

.sugano-psp-tabs {
    display: flex;
    gap: 6px;
    min-width: 0; /* 🛡️ Flexboxオーバーフロー多層防護 */
}

.sugano-psp-tab {
    background: transparent;
    border: none;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: #64748b;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
}

.sugano-psp-tab.is-active {
    background: #ffffff;
    color: #0284c7;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.sugano-psp-close {
    background: transparent;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    padding: 2px 6px;
}

.sugano-psp-close:hover {
    color: #334155;
}

/* コンテンツエリア */
.sugano-psp-content {
    max-height: 360px;
    overflow-y: auto;
    padding: 8px;
    box-sizing: border-box;
}

/* 記事リスト表示 */
.sugano-psp-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sugano-psp-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 8px;
    text-decoration: none;
    color: #1e293b;
    transition: background 0.15s ease;
    min-width: 0; /* 🛡️ Flexboxオーバーフロー多層防護 */
}

.sugano-psp-item:hover {
    background: #f1f5f9;
}

.sugano-psp-item-icon {
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 2px;
}

.sugano-psp-item-main {
    flex: 1;
    min-width: 0; /* 🛡️ Flexboxオーバーフロー多層防護 */
}

.sugano-psp-item-title {
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 🛡️ タイトル三点リーダー防護 */
}

.sugano-psp-item-excerpt {
    font-size: 11px;
    color: #64748b;
    line-height: 1.4;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 🛡️ 要約三点リーダー防護 */
}

/* 画像グリッド表示 */
.sugano-psp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 8px;
}

.sugano-psp-thumb-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    background: #f8fafc;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    min-width: 0; /* 🛡️ Flexboxオーバーフロー多層防護 */
}

.sugano-psp-thumb-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.sugano-psp-thumb-box {
    position: relative;
    width: 100%;
    height: 70px;
    background: #e2e8f0;
    overflow: hidden;
}

.sugano-psp-thumb-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s ease;
}

.sugano-psp-thumb-card:hover .sugano-psp-thumb-box img {
    transform: scale(1.05);
}

.sugano-psp-thumb-badge {
    position: absolute;
    bottom: 3px;
    right: 3px;
    background: rgba(15, 23, 42, 0.82);
    color: #ffffff;
    font-size: 9px;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    backdrop-filter: blur(2px);
    pointer-events: none;
    line-height: 1.3;
}

.sugano-psp-thumb-card.has-article .sugano-psp-thumb-badge {
    background: rgba(37, 99, 235, 0.88); /* 記事リンク付き画像は青バッジ */
}

.sugano-psp-thumb-title {
    font-size: 10px;
    font-weight: 600;
    color: #334155;
    padding: 4px 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* 🛡️ タイトル三点リーダー防護 */
}

/* フッター */
.sugano-psp-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    font-size: 10px;
    color: #94a3b8;
    min-width: 0; /* 🛡️ Flexboxオーバーフロー多層防護 */
}

.sugano-psp-hint {
    color: #64748b;
}

.sugano-psp-loading,
.sugano-psp-empty {
    padding: 24px 16px;
    text-align: center;
    font-size: 12px;
    color: #64748b;
}

.sugano-psp-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid #cbd5e1;
    border-top-color: #0284c7;
    border-radius: 50%;
    animation: sugano-spin 0.6s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

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