/**
 * Interactive Hotspots - Frontend Styles
 *
 * Styling for hotspot markers and tooltips on the frontend.
 * CSS custom properties are set dynamically via wp_head.
 *
 * @package InteractiveHotspots
 */

/* ==========================================================================
   CSS Custom Properties (Static defaults for non-variable properties)
   Note: Primary theme variables are set via dynamic inline CSS in wp_head
   ========================================================================== */

/*
 * Note: All configurable CSS variables are set dynamically via inline CSS in wp_head.
 * This includes: --ih-primary, --ih-secondary, --ih-pulse-color, --ih-tooltip-bg,
 * --ih-tooltip-text, --ih-tooltip-title, --ih-tooltip-link, --ih-animation-speed,
 * --ih-dot-size, --ih-pulse-size, --ih-tooltip-width, --ih-tooltip-border-radius, --ih-z-index
 *
 * Only static, non-configurable properties are defined here as fallbacks.
 */
:root {
    /* Static marker properties (not configurable via settings) */
    --ih-marker-color: #ffffff;
    --ih-marker-border: 2px solid #ffffff;
    --ih-marker-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);

    /* Static tooltip properties (not overriding dynamic values) */
    --ih-tooltip-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    --ih-tooltip-padding: 16px;
}

/* ==========================================================================
   Hotspot Container
   ========================================================================== */

.ih-hotspot-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
}

.ih-hotspot-image-wrapper {
    position: relative;
    display: inline-block;
    width: 100%;
    line-height: 0;
}

.ih-hotspot-image {
    width: 100%;
    height: auto;
    display: block;
}

/* ==========================================================================
   Slider Overlay (for hotspots in carousels/sliders)
   ========================================================================== */

.ih-slider-overlay {
    position: absolute;
    pointer-events: none; /* Allow clicks to pass through to slider */
    z-index: var(--ih-z-index, 10);
    cursor: default; /* Prevent cursor inheritance */
    /* Position and size are set dynamically by JS to match visible image area */
    /* This handles object-fit: cover cropping automatically */
}

/* Reset cursor on slider containers that have hotspots to prevent Elementor inheritance */
.swiper-slide:has(.ih-slider-overlay),
figure:has(.ih-slider-overlay) {
    cursor: default;
}

/* Disable click on underlying links when hotspot overlay is present */
/* This prevents lightbox/self-links from triggering when clicking empty areas */
.swiper-slide:has(.ih-slider-overlay) > a,
figure:has(.ih-slider-overlay) > a,
.swiper-slide-inner:has(.ih-slider-overlay) > a {
    pointer-events: none;
}

/* But keep the image visible and swiper touch working */
.swiper-slide:has(.ih-slider-overlay) > a > img,
figure:has(.ih-slider-overlay) > a > img {
    pointer-events: none;
}

/* Markers inside overlay need to be clickable */
.ih-slider-overlay .ih-hotspot-marker {
    pointer-events: auto;
}

/* Ensure slider slide containers have position relative */
/* Individual slides can have overflow:visible - parent containers handle clipping */
.swiper-slide:has(.ih-slider-overlay),
.slick-slide:has(.ih-slider-overlay),
.owl-item:has(.ih-slider-overlay),
.carousel-item:has(.ih-slider-overlay),
.gallery-item:has(.ih-slider-overlay) {
    position: relative !important;
}

/* Handle Elementor's inner figure wrapper */
.swiper-slide figure.swiper-slide-inner:has(.ih-slider-overlay),
figure:has(.ih-slider-overlay) {
    position: relative !important;
    display: block !important;
}

/* The overlay itself - positioned within the slide */
.ih-slider-overlay {
    overflow: visible; /* Allow tooltips to extend outside overlay bounds */
}

/*
 * NOTE: We do NOT set overflow:visible on parent slider containers
 * (.swiper, .swiper-container, .swiper-wrapper, etc.)
 * Those NEED overflow:hidden for proper carousel behavior.
 * Tooltips will be constrained within the visible slide area.
 */

/*
 * NOTE: We do NOT change object-fit for slider images.
 * The overlay positioning is calculated dynamically by JavaScript
 * to match the visible area of the image regardless of object-fit mode.
 * This keeps image display consistent whether or not hotspots are present.
 */

/* ==========================================================================
   Hotspot Marker
   ========================================================================== */

.ih-hotspot-marker {
    position: absolute;
    left: calc(var(--ih-x) * 1%);
    top: calc(var(--ih-y) * 1%);
    transform: translate(-50%, -50%);
    z-index: 10;
    cursor: default; /* Only the dot inside has pointer cursor */
    outline: none;
    /* Explicit size to match dot - prevents pulse from expanding clickable area */
    width: var(--ih-dot-size);
    height: var(--ih-dot-size);
}

/* Active/hovered marker gets higher z-index so tooltip appears on top */
.ih-hotspot-marker:hover,
.ih-hotspot-marker:focus,
.ih-hotspot-marker.ih-active {
    z-index: 100;
}

.ih-hotspot-marker:focus {
    outline: 2px solid var(--ih-primary);
    outline-offset: 4px;
    border-radius: 50%;
}

