﻿/* ==========================================================================
   VINDHYA MILLETS — PRODUCTION OFFLINE EXPERIENCE v3.2
   Strict Zero-Scroll · Pure Single Screen · 3D Tactile · Zero Glitches
   ========================================================================== */

:root {
    --vm-green-deep:   #0F2E1B;
    --vm-green-forest: #166534;
    --vm-green-mid:    #15803D;
    --vm-green-light:  #DCFCE7;
    --vm-terra:        #C25E1A;
    --vm-cream:        #FAF9F5;
    --vm-muted:        #64748B;
    --vm-border-glass: rgba(255, 255, 255, 0.9);
}

/* ── 1. Global Viewport Lock When Offline (Zero Leaks, Zero Scroll) ──────── */
html.vm-is-offline,
body.vm-is-offline {
    overflow: hidden !important;
    height: 100% !important;
    height: 100vh !important;
    height: 100dvh !important;
    width: 100% !important;
    position: fixed !important;
    inset: 0 !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
    background: #FAF9F5 !important;
}

/* Force-hide ALL progressbars and floating elements when offline */
html.vm-is-offline .reading-progress-bar,
body.vm-is-offline .reading-progress-bar,
html.vm-is-offline #vm-nano-bar,
body.vm-is-offline #vm-nano-bar,
html.vm-is-offline #readingProgressBar,
body.vm-is-offline #readingProgressBar,
html.vm-is-offline .mobile-bottom-dock,
body.vm-is-offline .mobile-bottom-dock,
html.vm-is-offline .floating-whatsapp,
body.vm-is-offline .floating-whatsapp,
html.vm-is-offline .whatsapp-btn,
body.vm-is-offline .whatsapp-btn,
html.vm-is-offline .scroll-top-btn,
body.vm-is-offline .scroll-top-btn,
html.vm-is-offline header,
body.vm-is-offline header,
html.vm-is-offline .site-header,
body.vm-is-offline .site-header {
    display: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

/* ── 2. Full-Screen Fixed Overlay (Max Z-Index, Absolute 0-Scroll) ───────── */
#vm-offline-overlay {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: 100dvh !important;
    z-index: 2147483647 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.14s ease, visibility 0.14s ease;
    box-sizing: border-box;
    overflow: hidden !important;
    overscroll-behavior: none !important;
    touch-action: none !important;
    background: #FAF9F5 !important;
}

#vm-offline-overlay.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ── 3. Clean Radial Ambient Backdrop (No Distractions, No Lag) ────────── */
.vm-offline-backdrop {
    position: fixed !important;
    inset: 0 !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    height: 100dvh !important;
    background: radial-gradient(circle at 50% 32%, #FFFFFF 0%, #FAF8F2 65%, #F0EADF 100%) !important;
    z-index: 1;
    pointer-events: none;
}

/* Hide all old decorative corner watermark classes completely */
.vm-offline-corner-tl,
.vm-offline-corner-tr,
.vm-offline-corner-bl,
.vm-offline-corner-br,
.vm-offline-brand-hero {
    display: none !important;
}

/* ── 4. Main Centered Single-Screen Container (Fits 100% in Viewport) ───── */
.vm-offline-container {
    position: relative;
    z-index: 5;
    width: 100%;
    max-width: 580px;
    margin: 0 auto;
    padding: calc(14px + env(safe-area-inset-top, 0px))
             calc(20px + env(safe-area-inset-right, 0px))
             calc(16px + env(safe-area-inset-bottom, 0px))
             calc(20px + env(safe-area-inset-left, 0px));
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    max-height: 100dvh;
    overflow: hidden !important;
    text-align: center;
}

#vm-offline-overlay.is-active .vm-offline-container {
    animation: vmInstantFadeIn 0.16s ease-out;
}

@keyframes vmInstantFadeIn {
    from { opacity: 0; transform: scale(0.985); }
    to   { opacity: 1; transform: scale(1); }
}

/* ── 5. 3D No-Internet Floating Visual ─────────────────────────────────── */
.vm-offline-hero-art {
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    user-select: none;
}

.vm-offline-3d-stage {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    perspective: 800px;
}

