/*
=======================================================================
   アーカイブページ専用CSS - archive.php用
   test-essential-elements.htmlのデザインを基に作成
=======================================================================
*/

/* CSS変数システム - test-essential-elements.htmlから移植 */
:root {
    /* カードサイズ制御変数 - 要件1.1, 1.2, 1.3 */
    --archive-card-height-desktop: 320px;    /* 現在の約450pxから30%削減 */
    --archive-card-height-tablet: 300px;     /* 現在の約400pxから25%削減 */
    --archive-card-height-mobile: 280px;     /* 現在の約350pxから20%削減 */

    /* 画像アスペクト比 - 要件1.4 */
    --archive-image-aspect-ratio: 16/9;      /* 3/2から16/9に変更 */

    /* テキスト制限 - 要件2.2, 2.3 */
    --archive-title-lines: 2;
    --archive-excerpt-lines: 2;
    --archive-title-line-height: 1.4;
    --archive-excerpt-line-height: 1.5;

    /* スペーシング最適化 - 要件2.5, 3.4 */
    --archive-card-gap-optimized: 24px;      /* 40pxから24pxに削減 */
    --archive-card-padding-optimized: 16px;  /* 20pxから16pxに削減（20%削減） */

    /* レスポンシブグリッド設定 - 要件3.1, 3.2, 3.3 */
    --archive-grid-columns-desktop: 3;       /* デスクトップ: 3列維持 */
    --archive-grid-columns-tablet: 2;        /* タブレット: 2列維持 */
    --archive-grid-columns-mobile: 1;        /* モバイル: 1列維持 */

    /* フォールバック用グラデーション */
    --hero-fallback-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/*
=======================================================================
   アーカイブヘッダー
=======================================================================
*/
.archive-header {
    position: relative;
    padding: 60px 20px;
    text-align: center;
    color: white;
    overflow: hidden;
    margin-bottom: 40px;
    background: var(--hero-fallback-gradient);
}

/* 背景画像がある場合 */
.archive-header.has-background-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

/* 背景画像の上にオーバーレイを追加 */
.archive-header.has-background-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1;
}

.archive-header-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    margin: 0 auto;
}

.archive-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 20px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.archive-description {
    font-size: 1.1rem;
    line-height: 1.6;
    margin-bottom: 30px;
    opacity: 0.9;
}

.archive-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-top: 20px;
}

.archive-type-info,
.archive-count {
    background: rgba(255, 255, 255, 0.2);
    padding: 5px 10px;
    border-radius: 15px;
    font-weight: 400;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .archive-header {
        padding: 40px 20px;
    }

    .archive-title {
        font-size: 2rem;
    }

    .archive-description {
        font-size: 0.9rem;
    }
}



/*
=======================================================================
   WordPressクエリループのグリッド設定
=======================================================================
*/
/* WordPressブロックエディタが生成するクラス名に対応 */
.wp-block-post-template.archive-post-grid {
    display: grid;
    gap: var(--archive-card-gap-optimized);
    margin-bottom: 40px;
    list-style: none;
    padding: 0;
    margin: 0;
}