/* ==========================================================================
   Marker Shapes - Base Styles
   ========================================================================== */

/* Base dot styles (shared by all shapes) */
.ih-hotspot-dot {
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--ih-dot-size);
    height: var(--ih-dot-size);
    background-color: var(--ih-primary);
    border: var(--ih-marker-border);
    border-radius: 50%;
    box-shadow: var(--ih-marker-shadow);
    transition: transform var(--ih-animation-speed) ease,
                background-color var(--ih-animation-speed) ease;
    position: relative;
    z-index: 2;
    pointer-events: auto; /* Dot is the clickable element */
    cursor: pointer;
}

/* Default: Plus icon */
.ih-hotspot-dot::before {
    content: '+';
    color: var(--ih-marker-color);
    font-size: calc(var(--ih-dot-size) * 0.7);
    font-weight: bold;
    line-height: 1;
}

/* ==========================================================================
   Marker Shape: Donut (Ring)
   ========================================================================== */

.ih-marker-donut .ih-hotspot-dot {
    background-color: transparent;
    border: 3px solid var(--ih-primary);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8), var(--ih-marker-shadow);
}

.ih-marker-donut .ih-hotspot-dot::before {
    display: none;
}

.ih-marker-donut:hover .ih-hotspot-dot,
.ih-marker-donut:focus .ih-hotspot-dot,
.ih-marker-donut.ih-active .ih-hotspot-dot {
    border-color: var(--ih-secondary);
}

.ih-marker-donut.ih-active .ih-hotspot-dot::before {
    background-color: var(--ih-secondary);
}

/* ==========================================================================
   Marker Shape: Pin (Map Marker)
   ========================================================================== */

.ih-marker-pin .ih-hotspot-dot {
    width: calc(var(--ih-dot-size) * 0.9);
    height: calc(var(--ih-dot-size) * 1.3);
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
}

.ih-marker-pin .ih-hotspot-dot::before {
    content: '';
    width: 8px;
    height: 8px;
    background-color: var(--ih-marker-color);
    border-radius: 50%;
    transform: rotate(45deg);
}

.ih-hotspot-marker.ih-marker-pin:hover .ih-hotspot-dot,
.ih-hotspot-marker.ih-marker-pin:focus .ih-hotspot-dot {
    transform: rotate(-45deg) scale(1.15);
}

.ih-hotspot-marker.ih-marker-pin.ih-active .ih-hotspot-dot {
    transform: rotate(-45deg) scale(1.1);
}

/* ==========================================================================
   Marker Shape: Star
   ========================================================================== */

.ih-marker-star .ih-hotspot-dot {
    background: none;
    border: none;
    box-shadow: none;
    width: var(--ih-dot-size);
    height: var(--ih-dot-size);
}

.ih-marker-star .ih-hotspot-dot::before {
    content: '★';
    font-size: calc(var(--ih-dot-size) * 1.2);
    color: var(--ih-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    filter: drop-shadow(0 0 2px rgba(255, 255, 255, 0.8));
}

.ih-marker-star:hover .ih-hotspot-dot::before,
.ih-marker-star:focus .ih-hotspot-dot::before,
.ih-marker-star.ih-active .ih-hotspot-dot::before {
    color: var(--ih-secondary);
}

/* ==========================================================================
   Marker Shape: Info (i icon)
   ========================================================================== */

.ih-marker-info .ih-hotspot-dot::before {
    content: 'i';
    font-family: Georgia, serif;
    font-style: italic;
    font-size: calc(var(--ih-dot-size) * 0.65);
    font-weight: bold;
}

/* ==========================================================================
   Marker Shape: Number (shows index)
   ========================================================================== */

.ih-marker-number .ih-hotspot-dot::before {
    content: attr(data-number);
    font-size: calc(var(--ih-dot-size) * 0.55);
    font-weight: 600;
}

/* ==========================================================================
   Marker Shape: Heart
   ========================================================================== */

.ih-marker-heart .ih-hotspot-dot {
    background: none;
    border: none;
    box-shadow: none;
}

.ih-marker-heart .ih-hotspot-dot::before {
    content: '♥';
    font-size: calc(var(--ih-dot-size) * 1.1);
    color: var(--ih-primary);
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.ih-marker-heart:hover .ih-hotspot-dot::before,
.ih-marker-heart:focus .ih-hotspot-dot::before,
.ih-marker-heart.ih-active .ih-hotspot-dot::before {
    color: var(--ih-secondary);
}

/* ==========================================================================
   Marker Shape: Eye (View/Look)
   ========================================================================== */

.ih-marker-eye .ih-hotspot-dot::before {
    content: '👁';
    font-size: calc(var(--ih-dot-size) * 0.7);
}

/* ==========================================================================
   Marker Shape: Cart (Shopping)
   ========================================================================== */

.ih-marker-cart .ih-hotspot-dot::before {
    content: '🛒';
    font-size: calc(var(--ih-dot-size) * 0.65);
}

/* ==========================================================================
   Marker Shape: Tag (Price/Label)
   ========================================================================== */

.ih-marker-tag .ih-hotspot-dot::before {
    content: '🏷';
    font-size: calc(var(--ih-dot-size) * 0.65);
}

/* Pulse animation */
.ih-hotspot-pulse {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: var(--ih-pulse-size);
    pointer-events: none; /* Pulse doesn't capture clicks - only the dot does */
    height: var(--ih-pulse-size);
    background-color: var(--ih-pulse-color);
    border-radius: 50%;
    z-index: 1;
    animation: ih-pulse var(--ih-pulse-speed, 2s) ease-out infinite;
}

@keyframes ih-pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(var(--ih-pulse-scale, 1.5));
        opacity: 0;
    }
}

