/**
 * NK Base Theme - archive.css
 * アーカイブ・ブログ一覧・タクソノミー専用スタイル
 *
 * @package NK_Base_Theme
 * @version 1.4.0
 *
 * 目次:
 * 1. アーカイブレイアウト基盤
 * 2. アーカイブヘッダー
 * 3. 投稿グリッド（カードレイアウト）
 * 4. 投稿リスト（リストレイアウト）
 * 5. 投稿カード共通パーツ
 * 6. スティッキー投稿
 * 7. ページネーション
 * 8. サイドバー（アーカイブ専用）
 * 9. タクソノミーアーカイブ固有スタイル
 * 10. 検索結果ページ固有スタイル
 * 11. カスタム投稿タイプアーカイブ固有スタイル
 * 12. コンテンツ未検出（no-results）
 * 13. レスポンシブ対応
 */

/* =============================================================
   1. アーカイブレイアウト基盤
   ============================================================= */

.archive .nk-layout,
.blog .nk-layout,
.search .nk-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--nk-spacing-2xl, 3rem);
    max-width: var(--nk-container-width, 1200px);
    margin-inline: auto;
    padding-inline: var(--nk-spacing-md, 1.5rem);
}

.archive .nk-layout--has-sidebar,
.blog .nk-layout--has-sidebar,
.search .nk-layout--has-sidebar {
    grid-template-columns: 1fr 300px;
}

@media (max-width: 960px) {
    .archive .nk-layout--has-sidebar,
    .blog .nk-layout--has-sidebar,
    .search .nk-layout--has-sidebar {
        grid-template-columns: 1fr;
    }
}

/* =============================================================
   2. アーカイブヘッダー
   ============================================================= */

