/* ============================================
   レスポンシブテーブル CSS
   モバイル対応強化
   ============================================ */

/* テーブルのラッパー */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* テーブル基本スタイル */
table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

/* デスクトップでは最小幅を確保 */
@media (min-width: 769px) {
    table {
        min-width: 600px;
    }
}

/* ヘッダー */
table thead th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

/* セル */
table tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
    line-height: 1.6;
}

/* 交互の行 */
table tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

/* ホバー効果 */
table tbody tr:hover {
    background-color: #f0f0f0;
}

/* モバイル最適化 */
@media (max-width: 768px) {
    .table-wrapper {
        margin: 15px 0;
        border-radius: 6px;
    }
    
    table thead th {
        font-size: 13px;
        padding: 10px 12px;
    }
    
    table tbody td {
        font-size: 13px;
        padding: 10px 12px;
    }
}

/* 小さな画面 */
@media (max-width: 480px) {
    table thead th {
        font-size: 12px;
        padding: 8px 10px;
    }
    
    table tbody td {
        font-size: 12px;
        padding: 8px 10px;
    }
}

/* ============================================
   見出し構造の改善
   ============================================ */

/* H1 の適正化 */
h1 {
    font-size: 28px;
    line-height: 1.3;
    margin: 30px 0 20px;
    color: #333;
    font-weight: 700;
}

@media (max-width: 768px) {
    h1 {
        font-size: 24px;
        margin: 25px 0 15px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 22px;
        margin: 20px 0 12px;
    }
}

/* H2 の適正化 */
h2 {
    font-size: 24px;
    line-height: 1.4;
    margin: 25px 0 15px;
    color: #444;
    font-weight: 600;
    border-bottom: 2px solid #667eea;
    padding-bottom: 8px;
}

@media (max-width: 768px) {
    h2 {
        font-size: 22px;
        margin: 20px 0 12px;
    }
}

@media (max-width: 480px) {
    h2 {
        font-size: 20px;
        margin: 18px 0 10px;
    }
}

/* H3 の適正化 */
h3 {
    font-size: 20px;
    line-height: 1.4;
    margin: 20px 0 12px;
    color: #555;
    font-weight: 600;
}

@media (max-width: 768px) {
    h3 {
        font-size: 18px;
        margin: 18px 0 10px;
    }
}

@media (max-width: 480px) {
    h3 {
        font-size: 17px;
        margin: 15px 0 8px;
    }
}

/* ============================================
   段落の最適化
   ============================================ */

p {
    font-size: 16px;
    line-height: 1.8;
    margin: 15px 0;
    color: #333;
    max-width: 800px;
}

@media (max-width: 768px) {
    p {
        font-size: 15px;
        line-height: 1.7;
    }
}

@media (max-width: 480px) {
    p {
        font-size: 14px;
        line-height: 1.6;
    }
}

/* ============================================
   箇条書きの最適化
   ============================================ */

ul, ol {
    margin: 15px 0;
    padding-left: 25px;
}

li {
    font-size: 16px;
    line-height: 1.8;
    margin: 8px 0;
    color: #333;
}

@media (max-width: 768px) {
    li {
        font-size: 15px;
        line-height: 1.7;
    }
}

@media (max-width: 480px) {
    li {
        font-size: 14px;
        line-height: 1.6;
    }
}

/* ============================================
   画像の最適化
   ============================================ */

img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

@media (max-width: 768px) {
    img {
        margin: 15px auto;
        border-radius: 6px;
    }
}

@media (max-width: 480px) {
    img {
        margin: 12px auto;
        border-radius: 4px;
    }
}

/* ============================================
   Related Articles カルーセル
   ============================================ */

.related-articles-carousel {
    margin: 40px 0;
    padding: 30px 0;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 12px;
    overflow: hidden;
}

.related-articles-carousel h3 {
    font-size: 1.5rem;
    color: #333;
    margin: 0 0 25px 0;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.carousel-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    padding: 0 20px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.carousel-item {
    background: white;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: transform 0.3s, box-shadow 0.3s;
    scroll-snap-align: start;
    min-width: 280px;
}

.carousel-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.carousel-item img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
}

.carousel-content {
    padding: 20px;
}

.carousel-content h4 {
    font-size: 1.1rem;
    color: #333;
    margin: 0 0 12px 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.carousel-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: color 0.3s;
}

.carousel-content a:hover {
    color: #764ba2;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .related-articles-carousel {
        margin: 30px 0;
        padding: 20px 0;
    }
    
    .related-articles-carousel h3 {
        font-size: 1.3rem;
        margin: 0 0 20px 0;
        padding: 0 15px;
    }
    
    .carousel-container {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 0 15px;
    }
    
    .carousel-item {
        min-width: 100%;
    }
    
    .carousel-content h4 {
        font-size: 1rem;
    }
}

/* ============================================
   記事ナビゲーション（前後リンク）
   ============================================ */

.article-navigation {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin: 40px 0;
    padding: 0;
}

.article-navigation a {
    display: block;
    padding: 20px 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    border-radius: 10px;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.article-navigation a:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.article-navigation .prev-article::before {
    content: '← ';
    font-weight: bold;
}

.article-navigation .next-article::after {
    content: ' →';
    font-weight: bold;
}

.article-navigation .nav-label {
    display: block;
    font-size: 0.85rem;
    opacity: 0.9;
    margin-bottom: 8px;
}

.article-navigation .nav-title {
    display: block;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

/* モバイル対応 */
@media (max-width: 768px) {
    .article-navigation {
        grid-template-columns: 1fr;
        gap: 15px;
        margin: 30px 0;
    }
    
    .article-navigation a {
        padding: 18px 20px;
    }
    
    .article-navigation .nav-title {
        font-size: 1rem;
    }
}

/* ============================================
   パフォーマンス最適化
   ============================================ */

/* レイアウトシフト防止 */
img {
    aspect-ratio: 16 / 10;
    object-fit: cover;
}

/* アニメーションの最適化 */
* {
    transition-property: color, background-color, transform;
    transition-duration: 0.3s;
    transition-timing-function: ease;
}

/* ============================================
   アクセシビリティ
   ============================================ */

/* フォーカスインジケーター */
a:focus, button:focus {
    outline: 3px solid #667eea;
    outline-offset: 2px;
}

/* コントラスト比の確保 */
a {
    color: #667eea;
    text-decoration: underline;
}

a:hover {
    color: #764ba2;
}

/* 色のみの情報伝達防止 */
.table-wrapper {
    border: 1px solid #ddd;
}
