﻿:root {
    --primary: #1a56db;
    --primary-dark: #1040b0;
    --primary-light: #e8f0fe;
    --accent: #f97316;
    --accent-light: #fff4ed;
    --success: #16a34a;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --surface-3: #f1f5f9;
    --border: #e2e8f0;
    --text: #0f172a;
    --text-2: #475569;
    --text-3: #94a3b8;
    --radius: 14px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.06);
    --shadow-hover: 0 4px 16px rgba(26,86,219,.18);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Vazirmatn', system-ui, sans-serif;
    background: var(--surface-2);
    color: var(--text);
    font-size: 16px;
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── HEADER ─── */
header {
    background: linear-gradient(135deg, #1a56db 0%, #1040b0 60%, #0d2d7a 100%);
    padding: 16px 16px 18px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(0,0,0,.2);
}

.header-top {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.logo {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.site-title {
    font-size: 18px;
    font-weight: 800;
    color: #fff;
    line-height: 1.2;
}

.site-subtitle {
    font-size: 12px;
    color: rgba(255,255,255,.7);
    font-weight: 400;
}

/* search */
.search-wrap {
    position: relative;
    margin-bottom: 0;
}

    .search-wrap input {
        width: 100%;
        padding: 12px 44px 12px 16px;
        border-radius: 12px;
        border: none;
        font-family: 'Vazirmatn', sans-serif;
        font-size: 15px;
        background: rgba(255,255,255,.95);
        color: var(--text);
        outline: none;
        box-shadow: 0 2px 8px rgba(0,0,0,.15);
    }

        .search-wrap input::placeholder {
            color: var(--text-3);
        }

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-3);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.clear-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-3);
    cursor: pointer;
    font-size: 18px;
    display: none;
}

/* ── تب‌بار: نوار مستقل زیر هدر — فقط تبلت ── */
.tabs-scroll {
    display: none;
}

@media (min-width: 768px) and (max-width: 1023px) {
    .tabs-scroll {
        display: flex;
        gap: 0;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        padding: 0 16px;
        position: sticky;
        top: 70px; /* هدر ارتفاعش ~88px */
        z-index: 99;
        box-shadow: 0 2px 8px rgba(0,0,0,.06);
    }

        .tabs-scroll::-webkit-scrollbar {
            display: none;
        }

    .tab-btn {
        background: transparent;
        color: var(--text-3);
        border-radius: 0;
        border-bottom: 2px solid transparent;
        padding: 12px 16px;
        font-size: 13px;
        font-weight: 600;
        white-space: nowrap;
    }

        .tab-btn:hover:not(.active) {
            background: var(--surface-3);
            color: var(--text);
        }

        .tab-btn.active {
            background: transparent;
            color: var(--primary);
            border-bottom-color: var(--primary);
        }
}

/* دسکتاپ — تب‌بار کاملاً پنهان */
@media (min-width: 1024px) {
    .tabs-scroll {
        display: none !important;
    }
}

.tab-btn {
    flex-shrink: 0;
    padding: 8px 14px;
    border-radius: 10px 10px 0 0;
    border: none;
    background: rgba(255,255,255,.15);
    color: var(--text);
    font-family: 'Vazirmatn', sans-serif;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all .2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

    .tab-btn:hover {
        background: rgba(255,255,255,.25);
        color: #fff;
    }

    .tab-btn.active {
        background: var(--surface-2);
        color: var(--primary);
    }

/* ─── MAIN ─── */
main {
    max-width: 900px;
    margin: 0 auto;
    padding: 16px 12px 80px;
}

/* search results bar */
.search-result-info {
    display: none;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    color: var(--primary-dark);
    margin-bottom: 14px;
    font-weight: 600;
}

/* ─── HERO SERVICES (top picks) ─── */
.section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-2);
    margin: 18px 0 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

    .section-title::after {
        content: '';
        flex: 1;
        height: 1px;
        background: var(--border);
    }

/* big card grid */
.hero-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

@media(min-width: 480px) {
    .hero-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.hero-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: all .2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 1.5px solid transparent;
}

    .hero-card:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow-hover);
        transform: translateY(-2px);
    }

    .hero-card:active {
        transform: scale(.97);
    }

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .card-icon svg {
        display: block;
    }
/* buttons must inherit font explicitly */
button {
    font-family: 'Vazirmatn', system-ui, sans-serif;
}

.hero-card .card-name {
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--text);
    font-family: 'Vazirmatn', system-ui, sans-serif;
}

.hero-card .card-tag {
    font-size: 10px;
    color: var(--text-3);
    font-weight: 400;
}

/* ─── CATEGORY PANEL ─── */
.category-panel {
    display: none;
}

    .category-panel.active {
        display: block;
    }

/* service list */
.service-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.service-card {
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
    box-shadow: var(--shadow);
    transition: all .2s;
    border: 1.5px solid transparent;
}

    .service-card:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow-hover);
    }

    .service-card:active {
        background: var(--primary-light);
    }

.service-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

    .service-icon svg {
        display: block;
    }

.service-info {
    flex: 1;
    min-width: 0;
}

.service-name {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.service-url {
    font-size: 11px;
    color: var(--text-3);
    direction: rtl;
    /* 1. Anchor the text to the left so the end (right side) eclipses with ... */
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    /* 2. Shrink the box and push it to the right so short URLs align perfectly with your RTL layout */
    width: fit-content;
    max-width: 100%;
    margin-left: auto;
}

.service-arrow {
    color: var(--text-3);
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

/* subcategory label */
.sub-label {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin: 16px 0 8px;
    padding-right: 4px;
}

/* ─── SEARCH RESULTS ─── */
#search-panel {
    display: none;
}

    #search-panel.active {
        display: block;
    }

/* ─── COMING SOON BADGE ─── */
.coming-soon {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 32px 20px;
    text-align: center;
    color: var(--text-3);
    border: 2px dashed var(--border);
    margin-top: 20px;
}

    .coming-soon .cs-icon {
        font-size: 40px;
        margin-bottom: 12px;
    }

    .coming-soon p {
        font-size: 14px;
    }

/* ── Bottom nav mine badge ── */
.nav-btn[data-panel="mine"] {
    position: relative;
}

