/* =====================================================================
   responsive.css — نقاط شکست و تجربه موبایل
   ===================================================================== */

/* دسکتاپ — منو داخل grid هدر؛ بدون position:fixed */
@media (min-width: 961px) {
    .main-nav {
        position: static;
        visibility: visible;
        pointer-events: auto;
        height: auto;
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
        transform: none;
    }

    .header-support {
        display: inline-flex;
    }

    .lang-switch--drawer {
        display: none !important;
    }
    .lang-switch--header {
        display: none !important;
    }

    /* لوگو و منو در grid عادی جدا؛ با contents فرزندان مستقیم grid می‌شوند */
    .header-nav-cluster {
        display: contents;
    }

    /* عنوان Hero: دقیقاً دو خط — خط اول بدون شکستن داخل */
    .hero-title .hero-title-line:first-child {
        white-space: nowrap;
    }

    /* هدر فشرده هنگام اسکرول — فقط لوگو + منو */
    .site-header.is-scrolled {
        height: 58px;
    }

    .site-header.is-scrolled .header-inner {
        grid-template-columns: 1fr;
        justify-items: center;
    }

    .site-header.is-scrolled .header-actions {
        display: none;
    }

    /* لوگو کنار «خانه» — بدون کارت/پیل اضافه */
    .site-header.is-scrolled .header-nav-cluster {
        display: inline-flex;
        align-items: center;
        flex-wrap: nowrap;
        gap: 0.35rem;
        max-width: 100%;
        padding: 0;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }

    .site-header.is-scrolled .brand-text {
        opacity: 0;
        visibility: hidden;
        max-width: 0;
        margin: 0;
        overflow: hidden;
    }

    .site-header.is-scrolled .brand {
        flex-shrink: 0;
        gap: 0;
        padding: 0;
        margin: 0;
        border: none;
    }

    .site-header.is-scrolled .brand-logo {
        width: 34px;
        height: 34px;
    }

    .site-header.is-scrolled .main-nav {
        flex: 0 1 auto;
        min-width: 0;
        justify-content: flex-start;
    }

    .site-header.is-scrolled .main-nav .nav-list {
        display: inline-flex;
        flex-wrap: nowrap;
        align-items: center;
        gap: 0.1rem;
        padding: 0;
        border: none;
        border-radius: 0;
        background: transparent;
        box-shadow: none;
    }

    .site-header.is-scrolled .nav-link {
        font-size: 0.8rem;
        padding: 0.38rem 0.65rem;
    }

    .site-header.is-scrolled .nav-link::after {
        bottom: 4px;
    }

    .site-header.is-scrolled::before {
        background: var(--header-solid);
        box-shadow: var(--shadow-sm);
    }

    /* فرآیند: شش مرحله در یک خط */
    .timeline {
        overflow-x: visible;
    }
    .tl-step {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
    }
}

/* تبلت بزرگ — فشرده‌تر کردن منو */
@media (max-width: 1200px) and (min-width: 961px) {
    .header-inner { column-gap: 0.65rem; }
    .nav-link { padding: 0.42rem 0.45rem; font-size: 0.78rem; }
    .header-support { padding: 0.38rem 0.65rem; font-size: 0.76rem; }
    .btn-login { padding: 0.5rem 0.8rem; font-size: 0.8rem; }
    .brand-title-row { font-size: 0.86rem; }
    .brand-tagline { max-width: 9.5rem; }
    .main-nav .nav-list { gap: 0.02rem; }
}

/* تبلت بزرگ */
@media (max-width: 1080px) {
    .grid-3 > * { grid-column: span 6; }
    .grid-2 > * { grid-column: span 6; }
    .why-grid > * { grid-column: span 6; }
    .value-grid { grid-template-columns: repeat(2, 1fr); }
    .parts-grid > * { grid-column: span 4; }
}

