/**
 * Recommend List Plugin - Frontend Styles
 */

.recommend-list-wrapper {
    margin: 15px auto;
    padding: 12px;
    border-radius: 8px;
    background-color: #e8f4f8;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    width: 85%;
    max-width: 550px;
    position: relative;
    overflow: hidden;
}

.recommend-list-title {
    text-align: center;
    margin-bottom: 15px;
    opacity: 0;
    animation: slideInFromLeft 0.8s ease-out forwards;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recommend-title-text {
    margin: 0;
    font-size: 28px;
    font-weight: 700;
    color: #333;
    line-height: 1.2;
    word-break: break-word;
}

.recommend-list-container {
    width: 100%;
}

.recommend-list-item {
    margin-bottom: 20px;
}

.recommend-list-item:last-child {
    margin-bottom: 0;
}

.recommend-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    width: 100%;
    margin: 0 auto;
}

.recommend-grid-item {
    background: #fff;
    border-radius: 6px;
    padding: 6px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    border: 1px solid rgba(0, 0, 0, 0.05);
    width: 100%;
    min-height: 65px;
    transform: translateY(0) scale(1);
}

.recommend-grid-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
    border-color: rgba(0, 0, 0, 0.1);
}

/* リンクがあるアイテムのスタイル */
.recommend-grid a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.recommend-grid-item.has-link {
    cursor: pointer;
}

.recommend-grid-item.has-link:hover {
    transform: translateY(-10px) scale(1.03);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.2);
    border-color: rgba(0, 0, 0, 0.15);
}

.recommend-card-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.recommend-card-header {
    display: flex;
    align-items: center;
    margin-bottom: 4px;
    gap: 4px;
}

