/* ================================================================
   AgriNovel – Liquid Glass Author Card
   Target: agriculturenovel.co  |  Author: Ranjeet Natarajan
   Apple-inspired glassmorphism, 2025-grade CSS
   ================================================================ */

/* ---------- 1. AD SUPPRESSION ---------- */
/* PayRupik & generic bottom ad networks */
[class*="payrupik"],
[id*="payrupik"],
[class*="PayRupik"],
iframe[src*="payrupik"],
iframe[src*="loan"],
div[data-ad-unit],
.adsbygoogle,
ins.adsbygoogle,
[id^="google_ads_iframe"],
.ad-container,
.bottom-ad,
.post-ad,
[class*="ad-banner"],
[class*="ad_banner"],
[class*="advertisement"]:not(.agnovel-card),
[class*="sponsored-content"]:not(.agnovel-card),
/* Common loan / fintech ad wrappers */
div:has(> iframe[src*="loan"]),
div:has(> iframe[src*="credit"]),
div:has(> iframe[src*="rupik"]) {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* ---------- 2. CSS CUSTOM PROPERTIES ---------- */
:root {
    /* Liquid Glass palette */
    --lg-tint:          rgba(255, 255, 255, 0.18);
    --lg-tint-hover:    rgba(255, 255, 255, 0.28);
    --lg-border:        rgba(255, 255, 255, 0.40);
    --lg-shadow:        0 8px 48px rgba(0, 0, 0, 0.22),
                        0 2px 12px rgba(0, 0, 0, 0.14),
                        inset 0 1px 0 rgba(255,255,255,0.55);
    --lg-shadow-hover:  0 20px 72px rgba(0, 0, 0, 0.30),
                        0 4px 20px rgba(0, 0, 0, 0.18),
                        inset 0 1px 0 rgba(255,255,255,0.70);

    /* AgriNovel greens */
    --ag-green:         #2d7a3a;
    --ag-green-light:   #4caf6a;
    --ag-green-glow:    rgba(45, 122, 58, 0.35);

    /* Motion */
    --ease-spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-smooth:      cubic-bezier(0.25, 0.46, 0.45, 0.94);

    /* Layout */
    --card-w:           340px;
    --card-radius:      28px;
    --avatar-size:      68px;
}

/* ---------- 3. BACKDROP OVERLAY ---------- */
#agnovel-overlay {
    position: fixed;
    inset: 0;
    z-index: 99998;
    background: rgba(0, 0, 0, 0.38);
    backdrop-filter: blur(4px) saturate(120%);
    -webkit-backdrop-filter: blur(4px) saturate(120%);
    opacity: 0;
    transition: opacity 0.35s var(--ease-smooth);
    pointer-events: none;
}

#agnovel-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- 4. POPUP CARD CONTAINER ---------- */
#agnovel-popup {
    position: fixed;
    bottom: -420px;                       /* slides up from below */
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999;
    width: var(--card-w);
    max-width: calc(100vw - 32px);

    /* Liquid Glass core */
    background: var(--lg-tint);
    backdrop-filter: blur(40px) saturate(180%) brightness(115%);
    -webkit-backdrop-filter: blur(40px) saturate(180%) brightness(115%);

    border: 1.5px solid var(--lg-border);
    border-radius: var(--card-radius);
    box-shadow: var(--lg-shadow);

    padding: 0;
    overflow: hidden;

    transition: bottom 0.62s var(--ease-spring),
                box-shadow 0.3s var(--ease-smooth);

    /* Subtle inner gradient for depth */
    background-image:
        linear-gradient(
            145deg,
            rgba(255, 255, 255, 0.32) 0%,
            rgba(255, 255, 255, 0.06) 50%,
            rgba(255, 255, 255, 0.18) 100%
        );
}

#agnovel-popup.open {
    bottom: 20px;
    box-shadow: var(--lg-shadow-hover);
}

/* ---------- 5. GREEN TOP ACCENT BAR ---------- */
#agnovel-popup::before {
    content: '';
    display: block;
    height: 4px;
    background: linear-gradient(
        90deg,
        var(--ag-green) 0%,
        var(--ag-green-light) 50%,
        var(--ag-green) 100%
    );
    border-radius: var(--card-radius) var(--card-radius) 0 0;
    box-shadow: 0 0 16px var(--ag-green-glow);
}

/* ---------- 6. SPECULAR HIGHLIGHT ---------- */
#agnovel-popup::after {
    content: '';
    pointer-events: none;
    position: absolute;
    top: 4px;
    left: 12px;
    right: 12px;
    height: 50%;
    background: linear-gradient(
        to bottom,
        rgba(255,255,255,0.22) 0%,
        rgba(255,255,255,0.00) 100%
    );
    border-radius: 20px 20px 40% 40% / 12px 12px 100% 100%;
    pointer-events: none;
}

