/**
 * Popular Posts Block Styles
 * 
 * @package Forgeee
 * @since 1.0.0
 */

/* ========================================
   基本スタイル
   ======================================== */
.fg-popular-posts {
    margin: 2rem 0;
}

.fg-popular-posts__title {
    margin: 0 0 1.5rem 0;
    font-size: 1.5rem;
    font-weight: 700;
    color: #333;
}

.fg-popular-posts__placeholder {
    padding: 2rem;
    text-align: center;
    background: #f5f5f5;
    border: 2px dashed #ddd;
    border-radius: 4px;
    color: #666;
}

.fg-popular-posts__placeholder p {
    margin: 0.5rem 0;
}

/* ========================================
   リスト形式
   ======================================== */
.fg-popular-posts__list--list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* リスト形式：列数設定 */
.fg-popular-posts__list--list.fg-popular-posts__list--columns-1 {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.fg-popular-posts__list--list.fg-popular-posts__list--columns-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.fg-popular-posts__item {
    border-bottom: 1px solid #eee;
    padding-bottom: 1.5rem;
}

.fg-popular-posts__item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.fg-popular-posts__link {
    display: flex;
    gap: 1.5rem;
    text-decoration: none;
    color: inherit;
    transition: opacity 0.3s ease;
    position: relative;
}

.fg-popular-posts__link:hover {
    opacity: 0.8;
}

.fg-popular-posts__link-icon {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    font-size: 1.5rem;
    color: #333;
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.fg-popular-posts__link:hover .fg-popular-posts__link-icon {
    background: transparent;
    transform: scale(1.1);
}

.fg-popular-posts__thumbnail {
    flex-shrink: 0;
    width: 200px;
    overflow: hidden;
    border-radius: 4px;
    position: relative;
}

.fg-popular-posts__thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

/* 縦横比の設定 */
.fg-popular-posts__thumbnail--16-9 {
    aspect-ratio: 16 / 9;
    height: auto;
}

.fg-popular-posts__thumbnail--4-3 {
    aspect-ratio: 4 / 3;
    height: auto;
}

.fg-popular-posts__thumbnail--1-1 {
    aspect-ratio: 1 / 1;
    height: auto;
}

.fg-popular-posts__thumbnail--3-4 {
    aspect-ratio: 3 / 4;
    height: auto;
}

.fg-popular-posts__thumbnail--auto {
    aspect-ratio: auto;
    height: auto;
}

.fg-popular-posts__content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.fg-popular-posts__item-title {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
    line-height: 1.4;
}

.fg-popular-posts__meta {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #666;
    flex-wrap: wrap;
}

.fg-popular-posts__date,
.fg-popular-posts__views {
    display: inline-flex;
    align-items: center;
}

.fg-popular-posts__category {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--category-color, #333333);
    border-radius: 12px;
    color: var(--category-color, #333333);
    background: transparent;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

.fg-popular-posts__views::before {
    content: '・';
    margin: 0 0.5rem;
}

.fg-popular-posts__excerpt {
    font-size: 0.9375rem;
    color: #666;
    line-height: 1.6;
    margin-top: 0.5rem;
}

/* ========================================
   関連記事風スライダー形式
   ======================================== */

.fg-popular-posts__related-slider {
    position: relative;
    overflow: hidden;
    padding-bottom: 40px;
}

.fg-popular-posts__related-slider .swiper-wrapper {
    display: flex;
}

.fg-popular-posts__related-slider .swiper-slide {
    height: auto;
}

.fg-popular-posts__related-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.fg-popular-posts__related-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

/* サムネイル */
.fg-popular-posts__related-thumbnail {
    position: relative;
    width: 100%;
    overflow: hidden;
    background: #f0f0f0;
}

/* 縦横比の設定 */
.fg-popular-posts__related-thumbnail--16-9 {
    aspect-ratio: 16 / 9;
    height: auto;
}

.fg-popular-posts__related-thumbnail--4-3 {
    aspect-ratio: 4 / 3;
    height: auto;
}

.fg-popular-posts__related-thumbnail--1-1 {
    aspect-ratio: 1 / 1;
    height: auto;
}

.fg-popular-posts__related-thumbnail--3-4 {
    aspect-ratio: 3 / 4;
    height: auto;
}

.fg-popular-posts__related-thumbnail--auto {
    aspect-ratio: auto;
    height: auto;
}

.fg-popular-posts__related-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.fg-popular-posts__related-item:hover .fg-popular-posts__related-thumbnail img {
    transform: scale(1.05);
}

/* オーバーレイ */
.fg-popular-posts__related-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0) 100%);
    padding: 20px;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    pointer-events: none;
    z-index: 2;
}

.fg-popular-posts__related-thumbnail {
    position: relative;
}

.fg-popular-posts__related-thumbnail .fg-popular-posts__related-link {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    display: block;
    text-decoration: none;
}

.fg-popular-posts__related-thumbnail .fg-popular-posts__related-category {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 10;
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border: 1px solid var(--category-color, #fff);
    border-radius: 12px;
    color: var(--category-color, #fff);
    background: rgba(255, 255, 255, 0.2);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.fg-popular-posts__related-overlay .fg-popular-posts__related-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* コンテンツ（画像がない場合） */
.fg-popular-posts__related-content {
    padding: 20px;
}

.fg-popular-posts__related-content .fg-popular-posts__related-title {
    margin: 0 0 10px 0;
    font-size: 1.1rem;
    font-weight: 600;
    line-height: 1.4;
}

.fg-popular-posts__related-content .fg-popular-posts__related-title a {
    color: var(--fg-text-color, #333);
    text-decoration: none;
    transition: color 0.3s ease;
}

.fg-popular-posts__related-content .fg-popular-posts__related-title a:hover {
    color: var(--fg-primary-color, #0073aa);
}

/* スライダーナビゲーション */
.fg-popular-posts__related-slider .swiper-button-next,
.fg-popular-posts__related-slider .swiper-button-prev {
    color: #fff;
    background: rgba(0, 0, 0, 0.7);
    width: 40px;
    height: 40px;
    margin-top: -20px;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.fg-popular-posts__related-slider .swiper-button-next:hover,
.fg-popular-posts__related-slider .swiper-button-prev:hover {
    background: rgba(0, 0, 0, 0.9);
}

.fg-popular-posts__related-slider .swiper-button-next:after,
.fg-popular-posts__related-slider .swiper-button-prev:after {
    font-size: 20px;
}

.fg-popular-posts__related-slider .swiper-pagination {
    position: relative;
    margin-top: 20px;
}

.fg-popular-posts__related-slider .swiper-pagination-bullet {
    background: var(--fg-primary-color, #0073aa);
}

/* ========================================
   レスポンシブ対応（関連記事風スライダー）
   ======================================== */

@media (max-width: 768px) {
    .fg-popular-posts__related-overlay {
        padding: 15px;
        gap: 6px;
    }
    
    .fg-popular-posts__related-thumbnail .fg-popular-posts__related-category {
        top: 10px;
        right: 10px;
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }
    
    .fg-popular-posts__related-overlay .fg-popular-posts__related-title {
        font-size: 1rem;
    }
    
    .fg-popular-posts__related-content {
        padding: 15px;
    }
}

/* ========================================
   グリッド形式
   ======================================== */
.fg-popular-posts__list--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

/* グリッド形式：列数設定 */
.fg-popular-posts__list--grid.fg-popular-posts__list--grid-columns-2 {
    grid-template-columns: repeat(2, 1fr);
}

.fg-popular-posts__list--grid.fg-popular-posts__list--grid-columns-3 {
    grid-template-columns: repeat(3, 1fr);
}

.fg-popular-posts__list--grid.fg-popular-posts__list--grid-columns-4 {
    grid-template-columns: repeat(4, 1fr);
}

.fg-popular-posts--grid .fg-popular-posts__item {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.fg-popular-posts--grid .fg-popular-posts__item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.fg-popular-posts--grid .fg-popular-posts__link {
    flex-direction: column;
    gap: 0;
    position: relative;
}

.fg-popular-posts--grid .fg-popular-posts__thumbnail {
    width: 100%;
    height: auto;
}

.fg-popular-posts--grid .fg-popular-posts__content {
    padding: 1rem;
}

.fg-popular-posts--grid .fg-popular-posts__item-title {
    font-size: 1.125rem;
}

/* ========================================
   グリッドスライダー形式
   ======================================== */
.fg-popular-posts__slider-wrapper {
    position: relative;
    margin: 2rem 0;
    width: 100%;
    box-sizing: border-box;
}

.fg-popular-posts__slider {
    position: relative;
    overflow: hidden;
    width: 100%;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}

.fg-popular-posts__slider-track {
    display: flex;
    transition: transform 0.3s ease;
    gap: 1.5rem;
    width: 100%;
    box-sizing: border-box;
    touch-action: pan-x;
    -webkit-overflow-scrolling: touch;
}

.fg-popular-posts__slider .fg-popular-posts__item {
    flex-shrink: 0;
    min-width: 0;
    border: none;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.fg-popular-posts__slider .fg-popular-posts__item:hover .fg-popular-posts__thumbnail img {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.fg-popular-posts__slider .fg-popular-posts__link {
    flex-direction: column;
    gap: 0;
    position: relative;
    touch-action: pan-x;
}

.fg-popular-posts__slider .fg-popular-posts__thumbnail {
    width: 100%;
    height: auto;
    overflow: hidden;
}

.fg-popular-posts__slider .fg-popular-posts__content {
    padding: 1rem;
}

.fg-popular-posts__slider .fg-popular-posts__item-title {
    font-size: 1.125rem;
}

.fg-popular-posts__slider-prev,
.fg-popular-posts__slider-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fg-popular-posts__slider-prev:hover,
.fg-popular-posts__slider-next:hover {
    background: #fff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.fg-popular-posts__slider-prev {
    left: -24px;
}

.fg-popular-posts__slider-next {
    right: -24px;
}

.fg-popular-posts__slider-prev .material-symbols-outlined,
.fg-popular-posts__slider-next .material-symbols-outlined {
    font-size: 24px;
    width: 24px;
    height: 24px;
    color: #333;
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.fg-popular-posts__slider-prev:disabled,
.fg-popular-posts__slider-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 1024px) {
    .fg-popular-posts__slider-wrapper[data-items-per-view="3"] .fg-popular-posts__item,
    .fg-popular-posts__slider-wrapper[data-items-per-view="4"] .fg-popular-posts__item {
        flex: 0 0 calc((100% - 1.5rem) / 2) !important;
        width: calc((100% - 1.5rem) / 2) !important;
    }
    
    .fg-popular-posts__slider-prev {
        left: 10px;
    }
    
    .fg-popular-posts__slider-next {
        right: 10px;
    }
}

/* スライダーアイテム数に応じた幅調整 */
/* gap: 1.5rem = 24px, gap数 = itemsPerView - 1 */
.fg-popular-posts__slider-wrapper[data-items-per-view="1"] .fg-popular-posts__item {
    flex: 0 0 calc(100% - 0px);
    width: calc(100% - 0px);
}

.fg-popular-posts__slider-wrapper[data-items-per-view="2"] .fg-popular-posts__item {
    flex: 0 0 calc((100% - 1.5rem) / 2);
    width: calc((100% - 1.5rem) / 2);
    max-width: calc((100% - 1.5rem) / 2);
    box-sizing: border-box;
}

.fg-popular-posts__slider-wrapper[data-items-per-view="3"] .fg-popular-posts__item {
    flex: 0 0 calc((100% - 3rem) / 3);
    width: calc((100% - 3rem) / 3);
    max-width: calc((100% - 3rem) / 3);
    box-sizing: border-box;
}

.fg-popular-posts__slider-wrapper[data-items-per-view="4"] .fg-popular-posts__item {
    flex: 0 0 calc((100% - 4.5rem) / 4);
    width: calc((100% - 4.5rem) / 4);
    max-width: calc((100% - 4.5rem) / 4);
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .fg-popular-posts__list--list.fg-popular-posts__list--columns-2 {
        grid-template-columns: 1fr;
    }
    
    .fg-popular-posts__list--list .fg-popular-posts__link {
        flex-direction: column;
    }
    
    .fg-popular-posts__list--list .fg-popular-posts__thumbnail {
        width: 100%;
        height: 200px;
    }
    
    .fg-popular-posts__list--grid.fg-popular-posts__list--grid-columns-2,
    .fg-popular-posts__list--grid.fg-popular-posts__list--grid-columns-3,
    .fg-popular-posts__list--grid.fg-popular-posts__list--grid-columns-4 {
        grid-template-columns: 1fr;
    }
    
    .fg-popular-posts__slider-wrapper[data-items-per-view="1"] .fg-popular-posts__item,
    .fg-popular-posts__slider-wrapper[data-items-per-view="2"] .fg-popular-posts__item,
    .fg-popular-posts__slider-wrapper[data-items-per-view="3"] .fg-popular-posts__item,
    .fg-popular-posts__slider-wrapper[data-items-per-view="4"] .fg-popular-posts__item {
        flex: 0 0 100% !important;
        width: 100% !important;
    }
    
    .fg-popular-posts__slider-prev {
        left: 5px;
    }
    
    .fg-popular-posts__slider-next {
        right: 5px;
    }
}

