:root {
    --fs-nav: clamp(0.84rem, 1.2vw + 0.48rem, 1.2rem);
    --fs-nav-sm: clamp(0.78rem, 0.6vw + 0.66rem, 1.08rem);
    --touch-target: 44px;
}

header {
    block-size: var(--header-size, 4rem);
    min-height: 60px;
    display: flex;
    align-items: center;
    padding: clamp(0.5rem, 1vh, 1rem) clamp(1rem, 2vw, 2rem);
    background: var(--card-bg);
}

.site-header {
    background: var(--card-bg);
    color: var(--text);
    position: fixed;
    top: 0;
    inset-inline-start: 0;
    width: 100%;
    z-index: 1000;
    margin: 0;
    min-block-size: var(--header-size, 4rem);
    padding: clamp(0.5rem, 1vh, 1rem) clamp(1rem, 2vw, 2rem);
    transition: padding .3s ease, background-color .3s, color .3s;
}

.hdr-container {
    max-width: none;
    margin: 0 auto;
    width: 100%;
    padding: 0 clamp(0.5rem, 1.5vw, 1.5rem);
    display: flex;
    align-items: center;
    gap: clamp(0.15rem, 1vw, 1rem);
    flex-wrap: nowrap;
    justify-content: flex-start;
    height: 100%;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: clamp(0.25rem, 1.5vw, 1.5rem);
    position: static;
}

.nav-actions {
    display: flex;
    align-items: center;
    margin-inline-start: auto;
    gap: clamp(0.25rem, 2vw, 1rem);
    flex-shrink: 0;
}

.logo {
    font-family: 'TehranPlumber-font', 'Vazirmatn', sans-serif;
    font-size: clamp(0.7rem, 2vw, 1.3rem);
    font-weight: bold;
    text-decoration: none;
    color: inherit;
    line-height: 1.2;
    white-space: nowrap;
    padding-inline: clamp(0rem, 1vw, 0.5rem);
    transition: font-size .3s ease;
}

.call-btn {
    display: inline-flex;
    align-items: center;
    gap: clamp(0.2rem, 0.8vw, 0.5rem);
    text-decoration: none;
    white-space: nowrap;
    flex: 0 0 auto;
    transition: padding .3s ease, font-size .3s ease, background-color .3s ease;
    background-color: var(--card-bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    font-size: clamp(0.72rem, 1.8vw, 1.14rem);
    padding: clamp(0.25rem, 0.8vw, 0.6rem) clamp(0.5rem, 1.5vw, 1.1rem);
    min-height: clamp(32px, 4vw, var(--touch-target));
}

.call-btn .icon {
    font-size: 1.1em;
    line-height: 1;
}

.call-btn:hover {
    background-color: var(--btn-outline-hover-bg);
    color: var(--btn-text);
}

.call-btn.cta-numbered {
    font-size: clamp(1.02rem, 3vw, 1.32rem);
    padding: clamp(0.5rem, 1.2vw, 0.8rem) clamp(1rem, 2.5vw, 1.4rem);
}

.call-btn.cta-numbered .cta-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.5;
    gap: 0.25rem;
}

.call-btn.cta-numbered .cta-label {
    font-size: inherit;
    padding-bottom: 0.25rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px dotted var(--border);
}

.call-btn.cta-numbered .cta-number {
    font-size: 1.25em;
    font-weight: 700;
    direction: ltr;
    unicode-bidi: bidi-override;
}

.call-btn.golden-cta {
    border: 1px solid #FFD700;
    box-shadow: 0 0 0 1px var(--card-ring), 0 0 8px rgba(255, 215, 0, 0.8);
}

.call-btn.golden-cta .call-label {
    font-size: inherit;
}

body.nav-open {
    overflow: hidden;
}


.hamburger {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.9rem;
    cursor: pointer;
}

