/**
 * Amazon Corner Buddy Styles
 * ページ左下角のAmazonアイコンのアニメーション定義
 */

/* ベースアイコンスタイル */
#acb-corner-buddy {
    position: fixed !important;
    bottom: 20px !important;
    left: 20px !important;
    z-index: 9999 !important;
    display: block !important;
    text-decoration: none !important;
    border: none !important;
    outline: none !important;
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    /* サイズはJavaScriptで動的に設定されるため、!importantを削除 */
}

/* スワイプ隠し機能 */
#acb-corner-buddy.acb-swipe-hidden {
    transform: translateX(-100%) !important;
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1) !important;
}

#acb-corner-buddy.acb-swipe-transitioning {
    pointer-events: none !important;
}

/* ホバー効果 */
#acb-corner-buddy:hover {
    transform: scale(1.1) !important;
    opacity: 1 !important;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3)) !important;
}

#acb-corner-buddy:active {
    transform: scale(0.95) !important;
}

#acb-corner-buddy img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: contain !important;
    border: none !important;
    box-shadow: none !important;
    background: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border-radius: inherit !important;
}

/* アニメーション定義 */

/* 1. Shake - 軽い揺れ */
@keyframes acb-shake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-2px) rotate(-1deg); }
    20% { transform: translateX(2px) rotate(1deg); }
    30% { transform: translateX(-1px) rotate(-0.5deg); }
    40% { transform: translateX(1px) rotate(0.5deg); }
    50% { transform: translateX(-0.5px) rotate(-0.2deg); }
    60% { transform: translateX(0.5px) rotate(0.2deg); }
    70% { transform: translateX(-0.2px) rotate(-0.1deg); }
    80% { transform: translateX(0.2px) rotate(0.1deg); }
    90% { transform: translateX(0) rotate(0); }
}

/* 2. Bounce - 軽い跳ねる動き */
@keyframes acb-bounce {
    0%, 100% { transform: translateY(0); }
    25% { transform: translateY(-8px); }
    50% { transform: translateY(-4px); }
    75% { transform: translateY(-2px); }
}

/* 3. Wiggle - くねくね動き */
@keyframes acb-wiggle {
    0%, 100% { transform: rotate(0deg); }
    12.5% { transform: rotate(3deg) scale(1.02); }
    25% { transform: rotate(-3deg) scale(1.04); }
    37.5% { transform: rotate(2deg) scale(1.02); }
    50% { transform: rotate(-2deg) scale(1.01); }
    62.5% { transform: rotate(1deg) scale(1.02); }
    75% { transform: rotate(-1deg) scale(1.01); }
    87.5% { transform: rotate(0.5deg) scale(1.005); }
}

/* 4. Pulse - 拡大縮小 */
@keyframes acb-pulse {
    0%, 100% { transform: scale(1); opacity: 0.8; }
    50% { transform: scale(1.1); opacity: 1; }
}

/* 5. Rotate - 回転 */
@keyframes acb-rotate {
    0% { transform: rotate(0deg); }
    25% { transform: rotate(5deg) scale(1.05); }
    50% { transform: rotate(0deg) scale(1.1); }
    75% { transform: rotate(-5deg) scale(1.05); }
    100% { transform: rotate(0deg) scale(1); }
}

/* 6. Float - ふわふわ浮遊 */
@keyframes acb-float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    25% { transform: translateY(-6px) rotate(1deg); }
    50% { transform: translateY(-12px) rotate(0deg); }
    75% { transform: translateY(-6px) rotate(-1deg); }
}

/* アニメーションクラス */
.acb-animation-shake {
    animation: acb-shake 1.5s ease-in-out !important;
}

.acb-animation-bounce {
    animation: acb-bounce 1.2s ease-out !important;
}

.acb-animation-wiggle {
    animation: acb-wiggle 2s ease-in-out !important;
}

.acb-animation-pulse {
    animation: acb-pulse 1.8s ease-in-out !important;
}

.acb-animation-rotate {
    animation: acb-rotate 2.2s ease-in-out !important;
}

.acb-animation-float {
    animation: acb-float 2.5s ease-in-out !important;
}

