/* 全体的なスタイル */
body {
    font-family: 'Noto Sans JP', sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    max-width: 960px;
    margin: 20px auto;
    padding: 0 20px;
}

/* ヘッダー */
.main-header {
    background-color: #333;
    color: #fff;
    padding: 20px 0;
    text-align: center;
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

.site-logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 10px;
}

.main-header h1 {
    margin: 10px 0 5px;
    font-size: 2.5em;
    font-family: 'Oswald', sans-serif;
    letter-spacing: 2px;
}

.main-header .tagline {
    font-size: 1.2em;
    margin-bottom: 20px;
}

.header-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 0 auto;
    object-fit: contain;
}

/* 共通セクションスタイル */
.section-box {
    background-color: #fff;
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

h2 {
    color: #2c3e50;
    text-align: center;
    margin-bottom: 20px;
    font-size: 2em;
}

.section-description {
    text-align: center;
    margin-bottom: 30px;
    color: #555;
}

/* ヒーローセクション */
.hero-section {
    text-align: center;
    padding: 40px 20px;
    background-color: #e2f0e0;
    border-radius: 8px;
    margin-bottom: 20px;
}

.hero-section h2 {
    color: #4a6c4a;
    font-size: 2.5em;
}

.hero-section p {
    font-size: 1.1em;
    margin-bottom: 10px;
}

.button {
    display: inline-block;
    background-color: #4CAF50;
    color: white;
    padding: 10px 20px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.button:hover {
    background-color: #45a049;
}

/* カードグリッド */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.card {
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    text-align: center;
    padding: 20px;
    display: flex;
    flex-direction: column;
    align-items: stretch; /* 子要素をコンテナいっぱいに伸ばす */
}

.card a {
    text-decoration: none;
    color: inherit;
    display: block;
    flex-grow: 1; /* リンク領域がカードの高さを埋めるように */
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* ★修正点★ カード画像の高さ固定を削除、containを維持 */
.card-image {
    width: 100%; /* 親要素の幅いっぱいに */
    height: auto; /* 高さを自動調整 */
    object-fit: contain; /* 画像全体を表示 */
    border-radius: 4px;
    margin-bottom: 15px;
}

.card h3 {
    font-size: 1.5em;
    margin: 10px 0;
    color: #333;
}

/* 音楽プレイヤーグリッド */
.music-player-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.music-player-card {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.music-player-card h3 {
    margin-top: 0;
    color: #444;
}

/* 音楽制作機材セクション */
.gear-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
}

.gear-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch; /* 子要素をコンテナいっぱいに伸ばす */
}

.gear-item a {
    text-decoration: none;
    color: #333;
    display: block;
    flex-grow: 1; /* リンク領域がアイテムの高さを埋めるように */
    display: flex;
    flex-direction: column;
    align-items: stretch;
}

/* ★修正点★ 機材画像の高さ固定を削除、containを維持 */
.gear-item img {
    width: 100%; /* 親要素の幅いっぱいに */
    height: auto; /* 高さを自動調整 */
    object-fit: contain; /* 画像全体を表示 */
    border-radius: 4px;
    margin-bottom: 10px;
}

.gear-item p {
    margin: 5px 0;
}

.gear-item .price {
    font-weight: bold;
    color: #d9534f;
    margin-top: 10px;
}

.buy-button {
    display: inline-block;
    background-color: #5cb85c;
    color: white;
    padding: 8px 15px;
    border-radius: 5px;
    margin-top: 10px;
    transition: background-color 0.3s ease;
}

.buy-button:hover {
    background-color: #4cae4c;
}

.gear-item .description {
    font-size: 0.9em;
    color: #666;
    margin-top: 10px;
}

/* 目次 */
.table-of-contents {
    background-color: #fff;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.table-of-contents #toggle-toc {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%; /* 親要素の幅いっぱいに広げる */
    border-radius: 5px;
    box-sizing: border-box; /* paddingとborderをwidthに含める */
}

.table-of-contents #toggle-toc span {
    margin-left: 10px;
    transition: transform 0.3s ease;
    display: inline-block; /* 回転アニメーションのために必要 */
}

.table-of-contents #toggle-toc.expanded span {
    transform: rotate(180deg);
}