@keyframes ih-fade {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: var(--ih-fade-opacity, 0.5);
    }
}

@keyframes ih-bounce-marker {
    0%, 100% {
        transform: translate(-50%, -50%) translateY(0);
    }
    50% {
        transform: translate(-50%, -50%) translateY(calc(-1 * var(--ih-bounce-height, 5px)));
    }
}

/* Animation Style: Fade */
.ih-animation-fade .ih-hotspot-marker {
    animation: ih-fade 1.5s ease-in-out infinite;
}

.ih-animation-fade .ih-hotspot-pulse {
    display: none;
}

/* Animation Style: Bounce */
.ih-animation-bounce .ih-hotspot-marker {
    animation: ih-bounce-marker 1s ease infinite;
}

.ih-animation-bounce .ih-hotspot-pulse {
    display: none;
}

/* Animation Style: Glow (uses CSS variable for intensity) */
.ih-animation-glow .ih-hotspot-dot {
    box-shadow: 0 0 calc(15px * var(--ih-glow-intensity, 0.5)) var(--ih-primary),
                0 0 calc(30px * var(--ih-glow-intensity, 0.5)) var(--ih-pulse-color);
}

.ih-animation-glow .ih-hotspot-pulse {
    display: none;
}

/* Animation Style: None (Static) */
.ih-animation-none .ih-hotspot-pulse {
    display: none;
}

/* Hover Effect: Scale (default) - only on dot hover, not tooltip */
.ih-hover-scale .ih-hotspot-dot:hover,
.ih-hover-scale .ih-hotspot-marker:focus .ih-hotspot-dot {
    transform: scale(1.2);
}

/* Hover Effect: Glow - adds glowing shadow on hover */
.ih-hover-glow .ih-hotspot-dot:hover,
.ih-hover-glow .ih-hotspot-marker:focus .ih-hotspot-dot {
    box-shadow: 0 0 15px var(--ih-primary),
                0 0 30px var(--ih-primary),
                0 0 45px var(--ih-pulse-color);
}

/* Hover Effect: Bounce - dot bounces up on hover */
.ih-hover-bounce .ih-hotspot-dot:hover {
    animation: ih-dot-bounce 0.4s ease;
}

@keyframes ih-dot-bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

/* Hover Effect: None - no visual change on hover */
.ih-hover-none .ih-hotspot-dot:hover,
.ih-hover-none .ih-hotspot-marker:focus .ih-hotspot-dot {
    transform: none !important;
    box-shadow: var(--ih-marker-shadow) !important;
}

/* Active state (tooltip open) */
.ih-hotspot-marker.ih-active .ih-hotspot-pulse {
    animation: none;
    opacity: 0;
}

.ih-hotspot-marker.ih-active .ih-hotspot-dot {
    background-color: var(--ih-secondary);
    transform: scale(1.1);
}

/* ==========================================================================
   Tooltip
   ========================================================================== */

.ih-hotspot-tooltip {
    position: absolute;
    bottom: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%);
    width: var(--ih-tooltip-width);
    max-width: var(--ih-tooltip-width);
    background-color: var(--ih-tooltip-bg);
    color: var(--ih-tooltip-text);
    font-family: var(--ih-tooltip-font, inherit);
    border-radius: var(--ih-tooltip-border-radius);
    box-shadow: var(--ih-tooltip-shadow);
    padding: var(--ih-tooltip-padding);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--ih-animation-speed) ease,
                visibility var(--ih-animation-speed) ease,
                transform var(--ih-animation-speed) ease;
    z-index: calc(var(--ih-z-index) + 100);
    text-align: left;
    line-height: 1.5;
}

/* Force ALL text elements in tooltip to inherit font */
.ih-hotspot-tooltip *,
.ih-hotspot-tooltip *::before,
.ih-hotspot-tooltip *::after {
    font-family: inherit;
}

/* Tooltip arrow - uses --arrow-offset for dynamic positioning */
.ih-hotspot-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: calc(50% + var(--arrow-offset, 0px));
    transform: translateX(-50%);
    border: 8px solid transparent;
    border-top-color: var(--ih-tooltip-bg);
}

/* Visible state - controlled by JS via ih-active class only */
/* Note: transform is set dynamically by JS for boundary-aware positioning */
.ih-hotspot-marker.ih-active .ih-hotspot-tooltip {
    opacity: 1;
    visibility: visible;
}

/* Tooltip positioning - when near top edge */
.ih-hotspot-marker[data-position="bottom"] .ih-hotspot-tooltip {
    bottom: auto;
    top: calc(100% + 15px);
}

.ih-hotspot-marker[data-position="bottom"] .ih-hotspot-tooltip::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--ih-tooltip-bg);
}