/* モバイル対応 */
@media (max-width: 768px) {
    #acb-corner-buddy {
        /* ポジションのみCSS固定、サイズはJavaScriptで動的設定 */
        bottom: 15px !important;
        left: 15px !important;
    }
    
    /* モバイルではアニメーションを少し控えめに */
    .acb-animation-shake {
        animation-duration: 1s !important;
    }
    
    .acb-animation-bounce {
        animation-duration: 0.8s !important;
    }
    
    .acb-animation-wiggle {
        animation-duration: 1.5s !important;
    }
    
    .acb-animation-pulse {
        animation-duration: 1.2s !important;
    }
    
    .acb-animation-rotate {
        animation-duration: 1.5s !important;
    }
    
    .acb-animation-float {
        animation-duration: 2s !important;
    }
}

/* 超小さいスクリーン用 */
@media (max-width: 480px) {
    #acb-corner-buddy {
        /* ポジションのみCSS固定、サイズはJavaScriptで動的設定 */
        bottom: 10px !important;
        left: 10px !important;
    }
}

/* アクセシビリティ：アニメーション無効化設定に対応 */
@media (prefers-reduced-motion: reduce) {
    .acb-animation-shake,
    .acb-animation-bounce,
    .acb-animation-wiggle,
    .acb-animation-pulse,
    .acb-animation-rotate,
    .acb-animation-float {
        animation: none !important;
    }
    
    /* 代替として軽い点滅のみ */
    #acb-corner-buddy {
        animation: acb-subtle-blink 3s ease-in-out infinite !important;
    }
}

@keyframes acb-subtle-blink {
    0%, 90%, 100% { opacity: 0.8; }
    95% { opacity: 0.6; }
}

/* 吹き出しメッセージ関連スタイル */

/* 吹き出しコンテナ */
#acb-speech-bubble {
    position: absolute !important;
    top: -45px !important;
    left: 0px !important;
    background: linear-gradient(145deg, #ff9500, #ff7700) !important;
    color: white !important;
    padding: 8px 12px !important;
    border-radius: 12px !important;
    font-size: 12px !important;
    font-weight: 500 !important;
    white-space: normal !important;
    word-wrap: break-word !important;
    box-shadow: 0 4px 12px rgba(255, 149, 0, 0.3) !important;
    z-index: 10000 !important;
    opacity: 0 !important;
    transform: scale(0.8) translateY(10px) !important;
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) !important;
    pointer-events: none !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    letter-spacing: 0.3px !important;
    line-height: 1.3 !important;
    max-width: 200px !important;
    min-width: 120px !important;
}

/* 吹き出しの矢印 */
#acb-speech-bubble::after {
    content: '' !important;
    position: absolute !important;
    bottom: -6px !important;
    left: 15px !important;
    width: 0 !important;
    height: 0 !important;
    border-left: 6px solid transparent !important;
    border-right: 6px solid transparent !important;
    border-top: 6px solid #ff7700 !important;
}

/* 表示アニメーション */
#acb-speech-bubble.acb-show {
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
}

/* フェードアウトアニメーション */
#acb-speech-bubble.acb-fade-out {
    opacity: 0 !important;
    transform: scale(0.9) translateY(-10px) !important;
    transition: all 1.5s ease-out !important;
}

/* 第2段階表示スタイル */
#acb-speech-bubble.acb-second-phase {
    background: linear-gradient(145deg, #007cba, #005a87) !important;
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.3) !important;
}

#acb-speech-bubble.acb-second-phase::after {
    border-top-color: #005a87 !important;
}

/* 小さなパルス効果 */
@keyframes acb-bubble-pulse {
    0%, 100% { transform: scale(1) translateY(0); }
    50% { transform: scale(1.03) translateY(-1px); }
}

#acb-speech-bubble.acb-pulse {
    animation: acb-bubble-pulse 2s ease-in-out infinite !important;
}

/* テキスト切り替え用フェードアニメーション */
#acb-speech-bubble.acb-text-fade-out {
    opacity: 0 !important;
    transform: scale(0.95) translateY(0) !important;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out !important;
}

#acb-speech-bubble.acb-text-fade-in {
    opacity: 1 !important;
    transform: scale(1) translateY(0) !important;
    transition: opacity 0.15s ease-in, transform 0.15s ease-in !important;
}

