/**
 * GRAPHIC VIEW — Natural Scrolling, Pull-to-Refresh & Smooth Motion Engine (Feature 6)
 * Developed by: Web Era Solutions | Made with ❤️ by Web Era Solutions
 */

/* ==========================================================================
   1. NATURAL SCROLLING BEHAVIOUR & STICKY ANCHOR OFFSETS
   ========================================================================== */

/* Smooth scrolling for anchor targets (respects native user scrolling) */
html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

/* Reduced motion preference compliance */
@media (prefers-reduced-motion: reduce) {
    html, body {
        scroll-behavior: auto !important;
    }
    .gv-pull-indicator,
    .gv-pull-pill,
    .gv-back-to-top,
    .gv-pull-arrow {
        transition: none !important;
        animation: none !important;
    }
}

/* Offset anchor scroll targets so sticky headers do not cover headings */
:target,
[id].gv-scroll-target {
    scroll-margin-top: calc(var(--gv-sticky-header-height, 74px) + 16px);
}

/* Slim, modern, non-obtrusive scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(11, 27, 61, 0.2) transparent;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(11, 27, 61, 0.2);
    border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(16, 185, 129, 0.6);
}

/* Modals & Drawers independent scroll protection */
.modal,
.offcanvas {
    -webkit-overflow-scrolling: touch;
}

.modal-dialog-scrollable .modal-body,
.offcanvas-body {
    overflow-y: auto;
    overscroll-behavior: contain;
}

/* Prevent accidental horizontal overflow leaks */
.gv-scroll-container,
.gv-content-body,
main {
    overscroll-behavior-y: auto;
    overscroll-behavior-x: none;
}

/* Image aspect ratio container placeholder to prevent cumulative layout shift (CLS) */
.gv-aspect-img {
    aspect-ratio: 1 / 1;
    object-fit: cover;
    background-color: #F1F5F9;
}


/* ==========================================================================
   2. MOBILE PULL-TO-REFRESH COMPONENT
   ========================================================================== */

.gv-pull-indicator {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%) translateY(-150%);
    z-index: 1085;
    pointer-events: none;
    opacity: 0;
    transition: transform 0.24s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    will-change: transform, opacity;
}

/* Pulling state */
.gv-pull-indicator.gv-pulling {
    opacity: 1;
    pointer-events: auto;
}

/* The floating pill bubble */
.gv-pull-pill {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    background: #FFFFFF;
    color: #0B1B3D;
    padding: 8px 18px;
    border-radius: 999px;
    box-shadow: 0 10px 28px -4px rgba(11, 27, 61, 0.18), 0 0 0 1px rgba(11, 27, 61, 0.08);
    font-size: 13px;
    font-weight: 600;
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    user-select: none;
    transition: all 0.22s ease;
}

/* Icon wrapper */
.gv-pull-icon-wrap {
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    position: relative;
    flex-shrink: 0;
}

/* Pull arrow icon */
.gv-pull-arrow {
    color: #10B981;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), color 0.2s ease;
}

/* When threshold is reached */
.gv-pull-indicator.gv-threshold .gv-pull-arrow {
    transform: rotate(180deg);
    color: #059669;
}

.gv-pull-indicator.gv-threshold .gv-pull-pill {
    box-shadow: 0 12px 32px -4px rgba(16, 185, 129, 0.26), 0 0 0 1.5px #10B981;
    transform: scale(1.03);
}

/* Spinner during refresh */
.gv-pull-spinner {
    display: none;
    width: 18px;
    height: 18px;
    animation: gvSpin 0.75s linear infinite;
}

.gv-spinner-track {
    stroke: rgba(16, 185, 129, 0.2);
}

.gv-spinner-head {
    stroke: #10B981;
    stroke-dasharray: 45;
    stroke-dashoffset: 15;
    stroke-linecap: round;
}

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

/* Success checkmark */
.gv-pull-success-icon {
    display: none;
    font-size: 18px;
    color: #10B981;
    font-weight: 800;
}

/* State: Refreshing */
.gv-pull-indicator.gv-refreshing {
    opacity: 1;
    transform: translateX(-50%) translateY(0) !important;
}

.gv-pull-indicator.gv-refreshing .gv-pull-arrow {
    display: none;
}

.gv-pull-indicator.gv-refreshing .gv-pull-spinner {
    display: block;
}

.gv-pull-indicator.gv-refreshing .gv-pull-pill {
    background: #FFFFFF;
    color: #0B1B3D;
    box-shadow: 0 12px 36px rgba(16, 185, 129, 0.28), 0 0 0 1.5px #10B981;
}

/* State: Success */
.gv-pull-indicator.gv-success .gv-pull-arrow,
.gv-pull-indicator.gv-success .gv-pull-spinner {
    display: none;
}

.gv-pull-indicator.gv-success .gv-pull-success-icon {
    display: block;
    animation: gvPopIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gv-pull-indicator.gv-success .gv-pull-pill {
    background: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

@keyframes gvPopIn {
    0% { transform: scale(0.5); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}


/* ==========================================================================
   3. FLOATING "BACK TO TOP" BUTTON
   ========================================================================== */

.gv-back-to-top {
    position: fixed;
    right: 22px;
    bottom: 82px;
    z-index: 1030;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0B1B3D 0%, #1E293B 100%);
    color: #FFFFFF;
    border: 1.5px solid rgba(255, 255, 255, 0.16);
    box-shadow: 0 8px 24px rgba(11, 27, 61, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(16px) scale(0.9);
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.gv-back-to-top.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.gv-back-to-top:hover {
    background: linear-gradient(135deg, #10B981 0%, #059669 100%);
    color: #FFFFFF;
    transform: translateY(-3px) scale(1.06);
    box-shadow: 0 12px 28px rgba(16, 185, 129, 0.35);
}

.gv-back-to-top:active {
    transform: translateY(0) scale(0.96);
}

/* Reposition when mobile bottom navigation bar is present */
@media (max-width: 991.98px) {
    .gv-back-to-top {
        right: 18px;
        bottom: 86px;
        width: 42px;
        height: 42px;
        font-size: 16px;
    }
}
