/* カルーセル専用CSS（Text Ad Manager連携版） */
.at-carousel-container {
    position: relative;
    width: 100%;
    max-width: none;
    margin: 20px 0;
    border: 2px solid #ddd;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    outline: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    box-sizing: border-box;
}

.at-carousel-container:focus {
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2), 0 0 0 2px #007cba;
}

/* PRバッジ - Text Ad Managerから動的に色を取得 */
.at-carousel-pr-text {
    position: absolute;
    top: 10px;
    left: 15px;
    background-color: rgba(255, 0, 0, 0.8); /* デフォルト色(インラインスタイルで上書き) */
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    z-index: 10;
    pointer-events: none;
}

.at-carousel-pr-badge {
    position: absolute;
    top: 10px;
    left: 15px;
    background-color: rgba(255, 0, 0, 0.8); /* デフォルト色 */
    color: white;
    padding: 4px 8px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 3px;
    z-index: 10;
}

/* カスタムHTMLテキスト */
.at-carousel-custom-text {
    position: absolute;
    top: 10px;
    left: 65px; /* PRバッジの右側 */
    background-color: #fff;
    color: #333;
    font-size: 12px;
    font-weight: normal;
    padding: 4px 8px;
    border-radius: 3px;
    z-index: 10;
    max-width: calc(100% - 75px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.at-carousel-custom-text a {
    color: #0066c0;
    text-decoration: none;
}

.at-carousel-custom-text a:hover {
    color: #c45500;
    text-decoration: underline;
}

.at-carousel-wrapper {
    position: relative;
    overflow: hidden;
    background: white;
    width: 100%;
    touch-action: pan-y;
    box-sizing: border-box;
}

.at-carousel-track {
    display: flex;
    transition: transform 0.5s ease;
    will-change: transform;
    width: 100%;
}

.at-carousel-slide {
    min-width: 100%;
    width: 100%;
    display: flex;
    align-items: stretch;
    flex-shrink: 0;
    box-sizing: border-box;
}

.at-carousel-product-item {
    display: flex;
    width: 100%;
    padding: 20px;
    align-items: flex-start;
    box-sizing: border-box;
}

.at-carousel-product-image {
    width: 200px;
    min-width: 200px;
    flex-shrink: 0;
    margin-right: 20px;
}

.at-carousel-product-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    border-radius: 5px;
    pointer-events: none;
    display: block;
}

.at-carousel-product-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
    box-sizing: border-box;
}

.at-carousel-product-name {
    margin: 0 0 10px 0;
    font-size: 16px;
    line-height: 1.4;
    word-wrap: break-word;
}

.at-carousel-product-name a {
    color: #333;
    text-decoration: none;
    font-weight: bold;
}

.at-carousel-product-name a:hover {
    color: #007cba;
    text-decoration: underline;
}

.at-carousel-shop-name {
    color: #777;
    font-size: 14px;
    margin: 5px 0;
    word-wrap: break-word;
}

.at-carousel-product-explanation {
    color: #555;
    font-size: 14px;
    line-height: 1.5;
    margin: 10px 0;
    flex-grow: 1;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.at-carousel-product-button {
    margin-top: 15px;
    flex-shrink: 0;
}

.at-carousel-detail-btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #007cba;
    color: white !important;
    text-decoration: none !important;
    border-radius: 5px;
    font-weight: bold;
    transition: background-color 0.3s ease;
    white-space: nowrap;
}

.at-carousel-detail-btn:hover {
    background-color: #005a87;
}

.at-carousel-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 5;
    padding: 0 10px;
    box-sizing: border-box;
}

.at-carousel-btn {
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    pointer-events: all;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    flex-shrink: 0;
}

.at-carousel-btn:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

.at-carousel-btn:active {
    transform: scale(0.95);
}

.at-carousel-prev {
    margin-left: 0;
}

.at-carousel-next {
    margin-right: 0;
}

.at-carousel-dots {
    display: flex;
    justify-content: center;
    padding: 15px;
    background: #f9f9f9;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.at-carousel-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.at-carousel-dot:hover {
    background: #999;
    transform: scale(1.2);
}