/* Fixed hamburger button outside header */
.sticky-hamburger {
    position: fixed;
    top: 50%;
    right: 1rem;
    left: auto;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

body.nav-overflow .sticky-hamburger {
    display: flex;
}

.hamburger-icon {
    background-color: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--card-ring);
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.hamburger-icon span {
    position: absolute;
    left: 50%;
    width: 20px;
    height: 2px;
    background-color: var(--btn-line);
    transition: background-color 0.3s ease, transform 0.3s ease, opacity 0.3s ease;
    transform: translateX(-50%);
}

.hamburger-icon span:nth-child(1) {
    transform: translate(-50%, -6px);
}

.hamburger-icon span:nth-child(2) {
    transform: translate(-50%, 0);
}

.hamburger-icon span:nth-child(3) {
    transform: translate(-50%, 6px);
}

.hamburger-icon.open span:nth-child(1) {
    transform: translate(-50%, 0) rotate(45deg);
}

.hamburger-icon.open span:nth-child(2) {
    opacity: 0;
}

.hamburger-icon.open span:nth-child(3) {
    transform: translate(-50%, 0) rotate(-45deg);
}

.theme-toggle {
    background-color: var(--card-bg);
    color: var(--text);
    font-size: clamp(0.8rem, 1.5vw, 1rem);
    width: clamp(32px, 4vw, var(--touch-target));
    height: clamp(32px, 4vw, var(--touch-target));
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--border);
    box-shadow: 0 0 0 1px var(--card-ring);
    cursor: pointer;
    transition: transform .15s ease, background-color .3s, color .3s;
    box-sizing: border-box;
    flex-shrink: 0;
}

.theme-toggle:hover {
    background-color: var(--btn-outline-hover-bg);
}

.theme-toggle.clicked {
    transform: scale(0.85);
}

.nav-theme-toggle {
    display: none;
}

.nav-theme-toggle-wrapper {
    display: none;
}

/* ─── Navigation ─── */
/* Ensure nav fills header height so the desktop highlight matches */
.nav {
    flex: 1;
    display: flex;
    justify-content: center;
    transition: background-color .3s, color .3s;
    align-self: stretch; /* allow nav to take full header height */
}

/* make list span full height so highlight can cover background */
.nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: clamp(0.1rem, 0.5vw, 0.5rem);
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    height: 100%;
    align-items: center;
}

.nav ul li {
    position: relative;
    z-index: 1;
    flex: 0 0 auto;
    min-width: fit-content;
}

.nav-more {
    display: none;
    position: relative;
}

.nav-more.has-items {
    display: block;
}

.nav-more-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--fs-nav);
}

.nav-more-menu {
    display: none;
    position: absolute;
    top: 100%;
    inset-inline-start: 0;
    background: var(--card-bg);
    list-style: none;
    margin: 0;
    padding: 0.5rem 0;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    min-width: 8rem;
    z-index: 1000;
}

.nav-more-menu li {
    white-space: nowrap;
}

.nav-more.open .nav-more-menu {
    display: block;
}

body.nav-overflow .nav-more {
    display: none;
}

.nav-desktop-highlight {
    position: absolute;
    top: 0;
    inset-inline-start: 0;
    height: 100%;
    background: var(--nav-highlight);
    border-radius: 10px;
    transition: left .4s ease, width .4s ease, height .4s ease, top .4s ease;
    pointer-events: none;
    z-index: 0;
    display: none;
}

@media (min-width: 1024px) {
    body:not(.nav-overflow) .nav-desktop-highlight {
        display: block;
    }
}

.nav a {
    font-size: var(--fs-nav);
    color: var(--text);
    margin: 0 clamp(0.1rem, 0.5vw, 0.5rem);
    text-decoration: none;
    padding: clamp(0.2rem, 0.5vw, 0.5rem) clamp(0.4rem, 1vw, 0.8rem);
}

.menu-link {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

nav a:hover {
    color: var(--primary);
}

/* Adjust sizes when the header shrinks */
.site-header.shrink .nav a {
    font-size: var(--fs-nav-sm);
}

.site-header.shrink .call-btn {
    padding: 0.4rem 1rem;
    font-size: var(--fs-nav-sm);
}

/* Shrink header when scrolling */
.site-header.shrink {
    /* Reduce header padding for a smaller height when shrunk */
    padding: .3rem 1rem;
    box-shadow: 0 1px 0px rgba(0, 0, 0, 0.4);
}

.site-header.shrink .logo {
    /* Keep the logo smaller in the compact state */
    font-size: clamp(1rem, 4vw, 1.5rem);
}

/* Mobile Drawer */
@media (max-width: 1023px) {
    .nav {
        position: fixed;
        inset: 0 0 0 auto;
        width: 270px;
        background: var(--card-bg);
        height: 100%;
        overflow-y: auto;
        direction: rtl;
        z-index: 1100;
        transform: translateX(100%);
        transition: transform .3s ease;
        display: flex;
        flex-direction: column;
        padding: 0.8rem 1rem 5rem;
    }

    .nav.open {
        transform: translateX(0);
    }

    .nav ul {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-direction: column;
        gap: clamp(0.25rem, 2vw, 1.25rem);
        flex-wrap: nowrap;
        flex: 1;
        justify-content: flex-start;
    }

    .nav a {
        font-size: calc(var(--fs-nav) * 1.2);
    }

    .nav ul li.nav-cta-item {
        margin-top: auto;
    }

    .nav ul li {
        width: 100%;
        opacity: 0;
        transform: translateX(20px);
        transition: opacity .3s ease, transform .3s ease;
    }

    .nav.open ul li {
        opacity: 1;
        transform: translateX(0);
    }

    .nav.open ul li:nth-child(1) {
        transition-delay: .1s;
    }

    .nav.open ul li:nth-child(2) {
        transition-delay: .2s;
    }

    .nav.open ul li:nth-child(3) {
        transition-delay: .3s;
    }

    .nav.open ul li:nth-child(4) {
        transition-delay: .4s;
    }

    .nav.open ul li:nth-child(5) {
        transition-delay: .5s;
    }

    .nav.open ul li:nth-child(6) {
        transition-delay: .6s;
    }
}


@media (prefers-reduced-motion: reduce) {
    .nav,
    .nav ul li {
        transition: none;
    }
}

@keyframes nav-shake {
    0%, 70%, 100% {
        transform: translateX(0);
    }
    80% {
        transform: translateX(-2px);
    }
    90% {
        transform: translateX(2px);
    }
    95% {
        transform: translateX(-1px);
    }
}

@keyframes red-glow {
    0%, 100% {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 0 0 rgba(255, 0, 0, 0);
    }
    50% {
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1), 0 0 8px rgba(255, 0, 0, 0.8);
    }
}

