/* RTL Support System */

/* Prevent text breaking in RTL */
[dir="rtl"] {
    word-break: auto-phrase;
    hyphens: auto;
}

[dir="rtl"] .hero-headline,
[lang="fa"] .hero-headline,
[lang="ar"] .hero-headline {
    word-break: keep-all;
    text-align: center;
    font-family: var(--font-rtl);
}

/* Language Dropdown - always stays LTR inside nav */
.glass-nav .lang-dropdown-menu {
    direction: ltr;
}

.glass-nav .lang-option {
    direction: ltr;
}

/* Layout Mirroring - navbar stays LTR, only content area changes */

/* Text Alignment */
[dir="rtl"] .hero-content {
    text-align: right;
}

[dir="rtl"] .card-title,
[dir="rtl"] .card-desc {
    text-align: right;
}

[dir="rtl"] .copyright {
    text-align: left;
}

/* Icon Positioning */
[dir="rtl"] .card-icon {
    margin-right: 0;
    margin-left: auto;
}

/* Button Adjustments */
[dir="rtl"] .card-btn {
    flex-direction: row-reverse;
}

[dir="rtl"] .card-btn::after {
    content: '←';
}

[dir="rtl"] .card-btn:hover::after {
    transform: translateX(-3px);
}

/* Visual Elements */
[dir="rtl"] .particle-visual {
    right: auto;
    left: -50px;
}

[dir="rtl"] .code-visual {
    right: auto;
    left: 24px;
}

/* Scroll Indicator */
[dir="rtl"] .scroll-indicator {
    transform: translateX(50%);
}

/* ═══════════════════════════════════════════
   Bento Grid RTL Fix
   Force grid layout to LTR so grid-column line numbers
   stay consistent (line 1 = left). Only the card CONTENT
   should be RTL for proper text direction.
   ═══════════════════════════════════════════ */
[dir="rtl"] .bento-grid {
    direction: ltr;
}

[dir="rtl"] .grid-card {
    direction: rtl;
}

/* ── Premium Footer RTL ── */
[dir="rtl"] .footer-top {
    direction: rtl;
}

[dir="rtl"] .footer-link:hover {
    transform: translateX(-3px);
}

[dir="rtl"] .footer-tagline {
    text-align: right;
}

[dir="rtl"] .footer-socials {
    justify-content: flex-start;
}

[dir="rtl"] .footer-bottom-inner {
    direction: rtl;
}

[dir="rtl"] .footer-link-external::after {
    margin-inline-start: 6px;
    margin-inline-end: 0;
}

/* Mobile Menu */
@media (max-width: 768px) {
    [dir="rtl"] .mobile-nav-links {
        text-align: right;
    }

    [dir="rtl"] .mobile-nav-links a {
        flex-direction: row-reverse;
        justify-content: flex-start;
    }

    /* RTL mobile hero — center text */
    [dir="rtl"] .hero-content {
        text-align: center;
    }

    [dir="rtl"] .hero-headline,
    [dir="rtl"] .hero-subheadline {
        text-align: center;
    }

    /* Card button full-width in RTL mobile */
    [dir="rtl"] .card-btn {
        justify-content: center;
    }

    /* RTL card content alignment on mobile */
    [dir="rtl"] .grid-card .card-btn {
        align-self: flex-end;
    }

    /* footer center on mobile RTL */
    [dir="rtl"] .footer-bottom-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    [dir="rtl"] .footer-brand {
        align-items: center;
        text-align: center;
    }

    [dir="rtl"] .footer-tagline {
        text-align: center;
    }

    [dir="rtl"] .footer-socials {
        justify-content: center;
    }

    /* Language dropdown RTL mobile — open to left */
    [dir="rtl"] .lang-dropdown-menu {
        right: auto;
        left: -8px;
    }
}

@media (max-width: 480px) {
    [dir="rtl"] .card-btn {
        width: 100%;
    }

    [lang="ar"] .hero-headline {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }

    [lang="fa"] .hero-headline {
        font-size: clamp(1.5rem, 7vw, 2rem);
    }

    [lang="ar"] .card-title,
    [lang="fa"] .card-title {
        font-size: 1.05rem;
    }
}

/* Status Indicator */
[dir="rtl"] .footer-status {
    flex-direction: row-reverse;
}

/* Typography */
[dir="rtl"] .hero-headline,
[dir="rtl"] .hero-subheadline {
    text-align: center;
}

/* Number formatting */
[dir="rtl"] .numbers {
    font-feature-settings: "tnum";
}

/* Cursor position */
[dir="rtl"] .typewriter {
    border-right: none;
    border-left: 2px solid var(--cyan-neon);
}

/* Gradient directions */
[dir="rtl"] .text-gradient {
    background: linear-gradient(225deg, var(--cyan-neon), var(--purple-neon));
}

/* Shimmer animation */
[dir="rtl"] .shimmer-text {
    background: linear-gradient(
        270deg,
        #fff 0%,
        var(--cyan-neon) 50%,
        #fff 100%
    );
}

/* Arabic specific adjustments */
[lang="ar"] {
    font-family: var(--font-rtl);
}

[lang="ar"] .hero-headline {
    font-size: clamp(2.5rem, 5vw, 3.5rem);
    font-feature-settings: "ss01" 1;
}

[lang="ar"] .card-title {
    font-size: 1.75rem;
}

/* Persian specific adjustments */
[lang="fa"] {
    font-family: var(--font-rtl);
}

[lang="fa"] .hero-headline {
    font-feature-settings: "ss01" 1;
}

[lang="fa"] .numbers {
    font-feature-settings: "tnum" 1, "ss01" 1;
}

/* RTL Utility Classes */
.rtl-mirror {
    transform: scaleX(-1);
}

.rtl-text-right {
    text-align: right;
}

.rtl-text-left {
    text-align: left;
}

/* Fix for mixed RTL/LTR content */
.bidi-isolate {
    unicode-bidi: isolate;
    direction: ltr;
}

/* RTL Scrollbar */
[dir="rtl"] ::-webkit-scrollbar-thumb {
    background: linear-gradient(to left, var(--cyan-neon), var(--purple-neon));
}

/* RTL Animation Adjustments */
[dir="rtl"] .status-dot::after {
    animation-direction: reverse;
}

[dir="rtl"] .mouse::before {
    animation: scroll-rtl 2s infinite;
}

@keyframes scroll-rtl {
    0%, 100% {
        transform: translateX(50%) translateY(0);
    }
    50% {
        transform: translateX(50%) translateY(15px);
    }
}

/* RTL Card Hover */
[dir="rtl"] .glass-card:hover {
    transform: translateY(-4px);
}

[dir="rtl"] .glass-card:hover .card-icon {
    transform: scale(1.1) rotate(-5deg);
}