/* Tooltip positioning - when near left edge */
.ih-hotspot-marker[data-position-x="left"] .ih-hotspot-tooltip {
    left: 0;
    transform: translateX(0);
}

.ih-hotspot-marker[data-position-x="left"] .ih-hotspot-tooltip::after {
    left: 20px;
    transform: translateX(0);
}

/* Tooltip positioning - when near right edge */
.ih-hotspot-marker[data-position-x="right"] .ih-hotspot-tooltip {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.ih-hotspot-marker[data-position-x="right"] .ih-hotspot-tooltip::after {
    left: auto;
    right: 20px;
    transform: translateX(0);
}

/* ==========================================================================
   Slider Absolute Positioning (v1.0.45)
   Uses JS-calculated pixel positions for strict slider containment
   ========================================================================== */

/* Override default CSS positioning - let JS inline styles control position and size */
.ih-hotspot-marker[data-position="slider-absolute"] .ih-hotspot-tooltip {
    /* Remove default CSS positioning - JS sets top/bottom in pixels */
    bottom: auto;
    top: auto;
    /* Keep horizontal centering, JS handles vertical */
    left: 50%;
    transform: translateX(-50%);
    /* Override global tooltip width - JS sets relative width */
    width: auto !important;
}

/* Arrow positioning for slider tooltips showing above */
.ih-hotspot-marker[data-position="slider-absolute"][data-position-y="above"] .ih-hotspot-tooltip::after {
    top: 100%;
    bottom: auto;
    border-top-color: var(--ih-tooltip-bg);
    border-bottom-color: transparent;
}

/* Arrow positioning for slider tooltips showing below */
.ih-hotspot-marker[data-position="slider-absolute"][data-position-y="below"] .ih-hotspot-tooltip::after {
    top: auto;
    bottom: 100%;
    border-top-color: transparent;
    border-bottom-color: var(--ih-tooltip-bg);
}

/* Horizontal positioning for slider tooltips - left edge */
.ih-hotspot-marker[data-position="slider-absolute"][data-position-x="left"] .ih-hotspot-tooltip {
    left: 0;
    transform: translateX(0);
}

.ih-hotspot-marker[data-position="slider-absolute"][data-position-x="left"] .ih-hotspot-tooltip::after {
    left: 20px;
    transform: translateX(0);
}

/* Horizontal positioning for slider tooltips - right edge */
.ih-hotspot-marker[data-position="slider-absolute"][data-position-x="right"] .ih-hotspot-tooltip {
    left: auto;
    right: 0;
    transform: translateX(0);
}

.ih-hotspot-marker[data-position="slider-absolute"][data-position-x="right"] .ih-hotspot-tooltip::after {
    left: auto;
    right: 20px;
    transform: translateX(0);
}

/* ==========================================================================
   Slider Portal Positioning (v1.0.46)
   Portal tooltips render to <body> to escape overflow:hidden containers
   Original tooltip is HIDDEN - only the portal clone is visible
   ========================================================================== */

/* CRITICAL: Slider markers NEVER show original tooltip - portal handles display */
.ih-slider-marker .ih-hotspot-tooltip,
.ih-slider-marker:hover .ih-hotspot-tooltip,
.ih-slider-marker.ih-active .ih-hotspot-tooltip,
.ih-slider-marker[data-position="slider-portal"] .ih-hotspot-tooltip {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Also hide the arrow of original tooltip in sliders */
.ih-slider-marker .ih-hotspot-tooltip::after,
.ih-slider-marker .ih-hotspot-tooltip::before {
    display: none !important;
    content: none !important;
}

/* ==========================================================================
   Tooltip Content
   ========================================================================== */

.ih-tooltip-title {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    font-family: var(--ih-tooltip-font, inherit);
    color: var(--ih-tooltip-title, var(--ih-tooltip-text));
    line-height: 1.3;
}

.ih-tooltip-description {
    margin: 0 0 12px 0;
    font-size: 14px;
    font-family: var(--ih-tooltip-font, inherit);
    color: var(--ih-tooltip-text, #666666);
    line-height: 1.5;
}

.ih-tooltip-description:last-child {
    margin-bottom: 0;
}

/* Budget field */
.ih-tooltip-budget {
    margin: 4px 0;
    font-size: 12px;
    font-family: var(--ih-tooltip-font, inherit);
    line-height: 1.3;
    color: var(--ih-tooltip-text, #555555);
}

.ih-tooltip-budget strong {
    font-family: inherit;
    font-weight: 600;
    color: var(--ih-tooltip-title, #333333);
}

/* Additional info field */
.ih-tooltip-additional {
    margin: 4px 0;
    font-size: 12px;
    font-family: var(--ih-tooltip-font, inherit);
    line-height: 1.3;
    color: var(--ih-tooltip-text, #666666);
}

.ih-tooltip-link {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    color: var(--ih-tooltip-link, var(--ih-primary));
    text-decoration: none;
    font-size: 14px;
    font-family: var(--ih-tooltip-font, inherit);
    font-weight: 500;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    transition: color var(--ih-animation-speed) ease, opacity var(--ih-animation-speed) ease;
}

.ih-tooltip-link:hover,
.ih-tooltip-link:focus {
    opacity: 0.8;
    text-decoration: underline;
}

.ih-link-arrow {
    transition: transform var(--ih-animation-speed) ease;
}

.ih-tooltip-link:hover .ih-link-arrow {
    transform: translateX(3px);
}

/* Link URL Preview */
.ih-tooltip-link-preview {
    display: block;
    margin-top: 8px;
    padding: 8px 10px;
    background-color: rgba(0, 0, 0, 0.05);
    border-radius: 4px;
    font-size: 11px;
    color: #888;
    word-break: break-all;
    font-family: monospace;
}

.ih-tooltip-link-preview::before {
    content: '🔗 ';
}

/* ==========================================================================
   Tooltip Images
   ========================================================================== */

.ih-tooltip-images {
    display: flex;
    gap: 8px;
    margin: 12px 0;
}

.ih-tooltip-images.ih-images-single {
    justify-content: center;
}

.ih-tooltip-images.ih-images-double {
    justify-content: space-between;
}

/* Image scaling uses --ih-image-scale CSS variable (0.1 to 1.0) */
.ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5));
    max-height: calc(200px * var(--ih-image-scale, 0.5));
    height: auto;
    border-radius: 6px;
    object-fit: contain;
}

/* Single image - centered */
.ih-images-single .ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5));
    max-height: calc(200px * var(--ih-image-scale, 0.5));
    margin: 0 auto;
    display: block;
}