.vm-offline-art-img {
    width: clamp(120px, 18vw, 155px);
    height: auto;
    display: block;
    object-fit: contain;
    filter: drop-shadow(0 10px 22px rgba(220, 38, 38, 0.3));
    animation: vm3DFloat 3.4s ease-in-out infinite;
    will-change: transform;
    transform: translate3d(0, 0, 0);
}

.vm-offline-3d-shadow {
    width: 65%;
    height: 12px;
    margin-top: -6px;
    background: radial-gradient(ellipse, rgba(220, 38, 38, 0.26) 0%, rgba(220, 38, 38, 0.06) 48%, transparent 72%);
    border-radius: 50%;
    animation: vmShadowBreathe 3.4s ease-in-out infinite;
    will-change: transform, opacity;
}

@keyframes vm3DFloat {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotateX(2.5deg);
    }
    50% {
        transform: translate3d(0, -9px, 0) rotateX(-2.5deg);
    }
}

@keyframes vmShadowBreathe {
    0%, 100% {
        transform: scale(1);
        opacity: 0.85;
    }
    50% {
        transform: scale(0.72);
        opacity: 0.35;
    }
}

/* ── 6. Typography ─────────────────────────────────────────────────────── */
.vm-offline-title {
    font-family: 'Outfit', 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: clamp(1.45rem, 2.8vw, 2.05rem);
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.025em;
    color: var(--vm-green-deep);
    margin: 0 0 5px 0;
}

.vm-offline-title-highlight {
    color: var(--vm-terra);
    display: inline-block;
}

.vm-offline-desc {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: clamp(0.85rem, 1.3vw, 0.98rem);
    font-weight: 400;
    line-height: 1.5;
    color: var(--vm-muted);
    margin: 0 auto 14px auto;
    max-width: 420px;
}

/* ── 7. Primary Action: 3D Tactile Retry Button ────────────────────────── */
.vm-offline-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 7px;
    margin-bottom: 14px;
    width: 100%;
}

.vm-offline-retry-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 48px;
    padding: 0 42px;
    background: linear-gradient(180deg, #1A6337 0%, #114224 100%);
    color: #FFFFFF;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.98rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    border: 1px solid rgba(255, 255, 255, 0.22);
    border-radius: 50px;
    cursor: pointer;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.28),
        inset 0 -2px 0 rgba(0, 0, 0, 0.28),
        0 6px 18px -2px rgba(17, 66, 36, 0.4);
    transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.15s ease;
    user-select: none;
    -webkit-user-select: none;
    position: relative;
    transform: translate3d(0, 0, 0);
}

.vm-offline-retry-btn:hover:not(:disabled) {
    background: linear-gradient(180deg, #1E7541 0%, #144E2B 100%);
    transform: translate3d(0, -2px, 0);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.32),
        inset 0 -2px 0 rgba(0, 0, 0, 0.32),
        0 8px 22px -2px rgba(17, 66, 36, 0.48);
}

.vm-offline-retry-btn:active:not(:disabled) {
    transform: translate3d(0, 2px, 0);
    box-shadow:
        inset 0 2px 4px rgba(0, 0, 0, 0.35),
        0 2px 4px rgba(17, 66, 36, 0.25);
}

.vm-offline-retry-btn:disabled,
.vm-offline-retry-btn.is-checking {
    opacity: 0.88;
    cursor: wait;
    transform: none !important;
}

.vm-offline-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
}

.vm-offline-btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
}

.vm-offline-retry-btn.is-checking .vm-offline-btn-icon {
    display: none;
}

.vm-offline-retry-btn.is-checking .vm-offline-btn-spinner {
    display: inline-block;
    animation: vmSpinFast 0.65s linear infinite;
}

@keyframes vmSpinFast {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

.vm-offline-retry-btn.is-success {
    background: linear-gradient(180deg, #16A34A 0%, #15803D 100%) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.35),
        0 6px 18px rgba(22, 163, 74, 0.45) !important;
    border-color: rgba(134, 239, 172, 0.5) !important;
    transform: scale(1.02);
}

/* ── 8. Status Feedback Dot & Label ────────────────────────────────────── */
.vm-offline-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--vm-muted);
}

