/**
 * Netflix風カルーセルの追加スタイル
 * パフォーマンス最適化とアニメーション
 */

/* カルーセルの基本スタイル強化 */
.netflix-carousel {
    position: relative;
    overflow: visible;
    margin: 0;
    padding: 0;
}

/* カルーセルラッパー（ボタンを含む全体） */
.carousel-wrapper {
    position: relative;
    padding: 0 70px; /* ボタン用のスペースを確保 */
}

.carousel-wrapper:hover .carousel-arrow,
.netflix-carousel:hover .carousel-arrow {
    opacity: 1;
    visibility: visible;
}

/* ナビゲーション矢印 */
.carousel-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(0, 150, 199, 0.8);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    opacity: 0.7;
    visibility: visible;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    color: white;
}

.carousel-arrow:hover {
    background: rgba(0, 150, 199, 1);
    border-color: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.4);
    opacity: 1;
}

.carousel-arrow:disabled {
    cursor: not-allowed;
    opacity: 0.3 !important;
}

.carousel-arrow-left {
    left: 30px;
}

.carousel-arrow-right {
    right: 30px;
}

.carousel-arrow svg {
    width: 24px;
    height: 24px;
    transition: transform 0.2s ease;
}

.carousel-arrow:hover svg {
    transform: scale(1.1);
}

/* スクロールインジケーター */
.scroll-indicator {
    position: absolute;
    bottom: -15px;
    left: 10px;
    right: 10px;
    height: 3px;
    background: rgba(142, 238, 231, 0.2);
    border-radius: 2px;
    overflow: hidden;
}

.scroll-progress {
    height: 100%;
    background: linear-gradient(90deg, #8eeee7, #48CAE4);
    border-radius: 2px;
    transition: width 0.3s ease;
    min-width: 20px;
}

/* カルーセル内部の最適化 */
.carousel-inner {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(142, 238, 231, 0.3) transparent;
}

.carousel-inner.scrolling {
    scroll-behavior: auto; /* スクロール中はスムースを無効化してパフォーマンス向上 */
}

.carousel-inner.dragging {
    scroll-behavior: auto;
    cursor: grabbing;
}

/* カードのホバーエフェクト強化 */
.card-content {
    will-change: transform;
    transform: translateZ(0); /* GPU加速 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-content:hover {
    transform: translateY(-8px) translateZ(0);
    box-shadow: 
        0 20px 60px rgba(0, 150, 199, 0.15),
        0 8px 25px rgba(0, 150, 199, 0.1);
}

/* 画像の最適化 */
.card-image img {
    will-change: transform;
    transform: translateZ(0);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-content:hover .card-image img {
    transform: scale(1.08) translateZ(0);
}

/* レイジーローディング対応 */
.card-image img:not(.loaded) {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.card-image img.loaded {
    opacity: 1;
}

/* プレースホルダー画像 */
.card-image::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #E3F2FD, #E0F7FA);
    background-image: url("data:image/svg+xml,%3Csvg width='40' height='40' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M21 19V5C21 3.9 20.1 3 19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 19 20.1 19 19ZM8.5 13.5L11 16.51L14.5 12L19 18H5L8.5 13.5Z' fill='%2348CAE4' fill-opacity='0.3'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    border-radius: 10px;
    opacity: 0;
    z-index: -1;
}

.card-image img:not(.loaded) + ::before {
    opacity: 1;
}

/* パフォーマンス最適化 */
.netflix-carousel * {
    box-sizing: border-box;
}

.carousel-item {
    contain: layout style;
}

/* アニメーション最適化 */
@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.carousel-item {
    animation: slideInFromLeft 0.5s ease-out;
    animation-fill-mode: both;
}

.carousel-item:nth-child(1) { animation-delay: 0.1s; }
.carousel-item:nth-child(2) { animation-delay: 0.2s; }
.carousel-item:nth-child(3) { animation-delay: 0.3s; }
.carousel-item:nth-child(4) { animation-delay: 0.4s; }
.carousel-item:nth-child(5) { animation-delay: 0.5s; }

/* フォーカス時のアクセシビリティ */
.carousel-arrow:focus,
.netflix-carousel:focus {
    outline: 2px solid #48CAE4;
    outline-offset: 2px;
}

.card-content:focus-within {
    outline: 2px solid #48CAE4;
    outline-offset: 2px;
    transform: translateY(-5px);
}

/* モバイル最適化 */
@media (max-width: 768px) {
    .carousel-wrapper {
        padding: 0; /* モバイルではボタンスペース不要 */
    }
    
    /* モバイルでは既存のcarousel-arrowを非表示 */
    .carousel-arrow {
        display: none !important;
    }
    
    .carousel-arrow-left {
        display: none !important;
    }
    
    .carousel-arrow-right {
        display: none !important;
    }
    
    .scroll-indicator {
        bottom: -10px;
    }
    
    .card-content:hover {
        transform: translateY(-3px);
    }
}

@media (max-width: 480px) {
    .carousel-wrapper {
        padding: 0; /* スマホではボタンスペース不要 */
    }
    
    /* スマホでは既存のcarousel-arrowを非表示 */
    .carousel-arrow {
        display: none !important;
    }
    
    /* カルーセルアイテムのサイズ固定 */
    .carousel-item {
        min-width: 280px !important;
        max-width: 300px !important;
        margin-right: 15px !important;
    }
    
    /* 日記番号バッジの修正 */
    .diary-number-badge-home {
        top: 5px !important;
        right: 5px !important;
        font-size: 0.75rem !important;
        padding: 3px 6px !important;
        min-width: 60px !important;
    }
    
    /* カード内のコンテンツ調整 */
    .card-title {
        font-size: 1rem !important;
    }
    
    .card-excerpt {
        font-size: 0.85rem !important;
    }
}

/* ハイコントラストモード対応 */
@media (prefers-contrast: high) {
    .carousel-arrow {
        background: white;
        border: 2px solid #0096C7;
        color: #0096C7;
    }
    
    .scroll-indicator {
        background: #333;
    }
    
    .scroll-progress {
        background: #0096C7;
    }
}

/* 動きを抑制する設定 */
@media (prefers-reduced-motion: reduce) {
    .carousel-inner {
        scroll-behavior: auto;
    }
    
    .card-content,
    .card-image img,
    .carousel-arrow,
    .carousel-arrow svg {
        transition: none;
    }
    
    .carousel-item {
        animation: none;
    }
}

/* ダークモード対応 */
@media (prefers-color-scheme: dark) {
    .carousel-arrow {
        background: rgba(0, 0, 0, 0.8);
        color: #B0E0E6;
        border: 1px solid rgba(176, 224, 230, 0.2);
    }
    
    .carousel-arrow:hover {
        background: rgba(0, 0, 0, 0.9);
        border-color: rgba(176, 224, 230, 0.4);
    }
    
    .scroll-indicator {
        background: rgba(176, 224, 230, 0.1);
    }
    
    .scroll-progress {
        background: linear-gradient(90deg, #B0E0E6, #E0FFFF);
    }
}

/* プリント時の最適化 */
@media print {
    .netflix-carousel {
        overflow: visible;
    }
    
    .carousel-inner {
        display: block;
    }
    
    .carousel-item {
        display: block;
        width: 100%;
        margin-bottom: 20px;
        page-break-inside: avoid;
    }
    
    .carousel-arrow,
    .scroll-indicator {
        display: none;
    }
}