/* モバイル対応 */
@media (max-width: 768px) {
    #acb-speech-bubble {
        font-size: 11px !important;
        padding: 6px 10px !important;
        top: -40px !important;
        left: 0px !important;
        max-width: 180px !important;
        min-width: 100px !important;
        border-radius: 10px !important;
        line-height: 1.2 !important;
    }
    
    #acb-speech-bubble::after {
        left: 12px !important;
        border-left-width: 5px !important;
        border-right-width: 5px !important;
        border-top-width: 5px !important;
        bottom: -5px !important;
    }
}

/* 超小さいスクリーン用 */
@media (max-width: 480px) {
    #acb-speech-bubble {
        font-size: 10px !important;
        padding: 5px 8px !important;
        top: -35px !important;
        left: 0px !important;
        max-width: calc(100vw - 55px) !important;
        min-width: 80px !important;
        line-height: 1.2 !important;
    }
}

/* スワイプインジケーター（矢印マーク） */
#acb-swipe-indicator {
    position: fixed !important;
    left: 2px !important;
    bottom: 65px !important; /* バナー中心高さ（PC: 90px/2 + 20px = 65px） */
    width: 40px !important;
    height: 40px !important;
    background: transparent !important;
    opacity: 0 !important;
    transform: scale(0.8) !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    z-index: 10000 !important;
    display: none !important;
}

/* 二重矢印（≫）アイコン */
#acb-swipe-indicator::after {
    content: '≫' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 24px !important;
    font-weight: bold !important;
    color: #ff9500 !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3) !important;
    font-family: Arial, sans-serif !important;
    line-height: 1 !important;
}

/* インジケーター表示状態 */
#acb-swipe-indicator.acb-show {
    opacity: 0.9 !important;
    transform: scale(1) !important;
    display: block !important;
}

/* インジケーターホバー効果 */
#acb-swipe-indicator:hover {
    transform: scale(1.15) !important;
    opacity: 1 !important;
}

#acb-swipe-indicator:hover::after {
    color: #ff7700 !important;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4) !important;
    transform: translate(-50%, -50%) scale(1.05) !important;
}

/* PC版用キーボードフォーカス */
#acb-swipe-indicator:focus {
    outline: 2px solid #ff9500 !important;
    outline-offset: 2px !important;
    transform: scale(1.1) !important;
    opacity: 1 !important;
}

#acb-swipe-indicator:focus::after {
    color: #ff7700 !important;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4) !important;
}

/* インジケータータップ効果 */
#acb-swipe-indicator:active {
    transform: scale(0.9) !important;
}

#acb-swipe-indicator:active::after {
    color: #ff6600 !important;
    transform: translate(-50%, -50%) scale(0.95) !important;
}

/* インジケーター スライドアニメーション */
@keyframes acb-indicator-slide {
    0%, 100% { 
        transform: translateX(0px) scale(0.8);
        opacity: 0.8;
    }
    25% { 
        transform: translateX(6px) scale(0.85);
        opacity: 0.9;
    }
    50% { 
        transform: translateX(10px) scale(0.9);
        opacity: 1;
    }
    75% { 
        transform: translateX(6px) scale(0.85);
        opacity: 0.9;
    }
}

#acb-swipe-indicator.acb-pulse {
    animation: acb-indicator-slide 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
}

/* モバイル対応のインジケーター */
@media (max-width: 768px) {
    #acb-swipe-indicator {
        bottom: 45px !important; /* モバイル: 60px/2 + 15px = 45px */
        width: 32px !important;
        height: 32px !important;
    }
    
    #acb-swipe-indicator::after {
        font-size: 20px !important;
    }
}

/* 超小型端末対応のインジケーター */
@media (max-width: 480px) {
    #acb-swipe-indicator {
        bottom: 32px !important; /* 超小型: 45px/2 + 10px = 32px */
        width: 28px !important;
        height: 28px !important;
    }
    
    #acb-swipe-indicator::after {
        font-size: 18px !important;
    }
}

/* 隠すためのインジケーター（左矢印マーク） - バナー表示時用 */
#acb-hide-indicator {
    position: fixed !important;
    left: 5px !important; /* バナーの左側に配置（画面内） */
    bottom: 65px !important; /* バナー中心高さ（PC: 90px/2 + 20px = 65px） */
    width: 40px !important;
    height: 40px !important;
    background: transparent !important;
    opacity: 0 !important;
    transform: scale(0.8) !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    z-index: 10000 !important;
    display: none !important;
}