.vm-offline-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #EF4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2);
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.vm-offline-status.is-checking .vm-offline-status-dot {
    background: #3B82F6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.25);
    animation: vmDotPulse 0.8s infinite;
}

.vm-offline-status.is-checking .vm-offline-status-text { color: #2563EB; }

.vm-offline-status.is-error .vm-offline-status-dot {
    background: #DC2626;
    box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.2);
}

.vm-offline-status.is-error .vm-offline-status-text { color: #B91C1C; }

.vm-offline-status.is-success .vm-offline-status-dot {
    background: #16A34A;
    box-shadow: 0 0 0 4px rgba(22, 163, 74, 0.3);
}

.vm-offline-status.is-success .vm-offline-status-text {
    color: #15803D;
    font-weight: 700;
}

@keyframes vmDotPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.35; transform: scale(0.8); }
}

/* ── 9. 3D Glassmorphic Reassurance Card ───────────────────────────────── */
.vm-offline-farmer-card {
    background: rgba(255, 255, 255, 0.88);
    border: 1px solid var(--vm-border-glass);
    border-radius: 16px;
    padding: 10px 18px;
    margin: 0 auto 13px auto;
    max-width: 480px;
    width: 100%;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 4px 16px -3px rgba(22, 101, 52, 0.07);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    text-align: center;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-sizing: border-box;
}

.vm-offline-farmer-quote {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.83rem;
    font-weight: 500;
    line-height: 1.4;
    color: #133826;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
}

.vm-offline-farmer-icon {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    color: var(--vm-green-forest);
}

.vm-offline-farmer-sub {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.74rem;
    color: var(--vm-muted);
}

.vm-offline-helpline-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 14px;
    background: linear-gradient(135deg, #F0FDF4, #DCFCE7);
    border: 1px solid rgba(22, 101, 52, 0.2);
    border-radius: 50px;
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--vm-green-forest);
    text-decoration: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 2px 5px rgba(22, 101, 52, 0.08);
    transition: transform 0.12s ease;
}

.vm-offline-helpline-chip:hover {
    background: linear-gradient(135deg, #DCFCE7, #BBF7D0);
    transform: translateY(-1px);
}

.vm-offline-helpline-chip:active {
    transform: scale(0.97);
}

.vm-offline-helpline-chip svg {
    width: 12px;
    height: 12px;
}

/* ── 10. 3-Column Troubleshooting Guidance Row ─────────────────────────── */
.vm-offline-tips {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto 13px auto;
}

.vm-offline-tip-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 9px 6px 8px;
    background: rgba(255, 255, 255, 0.82);
    border: 1px solid var(--vm-border-glass);
    border-radius: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.95),
        0 2px 8px -2px rgba(22, 101, 52, 0.05);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    transition: transform 0.15s ease;
}

.vm-offline-tip-col:hover {
    transform: translateY(-2px);
}

.vm-offline-tip-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(145deg, #F0FDF4, #DCFCE7);
    border: 1px solid rgba(22, 101, 52, 0.18);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--vm-green-forest);
    margin-bottom: 5px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.9),
        0 3px 6px rgba(22, 101, 52, 0.12);
}

.vm-offline-tip-badge svg {
    width: 17px;
    height: 17px;
    stroke-width: 2.2;
}

.vm-offline-tip-text {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.74rem;
    font-weight: 600;
    line-height: 1.3;
    color: #475569;
}

/* ── 11. Bottom Brand Motto Row ────────────────────────────────────────── */
.vm-offline-motto-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid rgba(203, 213, 225, 0.5);
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
}

.vm-offline-motto-leaf {
    width: 14px;
    height: 14px;
    flex-shrink: 0;
}

.vm-offline-motto-text {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-size: 0.79rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--vm-muted);
}

