/**
 * מגירת קטגוריות + הדר: מובייל בשורת כלים (קטגוריות | לוגו ממורכז | חיפוש+שפה), דסקטופ בשורה אחת.
 */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

:root {
    --aligali-public-header-sticky-top: 0px;
}

/* Sticky storefront header (category trigger stays reachable). Homepage uses home-sticky-header.css instead. */
body:not(.home-index) header[role='banner'] {
    position: sticky;
    top: calc(var(--aligali-public-header-sticky-top, 0px) + env(safe-area-inset-top, 0px));
    z-index: 1000;
}

/* Logo story motion: gentle entrance + compact on scroll (desktop + mobile). */
header[role='banner'] .header-toolbar__logo {
    transform: translateY(8px) scale(0.985);
    opacity: 0;
    transition:
        transform 560ms cubic-bezier(0.22, 1, 0.36, 1),
        opacity 420ms ease,
        filter 420ms ease;
    filter: saturate(0.94);
    will-change: transform, opacity;
}

header[role='banner'].ali-logo-entered .header-toolbar__logo {
    transform: translateY(0) scale(1);
    opacity: 1;
    filter: saturate(1);
}

header[role='banner'] .header-toolbar__logo img {
    transition: transform 360ms cubic-bezier(0.22, 1, 0.36, 1), opacity 300ms ease;
    transform-origin: center center;
}

header[role='banner'].ali-logo-compact .header-toolbar__logo img {
    transform: scale(0.95);
    opacity: 0.96;
}

header[role='banner'].ali-logo-upscroll .header-toolbar__logo img {
    transform: scale(1.015);
    opacity: 1;
}

/* ——— מובייל: רשת הדר ——— */
@media (max-width: 768px) {
    header[role='banner'] .header-inner {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto !important;
        grid-template-rows: auto !important;
        grid-template-areas:
            'hdr-trail hdr-logo hdr-lead' !important;
        align-items: center !important;
        column-gap: 6px !important;
        row-gap: 0 !important;
        justify-content: initial !important;
        min-height: 56px;
        overflow: visible;
    }

    header[role='banner'] .header-inner > .header-toolbar__lead {
        grid-area: hdr-lead;
        justify-self: end;
        min-width: 0;
    }

    header[role='banner'] .header-inner > .header-toolbar__lead.header-toolbar__lead--empty {
        min-height: 1px;
    }

    header[role='banner'] .header-inner > .logo.header-toolbar__logo {
        grid-area: hdr-logo;
        justify-self: center;
        text-align: center;
        min-width: 0;
        overflow: hidden;
    }

    html[dir='rtl'] header[role='banner'] .header-inner > .logo.header-toolbar__logo {
        justify-self: center;
        text-align: center;
    }

    header[role='banner'] .header-inner > .logo.header-toolbar__logo img {
        max-width: clamp(110px, 34vw, 150px);
        height: auto;
    }

    header[role='banner'] .header-inner > .nav {
        display: none !important;
    }

    header[role='banner'] .header-inner > .header-toolbar__trailing {
        grid-area: hdr-trail;
        justify-self: start;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 0.3rem;
        max-width: min(45vw, 240px);
        min-width: 0;
        white-space: nowrap;
    }

    .header-toolbar__trailing .lang-switcher,
    .header-toolbar__trailing .currency-switcher {
        margin-inline-start: 0;
    }

    .header-toolbar__trailing .lang-switcher {
        min-width: 0;
    }

    .header-toolbar__trailing .currency-switcher {
        min-width: 0;
    }

    .header-toolbar__trailing .lang-switcher__select,
    .header-toolbar__trailing .currency-switcher__select {
        min-height: 34px;
        height: 34px;
        font-size: 12px;
        font-weight: 500;
        line-height: 1;
        padding-inline-start: 8px;
        padding-inline-end: 20px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .header-toolbar__trailing .lang-switcher__select {
        max-width: clamp(52px, 15vw, 68px);
    }

    .header-toolbar__trailing .currency-switcher__select {
        max-width: clamp(52px, 15vw, 68px);
    }

    .header-toolbar__trailing .lang-switcher::after,
    .header-toolbar__trailing .currency-switcher::after {
        inset-inline-end: 0.45rem;
        width: 10px;
        height: 10px;
    }

    .mobile-cat-drawer__trigger-text {
        display: none;
    }

    .mobile-cat-drawer__trigger {
        min-height: 34px;
        min-width: 34px;
        height: 34px;
        gap: 0;
        padding-inline: 10px;
        border-radius: 999px;
        font-size: 12px;
    }
}

@media (prefers-reduced-motion: reduce) {
    header[role='banner'] .header-toolbar__logo,
    header[role='banner'] .header-toolbar__logo img {
        transition: none !important;
        transform: none !important;
        opacity: 1 !important;
    }
}

@media (max-width: 380px) {
    .header-toolbar__trailing .currency-switcher__select {
        max-width: 40px;
        padding-inline-start: 7px;
        padding-inline-end: 18px;
    }
}

@media (min-width: 769px) {
    .mobile-cat-drawer__trigger-text {
        display: none;
    }

    .mobile-cat-drawer__trigger {
        min-width: 40px;
        width: 40px;
        padding-inline: 0;
        gap: 0;
    }

    header[role='banner'] .header-inner > .header-toolbar__lead--empty {
        display: none !important;
    }

    header[role='banner'] .header-inner {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 10px !important;
    }

    header[role='banner'] .header-inner > .nav {
        margin-inline-start: auto !important;
        max-width: min(70vw, 300px) !important;
        width: auto !important;
        padding-top: 0 !important;
        border-top: none !important;
    }

    header[role='banner'] .header-inner > .header-toolbar__trailing {
        display: flex;
        align-items: center;
        flex-shrink: 0;
        gap: 0.35rem;
    }

    .header-toolbar__trailing .lang-switcher {
        margin-inline-start: 0;
    }
}

.mobile-cat-drawer__trigger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    flex-shrink: 0;
    margin: 0;
    padding: 0.45rem 0.55rem;
    min-height: 44px;
    min-width: 44px;
    border: 1px solid rgba(61, 53, 46, 0.14);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.92);
    color: #5a5a5a;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.mobile-cat-drawer__trigger:hover,
