/* ==========================================================
   SCOPE: チャットUI（トシ×ヒナコ 掛け合いコンポーネント）
     - .chat-section, .chat-row, .chat-row.hinako, .chat-row.toshi
     - .chat-icon, .chat-bubble-name, .chat-bubble
     - (Legacy) .chat-box, .chat-text, .hinako-text, .toshi-text,
       .hinako-icon, .toshi-icon, .chat-name, .chat-row.reverse
   DEPENDS: base.css
   NOTE: キャラ色はCSS変数で管理。新キャラ追加時は変数+セレクタ1組を追加するだけ。
         Phase 2完了後、LEGACYセクションを削除する。
   CREATED: 2026-03-04
   ========================================================== */

/* ============================================================
   1. キャラクターカラー変数
   ============================================================ */
:root {
    --chat-color-hinako: #e91e63;
    --chat-color-toshi:  #c9a84c;
    /* 将来キャラ追加例:
       --chat-color-newchar: #1e88e5; */
}

/* ============================================================
   2. チャットセクション（会話ブロック全体の枠）
   ============================================================ */
.chat-section {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
}

/* ============================================================
   3. チャット行（1発言 = 1行）
   ============================================================ */
.chat-row {
    display: flex;
    align-items: flex-start;
    gap: 15px;
    margin-bottom: 20px;
}

.chat-row:last-child {
    margin-bottom: 0;
}

/* トシの行：アイコンを右に配置 */
.chat-row.toshi {
    flex-direction: row-reverse;
}

/* ============================================================
   4. アバターアイコン
   ============================================================ */
.chat-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 2px solid #ccc;
    overflow: hidden;
    background: #f0f0f0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.chat-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 10%;
    transform: scale(1.15);
    display: block;
}

/* キャラ別アイコン枠色（.chat-row のキャラクラスで制御） */
.chat-row.hinako .chat-icon {
    border-color: var(--chat-color-hinako);
    background: rgba(233, 30, 99, 0.08);
}

.chat-row.toshi .chat-icon {
    border-color: var(--chat-color-toshi);
    background: rgba(201, 168, 76, 0.08);
}

/* ============================================================
   5. テキスト領域（名前 + バブル のカラム）
   ============================================================ */
.chat-row > div:not(.chat-icon) {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.chat-row.toshi > div:not(.chat-icon) {
    align-items: flex-end;
}

/* ============================================================
   6. 発言者名ラベル
   ============================================================ */
.chat-bubble-name {
    font-size: 0.8rem;
    font-weight: bold;
    margin-bottom: 6px;
    display: block;
}

.chat-row.hinako .chat-bubble-name {
    color: var(--chat-color-hinako);
}

.chat-row.toshi .chat-bubble-name {
    color: var(--chat-color-toshi);
}

/* ============================================================
   7. 吹き出しバブル
   ============================================================ */
.chat-bubble {
    border-radius: 12px;
    padding: 14px 18px;
    max-width: 90%;
    display: inline-block;
    text-align: left;
}

/* ヒナコ: 薄ピンク背景＋ピンク枠、左上角シャープ（発言方向示唆） */
.chat-row.hinako .chat-bubble {
    background: #fce4ec;
    border: 1px solid var(--chat-color-hinako);
    border-top-left-radius: 2px;
}

/* トシ: 薄ゴールド背景＋ゴールド枠、右上角シャープ */
.chat-row.toshi .chat-bubble {
    background: rgba(201, 168, 76, 0.08);
    border: 1px solid var(--chat-color-toshi);
    border-top-right-radius: 2px;
}

.chat-bubble p {
    margin: 0;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #333;
}

.chat-bubble p + p {
    margin-top: 10px;
}

/* ============================================================
   7b. 強調テキスト（対話内のキーメッセージ）
   ============================================================ */
.chat-emphasis {
    color: #c9a84c;
}

/* ============================================================
   8. モバイル最適化
   ============================================================ */
@media screen and (max-width: 768px) {
    .chat-section {
        padding: 15px 0;
    }

    .chat-row {
        gap: 10px;
        padding: 0;
    }

    .chat-icon {
        width: 44px;
        height: 44px;
    }

    .chat-bubble {
        max-width: 85%;
        padding: 16px;
    }

    .chat-bubble p {
        font-size: 0.9rem;
    }

    /* base.css の .main-content div { padding: 0 !important } および
       .main-content * { max-width: 100% !important } がチャットUI要素の
       デザインを破壊するのを防止。全ページでaboutページと同じバランスに統一。
       specificity: .main-content .chat-xxx (0,2,0) > .main-content div (0,1,1) */
    .main-content .chat-bubble {
        max-width: 85% !important;
        padding: 16px !important;
    }
}

/* ============================================================
   LEGACY: 旧構造との後方互換性
   Phase 2で全ファイル変換後、このセクション全体を削除する。
   ============================================================ */

/* 旧構造: .chat-box を外枠として使うページ（既存の新構造42ファイル） */
.chat-box {
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0;
}

/* 旧構造: .chat-row.reverse（新構造では .chat-row.toshi に統一） */
.chat-row.reverse {
    flex-direction: row-reverse;
}
.chat-row.reverse > div:not(.chat-icon) {
    align-items: flex-end;
}

/* 旧構造: アイコン内の名前ラベル非表示 */
.chat-icon .chat-name {
    display: none;
}

/* 旧構造: アイコン別名クラス */
.hinako-icon {
    border-color: #e0007a;
    background: rgba(224, 0, 122, 0.08);
}
.toshi-icon {
    border-color: #c9a84c;
    background: rgba(201, 168, 76, 0.08);
}

/* 旧構造: 名前ラベル（.chat-name 単体使用） */
.chat-name {
    font-size: 0.8rem;
    color: #555;
    margin-bottom: 6px;
    font-weight: bold;
    display: block;
}

/* 旧構造: chat-text バブル */
.chat-text {
    position: relative;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.6;
    max-width: 80%;
}
.chat-text.hinako-text {
    background: #fce4ec;
    border: 1px solid var(--chat-color-hinako);
    color: #333;
    border-top-left-radius: 2px;
}
.chat-text.toshi-text {
    background: rgba(201, 168, 76, 0.08);
    border: 1px solid var(--chat-color-toshi);
    color: #333;
    border-top-right-radius: 2px;
}