/* 二重矢印（≪）アイコン */
#acb-hide-indicator::after {
    content: '≪' !important;
    position: absolute !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    font-size: 24px !important;
    font-weight: bold !important;
    color: #ff9500 !important;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3) !important;
    font-family: Arial, sans-serif !important;
    line-height: 1 !important;
}

/* 隠すインジケーター表示状態 */
#acb-hide-indicator.acb-show {
    opacity: 0.9 !important;
    transform: scale(1) !important;
    display: block !important;
}

/* 隠すインジケーターホバー効果 */
#acb-hide-indicator:hover {
    transform: scale(1.15) !important;
    opacity: 1 !important;
}

#acb-hide-indicator:hover::after {
    color: #ff7700 !important;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4) !important;
    transform: translate(-50%, -50%) scale(1.05) !important;
}

/* PC版用キーボードフォーカス */
#acb-hide-indicator:focus {
    outline: 2px solid #ff9500 !important;
    outline-offset: 2px !important;
    transform: scale(1.1) !important;
    opacity: 1 !important;
}

#acb-hide-indicator:focus::after {
    color: #ff7700 !important;
    text-shadow: 3px 3px 6px rgba(0, 0, 0, 0.4) !important;
}

/* 隠すインジケータータップ効果 */
#acb-hide-indicator:active {
    transform: scale(0.9) !important;
}

#acb-hide-indicator:active::after {
    color: #ff6600 !important;
    transform: translate(-50%, -50%) scale(0.95) !important;
}

/* 隠すインジケーター スライドアニメーション */
@keyframes acb-hide-indicator-slide {
    0%, 100% { 
        transform: translateX(0px) scale(0.8);
        opacity: 0.8;
    }
    25% { 
        transform: translateX(-6px) scale(0.85);
        opacity: 0.9;
    }
    50% { 
        transform: translateX(-10px) scale(0.9);
        opacity: 1;
    }
    75% { 
        transform: translateX(-6px) scale(0.85);
        opacity: 0.9;
    }
}

#acb-hide-indicator.acb-pulse {
    animation: acb-hide-indicator-slide 2.5s cubic-bezier(0.4, 0, 0.6, 1) infinite !important;
}

/* モバイル対応の隠すインジケーター */
@media (max-width: 768px) {
    #acb-hide-indicator {
        left: 2px !important; /* モバイル: バナーの左側（画面内） */
        bottom: 45px !important; /* モバイル: 60px/2 + 15px = 45px */
        width: 32px !important;
        height: 32px !important;
    }
    
    #acb-hide-indicator::after {
        font-size: 20px !important;
    }
}

/* 超小型端末対応の隠すインジケーター */
@media (max-width: 480px) {
    #acb-hide-indicator {
        left: 0px !important; /* 超小型: 画面左端ギリギリ */
        bottom: 32px !important; /* 超小型: 45px/2 + 10px = 32px */
        width: 28px !important;
        height: 28px !important;
    }
    
    #acb-hide-indicator::after {
        font-size: 18px !important;
    }
}

/* アクセシビリティ：アニメーション無効化設定に対応 */
@media (prefers-reduced-motion: reduce) {
    #acb-corner-buddy.acb-swipe-hidden {
        transition: transform 0.2s ease !important;
    }
    
    #acb-swipe-indicator, #acb-hide-indicator {
        transition: opacity 0.2s ease !important;
        transform: none !important;
    }
    
    #acb-swipe-indicator.acb-show, #acb-hide-indicator.acb-show {
        transform: none !important;
    }
    
    #acb-swipe-indicator:hover, #acb-hide-indicator:hover {
        transform: none !important;
    }
    
    #acb-swipe-indicator:hover::after, #acb-hide-indicator:hover::after {
        transform: translate(-50%, -50%) !important;
    }
    
    #acb-swipe-indicator:active::after, #acb-hide-indicator:active::after {
        transform: translate(-50%, -50%) !important;
    }
    
    .acb-pulse {
        animation: none !important;
    }
    
    #acb-speech-bubble {
        transition: opacity 0.3s ease !important;
        transform: none !important;
    }
    
    #acb-speech-bubble.acb-show {
        transform: none !important;
    }
    
    #acb-speech-bubble.acb-fade-out {
        transform: none !important;
    }
}