.archive-header {
    margin-bottom: var(--nk-spacing-2xl, 3rem);
    padding-bottom: var(--nk-spacing-xl, 2rem);
    border-bottom: 2px solid var(--nk-color-border, #e0e0e0);
}

.archive-header__eyebrow {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.15em;
    text-transform: uppercase;
    color: var(--nk-color-primary, #1a4f8a);
    background: rgba(26, 79, 138, 0.08);
    padding: 0.25em 0.75em;
    border-radius: 20px;
    margin-bottom: var(--nk-spacing-sm, 0.75rem);
}

.archive-header__title {
    font-size: var(--wp--preset--font-size--3xl, 2rem);
    font-weight: 700;
    line-height: 1.3;
    color: var(--nk-color-text, #1e1e1e);
    margin: 0 0 var(--nk-spacing-sm, 0.75rem);
}

.archive-header__description {
    font-size: var(--wp--preset--font-size--base, 1rem);
    color: var(--nk-color-text-muted, #666666);
    line-height: 1.7;
    margin: 0;
    max-width: 720px;
}

.archive-header__meta {
    margin-top: var(--nk-spacing-md, 1.5rem);
    font-size: 0.875rem;
    color: var(--nk-color-text-muted, #666666);
}

.archive-header__count {
    font-weight: 600;
    color: var(--nk-color-primary, #1a4f8a);
}

/* =============================================================
   3. 投稿グリッド（カードレイアウト）
   ============================================================= */

.nk-post-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--nk-spacing-xl, 2rem);
    margin-bottom: var(--nk-spacing-2xl, 3rem);
}

/* サイドバーあり時はカラム数を調整 */
.nk-layout--has-sidebar .nk-post-grid {
    grid-template-columns: repeat(2, 1fr);
}

@media (max-width: 1100px) {
    .nk-post-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 640px) {
    .nk-post-grid {
        grid-template-columns: 1fr;
    }

    .nk-layout--has-sidebar .nk-post-grid {
        grid-template-columns: 1fr;
    }
}

/* =============================================================
   4. 投稿リスト（リストレイアウト）
   ============================================================= */

.nk-post-list {
    display: flex;
    flex-direction: column;
    gap: var(--nk-spacing-lg, 1.5rem);
    margin-bottom: var(--nk-spacing-2xl, 3rem);
}

.nk-post-list-item {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: var(--nk-spacing-lg, 1.5rem);
    background: #fff;
    border: 1px solid var(--nk-color-border, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.nk-post-list-item:hover {
    box-shadow: 0 4px 20px rgba(26, 79, 138, 0.1);
    transform: translateY(-2px);
}

.nk-post-list-item__thumbnail {
    aspect-ratio: 4 / 3;
    overflow: hidden;
}

.nk-post-list-item__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.nk-post-list-item:hover .nk-post-list-item__thumbnail img {
    transform: scale(1.05);
}

.nk-post-list-item__body {
    padding: var(--nk-spacing-lg, 1.5rem) var(--nk-spacing-lg, 1.5rem) var(--nk-spacing-lg, 1.5rem) 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.nk-post-list-item__cat {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--nk-color-primary, #1a4f8a);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: var(--nk-spacing-xs, 0.5rem);
}

.nk-post-list-item__title {
    font-size: var(--wp--preset--font-size--lg, 1.125rem);
    font-weight: 700;
    line-height: 1.4;
    color: var(--nk-color-text, #1e1e1e);
    margin: 0 0 var(--nk-spacing-sm, 0.75rem);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nk-post-list-item__excerpt {
    font-size: 0.9375rem;
    color: var(--nk-color-text-muted, #666666);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin: 0;
}

.nk-post-list-item__date {
    margin-top: auto;
    padding-top: var(--nk-spacing-sm, 0.75rem);
    font-size: 0.8125rem;
    color: var(--nk-color-text-muted, #666666);
}

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

    .nk-post-list-item__thumbnail {
        aspect-ratio: 16 / 9;
    }

    .nk-post-list-item__body {
        padding: var(--nk-spacing-md, 1.5rem);
    }
}

/* =============================================================
   5. 投稿カード共通パーツ
   ============================================================= */

.nk-post-card {
    background: #fff;
    border: 1px solid var(--nk-color-border, #e0e0e0);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
    display: flex;
    flex-direction: column;
}

.nk-post-card:hover {
    box-shadow: 0 8px 32px rgba(26, 79, 138, 0.12);
    transform: translateY(-4px);
}

.nk-post-card__thumbnail {
    aspect-ratio: 3 / 2;
    overflow: hidden;
    position: relative;
}

.nk-post-card__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.nk-post-card:hover .nk-post-card__thumbnail img {
    transform: scale(1.06);
}

.nk-post-card__thumbnail--noimage {
    background: var(--nk-color-bg-light, #f8f9fa);
    display: flex;
    align-items: center;
    justify-content: center;
}

.nk-post-card__thumbnail--noimage::after {
    content: '';
    display: block;
    width: 48px;
    height: 48px;
    background: var(--nk-color-border, #e0e0e0);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z'/%3E%3C/svg%3E") no-repeat center / contain;
}

.nk-post-card__badges {
    position: absolute;
    top: var(--nk-spacing-sm, 0.75rem);
    left: var(--nk-spacing-sm, 0.75rem);
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.nk-post-card__badge {
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.2em 0.5em;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.nk-post-card__badge--new {
    background: var(--nk-color-primary, #1a4f8a);
    color: #fff;
}

.nk-post-card__badge--pickup {
    background: var(--nk-color-accent, #f0a500);
    color: #fff;
}

.nk-post-card__body {
    padding: var(--nk-spacing-lg, 1.5rem);
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: var(--nk-spacing-xs, 0.5rem);
}

.nk-post-card__meta {
    display: flex;
    align-items: center;
    gap: var(--nk-spacing-sm, 0.75rem);
    flex-wrap: wrap;
}

.nk-post-card__cat {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--nk-color-primary, #1a4f8a);
    background: rgba(26, 79, 138, 0.08);
    padding: 0.2em 0.6em;
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.2s ease;
}

.nk-post-card__cat:hover {
    background: rgba(26, 79, 138, 0.16);
}

.nk-post-card__date {
    font-size: 0.8125rem;
    color: var(--nk-color-text-muted, #666666);
}

.nk-post-card__title {
    font-size: var(--wp--preset--font-size--base, 1rem);
    font-weight: 700;
    line-height: 1.5;
    color: var(--nk-color-text, #1e1e1e);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nk-post-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.nk-post-card__title a:hover {
    color: var(--nk-color-primary, #1a4f8a);
}

.nk-post-card__excerpt {
    font-size: 0.875rem;
    color: var(--nk-color-text-muted, #666666);
    line-height: 1.6;
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.nk-post-card__footer {
    margin-top: auto;
    padding-top: var(--nk-spacing-sm, 0.75rem);
    border-top: 1px solid var(--nk-color-border, #e0e0e0);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--nk-color-text-muted, #666666);
}

.nk-post-card__read-more {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--nk-color-primary, #1a4f8a);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: gap 0.2s ease;
}

.nk-post-card:hover .nk-post-card__read-more {
    gap: 0.5rem;
}

/* =============================================================
   6. スティッキー投稿
   ============================================================= */

.nk-post-card.sticky {
    border-color: var(--nk-color-accent, #f0a500);
    position: relative;
}

.nk-post-card.sticky::before {
    content: 'おすすめ';
    position: absolute;
    top: var(--nk-spacing-sm, 0.75rem);
    right: var(--nk-spacing-sm, 0.75rem);
    background: var(--nk-color-accent, #f0a500);
    color: #fff;
    font-size: 0.6875rem;
    font-weight: 700;
    padding: 0.2em 0.6em;
    border-radius: 3px;
    z-index: 1;
}

/* =============================================================
   7. ページネーション
   ============================================================= */

.nk-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--nk-spacing-xs, 0.5rem);
    margin-top: var(--nk-spacing-2xl, 3rem);
    flex-wrap: wrap;
}

/* WordPress コア .wp-pagenavi / .navigation 対応 */
.nav-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--nk-spacing-xs, 0.5rem);
    margin-top: var(--nk-spacing-2xl, 3rem);
    flex-wrap: wrap;
}

.nav-links .page-numbers,
.nk-pagination .page-numbers {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 0.5rem;
    border: 1px solid var(--nk-color-border, #e0e0e0);
    border-radius: 6px;
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--nk-color-text, #1e1e1e);
    background: #fff;
    transition: all 0.2s ease;
}

.nav-links .page-numbers:hover:not(.current),
.nk-pagination .page-numbers:hover:not(.current) {
    border-color: var(--nk-color-primary, #1a4f8a);
    color: var(--nk-color-primary, #1a4f8a);
    background: rgba(26, 79, 138, 0.05);
}

.nav-links .page-numbers.current,
.nk-pagination .page-numbers.current {
    background: var(--nk-color-primary, #1a4f8a);
    border-color: var(--nk-color-primary, #1a4f8a);
    color: #fff;
    font-weight: 700;
}

.nav-links .page-numbers.dots,
.nk-pagination .page-numbers.dots {
    border: none;
    background: transparent;
    cursor: default;
}

.nav-links .prev,
.nav-links .next,
.nk-pagination .prev,
.nk-pagination .next {
    font-weight: 600;
    padding: 0 1rem;
    min-width: auto;
}

/* =============================================================
   8. サイドバー（アーカイブ専用）
   ============================================================= */

.nk-layout__sidebar {
    display: flex;
    flex-direction: column;
    gap: var(--nk-spacing-xl, 2rem);
}

.nk-layout__sidebar .widget {
    background: var(--nk-color-bg-light, #f8f9fa);
    border-radius: 8px;
    padding: var(--nk-spacing-lg, 1.5rem);
}

.nk-layout__sidebar .widget-title {
    font-size: var(--wp--preset--font-size--base, 1rem);
    font-weight: 700;
    color: var(--nk-color-text, #1e1e1e);
    margin: 0 0 var(--nk-spacing-md, 1.5rem);
    padding-bottom: var(--nk-spacing-sm, 0.75rem);
    border-bottom: 2px solid var(--nk-color-primary, #1a4f8a);
    position: relative;
}

.nk-layout__sidebar .widget-title::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 40px;
    height: 2px;
    background: var(--nk-color-accent, #f0a500);
}

.nk-layout__sidebar .widget ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.nk-layout__sidebar .widget ul li {
    border-bottom: 1px solid var(--nk-color-border, #e0e0e0);
}

.nk-layout__sidebar .widget ul li:last-child {
    border-bottom: none;
}

.nk-layout__sidebar .widget ul li a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--nk-spacing-sm, 0.75rem) 0;
    color: var(--nk-color-text, #1e1e1e);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: color 0.2s ease, padding-left 0.2s ease;
}

.nk-layout__sidebar .widget ul li a:hover {
    color: var(--nk-color-primary, #1a4f8a);
    padding-left: 0.375rem;
}

/* 検索ウィジェット */
.nk-layout__sidebar .widget_search .search-form {
    display: flex;
    gap: 0.5rem;
}

.nk-layout__sidebar .widget_search .search-field {
    flex: 1;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--nk-color-border, #e0e0e0);
    border-radius: 6px;
    font-size: 0.9375rem;
}

.nk-layout__sidebar .widget_search .search-submit {
    padding: 0.625rem 1rem;
    background: var(--nk-color-primary, #1a4f8a);
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s ease;
}

.nk-layout__sidebar .widget_search .search-submit:hover {
    background: var(--nk-color-secondary, #2d7dd2);
}

/* =============================================================
   9. タクソノミーアーカイブ固有スタイル
   ============================================================= */

.tax-archive .archive-header {
    border-left: 4px solid var(--nk-color-primary, #1a4f8a);
    padding-left: var(--nk-spacing-lg, 1.5rem);
}

.tax-archive .archive-header__eyebrow {
    background: rgba(26, 79, 138, 0.1);
    color: var(--nk-color-primary, #1a4f8a);
}

/* カテゴリー別カラーバリエーション（子テーマで上書き可） */
.term-featured .archive-header__eyebrow {
    background: rgba(240, 165, 0, 0.12);
    color: var(--nk-color-accent, #f0a500);
}

/* =============================================================
   10. 検索結果ページ固有スタイル
   ============================================================= */

.search .archive-header__query {
    font-size: var(--wp--preset--font-size--3xl, 2rem);
}

.search .archive-header__query strong {
    color: var(--nk-color-primary, #1a4f8a);
}

.search .archive-header__zero {
    color: var(--nk-color-danger, #e74c3c);
    font-weight: 600;
}

/* 検索ハイライト */
.search-highlight {
    background: rgba(240, 165, 0, 0.2);
    color: var(--nk-color-text, #1e1e1e);
    padding: 0 0.125em;
    border-radius: 2px;
}

/* =============================================================
   11. カスタム投稿タイプアーカイブ固有スタイル
   ============================================================= */

/* お知らせアーカイブ */
.post-type-archive-nk_news .nk-post-grid {
    grid-template-columns: repeat(3, 1fr);
}

/* 導入事例アーカイブ */
.post-type-archive-nk_case .nk-post-grid {
    grid-template-columns: repeat(2, 1fr);
}

.post-type-archive-nk_case .nk-post-card__thumbnail {
    aspect-ratio: 16 / 9;
}

/* サービスアーカイブ */
.post-type-archive-nk_service .nk-post-grid {
    grid-template-columns: repeat(3, 1fr);
}

.post-type-archive-nk_service .nk-post-card__thumbnail {
    aspect-ratio: 4 / 3;
}

/* =============================================================
   12. コンテンツ未検出（no-results）
   ============================================================= */

.no-results {
    text-align: center;
    padding: var(--nk-spacing-4xl, 8rem) var(--nk-spacing-md, 1.5rem);
}

.no-results__icon {
    font-size: 4rem;
    color: var(--nk-color-border, #e0e0e0);
    margin-bottom: var(--nk-spacing-lg, 1.5rem);
    display: block;
}

.no-results__title {
    font-size: var(--wp--preset--font-size--2xl, 1.5rem);
    font-weight: 700;
    color: var(--nk-color-text, #1e1e1e);
    margin-bottom: var(--nk-spacing-sm, 0.75rem);
}

.no-results__description {
    color: var(--nk-color-text-muted, #666666);
    margin-bottom: var(--nk-spacing-xl, 2rem);
    font-size: var(--wp--preset--font-size--base, 1rem);
    line-height: 1.7;
}

.no-results .search-form {
    max-width: 480px;
    margin-inline: auto;
    display: flex;
    gap: var(--nk-spacing-sm, 0.75rem);
}

.no-results .search-field {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--nk-color-border, #e0e0e0);
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.no-results .search-field:focus {
    outline: none;
    border-color: var(--nk-color-primary, #1a4f8a);
    box-shadow: 0 0 0 3px rgba(26, 79, 138, 0.1);
}

.no-results .search-submit {
    padding: 0.75rem 1.5rem;
    background: var(--nk-color-primary, #1a4f8a);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.no-results .search-submit:hover {
    background: var(--nk-color-secondary, #2d7dd2);
}

/* =============================================================
   13. レスポンシブ対応
   ============================================================= */

@media (max-width: 960px) {
    .nk-layout__sidebar {
        order: -1; /* サイドバーをコンテンツ上に移動 */
    }
}

@media (max-width: 768px) {
    .archive-header__title {
        font-size: var(--wp--preset--font-size--2xl, 1.5rem);
    }

    .nk-post-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--nk-spacing-lg, 1.5rem);
    }

    .nav-links .page-numbers,
    .nk-pagination .page-numbers {
        min-width: 36px;
        height: 36px;
        font-size: 0.875rem;
    }
}

@media (max-width: 540px) {
    .nk-post-grid {
        grid-template-columns: 1fr;
    }

    .archive-header {
        padding-bottom: var(--nk-spacing-lg, 1.5rem);
        margin-bottom: var(--nk-spacing-xl, 2rem);
    }

    .no-results .search-form {
        flex-direction: column;
    }

    .no-results .search-submit {
        width: 100%;
    }
}
