/**
 * Affiliate Widget Styles
 *
 * Styles for the affiliate product shortcode.
 * Designed to stand out while matching site aesthetic.
 *
 * @package WakasmTheme
 * @since 2.0
 */

/* ==========================================================================
   Container
   ========================================================================== */

.wakasm-affiliate-container {
    background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%);
    border: 2px solid #4da44b;
    border-radius: 12px;
    padding: 20px;
    margin: 30px 0;
    position: relative;
    overflow: hidden;
}

/* Subtle corner accent */
.wakasm-affiliate-container::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100px;
    height: 100px;
    background: linear-gradient(135deg, transparent 50%, rgba(77, 164, 75, 0.1) 50%);
    pointer-events: none;
}

/* ==========================================================================
   Header & Disclosure
   ========================================================================== */

.affiliate-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.affiliate-icon {
    font-size: 1.5rem;
}

.affiliate-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #4da44b;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.affiliate-disclosure {
    font-size: 0.85rem;
    color: #999;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #3d3d3d;
    font-style: italic;
}

/* ==========================================================================
   Items Row (Horizontal Layout)
   ========================================================================== */

.affiliate-items-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: flex-start;
}

/* ==========================================================================
   Individual Item Card
   ========================================================================== */

.affiliate-item {
    flex: 0 1 calc(25% - 12px); /* 4 columns on desktop */
    min-width: 140px;
    max-width: 200px;
    background: #252525;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Image Container - portrait ratio better fits tall box art */
.affiliate-item-image {
    width: 100%;
    aspect-ratio: 2 / 3;
    overflow: hidden;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    box-sizing: border-box;
}

.affiliate-item-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center;
}


