/* 改善版: 動的ニュース読み込み用スタイル - FOUC対策版 */

/* 📍 改善ポイント1: 基本的な表示制御 */
#announce .announce-list {
    opacity: 0;
    transition: opacity 0.5s ease;
    min-height: 180px; /* レイアウトシフト防止 */
}

#announce .announce-list.loaded {
    opacity: 1;
}

/* 📍 改善ポイント2: スケルトンローダー */
.skeleton-loader {
    display: none; /* 初期は非表示 */
}

.skeleton-item {
    display: flex;
    align-items: center;
    padding: 20px 0;
    border-bottom: 1px solid #e0e0e0;
}

.skeleton-date {
    width: 80px;
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
    margin-right: 20px;
}

.skeleton-category {
    width: 100px;
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
    margin-right: 20px;
    animation-delay: 0.1s;
}

.skeleton-text {
    flex: 1;
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeletonShimmer 1.5s infinite;
    border-radius: 4px;
    animation-delay: 0.2s;
}

@keyframes skeletonShimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* 📍 改善ポイント3: ローディングスピナー（代替案） */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 180px;
    flex-direction: column;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #918A7A;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-text {
    color: #666;
    font-size: 14px;
    text-align: center;
}

.loading-spinner.hidden {
    display: none;
}

/* 📍 改善ポイント4: エラー表示 */
.error-message {
    display: none;
    text-align: center;
    padding: 30px 20px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    color: #856404;
    margin: 20px 0;
}

.error-message.show {
    display: block;
}

.error-message p {
    margin: 0 0 15px 0;
    font-size: 16px;
    line-height: 1.4;
}

.error-message button {
    padding: 10px 20px;
    background: #856404;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.3s ease;
}

.error-message button:hover {
    background: #6d4c04;
}

/* 📍 改善ポイント5: スムーズなアニメーション */
.announcement-item-link {
    opacity: 0;
    transform: translateY(10px);
    animation: fadeInNews 0.5s ease forwards;
}

.announcement-item-link:nth-child(1) { animation-delay: 0.0s; }
.announcement-item-link:nth-child(2) { animation-delay: 0.1s; }
.announcement-item-link:nth-child(3) { animation-delay: 0.2s; }
.announcement-item-link:nth-child(4) { animation-delay: 0.3s; }

@keyframes fadeInNews {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 📍 改善ポイント6: 記事がない場合のスタイル */
.no-announcements {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f4 100%);
    border: 1px solid #e9ecef;
    border-radius: 12px;
    margin: 20px 0;
    position: relative;
    overflow: hidden;
}

.no-announcements::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
    animation: shimmerEffect 2s infinite;
}

@keyframes shimmerEffect {
    0% { left: -100%; }
    100% { left: 100%; }
}

.no-announcements p {
    margin: 0;
    font-style: italic;
    color: #6c757d;
    font-size: 16px;
    z-index: 1;
    position: relative;
}

/* 📍 改善ポイント7: エラーフォールバック */
.error-fallback {
    animation: errorSlideIn 0.3s ease-out;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.error-fallback button {
    transition: all 0.3s ease;
}

.error-fallback button:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* 📍 改善ポイント8: レスポンシブ対応 */
@media screen and (max-width: 768px) {
    .skeleton-item {
        flex-direction: column;
        align-items: flex-start;
        padding: 15px 0;
    }
    
    .skeleton-date,
    .skeleton-category {
        margin-right: 0;
        margin-bottom: 8px;
        width: 100%;
        max-width: 150px;
    }
    
    .skeleton-text {
        width: 100%;
    }
    
    .no-announcements {
        min-height: 100px;
        padding: 30px 15px;
    }
    
    .no-announcements p {
        font-size: 14px;
    }
    
    .error-message {
        padding: 20px 15px;
    }
    
    .error-message p {
        font-size: 14px;
    }
}

@media screen and (max-width: 480px) {
    #announce .announce-list {
        min-height: 150px;
    }
    
    .skeleton-item {
        padding: 12px 0;
    }
    
    .loading-spinner {
        height: 150px;
    }
    
    .spinner {
        width: 32px;
        height: 32px;
        border-width: 3px;
    }
    
    .loading-text {
        font-size: 12px;
    }
}

/* 📍 改善ポイント9: プリファレンス対応 */
@media (prefers-reduced-motion: reduce) {
    .announcement-item-link {
        animation: none;
        opacity: 1;
        transform: none;
    }
    
    .skeleton-date,
    .skeleton-category,
    .skeleton-text {
        animation: none;
        background: #e0e0e0;
    }
    
    .spinner {
        animation: none;
        border: 4px solid #e0e0e0;
        border-top: 4px solid #918A7A;
    }
    
    .no-announcements::before {
        animation: none;
    }
}

/* 📍 改善ポイント10: ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .skeleton-date,
    .skeleton-category,
    .skeleton-text {
        background: linear-gradient(90deg, #333 25%, #444 50%, #333 75%);
        background-size: 200% 100%;
    }
    
    .no-announcements {
        background: linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%);
        border-color: #444;
    }
    
    .no-announcements p {
        color: #ccc;
    }
    
    .error-message {
        background: #3a3a2a;
        border-color: #5a5a3a;
        color: #ffeb9c;
    }
    
    .error-message button {
        background: #5a5a3a;
        color: #ffeb9c;
    }
    
    .error-message button:hover {
        background: #4a4a2a;
    }
}