/* =========================================
   Article & Post Page Styles (Added)
   ========================================= */

/* --- Layout Structure --- */
.page-content {
    margin-top: var(--header-height);
    padding-bottom: 6rem;
}

/* 記事本文とサイドバー（目次）のグリッド配置 */
.media-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 4rem;
    padding: 2rem 0;
    align-items: stretch;
}

/* --- Article Header --- */
.article-header {
    padding: 3rem 0;
    background: var(--bg-pale);
    border-bottom: 1px solid var(--border-light);
}

.post-label {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    padding: 0.3rem 1rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.article-title {
    font-size: 2.2rem;
    line-height: 1.4;
    font-weight: 800;
    margin-bottom: 1rem;
    color: var(--text-main);
    word-break: normal;
}

.article-meta {
    display: flex;
    gap: 1.5rem;
    color: var(--text-light);
    font-size: 0.9rem;
    font-family: var(--font-en);
    font-weight: 600;
}

/* パンくずリスト */
.breadcrumbs {
    padding: 1.5rem 0;
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.breadcrumbs a {
    color: var(--primary);
    font-weight: 600;
}

.breadcrumbs span {
    margin: 0 0.5rem;
    color: #ccc;
}

/* --- Article Body Typography --- */
.eye-catch {
    margin-bottom: 3rem;
    box-shadow: var(--shadow-md);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.article-body {
    overflow-wrap: break-word;
    word-break: break-word;
}

.article-body h2 {
    font-size: 1.8rem;
    border-bottom: 2px solid var(--primary);
    padding-bottom: 0.5rem;
    margin: 3.5rem 0 1.5rem;
    position: relative;
    scroll-margin-top: 120px;
}

.article-body h3 {
    font-size: 1.4rem;
    padding: 0.5rem 1rem;
    border-left: 4px solid var(--primary);
    margin: 2.5rem 0 1rem;
    background: var(--bg-pale);
    scroll-margin-top: 120px;
}

.article-body p {
    margin-bottom: 1.8rem;
    line-height: 2;
    font-size: 1.05rem;
}

/* --- Table of Contents (Desktop Sticky) --- */
.sidebar {
    position: relative;
    height: 100%;
    /* Ensure full height for sticky context */
}

.toc-widget {
    position: sticky;
    top: 120px;
    background: #fff;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    z-index: 100;
    /* Increased z-index */
    align-self: start;
    /* Ensure it sticks at top of container */
}

.toc-widget-title {
    font-size: 1rem;
    font-weight: 800;
    margin-bottom: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.toc-widget-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--primary);
    display: block;
}

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

.toc-list li {
    margin-bottom: 0.8rem;
}

.toc-list a {
    font-size: 0.9rem;
    color: var(--text-light);
    display: block;
    line-height: 1.4;
    transition: all 0.3s ease;
    border-left: 2px solid transparent;
    padding-left: 10px;
}

.toc-list a:hover {
    color: var(--primary);
}

.toc-list a.active {
    color: var(--primary);
    font-weight: 700;
    border-left: 2px solid var(--primary);
}

/* --- Table of Contents (Mobile View) --- */
.toc-mobile {
    display: none;
    background: var(--bg-pale);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.8rem;
    margin-bottom: 3rem;
}

.toc-mobile-title {
    font-weight: 800;
    margin-bottom: 1.2rem;
    font-size: 1.1rem;
    text-align: center;
    color: var(--primary);
}

.toc-mobile-list {
    list-style: none;
}

.toc-mobile-list li {
    margin-bottom: 0.6rem;
    border-bottom: 1px dashed rgba(0, 174, 239, 0.2);
    padding-bottom: 0.6rem;
}

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

.toc-mobile-list a {
    font-size: 0.95rem;
    color: var(--text-main);
    font-weight: 600;
}

/* --- Related Posts Section --- */
.related-posts {
    margin-top: 5rem;
    padding-top: 3rem;
    border-top: none;
}

.related-title {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.related-title::after {
    content: '';
    flex-grow: 1;
    height: 1px;
    background: var(--border-light);
}

.related-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
}

.related-card {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
}

.related-thumb {
    width: 100px;
    height: 75px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    background-color: #eee;
}

.related-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.related-info h4 {
    font-size: 0.95rem;
    line-height: 1.5;
    font-weight: 700;
    margin-bottom: 0.4rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    color: var(--text-main);
}

.related-date {
    font-size: 0.8rem;
    color: var(--text-light);
    font-family: var(--font-en);
}

/* --- Responsive Adjustments --- */
@media (max-width: 950px) {
    .media-layout {
        grid-template-columns: minmax(0, 1fr);
        gap: 2rem;
    }

    .sidebar {
        display: none;
    }

    .toc-mobile {
        display: block;
    }

    .article-title {
        font-size: 1.8rem;
    }

    .article-header {
        padding: 2rem 0;
    }

    .related-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

@media (max-width: 600px) {
    .article-title {
        font-size: 1.5rem;
    }

    .article-body h2 {
        font-size: 1.4rem;
        margin-top: 2.5rem;
    }

    .article-body h3 {
        font-size: 1.2rem;
    }

    .article-body p {
        font-size: 0.95rem;
    }
}

/* =========================================
   Column (Media) Directory Page Specific Styles
   ========================================= */

/* Unique Hero for Media Directory */
.md-hero {
    margin-top: var(--header-height);
    background: linear-gradient(135deg, var(--primary) 0%, #00d2ff 100%);
    padding: 5rem 0;
    text-align: center;
    color: var(--white);
}

.md-title {
    font-size: 2.8rem;
    margin-bottom: 0.5rem;
    font-weight: 800;
    line-height: 1.2;
}

.md-subtitle {
    font-family: var(--font-en);
    letter-spacing: 0.25em;
    font-weight: 700;
    opacity: 0.9;
    font-size: 1rem;
}

/* Breadcrumbs with unique scope */
.md-breadcrumbs {
    padding: 1.2rem 0;
    font-size: 0.85rem;
    color: var(--text-light);
    white-space: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.md-breadcrumbs a {
    color: var(--primary);
}

.md-breadcrumbs span {
    margin: 0 0.6rem;
    color: #ccc;
}

/* Layout Grid for Directory (300px sidebar) */
.md-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 4rem;
    padding: 1rem 0 6rem;
}

/* Post List & Directory Cards */
.md-post-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
}

.md-post-card {
    background: var(--white);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.md-post-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.md-post-thumb {
    width: 100%;
    height: 220px;
    background-color: #f5f5f5;
    position: relative;
    overflow: hidden;
}

.md-post-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.md-post-card:hover .md-post-thumb img {
    transform: scale(1.05);
}

.md-post-cat {
    position: absolute;
    top: 15px;
    left: 15px;
    background: var(--primary);
    color: #fff;
    padding: 0.4rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 4px;
    z-index: 2;
}

.md-post-body {
    padding: 2rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.md-post-meta {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    font-family: var(--font-en);
    font-weight: 600;
}

.md-post-title {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    line-height: 1.6;
    color: var(--text-main);
    font-weight: 700;
    word-break: normal;
}

.md-post-excerpt {
    font-size: 0.95rem;
    color: var(--text-light);
    margin-bottom: 1.8rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.7;
}

.md-post-more {
    margin-top: auto;
    color: var(--primary);
    font-weight: 700;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Sidebar Widgets for Directory */
.md-widget {
    margin-bottom: 4rem;
}

.md-widget-title {
    font-size: 1.2rem;
    border-left: 5px solid var(--primary);
    padding-left: 1.2rem;
    margin-bottom: 2rem;
    color: var(--text-main);
    font-weight: 800;
}

.md-cat-list,
.md-recent-list {
    list-style: none;
}

.md-cat-list li {
    border-bottom: 1px solid var(--border-light);
}

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

.md-cat-list a {
    display: flex;
    justify-content: space-between;
    padding: 1rem 0;
    font-size: 1rem;
    color: var(--text-main);
    font-weight: 600;
}

.md-cat-list a span {
    color: var(--text-light);
    opacity: 0.6;
    font-family: var(--font-en);
    font-weight: 400;
}

.md-recent-item {
    display: flex;
    gap: 1.2rem;
    margin-bottom: 1.5rem;
    text-decoration: none;
    color: inherit;
}

.md-recent-thumb {
    width: 90px;
    height: 70px;
    border-radius: 8px;
    overflow: hidden;
    background: #eee;
    flex-shrink: 0;
}

.md-recent-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.md-recent-info {
    flex: 1;
}

.md-recent-info h4 {
    font-size: 0.9rem;
    line-height: 1.5;
    font-weight: 700;
    margin: 0;
    color: var(--text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.md-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 0.7rem;
}

.md-tag-cloud a {
    background: var(--bg-pale);
    border: 1px solid var(--border-light);
    padding: 0.5rem 1.2rem;
    font-size: 0.8rem;
    border-radius: 8px;
    font-weight: 600;
    color: var(--text-light);
    transition: 0.3s;
}

.md-tag-cloud a:hover {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* Pagination Unique */
.md-pagination {
    grid-column: 1 / -1;
    display: flex;
    justify-content: center;
    margin-top: 3rem;
}

.md-pagination .nav-links {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.8rem;
}

.md-pagination a,
.md-pagination span {
    width: 50px;
    height: 50px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    font-weight: 700;
    font-family: var(--font-en);
    transition: 0.3s;
}

.md-pagination a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--bg-pale);
}

.md-pagination .current {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* =========================================
   Mobile Logic for Media Page
   ========================================= */
@media (max-width: 950px) {
    .md-layout {
        grid-template-columns: 1fr;
        gap: 4rem;
        padding-bottom: 5rem;
    }

    .md-post-list {
        gap: 2.5rem;
    }

    .md-sidebar {
        padding: 0 1rem;
        border-top: 1px solid var(--border-light);
        padding-top: 4rem;
    }

    .md-hero {
        padding: 4rem 0;
    }

    .md-title {
        font-size: 2.2rem;
    }

    .md-subtitle {
        font-size: 0.9rem;
    }
}

@media (max-width: 600px) {
    .md-post-list {
        grid-template-columns: 1fr;
    }

    .md-title {
        font-size: 1.8rem;
        padding: 0 5%;
    }

    .md-post-thumb {
        height: 180px;
    }

    .md-post-body {
        padding: 1.5rem;
    }

    .md-post-title {
        font-size: 1.15rem;
        line-height: 1.5;
        margin-bottom: 0.8rem;
    }

    .md-post-excerpt {
        font-size: 0.9rem;
        margin-bottom: 1.2rem;
    }

    .md-pagination a,
    .md-pagination span {
        width: 40px;
        height: 40px;
        font-size: 0.9rem;
    }

    .md-widget {
        margin-bottom: 3rem;
    }

    .md-widget-title {
        font-size: 1.1rem;
        margin-bottom: 1.5rem;
    }

    .md-breadcrumbs {
        font-size: 0.75rem;
    }
}

/* --- FAQ Section Overrides for Article Body --- */
.article-body .faq-question h3 {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
    font-size: 1.05rem;
    font-weight: 700;
    color: inherit;
    line-height: inherit;
}

@media (max-width: 600px) {
    .article-body .faq-question h3 {
        font-size: 0.95rem;
    }
}

.article-body .faq-list {
    grid-template-columns: 1fr !important;
    /* Force 1 column always */
}

/* --- Article Body Lists & Tables --- */
.article-body ul,
.article-body ol {
    margin-bottom: 1.5rem;
    padding-left: 2rem;
    /* Prevents numbers from sticking out */
}

.article-body li {
    margin-bottom: 0.5rem;
}

/* Table Styles (Visuals Global) */
.article-body table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 2rem;
}

.article-body th,
.article-body td {
    padding: 1rem;
    border: 1px solid #e2e8f0;
    /* var(--border-light) */
    vertical-align: top;
    font-size: 0.95rem;
    line-height: 1.6;
}


.article-body th {
    background: #f7fafc;
    /* var(--bg-pale) */
    font-weight: 700;
    white-space: normal;
    min-width: 120px;
    /* Ensure headers don't get too narrow */
}

/* Mobile Table Logic (Scroll & Widths) */
@media (max-width: 768px) {

    .wp-block-table,
    .table-responsive {
        display: block;
        overflow-x: auto;
        margin-bottom: 2rem;
        -webkit-overflow-scrolling: touch;
        width: 100%;
    }

    .article-body table {
        display: block;
        /* Create a scrolling container */
        overflow-x: auto;
        width: 100%;
        min-width: unset;
        /* Let content dictate width, but scroll if needed */
        margin-bottom: 2rem;
    }



    .article-body th,
    .article-body td {
        padding: 0.5rem;
        /* Reduce padding slightly */
        font-size: 0.85rem;
        /* Smaller font for mobile */
    }

    .article-body td {
        min-width: 100px;
        word-wrap: break-word;
        overflow-wrap: break-word;
    }
}