* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    width: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: #333;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    width: 100%;
    min-width: 320px;
    box-sizing: border-box;
}

*, *::before, *::after {
    box-sizing: border-box;
}

.article-content h2 {
  font-size: 1.8rem;
  font-weight: 700;
  padding: 0.5em 0;/*上下の余白*/
  border-top: solid 3px #364e96;/*上線*/
  border-bottom: solid 3px #364e96;/*下線*/
  margin-top: 2em;
  margin-bottom: 1em;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

.site-header {
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 100;
    width: 100%;
    min-width: 100%;
    left: 0;
    right: 0;
}

.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    box-sizing: border-box;
}

.site-title {
    font-size: 28px;
    font-weight: bold;
    /* background: linear-gradient(135deg, #3498db, #2980b9); */
    padding: 10px 0px;
    /* border-radius: 8px; */
    /* color: #000; */
}

.site-title a {
    color: #000;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

.site-logo {
    height: 40px;
    width: auto;
}

.main-nav {
    display: flex;
    gap: 30px;
}

.main-nav a {
    color: #34495e;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.main-nav a:hover {
    color: #3498db;
}

.breadcrumb {
    background: #ecf0f1;
    padding: 10px 20px;
    margin-bottom: 20px;
    border-radius: 5px;
    font-size: 14px;
    width: 100%;
}

.breadcrumb a {
    color: #3498db;
    text-decoration: none;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.main-content {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
    margin-bottom: 40px;
    width: 100%;
    max-width: 100%;
    /* sticky要素が正しく動作するための設定 */
    align-items: start;
}

.content-area {
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

.news-section {
    margin-bottom: 40px;
    padding-bottom: 30px;
    border-bottom: 1px solid #eee;
}

.news-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 24px;
}

.news-list {
    list-style: none;
}

.news-list li {
    padding: 10px 0;
    border-bottom: 1px solid #f1f2f6;
    display: flex;
    gap: 15px;
}

.news-list li:last-child {
    border-bottom: none;
}

.news-date {
    color: #7f8c8d;
    font-size: 14px;
    white-space: nowrap;
}

.news-title {
    color: #2c3e50;
}

.articles-section h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 24px;
}

.articles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.article-card {
    background: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.article-thumbnail {
    width: 100%;
    height: 200px;
    overflow: hidden;
}

.article-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-content {
    padding: 20px;
}

.article-content h3 {
    margin-bottom: 10px;
    font-size: 18px;
}

.article-content h3 a {
    color: #2c3e50;
    text-decoration: none;
}

.article-content h3 a:hover {
    color: #3498db;
}

.article-summary {
    color: #6c757d;
    margin-bottom: 15px;
    line-height: 1.5;
}

.article-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: #7f8c8d;
}

.article-category a {
    color: #3498db;
    text-decoration: none;
    background: #e3f2fd;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 30px;
}

.pagination a,
.pagination span {
    padding: 8px 12px;
    border-radius: 4px;
    text-decoration: none;
    color: #3498db;
    border: 1px solid #ddd;
}

.pagination a:hover {
    background-color: #3498db;
    color: white;
}

.pagination .current {
    background-color: #3498db;
    color: white;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
    width: 300px;
    min-width: 300px;
    max-width: 300px;
}

/* Stickyコンテナ */
.sticky-sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.widget {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.widget h3 {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 18px;
    border-bottom: 2px solid #3498db;
    padding-bottom: 5px;
    display: flex;
    align-items: center;
}

.widget-icon {
    margin-right: 8px;
    font-size: 16px;
}

.popular-articles-widget {
    background: linear-gradient(135deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid rgba(52, 152, 219, 0.1);
}

.popular-articles-widget h3 {
    background: linear-gradient(90deg, #3498db, #2980b9);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    border-bottom-color: #3498db;
}

.category-list,
.archive-list,
.popular-articles-list {
    list-style: none;
}

.category-list li,
.archive-list li,
.popular-articles-list li {
    margin-bottom: 8px;
}

.category-list a,
.archive-list a {
    color: #34495e;
    text-decoration: none;
    padding: 5px 0;
    display: block;
    transition: color 0.3s;
}

.category-list a:hover,
.archive-list a:hover {
    color: #3498db;
}

.category-list .count,
.archive-list .count {
    color: #7f8c8d;
    font-size: 12px;
    font-weight: normal;
}

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

.popular-article-item {
    margin-bottom: 12px;
    /* border-radius: 8px; */
    overflow: hidden;
    /* background: #ffffff; */
    /* border: 1px solid #f0f0f0; */
    transition: all 0.3s ease;
}

.popular-article-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    border-color: #e0e0e0;
}

.popular-article-item:last-child {
    margin-bottom: 0;
}

.popular-article-link {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: inherit;
    /* padding: 8px; */
}

.popular-article-thumbnail {
    position: relative;
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    margin-right: 12px;
}

.popular-article-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.popular-article-item:hover .popular-article-thumbnail img {
    transform: scale(1.05);
}

.rank-badge {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.rank-badge.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border: 1px solid #e6c200;
}

.rank-badge.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    border: 1px solid #a0a0a0;
    color: #333;
}

.rank-badge.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #daa520);
    border: 1px solid #b8860b;
}

.rank-badge.rank-4,
.rank-badge.rank-5 {
    background: linear-gradient(135deg, #6c757d, #868e96);
    border: 1px solid #5a6268;
}

.rank-badge-no-image {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-right: 12px;
    flex-shrink: 0;
}

.rank-badge-no-image.rank-1 {
    background: linear-gradient(135deg, #ffd700, #ffed4e);
    border: 1px solid #e6c200;
}

.rank-badge-no-image.rank-2 {
    background: linear-gradient(135deg, #c0c0c0, #e8e8e8);
    border: 1px solid #a0a0a0;
    color: #333;
}

.rank-badge-no-image.rank-3 {
    background: linear-gradient(135deg, #cd7f32, #daa520);
    border: 1px solid #b8860b;
}

.rank-badge-no-image.rank-4,
.rank-badge-no-image.rank-5 {
    background: linear-gradient(135deg, #6c757d, #868e96);
    border: 1px solid #5a6268;
}

.popular-article-info {
    flex: 1;
    min-width: 0;
}

.popular-article-title {
    display: block;
    font-size: 13px;
    font-weight: 500;
    line-height: 1.3;
    color: #2c3e50;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    transition: color 0.3s ease;
}

.popular-article-link:hover .popular-article-title {
    color: #3498db;
}

.tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    background: #ecf0f1;
    color: #34495e;
    padding: 4px 12px;
    border-radius: 15px;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.3s;
}

.tag:hover {
    background: #3498db;
    color: white;
}

.ad-widget {
    text-align: center;
    /* 広告ウィジェットの統一スタイル */
    border: none !important;
    background: transparent !important;
    outline: none !important;
}

/* 広告要素の全体リセット - 全ページで統一表示 */
.widget.ad-widget,
.ad-widget,
.sticky-ad {
    border: none !important;
    background: white !important;
    outline: none !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1) !important;
}

/* Sticky Sidebar Advertisement - 広告ウィジェットのみ */
.widget.ad-widget.sticky-ad {
    position: sticky !important;
    top: 200px !important;
    z-index: 10 !important;
}

/* 他のウィジェットは確実にstaticに */
.widget.popular-articles-widget {
    position: static !important;
}


.sticky-ad.stuck {
    transform: scale(0.98);
    box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.ad-placeholder {
    background: linear-gradient(135deg, #f1f2f6, #e8eaed);
    border: 2px dashed #bdc3c7;
    padding: 40px 20px;
    border-radius: 8px;
    color: #7f8c8d;
    font-weight: 500;
    position: relative;
    overflow: hidden;
    /* 統一スタイル確保 */
    box-sizing: border-box;
}

.ad-placeholder::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shine 3s infinite;
}
.article-toc {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.article-toc h2 {
    margin-top: 0;
    color: #495057;
}

.article-toc ul {
    list-style: none;
    padding-left: 0;
}

.article-toc li {
    margin: 8px 0;
}

.article-toc a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

.article-toc a:hover {
    text-decoration: underline;
}

@keyframes shine {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Content Advertisements */
.content-ad-widget {
    margin: 30px 0;
    text-align: center;
    width: 100%;
}

.content-ad {
    max-width: 728px;
    margin: 0 auto;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow: hidden;
}

.ad-placeholder-content {
    background: linear-gradient(135deg, #e8f4f8, #f0f8ff);
    border: 2px dashed #4a90e2;
    padding: 30px 20px;
    color: #5a6c7d;
    font-weight: 500;
    position: relative;
    min-height: 90px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.ad-placeholder-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(74,144,226,0.1), transparent);
    animation: shimmer 4s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

/* Mobile Advertisement */
.mobile-ad-widget {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: white;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}

.mobile-ad {
    text-align: center;
    padding: 10px;
    position: relative;
}

.ad-placeholder-mobile {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 2px dashed #fdcb6e;
    padding: 15px;
    border-radius: 6px;
    color: #6c5ce7;
    font-weight: 500;
    font-size: 14px;
}

/* モバイル広告の閉じるボタン */
.mobile-ad-close {
    position: absolute;
    top: 5px;
    right: 10px;
    background: #ff6b6b;
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}

.site-footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 20px 0;
    margin-top: 40px;
}

@media (max-width: 768px) {
    .site-header {
        width: 100%;
    }

    .site-header .container {
        flex-direction: column;
        gap: 15px;
        padding: 15px 15px;
        width: 100%;
        max-width: 100%;
        margin: 0;
        box-sizing: border-box;
    }

    .main-nav {
        gap: 15px;
        flex-wrap: wrap;
        justify-content: center;
        width: 100%;
    }

    .main-nav a {
        font-size: 14px;
        padding: 8px 12px;
    }

    .breadcrumb {
        padding: 10px 0;
        margin: 0;
        width: 100%;
        box-sizing: border-box;
        border-radius: 0;
    }

    .main-content {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 0;
    }

    .content-area {
        padding: 20px 15px;
        margin: 0;
        margin-bottom: 120px; /* モバイル広告の分のマージン */
        border-radius: 0;
    }

    .articles-grid {
        grid-template-columns: 1fr;
    }

    .container {
        padding: 0;
        width: 100%;
        max-width: 100%;
    }

    /* サイドバー要素のモバイル対応 */
    .sidebar {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        padding: 0;
        gap: 0;
    }

    .sticky-sidebar {
        position: relative;
    }

    .widget {
        margin: 0;
        padding: 20px 15px;
        border-radius: 0;
        border-bottom: 1px solid #eee;
    }

    .widget:last-child {
        border-bottom: none;
    }

    /* 大きな要素の制限 */
    img, table, pre, code {
        max-width: 100%;
        height: auto;
        overflow-x: auto;
    }

    table {
        display: block;
        white-space: nowrap;
        overflow-x: auto;
    }

    .article-meta {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .news-list li {
        flex-direction: column;
        gap: 5px;
    }

    /* モバイル広告を表示 */
    .mobile-ad-widget {
        display: block;
        position: relative;
    }

    /* サイドバー広告をモバイルで調整 */
    .widget.ad-widget.sticky-ad {
        position: static !important;
        top: auto !important;
        margin: 0;
        border-radius: 0;
    }

    .ad-placeholder {
        padding: 30px 15px;
        border-radius: 0;
    }

    /* コンテンツ広告をモバイル用に調整 */
    .content-ad {
        max-width: 100%;
        margin: 0;
        border-radius: 0;
    }

    .ad-placeholder-content {
        min-height: 80px;
        padding: 20px 15px;
        font-size: 14px;
        border-radius: 0;
    }
}

@media (max-width: 480px) {
    .site-header {
        width: 100%;
    }

    .site-header .container {
        padding: 10px 10px;
        max-width: 100%;
        margin: 0;
    }

    .site-title {
        font-size: 20px;
    }

    .site-logo {
        height: 30px;
    }

    .main-nav {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
    }

    .main-nav a {
        font-size: 13px;
        padding: 6px 10px;
    }

    .breadcrumb {
        padding: 8px 0;
        font-size: 12px;
        width: 100%;
        box-sizing: border-box;
        border-radius: 0;
    }

    .content-area {
        padding: 15px 10px;
        margin-bottom: 140px;
        border-radius: 0;
    }

    .widget {
        padding: 15px 10px;
        border-radius: 0;
    }

    .popular-article-item {
        margin-bottom: 10px;
    }

    .popular-article-link {
        padding: 6px;
    }

    .popular-article-thumbnail {
        width: 50px;
        height: 50px;
        margin-right: 10px;
    }

    .rank-badge {
        width: 16px;
        height: 16px;
        font-size: 9px;
        top: 3px;
        left: 3px;
    }
    
    .rank-badge-no-image {
        width: 20px;
        height: 20px;
        font-size: 10px;
        margin-right: 10px;
    }

    .popular-article-title {
        font-size: 12px;
        line-height: 1.2;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .pagination a,
    .pagination span {
        padding: 6px 10px;
        font-size: 14px;
    }

    /* 超小画面での広告調整 */
    .ad-placeholder {
        padding: 20px 10px;
        font-size: 12px;
        border-radius: 0;
    }

    .ad-placeholder-content {
        padding: 15px 10px;
        font-size: 12px;
        min-height: 60px;
        border-radius: 0;
    }

    .ad-placeholder-mobile {
        padding: 10px;
        font-size: 12px;
    }
}

/* 広告の可視性アニメーション */
.ad-widget.ad-visible,
.content-ad-widget.ad-visible {
    animation: fadeInUp 0.6s ease-out;
}

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

/* 広告ホバー効果 */
.ad-widget:hover .ad-placeholder,
.content-ad-widget:hover .ad-placeholder-content {
    transform: scale(1.02);
    transition: transform 0.3s ease;
}

/* 広告の読み込み状態 */
.ad-loading {
    position: relative;
    overflow: hidden;
}

.ad-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading-shimmer 1.5s infinite;
}

@keyframes loading-shimmer {
    0% { left: -100%; }
    100% { left: 100%; }
}