.recommend-arrow {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.recommend-arrow img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* SVGファイルの表示を最適化 */
.recommend-arrow img[src*=".svg"] {
    width: 24px;
    height: 24px;
    object-fit: contain;
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* 遅延読み込みを無効にする */
.recommend-arrow img[data-src] {
    content: attr(data-src);
}

.recommend-arrow img.lazyload {
    opacity: 1 !important;
    visibility: visible !important;
}

.recommend-logo {
    width: 160px;
    height: 55px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.recommend-logo img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
}

.recommend-description {
    color: #666;
    font-size: 12px;
    line-height: 1.3;
    flex: 1;
    margin-top: 4px;
}

.recommend-description p {
    margin: 0;
    word-break: break-word;
    white-space: pre-line;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .recommend-list-wrapper {
        margin: 12px auto;
        padding: 10px;
        width: 92%;
        max-width: 480px;
    }

    .recommend-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .recommend-title-text {
        font-size: 24px;
        margin-bottom: 8px;
    }

    .recommend-list-title {
        margin-bottom: 12px;
    }

    .recommend-grid-item {
        padding: 6px;
        min-height: 60px;
    }

    .recommend-grid-item:hover {
        transform: translateY(-3px) scale(1.01);
        box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
    }

    .recommend-grid-item.has-link:hover {
        transform: translateY(-4px) scale(1.015);
        box-shadow: 0 8px 22px rgba(0, 0, 0, 0.15);
    }

    .recommend-card-header {
        gap: 3px;
    }

    .recommend-logo {
        width: 140px;
        height: 50px;
    }

    .recommend-arrow svg {
        width: 30px;
        height: 30px;
    }

    .recommend-description {
        margin-top: 3px;
    }
}

@media (max-width: 480px) {
    .recommend-list-wrapper {
        margin: 8px auto;
        padding: 6px;
        width: 96%;
        max-width: none;
        box-sizing: border-box;
    }

    .recommend-title-text {
        font-size: 18px;
        margin-bottom: 4px;
    }

    .recommend-list-title {
        margin-bottom: 8px;
    }

    .recommend-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
        width: 100%;
        box-sizing: border-box;
    }

    .recommend-grid-item {
        padding: 3px;
        min-height: 48px;
        box-sizing: border-box;
        overflow: hidden;
    }

    .recommend-grid-item:hover {
        transform: translateY(-2px) scale(1.005);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .recommend-grid-item.has-link:hover {
        transform: translateY(-3px) scale(1.01);
        box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
    }

    .recommend-card-header {
        gap: 2px;
    }

    .recommend-logo {
        width: 85px;
        height: 30px;
    }

    .recommend-arrow svg {
        width: 18px;
        height: 18px;
    }

    .recommend-description {
        margin-top: 1px;
        line-height: 1.1;
    }
}

@media (max-width: 375px) {
    .recommend-list-wrapper {
        margin: 6px auto;
        padding: 5px;
        width: 97%;
    }

    .recommend-grid {
        gap: 2px;
    }

    .recommend-grid-item {
        padding: 2px;
        min-height: 45px;
    }

    .recommend-logo {
        width: 80px;
        height: 28px;
    }

    .recommend-arrow svg {
        width: 16px;
        height: 16px;
    }

    .recommend-description {
        line-height: 1.0;
    }

    .recommend-title-text {
        font-size: 16px;
    }
}

@media (max-width: 360px) {
    .recommend-list-wrapper {
        margin: 8px auto;
        padding: 8px;
        width: 98%;
        max-width: 320px;
    }

    .recommend-grid {
        gap: 3px;
    }

    .recommend-grid-item {
        padding: 3px;
        min-height: 45px;
    }

    .recommend-logo {
        width: 90px;
        height: 30px;
    }

    .recommend-arrow svg {
        width: 20px;
        height: 20px;
    }

    .recommend-description {
        margin-top: 1px;
    }

    .recommend-title-text {
        font-size: 18px;
    }

    .recommend-bg-top-right {
        width: 70px !important;
        height: 70px !important;
        max-width: 70px;
        max-height: 70px;
        top: 5px;
        right: 5px;
    }

    .recommend-bg-bottom-right {
        width: 70px !important;
        height: 70px !important;
        max-width: 70px;
        max-height: 70px;
        bottom: 3px;
        right: 3px;
    }

    .recommend-list-wrapper.has-bg-top-right .recommend-list-title {
        padding-left: calc(var(--top-right-image-width, 35px) * 0.4);
        padding-right: calc(var(--top-right-image-width, 35px) * 0.4);
        text-align: center;
        margin-bottom: 3px;
        min-height: var(--top-right-image-height, 30px);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .recommend-list-wrapper.has-bg-bottom-right {
        padding-bottom: calc(3px + var(--bottom-right-image-height, 30px) + 3px);
    }
}

/* カスタムカラーバリエーション */
.recommend-list-wrapper.color-blue {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.recommend-list-wrapper.color-green {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
}

.recommend-list-wrapper.color-orange {
    background: linear-gradient(135deg, #ff9a56 0%, #ffad56 100%);
}

.recommend-list-wrapper.color-purple {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
}

/* アニメーション効果（パフォーマンス最適化） */
.recommend-grid-item {
    opacity: 0;
    animation: fadeInUp 0.4s ease forwards;
    will-change: transform, opacity;
    backface-visibility: hidden;
}

.recommend-grid-item:nth-child(n+1):nth-child(-n+2) { animation-delay: 0.05s; }
.recommend-grid-item:nth-child(n+3):nth-child(-n+4) { animation-delay: 0.1s; }
.recommend-grid-item:nth-child(n+5):nth-child(-n+6) { animation-delay: 0.15s; }
.recommend-grid-item:nth-child(n+7):nth-child(-n+8) { animation-delay: 0.2s; }
.recommend-grid-item:nth-child(n+9):nth-child(-n+10) { animation-delay: 0.25s; }

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(15px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* プリント時の調整 */
@media print {
    .recommend-list-wrapper {
        box-shadow: none;
        background: white !important;
    }

    .recommend-grid-item {
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .recommend-grid-item:hover {
        transform: none;
    }
}

.recommend-arrow svg {
    width: 45px;
    height: 45px;
    display: block;
    flex-shrink: 0;
}

.recommend-arrow svg .cls-2 {
    stroke: #333;
    stroke-width: 4px;
}

/* エラー・空表示用スタイル */
.recommend-list-error,
.recommend-list-empty {
    padding: 15px;
    margin: 10px 0;
    border-radius: 4px;
    text-align: center;
    font-size: 14px;
}

.recommend-list-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.recommend-list-empty {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

/* クリック効果 */
.recommend-grid-item.clicked {
    transform: translateY(-5px) scale(0.98);
    transition: transform 0.1s ease;
}

/* ホバー時のアローアイコンアニメーション */
.recommend-grid-item:hover .recommend-arrow {
    transform: translateX(3px);
    transition: transform 0.3s ease;
}

.recommend-arrow {
    transition: transform 0.3s ease;
}

/* ホバー時のロゴアニメーション */
.recommend-grid-item:hover .recommend-logo {
    transform: scale(1.05);
    transition: transform 0.3s ease;
}

.recommend-logo {
    transition: transform 0.3s ease;
}

/* ホバー時のテキストアニメーション */
.recommend-grid-item:hover .recommend-description {
    color: #333;
    transition: color 0.3s ease;
}

/* フォーカス時のアクセシビリティ */
.recommend-grid-item:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

/* 王冠マーク */
.recommend-crown {
    position: absolute;
    top: -12px;
    right: -10px;
    z-index: 12;
    opacity: 0;
    animation: crownFadeIn 0.6s ease-out 0.3s forwards;
    transform: rotate(0deg);
}

.recommend-crown svg {
    width: 20px;
    height: 20px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

/* 王冠マーク位置調整（枠外オフセット・ロゴに干渉しない） */
.recommend-grid a, .recommend-grid-item { overflow: visible; }
.recommend-crown {
    position: absolute;
    top: -20px;
    right: 0;
    z-index: 12;
    background: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.recommend-crown img {
    width: 24px !important;
    height: 24px !important;
    display: block;
}
.recommend-grid-item .recommend-logo {
    position: relative; z-index: 2;
}

.recommend-grid-item.first-item {
    position: relative;
    border: 2px solid #ffd700;
}

.recommend-grid-item.first-item:hover {
    transform: translateY(-10px) scale(1.03);
    box-shadow: 0 16px 40px rgba(255, 215, 0, 0.3);
    border-color: #ffd700;
}

@keyframes crownFadeIn {
    from {
        opacity: 0;
        transform: rotate(0deg) scale(0.5) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: rotate(0deg) scale(1) translateY(0);
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    .recommend-crown {
        top: -18px;
        right: 0;
        width: 32px;
        height: 32px;
    }

    .recommend-crown img {
        width: 20px !important;
        height: 20px !important;
    }

    .recommend-crown svg {
        width: 18px;
        height: 18px;
    }

    .recommend-grid-item.first-item {
        border-width: 1.5px;
    }
}

@media (max-width: 480px) {
    .recommend-crown {
        top: -16px;
        right: 0;
        width: 28px;
        height: 28px;
    }

    .recommend-crown img {
        width: 18px !important;
        height: 18px !important;
    }

    .recommend-crown svg {
        width: 16px;
        height: 16px;
    }

    .recommend-grid-item.first-item {
        border-width: 1px;
    }
}

/* カード アニメーション設定用クラス */

/* アニメーションなし */
.recommend-grid-item.animation-none {
    opacity: 1;
    animation: none;
}

/* 背景画像アニメーション - なし */
.recommend-bg-image.animation-none {
    opacity: 1;
    animation: none;
}

/* フェードアニメーション */
.recommend-grid-item.animation-fade {
    opacity: 0;
    animation: fadeInAnimation 0.6s ease forwards;
}

/* 背景画像フェードアニメーション */
.recommend-bg-image.animation-fade {
    opacity: 0;
    animation: fadeInAnimation 0.8s ease 0.3s forwards;
}

.recommend-grid-item.animation-fade:nth-child(n+1):nth-child(-n+2) { animation-delay: 0.1s; }
.recommend-grid-item.animation-fade:nth-child(n+3):nth-child(-n+4) { animation-delay: 0.2s; }
.recommend-grid-item.animation-fade:nth-child(n+5):nth-child(-n+6) { animation-delay: 0.3s; }
.recommend-grid-item.animation-fade:nth-child(n+7):nth-child(-n+8) { animation-delay: 0.4s; }

@keyframes fadeInAnimation {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* スライドアニメーション */
.recommend-grid-item.animation-slide {
    opacity: 0;
    animation: slideInAnimation 0.7s ease forwards;
}

/* 背景画像スライドアニメーション */
.recommend-bg-image.animation-slide {
    opacity: 0;
    animation: slideInAnimation 0.8s ease 0.4s forwards;
}

.recommend-grid-item.animation-slide:nth-child(n+1):nth-child(-n+2) { animation-delay: 0.1s; }
.recommend-grid-item.animation-slide:nth-child(n+3):nth-child(-n+4) { animation-delay: 0.2s; }
.recommend-grid-item.animation-slide:nth-child(n+5):nth-child(-n+6) { animation-delay: 0.3s; }
.recommend-grid-item.animation-slide:nth-child(n+7):nth-child(-n+8) { animation-delay: 0.4s; }

@keyframes slideInAnimation {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* スケールアニメーション */
.recommend-grid-item.animation-scale {
    opacity: 0;
    animation: scaleInAnimation 0.6s ease forwards;
}

/* 背景画像スケールアニメーション */
.recommend-bg-image.animation-scale {
    opacity: 0;
    animation: scaleInAnimation 0.8s ease 0.5s forwards;
}

.recommend-grid-item.animation-scale:nth-child(n+1):nth-child(-n+2) { animation-delay: 0.1s; }
.recommend-grid-item.animation-scale:nth-child(n+3):nth-child(-n+4) { animation-delay: 0.2s; }
.recommend-grid-item.animation-scale:nth-child(n+5):nth-child(-n+6) { animation-delay: 0.3s; }
.recommend-grid-item.animation-scale:nth-child(n+7):nth-child(-n+8) { animation-delay: 0.4s; }

@keyframes scaleInAnimation {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* バウンスアニメーション */
.recommend-grid-item.animation-bounce {
    opacity: 0;
    animation: bounceInAnimation 0.8s ease forwards;
}

/* 背景画像バウンスアニメーション */
.recommend-bg-image.animation-bounce {
    opacity: 0;
    animation: bounceInAnimation 0.9s ease 0.6s forwards;
}

.recommend-grid-item.animation-bounce:nth-child(n+1):nth-child(-n+2) { animation-delay: 0.1s; }
.recommend-grid-item.animation-bounce:nth-child(n+3):nth-child(-n+4) { animation-delay: 0.2s; }
.recommend-grid-item.animation-bounce:nth-child(n+5):nth-child(-n+6) { animation-delay: 0.3s; }
.recommend-grid-item.animation-bounce:nth-child(n+7):nth-child(-n+8) { animation-delay: 0.4s; }

@keyframes bounceInAnimation {
    0% {
        opacity: 0;
        transform: scale(0.3) translateY(-50px);
    }
    50% {
        opacity: 1;
        transform: scale(1.05) translateY(-10px);
    }
    70% {
        transform: scale(0.9) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* 背景画像アニメーション */
@keyframes bgImageFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* 右上画像アニメーション */
@keyframes bgImageSlideInRight {
    from {
        opacity: 0;
        transform: translateX(30px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

/* 右下画像アニメーション */
@keyframes bgImageSlideInBottom {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* 背景画像設定 */
.recommend-bg-image {
    position: absolute;
    z-index: 1;
    opacity: 0;
    pointer-events: none;
}

.recommend-bg-image img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
    object-position: center;
}

/* 右上の背景画像 - タイトル横に配置 */
.recommend-bg-top-right {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 3;
}

/* 右下の背景画像 */
.recommend-bg-bottom-right {
    bottom: 8px;
    right: 8px;
}

/* 右上画像がある場合はタイトルエリアのバランス調整 */
.recommend-list-wrapper.has-bg-top-right .recommend-list-title {
    padding-left: calc(var(--top-right-image-width, 80px) + 20px);
    padding-right: calc(var(--top-right-image-width, 80px) + 20px);
    text-align: center;
    margin-bottom: 10px;
    min-height: var(--top-right-image-height, 50px);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 右下画像がある場合の下部余白調整 */
.recommend-list-wrapper.has-bg-bottom-right {
    padding-bottom: calc(8px + var(--bottom-right-image-height, 50px) + 10px);
}

/* コンテンツをz-indexで前面に */
.recommend-list-title,
.recommend-list-container {
    position: relative;
    z-index: 2;
}

/* レスポンシブ対応 */
@media (max-width: 768px) {
    .recommend-bg-top-right {
        top: 12px;
        right: 12px;
    }

    .recommend-bg-bottom-right {
        bottom: 6px;
        right: 6px;
    }

    .recommend-list-wrapper.has-bg-top-right .recommend-list-title {
        padding-left: calc(var(--top-right-image-width, 80px) * 0.6 + 10px);
        padding-right: calc(var(--top-right-image-width, 80px) * 0.6 + 10px);
        text-align: center;
        margin-bottom: 8px;
        min-height: var(--top-right-image-height, 50px);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .recommend-list-wrapper.has-bg-bottom-right {
        padding-bottom: calc(6px + var(--bottom-right-image-height, 50px) + 8px);
    }
}

@media (max-width: 480px) {
    .recommend-bg-image {
        opacity: 1.0;
    }

    .recommend-bg-top-right {
        top: 8px;
        right: 8px;
        width: 80px !important;
        height: 80px !important;
        max-width: 80px;
        max-height: 80px;
    }

    .recommend-bg-bottom-right {
        bottom: 5px;
        right: 5px;
        width: 80px !important;
        height: 80px !important;
        max-width: 80px;
        max-height: 80px;
    }

    .recommend-list-wrapper.has-bg-top-right .recommend-list-title {
        padding-left: calc(var(--top-right-image-width, 50px) * 0.6);
        padding-right: calc(var(--top-right-image-width, 50px) * 0.6);
        text-align: center;
        margin-bottom: 6px;
        min-height: var(--top-right-image-height, 40px);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .recommend-list-wrapper.has-bg-bottom-right {
        padding-bottom: calc(4px + var(--bottom-right-image-height, 40px) + 6px);
    }
}

@media (max-width: 375px) {
    .recommend-bg-image {
        opacity: 1.0;
    }

    .recommend-bg-top-right {
        top: 6px;
        right: 6px;
        width: 75px !important;
        height: 75px !important;
        max-width: 75px;
        max-height: 75px;
    }

    .recommend-bg-bottom-right {
        bottom: 3px;
        right: 3px;
        width: 75px !important;
        height: 75px !important;
        max-width: 75px;
        max-height: 75px;
    }

    .recommend-list-wrapper.has-bg-top-right .recommend-list-title {
        padding-left: calc(var(--top-right-image-width, 40px) * 0.5);
        padding-right: calc(var(--top-right-image-width, 40px) * 0.5);
        text-align: center;
        margin-bottom: 4px;
        min-height: var(--top-right-image-height, 35px);
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .recommend-list-wrapper.has-bg-bottom-right {
        padding-bottom: calc(3px + var(--bottom-right-image-height, 35px) + 5px);
    }
}
