﻿.news-container {
    width: 95%;
    max-width: 800px;
    margin: 20px auto;
    padding: 10px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
}



.news-list {
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.news-item {
    display: flex;
    justify-content: space-between;
    align-items: stretch; /* 高さを揃える */
    flex-wrap: nowrap; /* 画像なしのときに適切に折り返し */
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 8px;
    background-color: #fdfdfd;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    flex-direction: row;
    box-sizing: border-box;
}

/* 通常の画像ありレイアウト */
.image-placeholder {
    width: 40%;
    background: #e0e0e0;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: 15px;
    border-radius: 8px;
    font-size: 14px;
    color: #666;
    overflow: hidden;
}

.image-placeholder img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}



.news-image {
    max-width: 100%;
    max-height: 100%;
    border-radius: 8px;
}

.news-content {
    width: 55%;  /* 画像がない場合は幅を100%にして、テキストが途中で改行されないようにする */
    text-align: left;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: flex-start;
    box-sizing: border-box;
}

/* 画像がない場合の処理 */
.news-item.no-image {
    display: flex; /* flexを適用 */
    flex-direction: column; /* 縦並びにする */
    align-items: flex-start; /* 左揃え */
    width: 100%;
    text-align: left;
}

.news-item.no-image .news-content {
    width: 100%; /* 幅を100%に */
    text-align: left; /* テキストを左揃え */
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center; /* 高さを中央揃え */
    word-break: break-word; /* はみ出しを防ぐ */
    overflow-wrap: break-word; /* 長い単語が折り返されるように */
    box-sizing: border-box;
}

.news-item.no-image h3 {
    white-space: normal; /* 改行を許可 */
    overflow: hidden; /* はみ出しを防ぐ */
    text-overflow: ellipsis; /* 「…」で省略（必要なら適用） */
    width: 100%;
}

.news-content p {
    margin: 0.8em 0;
    font-size: 14px;
}

.update-time {
    font-size: 12px;
    color: #999;
    margin-top: 10px; /* 上の内容と重ならないようにする */
    align-self: flex-end; /* 右揃え */}

.details-button {
    background-color: #006400;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    text-decoration: none;
    display: inline-block;
    margin-top: 10px;
}

.details-button:hover {
    background-color: #008000;
}

.news-item .details-button {
    align-self: center;
}

.news-item .image-placeholder {
    min-height: 120px; /* 高さを最小限に設定 */
}

/* 画像がない場合、news-content を100%にする */
.news-item:has(.image-placeholder:empty) .news-content {
    width: 100%;
}

/*-----------------------------------------------------------------------------------------*/


/*スマホ対応CSS*/

@media screen and (max-width: 768px) {
    .news-item {
        flex-direction: column; /* 画像を上、テキストを下に */
        align-items: center;
        text-align: center;
    }

    .image-placeholder {
        width: 100%;  /* 画像を横幅いっぱいに */
        height: auto;
        margin-right: 0;
        margin-bottom: 10px; /* 文章との間隔を作る */
    }

.news-content p {
    margin: 0em 0;
}



    .news-content {
        width: 95%;  /* テキストも横幅いっぱいに */
        align-items: center; /* スマホでは中央揃え */
        text-align: center;
    }

    .details-button {
        width: 80%; /* スマホではボタンを横幅いっぱいに */
    }


    /* 画像がない場合の調整 */
    .news-item.no-image {
        align-items: center; /* 文章を中央寄せ */
        text-align: center;
    }

    .news-item.no-image .news-content {
        width: 100%;
    }


}



