/* ===================================
   iland Story Component
   =================================== */

/* CSS Variables */
:root {
    --c-primary-700: #1e3a8a;
    --c-primary-400: #2563eb;
    --c-primary-500: #1e3a8a;
    --c-primary-200: #93c5fd;
    --c-primary: #1e3a8a;
    --c-secondary: #2563eb;
    --c-white: #fff;
    --c-neutral-250: #f0f0f0;
    --c-navy-dark: #1e293b;
    --fs-12: 12px;
    --fs-18: 18px;
    --fw-500: 500;
    --ff-icon: 'vazir', sans-serif;
    --t-ease: 0.3s;
    --ease4: cubic-bezier(0.4, 0, 0.2, 1);
}

/* Buttons only inside the story widget — not sitewide .btn */
#iland .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1.5rem;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 14px;
    font-weight: 500;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    position: relative;
    overflow: visible;
}

#iland .btn--primary {
    background: transparent;
    color: var(--c-white);
}

#iland .btn--primary:hover {
    transform: translateY(-2px);
}

#iland .btn--primary:active {
    transform: translateY(0);
}

/* iland Container */
#iland {
    z-index: 9999;
    position: fixed;
    bottom: 1.5rem;
    right: 4rem;
    left: auto;
    transform: none;
}

.iland-wrapper {
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 0;
}

/* CTA Buttons Container - Hidden completely */
.iland-cta {
    display: none !important;
}

/* Request Button */
.iland__request {
    padding: .5rem .9rem;
    background: transparent;
    border: none;
    color: var(--c-white);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 12px;
    font-weight: 500;
}

.iland__request-icon {
    stroke: var(--c-white);
    width: 1.4rem;
    height: 1.4rem;
    fill: transparent;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2;
    transition: var(--t-ease) var(--ease4);
    z-index: 2;
    position: relative;
}

.iland__request:hover {
    background: rgba(37, 99, 235, 0.2);
    border-radius: 12px;
}

.iland__request:hover .iland__request-icon {
    stroke: var(--c-primary-400);
}

/* Phone Button */
.iland__phone {
    gap: 0.6rem;
    font-size: 13px;
    padding: .5rem .9rem;
    background: transparent;
    border: none;
    color: var(--c-white);
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 500;
}

.iland__phone-icon {
    width: 1.4rem;
    height: 1.4rem;
    flex: none;
    stroke: var(--c-white);
    fill: transparent;
    transition: var(--t-ease) var(--ease4);
    position: relative;
    z-index: 2;
}

.iland__phone:hover {
    background: rgba(37, 99, 235, 0.2);
    border-radius: 12px;
}

.iland__phone:hover .iland__phone-icon {
    stroke: var(--c-primary-400);
}

.iland__phone-icon-line {
    animation: ringPhoneBack 1s ease-in-out 1 forwards;
}

.iland__phone-icon-line.second {
    animation: ringPhoneBack 1s ease-in-out 0.2s 1 forwards;
}

.iland__phone:hover .iland__phone-icon-line {
    animation: ringPhone 1s ease-in-out infinite backwards;
}

.iland__phone:hover .iland__phone-icon-line.second {
    animation: ringPhone 1s ease-in-out 0.2s infinite backwards;
}

