/* ===== ریسپانسیو سراسری — همه صفحات ===== */

:root {
    --header-offset: var(--header-h);
}

/* safe-area برای گوشی‌های با ناچ */
@supports (padding: env(safe-area-inset-top)) {
    :root {
        --header-offset: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    }

    .site-header {
        padding-top: env(safe-area-inset-top, 0px);
    }

    .main-nav {
        top: var(--header-offset);
        max-height: calc(100dvh - var(--header-offset));
    }

    .guide-topbar {
        top: var(--header-offset);
    }
}

/* صفحات داخلی (درباره، 404، ...) */
body.page-inner main {
    padding-top: var(--header-offset);
    min-height: calc(100dvh - var(--header-offset));
}

body.page-parts main,
body.page-guide main {
    padding-top: var(--header-offset);
    min-height: calc(100dvh - var(--header-offset));
}

/* فاصله پایین برای نوار شیشه‌ای */
main {
    padding-bottom: calc(1rem + var(--dock-bar-offset, 5.5rem));
}

body.page-home main {
    padding-bottom: calc(1rem + var(--dock-bar-offset, 5.5rem));
}

body.page-guide .guide-stage {
    padding-bottom: calc(1rem + var(--dock-bar-offset, 5.5rem));
}

/* ─── تبلت ─── */
@media (max-width: 1024px) {
    body.page-home .header-inner {
        padding-inline: clamp(1rem, 3vw, 1.5rem);
    }

    .services-board {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .service-card[data-service] {
        grid-column: span 1;
    }

    .service-card[data-service="repair"] {
        grid-column: span 2;
    }

    .service-card[data-service="warranty"] {
        grid-column: span 2;
    }

    .service-card[data-service="repair"] .service-card__list {
        grid-template-columns: 1fr;
    }

    .service-card--featured {
        flex-direction: column;
        align-items: stretch;
    }

    .service-card--featured .service-card__head {
        flex-direction: row;
        align-items: flex-start;
        text-align: start;
        min-width: 0;
        padding-inline-start: 0;
    }

    .service-card--featured .service-card__icon {
        width: 48px;
        height: 48px;
    }

    .service-card--featured .service-card__icon svg {
        width: 23px;
        height: 23px;
    }

    .service-card--featured .service-card__index {
        top: 0.85rem;
        transform: none;
        font-size: 2.4rem;
    }
}

/* ─── موبایل ─── */
@media (max-width: 768px) {
    body.page-parts .parts-section,
    body.page-parts .product-section {
        padding-top: clamp(1.5rem, 4vw, 2rem);
    }

    body.page-guide .guide-stage {
        padding-top: clamp(1.5rem, 4vw, 2rem);
    }

    .page-hero h1 {
        padding-inline: 0.25rem;
    }

    .content-block {
        padding-inline: 0.15rem;
    }

    .error-page .btn {
        width: 100%;
        max-width: 280px;
    }
}

/* ─── موبایل کوچک ─── */
@media (max-width: 480px) {
    :root {
        --header-h: 60px;
    }

    .page-hero {
        padding: calc(var(--header-h) + 1.5rem) 0 1.75rem;
    }

    .page-hero p {
        padding-inline: 0.5rem;
        line-height: 1.65;
    }

    .page-content {
        padding: 1.75rem 0 2.5rem;
    }

    .btn,
    .btn-primary,
    a.btn-primary {
        min-height: 46px;
        padding-inline: 1.25rem;
    }
}

/* ─── راهنما ─── */
@media (max-width: 768px) {
    .guide-topbar-inner {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.65rem;
        padding: 0.7rem 0;
    }

    .guide-breadcrumb {
        flex: 1 1 100%;
        order: 2;
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.15rem;
        mask-image: linear-gradient(to left, transparent, #000 12px, #000 calc(100% - 12px), transparent);
    }

    .guide-breadcrumb::-webkit-scrollbar {
        display: none;
    }

    .guide-topbar-actions {
        order: 1;
        margin-inline-start: auto;
        flex: 0 0 auto;
    }

    .guide-topbar-actions .guide-btn {
        flex: 0 0 auto;
        min-height: 42px;
        padding: 0.5rem 0.85rem;
        font-size: 0.86rem;
    }

    .guide-interactive-hint {
        font-size: 0.86rem;
        padding-inline: 0.25rem;
    }

    .guide-chart-toolbar {
        gap: 0.4rem;
    }

    .guide-chart-toolbar .guide-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0.5rem 0.75rem;
    }

    .guide-chart-viewport {
        height: min(58svh, 520px);
        border-radius: 12px;
    }

    .guide-wizard-map .guide-chart-viewport {
        height: min(52svh, 440px);
    }

    .guide-interactive-nav {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.35rem;
        margin-inline: -0.25rem;
        padding-inline: 0.25rem;
    }

    .guide-interactive-nav::-webkit-scrollbar {
        display: none;
    }

    .guide-interactive-nav a {
        flex: 0 0 auto;
        max-width: 85vw;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .guide-warning-card {
        padding: 1.25rem;
    }

    .guide-warning-title {
        font-size: 1.15rem;
    }

    .guide-hub-grid {
        gap: 0.75rem;
    }

    .guide-card {
        gap: 0.75rem;
    }

    .guide-card-title {
        font-size: 0.98rem;
    }

    .guide-progress {
        overflow-x: auto;
        flex-wrap: nowrap;
        scrollbar-width: none;
    }

    .guide-progress::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 480px) {
    .guide-stage {
        width: min(100% - 1rem, 1140px);
        padding-top: 1rem;
    }

    .guide-topbar-inner,
    .guide-progress {
        width: min(100% - 1rem, 1140px);
    }

    .guide-chart-viewport {
        height: min(54svh, 460px);
    }

    .guide-wizard-map .guide-chart-viewport {
        height: min(48svh, 380px);
    }

    .guide-btn {
        font-size: 0.9rem;
    }

    .guide-hero {
        padding: 1.15rem 0.85rem;
    }

    .guide-hero-title {
        font-size: 1.25rem;
    }
}

/* ─── قطعات و محصول ─── */
@media (max-width: 768px) {
    .parts-sidebar {
        padding: 0.85rem;
        border-radius: 14px;
    }

    .parts-sidebar-title {
        font-size: 0.85rem;
        margin-bottom: 0.65rem;
    }

    .parts-search-form {
        flex-direction: column;
        align-items: stretch;
    }

    .parts-search {
        flex: 1 1 auto;
    }

    .parts-search-btn,
    .parts-search-form .btn-ghost {
        width: 100%;
    }

    .parts-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.85rem;
    }

    .parts-card-body {
        padding: 0.8rem 0.85rem 0.95rem;
    }

    .parts-card-title {
        font-size: 0.86rem;
    }

    .parts-pagination {
        flex-direction: column;
        gap: 0.75rem;
    }

    .parts-page-list {
        justify-content: center;
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.2rem;
    }

    .parts-page-list::-webkit-scrollbar {
        display: none;
    }

    .parts-page,
    .parts-page-btn {
        flex: 0 0 auto;
    }

    .parts-pagination-meta {
        font-size: 0.8rem;
        line-height: 1.6;
        padding-inline: 0.5rem;
    }

    .product-gallery-thumbs {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 0.25rem;
        margin-inline: -0.25rem;
        padding-inline: 0.25rem;
    }

    .product-gallery-thumbs::-webkit-scrollbar {
        display: none;
    }

    .product-thumb {
        flex: 0 0 auto;
    }

    .product-details-title {
        font-size: 1.25rem;
    }

    .product-breadcrumb {
        font-size: 0.82rem;
    }
}

@media (max-width: 480px) {
    .parts-section,
    .product-section {
        padding-bottom: 2.5rem;
    }

    .parts-grid {
        grid-template-columns: 1fr;
    }

    .parts-card-media {
        padding: 1rem;
    }

    .product-gallery-main {
        border-radius: 16px;
        padding: 1rem;
    }

    .product-meta {
        padding: 0.85rem 0.95rem;
    }
}

@media (max-width: 360px) {
    .parts-page,
    .parts-page-btn {
        min-width: 38px;
        min-height: 38px;
        padding: 0.35rem 0.6rem;
        font-size: 0.82rem;
    }
}

/* ─── صفحه اصلی — لندینگ موبایل ─── */
@media (max-width: 900px) {
    body.page-home .landing {
        overflow-x: clip;
    }

    body.page-home .landing__container {
        direction: ltr;
    }

    body.page-home .landing__aside {
        direction: rtl;
    }
}

@media (max-width: 768px) {
    body.page-home .section--services {
        margin-top: 0.75rem;
        border-radius: clamp(1.5rem, 5vw, 2.25rem) clamp(1.5rem, 5vw, 2.25rem) 0 0;
    }

    .services-head {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .services-head__copy {
        max-width: none;
    }

    .services-head__stats {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .services-board {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .service-card[data-service] {
        grid-column: span 1;
    }

    .service-card[data-service="repair"] .service-card__list {
        grid-template-columns: 1fr;
    }

    .service-card {
        padding: 1.15rem 1rem 1.2rem;
    }

    .service-card--featured {
        flex-direction: column;
        align-items: stretch;
    }

    .service-card--featured .service-card__head {
        flex-direction: row;
        text-align: start;
        min-width: 0;
        padding-inline-start: 0;
    }

    .service-card--featured .service-card__index {
        top: 0.85rem;
        transform: none;
        font-size: 2.4rem;
    }

    body.page-home .section--map__curve {
        border-radius: clamp(1.5rem, 5vw, 2.25rem) clamp(1.5rem, 5vw, 2.25rem) 0 0;
    }

    .hero__shell {
        padding-inline: 0.25rem;
    }

    .hero__copy {
        text-align: center;
    }

    .hero__foot {
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero__center {
        max-width: 100%;
    }

    .hero__tabs {
        width: 100%;
    }

    .hero__desc {
        font-size: 0.9rem;
    }
}

/* landscape موبایل */
@media (max-height: 500px) and (orientation: landscape) {
    .guide-chart-viewport,
    .guide-wizard-map .guide-chart-viewport {
        height: min(72vh, 360px);
    }

    .landing,
    .hero {
        min-height: auto;
    }

    .landing__container {
        min-height: auto;
    }
}
