/**
 * Mana Location Gating Styles
 *
 * Controls visibility of location-specific sections
 * and the dedicated location picker popup.
 *
 * @package Mana_Elementor_Widgets
 * @since 1.6.0
 */

/* ===========================================
   Location-Based Section Visibility
   =========================================== */

/**
 * Hide all location-specific sections by default.
 * Positions sections off-screen instead of height:0 so that third-party
 * embeds (Dutchie iframes) can initialize with correct dimensions.
 * height:0 and display:none both collapse child geometry, causing
 * embeds to render at 0px height and never recover when later shown.
 */
[data-location] {
    position: fixed !important;
    left: 0 !important;
    top: -200vh !important;
    width: 100% !important;
    visibility: hidden !important;
    pointer-events: none !important;
    z-index: -1 !important;
}

/**
 * Show sections when they have the visible class
 * JS adds this class when the section's location matches selected location
 */
[data-location].mana-location-visible {
    position: static !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: auto !important;
}

/**
 * Elementor editor: show all location sections for editing
 */
.elementor-editor-active [data-location],
.elementor-editor-preview [data-location] {
    position: relative !important;
    left: auto !important;
    top: auto !important;
    width: auto !important;
    visibility: visible !important;
    pointer-events: auto !important;
    z-index: auto !important;
}

/**
 * Editor indicator - shows which location a section is for
 */
.elementor-editor-active [data-location]::before {
    content: 'Location: ' attr(data-location);
    position: absolute;
    top: 0;
    left: 0;
    background: #0D4F43;
    color: #fff;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 100;
    border-bottom-right-radius: 4px;
}


/* ===========================================
   Location Picker Popup
   =========================================== */

.mana-lp {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999998; /* Just below age gate */
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.mana-lp.active {
    opacity: 1;
    visibility: visible;
}

/* Overlay */
.mana-lp-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(13, 79, 67, 0.95);
    cursor: not-allowed;
}

/* Container */
.mana-lp-container {
    position: relative;
    z-index: 1;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

/* Content */
.mana-lp-content {
    background: #ffffff;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
}

/* Title */
.mana-lp-title {
    font-family: 'Gotham Rounded', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 32px;
    font-weight: 500;
    color: #0D4F43;
    margin: 0 0 12px 0;
    line-height: 1.2;
}

/* Subtitle */
.mana-lp-subtitle {
    font-family: 'Gotham', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 16px;
    font-weight: 400;
    color: #666666;
    margin: 0 0 32px 0;
    line-height: 1.4;
}

/* Cards container */
.mana-lp-cards {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Location card button */
.mana-lp-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 24px;
    background: #f8f8f8;
    border: 2px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.mana-lp-card:hover {
    background: #0D4F43;
    border-color: #0D4F43;
}

.mana-lp-card:hover .mana-lp-card-name,
.mana-lp-card:hover .mana-lp-card-address {
    color: #ffffff;
}

.mana-lp-card:focus {
    outline: none;
    border-color: #F2AD2D;
}

/* Disabled state (coming soon) */
.mana-lp-card--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mana-lp-card--disabled:hover {
    background: #f8f8f8;
    border-color: transparent;
}

.mana-lp-card--disabled:hover .mana-lp-card-name,
.mana-lp-card--disabled:hover .mana-lp-card-address {
    color: inherit;
}

/* Card name */
.mana-lp-card-name {
    font-family: 'Gotham Rounded', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 20px;
    font-weight: 500;
    color: #0D4F43;
    margin-bottom: 4px;
    transition: color 0.2s ease;
}

/* Card address */
.mana-lp-card-address {
    font-family: 'Gotham', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    font-weight: 400;
    color: #666666;
    line-height: 1.4;
    transition: color 0.2s ease;
}

/* Required message */
.mana-lp-required-message {
    background: #F2AD2D;
    color: #0D4F43;
    padding: 12px 20px;
    border-radius: 8px;
    text-align: center;
    font-family: 'Gotham', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 20px;
    animation: mana-lp-fadeIn 0.3s ease;
}

.mana-lp-required-message.shake {
    animation: mana-lp-shake 0.5s ease;
}

@keyframes mana-lp-shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

@keyframes mana-lp-fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}


/* ===========================================
   Pre-Selection State
   =========================================== */

/**
 * Optional: Add a loading/placeholder state before location is selected
 * This prevents layout shift when sections appear
 */
body:not(.mana-location-selected) [data-location-placeholder] {
    display: block !important;
}

body.mana-location-selected [data-location-placeholder] {
    display: none !important;
}


/* ===========================================
   Responsive Adjustments
   =========================================== */

@media (max-width: 767px) {
    .mana-lp-content {
        padding: 30px 24px;
    }

    .mana-lp-title {
        font-size: 26px;
    }

    .mana-lp-subtitle {
        font-size: 14px;
        margin-bottom: 24px;
    }

    .mana-lp-card {
        padding: 16px 20px;
    }

    .mana-lp-card-name {
        font-size: 18px;
    }

    .mana-lp-card-address {
        font-size: 13px;
    }

    .mana-lp-required-message {
        font-size: 13px;
        padding: 10px 16px;
        margin-bottom: 16px;
    }
}