.mobile-cat-drawer__trigger:focus-visible {
    background: #faf1eb;
    border-color: rgba(184, 90, 58, 0.35);
    color: #b85a3a;
    outline: none;
}

.mobile-cat-drawer__trigger-icon {
    display: flex;
    color: currentColor;
}

.mobile-cat-drawer__trigger-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-cat-drawer {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100040;
    pointer-events: none;
}

.mobile-cat-drawer[hidden] {
    display: none !important;
}

.mobile-cat-drawer:not([hidden]) {
    pointer-events: none;
}

.mobile-cat-drawer__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(34, 30, 27, 0.26);
    opacity: 0;
    transition: opacity 0.22s ease;
    pointer-events: none;
}

.mobile-cat-drawer:not([hidden]) .mobile-cat-drawer__backdrop {
    opacity: 1;
}

.mobile-cat-drawer__sheet {
    position: absolute;
    /* Opens at current page scroll position and moves with page content. */
    left: 50%;
    right: auto;
    top: var(--mcd-open-top, 120px);
    bottom: auto;
    width: min(calc(100vw - 28px), 520px);
    max-height: min(88vh, 700px);
    margin: 0;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 24px;
    border: 1px solid rgba(224, 213, 206, 0.95);
    box-shadow: 0 22px 56px rgba(0, 0, 0, 0.18), 0 6px 18px rgba(44, 32, 24, 0.08);
    transform: translate(-50%, 12px) scale(0.97);
    opacity: 0;
    transition:
        transform 0.34s cubic-bezier(0.22, 1, 0.36, 1),
        opacity 0.26s ease;
    overflow: hidden;
    pointer-events: auto;
}

