@charset "UTF-8";

/* ベース設定 */
:root {
    --bg-color: #FFFEF9;
    --text-color: #9D694D;
    --bubble-bg: #FFFFFF;
    --bubble-border: #ddd0c8;
    --icon-border: #f2f2f2;
}

body {
    font-family: "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-color);
    background-color: var(--bg-color);
    -webkit-text-size-adjust: 100%;
}

/* リンクの標準スタイル */
a {
    color: #a48476;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color 0.2s ease, opacity 0.2s ease;
}

a:hover {
    color: #8c6a5d;
    opacity: 0.8;
}

/* コンテナ設定（幅指定・中央寄せ） */
.container {
    max-width: 860px;
    margin: 0 auto;
    padding: 40px 20px;
    box-sizing: border-box;
}

/* 会話行の共通スタイル（Gridレイアウトに変更） */
.chat-row {
    display: grid;
    /* アイコン(左) | テキスト本文 | アイコン(右) */
    grid-template-columns: 64px 1fr 64px;
    gap: 20px;
    align-items: start;
    margin-bottom: 10px;
    position: relative;
}

/* グリッド内のアイテムを行頭に固定（ソース順による段落ち防止） */
.chat-row>* {
    grid-row: 1;
}

/* 左側の発言者 */
.chat-row.left .chat-icon {
    grid-column: 1;
    justify-self: center;
}

.chat-row.left .chat-bubble {
    grid-column: 2;
}

/* 右側の発言者（自分） */
.chat-row.right .chat-icon {
    grid-column: 3;
    justify-self: center;
}

.chat-row.right .chat-bubble {
    grid-column: 2;
}

/* アイコン画像エリア */
.chat-icon {
    width: 64px;
    height: 64px;
    /* flex-shrinkなど不要 */
    border-radius: 0;
    border: none;
    overflow: hidden;
    background-color: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #666;
    text-align: center;
    /* デフォルトのbox-sizingがcontent-boxの場合、幅が広がるため明示的に指定しても良いが、
       Gridカラム80px内に収めるためmargin調整等はjustify-selfで対応 */
}

.chat-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* 吹き出しエリア */
.chat-bubble {
    position: relative;
    padding: 1em;
    border-radius: 10px;
    background-color: var(--bubble-bg);
    border: 2px solid var(--bubble-border);
    width: 100%;
    /* カラム幅いっぱいに広げる */
    box-sizing: border-box;
    /* パディングを含めて幅計算 */
    line-height: 1.8;
    word-break: normal;
}

/* 地の文（吹き出しと同じ幅・位置） */
.chat-narration {
    grid-column: 2;
    padding: 1em;
    line-height: 1.8;
    box-sizing: border-box;
    word-break: auto-phrase;
}

.chat-bubble.break-all {
    word-break: break-all;
}

/* 吹き出しのしっぽ（共通） */
.chat-bubble::before,
.chat-bubble::after {
    content: '';
    position: absolute;
    top: 15px;
    width: 13px;
    height: 30px;
    pointer-events: none;
}

/* 左側のしっぽ */
.chat-row.left .chat-bubble::before {
    /* 外枠（ボーダー色） */
    left: -13px;
    background-color: var(--bubble-border);
    -webkit-clip-path: polygon(0 50%, 100% 0, 100% 100%);
    clip-path: polygon(0 50%, 100% 0, 100% 100%);
}

.chat-row.left .chat-bubble::after {
    /* 内側（背景色） */
    left: -10px;
    /* 枠線の太さに合わせて微調整 */
    background-color: var(--bubble-bg);
    -webkit-clip-path: polygon(0 50%, 100% 0, 100% 100%);
    clip-path: polygon(0 50%, 100% 0, 100% 100%);
}