.mine-badge-nav {
    position: absolute;
    top: 3px;
    right: calc(50% - 20px);
    background: var(--primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 15px;
    height: 15px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
    line-height: 1;
    border: 1.5px solid var(--surface);
    z-index: 2;
}

    .mine-badge-nav.show {
        display: flex;
    }


/* mine nav btn: bookmark fills when active */
.nav-btn[data-panel="mine"].active .nav-icon-wrap svg {
    fill: var(--primary);
}

/* ─── BOTTOM NAV (fixed, full-width, app-style) ─── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 env(safe-area-inset-bottom, 8px);
    z-index: 99;
    box-shadow: 0 -2px 12px rgba(0,0,0,.08);

    /* ─── FIREFOX & SAFARI JUMPING FIX ─── */
    /* Forces the element onto the GPU layer to stop repainting jitter */
    transform: translate3d(0, 0, 0);
    backface-visibility: hidden;
    will-change: transform;
    /* (Optional but highly recommended) Ensures it doesn't get cut off by iOS home bars */
    padding-bottom: env(safe-area-inset-bottom);
}

.nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    font-family: 'Vazirmatn', sans-serif;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-3);
    cursor: pointer;
    padding: 6px 0 4px;
    transition: color .2s;
    position: relative;
}

    .nav-btn.active {
        color: var(--primary);
    }

        .nav-btn.active .nav-icon-wrap {
            background: var(--primary-light);
            border-radius: 10px;
            width: 40px;
            height: 28px;
        }

.nav-icon-wrap {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all .16s;
}

    .nav-icon-wrap svg {
        display: block;
    }

/* ─── EMPTY STATE ─── */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-3);
}

    .empty-state .es-icon {
        font-size: 48px;
        margin-bottom: 12px;
    }

    .empty-state p {
        font-size: 14px;
    }

mark {
    background: #fff176;
    border-radius: 3px;
    padding: 0 2px;
    color: var(--text);
}

/* ─── BOOKMARK BUTTON ─── */
.bm-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all .18s;
    padding: 0;
    margin-right: -4px;
}

    .bm-btn:hover {
        background: var(--surface-3);
        color: var(--primary);
    }

    .bm-btn.saved {
        color: #f59e0b;
        background: #fef9ee;
    }

        .bm-btn.saved:hover {
            background: #fef3cd;
            color: #d97706;
        }

    .bm-btn svg {
        display: block;
        transition: transform .2s cubic-bezier(.34,1.56,.64,1);
    }

    .bm-btn.pop svg {
        transform: scale(1.35);
    }

/* card wraps the link + bookmark side by side */
.service-row {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    border: 1.5px solid transparent;
    transition: border-color .2s, box-shadow .2s;
    margin-bottom: 8px;
    overflow: hidden;
}

    .service-row:hover {
        border-color: var(--primary);
        box-shadow: var(--shadow-hover);
    }

    .service-row .service-card {
        flex: 1;
        box-shadow: none;
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        background: transparent;
        padding-left: 6px;
    }

        .service-row .service-card:hover {
            border-color: transparent;
            box-shadow: none;
        }

.bm-wrap {
    padding: 0 8px 0 4px;
    display: flex;
    align-items: center;
}

/* ─── MINE PANEL ─── */
.mine-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px 32px;
    text-align: center;
    gap: 12px;
}

.mine-empty-icon {
    width: 64px;
    height: 64px;
    background: var(--surface-3);
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-3);
    margin-bottom: 4px;
}

.mine-empty h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin: 0;
}

.mine-empty p {
    font-size: 13px;
    color: var(--text-2);
    line-height: 1.6;
    max-width: 260px;
    margin: 0;
}

.mine-empty-hint {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fef9ee;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 8px 14px;
    font-size: 12px;
    color: #92400e;
    margin-top: 4px;
}

.mine-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.mine-count {
    font-size: 12px;
    color: var(--text-3);
    font-weight: 500;
}

.mine-clear-btn {
    font-size: 12px;
    color: var(--text-3);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: all .15s;
}

    .mine-clear-btn:hover {
        background: #fef2f2;
        color: #dc2626;
    }

/* ─── MINE TAB BADGE ─── */
.tab-btn[data-panel="mine"] {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--primary);
    font-weight: 700;
}

    .tab-btn[data-panel="mine"] .tab-mine-icon {
        color: #f59e0b;
        display: flex;
    }

.mine-badge {
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
}

    .mine-badge.show {
        display: flex;
    }

/* ─── ADD ANIMATION ─── */
@keyframes mine-add {
    0% {
        transform: scale(1);
    }

    40% {
        transform: scale(1.06);
    }

    100% {
        transform: scale(1);
    }
}

.service-row.just-saved {
    animation: mine-add .3s ease;
}

/* ─── MINE DRAG HANDLE ─── */
.mine-drag {
    padding: 0 6px 0 10px;
    color: var(--text-3);
    cursor: grab;
    display: flex;
    align-items: center;
    touch-action: none;
    flex-shrink: 0;
}

    .mine-drag:active {
        cursor: grabbing;
    }

    .mine-drag svg {
        display: block;
        pointer-events: none;
    }

/* dragging state */
.service-row.dragging {
    opacity: .5;
    border-color: var(--primary) !important;
}

.service-row.drag-over {
    border-color: #f59e0b !important;
    background: #fef9ee;
}

/* ════════════════════════════════════════
     MOTION SYSTEM — Apple-quality interactions
     Easing · Duration · Stagger · Spring
     ════════════════════════════════════════ */

:root {
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
    --ease-decel: cubic-bezier(0, 0, 0.2, 1);
    --dur-instant: 80ms;
    --dur-fast: 160ms;
    --dur-normal: 240ms;
    --dur-slow: 380ms;
    --dur-enter: 460ms;
    --stagger: 38ms;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 1ms !important;
        transition-duration: 1ms !important;
    }
}

/* ── 1. PAGE LOAD SEQUENCE ── */
header {
    animation: hdr-enter var(--dur-enter) var(--ease-out) both;
}