@keyframes ringPhone {
    0% { opacity: 0; }
    40% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes ringPhoneBack {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

.iland__request-icon.animate * {
    animation: noteStroke 1.2s var(--ease4) 1 forwards;
}

@keyframes noteStroke {
    100% { stroke-dashoffset: 0; }
}

/* Request Curve Decoration */
.iland__request-curve {
    position: absolute;
    top: calc(100% + .8rem);
    background-color: var(--c-primary-700);
    border-radius: 0 0 12px 12px;
    width: 3.8rem;
    height: .4rem;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.iland__request-curve-line {
    position: absolute;
    background-color: var(--c-secondary);
    width: 76%;
    height: .15rem;
    border-radius: 1rem;
    left: 50%;
    transform: translateX(-50%);
    top: -.08rem;
}

.iland__request-curve::after,
.iland__request-curve::before {
    content: "";
    position: absolute;
    box-shadow: 0 calc(-0.3rem / 2) 0 0 var(--c-primary);
    height: .3rem;
    width: 1.4rem;
    top: .08rem;
}

.iland__request-curve::after {
    right: -1.3rem;
    border-top-left-radius: 12px;
}

.iland__request-curve::before {
    left: -1.3rem;
    border-top-right-radius: 12px;
}

/* iland Interactive CTA */
.iland-icta {
    display: flex;
    flex-direction: row-reverse;
    align-items: center;
    cursor: pointer;
    gap: 0;
}

.iland-icta-circle {
    position: relative;
}

/* Wave Animation Wrapper */
.icta-wave-wrapper {
    position: absolute;
    transform: translate(-50%, -50%) scale(.9) rotate(4deg);
    z-index: -1;
    left: 50%;
    width: 10rem;
    height: 10rem;
    top: 50%;
    opacity: 0;
    transition: .7s cubic-bezier(.4, 0, 1, 1);
}

#iland-icta-wave {
    width: 100%;
    height: 100%;
}

.iland-icta:hover .icta-wave-wrapper {
    opacity: 1;
    transform: translate(-50%, -50%);
    transition: var(--t-ease) cubic-bezier(.4, 0, 1, 1);
}

/* iland Image/Video Circle */
.iland-icta__img {
    width: 6rem;
    height: 6rem;
    border-radius: 50%;
    background: var(--c-neutral-250);
    overflow: hidden;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 4px rgb(0 0 0 / 16%);
    flex: none;
    border: 2px solid var(--c-primary-700);
}

.iland-icta__video {
    position: absolute;
    inset: 0;
    object-fit: cover;
    width: 100%;
    height: 100%;
    background: #1e293b;
    transform: translateZ(0);
}

.iland-icta__video.is-broken {
    opacity: 0;
}

.iland-icta__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* iland Title */
.iland-icta__title {
    background: var(--c-primary-200);
    border-radius: 15px 0 0 15px;
    font-size: 11px;
    padding: .4rem 0rem .4rem .9rem;
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-right: -1rem;
    font-weight: var(--fw-500);
    white-space: nowrap;
    font-family: 'Vazirmatn', sans-serif;
    color: var(--c-primary-700);
}

.iland-icta__icon-title {
    background-color: var(--c-primary-700);
    border-radius: 15px 0 0 15px;
    width: 2rem;
    height: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-right: .7rem;
    order: -1;
}

.iland-icta__icon-title::before {
    content: "💡";
    font-size: .7rem;
}

/* Responsive - CTA buttons removed completely */

/* Responsive Design for iland */
@media (max-width: 991.98px) {
    #iland {
        right: 1rem;
        bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    }
}

@media (max-width: 768px) {
    #iland {
        right: 1rem;
        bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    }
    
    .iland-wrapper {
        gap: 1.2rem;
    }
    
    .iland-icta__img {
        width: 5rem;
        height: 5rem;
    }
    
    .icta-wave-wrapper {
        width: 8rem;
        height: 8rem;
    }
    
    .iland-icta__title {
        font-size: 10px;
        padding: .3rem 0rem .3rem .7rem;
    }
    
    .iland__phone {
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    #iland {
        right: 1rem;
        bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
    }
    
    .iland-icta__img {
        width: 4.5rem;
        height: 4.5rem;
    }
    
    .icta-wave-wrapper {
        width: 7rem;
        height: 7rem;
    }
    
    .iland-icta__title {
        font-size: 9px;
        padding: .25rem 0rem .25rem .6rem;
    }
    
    .iland__phone {
        font-size: 11px;
        padding: .4rem .7rem;
    }
    
    .iland__request {
        font-size: 10px;
        padding: .4rem .7rem;
    }
}

/* Story Modal */
.story-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.story-modal.active {
    display: flex;
    opacity: 1;
}

.story-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    cursor: pointer;
}

.story-modal .story-content {
    position: relative;
    width: 90%;
    max-width: 420px;
    height: 90vh;
    max-height: 750px;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: storyModalSlideUp 0.4s ease-out;
}