@media (max-width: 1023px) {
    .menu-link {
        text-decoration: none;
        border: 1px solid var(--border);
        color: var(--text);
        position: relative;
        overflow: hidden;
        background: var(--card-bg);
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    }

    .menu-card {
        display: block;
        width: 100%;
        max-width: 280px;
        margin: 0.5rem auto;
        padding: 0.6rem 1rem;
        text-align: center;
        box-sizing: border-box;
    }

    .menu-link:hover {
        background: var(--btn-outline-hover-bg);
    }

    .menu-link .ripple {
        position: absolute;
        border-radius: 50%;
        transform: scale(0);
        animation: ripple .4s linear;
        background: rgba(255, 255, 255, 0.4);
        pointer-events: none;
    }

    .nav {
        align-items: center;
        justify-content: flex-start;
        gap: 1rem;
    }

    .nav ul {
        flex: 1;
        align-items: center;
        justify-content: flex-start;
    }

    .nav-title {
        font-size: clamp(1.3rem, 2.6vw, 1.69rem);
        color: var(--text);
        text-align: center;
        margin: 0.5rem 0;
        font-family: 'TehranPlumber-font', 'Vazirmatn', sans-serif;
        line-height: 1.8;
        font-weight: bold;
    }

    .nav-theme-toggle-wrapper {
        display: flex;
        align-items: center;
        gap: 0.5rem;
        margin: 0 0 1rem;
        align-self: flex-start;
        color: var(--text);
    }

    .nav-theme-toggle { 
        display: flex;
    }

    .nav-theme-toggle-wrapper .theme-toggle-label {
        font-size: clamp(1.08rem, 2.4vw, 1.2rem);
    }

    .nav-cta.btn-primary {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: .55rem;
        background: var(--card-bg);
        color: var(--text);
        border: 1px solid var(--border);
        border-radius: 12px;
    }

    .nav-cta.btn-primary:hover {
        background: var(--btn-outline-hover-bg);
    }

    .cta-animated {
        animation: red-glow 2s infinite;
    }

    .nav-cta .icon {
        display: inline-block;
        animation: nav-shake 5s infinite;
    }

    .sticky-hamburger {
        display: flex;
        align-items: center;
        justify-content: center;
        background: var(--card-bg);
        color: var(--text);
        border: 1px solid var(--border);
        border-radius: 12px;
        box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
        overflow: hidden;
        animation: red-glow 2s infinite;
    }

    /* حذف لینک های وبلاگ و تماس با ما روی موبایل در صورت وجود */
    .nav ul li.hide-mobile {
        display: none;
    }
}

@keyframes ripple {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

#service-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, .6);
    z-index: 1200;
}

#service-modal.open {
    display: flex;
}

#service-modal .modal-card {
    background: var(--card-bg);
    padding-block: 2rem;
    padding-inline: clamp(1rem, 4vw, 2rem);
    border-radius: 1rem;
    width: 100%;
    max-inline-size: min(90%, 400px);
    text-align: center;
    position: relative;
    animation: scaleIn .3s ease;
}

#service-modal .modal-close {
    position: absolute;
    top: .5rem;
    inset-inline-start: .5rem;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text);
    cursor: pointer;
}