@keyframes hdr-enter {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.logo {
    animation: logo-pop 500ms var(--ease-spring) 120ms both;
}

@keyframes logo-pop {
    from {
        transform: scale(0.4) rotate(-15deg);
        opacity: 0;
    }

    to {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

.site-title {
    animation: slide-in-rtl var(--dur-enter) var(--ease-out) 160ms both;
}

.site-subtitle {
    animation: slide-in-rtl var(--dur-enter) var(--ease-out) 200ms both;
}

@keyframes slide-in-rtl {
    from {
        transform: translateX(24px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.search-wrap {
    animation: rise-up var(--dur-enter) var(--ease-out) 240ms both;
}

@keyframes rise-up {
    from {
        transform: translateY(16px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.tabs-scroll {
    animation: fade-in var(--dur-slow) var(--ease-out) 300ms both;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.section-title {
    animation: rise-up var(--dur-normal) var(--ease-out) 360ms both;
}

.bottom-nav {
    animation: nav-enter var(--dur-enter) var(--ease-out) 400ms both;
}

@keyframes nav-enter {
    from {
        transform: translateY(100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}
/* Hero cards stagger — JS injects --i */
#top-services .hero-card {
    animation: card-rise var(--dur-slow) var(--ease-spring) both;
    animation-delay: calc(360ms + var(--i,0) * var(--stagger));
}

#cat-grid .hero-card {
    animation: card-rise var(--dur-slow) var(--ease-spring) both;
    animation-delay: calc(480ms + var(--i,0) * var(--stagger));
}

@keyframes card-rise {
    from {
        transform: translateY(22px) scale(0.94);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* ── 2. PANEL TRANSITIONS ── */
main {
    position: relative;
}

.category-panel {
    display: none;
    opacity: 0;
}

    .category-panel.active {
        display: block;
        opacity: 1;
        animation: panel-fade-in var(--dur-normal) var(--ease-out) both;
    }

@keyframes panel-fade-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}
/* Service rows stagger on panel entry */
.category-panel.active .service-row:nth-child(1) {
    animation: item-in var(--dur-slow) var(--ease-out) 20ms both;
}

.category-panel.active .service-row:nth-child(2) {
    animation: item-in var(--dur-slow) var(--ease-out) 55ms both;
}

.category-panel.active .service-row:nth-child(3) {
    animation: item-in var(--dur-slow) var(--ease-out) 88ms both;
}

.category-panel.active .service-row:nth-child(4) {
    animation: item-in var(--dur-slow) var(--ease-out) 116ms both;
}

.category-panel.active .service-row:nth-child(5) {
    animation: item-in var(--dur-slow) var(--ease-out) 140ms both;
}

.category-panel.active .service-row:nth-child(6) {
    animation: item-in var(--dur-slow) var(--ease-out) 160ms both;
}

.category-panel.active .service-row:nth-child(7) {
    animation: item-in var(--dur-slow) var(--ease-out) 175ms both;
}

.category-panel.active .service-row:nth-child(n+8) {
    animation: item-in var(--dur-slow) var(--ease-out) 185ms both;
}

.category-panel.active .sub-label {
    animation: fade-in var(--dur-normal) var(--ease-out) both;
}

@keyframes item-in {
    from {
        transform: translateX(14px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ── 3. HOVER MICRO-INTERACTIONS ── */
.hero-card {
    transition: transform var(--dur-fast) var(--ease-spring), border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}

    .hero-card:hover {
        transform: translateY(-4px) scale(1.03);
        box-shadow: 0 8px 24px rgba(26,86,219,.16);
    }

    .hero-card:active {
        transform: scale(0.95) !important;
        transition-duration: var(--dur-instant);
    }

.card-icon {
    transition: transform var(--dur-fast) var(--ease-spring);
}

.hero-card:hover .card-icon {
    transform: scale(1.12) rotate(-4deg);
}

.hero-card .card-name {
    transition: color var(--dur-fast) var(--ease-out);
}

.hero-card:hover .card-name {
    color: var(--primary);
}

.service-row {
    transition: border-color var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
    border-right: 3px solid transparent;
}

    .service-row:hover {
        transform: translateX(-3px);
        border-right-color: var(--primary);
        box-shadow: var(--shadow-hover);
    }

    .service-row:active {
        transform: scale(0.982) !important;
        background: var(--surface-3);
        transition-duration: var(--dur-instant);
    }

.service-icon {
    transition: transform var(--dur-fast) var(--ease-spring);
}

.service-row:hover .service-icon {
    transform: scale(1.1);
}

.service-arrow {
    transition: transform var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}

.service-row:hover .service-arrow {
    transform: translateX(-4px);
    color: var(--primary);
}

.service-name {
    transition: color var(--dur-fast) var(--ease-out);
}

.service-row:hover .service-name {
    color: var(--primary);
}

/* Tab hover + active indicator */
.tab-btn {
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-spring);
}

    .tab-btn:hover:not(.active) {
        transform: translateY(-1px);
    }

    .tab-btn:active {
        transform: scale(0.93);
        transition-duration: var(--dur-instant);
    }

    .tab-btn.active {
        position: relative;
        overflow: hidden;
    }

        .tab-btn.active::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 10%;
            right: 10%;
            height: 2px;
            background: var(--primary);
            border-radius: 2px 2px 0 0;
            animation: tab-line var(--dur-fast) var(--ease-out) both;
        }

@keyframes tab-line {
    from {
        transform: scaleX(0);
    }

    to {
        transform: scaleX(1);
    }
}

/* Bottom nav tap */
.nav-btn {
    transition: color var(--dur-fast) var(--ease-out);
}

    .nav-btn .nav-icon-wrap {
        transition: transform var(--dur-fast) var(--ease-spring);
    }

    .nav-btn:hover .nav-icon-wrap {
        transform: translateY(-2px);
    }

    .nav-btn:active .nav-icon-wrap {
        transform: scale(0.84);
        transition-duration: var(--dur-instant);
    }

    .nav-btn.active .nav-icon-wrap {
        animation: nav-bounce var(--dur-slow) var(--ease-spring) both;
    }

@keyframes nav-bounce {
    0% {
        transform: scale(1);
    }

    35% {
        transform: scale(0.78) translateY(2px);
    }

    68% {
        transform: scale(1.22) translateY(-4px);
    }

    100% {
        transform: scale(1) translateY(0);
    }
}

/* ── 4. SEARCH INTERACTIONS ── */
.search-wrap input {
    transition: box-shadow var(--dur-fast) var(--ease-out), transform var(--dur-normal) var(--ease-spring);
}

    .search-wrap input:focus {
        box-shadow: 0 0 0 3px rgba(26,86,219,.3), 0 2px 8px rgba(0,0,0,.15);
        transform: scaleX(1.01);
    }

#search-panel.active {
    animation: rise-up var(--dur-normal) var(--ease-out) both;
}

.clear-btn {
    transition: opacity var(--dur-fast) var(--ease-out), transform var(--dur-fast) var(--ease-spring);
}

    .clear-btn:hover {
        transform: scale(1.18) translateY(-50%) !important;
    }

    .clear-btn:active {
        transform: scale(0.86) translateY(-50%) !important;
    }

/* ── 5. BOOKMARK MICRO-INTERACTION ── */
.bm-btn {
    transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), transform var(--dur-instant) var(--ease-spring);
}

    .bm-btn:hover {
        transform: scale(1.14);
    }

    .bm-btn:active {
        transform: scale(0.84);
    }

    .bm-btn.saved svg {
        animation: bm-fill var(--dur-slow) var(--ease-spring) both;
    }

@keyframes bm-fill {
    0% {
        transform: scale(1);
    }

    28% {
        transform: scale(0.65) rotate(-12deg);
    }

    62% {
        transform: scale(1.4) rotate(6deg);
    }

    100% {
        transform: scale(1) rotate(0deg);
    }
}

/* ── 6. MINE PANEL ── */
.mine-empty {
    animation: mine-in 500ms var(--ease-spring) 60ms both;
}

@keyframes mine-in {
    from {
        transform: translateY(28px) scale(0.95);
        opacity: 0;
    }

    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.mine-empty-icon {
    animation: float 3.2s ease-in-out infinite;
}

@keyframes float {
    0%,100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

@keyframes mine-add {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245,158,11,0);
    }

    30% {
        transform: scale(1.03);
        box-shadow: 0 0 0 5px rgba(245,158,11,.28);
    }

    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(245,158,11,0);
    }
}

.service-row.just-saved {
    animation: mine-add 420ms var(--ease-spring) !important;
}

/* ── 7. SCROLL REVEAL ── */
.reveal {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity var(--dur-slow) var(--ease-out), transform var(--dur-slow) var(--ease-out);
}

    .reveal.in-view {
        opacity: 1;
        transform: translateY(0);
    }

/* ── 8. PULL-TO-REFRESH ── */
#ptr-indicator {
    position: fixed;
    top: -60px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 40px;
    background: var(--surface);
    border-radius: 50%;
    box-shadow: 0 2px 14px rgba(0,0,0,.13);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    transition: top var(--dur-fast) var(--ease-out);
    z-index: 200;
}

    #ptr-indicator.visible {
        top: 72px;
    }

    #ptr-indicator svg {
        transition: transform var(--dur-fast) linear;
    }

    #ptr-indicator.releasing svg {
        animation: spin 600ms linear infinite;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ════════════════════════════════════════════════════════
     RESPONSIVE DESIGN SYSTEM
     Breakpoints: 375px · 768px · 1024px
     RTL-first, Persian typography, mobile-primary
     ════════════════════════════════════════════════════════ */

/* ── Design tokens per breakpoint ── */
:root {
    /* Mobile base (375px) */
    --fs-display: 18px;
    --fs-title: 15px;
    --fs-body: 14px;
    --fs-caption: 12px;
    --fs-micro: 10px;
    --sp-page: 12px;
    --sp-card: 12px 10px;
    --sp-row: 10px 12px;
    --sp-gap: 8px;
    --sp-section: 14px;
    --card-icon-size: 44px;
    --card-icon-radius: 11px;
    --list-icon-size: 38px;
    --card-cols: 3;
}

/* ════════════ TABLET 768px ════════════ */
@media (min-width: 768px) {
    :root {
        --fs-display: 22px;
        --fs-title: 17px;
        --fs-body: 15px;
        --fs-caption: 13px;
        --fs-micro: 11px;
        --sp-page: 24px;
        --sp-card: 16px 14px;
        --sp-row: 13px 16px;
        --sp-gap: 12px;
        --sp-section: 20px;
        --card-icon-size: 52px;
        --card-icon-radius: 14px;
        --list-icon-size: 44px;
        --card-cols: 4;
    }
}

/* ════════════ DESKTOP 1024px ════════════ */
@media (min-width: 1024px) {
    :root {
        --fs-display: 26px;
        --fs-title: 18px;
        --fs-body: 15px;
        --fs-caption: 13px;
        --fs-micro: 11px;
        --sp-page: 40px;
        --sp-card: 20px 16px;
        --sp-row: 14px 20px;
        --sp-gap: 14px;
        --sp-section: 28px;
        --card-icon-size: 56px;
        --card-icon-radius: 16px;
        --list-icon-size: 48px;
        --card-cols: 6;
    }
}

/* ════════════════════════════════════════
     1. HEADER & NAVIGATION
     Mobile:  stacked, bottom-nav, scroll tabs
     Tablet:  inline search, tab bar stays
     Desktop: horizontal sidebar + top bar
     ════════════════════════════════════════ */

/* ── MOBILE (base) ── */
.header-top {
    gap: 10px;
    margin-bottom: 12px;
}

.logo {
    width: 38px;
    height: 38px;
    border-radius: 9px;
}

.site-title {
    font-size: var(--fs-display);
}

.site-subtitle {
    font-size: var(--fs-caption);
}

.search-wrap input {
    font-size: 15px;
    padding: 11px 42px 11px 14px;
}

.tabs-scroll {
    gap: 6px;
}

.tab-btn {
    font-size: 12px;
    padding: 7px 12px;
}

/* Bottom nav: visible on mobile only by default */
.bottom-nav {
    display: flex;
}
/* main gets padding so content clears bottom nav */
main {
    padding: var(--sp-section) var(--sp-page) 90px;
}

/* ── TABLET 768px ── */
@media (min-width: 768px) and (max-width: 1023px) {
    header {
        padding: 14px var(--sp-page) 14px;
        display: flex;
        align-items: center;
        gap: 16px;
    }

    .header-top {
        flex-shrink: 0;
        margin-bottom: 0;
        align-items: center;
    }

    .logo {
        width: 40px;
        height: 40px;
        border-radius: 11px;
    }

    .site-title {
        font-size: 18px;
    }

    .site-subtitle {
        font-size: 12px;
    }

    /* سرچ در همان ردیف، کشیده می‌شه */
    .search-wrap {
        flex: 1;
        max-width: 480px;
        margin-bottom: 0;
        margin-right: auto;
    }

        .search-wrap input {
            font-size: 14px;
            padding: 10px 40px 10px 14px;
        }

    .bottom-nav {
        display: none;
    }

    main {
        padding: 24px var(--sp-page) 40px;
        max-width: 900px;
    }
}

/* ── DESKTOP 1024px ── */
@media (min-width: 1024px) {
    body {
        display: flex;
        flex-direction: column;
        min-height: 100vh;
    }

    /* هدر فشرده — navbar افقی */
    header {
        padding: 0 48px;
        display: flex;
        align-items: center;
        height: 60px;
    }

    /* header-top کل عرض رو می‌گیره */
    .header-top {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        margin-bottom: 0;
        gap: 0;
    }

        /* لوگو + عنوان — گروه راست */
        .header-top > :first-child,
        .header-top > div:first-of-type {
            flex-shrink: 0;
        }

    /* لوگو + عنوان در کنار هم */
    /* لوگو مربعی در دسکتاپ مخفی — برند در hero نشون داده می‌شه */
    .logo {
        display: none;
    }

    /* عنوان «انجیر» در navbar — کوچک و clean */
    .site-title {
        font-size: 17px;
        font-weight: 800;
        letter-spacing: -0.3px;
    }

    .site-subtitle {
        display: none;
    }

    /* header-top: عنوان سمت راست، dark btn سمت چپ */
    .header-top {
        gap: 16px;
    }

    /* سرچ در هدر — مخفی در دسکتاپ */
    header .search-wrap {
        display: none;
    }

    /* No sidebar */
    .page-body {
        display: block;
        max-width: 860px;
        margin: 0 auto;
        width: 100%;
    }

    main {
        padding: 0 24px 48px;
        max-width: none;
    }

    .bottom-nav {
        display: none;
    }

    /* ── سرچ Google-style — طراحی تمیز ── */
    .desktop-search-hero {
        display: flex;
        flex-direction: column;
        align-items: center;
        padding: 52px 24px 40px;
        background: var(--surface-2);
    }

        .desktop-search-hero .hero-brand {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 6px;
            margin-bottom: 32px;
        }
        /* لوگوی مربعی حذف شد */
        .desktop-search-hero .hero-logo {
            display: none;
        }

        .desktop-search-hero .hero-title {
            font-size: 52px;
            font-weight: 800;
            color: var(--primary);
            line-height: 1;
            letter-spacing: -1px;
        }

        .desktop-search-hero .hero-sub {
            font-size: 15px;
            color: var(--text-3);
            font-weight: 400;
            margin-top: 4px;
        }

        .desktop-search-hero .search-wrap {
            width: 100%;
            max-width: 580px;
            display: flex !important;
        }

            .desktop-search-hero .search-wrap input {
                font-size: 16px;
                padding: 15px 52px 15px 20px;
                border-radius: 50px;
                border: 1.5px solid var(--border);
                background: var(--surface);
                box-shadow: 0 2px 10px rgba(0,0,0,.07);
                transition: border-color .15s, box-shadow .15s;
            }

                .desktop-search-hero .search-wrap input:focus {
                    border-color: var(--primary);
                    box-shadow: 0 0 0 4px rgba(26,86,219,.1), 0 2px 10px rgba(0,0,0,.07);
                    transform: none;
                }

        .desktop-search-hero .search-icon {
            left: 18px;
        }

        .desktop-search-hero .search-wrap input::placeholder {
            font-size: 14px;
            color: var(--text-3);
        }
}

/* Sidebar disabled — not used */
#desktop-sidebar {
    display: none !important;
}

/* Desktop search hero — فقط دسکتاپ */
.desktop-search-hero {
    display: none;
}

@media (min-width: 1024px) {
    .desktop-search-hero {
        display: flex;
    }
}

/* ════════════════════════════════════════
     2. HERO CARD GRID
     Mobile:  3 col, compact
     Tablet:  4 col, bigger icons
     Desktop: 6 col, larger padding
     ════════════════════════════════════════ */

.hero-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--sp-gap);
    margin-bottom: var(--sp-section);
}

@media (min-width: 480px) {
    .hero-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

@media (min-width: 768px) {
    .hero-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--sp-gap);
    }
}

@media (min-width: 1024px) {
    .hero-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (min-width: 1024px) {
    .hero-grid {
        grid-template-columns: repeat(6, 1fr);
        gap: var(--sp-gap);
    }
}

.hero-card {
    padding: var(--sp-card);
    gap: 7px;
}

.card-icon {
    width: var(--card-icon-size);
    height: var(--card-icon-size);
    border-radius: var(--card-icon-radius);
}

.hero-card .card-name {
    font-size: var(--fs-caption);
}

@media (min-width: 768px) {
    .hero-card .card-name {
        font-size: 13px;
    }

    .card-icon svg {
        width: 24px;
        height: 24px;
    }
}

@media (min-width: 1024px) {
    .card-icon svg {
        width: 26px;
        height: 26px;
    }
}

/* ════════════════════════════════════════
     3. SERVICE LIST ROWS
     Mobile:  full-width single column
     Tablet:  two-column grid
     Desktop: three-column grid in panels
     ════════════════════════════════════════ */

.service-list {
    gap: var(--sp-gap);
}

@media (min-width: 768px) {
    /* Two-column service list on tablet */
    .service-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--sp-gap);
    }
    /* Sub-labels span full width */
    .sub-label {
        grid-column: 1 / -1;
        font-size: var(--fs-caption);
        margin: var(--sp-section) 0 4px;
    }
}

@media (min-width: 1024px) {
    /* Three-column service list on desktop */
    .service-list {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .sub-label {
        grid-column: 1 / -1;
    }
}

/* Row padding scaling */
.service-row .service-card {
    padding: var(--sp-row);
}

.service-icon {
    width: var(--list-icon-size);
    height: var(--list-icon-size);
}

.service-name {
    font-size: var(--fs-body);
}

.service-url {
    font-size: calc(var(--fs-caption) - 1px);
}

/* ════════════════════════════════════════
     4. SECTION LABELS & TYPOGRAPHY
     ════════════════════════════════════════ */

.section-title {
    font-size: var(--fs-title);
    margin: var(--sp-section) 0 10px;
}

.sub-label {
    font-size: var(--fs-micro);
    margin: var(--sp-section) 0 6px;
}

@media (min-width: 768px) {
    .section-title {
        font-size: var(--fs-display);
        margin: 24px 0 14px;
    }
}

@media (min-width: 1024px) {
    .section-title {
        margin: 32px 0 16px;
    }
}

/* ════════════════════════════════════════
     5. SEARCH BAR RESPONSIVE
     Mobile:  full width below header-top
     Tablet:  inline right of logo/title
     Desktop: fixed-width center slot
     ════════════════════════════════════════ */

@media (min-width: 768px) {
    .search-wrap input {
        border-radius: 10px;
    }
    /* Search icon stays left (LTR position for icon, RTL text) */
}

/* ════════════════════════════════════════
     6. MINE PANEL RESPONSIVE
     ════════════════════════════════════════ */

@media (min-width: 768px) {
    /* Mine list uses same 2-col layout */
    #mine-list {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: var(--sp-gap);
    }

    .mine-header {
        margin-bottom: 16px;
    }
}

@media (min-width: 1024px) {
    #mine-list {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* ════════════════════════════════════════
     7. BOTTOM NAV RESPONSIVE
     Mobile:  fixed bottom, 5 items, icon+label
     Tablet:  hidden (tab bar takes over)
     Desktop: hidden (sidebar takes over)
     ════════════════════════════════════════ */

.nav-btn {
    font-size: var(--fs-micro);
}

.nav-icon-wrap {
    width: 26px;
    height: 26px;
}

@media (min-width: 768px) {
    .bottom-nav {
        display: none !important;
    }
    /* Add visual active indicator to tab bar instead */
    .tab-btn.active {
        background: var(--surface-2);
        color: var(--primary);
        font-weight: 700;
    }
}

/* ════════════════════════════════════════
     8. SEARCH RESULT PANEL
     ════════════════════════════════════════ */

.search-result-info {
    font-size: var(--fs-caption);
    padding: 9px 12px;
}

@media (min-width: 768px) {
    .search-result-info {
        font-size: 13px;
        padding: 10px 16px;
    }

    #search-panel .service-list {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 1024px) {
    #search-panel .service-list {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

/* ════════════════════════════════════════
     9. CONTENT PRIORITIZATION
     Hide/show elements per breakpoint
     ════════════════════════════════════════ */

/* Service URL: hidden on smallest phones, shown 400px+ */
@media (max-width: 374px) {
    .service-row .service-card {
        padding: 10px;
    }
}

/* On desktop, show full URL always */
@media (min-width: 1024px) {
    .service-url {
        display: block;
    }
}

/* Subtitle in header: hide on very small */
@media (max-width: 359px) {
    .site-subtitle {
        display: none;
    }
}

/* ════════════════════════════════════════
     10. COMING SOON & EMPTY STATE
     ════════════════════════════════════════ */

.coming-soon {
    padding: 28px 16px;
}

    .coming-soon p {
        font-size: var(--fs-body);
    }

.empty-state {
    padding: 40px 16px;
}

    .empty-state p {
        font-size: var(--fs-body);
    }

@media (min-width: 768px) {
    .coming-soon {
        padding: 48px 32px;
    }

    .empty-state {
        padding: 64px 32px;
    }
}

/* ════════════════════════════════════════
     11. PRINT STYLES
     ════════════════════════════════════════ */

@media print {
    header, .bottom-nav, .search-wrap, .tabs-scroll, .bm-btn {
        display: none !important;
    }

    main {
        padding: 0;
    }

    .category-panel {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
    }

    .service-list {
        grid-template-columns: 1fr 1fr 1fr;
    }

    .service-row {
        break-inside: avoid;
        border: 1px solid #ccc;
    }
}

/* ════════════════════════════════════════
     12. SCROLLBAR POLISH (desktop)
     ════════════════════════════════════════ */
@media (min-width: 768px) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-track {
        background: transparent;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 3px;
    }

        ::-webkit-scrollbar-thumb:hover {
            background: var(--text-3);
        }
}

/* ════════════════════════════════════════
     DARK MODE — class-based (.dark روی html)
     پیش‌فرض: light — کاربر می‌تونه toggle کنه
     ════════════════════════════════════════ */
html.dark {
    --primary: #4d7cf4;
    --primary-dark: #3b6ae0;
    --primary-light: #1e2d54;
    --surface: #1c1c2e;
    --surface-2: #16162a;
    --surface-3: #22223a;
    --border: #2e2e50;
    --text: #e8e8f2;
    --text-2: #9898b8;
    --text-3: #55557a;
    --shadow: 0 1px 3px rgba(0,0,0,.4), 0 4px 12px rgba(0,0,0,.3);
    --shadow-hover: 0 4px 20px rgba(77,124,244,.35);
}

    html.dark header {
        background: linear-gradient(135deg, #1a2b6b 0%, #111840 60%, #080f2a 100%);
    }

    html.dark .search-wrap input {
        background: rgba(255,255,255,.07);
        color: var(--text);
    }

        html.dark .search-wrap input::placeholder {
            color: var(--text-3);
        }

    html.dark .tabs-scroll {
        background: var(--surface);
        border-bottom-color: var(--border);
    }

    html.dark .tab-btn {
        color: var(--text-2);
    }

        html.dark .tab-btn:hover:not(.active) {
            background: var(--surface-3);
        }

        html.dark .tab-btn.active {
            color: var(--primary);
            border-bottom-color: var(--primary);
        }

    html.dark .hero-card {
        background: var(--surface);
    }

    html.dark .service-row {
        background: var(--surface);
    }

    html.dark .service-card {
        background: transparent;
    }

    html.dark .bottom-nav {
        background: var(--surface);
        border-top-color: var(--border);
    }

    html.dark .coming-soon {
        background: var(--surface);
        border-color: var(--border);
    }

    html.dark mark {
        background: #4a3c00;
        color: #ffd966;
    }

    html.dark .mine-empty-icon {
        background: var(--surface-3);
    }

    html.dark .bm-btn.saved {
        background: #3a2d00;
        color: #f59e0b;
    }

    html.dark .search-result-info {
        background: #1e2d54;
        color: #8ab0ff;
    }

    html.dark .mine-empty-hint {
        background: #2a2000;
        border-color: #4a3a00;
        color: #c8a000;
    }

    html.dark .mine-clear-btn:hover {
        background: #2a1515;
        color: #f87171;
    }

    html.dark #ptr-indicator {
        background: var(--surface);
    }

    html.dark .desktop-search-hero .hero-title {
        color: var(--primary);
    }

    html.dark .desktop-search-hero {
        background: var(--surface-2);
    }

        html.dark .desktop-search-hero .search-wrap input {
            background: var(--surface);
            border-color: var(--border);
            color: var(--text);
        }

/* ─── دکمه dark/light toggle ─── */
.theme-btn {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,.15);
    color: rgba(255,255,255,.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .18s, transform .18s;
}

    .theme-btn:hover {
        background: rgba(255,255,255,.25);
        transform: scale(1.08);
    }

    .theme-btn:active {
        transform: scale(0.92);
    }

    .theme-btn svg {
        display: block;
        transition: transform .35s cubic-bezier(0.34,1.56,0.64,1);
    }
    /* آیکون خورشید نمایان — حالت تاریک */
    .theme-btn .icon-sun {
        display: none;
    }

    .theme-btn .icon-moon {
        display: block;
    }

html.dark .theme-btn .icon-sun {
    display: block;
}

html.dark .theme-btn .icon-moon {
    display: none;
}

/* در موبایل و تبلت — دکمه آخرین آیتم header-top، سمت چپ */
@media (max-width: 1023px) {
    .theme-btn {
        margin-right: auto;
    }
}

/* ── WIDER DESKTOP VIEW ── */
@media (min-width: 1024px) {
    body {
        background: var(--surface-3);
    }

    .page-body {
        max-width: 1024px !important;
        margin: 24px auto !important;
        padding: 32px;
        background: var(--surface);
        box-shadow: var(--shadow);
        border-radius: 20px;
        min-height: calc(100vh - 100px);
    }

    header, .desktop-search-hero {
        max-width: 100% !important;
    }

    .header-top, .search-wrap {
        max-width: 1024px;
        margin: 0 auto;
    }

    .hero-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)) !important;
    }

    .bottom-nav {
        display: none !important;
    }
}