@keyframes storyModalSlideUp {
    from {
        transform: translateY(50px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Progress Bar Container
   One segment per story + a small remaining-time label on the right.
   Segment fill widths are set from JS on the video `timeupdate` event
   (no CSS animation), so pausing the video pauses the fill. */
.story-progress-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    align-items: center;
    direction: ltr; /* segments run left→right, time label sits at the right end */
    gap: 4px;
    padding: 10px 12px 0;
    z-index: 10;
    pointer-events: none;
}

.story-progress-bar {
    flex: 1 1 0;
    min-width: 0;
    height: 3px;
    background: rgba(255, 255, 255, 0.35);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.story-progress-fill {
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 0%;
    background: #fff;
    border-radius: 999px;
    transition: width 0.1s linear;
}

/* Previously watched segments are always full; the current one is JS-driven */
.story-progress-bar.completed .story-progress-fill {
    width: 100%;
}

.story-time {
    flex: 0 0 auto;
    margin-left: 6px;
    color: #fff;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 0.8rem;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
    white-space: nowrap;
    direction: ltr;
}

/* Close Button (top-left) */
.story-close {
    position: absolute;
    top: 28px;
    left: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border: none;
    color: #fff;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 11;
    transition: all 0.2s ease;
}

.story-close:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: scale(1.1);
}

/* Home Button (top-right, just below the progress bar row; answer videos only) */
.story-nav-home {
    position: absolute;
    top: 28px;
    right: 16px;
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 11;
    box-sizing: border-box;
    transition: background 0.2s ease, transform 0.2s ease;
}

.story-nav-home svg {
    width: 20px;
    height: 20px;
    display: block;
}

.story-nav-home:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: scale(1.08);
}

.story-nav-home:active {
    transform: scale(1);
}

.story-nav-home.is-hidden {
    display: none;
}

/* Video Container */
.story-video-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
}

.story-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
}

/* Paused Indicator */
.story-paused-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.story-paused-indicator i {
    font-size: 30px;
    color: #fff;
}

.story-paused .story-paused-indicator {
    display: flex;
}

/* Responsive Design */
@media (max-width: 768px) {
    .story-intro-wrapper {
        bottom: 20px;
        padding: 6px 16px 6px 6px;
        gap: 10px;
    }

    .story-circle {
        width: 50px;
        height: 50px;
    }

    .story-modal .story-text {
        font-size: 14px;
    }

    .story-modal .story-content {
        width: 95%;
        height: 95vh;
        border-radius: 12px;
    }

    .story-close {
        width: 32px;
        height: 32px;
        font-size: 20px;
        left: 10px;
    }

    .story-nav-home {
        right: 10px;
    }
}

/* Hide on very small screens */
@media (max-width: 480px) {
    .story-intro-wrapper {
        bottom: 80px;
    }
}

/* Accessibility */
.story-intro-wrapper:focus-visible,
.story-close:focus-visible {
    outline: 2px solid #0078D4;
    outline-offset: 2px;
}

/* Loading State - Hidden */
.story-loading {
    display: none !important;
}

@keyframes storySpinner {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Story Navigation Buttons (vertical stack) */
.story-navigation {
    position: absolute;
    bottom: 1.5rem;
    left: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    z-index: 15;
    pointer-events: none;
}

/* Soft dark fade behind the button stack so white text stays readable */
/* No stories with a question → no buttons → hide the container and its gradient */
.story-navigation:empty {
    display: none;
}

.story-navigation::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1.5rem;
    height: 45vh;
    max-height: 340px;
    background: linear-gradient(to top, rgba(10, 15, 40, 0.75), transparent);
    pointer-events: none;
    z-index: -1;
}

.story-nav-btn {
    position: relative;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.22);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid transparent;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease, border-color 0.25s ease;
    color: #fff;
    font-family: 'Vazirmatn', sans-serif;
    display: flex;
    align-items: center;
    box-sizing: border-box;
    width: 88%;
    min-height: 44px;
    padding: 0.7rem 1.2rem;
    justify-content: flex-start;
    direction: rtl;
    text-align: right;
}

.story-nav-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-1px);
}

.story-nav-btn:active {
    transform: translateY(0);
}

.story-nav-btn.active {
    background: rgba(255, 255, 255, 0.45);
    border-color: #fff;
}

.story-nav-question {
    display: block;
    width: 100%;
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.4;
    color: #fff;
    text-align: right;
    direction: rtl;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
}

.story-nav-btn:focus-visible,
.story-nav-home:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Responsive Navigation */
@media (max-width: 480px) {
    .story-navigation {
        bottom: 1.25rem;
        gap: 0.5rem;
    }

    .story-navigation::before {
        bottom: -1.25rem;
    }

    .story-nav-btn {
        min-height: 40px;
        padding: 0.55rem 1rem;
    }

    .story-nav-question {
        font-size: 0.8rem;
    }
}

/* Hidden State */
.story-hidden {
    display: none !important;
}
