/**
 * Golf Handicap & Slope Calculator - Override Styles
 * Kompakt layout basert på Atlungstad design
 */

/* Fikser størrelsen på SVG-ikonet */
.calc-icon {
    width: 24px !important;
    height: 24px !important;
    margin-right: 10px !important;
    fill: var(--primary-color) !important;
}

/* EKSTREMT aggressiv whitespace-fjerning */

/* Hovedcontainer med ekstra aggressiv negativ margin */
.handicap-calculator,
.entry-content .handicap-calculator {
    margin: 20px 0 -100px 0 !important;
    position: relative !important;
    padding: 1rem 1.5rem 1.5rem 1.5rem !important; /* Redusert padding for kompakt layout */
}

/* Dobbel hack for å fjerne all whitespace */
.handicap-calculator::after {
    content: "" !important;
    display: block !important;
    height: 0 !important;
    margin-bottom: -80px !important;
    position: relative !important;
}

/* Ekstra hack med before pseudo-element */
.handicap-calculator::before {
    content: "" !important;
    display: block !important;
    height: 0 !important;
    margin-top: -20px !important;
}

/* Fjern ALL whitespace fra WordPress containere */
.entry-content:has(.handicap-calculator) {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* WordPress block wrappers - null alt */
.wp-block-group:has(.handicap-calculator),
.wp-block-group__inner-container:has(.handicap-calculator),
[class*="wp-container-"]:has(.handicap-calculator),
[class*="wp-block-"]:has(.handicap-calculator) {
    padding: 0 !important;
    margin: 0 !important;
    min-height: 0 !important;
    height: auto !important;
}

/* Alle parent elementer - null padding/margin */
*:has(> .handicap-calculator) {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
}

/* Parent til parent - enda mer aggressiv */
*:has(> *:has(> .handicap-calculator)) {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Override alt på article/main nivå */
article:has(.handicap-calculator),
main:has(.handicap-calculator),
.site-main:has(.handicap-calculator),
.site-content:has(.handicap-calculator),
.entry-content:has(.handicap-calculator) {
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* Neste element etter kalkulatoren - reduser margin */
.handicap-calculator + * {
    margin-top: 20px !important;
}

/* Wrapper divs etter kalkulatoren */
div:has(> .handicap-calculator) + * {
    margin-top: 20px !important;
}

/* Siste element før footer - minimal margin */
body > *:last-child:has(.handicap-calculator),
.site-main > *:last-child:has(.handicap-calculator),
.entry-content:last-child:has(.handicap-calculator) {
    margin-bottom: 40px !important;
}

/* Fjern all padding på entry-content */
.entry-content {
    padding-bottom: 0 !important;
}

/* Target WordPress's auto-generated spacing */
.wp-block-spacer {
    display: none !important;
    height: 0 !important;
}

/* Fjern spacing blocks rundt kalkulatoren */
.handicap-calculator + .wp-block-spacer,
.wp-block-spacer + .handicap-calculator,
*:has(+ .handicap-calculator) > .wp-block-spacer {
    display: none !important;
}

/* Remove ALL theme-specific spacing */
.entry-content > :last-child,
.entry-content > *:has(.handicap-calculator):last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* Mobile justering - litt mindre aggressiv */
@media (max-width: 768px) {
    .handicap-calculator,
    .entry-content .handicap-calculator {
        margin-bottom: -80px !important;
    }
    
    .handicap-calculator::after {
        margin-bottom: -60px !important;
    }
}

/* Override for høy spesifisitet temaer */
div.handicap-calculator,
.entry-content div.handicap-calculator,
main .handicap-calculator,
article .handicap-calculator,
#content .handicap-calculator,
.site .handicap-calculator {
    margin-bottom: -100px !important;
}

/* Fix for temaer som bruker flexbox/grid */
.entry-content:has(.handicap-calculator) {
    display: block !important;
}

/* Responsive mobile/desktop toggle */
@media (min-width: 769px) {
    .handicap-calculator .mobile-calculator {
        display: none !important;
    }
    .handicap-calculator .desktop-calculator {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .handicap-calculator .desktop-calculator {
        display: none !important;
    }
    .handicap-calculator .mobile-calculator {
        display: block !important;
    }
}

/* Nuclear option - fjern alt mellom kalkulator og neste element */
.handicap-calculator ~ :empty,
.handicap-calculator ~ br,
.handicap-calculator ~ p:empty {
    display: none !important;
}