/* Double images - side by side, scaled */
.ih-images-double .ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5));
    max-height: calc(150px * var(--ih-image-scale, 0.5));
    flex-shrink: 0;
}

/* Image wrapper for image + caption */
.ih-image-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ih-images-single .ih-image-wrapper {
    width: 100%;
}

.ih-images-double .ih-image-wrapper {
    width: calc(50% - 4px);
    flex-shrink: 0;
}

.ih-images-double .ih-image-wrapper .ih-tooltip-image {
    width: auto;
    max-width: 100%;
}

/* Image caption styling - matches description text styling */
.ih-image-caption {
    display: block;
    font-size: 14px;
    font-family: var(--ih-tooltip-font, inherit);
    color: var(--ih-tooltip-text, #666666);
    text-align: center;
    line-height: 1.5;
    max-width: 100%;
    margin-top: 6px;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Image scaling based on settings (--ih-image-scale: 0.1 to 1.0) */
.ih-tooltip-images {
    justify-content: center;
}

.ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5)) !important;
    max-height: calc(200px * var(--ih-image-scale, 0.5));
    width: auto;
    height: auto;
    object-fit: contain;
}

.ih-images-single .ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5)) !important;
    margin: 0 auto;
    display: block;
}

.ih-images-double {
    gap: 8px;
}

.ih-images-double .ih-image-wrapper {
    max-width: calc(50% * var(--ih-image-scale, 0.5) + 20%);
    flex: 0 1 auto;
}

.ih-images-double .ih-tooltip-image {
    width: auto;
    max-width: calc(100% * var(--ih-image-scale, 0.5)) !important;
    max-height: calc(150px * var(--ih-image-scale, 0.5));
}

/* ==========================================================================
   Responsive Tooltip Scaling
   Uses --ih-scale CSS variable (0.4 to 1.0) set by JS based on available space
   FONTS stay FIXED size - only spacing and images scale proportionally
   ========================================================================== */

/* Default scale if not set */
.ih-hotspot-tooltip {
    --ih-scale: 1;
}

/* Scale-based tooltip sizing - padding scales, fonts stay fixed */
.ih-hotspot-tooltip[style*="--ih-scale"] {
    padding: calc(var(--ih-tooltip-padding, 16px) * var(--ih-scale));
}

/* FIXED font sizes - do NOT scale with --ih-scale */
.ih-hotspot-tooltip[style*="--ih-scale"] .ih-tooltip-title {
    font-size: 16px; /* Fixed size */
    margin-bottom: calc(8px * var(--ih-scale));
}

.ih-hotspot-tooltip[style*="--ih-scale"] .ih-tooltip-description {
    font-size: 14px; /* Fixed size */
    margin-bottom: calc(12px * var(--ih-scale));
    line-height: 1.5;
}

.ih-hotspot-tooltip[style*="--ih-scale"] .ih-tooltip-images {
    margin: calc(12px * var(--ih-scale)) 0;
    gap: calc(8px * var(--ih-scale));
}

.ih-hotspot-tooltip[style*="--ih-scale"] .ih-tooltip-image {
    /* Images still scale to fit available space */
    max-height: calc(150px * var(--ih-scale));
    width: auto;
    height: auto;
    object-fit: contain;
}

.ih-hotspot-tooltip[style*="--ih-scale"] .ih-images-double .ih-tooltip-image {
    max-height: calc(120px * var(--ih-scale));
    max-width: calc(50% - 4px);
    flex: 0 1 auto;
}

.ih-hotspot-tooltip[style*="--ih-scale"] .ih-tooltip-link {
    font-size: 14px; /* Fixed size */
}

/* ==========================================================================
   Slider-specific tooltip constraints
   ========================================================================== */