/* منوی موبایل */
@media (max-width: 960px) {
    :root { --header-h: 70px; }

    .header-nav-cluster {
        display: contents;
    }

    /* هدر و منو بالای لایه مات؛ مات فقط پشت منو و روی محتوا */
    body.nav-open .site-header,
    .site-header:has(.main-nav.is-open) {
        z-index: 1002;
    }

    .header-inner {
        display: flex;
        justify-content: space-between;
        gap: 0.75rem;
    }

    .nav-toggle {
        display: flex;
        position: relative;
        z-index: 3;
    }

    .main-nav {
        position: fixed;
        inset-block: 0;
        inset-inline-end: auto;
        right: 0;
        left: auto;
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        z-index: 2;
        flex: none;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        justify-content: flex-start;
        justify-self: auto;
        background: var(--surface-solid);
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
        border-inline-start: 1px solid var(--border);
        box-shadow: var(--shadow-lg);
        padding: calc(var(--header-h) + 1.5rem) 1.5rem 2rem;
        box-sizing: border-box;
        transform: translateX(110%);
        visibility: hidden;
        pointer-events: none;
        transition: transform 0.4s var(--ease), visibility 0.4s var(--ease);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    html[dir="ltr"] .main-nav:not(.is-open) { transform: translateX(110%); }
    .main-nav.is-open {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .main-nav .nav-list {
        flex: 0 0 auto;
        flex-direction: column;
        align-items: stretch;
        gap: 0.3rem;
        width: 100%;
    }
    .nav-link {
        display: block;
        padding: 0.9rem 1rem;
        border-radius: var(--radius-sm);
        font-size: 1.02rem;
        border: 1px solid transparent;
    }
    .nav-link.active { background: var(--glow-blue); border-color: var(--border); }
    .nav-link::after { display: none; }

    .header-support,
    .lang-switch--header {
        display: none !important;
    }

    .lang-switch--drawer {
        display: inline-flex;
        align-self: center;
        justify-content: center;
        margin-top: 1.1rem;
        padding-top: 0;
        border-top: none;
    }

    /* Hero تک‌ستونه — عنوان دقیقاً دو خط */
    .hero-title {
        font-size: clamp(1.06rem, 4.4vw + 0.48rem, 1.62rem);
        line-height: 0.7;
        text-wrap: wrap;
        text-align: justify;
        text-align-last: justify;
        width: 100%;
        margin-bottom: 0.9rem;
    }
    .hero-title .hero-title-line {
        display: block;
        white-space: normal;
        max-width: 100%;
        text-align: justify;
        text-align-last: justify;
        text-justify: inter-word;
    }
    .hero-title .hero-title-line::after {
        content: "";
        display: inline-block;
        width: 100%;
    }
    .hero-title .hero-title-line .text-gradient {
        display: inline;
        white-space: inherit;
    }
    .hero-title .hero-title-line + .hero-title-line {
        margin-top: 0.03em;
    }
    .hero {
        min-height: auto;
        align-items: flex-start;
        padding-top: var(--header-h);
        padding-bottom: 2rem;
    }
    .hero .container {
        padding-top: 0;
    }
    .hero-inner {
        row-gap: clamp(1.25rem, 3vw, 1.75rem);
    }
    .hero-inner .hero-content,
    .hero-inner .hero-visual { grid-column: 1 / -1; }
    .hero-inner .hero-visual {
        order: -1;
        justify-self: stretch;
        width: 100vw;
        max-width: 100vw;
        margin-inline: calc(50% - 50vw);
        margin-top: 0;
    }
    .hero-content .hero-actions { grid-template-columns: 1fr; max-width: 100%; }
    .about-grid .about-text,
    .about-grid .stats-grid { grid-column: 1 / -1; }

    /* موبایل: جاستیفای متن بخش معرفی + وسط‌چین کردن دکمه */
    .about-grid .about-text {
        text-align: justify;
        text-justify: inter-word;
        hyphens: auto;
    }
    .about-grid .about-text .section-title {
        /* عنوان این بخش در موبایل کامل و چندخطی نمایش داده شود */
        font-size: clamp(1.18rem, 4.2vw + 0.4rem, 1.65rem);
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.45;
        /* جلوگیری از کشیدگی غیرطبیعی فاصله بین کلمات */
        text-align: start;
        text-align-last: auto;
        text-justify: auto;
        word-spacing: normal;
        letter-spacing: normal;
    }
    .about-grid .about-text p {
        white-space: normal;
        text-align: justify;
        text-justify: inter-word;
        hyphens: auto;
    }
    .about-grid .about-text .about-points li {
        white-space: normal;
        text-align: justify;
        text-justify: inter-word;
        hyphens: auto;
    }
    .about-grid .about-text .btn-primary {
        display: flex;
        width: fit-content;
        margin-inline: auto; /* وسط‌چین در موبایل */
    }
    .hero-slider {
        max-width: 100%;
        width: 100%;
        margin-inline: 0;
        animation: none;
    }
    .hero-slider-viewport {
        border-radius: 0;
        border-inline: none;
        box-shadow: none;
    }
    .hero-visual-glow { display: none; }

    .warranty-grid .warranty-info,
    .warranty-grid .track-form { grid-column: 1 / -1; }
    .contact-layout, .feature-row { grid-template-columns: 1fr; }
    .feature-row.reverse { direction: rtl; }
    .feature-media img { aspect-ratio: 16 / 10; }

    .footer-grid { grid-template-columns: 1fr 1fr; gap: 1.8rem; }
    .footer-about { grid-column: 1 / -1; }
    .licenses-grid { grid-template-columns: 1fr; }

    .auth-wrap { grid-template-columns: 1fr; }
    .auth-side { min-height: auto; padding-block: 2.5rem; }
    .auth-feats { display: none; }
}

/* موبایل */
@media (max-width: 640px) {
    body { font-size: 15.5px; }

    .grid-3 > *,
    .grid-2 > * { grid-column: span 12; }
    .why-grid > * { grid-column: span 12; }
    .value-grid, .svc-detail-card { grid-template-columns: 1fr; }
    .contact-strip .contact-pill,
    .contact-strip .contact-pill--address { grid-column: span 12; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .parts-grid > * { grid-column: span 6; }
    .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
    .contact-pill .cp-value--address,
    .info-item--address p { white-space: normal; }

    .timeline {
        gap: 0.5rem;
        padding-inline: 0.15rem 0.35rem;
    }
    .tl-step {
        flex: 0 0 auto;
        min-width: 7.25rem;
        max-width: 9.5rem;
    }

    .svc-detail-card { grid-template-columns: 1fr; gap: 1rem; }

    .brand-tagline { max-width: 10rem; }
    .brand-sub { display: none; }
    .btn-login span { display: none; }
    .btn-login { padding: 0.55rem 0.7rem; }

    .hero-quick { grid-template-columns: 1fr; max-width: 100%; }
    .hero-chip { display: none; }
    .hero-actions .btn { flex: 1; }

    .cta-actions { flex-direction: column; }
    .cta-actions .btn { width: 100%; }

    .footer-bottom { justify-content: center; text-align: center; flex-direction: column; }
    .footer-version { margin-top: 0.35rem; }
}

@media (max-width: 420px) {
    .stats-grid { grid-template-columns: 1fr; }
    .parts-grid > * { grid-column: span 12; }
    .tl-step { min-width: 6.75rem; max-width: 8.5rem; }
    .brand-title-row { font-size: 0.82rem; }
    .brand-tagline-text { font-size: 0.58rem; }
    .brand-logo { width: 40px; height: 40px; }
    .hero-title {
        font-size: clamp(1.02rem, 4.2vw + 0.42rem, 1.48rem);
    }
}

@media (max-width: 960px) {
    /* فوتر — کپی‌رایت و آدرس در یک خط */
    .footer-contact-list li.footer-contact-address {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .footer-contact-list li.footer-contact-address::-webkit-scrollbar { display: none; }
    .footer-contact-list li.footer-contact-address span {
        white-space: nowrap;
        font-size: clamp(0.72rem, 2.4vw, 0.9rem);
    }

    .footer-bottom-text {
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }
    .footer-copyright {
        white-space: nowrap;
        font-size: clamp(0.62rem, 2.4vw, 0.8rem);
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .footer-copyright::-webkit-scrollbar { display: none; }

    /* نوار پایین: بعد از اسکرول نمایش داده می‌شود */
    .bottom-bar-wrap {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        position: fixed;
        bottom: 18px;
        justify-self: center;
        right: auto;
        z-index: 920;
        width: calc(100% - 2rem);
        max-width: 560px;
        box-sizing: border-box;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transform: translateX(-50%) translateY(110%);
        transition:
            opacity 0.35s var(--ease),
            visibility 0.35s var(--ease),
            transform 0.35s var(--ease);
    }
    .bottom-bar-wrap.is-visible {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
        transform: translateX(-50%) translateY(0);
    }

    .quick-contact-bar {
        display: flex;
        flex: 1;
        min-width: 0;
    }

    .quick-contact-link {
        font-size: clamp(0.72rem, 2.8vw, 0.88rem);
        padding-inline: 0.35rem;
    }

    .bottom-bar-wrap .scroll-top {
        position: static;
        flex-shrink: 0;
        width: 46px;
        height: 46px;
        min-height: 46px;
        margin: 0;
        box-shadow: var(--shadow-md);
    }

    /* RTL: دکمه بازگشت به بالا سمت راست (اولین جایگاه در محور flex) */
    html[dir="rtl"] .bottom-bar-wrap .scroll-top {
        order: -1;
    }

    .footer-bottom .footer-copyright {
        text-align: center;
    }

    .site-footer { padding-bottom: 5.5rem; }
}

@media (min-width: 961px) {
    .bottom-bar-wrap { display: contents; }
}

@media (max-width: 640px) {
    .hero-actions { display: grid; grid-template-columns: 1fr; }
    .hero-actions .btn { width: 100%; }
    .form-grid.cols-2 { grid-template-columns: 1fr; }
}