.mobile-cat-drawer:not([hidden]) .mobile-cat-drawer__sheet {
    transform: translate(-50%, 0) scale(1);
    opacity: 1;
}

.mobile-cat-drawer.is-opening .mobile-cat-drawer__sheet {
    animation: mcdSheetOpen 380ms cubic-bezier(0.22, 1, 0.36, 1) 1 both;
}

@keyframes mcdSheetOpen {
    0% {
        opacity: 0;
        transform: translate(-50%, 18px) scale(0.94);
    }
    60% {
        opacity: 1;
        transform: translate(-50%, -2px) scale(1.01);
    }
    100% {
        opacity: 1;
        transform: translate(-50%, 0) scale(1);
    }
}

@media (min-width: 769px) {
    .mobile-cat-drawer__sheet {
        width: min(calc(100vw - 48px), 720px);
        max-height: min(84vh, 780px);
        border-radius: 26px;
    }
}

.mobile-cat-drawer__top {
    flex-shrink: 0;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 48px;
    padding: 8px 52px 10px;
    border-bottom: 1px solid rgba(240, 234, 229, 0.9);
}

.mobile-cat-drawer__logo-link--top {
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0;
    text-decoration: none;
}

.mobile-cat-drawer__logo--top {
    height: 32px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
    display: block;
}

.mobile-cat-drawer__logo-fallback--top {
    font-size: 1.05rem;
    font-weight: 500;
    color: #4a4a4a;
    letter-spacing: 0.02em;
}

.mobile-cat-drawer__close {
    position: absolute;
    inset-inline-end: 4px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: transparent;
    color: #6b6b6b;
    font-size: 1.65rem;
    line-height: 1;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.15s ease, color 0.15s ease;
}

.mobile-cat-drawer__close:hover,
.mobile-cat-drawer__close:focus-visible {
    background: #faf1eb;
    color: #b85a3a;
    outline: none;
}

.mobile-cat-drawer__body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 16px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
}

@media (min-width: 769px) {
    .mobile-cat-drawer__body {
        padding: 10px 18px 20px;
    }
}

.mobile-cat-drawer__search {
    margin: 0 0 14px;
}

.mobile-cat-drawer__search-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e4dbd4;
    border-radius: 30px;
    font-size: 1rem;
    background: #fff;
    color: #2c2c2c;
    box-sizing: border-box;
}

.mobile-cat-drawer__search-input:focus {
    border-color: #b85a3a;
    outline: none;
    box-shadow: 0 0 0 2px rgba(184, 90, 58, 0.12);
}

.mobile-cat-drawer__search-results {
    margin-top: 8px;
    max-height: min(36vh, 240px);
    overflow-y: auto;
    border-radius: 12px;
    background: rgba(250, 247, 245, 0.65);
    border: 1px solid rgba(240, 234, 229, 0.95);
}

.mobile-cat-drawer__search-results:not([hidden]):empty {
    display: none;
}

.mobile-cat-drawer__search-results .search-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid rgba(240, 234, 229, 0.7);
}

.mobile-cat-drawer__search-results .search-result-item:last-child {
    border-bottom: none;
}

.mobile-cat-drawer__nav .mcd-tree {
    list-style: none;
    margin: 0;
    padding: 0;
}

