/**
 * TurnKey Directories 2.0 - Layout Fixes
 * Fixes for layout issues including top gap on business listings
 */

/* NUCLEAR OPTION - Remove ALL top spacing on business listing pages */

/* Remove margin from html tag when admin bar is hidden or on listing page */
html:has(body.tkd-listing-page) {
    margin-top: 0 !important;
}

/* Fallback for browsers that don't support :has() - target body with negative margin if needed, 
   but preferably we rely on the single-listing.php inline style. 
   This CSS file is mainly for external stylesheet approach. */

/* Target body element on single listing pages */
body.single-turnkeydir_listing,
body.single-listing,
body.tkd-listing-page,
body[class*="single"] .glass-business-container {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Remove top spacing from all WordPress theme wrappers */
body.single-turnkeydir_listing #page,
body.single-turnkeydir_listing .site,
body.single-turnkeydir_listing .site-content,
body.single-turnkeydir_listing .content-area,
body.single-turnkeydir_listing .site-main,
body.single-turnkeydir_listing main,
body.single-turnkeydir_listing article,
body.single-listing #page,
body.single-listing .site,
body.single-listing .site-content,
body.single-listing .content-area,
body.single-listing .site-main,
body.single-listing main,
body.single-listing article,
body.tkd-listing-page #page,
body.tkd-listing-page .site,
body.tkd-listing-page .site-content,
body.tkd-listing-page .content-area,
body.tkd-listing-page .site-main,
body.tkd-listing-page main,
body.tkd-listing-page article {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Ensure the glass container has correct spacing */
.glass-business-container {
    margin-top: 0 !important;
    padding-top: 30px !important; /* Add separation from header */
}

/* Remove spacing from entry content */
.entry-content,
.entry-content > *:first-child {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Override any theme container spacing */
.container,
.container-fluid,
.wrapper,
.content-wrapper,
.main-content {
    padding-top: 0 !important;
    margin-top: 0 !important;
}

/* Fix for admin bar - ensure no top spacing even with admin bar */
body.admin-bar .glass-business-container {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Override WordPress default content margins */
#content,
#primary,
.primary-content {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Mobile responsive */
@media (max-width: 768px) {
    html:has(body.tkd-listing-page) {
        margin-top: 0 !important;
    }

    body.single-turnkeydir_listing,
    body.single-listing,
    body.tkd-listing-page {
        padding-top: 0 !important;
    }
    
    .glass-business-container {
        margin-top: 0 !important;
        padding-top: 20px !important; /* Slightly less on mobile */
    }
}

@media (max-width: 480px) {
    .glass-business-container {
        margin-top: 0 !important;
        padding-top: 15px !important; /* Minimal on small screens */
    }
}

/* ============================================
   v2.16.20 — MAPILLARY OVERLAY TEXT STAYS WHITE
   ============================================
   single-listing.php gives the street-view overlay <p>s an inline
   color:#fff — but the bundle's global typography rules
   (`p { color: var(--tkd-text-color-secondary) !important }` and
   friends) carry !important, and !important beats inline styles.
   That is why the overlay text rendered grey through two rounds of
   inline fixes (§14 A1). This file loads AFTER the bundle (it
   depends on turnkeydir-bundle), so an equal-weight, higher-specificity
   rule here wins the cascade. Covers the pre-click overlay text and
   the post-click loading caption. */
.mapillary-progressive-container .mapillary-click-overlay p,
.mapillary-progressive-container .mapillary-loading-spinner p,
body .mapillary-progressive-container .mapillary-click-overlay p,
body .mapillary-progressive-container .mapillary-loading-spinner p {
    color: #fff !important;
}