/* ── CATEGORY ICON HEADER ANIMATION ── */
@keyframes popInLeft {
    0% {
        transform: translateX(-40px) scale(0.5);
        opacity: 0;
    }

    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

/* The animation only runs when the panel becomes active */
.category-panel.active .panel-header-icon {
    animation: popInLeft 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ── CREATIVE HERO FLAG LAYOUT ── */
.creative-hero {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 24px;
    margin-bottom: 24px;
    text-align: right;
}

.hero-titles {
    display: flex;
    flex-direction: column;
}

.hero-art-flag {
    height: 100px; /* Large enough to showcase the brush details */
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 8px 16px rgba(218, 0, 0, 0.15)); /* Soft red shadow */
    /* A subtle floating animation for a premium feel */
    animation: floatArt 5s ease-in-out infinite;
    transform-origin: center bottom;
}

@keyframes floatArt {
    0%, 100% {
        transform: translateY(0) rotate(0deg) scale(1);
    }

    50% {
        transform: translateY(-8px) rotate(4deg) scale(1.02);
    }
}

/* ── THE NUCLEAR MOBILE SEARCH INPUT FIX ── */

.search-wrap {
    position: relative;
    z-index: 9999 !important; /* Forces the container above ALL other invisible app layers */
    pointer-events: auto !important;
}

    .search-wrap input {
        position: relative;
        z-index: 2 !important;
        /* Force the OS to allow text selection and keyboard triggers */
        -webkit-user-select: text !important;
        user-select: text !important;
        -webkit-user-modify: read-write !important;
        -webkit-touch-callout: default !important; /* Critical for iOS */
        touch-action: manipulation !important; /* Tells the phone to treat taps as typing, not dragging */
        pointer-events: auto !important;
        cursor: text !important;
    }

    .search-wrap .search-icon {
        position: absolute !important;
        z-index: 3 !important;
        pointer-events: none !important; /* Your finger taps directly THROUGH the SVG */
    }

    .search-wrap .clear-btn {
        position: absolute !important;
        z-index: 4 !important;
        pointer-events: auto !important;
    }

/* ── REPORT BROKEN LINK BUTTON ── */
.report-btn {
    position: absolute;
    top: 8px;
    left: 8px;
    color: var(--text-3);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: all 0.2s ease-out;
    z-index: 5;
    /* Base State: Visible but subtle (For ALL touch devices, small or large) */
    opacity: 0.6;
    transform: scale(0.9);
}

    .report-btn:hover {
        color: #ef4444;
        background: #fef2f2;
        border-color: #fca5a5;
        transform: scale(1.05);
        opacity: 1;
    }

    .report-btn:active {
        transform: scale(0.9);
    }

/* Mouse/Trackpad Only: Hide by default, reveal on hover */
@media (hover: hover) and (pointer: fine) {
    .report-btn {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-4px);
    }

    .service-row:hover .report-btn {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
}

/* Desktop Behavior: Hidden by default, reveals on hover */
@media (min-width: 768px) {
    .report-btn {
        opacity: 0;
        pointer-events: none;
        transform: translateY(-4px); /* Slight slide-down animation on reveal */
    }

    .service-row:hover .report-btn {
        opacity: 1;
        pointer-events: auto;
        transform: translateY(0);
    }
}


/* ── HEADER OVERLAP FIX ── */
header {
    z-index: 10005 !important; /* Forces header above the Nuclear Search Fix */
    transition: box-shadow 0.3s ease;
}

/* Home page font size increase */
.hero-card .card-name {
    font-size: 16px !important;
    font-weight: 600 !important;
}


/* ── NEW CATEGORY CARD LAYOUT ── */
.service-row.new-layout {
    display: flex;
    align-items: center;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 10px;
    gap: 16px;
    position: relative;
}

/* Right column: holds Icon and Bookmark */
.service-side-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Custom Bookmark Button overrides */
.bm-btn.custom-bm {
    position: static !important;
    padding: 4px;
    display: flex;
    background: transparent;
    border: none;
    color: var(--text-3);
    cursor: pointer;
}

    .bm-btn.custom-bm.saved {
        color: var(--primary);
    }

/* Body column: holds Text and Arrow */
.service-card-body {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.service-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    min-width: 0; /* Prevents text overflow breaking flexbox */
}

/* 2-Line wrapping for title */
.service-name {
    font-size: 14.5px;
    font-weight: 600;
    white-space: normal !important;
    display: -webkit-box !important;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.6;
}

.service-arrow {
    flex-shrink: 0;
    color: var(--text-3);
    margin-right: auto; /* Pushes arrow to the absolute end (left side in RTL) */
    padding-right: 10px;
}


/* ── استایل‌های پاپ‌آپ خوش‌آمدگویی (Modal) ── */
.welcome-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    /* این مقدار را بسیار بالا بردیم تا قطعاً روی هدر بیاید */
    z-index: 999999 !important;
    opacity: 0;
    transition: opacity 0.3s ease;
    direction: rtl;
    font-family: 'Vazirmatn', sans-serif;
}

    .welcome-overlay.show {
        opacity: 1;
    }