/* 右側のしっぽ */
.chat-row.right .chat-bubble::before {
    /* 外枠（ボーダー色） */
    right: -13px;
    background-color: var(--bubble-border);
    -webkit-clip-path: polygon(0 0, 100% 50%, 0 100%);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.chat-row.right .chat-bubble::after {
    /* 内側（背景色） */
    right: -10px;
    /* 枠線の太さに合わせて微調整 */
    background-color: var(--bubble-bg);
    -webkit-clip-path: polygon(0 0, 100% 50%, 0 100%);
    clip-path: polygon(0 0, 100% 50%, 0 100%);
}

/* メインタイトル */
.main-title {
    text-align: center;
    margin: 0.5em auto 1em;
    font-size: 1.8em;
    font-weight: normal;
    letter-spacing: 0.15em;
    word-break: auto-phrase;
}

/* 章タイトル（話の区切り） */
.chapter-title {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 3em auto 1.5em;
    text-align: center;
    font-size: 1.2em;
    font-weight: bold;
    color: #a48476;
    /* 薄茶色で控えめに */
}

.chapter-title::before,
.chapter-title::after {
    content: '';
    display: block;
    width: 40px;
    height: 2px;
    background-color: #ddd0c8;
    /* 薄いボーダー色と合わせる */
    margin: 0 15px;
}

/* 区切り線 */
.chapter-divider {
    margin: 3.5em 0;
    border: none;
    border-top: 2px dashed #ddd0c8;
}

/* おしまい用 */
.narration-end {
    display: block;
    margin: 1.5em auto 1em;
    text-align: center;
    font-size: 1.6em;
    font-weight: bold;
    letter-spacing: 0.2em;
    text-indent: 0.7em;
    /* text-align: center での letter-spacing のずれを補正 */
}

/* コード表示エリア */
.code-container {
    margin: 30px 0;
}

.code-title {
    display: inline-block;
    padding: 4px 15px;
    background-color: #ddd0c8;
    /* 薄茶色の背景 */
    color: #8c6a5d;
    /* 濃い茶色の文字 */
    font-size: 0.85em;
    font-weight: bold;
    border: 1px solid var(--bubble-border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.code-block {
    display: block;
    margin: 0;
    padding: 1.2em;
    background-color: #fdfdfd;
    /* ほんの少しグレーを入れた白 */
    border: 1px solid var(--bubble-border);
    /* 吹き出しと同じ枠線色 */
    border-left: 5px double var(--bubble-border);
    /* 左端を太くしてコードらしさを強調 */
    border-radius: 4px;
    overflow-x: auto;
    /* 横スクロール対応 */
    font-family: "Consolas", "Monaco", "Andale Mono", monospace;
    font-size: 0.95em;
    color: #4a4a4a;
}

.code-block.text-only {
    line-height: 1.5;
}

/* タイトルがある場合は上の角を落とす */
.code-title+.code-block {
    border-top-left-radius: 0;
}

/* 発言者ごとのカラーバリエーション */

/* エルザ（青系） */
.chat-row.elza-style .chat-bubble {
    border-color: #b8c8d8;
    color: #2d4059;
    /* 読みやすいダークブルーグレー */
}

/* 左吹き出しのしっぽ枠線 */
.chat-row.elza-style.left .chat-bubble::before {
    background-color: #b8c8d8;
}

/* 右吹き出しのしっぽ枠線 */
.chat-row.elza-style.right .chat-bubble::before {
    background-color: #b8c8d8;
}

/* パラ犬（標準・ベージュ系） */
.chat-row.para-style .chat-bubble {
    border-color: #cbbcb3;
    /* 標準色（ベージュグレー） */
    color: #5c4e46;
    /* 読みやすいウォームグレー */
}

/* 左吹き出しのしっぽ枠線 */
.chat-row.para-style.left .chat-bubble::before {
    background-color: #cbbcb3;
}

/* 右吹き出しのしっぽ枠線 */
.chat-row.para-style.right .chat-bubble::before {
    background-color: #cbbcb3;
}

/* シャーレイ（黄緑色） */
.chat-row.shir-style .chat-bubble {
    border-color: #b8d592;
    /* 黄緑色 */
    color: #4f6b32;
    /* 読みやすいダークオリーブグリーン */
}

/* 左吹き出しのしっぽ枠線 */
.chat-row.shir-style.left .chat-bubble::before {
    background-color: #b8d592;
}

/* 右吹き出しのしっぽ枠線 */
.chat-row.shir-style.right .chat-bubble::before {
    background-color: #b8d592;
}

/* ページナビゲーション（シンプル文字リンク） */
.page-navigation {
    display: flex;
    flex-direction: column;
    /* 縦並び */
    align-items: center;
    gap: 30px;
    /* リンク間の間隔 */
    margin-top: 60px;
    padding-top: 40px;
    border-top: 1px solid #ddd0c8;
}

.page-navigation .nav-link {
    text-decoration: none;
    transition: opacity 0.3s;
}

.page-navigation .nav-link:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* 次へリンク（メイン） */
.page-navigation .next {
    font-size: 1.25em;
    font-weight: bold;
    color: #a48476;
    /* 章タイトル色と同じ */
    letter-spacing: 0.05em;
}

/* Homeリンク（控えめに） */
.page-navigation .home {
    font-size: 0.9em;
    color: var(--text-color);
    opacity: 0.8;
}

/* 画像表示コンテナ */
.image-container {
    max-width: 100%;
    margin: 20px auto;
    text-align: center;
}

.image-container img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    border: 1px solid var(--bubble-border);
}

.no_border {
    border: none !important;
    text-decoration: none !important;
}

/* 目次 */
.contents-section {
    margin: 1.5em auto;
    padding: 2em;
    background-color: #fff;
    border: 1px solid #ddd0c8;
    border-radius: 8px;
    max-width: 600px;
}

.contents-title {
    text-align: center;
    font-size: 1.2em;
    margin-top: 0;
    color: #a48476;
}

.contents-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.contents-item {
    border-bottom: 1px dashed #eee;
}

.contents-item:last-child {
    border-bottom: none;
}

.contents-link {
    display: block;
    padding: 12px 15px;
    color: var(--text-color);
    text-decoration: none;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.contents-link:hover {
    background-color: #fffaf0;
    padding-left: 20px;
}

/* ステップ表示ボックス */
.step-box {
    border: 1px solid #cccccc;
    color: #666;
    padding: 15px;
    margin: 15px 0;
    border-radius: 4px;
    line-height: 1.6;
}

.center {
    text-align: center;
}

/* 開閉ボックス（全文を表示） */
.expandable-box {
    position: relative;
    margin: 35px 0;
}

.expand-title {
    display: inline-block;
    padding: 4px 15px;
    background-color: #ddd0c8;
    /* 薄茶色の背景 */
    color: #8c6a5d;
    /* 濃い茶色の文字 */
    font-size: 0.85em;
    font-weight: bold;
    border: 1px solid var(--bubble-border);
    border-bottom: none;
    border-radius: 6px 6px 0 0;
}

.expand-check {
    display: none;
}

.expand-content {
    display: block;
    margin: 0;
    padding: 1.2em;
    background-color: #fdfdfd;
    /* ほんの少しグレーを入れた白 */
    border: 1px solid var(--bubble-border);
    border-left: 5px double var(--bubble-border);
    border-radius: 4px;
    max-height: 120px;
    /* 折りたたみ時の高さ */
    padding-bottom: 60px;
    /* ボタン領域の余白 */
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    line-height: 1.5;
    font-size: 0.95em;
    color: #4a4a4a;
}

/* タイトルがある場合は上の角を落とす */
.expand-title+.expand-check+.expand-content {
    border-top-left-radius: 0;
}

.expand-button {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: linear-gradient(to bottom, rgba(253, 253, 253, 0), rgba(253, 253, 253, 0.9) 50%, rgba(253, 253, 253, 1) 100%);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 15px;
    cursor: pointer;
    color: #a48476;
    font-weight: bold;
    font-size: 0.95em;
    transition: all 0.3s ease;
}

.expand-button::before {
    content: '▼ 全文を表示';
    background-color: #fff;
    padding: 4px 16px;
    border: 1px solid #ddd0c8;
    border-radius: 20px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.expand-button:hover::before {
    background-color: #faf7f5;
    transform: translateY(-2px);
}

/* チェック時のスタイル */
.expand-check:checked+.expand-content {
    max-height: 5000px;
    /* 十分な高さ（コンテンツに合わせて伸びる） */
    padding-bottom: 1.2em;
}

.expand-check:checked~.expand-button {
    position: relative;
    height: auto;
    background: none;
    padding-top: 10px;
    padding-bottom: 15px;
    border-top: 1px dashed #eee;
}

.expand-check:checked~.expand-button::before {
    content: '▲ 閉じる';
}

/* スマホ対応（幅600px以下） */
@media (max-width: 600px) {
    .container {
        padding: 20px 10px;
    }

    .chat-row {
        gap: 12px;
        margin-bottom: 10px;
        /* アイコンエリアを少し小さく */
        grid-template-columns: 32px 1fr 32px;
    }

    .chat-icon {
        width: 32px;
        height: 32px;
        margin-top: 8px;
    }

    .chat-bubble {
        padding: 0.7em 0.9em;
        font-size: 14px;
        border: 1.9px solid var(--bubble-border);
        /* max-width解除・width 100%は継承される */
    }

    .chat-narration {
        padding: 0.7em 0.9em;
    }

    /* しっぽの大きさを少し調整（必要に応じて） */
    .chat-bubble::before,
    .chat-bubble::after {
        top: 12px;
        width: 10px;
        height: 20px;
    }

    .chat-row.left .chat-bubble::before {
        left: -10px;
    }

    .chat-row.left .chat-bubble::after {
        left: -8px;
    }

    .chat-row.right .chat-bubble::before {
        right: -10px;
    }

    .chat-row.right .chat-bubble::after {
        right: -8px;
    }

    .code-block,
    .expand-content {
        font-size: 0.85em;
        /* スマホでは少し小さく */
        padding: 1em;
        box-sizing: border-box;
    }

    .expand-content {
        padding-bottom: 60px;
        /* ボタンと重ならないようにpadding-bottomを維持 */
    }

    /* スマホでの展開時の挙動を安定させる */
    .expand-check:checked+.expand-content {
        max-height: none;
        padding-bottom: 1.2em;
        transition: none;
    }

    .code-container,
    .expandable-box {
        margin: 20px 32px;
    }

    .code-title,
    .expand-title {
        font-size: 0.75em;
        padding: 3px 12px;
    }

    .image-container {
        margin: 20px 32px;
    }
}