/* レスポンシブグリッドレイアウト - 要件3.1, 3.2, 3.3 */
@media (min-width: 1024px) {
    .wp-block-post-template.archive-post-grid {
        grid-template-columns: repeat(var(--archive-grid-columns-desktop), 1fr);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .wp-block-post-template.archive-post-grid {
        grid-template-columns: repeat(var(--archive-grid-columns-tablet), 1fr);
    }
}

@media (max-width: 767px) {
    .wp-block-post-template.archive-post-grid {
        grid-template-columns: repeat(var(--archive-grid-columns-mobile), 1fr);
    }
}

/* CSS Grid未対応ブラウザ用のフォールバック */
@supports not (display: grid) {
    .wp-block-post-template.archive-post-grid {
        display: flex;
        flex-wrap: wrap;
        gap: var(--archive-card-gap-optimized);
    }

    .wp-block-post,
    .archive-post-card {
        flex: 1 1 calc(33.33% - var(--archive-card-gap-optimized));
        min-width: 300px;
    }

    @media (max-width: 1023px) {
        .wp-block-post,
        .archive-post-card {
            flex: 1 1 calc(50% - var(--archive-card-gap-optimized));
        }
    }

    @media (max-width: 767px) {
        .wp-block-post,
        .archive-post-card {
            flex: 1 1 auto;
            min-width: auto;
        }
    }
}

/*
=======================================================================
   アーカイブ投稿カード
=======================================================================
*/
/* test-essential-elements.htmlと同じスタイル */
article.wp-block-group.archive-post-card {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    cursor: pointer;
    padding: 0;
}

/* レスポンシブカード高さ - 要件1.1, 1.2, 1.3 */
@media (min-width: 1024px) {
    .archive-post-card {
        height: var(--archive-card-height-desktop);
    }
}

@media (min-width: 768px) and (max-width: 1023px) {
    .archive-post-card {
        height: var(--archive-card-height-tablet);
    }
}

@media (max-width: 767px) {
    .archive-post-card {
        height: var(--archive-card-height-mobile);
    }
}

/* ホバーエフェクト - 要件4.1 */
article.wp-block-group.archive-post-card:hover {
    box-shadow: 0 4px 4px rgba(0, 0, 0, 0.15);
}

/* アクセシビリティ - フォーカス状態 - 要件4.2 */
.archive-post-card:focus {
    outline: 2px solid #764ba2;
    outline-offset: 2px;
}

/*
=======================================================================
   1. サムネイル画像 - 要件2.1, 1.4
=======================================================================
*/
/* test-essential-elements.htmlと同じ画像スタイル */
.post-card-image {
    position: relative;
    aspect-ratio: var(--archive-image-aspect-ratio);
    overflow: hidden;
    background: var(--hero-fallback-gradient);
    flex-shrink: 0;
}

.post-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    transition: transform 0.3s ease;
}

.archive-post-card:hover .post-card-image img {
    transform: scale(1.05);
}

/* 画像読み込み失敗時のフォールバック - 要件4.4 */
.post-card-image.image-error::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--hero-fallback-gradient);
    z-index: 1;
}