/* Tooltips in sliders use RELATIVE width (set by JS), not fixed */
/* Override global --ih-tooltip-width for sliders - JS sets actual width */
.ih-slider-overlay .ih-hotspot-tooltip {
    width: auto !important; /* Let JS control width */
    max-width: none; /* Remove fixed max - JS sets this relative to container */
    box-sizing: border-box;
    z-index: 999999 !important; /* Ensure tooltip is ALWAYS on top */
}

/* Allow tooltip to extend outside slider - ALL content must be visible */
.ih-slider-overlay {
    overflow: visible !important;
}

/* Ensure parent containers don't clip the tooltip */
.ih-slider-overlay .ih-hotspot-marker {
    z-index: 999998;
}

/* Fallback if JS hasn't set width yet */
.ih-slider-overlay .ih-hotspot-tooltip:not([style*="max-width"]) {
    max-width: min(85%, calc(100vw - 40px));
}

/* ==========================================================================
   Compact Layout Classes (v1.0.46)
   Used when space is limited - ALL content visible, just more condensed
   ========================================================================== */

/* COMPACT: Narrow containers (<300px width) - smaller fonts/spacing only */
.ih-hotspot-tooltip.ih-compact {
    padding: 10px !important;
}

.ih-hotspot-tooltip.ih-compact .ih-tooltip-title {
    font-size: 14px !important;
    margin-bottom: 6px !important;
}

.ih-hotspot-tooltip.ih-compact .ih-tooltip-description {
    font-size: 12px !important;
    margin-bottom: 8px !important;
    line-height: 1.4 !important;
}

/* Keep images side-by-side, just smaller */
.ih-hotspot-tooltip.ih-compact .ih-tooltip-image {
    max-height: 80px !important;
}

.ih-hotspot-tooltip.ih-compact .ih-tooltip-link {
    font-size: 12px !important;
}

/* ULTRA-COMPACT: Very narrow containers (<200px width) */
.ih-hotspot-tooltip.ih-ultra-compact {
    padding: 8px !important;
}

.ih-hotspot-tooltip.ih-ultra-compact .ih-tooltip-title {
    font-size: 12px !important;
    margin-bottom: 4px !important;
}

.ih-hotspot-tooltip.ih-ultra-compact .ih-tooltip-description {
    font-size: 11px !important;
    margin-bottom: 6px !important;
    line-height: 1.3 !important;
}

/* Only stack images in ULTRA-compact when really needed */
.ih-hotspot-tooltip.ih-ultra-compact .ih-tooltip-image {
    max-height: 60px !important;
}

.ih-hotspot-tooltip.ih-ultra-compact .ih-tooltip-link {
    font-size: 11px !important;
}

/* Constrain images in slider tooltips */
.ih-slider-overlay .ih-tooltip-images {
    flex-wrap: wrap;
    justify-content: center;
}

.ih-slider-overlay .ih-tooltip-image {
    max-width: 100%;
    object-fit: contain;
}

.ih-slider-overlay .ih-images-double .ih-tooltip-image {
    max-width: calc(50% - 4px);
    object-fit: contain;
}

/* Empty tooltip (no content) - minimal styling */
.ih-tooltip-empty {
    display: none !important;
}

/* Dynamic sizing - remove margins on empty/last elements */
.ih-tooltip-title:last-child {
    margin-bottom: 0;
}

.ih-tooltip-description:last-child {
    margin-bottom: 0;
}

.ih-tooltip-images:last-child {
    margin-bottom: 0;
}

.ih-tooltip-images:first-child {
    margin-top: 0;
}

/* Adjust spacing when images follow description */
.ih-tooltip-description + .ih-tooltip-images {
    margin-top: 8px;
}

/* Adjust spacing when link follows images */
.ih-tooltip-images + .ih-tooltip-link {
    margin-top: 8px;
}

/* ==========================================================================
   Tooltip Close Button
   ========================================================================== */

.ih-tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--ih-tooltip-text);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--ih-animation-speed) ease,
                transform var(--ih-animation-speed) ease;
    z-index: 10;
}

.ih-tooltip-close:hover {
    background: rgba(0, 0, 0, 0.2);
    transform: scale(1.1);
}

.ih-tooltip-close:focus {
    outline: 2px solid var(--ih-primary);
    outline-offset: 2px;
}

/* Adjust tooltip content when close button is present */
.ih-hotspot-tooltip:has(.ih-tooltip-close) .ih-tooltip-title {
    padding-right: 24px;
}

/* ==========================================================================
   Mobile/Touch Styles
   ========================================================================== */

@media (max-width: 768px) {
    :root {
        --ih-dot-size: 16px;
        --ih-pulse-size: 40px;
    }

    /* Tooltip max 85% of container on tablet - override fixed width */
    .ih-hotspot-tooltip {
        width: auto;
        min-width: 200px;
        max-width: 85%;
    }

    /* On mobile, disable hover - only show on click/tap */
    .ih-hotspot-marker:hover .ih-hotspot-tooltip {
        opacity: 0;
        visibility: hidden;
    }

    .ih-hotspot-marker.ih-active .ih-hotspot-tooltip {
        opacity: 1;
        visibility: visible;
    }
}