@media (min-width: 769px) {
    .mobile-cat-drawer__nav .mcd-tree--roots {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .mobile-cat-drawer__nav .mcd-node--root {
        margin: 0;
        border: 1px solid rgba(233, 221, 213, 0.95);
        border-radius: 16px;
        background: rgba(255, 255, 255, 0.9);
        padding: 6px;
    }

    .mobile-cat-drawer__nav .mcd-node--root > .mcd-toggle {
        min-height: 42px;
        background: transparent;
        color: #4a4541;
        font-size: 1rem;
        font-weight: 700;
        padding: 8px 10px;
    }

    .mobile-cat-drawer__nav .mcd-node--root > .mcd-toggle .mcd-toggle__icon {
        display: none;
    }

    .mobile-cat-drawer__nav .mcd-node--root > .mcd-panel {
        padding: 0 6px 6px;
    }

    .mobile-cat-drawer__nav .mcd-node--root .mcd-tree--nested {
        border-inline-start: 0;
        padding-inline-start: 0;
        margin-top: 0;
    }

    .mobile-cat-drawer__nav .mcd-node--root .mcd-link {
        min-height: 40px;
        font-size: 0.92rem;
        padding: 8px 10px;
    }
}

.mobile-cat-drawer__nav .mcd-node {
    margin: 4px 0;
}

.mobile-cat-drawer__nav .mcd-tree--nested {
    margin-top: 4px;
    margin-inline-start: 0;
    padding-inline-start: 12px;
    border-inline-start: 1px dashed #e8ded7;
}

.mobile-cat-drawer__nav .mcd-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 10px 12px;
    margin: 0;
    border: none;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.65);
    color: #5a5a5a;
    font-size: 0.98rem;
    font-weight: 600;
    text-align: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.18s ease, color 0.18s ease;
}

.mobile-cat-drawer__nav .mcd-toggle:hover,
.mobile-cat-drawer__nav .mcd-toggle:focus-visible {
    background: #faf1eb;
    color: #b85a3a;
    outline: none;
}

.mobile-cat-drawer__nav .mcd-toggle__label {
    flex: 1;
    min-width: 0;
}

.mobile-cat-drawer__nav .mcd-toggle__icon {
    flex-shrink: 0;
    width: 1.25rem;
    height: 1.25rem;
    position: relative;
}

.mobile-cat-drawer__nav .mcd-toggle__icon::before {
    content: '▸';
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #9a9a9a;
    transition: transform 0.2s ease;
}

.mobile-cat-drawer__nav .mcd-toggle[aria-expanded='true'] .mcd-toggle__icon::before {
    transform: rotate(90deg);
}

.mobile-cat-drawer__nav .mcd-panel {
    padding-top: 4px;
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    transform: translateY(-4px);
    transition: max-height 280ms cubic-bezier(0.22, 1, 0.36, 1), opacity 220ms ease, transform 280ms ease;
    will-change: max-height, opacity, transform;
}

.mobile-cat-drawer__nav .mcd-panel:not([hidden]) {
    max-height: 1000px;
    opacity: 1;
    transform: translateY(0);
}

.mobile-cat-drawer__nav .mcd-panel[hidden] {
    display: none !important;
}

.mobile-cat-drawer__nav .mcd-link {
    display: flex;
    align-items: center;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 12px;
    text-decoration: none;
    color: #5a5a5a;
    font-size: 0.96rem;
    font-weight: 500;
    transition: background 0.18s ease, color 0.18s ease;
}

.mobile-cat-drawer__nav .mcd-link:hover,
.mobile-cat-drawer__nav .mcd-link:focus-visible {
    background: #faf1eb;
    color: #b85a3a;
    outline: none;
}

.mobile-cat-drawer__nav .mcd-link--all {
    font-weight: 700;
    color: #b85a3a;
}

@media (prefers-reduced-motion: reduce) {
    .mobile-cat-drawer__backdrop,
    .mobile-cat-drawer__sheet,
    .mobile-cat-drawer__nav .mcd-toggle__icon::before {
        transition: none !important;
    }

    .mobile-cat-drawer:not([hidden]) .mobile-cat-drawer__sheet {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

.categories-hub-mobile-hint {
    display: none;
}

@media (max-width: 768px) {
    body.page-search-results .content-wrapper > .sidebar {
        display: none !important;
    }

    body.page-search-results .search-mobile-nav {
        display: none !important;
    }

    body.page-category-items .category-mobile-jump {
        display: none !important;
    }

    body.page-categories-hub .categories-tree {
        display: none !important;
    }

    body.page-categories-hub .categories-hub-mobile-hint {
        display: block;
        margin: 0 0 1rem;
        font-size: 0.92rem;
        line-height: 1.55;
        color: #6b6b6b;
    }
}
