/**
 * Shuffle Images Plugin Styles
 * フロントエンド用CSS
 */

/* メインコンテナ */
.shuffle-images-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    background: #f8f9fa;
    overflow: hidden;
}

/* グリッドコンテナ */
.shuffle-images-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr) !important;
    grid-template-rows: repeat(4, 1fr);
    /* aspect-ratio: 6 / 4; 動的に設定されるためコメントアウト */
    background: #7f8a9a;
    overflow: hidden;
}

/* グリッドアイテム */
.shuffle-images-item {
    position: relative;
    overflow: hidden;
    background: #e9ecef;
    aspect-ratio: 1 / 1; /* 正方形を維持 */
}

/* 画像 */
.shuffle-images-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* コントロールボタンエリア */
.shuffle-images-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: #ffffff;
    border-top: 1px solid #e9ecef;
}

/* ボタンスタイル */
.shuffle-images-button {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    background: #0073aa;
    color: #ffffff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.shuffle-images-button:hover {
    background: #005a87;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.3);
}

.shuffle-images-button:active {
    transform: translateY(0);
}

.shuffle-images-button:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 特定のボタンスタイル */
.shuffle-images-button.shuffle-button {
    background: #28a745;
}

.shuffle-images-button.shuffle-button:hover {
    background: #218838;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.shuffle-images-button.pause-button {
    background: #ffc107;
    color: #212529;
}

.shuffle-images-button.pause-button:hover {
    background: #e0a800;
    box-shadow: 0 2px 4px rgba(255, 193, 7, 0.3);
}

.shuffle-images-button.play-button {
    background: #17a2b8;
}

.shuffle-images-button.play-button:hover {
    background: #138496;
    box-shadow: 0 2px 4px rgba(23, 162, 184, 0.3);
}

/* プレースホルダー（画像がない場合） */
.shuffle-images-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 40px 20px;
    text-align: center;
    color: #6c757d;
    font-size: 16px;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    background: #f8f9fa;
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .shuffle-images-controls {
        padding: 12px;
        flex-wrap: wrap;
    }
    
    .shuffle-images-button {
        padding: 8px 16px;
        font-size: 13px;
    }
}

@media (max-width: 630px) {
    .shuffle-images-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        grid-template-rows: repeat(3, 1fr) !important;
        aspect-ratio: 4 / 3 !important;
    }
}

@media (max-width: 480px) {
    .shuffle-images-controls {
        padding: 10px;
    }
    
    .shuffle-images-button {
        padding: 6px 12px;
        font-size: 12px;
        flex: 1;
        min-width: 80px;
    }
}

/* アニメーション用のユーティリティクラス */
.shuffle-images-animating .shuffle-images-item {
    pointer-events: none;
}

.shuffle-images-item {
    transition: all 0.3s cubic-bezier(0.4, 0.0, 0.2, 1);
    transform: translateZ(0); /* ハードウェアアクセラレーション */
    backface-visibility: hidden; /* アニメーションのちらつき防止 */
}

.shuffle-images-item.moving {
    z-index: 100;
}

/* シャッフルアニメーション関連 */
.shuffle-images-item.shuffle-fade-out {
    animation: shuffleFade 4.0s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes shuffleFade {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}


.shuffle-images-item.shuffle-fade-in {
    animation: shuffleFade 4.0s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes shuffleFade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}


.shuffle-images-item.shuffle-moving {
    z-index: 200;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    transform: scale(1.02);
    overflow: hidden;
}

/* 滑らかな移動アニメーション */
.shuffle-images-container.smooth-shuffle .shuffle-images-item {
    transition: transform 1.2s cubic-bezier(0.23, 1, 0.32, 1), 
                opacity 0.6s ease-in-out,
                box-shadow 0.6s ease-in-out;
}

/* 回転効果 */
.shuffle-images-item.rotate-effect {
    animation: rotateIn 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes rotateIn {
    0% {
        transform: rotateY(-180deg) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: rotateY(-90deg) scale(0.9);
        opacity: 0.5;
    }
    100% {
        transform: rotateY(0deg) scale(1);
        opacity: 1;
    }
}

/* スライド効果 */
.shuffle-images-item.slide-effect {
    animation: slideIn 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

@keyframes slideIn {
    0% {
        transform: translateX(-100%) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: translateX(-20%) scale(0.9);
        opacity: 0.7;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* エディタ用のスタイル（管理画面） */
.shuffle-images-editor-container {
    border: 1px solid #e2e4e7;
    border-radius: 4px;
    overflow: hidden;
}

.shuffle-images-editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #f1f1f1;
    border-bottom: 1px solid #e2e4e7;
}

.shuffle-images-editor-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}

.shuffle-images-editor-actions {
    display: flex;
    gap: 10px;
}

/* プレビューグリッド（エディタ用） */
.shuffle-images-preview-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(4, 1fr);
    /* aspect-ratio: 6 / 4; 動的に設定されるためコメントアウト */
    background: #ffffff;
}

.shuffle-images-preview-item {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
    aspect-ratio: 1 / 1;
}

.shuffle-images-preview-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* 警告メッセージ */
.shuffle-images-warning {
    padding: 15px;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    margin: 10px;
}

.shuffle-images-warning p {
    margin: 0;
    color: #856404;
    font-size: 14px;
}

/* ローディング状態 */
.shuffle-images-loading {
    opacity: 0.7;
    pointer-events: none;
}

.shuffle-images-loading .shuffle-images-grid::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* アクセシビリティ対応 */
@media (prefers-reduced-motion: reduce) {
    .shuffle-images-button {
        transition: none;
    }
    
    .shuffle-images-button:hover {
        transform: none;
    }
}

/* オーバーレイ効果 */
.shuffle-images-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.55); /* 半透明の背景色 */
}