.at-carousel-dot.active {
    background: #007cba;
    border-color: #005a87;
    transform: scale(1.3);
}

/* アニメーション効果 */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.at-carousel-slide.active .at-carousel-product-details > * {
    animation: slideIn 0.6s ease forwards;
}

/* スマートフォン対応 */
@media screen and (max-width: 767px) {
    .at-carousel-container {
        width: 100%;
        margin: 15px 0;
        touch-action: pan-y;
    }
    
    .at-carousel-wrapper {
        margin-top: 70px; /* スマホでは縦並びなので高さを増やす */
    }
    
    .at-carousel-nav {
        margin-top: 35px; /* wrapperのmargin-topの半分 */
    }
    
    .at-carousel-pr-badge,
    .at-carousel-pr-text {
        top: 8px;
        left: 10px;
        font-size: 11px;
        padding: 3px 6px;
    }
    
    .at-carousel-custom-text {
        top: 35px; /* PRバッジの下に配置 */
        left: 10px;
        right: 10px;
        font-size: 10px;
        padding: 3px 6px;
    }
    
    .at-carousel-product-item {
        flex-direction: column;
        padding: 15px;
        align-items: center;
    }
    
    .at-carousel-product-image {
        width: 100%;
        max-width: 250px;
        margin-right: 0;
        margin-bottom: 15px;
        align-self: center;
    }
    
    .at-carousel-product-details {
        width: 100%;
        text-align: left;
    }
    
    .at-carousel-detail-btn {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }
    
    .at-carousel-btn {
        width: 35px;
        height: 35px;
        font-size: 18px;
    }
    
    .at-carousel-nav {
        padding: 0 5px;
    }
    
    .at-carousel-dots {
        padding: 10px;
        gap: 6px;
    }
    
    .at-carousel-dot {
        width: 10px;
        height: 10px;
    }
}

/* 小さいスマホサイズ対応 */
@media screen and (max-width: 480px) {
    .at-carousel-wrapper {
        margin-top: 65px;
    }
    
    .at-carousel-nav {
        margin-top: 32.5px;
    }
    
    .at-carousel-pr-badge,
    .at-carousel-pr-text {
        top: 6px;
        left: 8px;
        font-size: 10px;
        padding: 2px 5px;
    }
    
    .at-carousel-custom-text {
        top: 30px;
        left: 8px;
        right: 8px;
        font-size: 9px;
        padding: 2px 5px;
    }
}

/* タブレット対応 */
@media screen and (min-width: 768px) and (max-width: 1024px) {
    .at-carousel-container {
        width: 100%;
    }
    
    .at-carousel-wrapper {
        margin-top: 42px;
    }
    
    .at-carousel-nav {
        margin-top: 21px;
    }
    
    .at-carousel-pr-badge,
    .at-carousel-pr-text {
        top: 10px;
        left: 12px;
        font-size: 11px;
        padding: 3px 7px;
    }
    
    .at-carousel-custom-text {
        left: 60px;
        right: 12px;
        font-size: 11px;
        padding: 3px 7px;
    }
    
    .at-carousel-product-image {
        width: 180px;
        min-width: 180px;
    }
    
    .at-carousel-product-item {
        padding: 18px;
    }
}

/* 大画面対応 */
@media screen and (min-width: 1025px) {
    .at-carousel-container {
        width: 100%;
    }
    
    .at-carousel-wrapper {
        margin-top: 50px; /* 大画面でも十分なスペース */
    }
    
    .at-carousel-nav {
        margin-top: 25px;
    }
    
    .at-carousel-product-image {
        width: 220px;
        min-width: 220px;
    }
    
    .at-carousel-product-item {
        padding: 25px;
    }
}

/* 高解像度ディスプレイ対応 */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .at-carousel-btn {
        border: 1px solid rgba(255, 255, 255, 0.3);
    }
}

/* WordPressテーマとの互換性向上 */
.at-carousel-container * {
    box-sizing: border-box;
}

/* フルワイド対応 */
.alignfull .at-carousel-container,
.wp-block-group.alignfull .at-carousel-container {
    width: 100%;
    max-width: none;
}