@media (max-width: 480px) {
    :root {
        --ih-dot-size: 18px;
        --ih-tooltip-padding: 10px;
    }

    /* Tooltip max 80% of container on small mobile */
    .ih-hotspot-tooltip {
        width: auto;
        min-width: 180px;
        max-width: 80%;
        font-size: 13px;
    }

    .ih-tooltip-title {
        font-size: 14px;
    }

    .ih-tooltip-description,
    .ih-tooltip-link {
        font-size: 12px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .ih-hotspot-marker {
        display: none;
    }
}

/* ==========================================================================
   Reduced Motion Preference
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .ih-hotspot-pulse {
        animation: none;
    }

    .ih-hotspot-dot,
    .ih-hotspot-tooltip,
    .ih-tooltip-link,
    .ih-link-arrow {
        transition: none;
    }
}

/* ==========================================================================
   Tooltip Portal (v1.0.46)
   Body-level container for slider tooltips to escape overflow:hidden
   Ensures ALL tooltip content is ALWAYS visible - NEVER clipped
   ========================================================================== */

/* Portal container - appended to body by JavaScript */
#ih-tooltip-portal,
.ih-tooltip-portal {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    overflow: visible;
    z-index: 9999999; /* Above everything */
    pointer-events: none; /* Don't block page interactions */
}

/* Portal tooltips - rendered inside portal - HIDDEN by default */
.ih-portal-tooltip {
    position: fixed !important;
    pointer-events: none;
    /* Width constraints - match main tooltip */
    width: var(--ih-tooltip-width, 280px);
    max-width: var(--ih-tooltip-width, 280px);
    min-width: 200px;
    /* Visual styling */
    background-color: var(--ih-tooltip-bg, #ffffff);
    color: var(--ih-tooltip-text, #333333);
    font-family: var(--ih-tooltip-font, inherit);
    border-radius: var(--ih-tooltip-border-radius, 8px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.25), 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: var(--ih-tooltip-padding, 16px);
    line-height: 1.5;
    text-align: left;
    z-index: 9999999 !important;
    /* Content containment */
    box-sizing: border-box;
    overflow: visible;
    /* HIDDEN by default - JS adds .ih-visible to show */
    opacity: 0;
    visibility: hidden;
    display: none;
}

/* Force ALL text elements in portal tooltip to inherit font */
.ih-portal-tooltip *,
.ih-portal-tooltip *::before,
.ih-portal-tooltip *::after {
    font-family: inherit;
}

/* Portal tooltip VISIBLE state - controlled by JS adding .ih-visible class */
.ih-portal-tooltip.ih-visible {
    opacity: 1 !important;
    visibility: visible !important;
    display: block !important;
    pointer-events: auto !important;
}

/* RAF sync approach - tooltip now travels WITH hotspot during scroll */
/* The tooltip position is continuously updated via requestAnimationFrame */
/* Auto-closes when marker scrolls out of viewport (handled in JS) */

/* Ensure links are clickable in portal tooltips on all devices */
.ih-portal-tooltip.ih-visible .ih-tooltip-link {
    pointer-events: auto !important;
    cursor: pointer;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

/* CRITICAL: Override original .ih-hotspot-tooltip styles when used as portal */
.ih-portal-tooltip.ih-hotspot-tooltip {
    /* Reset ONLY the transform - JS handles top/left positioning */
    position: fixed !important;
    transform: none !important;
    bottom: auto !important;
    /* Ensure proper block layout for content containment */
    display: block;
    overflow: visible !important;
}

/* Hide any ::before pseudo-element on portal tooltips */
.ih-portal-tooltip.ih-hotspot-tooltip::before {
    content: none !important;
    display: none !important;
}

/* Portal tooltip arrow - single arrow pointing to hotspot */
/* Use .ih-portal-tooltip.ih-hotspot-tooltip for higher specificity to override inherited styles */
.ih-portal-tooltip.ih-hotspot-tooltip::after {
    content: '' !important;
    display: none !important; /* Hidden by default */
    position: absolute !important;
    width: 0 !important;
    height: 0 !important;
    border: 10px solid transparent !important;
    left: 50% !important;
    transform: translateX(calc(-50% + var(--arrow-offset, 0px))) !important;
    z-index: 1 !important;
    /* Reset inherited positioning from .ih-hotspot-tooltip::after */
    top: auto !important;
    bottom: auto !important;
    border-top-color: transparent !important;
    border-bottom-color: transparent !important;
}

/* Arrow VISIBLE when tooltip has .ih-visible class */
.ih-portal-tooltip.ih-hotspot-tooltip.ih-visible::after {
    display: block !important;
}

/* Arrow pointing UP (tooltip is BELOW hotspot) */
.ih-portal-tooltip.ih-hotspot-tooltip[data-position-y="below"]::after {
    top: -20px !important;
    bottom: auto !important;
    border-bottom-color: var(--ih-tooltip-bg, #ffffff) !important;
    border-top-color: transparent !important;
}

/* Arrow pointing DOWN (tooltip is ABOVE hotspot) */
.ih-portal-tooltip.ih-hotspot-tooltip[data-position-y="above"]::after {
    bottom: -20px !important;
    top: auto !important;
    border-top-color: var(--ih-tooltip-bg, #ffffff) !important;
    border-bottom-color: transparent !important;
}

/* Horizontal positioning adjustments for arrow */
.ih-portal-tooltip.ih-hotspot-tooltip[data-position-x="left"]::after {
    left: 24px !important;
    transform: translateX(0) !important;
}

.ih-portal-tooltip.ih-hotspot-tooltip[data-position-x="right"]::after {
    left: auto !important;
    right: 24px !important;
    transform: translateX(0) !important;
}

/* Portal tooltip content styling - inherit from main tooltip */
.ih-portal-tooltip .ih-tooltip-title {
    margin: 0 0 8px 0;
    padding-right: 24px; /* Space for close button */
    font-size: 16px;
    font-weight: 600;
    color: var(--ih-tooltip-title, var(--ih-tooltip-text, #333333));
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ih-portal-tooltip .ih-tooltip-description {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: var(--ih-tooltip-text, #666666);
    line-height: 1.5;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ih-portal-tooltip .ih-tooltip-description:last-child {
    margin-bottom: 0;
}

/* Budget and additional info fields for portal */
.ih-portal-tooltip .ih-tooltip-budget {
    margin: 4px 0;
    font-size: 12px;
    line-height: 1.3;
    color: var(--ih-tooltip-text, #555555);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ih-portal-tooltip .ih-tooltip-budget strong {
    font-family: inherit;
    font-weight: 600;
    color: var(--ih-tooltip-title, #333333);
}

.ih-portal-tooltip .ih-tooltip-additional {
    margin: 4px 0;
    font-size: 12px;
    line-height: 1.3;
    color: var(--ih-tooltip-text, #666666);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ih-portal-tooltip .ih-tooltip-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
    width: 100%;
    box-sizing: border-box;
}

.ih-portal-tooltip .ih-tooltip-image {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    object-fit: contain; /* contain instead of cover to prevent cropping */
    display: block;
}

.ih-portal-tooltip .ih-images-single .ih-tooltip-image {
    max-width: 100%;
    width: auto;
    margin: 0 auto; /* center if narrower than container */
}

.ih-portal-tooltip .ih-images-double .ih-tooltip-image {
    width: calc(50% - 4px);
    max-width: calc(50% - 4px);
    height: auto; /* let images show at natural height */
    flex-shrink: 0;
    object-fit: contain;
}

/* Image wrapper for portal tooltips */
.ih-portal-tooltip .ih-image-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.ih-portal-tooltip .ih-images-single .ih-image-wrapper {
    width: 100%;
}

.ih-portal-tooltip .ih-images-double .ih-image-wrapper {
    width: calc(50% - 4px);
    flex-shrink: 0;
}

.ih-portal-tooltip .ih-images-double .ih-image-wrapper .ih-tooltip-image {
    width: 100%;
    max-width: 100%;
}

/* Image caption styling for portal tooltips - matches description text */
.ih-portal-tooltip .ih-image-caption {
    display: block;
    font-size: 14px;
    color: var(--ih-tooltip-text, #666666);
    text-align: center;
    line-height: 1.5;
    margin-top: 6px;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Portal tooltip image scaling */
.ih-portal-tooltip .ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5)) !important;
    max-height: calc(200px * var(--ih-image-scale, 0.5));
}

.ih-portal-tooltip .ih-images-single .ih-tooltip-image {
    max-width: calc(100% * var(--ih-image-scale, 0.5)) !important;
    margin: 0 auto;
}

.ih-portal-tooltip .ih-images-double .ih-tooltip-image {
    max-width: 100% !important;
    max-height: calc(150px * var(--ih-image-scale, 0.5));
}

.ih-portal-tooltip .ih-tooltip-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--ih-tooltip-link, var(--ih-primary, #3498db));
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.ih-portal-tooltip .ih-tooltip-link:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* Portal tooltip close button */
.ih-portal-tooltip .ih-tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--ih-tooltip-text, #333333);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.ih-portal-tooltip .ih-tooltip-close:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Portal compact classes */
.ih-portal-tooltip.ih-compact {
    padding: 10px !important;
}

.ih-portal-tooltip.ih-compact .ih-tooltip-title {
    font-size: 14px !important;
    margin-bottom: 6px !important;
}

.ih-portal-tooltip.ih-compact .ih-tooltip-description {
    font-size: 12px !important;
    margin-bottom: 8px !important;
}

.ih-portal-tooltip.ih-compact .ih-tooltip-image {
    max-height: 80px !important;
}

.ih-portal-tooltip.ih-compact .ih-tooltip-link {
    font-size: 12px !important;
}

.ih-portal-tooltip.ih-ultra-compact {
    padding: 8px !important;
}

.ih-portal-tooltip.ih-ultra-compact .ih-tooltip-title {
    font-size: 12px !important;
    margin-bottom: 4px !important;
}

.ih-portal-tooltip.ih-ultra-compact .ih-tooltip-description {
    font-size: 11px !important;
    margin-bottom: 6px !important;
}

.ih-portal-tooltip.ih-ultra-compact .ih-tooltip-image {
    max-height: 60px !important;
}

.ih-portal-tooltip.ih-ultra-compact .ih-tooltip-link {
    font-size: 11px !important;
}