/* Info Section */
.affiliate-item-info {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.affiliate-item-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #e0e0e0;
    margin: 0;
    line-height: 1.3;
    /* Limit to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.affiliate-item-price {
    font-size: 1rem;
    font-weight: 700;
    color: #4da44b;
}

/* Buy Button */
.affiliate-item-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 14px;
    background: var(--store-color, #232f3e);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    transition: background 0.2s ease;
    margin-top: auto;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.3px;
}

.affiliate-item-button:hover {
    background: var(--store-color-hover, var(--store-color, #232f3e));
    color: #fff;
}

/* Amazon-specific styling for better visibility */
.affiliate-item[data-store="amazon"] .affiliate-item-button {
    background: linear-gradient(135deg, #232f3e 0%, #37475a 100%);
    border: 2px solid #FF9900;
}

.affiliate-item[data-store="amazon"] .affiliate-item-button:hover {
    background: #FF9900;
    border-color: #ffd699;
}

/* ==========================================================================
   Multi-Store Horizontal Layout
   ========================================================================== */

/* "Available at:" label */
.affiliate-item-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Container for multiple inline buttons */
.affiliate-item-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

/* Compact buttons for multi-store items */
.affiliate-item-button-compact {
    padding: 6px 10px;
    font-size: 0.75rem;
    flex: 1 1 auto;
    min-width: 80px;
}

/* Store-specific styling for compact buttons */
.affiliate-item-button-compact[data-store="amazon"] {
    background: linear-gradient(135deg, #232f3e 0%, #37475a 100%);
    border: 1px solid #FF9900;
}

.affiliate-item-button-compact[data-store="amazon"]:hover {
    background: #FF9900;
    border-color: #ffd699;
}

.affiliate-item-button-compact[data-store="ebay"] {
    background: linear-gradient(135deg, #0064D2 0%, #0077D5 100%);
    border: 1px solid #66c0f4;
}

.affiliate-item-button-compact[data-store="ebay"]:hover {
    background: #004a9e;
    border-color: #8fd3ff;
}

.affiliate-item-button-compact[data-store="drivethrurpg"] {
    background: linear-gradient(135deg, #8b0000 0%, #a00000 100%);
    border: 1px solid #cc0000;
}

.affiliate-item-button-compact[data-store="drivethrurpg"]:hover {
    background: #cc0000;
    border-color: #ff8888;
}

.affiliate-item-button-compact[data-store="steam"] {
    border: 1px solid #66c0f4;
}

/* ==========================================================================
   Responsive Breakpoints
   ========================================================================== */

/* Tablet - 3 columns */
@media (max-width: 992px) {
    .affiliate-item {
        flex: 0 1 calc(33.333% - 10px);
    }
}

/* Small Tablet - 2 columns */
@media (max-width: 768px) {
    .affiliate-item {
        flex: 0 1 calc(50% - 8px);
        max-width: none;
    }

    .affiliate-items-row {
        gap: 12px;
    }

    .wakasm-affiliate-container {
        padding: 15px;
    }

    .affiliate-title {
        font-size: 1.1rem;
    }
}

/* Mobile - 2 columns but smaller */
@media (max-width: 480px) {
    .affiliate-item {
        flex: 0 1 calc(50% - 6px);
        min-width: 120px;
    }

    .affiliate-items-row {
        gap: 10px;
    }

    .affiliate-item-info {
        padding: 10px;
    }

    .affiliate-item-title {
        font-size: 0.85rem;
    }

    .affiliate-item-button {
        font-size: 0.75rem;
        padding: 6px 10px;
    }
}

/* ==========================================================================
   Dark Mode Enhancements (if site uses dark mode toggle)
   ========================================================================== */

.wakasm-affiliate-container {
    /* Already dark by default, but ensure contrast */
    color: #e0e0e0;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .wakasm-affiliate-container,
    .wakasm-affiliate-sidebar {
        display: none; /* Hide affiliate widgets in print */
    }
}

/* ==========================================================================
   VERTICAL SIDEBAR LAYOUT
   ========================================================================== */

.wakasm-affiliate-sidebar {
    background: linear-gradient(180deg, #1a1a1a 0%, #252525 100%);
    border: 2px solid #4da44b;
    border-radius: 10px;
    padding: 15px;
    max-width: 280px;
}

.affiliate-sidebar-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.affiliate-sidebar-header .affiliate-icon {
    font-size: 1.2rem;
}

.affiliate-sidebar-header .affiliate-title {
    font-size: 1rem;
    font-weight: 700;
    color: #4da44b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.affiliate-sidebar-disclosure {
    font-size: 0.75rem;
    color: #888;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid #3d3d3d;
    font-style: italic;
}

.affiliate-sidebar-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Individual Sidebar Item */
.affiliate-sidebar-item {
    background: #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
}

/* Image with rank badge */
.affiliate-sidebar-image {
    display: block;
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1; /* Square - works for most box art */
    background: #1a1a1a;
    overflow: hidden;
}

.affiliate-sidebar-image img {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Shows full image, letterboxed if needed */
    padding: 8px;
    box-sizing: border-box; /* Include padding in dimensions to prevent cut-off */
}

.affiliate-sidebar-rank {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(77, 164, 75, 0.95);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Info Section */
.affiliate-sidebar-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.affiliate-sidebar-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e0e0e0 !important;
    text-decoration: none;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    transition: color 0.2s ease;
}

.affiliate-sidebar-title:hover {
    color: #4da44b !important;
}

/* Read my review button - pink style matching other store buttons */
a.affiliate-sidebar-review-link,
a.affiliate-sidebar-review-link:link,
a.affiliate-sidebar-review-link:visited,
a.affiliate-sidebar-review-link:focus,
a.affiliate-sidebar-review-link:active,
.affiliate-sidebar-review-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 10px;
    background: linear-gradient(135deg, #e91e8c 0%, #d81b7a 100%);
    border: 2px solid #c41874;
    color: #ffffff !important;
    font-size: 0.75rem;
    font-weight: 700;
    text-decoration: none !important;
    border-radius: 5px;
    transition: background 0.2s ease, border-color 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    text-align: center;
}

a.affiliate-sidebar-review-link:hover,
a.affiliate-sidebar-review-link:hover:visited,
a.affiliate-sidebar-review-link:hover:link,
a.affiliate-sidebar-review-link:hover:focus,
a.affiliate-sidebar-review-link:hover:active {
    background: #ff69b4;
    border-color: #e91e8c;
    color: #ffffff !important;
    text-decoration: none !important;
}

.affiliate-sidebar-price {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4da44b;
}

/* Sidebar Buy Button */
.affiliate-sidebar-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 10px;
    background: var(--store-color, #232f3e);
    color: #fff !important;
    text-decoration: none;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 700;
    transition: background 0.2s ease, border-color 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.affiliate-sidebar-button:hover {
    color: #fff !important;
}

/* "Find it at:" label for multiple stores */
.affiliate-sidebar-label {
    font-size: 0.7rem;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

/* Container for multiple buttons */
.affiliate-sidebar-buttons {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

/* Compact buttons when multiple are shown */
.affiliate-sidebar-buttons .affiliate-sidebar-button {
    padding: 6px 8px;
    font-size: 0.7rem;
}

/* Amazon styling for sidebar - now targets data-store on button */
.affiliate-sidebar-button[data-store="amazon"] {
    background: linear-gradient(135deg, #232f3e 0%, #37475a 100%);
    border: 2px solid #FF9900;
}

.affiliate-sidebar-button[data-store="amazon"]:hover {
    background: #FF9900;
    border-color: #ffd699;
}

/* eBay styling */
.affiliate-sidebar-button[data-store="ebay"] {
    background: linear-gradient(135deg, #0064D2 0%, #0077D5 100%);
    border: 2px solid #66c0f4;
}

.affiliate-sidebar-button[data-store="ebay"]:hover {
    background: #004a9e;
    border-color: #8fd3ff;
}

/* eBay sidebar button with image */
.affiliate-sidebar-button.has-ebay-thumb {
    flex-wrap: wrap;
    position: relative;
    justify-content: center;
    align-items: center;
}

/* Desktop + mobile hover-expand accordion replaced with portal-to-body
   popup (wakasm-hover-popup.js). Touch users tap to show, tap again or
   tap popup to navigate. */

/* Image wrapper - order:-1 keeps it first */
.affiliate-sidebar-button.has-ebay-thumb .ebay-thumb-wrapper {
    order: -1;
}

/* Condition badge for sidebar eBay buttons */
.affiliate-sidebar-button .affiliate-condition {
    background: rgba(255, 255, 255, 0.15);
    color: #ccc;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
}

/* ==========================================================================
   Live Price Display (eBay API)
   ========================================================================== */

/* Price badge inside affiliate buttons */
.affiliate-price {
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #4da44b;
    margin-left: 4px;
    white-space: nowrap;
}

/* Button layout adjustment when price is present */
.affiliate-sidebar-button.has-price {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
}

/* eBay buttons with live prices get special styling */
.affiliate-sidebar-button[data-store="ebay"].has-price {
    border-color: #4da44b; /* Green border to highlight live pricing */
}

.affiliate-sidebar-button[data-store="ebay"].has-price .affiliate-price {
    color: #fff;
    background: rgba(77, 164, 75, 0.8);
}

/* DriveThruRPG styling */
.affiliate-sidebar-button[data-store="drivethrurpg"] {
    background: linear-gradient(135deg, #8b0000 0%, #a00000 100%);
    border: 2px solid #cc0000;
}

.affiliate-sidebar-button[data-store="drivethrurpg"]:hover {
    background: #cc0000;
    border-color: #ff8888;
}

/* Steam styling (non-affiliate, view only) */
.affiliate-sidebar-button[data-store="steam"] {
    background: linear-gradient(135deg, #1b2838 0%, #2a475e 100%);
    border: 2px solid #66c0f4;
}

.affiliate-sidebar-button[data-store="steam"]:hover {
    background: #66c0f4;
    border-color: #c4e7fb;
}

/* Responsive - make sidebar full width on small screens */
@media (max-width: 480px) {
    .wakasm-affiliate-sidebar {
        max-width: 100%;
    }

    .affiliate-sidebar-items {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .affiliate-sidebar-item {
        flex: 0 1 calc(50% - 6px);
        min-width: 130px;
    }
}

/* ==========================================================================
   BUY THIS GAME Section (Current Game Affiliates)
   ========================================================================== */

.wakasm-buy-game {
    background: linear-gradient(180deg, #1a1a1a 0%, #252525 100%);
    border: 2px solid #4da44b;
    border-radius: 8px;
    padding: 12px;
    margin: 15px 0;
}

.buy-game-header {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.buy-game-icon {
    font-size: 1rem;
}

.buy-game-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #4da44b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.buy-game-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Buy button styling */
.buy-game-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    background: var(--store-color, #232f3e);
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 700;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    border: 2px solid transparent;
}

.buy-game-btn:hover {
    color: #fff;
}

/* Store-specific styling */
.buy-game-btn[data-store="amazon"] {
    background: linear-gradient(135deg, #232f3e 0%, #37475a 100%);
    border-color: #FF9900;
}

.buy-game-btn[data-store="amazon"]:hover {
    background: #FF9900;
    border-color: #ffd699;
}

.buy-game-btn[data-store="ebay"],
.buy-game-btn.buy-game-ebay {
    background: linear-gradient(135deg, #0064D2 0%, #0077D5 100%);
    border-color: #66c0f4;
}

.buy-game-btn[data-store="ebay"]:hover,
.buy-game-btn.buy-game-ebay:hover {
    background: #004a9e;
    border-color: #8fd3ff;
}

.buy-game-btn[data-store="steam"] {
    background: linear-gradient(135deg, #1b2838 0%, #2a475e 100%);
    border-color: #66c0f4;
}

/* Price and condition badges */
.buy-game-btn .affiliate-price {
    background: rgba(77, 164, 75, 0.9);
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 700;
    margin-left: auto;
}

.buy-game-btn .affiliate-condition {
    background: rgba(255, 255, 255, 0.15);
    color: #ccc;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 500;
}

/* Disclosure text */
.buy-game-disclosure {
    font-size: 0.7rem;
    color: #666;
    text-align: center;
    margin-top: 8px;
    font-style: italic;
}

/* Compact mode for sidebar placement */
.wakasm-buy-game-compact {
    padding: 10px;
    margin: 5px 0 10px 0;
    width: 100%; /* Match box art width */
    box-sizing: border-box;
}

.wakasm-buy-game-compact .buy-game-header {
    margin-bottom: 8px;
}

.wakasm-buy-game-compact .buy-game-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
}

.wakasm-buy-game-compact .buy-game-options {
    gap: 6px;
}

.wakasm-buy-game-compact .buy-game-disclosure {
    font-size: 0.7rem;
    margin-top: 8px;
    padding-top: 6px;
    border-top: 1px solid #3d3d3d;
}

/* ==========================================================================
   OTHER GAMES Section (Sidebar placement)
   ========================================================================== */

.sidebar-other-games {
    margin-top: 15px;
}

.sidebar-other-games .other-games-header {
    text-align: center;
    padding-bottom: 8px;
    margin-bottom: 10px;
    border-bottom: 1px solid #3d3d3d;
}

/* Override sidebar styles when inside banner sidebar */
.sidebar-other-games .wakasm-affiliate-sidebar {
    max-width: 100%;
    border: none;
    padding: 0;
    background: transparent;
}

.sidebar-other-games .affiliate-sidebar-header {
    display: none; /* Hide duplicate header */
}

.sidebar-other-games .affiliate-sidebar-disclosure {
    display: none; /* Hide disclosure in compact mode */
}

/* ==========================================================================
   Pink Text for "affiliate links"
   ========================================================================== */

.pink-text {
    color: #ff69b4;
    font-style: normal;
}

/* ==========================================================================
   eBay Thumbnail Preview (inline with hover expand)
   ========================================================================== */

.ebay-thumb-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-right: 8px;
}

.ebay-thumb {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: #1a1a1a;
}

.buy-game-btn.has-thumb {
    align-items: center;
}

/* eBay button - uses flex-wrap so width changes push image to own row */
.buy-game-btn.buy-game-ebay {
    flex-wrap: wrap;
    position: relative;
    justify-content: center;
    align-items: center;
}

/* Desktop + mobile hover-expand accordion replaced with portal-to-body
   popup (wakasm-hover-popup.js). Touch users tap to show, tap again or
   tap popup to navigate. */

/* Image wrapper - order:-1 keeps it first */
.buy-game-btn.buy-game-ebay .ebay-thumb-wrapper {
    order: -1;
}

/* eBay thumbnail fallback - SVG logo hidden by default, shown when image fails */
.ebay-thumb-wrapper .store-thumb {
    display: none;
}

.ebay-thumb-wrapper.thumb-error .ebay-thumb {
    display: none;
}

.ebay-thumb-wrapper.thumb-error .store-thumb {
    display: block;
    width: 32px;
    height: 32px;
}

/* eBay item title - hidden by default, revealed on hover */
.ebay-item-title {
    display: none;
    width: 100%;
    font-size: 0.6rem;
    color: #ccc;
    text-align: center;
    margin-top: 4px;
    line-height: 1.2;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

/* ==========================================================================
   Store Logo Thumbnails (Amazon, Steam, etc.)
   Same hover expand effect as eBay thumbnails
   ========================================================================== */

.store-thumb-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-right: 8px;
}

.store-thumb {
    width: 32px;
    height: 32px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.4);
}