.post-card-image.image-error::after {
    content: '📝';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.5rem;
    z-index: 2;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* 画像プレースホルダー（フォールバック画像用） */
.image-placeholder {
    width: 100%;
    height: 100%;
    background: var(--hero-fallback-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 2.5rem;
}

.image-placeholder.no-featured-image {
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.image-placeholder::after {
    content: '📝';
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/*
=======================================================================
   カードコンテンツエリア
=======================================================================
*/
/* test-essential-elements.htmlと同じカードコンテンツエリア */
.wp-block-group.post-card-content {
    flex: 1;
    padding: var(--archive-card-padding-optimized);
    display: flex;
    flex-direction: column;
}

/*
=======================================================================
   2. メタ情報（投稿日とカテゴリー） - 要件2.1, 2.4
=======================================================================
*/
/* test-essential-elements.htmlと同じメタ情報スタイル */
.wp-block-group.post-card-meta {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    font-size: 0.75rem;
    color: #888888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
    padding: 0;
}

.wp-block-group.post-card-meta .post-date {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    border: none;
    padding: 0;
    margin: 0;
}

.wp-block-group.post-categories {
    font-family: 'Montserrat', sans-serif;
    font-weight: 400;
    border: none;
    padding: 0;
    margin: 0;
}

.post-categories a {
    color: #764ba2;
    text-decoration: none;
    transition: color 0.3s ease;
    background-color: inherit;
    border: none;
    border-radius: 0;
    padding: 0;
}

.post-categories a:hover {
    color: #667eea;
}

/* カテゴリー未設定時のフォールバック */
.category-fallback {
    color: #999999;
    font-style: italic;
}

/*
=======================================================================
   3. タイトル - 要件2.1, 2.3
=======================================================================
*/
/* test-essential-elements.htmlと同じタイトルスタイル */
.post-card-title {
    margin-bottom: 12px;
    flex-shrink: 0;
}

.post-card-title h2 {
    font-size: 1.1rem;
    font-weight: 600;
    line-height: var(--archive-title-line-height);
    color: #333333;
    margin: 0;
    /* テキスト制限 - 2行に制限 */
    display: -webkit-box;
    -webkit-line-clamp: var(--archive-title-lines);
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: calc(var(--archive-title-line-height) * var(--archive-title-lines) * 1em);
}

.post-card-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.3s ease;
}

.post-card-title a:hover {
    color: #764ba2;
}

/*
=======================================================================
   4. 抜粋 - 要件2.1, 2.2
=======================================================================
*/
/* test-essential-elements.htmlと同じ抜粋スタイル */
.post-card-excerpt {
    flex: 1;
    font-size: 0.9rem;
    color: #666666;
    line-height: var(--archive-excerpt-line-height);
    /* テキスト制限 - 2行に制限 */
    display: -webkit-box;
    -webkit-line-clamp: var(--archive-excerpt-lines);
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: calc(var(--archive-excerpt-line-height) * var(--archive-excerpt-lines) * 1em);
}

.read-more-link {
    color: #764ba2;
    text-decoration: none;
    font-weight: 500;
    margin-left: 8px;
    transition: color 0.3s ease;
}

.read-more-link:hover {
    color: #667eea;
}

/* フォールバック対応 - line-clamp未対応ブラウザ */
@supports not (-webkit-line-clamp: 2) {
    .post-card-title h2 {
        max-height: calc(var(--archive-title-line-height) * var(--archive-title-lines) * 1em);
        overflow: hidden;
    }

    .post-card-excerpt {
        max-height: calc(var(--archive-excerpt-line-height) * var(--archive-excerpt-lines) * 1em);
        overflow: hidden;
    }
}

/*
=======================================================================
   データ不足時のスタイル - 要件4.5
=======================================================================
*/
.data-incomplete {
    border-color: #ffc107;
    background: #fff9c4;
    position: relative;
}

.data-incomplete::before {
    content: '⚠️ データ不足';
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ffc107;
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    z-index: 10;
}

/*
=======================================================================
   検索結果なし表示
=======================================================================
*/
.archive-no-results {
    text-align: center;
    padding: 60px 20px;
    color: #666666;
}

.archive-no-results h2 {
    font-size: 1.5rem;
    margin-bottom: 15px;
    color: #333333;
}

.archive-no-results p {
    font-size: 1rem;
    line-height: 1.6;
}

/*
=======================================================================
   ページネーション
=======================================================================
*/
.archive-pagination {
    margin-top: 60px;
    padding: 40px 20px;
    text-align: center;
}

.pagination-info {
    margin-bottom: 30px;
}

.pagination-current-info {
    font-size: 0.9rem;
    color: #666666;
    margin: 0;
}

/* WordPressクエリページネーション */
.wp-block-query-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.wp-block-query-pagination a,
.wp-block-query-pagination .wp-block-query-pagination-numbers {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    text-decoration: none;
    color: #333333;
    transition: all 0.3s ease;
    background: #ffffff;
}

.wp-block-query-pagination a:hover {
    background: #764ba2;
    color: #ffffff;
    border-color: #764ba2;
}

.wp-block-query-pagination .current {
    background: #764ba2;
    color: #ffffff;
    border-color: #764ba2;
}

/*
=======================================================================
   高コントラストモード対応
=======================================================================
*/
@media (prefers-contrast: high) {
    .archive-header.has-background-image::before {
        background: rgba(0, 0, 0, 0.8);
    }

    .archive-post-card {
        border: 2px solid #000000;
    }

    .post-card-title a,
    .read-more-link,
    .post-categories a {
        text-stroke: -webkit-text-stroke;
        -webkit-text-stroke: 1px rgba(0, 0, 0, 0.1);
    }
}

/*
=======================================================================
   reduced-motion対応
=======================================================================
*/
@media (prefers-reduced-motion: reduce) {
    .archive-post-card,
    .post-card-image img,
    .post-card-title a,
    .read-more-link,
    .post-categories a {
        transition: none;
    }

    .archive-post-card:hover {
        transform: none;
    }

    .archive-post-card:hover .post-card-image img {
        transform: none;
    }
}