.welcome-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 24px;
    max-width: 600px;
    width: 92%;
    /* محدود کردن ارتفاع پاپ‌آپ به ۸۵ درصد ارتفاع صفحه موبایل */
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
    transform: translateY(20px);
    transition: transform 0.3s ease;
}

.welcome-overlay.show .welcome-modal {
    transform: translateY(0);
}

.welcome-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    color: var(--text);
    flex-shrink: 0; /* جلوگیری از جمع شدن هدر پاپ‌آپ */
}

    .welcome-header svg {
        color: var(--primary, #1a56db);
        flex-shrink: 0;
    }

    .welcome-header h3 {
        margin: 0;
        font-size: 18px;
        font-weight: 800;
    }

/* بخش میانی متن را اسکرول‌دار کردیم */
.welcome-body {
    overflow-y: auto;
    padding-left: 8px; /* جا برای اسکرول بار */
    margin-bottom: 16px;
}

    /* استایل‌دهی به اسکرول‌بار تا زیبا باشد */
    .welcome-body::-webkit-scrollbar {
        width: 4px;
    }

    .welcome-body::-webkit-scrollbar-thumb {
        background: var(--border);
        border-radius: 4px;
    }

    .welcome-body p {
        color: var(--text);
        opacity: 0.85;
        font-size: 13.5px;
        line-height: 1.8;
        margin-bottom: 12px;
        text-align: justify;
    }

.welcome-btn {
    background: var(--primary, #1a56db);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 700;
    font-family: inherit;
    width: 100%;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    flex-shrink: 0; /* دکمه پایین همیشه ثابت و در دسترس می‌ماند */
}

    .welcome-btn:hover {
        opacity: 0.9;
    }

    .welcome-btn:active {
        transform: scale(0.98);
    }


/* ── استایل‌های محافظتی برای جلوگیری از به هم ریختگی در موبایل ── */
.header-brand-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
    flex: 1;
    min-width: 0;
}

.header-text-wrap {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
}

    .header-text-wrap .site-title,
    .header-text-wrap .site-subtitle,
    .header-text-wrap .header-date {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

.header-date {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    margin-top: 4px;
    color: #ffffff;
    opacity: 0.95;
}

html.dark .header-date {
    color: var(--text-2, #cbd5e1);
}

/* ── مخفی کردن لوگوی هدر در حالت دسکتاپ ── */
@media (min-width: 1024px) {
    .header-top .logo {
        display: none !important;
    }
}

/* ── دکمه جستجو در ذره‌بین ── */
.zarebin-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(26, 86, 219, 0.1);
    color: var(--primary, #1a56db);
    padding: 6px 12px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    transition: all 0.2s ease;
}

/* رنگ دکمه در حالت شب */
html.dark .zarebin-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.zarebin-btn:hover {
    background: rgba(26, 86, 219, 0.15);
    transform: translateY(-1px);
}

html.dark .zarebin-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* مخفی کردن متن موبایل در حالت پیش‌فرض (دسکتاپ) */
.zarebin-text-mobile {
    display: none;
}

/* ── حالت واکنش‌گرا (موبایل) ── */
@media (max-width: 480px) {
    .zarebin-text-desktop {
        display: none;
    }
    /* متن طولانی مخفی می‌شود */
    .zarebin-text-mobile {
        display: inline;
    }
    /* متن کوتاه نمایان می‌شود */
    .zarebin-btn {
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
    }
}

@keyframes spin-anim {
    100% {
        transform: rotate(360deg);
    }
}

.api-loading-spin {
    animation: spin-anim 1s linear infinite;
    display: inline-block;
}

/* ── DESKTOP MINE (BOOKMARK) BUTTON ── */
.desktop-mine-btn {
    display: none; /* Hidden on mobile/tablet */
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    padding: 8px 16px;
    border-radius: 10px;
    color: #fff;
    cursor: pointer;
    font-family: 'Vazirmatn', sans-serif;
    font-weight: 600;
    font-size: 14px;
    transition: background 0.2s, transform 0.2s;
}

    .desktop-mine-btn:hover {
        background: rgba(255, 255, 255, 0.25);
        transform: translateY(-1px);
    }

.mine-badge-desktop {
    background: #f59e0b;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    display: none;
    line-height: 1;
}

/* Show only on Desktop */
@media (min-width: 1024px) {
    .desktop-mine-btn {
        display: flex;
    }
}

/* Dark Mode Overrides */
html.dark .desktop-mine-btn {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
}

    html.dark .desktop-mine-btn:hover {
        background: rgba(255, 255, 255, 0.15);
    }