/* ---------- 7. CARD INNER LAYOUT ---------- */
.agnovel-inner {
    padding: 22px 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* ---------- 8. HEADER ROW (avatar + text) ---------- */
.agnovel-header {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 14px;
}

/* Avatar */
.agnovel-avatar-wrap {
    flex-shrink: 0;
    width: var(--avatar-size);
    height: var(--avatar-size);
    border-radius: 50%;
    position: relative;

    /* Liquid ring */
    background: linear-gradient(135deg, rgba(255,255,255,0.55), rgba(255,255,255,0.10));
    padding: 3px;
    box-shadow:
        0 0 0 1.5px rgba(255,255,255,0.40),
        0 4px 16px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.60);
}

.agnovel-avatar {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    background: linear-gradient(135deg, var(--ag-green) 0%, var(--ag-green-light) 100%);
}

/* Fallback monogram when no photo */
.agnovel-avatar-fallback {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--ag-green) 0%, var(--ag-green-light) 100%);
    font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    letter-spacing: -0.5px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.25);
}

/* Text side */
.agnovel-meta {
    flex: 1;
    min-width: 0;
}

.agnovel-name {
    font-family: -apple-system, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.4px;
    color: #fff;
    text-shadow: 0 1px 4px rgba(0,0,0,0.30);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0 0 2px;
    line-height: 1.2;
}

.agnovel-role {
    font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.72);
    letter-spacing: 0.3px;
    text-transform: uppercase;
    margin: 0;
    line-height: 1.3;
}

/* ---------- 9. DIVIDER ---------- */
.agnovel-divider {
    height: 1px;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.30) 30%,
        rgba(255,255,255,0.30) 70%,
        transparent 100%
    );
    margin: 0 0 14px;
}

/* ---------- 10. BIO ---------- */
.agnovel-bio {
    font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 1px 2px rgba(0,0,0,0.20);
    margin: 0 0 16px;
}

/* ---------- 11. CTA BUTTON ---------- */
.agnovel-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 20px;
    border-radius: 18px;
    border: 1.5px solid rgba(255, 255, 255, 0.40);
    cursor: pointer;
    text-decoration: none;

    /* Glass button */
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.22) 0%,
        rgba(255, 255, 255, 0.06) 100%
    );
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow:
        0 2px 10px rgba(0,0,0,0.12),
        inset 0 1px 0 rgba(255,255,255,0.45);

    font-family: -apple-system, 'SF Pro Text', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    letter-spacing: -0.1px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.25);

    transition:
        background 0.22s var(--ease-smooth),
        transform  0.18s var(--ease-spring),
        box-shadow 0.22s var(--ease-smooth);

    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.agnovel-cta:hover,
.agnovel-cta:focus-visible {
    background: linear-gradient(
        135deg,
        rgba(255, 255, 255, 0.32) 0%,
        rgba(255, 255, 255, 0.14) 100%
    );
    box-shadow:
        0 4px 20px rgba(0,0,0,0.18),
        inset 0 1px 0 rgba(255,255,255,0.60);
    transform: translateY(-1px);
    text-decoration: none;
    color: #fff;
}

.agnovel-cta:active {
    transform: scale(0.97) translateY(0px);
}

.agnovel-cta-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

/* ---------- 12. CLOSE BUTTON ---------- */
.agnovel-close {
    position: absolute;
    top: 14px;
    right: 14px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.35);
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, transform 0.18s var(--ease-spring);
    z-index: 1;
    -webkit-tap-highlight-color: transparent;
}

.agnovel-close:hover {
    background: rgba(255,255,255,0.28);
    transform: scale(1.10);
}

.agnovel-close:active {
    transform: scale(0.93);
}

/* ---------- 13. LEAF BADGE ---------- */
.agnovel-leaf-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px 4px 8px;
    border-radius: 20px;
    background: rgba(45, 122, 58, 0.28);
    border: 1px solid rgba(76, 175, 106, 0.40);
    font-size: 11px;
    font-weight: 600;
    color: rgba(160, 230, 160, 0.95);
    letter-spacing: 0.2px;
    margin-bottom: 12px;
    width: fit-content;
}

.agnovel-leaf-badge span:first-child {
    font-size: 13px;
}

/* ---------- 14. BACKGROUND – site-level gradient for glass effect ---------- */
/* Only fires when popup is open so non-intrusive */
body.agnovel-open {
    /* push page content slightly; glass reads better against colour */
}

/* ---------- 15. REDUCED MOTION ---------- */
@media (prefers-reduced-motion: reduce) {
    #agnovel-popup,
    .agnovel-cta,
    .agnovel-close {
        transition: none !important;
        animation: none !important;
    }
}

/* ---------- 16. DARK MODE TWEAKS ---------- */
@media (prefers-color-scheme: dark) {
    #agnovel-popup {
        background-image:
            linear-gradient(
                145deg,
                rgba(255, 255, 255, 0.14) 0%,
                rgba(255, 255, 255, 0.04) 50%,
                rgba(255, 255, 255, 0.10) 100%
            );
    }
}

/* ---------- 17. MOBILE POLISH ---------- */
@media (max-width: 400px) {
    :root {
        --card-w: calc(100vw - 24px);
    }

    #agnovel-popup.open {
        bottom: 12px;
    }
}