.table-of-contents #toc-content {
    border-top: 1px solid #eee;
    padding-top: 10px;
    margin-top: 10px;
}

.table-of-contents .hidden {
    display: none;
}

.table-of-contents h2 {
    font-size: 1.5em;
    margin-top: 0;
    text-align: left; /* 目次のタイトルは左寄せに */
    color: #333;
}

.table-of-contents ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.table-of-contents li {
    margin-bottom: 8px;
}

.table-of-contents a {
    text-decoration: none;
    color: #007bff;
    transition: color 0.2s ease;
}

.table-of-contents a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* 物語セクション */
.story-section {
    background-color: #fff;
    padding: 30px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.story-category {
    text-align: center;
    font-size: 2em;
    color: #2c3e50;
    margin-bottom: 30px;
}

.story-item {
    display: flex;
    flex-wrap: wrap; /* 小さい画面で折り返す */
    margin-bottom: 40px;
    border-bottom: 1px dashed #eee;
    padding-bottom: 30px;
    align-items: flex-start; /* 画像とテキストの開始位置を合わせる */
}

.story-item:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

/* ★修正点★ 物語セクションの画像の高さ固定を削除、containを使用 */
.story-image {
    width: 100%; /* 常に親要素の幅いっぱいに広がるように */
    max-width: 400px; /* 最大幅は維持 */
    height: auto; /* 高さを自動調整 */
    object-fit: contain; /* 画像全体を表示 */
    margin-right: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    flex-shrink: 0; /* 縮小させない */
}

.story-text {
    flex: 1; /* 残りのスペースを埋める */
    min-width: 280px; /* 小さい画面での最小幅を維持 */
}

.story-text p {
    margin-bottom: 1em;
}

/* Back to Top ボタン */
.back-to-top-button {
    text-align: right;
    margin-top: 20px;
}

.back-to-top-button a {
    display: inline-block;
    background-color: #6c757d;
    color: white;
    padding: 8px 15px;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.3s ease;
}

.back-to-top-button a:hover {
    background-color: #5a6268;
}

/* プロモーションセクション */
.promotion-section {
    text-align: center;
    padding: 30px 20px;
    background-color: #eaf5e9;
    border-radius: 8px;
}

.promotion-section .section-title {
    color: #4a6c4a;
    margin-bottom: 20px;
}

.promotion-section .button {
    margin-bottom: 10px;
}

/* フッター */
.main-footer {
    background-color: #333;
    color: #fff;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

.main-footer p {
    margin: 0;
    font-size: 0.9em;
}

/* 区切り線 */
hr {
    border: none;
    border-top: 1px solid #ddd;
    margin: 40px 0;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .main-header h1 {
        font-size: 2em;
    }

    .hero-section h2 {
        font-size: 2em;
    }

    .card-grid, .music-player-grid, .gear-grid {
        grid-template-columns: 1fr; /* 1列にする */
    }

    .card {
        flex-direction: column;
        align-items: stretch;
    }

    .card a {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    /* ★修正点★ モバイルでの物語セクションのレイアウト調整、containを使用 */
    .story-item {
        flex-direction: column; /* 縦に並べる */
        align-items: stretch; /* 幅いっぱいに広げる */
    }

    .story-image {
        margin-right: 0;
        margin-bottom: 20px;
        max-width: 100%; /* モバイルでは全幅 */
        width: 100%; /* 幅を親要素の100%に */
        height: auto; /* 高さを自動調整 */
        object-fit: contain; /* 全体を表示 */
    }

    .story-text {
        min-width: unset; /* 最小幅をリセット */
    }

    .table-of-contents #toggle-toc {
        font-size: 1em;
    }
}