#service-modal .modal-title {
    margin-bottom: 1.5rem;
}

#service-modal .modal-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 480px) {
    #service-modal .modal-buttons {
        flex-direction: row;
    }
}

#service-modal .service-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text);
    position: relative;
    overflow: hidden;
}

#service-modal .service-btn .icon {
    font-size: 1.5rem;
    margin-bottom: .5rem;
}

#service-modal .service-btn .subtitle {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: .25rem;
    text-align: center;
}

@keyframes scaleIn {
    from {
        transform: scale(.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.hidden {
    display: none !important;
}

/* Desktop Override */
@media (min-width: 1024px) {
    body:not(.nav-overflow) .nav {
        all: unset;
        flex: 1;
        display: flex;
        justify-content: center;
        margin-inline: clamp(1rem, 5vw, 4rem);
    }

    body:not(.nav-overflow) .nav-title {
        display: none;
    }

    body:not(.nav-overflow) .nav-cta-item {
        display: none;
    }

    body:not(.nav-overflow) .nav ul {
        flex-direction: row;
    }

    body:not(.nav-overflow) .nav ul li {
        width: auto;
        opacity: 1;
        transform: none;
        transition: none;
    }

    body:not(.nav-overflow) .hdr-container {
        padding: .4rem 1.5rem;
       justify-content: space-between;
    }

    body:not(.nav-overflow) .sticky-hamburger {
        display: none;
    }

}

/* Mobile layout tune */
@media (max-width: 1023px) {
    .hdr-container {
        justify-content: space-between;
        gap: clamp(0.15rem, 1vw, 1rem);
    }

    .logo-wrapper {
        flex-basis: auto;
        justify-content: flex-start;
    }

    .logo {
        padding: 0;
        margin: 0;
    }

    .header-theme-toggle {
        display: none;
    }

    .nav-actions {
        margin-inline-start: 0;
    }

    .call-btn {
        display: inline-flex;
    }
}

@media (max-width: 600px) {
    .hdr-container {
        justify-content: space-between;
        gap: clamp(0.15rem, 1vw, 1rem);
    }

    .nav {
        flex-direction: column;
        align-items: stretch;
    }

    .nav ul {
        flex-direction: column;
        gap: clamp(0.25rem, 2vw, 1.25rem);
    }

    .nav ul li {
        flex: none;
        width: 100%;
    }

    .nav a {
        font-size: 1.08rem;
        padding: 0.25rem 0.5rem;
    }

    .call-btn {
        font-size: clamp(0.6rem, 3vw, 0.9rem);
        padding: clamp(0.25rem, 1.5vw, 0.5rem) clamp(0.4rem, 2vw, 0.75rem);
    }

    .nav-theme-toggle-wrapper {
        margin-bottom: 1rem;
    }

    .theme-toggle {
        width: clamp(28px, 8vw, 40px);
        height: clamp(28px, 8vw, 40px);
        font-size: clamp(0.75rem, 3vw, 1rem);
    }

    .logo {
        font-size: clamp(0.9rem, 5vw, 1.1rem);
    }
}

@media (max-width: 490px), (max-height: 550px) {
    .theme-toggle {
        position: static;
        transform: none;
    }
}

/* Layout when navigation collapses to hamburger */
/* .nav stays flex and off-canvas via transform */
body.nav-overflow .hdr-container {
    justify-content: space-between;
    gap: clamp(0.15rem, 1vw, 1rem);
}
body.nav-overflow .nav-actions {
    margin-inline-start: 0;
}
body.nav-overflow .logo-wrapper {
    flex-basis: auto;
    justify-content: flex-start;
}
body.nav-overflow .logo {
    margin: 0;
    font-size: 1rem;
}
body.nav-overflow .header-theme-toggle {
    display: none;
}
body.nav-overflow .nav-theme-toggle {
    display: flex;
}
body.nav-overflow .nav-theme-toggle-wrapper {
    display: flex;
    margin: 0 0 1rem;
    align-self: flex-start;
}
body.nav-overflow .call-btn {
    display: inline-flex;
}

@media (max-width: 300px) {
    .hdr-container {
        flex-wrap: wrap;
        justify-content: center;
    }

    .logo {
        white-space: normal;
        font-size: clamp(0.6rem, 5vw, 0.9rem);
    }

    .call-btn {
        font-size: clamp(0.55rem, 4vw, 0.85rem);
        padding: clamp(0.2rem, 1vw, 0.4rem) clamp(0.4rem, 1.5vw, 0.6rem);
    }
}