/* ── 12. Laptop Screen Tuning (>= 1024px) ───────────────────────────────── */
@media (min-width: 1024px) {
    .vm-offline-container {
        max-width: 600px;
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .vm-offline-art-img {
        width: 155px;
    }

    .vm-offline-title {
        font-size: 2.05rem;
        margin-bottom: 6px;
    }

    .vm-offline-desc {
        font-size: 1rem;
        margin-bottom: 16px;
    }

    .vm-offline-retry-btn {
        min-height: 50px;
        padding: 0 46px;
        font-size: 1.02rem;
    }

    .vm-offline-farmer-card {
        padding: 12px 20px;
        margin-bottom: 15px;
    }

    .vm-offline-tips {
        gap: 12px;
        margin-bottom: 15px;
    }
}

/* ── 13. Mobile View Tuning (<= 480px) ─────────────────────────────────── */
@media (max-width: 480px) {
    .vm-offline-container {
        padding:
            calc(6px + env(safe-area-inset-top, 0px))
            14px
            calc(8px + env(safe-area-inset-bottom, 0px))
            14px;
        height: 100vh;
        height: 100dvh;
        max-height: 100dvh;
    }

    .vm-offline-hero-art {
        margin-bottom: 8px;
    }

    .vm-offline-art-img {
        width: clamp(115px, 34vw, 138px);
    }

    .vm-offline-3d-shadow {
        height: 10px;
    }

    .vm-offline-title {
        font-size: 1.35rem;
        margin-bottom: 3px;
    }

    .vm-offline-desc {
        font-size: 0.8rem;
        margin-bottom: 10px;
        max-width: 290px;
        line-height: 1.38;
    }

    .vm-offline-actions {
        margin-bottom: 10px;
        gap: 5px;
    }

    .vm-offline-retry-btn {
        width: 100%;
        max-width: 270px;
        min-height: 44px;
        font-size: 0.92rem;
        padding: 0 20px;
    }

    .vm-offline-farmer-card {
        padding: 7px 12px;
        border-radius: 12px;
        margin-bottom: 8px;
        gap: 3px;
    }

    .vm-offline-farmer-quote {
        font-size: 0.75rem;
        line-height: 1.3;
    }

    .vm-offline-farmer-sub { font-size: 0.69rem; }
    .vm-offline-helpline-chip { font-size: 0.73rem; padding: 3px 11px; }

    .vm-offline-tips {
        grid-template-columns: repeat(3, 1fr);
        gap: 5px;
        margin-bottom: 8px;
    }

    .vm-offline-tip-col {
        padding: 7px 3px 5px;
        border-radius: 10px;
    }

    .vm-offline-tip-badge {
        width: 30px;
        height: 30px;
        margin-bottom: 3px;
    }

    .vm-offline-tip-badge svg { width: 14px; height: 14px; }
    .vm-offline-tip-text { font-size: 0.65rem; line-height: 1.15; }

    .vm-offline-motto-row { padding-top: 6px; }
    .vm-offline-motto-text { font-size: 0.71rem; }
}

/* ── 14. Ultra-Compact Mobile Screens (<= 360px) ───────────────────────── */
@media (max-width: 360px) {
    .vm-offline-art-img { width: 100px; }
    .vm-offline-title { font-size: 1.2rem; }
    .vm-offline-farmer-card { display: none; }
    .vm-offline-tips { gap: 4px; }
    .vm-offline-tip-text { font-size: 0.6rem; }
}

/* ── 15. Short Landscape View (<= 520px) ────────────────────────────────── */
@media (max-height: 520px) and (orientation: landscape) {
    .vm-offline-container {
        padding: 4px 10px;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        gap: 6px;
    }

    .vm-offline-hero-art { width: 80px; margin-bottom: 0; }
    .vm-offline-art-img { width: 80px; }
    .vm-offline-farmer-card { display: none; }
    .vm-offline-tips { display: none; }
    .vm-offline-title { font-size: 1.1rem; margin-bottom: 2px; }
    .vm-offline-desc { font-size: 0.74rem; margin-bottom: 4px; }
}

/* ── 16. Accessibility: Reduced Motion ─────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #vm-offline-overlay,
    .vm-offline-art-img,
    .vm-offline-3d-shadow,
    .vm-offline-retry-btn,
    .vm-offline-status {
        transition: none !important;
        animation: none !important;
    }
}