/* Storefront home (Phase 6) — loaded only on home */

.sf-page-home {
    --sf-home-radius: 10px;
    --sf-home-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
    position: relative;
    z-index: 0;
}

/* Home: paint header+carousel band on page background (covers sticky-header hide gap too). */
body:has(.sf-page-home) {
    background-color: var(--sf-page-bg);
    background-image: var(--sf-header-legacy-gradient);
    background-repeat: no-repeat;
    background-position: top center;
    background-size: 100% calc(6.25rem + clamp(168px, 50vh, 400px));
}

/* Home: carousel first — flush under header (main top padding removed via :has below) */
main.sf-page:has(.sf-page-home) {
    position: relative;
    padding-block-start: 0;
}

.sf-page-home > .sf-carousel:first-child {
    position: relative;
    z-index: 1;
    margin-top: 0;
    margin-bottom: 1.25rem;
    border-start-start-radius: 0;
    border-start-end-radius: 0;
    border-top: none;
}

.sf-page-home--ar {
    font-family: "Cairo", system-ui, sans-serif;
}

.sf-home-intro {
    margin-top: 1.25rem;
    margin-bottom: 1.25rem;
}

/* No slideshow: intro is first — restore main top spacing (see main.sf-page padding in chrome) */
.sf-page-home > .sf-home-intro:first-child {
    margin-top: 1.5rem;
}

/* —— Carousel —— */
.sf-carousel {
    position: relative;
    margin: 1.25rem 0 1.5rem;
    border-radius: var(--sf-home-radius);
    border: 1px solid var(--border, #d9dee3);
    background: #fff;
    box-shadow: var(--sf-home-shadow);
    overflow: hidden;
}

#sf-home-carousel:focus-visible {
    outline: 2px solid var(--accent, #0d6efd);
    outline-offset: 2px;
}

/* LTR clip + flex order so translateX(-index * width) matches slide indices in EN/AR */
.sf-carousel__viewport {
    position: relative;
    overflow: hidden;
    direction: ltr;
}

.sf-carousel__track {
    display: flex;
    margin: 0;
    padding: 0;
    list-style: none;
    transition: transform 0.35s ease;
    will-change: transform;
    direction: ltr;
}

@media (prefers-reduced-motion: reduce) {
    .sf-carousel__track {
        transition: none;
    }
}

.sf-carousel__slide {
    flex: 0 0 100%;
    margin: 0;
    padding: 0;
}

/* Full slide width; explicit height avoids aspect-ratio + max-height shrinking the box */
.sf-carousel__figure {
    position: relative;
    margin: 0;
    width: 100%;
    /* Taller than before: space reclaimed from former below-image toolbar + dots bar */
    height: clamp(168px, 50vh, 400px);
    overflow: hidden;
    background: #f1f5f9;
}

/* Keep caption centered and just above in-image controls (multi-slide only) */
.sf-carousel--multi .sf-carousel__caption {
    bottom: 4.85rem;
}

@media (max-width: 480px) {
    .sf-carousel--multi .sf-carousel__caption {
        bottom: 4.55rem;
    }
}

.sf-carousel__slide img {
    width: 100%;
    height: 100%;
    min-height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
}

.sf-carousel__caption {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: min(92%, 980px);
    bottom: 0.75rem;
    padding: 0.6rem 0.9rem;
    background: linear-gradient(to top, rgba(15, 23, 42, 0.84), rgba(15, 23, 42, 0.48));
    border-radius: 8px;
    color: #f8fafc;
    text-align: center;
}

[dir="rtl"] .sf-carousel__caption {
    direction: rtl;
}

.sf-carousel__caption-title {
    margin: 0 0 0.25rem;
    font-size: clamp(1rem, 2.5vw, 1.35rem);
    font-weight: 700;
    line-height: 1.25;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.sf-carousel__caption-desc {
    margin: 0;
    font-size: clamp(0.8rem, 2vw, 0.95rem);
    line-height: 1.4;
    opacity: 0.95;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

@media (max-width: 480px) {
    .sf-carousel__caption {
        padding: 0.5rem 0.65rem;
    }
}

/* In-image chrome: prev | status | next + dots (replaces separate white bars under slide) */
.sf-carousel__overlay {
    position: absolute;
    inset-inline: 0;
    bottom: 0;
    z-index: 4;
    padding: 0.35rem 0.5rem 0.55rem;
    background: linear-gradient(
        to top,
        rgba(15, 23, 42, 0.92) 0%,
        rgba(15, 23, 42, 0.55) 55%,
        transparent 100%
    );
    pointer-events: none;
}

.sf-carousel__overlay .sf-carousel__toolbar,
.sf-carousel__overlay .sf-carousel__dots {
    pointer-events: auto;
}

.sf-carousel__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0 0.15rem;
    border: none;
    background: transparent;
}

[dir="rtl"] .sf-carousel__toolbar {
    flex-direction: row-reverse;
}

.sf-carousel__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.5rem;
    min-height: 2.5rem;
    padding: 0 0.65rem;
    border: 1px solid rgba(248, 250, 252, 0.35);
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.45);
    color: #f8fafc;
    font: inherit;
    font-size: 1.35rem;
    line-height: 1;
    cursor: pointer;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.sf-carousel__btn:hover {
    background: rgba(15, 23, 42, 0.65);
    border-color: rgba(248, 250, 252, 0.55);
}

.sf-carousel__btn:focus-visible {
    outline: 2px solid var(--accent, #0d6efd);
    outline-offset: 2px;
}

.sf-carousel__btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

[dir="rtl"] .sf-carousel__btn {
    transform: scaleX(-1);
}

.sf-carousel__status {
    margin: 0;
    font-size: 0.8rem;
    color: rgba(248, 250, 252, 0.92);
    flex: 1;
    text-align: center;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

.sf-carousel__dots {
    display: flex;
    gap: 0.4rem;
    justify-content: center;
    padding: 0.35rem 0.5rem 0.15rem;
    border: none;
    background: transparent;
}

[dir="rtl"] .sf-carousel__dots {
    flex-direction: row-reverse;
}

.sf-carousel__dot {
    width: 0.5rem;
    height: 0.5rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.4);
    cursor: pointer;
    box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.25);
}

.sf-carousel__dot[aria-current="true"] {
    background: var(--accent, #0d6efd);
    box-shadow: 0 0 0 2px rgba(248, 250, 252, 0.35);
    transform: scale(1.15);
}

.sf-carousel__dot:focus-visible {
    outline: 2px solid var(--accent, #0d6efd);
    outline-offset: 2px;
}

/* —— Category strip (Phase 2) —— */
.sf-home-cats {
    margin: 1.5rem 0;
}

.sf-home-cats__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.65rem;
}

.sf-home-cats__title {
    font-size: 1.1rem;
    margin: 0;
}

.sf-home-cats__pager {
    position: relative;
    padding-inline: 1.85rem;
}

.sf-home-cats__btn {
    position: absolute;
    top: 50%;
    z-index: 3;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: none;
    border-radius: 999px;
    background: #fff;
    color: #64748b;
    font: inherit;
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
    transform: translateY(-50%);
}

.sf-home-cats__btn--prev {
    inset-inline-start: 0;
}

.sf-home-cats__btn--next {
    inset-inline-end: 0;
}

.sf-home-cats__btn:hover:not(:disabled) {
    background: #f8fafc;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.16);
}

.sf-home-cats__btn:focus-visible {
    outline: 2px solid var(--accent, #0d6efd);
    outline-offset: 2px;
}

.sf-home-cats__btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08);
}

/* LTR clip box: transform math stays physical-X; row-reverse on track handles AR order */
.sf-home-cats__viewport {
    overflow: hidden;
    margin: 0;
    padding: 0.25rem 0 0.75rem;
    /* pan-y: vertical scroll still works; horizontal moves go to Pointer Events (not browser pan) */
    touch-action: pan-y;
    direction: ltr;
}

/* Touch target is usually <a>; without this, UA uses touch-action:auto and steals horizontal pans */
.sf-home-cats__viewport .sf-home-cats__track,
.sf-home-cats__viewport .sf-home-cats__track * {
    touch-action: pan-y;
}

.sf-home-cats__viewport.sf-home-cats__viewport--dragging,
.sf-home-cats__viewport.sf-home-cats__viewport--dragging * {
    touch-action: none;
}

.sf-home-cats__track {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 0.5rem;
    width: max-content;
    min-width: 100%;
    transform: translate3d(0, 0, 0);
    will-change: transform;
    direction: ltr;
}

[dir="rtl"] .sf-home-cats__track {
    flex-direction: row-reverse;
}

[dir="rtl"] .sf-home-cats__track .sf-home-cats__card {
    direction: rtl;
}

.sf-home-cats__source {
    display: none;
}

.sf-home-cats__grid-wrap {
    min-width: 0;
}

.sf-home-cats__track .sf-home-cats__card {
    flex: 0 0 auto;
    width: min(200px, 46vw);
    scroll-snap-align: unset;
    border: 1px solid var(--border, #d9dee3);
    border-radius: var(--sf-home-radius);
    padding: 0;
    background: #fff;
    box-shadow: var(--sf-home-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@media (min-width: 768px) {
    .sf-home-cats__track .sf-home-cats__card {
        width: min(200px, 22vw);
    }
}

.sf-home-cats__card-head {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    padding: 0.65rem 0.75rem 0.5rem;
    color: inherit;
    text-decoration: none;
    min-height: 4.5rem;
}

.sf-home-cats__card-head:hover {
    color: var(--accent, #0d6efd);
    text-decoration: none;
}

.sf-home-cats__card-head:focus-visible {
    outline: 2px solid var(--accent, #0d6efd);
    outline-offset: -2px;
}

.sf-home-cats__badges {
    min-height: 1.1rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.sf-home-cats__badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 4px;
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    line-height: 1.2;
}

.sf-home-cats__badge--new {
    background: linear-gradient(135deg, #eef2ff, #e0e7ff);
    color: #3730a3;
    border: 1px solid #c7d2fe;
}

.sf-home-cats__badge--featured {
    background: linear-gradient(135deg, #fffbeb, #fef3c7);
    color: #b45309;
    border: 1px solid #fde68a;
}

.sf-home-cats__icon {
    font-size: 1.65rem;
    line-height: 1;
    text-align: center;
}

.sf-home-cats__card-title {
    font-weight: 700;
    font-size: 0.88rem;
    line-height: 1.3;
    color: var(--fg, #3b4056);
}

.sf-home-cats__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
    padding: 0 0.65rem 0.65rem;
    border-top: 1px solid var(--border, #e2e8f0);
    background: #fafbfc;
}

.sf-home-cats__chip {
    display: inline-block;
    max-width: 100%;
    padding: 0.2rem 0.45rem;
    border-radius: 999px;
    border: 1px solid var(--border, #d9dee3);
    background: #fff;
    font-size: 0.72rem;
    color: var(--accent, #0d6efd);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sf-home-cats__chip:hover {
    background: #f1f5f9;
    text-decoration: none;
}

.sf-home-cats__chip--more {
    font-weight: 600;
    color: var(--fg, #475569);
}

.sf-home-cats__card--c1 { border-top: 3px solid #667eea; }
.sf-home-cats__card--c2 { border-top: 3px solid #10b981; }
.sf-home-cats__card--c3 { border-top: 3px solid #f59e0b; }
.sf-home-cats__card--c4 { border-top: 3px solid #ec4899; }
.sf-home-cats__card--c5 { border-top: 3px solid #06b6d4; }
.sf-home-cats__card--c6 { border-top: 3px solid #8b5cf6; }
.sf-home-cats__card--c7 { border-top: 3px solid #ef4444; }
.sf-home-cats__card--c8 { border-top: 3px solid #64748b; }

/* —— Section headers —— */
.sf-home-section {
    margin-top: 2.25rem;
}

.sf-home-section__head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin-bottom: 0.75rem;
}

.sf-home-section__title {
    margin: 0;
    font-size: 1.15rem;
}

.sf-home-section__view-all {
    font-size: 0.875rem;
    font-weight: 600;
    white-space: nowrap;
}

.sf-home-section__empty {
    margin: 0.5rem 0 0;
    color: var(--muted, #8592a3);
    font-size: 0.9rem;
}

/* —— Product grid (home) —— */
.sf-home-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

@media (min-width: 640px) {
    .sf-home-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 1.25rem;
    }
}

.sf-home-card {
    position: relative;
    display: flex;
    flex-direction: column;
    border: none;
    border-radius: var(--sf-home-radius);
    overflow: hidden;
    background: #fff;
    box-shadow: none;
    color: inherit;
    text-decoration: none;
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.sf-home-card:hover {
    box-shadow: 0 30px 48px rgba(15, 23, 42, 0.26);
    transform: translateY(8px);
    text-decoration: none;
}

.sf-home-card:focus-visible {
    outline: 2px solid var(--accent, #0d6efd);
    outline-offset: 2px;
}

.sf-home-card__media {
    position: relative;
    aspect-ratio: 1;
    background: #f1f5f9;
}

.sf-home-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sf-home-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.5rem;
    color: #94a3b8;
}

.sf-home-card__badges {
    position: absolute;
    inset-inline-start: 0.3rem;
    inset-block-start: 0.3rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    align-items: flex-start;
    z-index: 1;
}

.sf-home-card__badge {
    display: inline-block;
    padding: 0.11rem 0.3rem;
    border-radius: 4px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.sf-home-card__badge--discount {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.sf-home-card__badge--new {
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.sf-home-card__badge--brand {
    background: rgba(255, 255, 255, 0.92);
    color: var(--fg, #3b4056);
    border: 1px solid var(--border, #d9dee3);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 10rem;
}

.sf-home-card__body {
    padding: 0.5rem 0.58rem 0.62rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.sf-home-card__title {
    font-size: 0.82rem;
    font-weight: 600;
    line-height: 1.28;
    color: var(--fg, #3b4056);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sf-home-card__meta {
    font-size: 0.72rem;
    color: var(--muted, #8592a3);
    margin-top: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.45rem;
    align-items: center;
}

.sf-home-card__price-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.25rem 0.35rem;
    font-size: 0.78rem;
}

.sf-home-card__price {
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--fg, #3b4056);
}

.sf-home-card__currency {
    opacity: 0.75;
    font-weight: 500;
    font-size: 0.72rem;
}

.sf-home-card__strike {
    text-decoration: line-through;
    opacity: 0.65;
    font-size: 0.72rem;
}

.sf-home-card__rating {
    font-size: 0.72rem;
    color: #ca8a04;
}

.sf-home-card__badge--sales {
    background: #fffbeb;
    color: #a16207;
    border: 1px solid #fde68a;
}

.sf-home-card__save {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #b91c1c;
}

.sf-home-card__ends {
    margin: 0;
    font-size: 0.68rem;
    color: var(--muted, #8592a3);
}

.sf-home-stars {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    max-width: 100%;
}

.sf-home-stars__track {
    position: relative;
    display: inline-block;
    line-height: 1;
    font-size: 0.72rem;
    letter-spacing: 0.02em;
}

.sf-home-stars__empty {
    color: #e2e8f0;
}

.sf-home-stars__fill {
    position: absolute;
    inset-block-start: 0;
    inset-inline-start: 0;
    overflow: hidden;
    white-space: nowrap;
    color: #ca8a04;
    pointer-events: none;
}

.sf-home-stars__value {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted, #8592a3);
}

.sf-home-card__cta {
    display: inline-block;
    margin-top: 0.25rem;
    padding: 0.26rem 0.4rem;
    align-self: flex-start;
    border-radius: 6px;
    border: 1px solid var(--border, #d9dee3);
    background: #f8fafc;
    font-size: 0.64rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--accent, #0d6efd);
}

.sf-home-card--hot_offers .sf-home-card__cta {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.sf-home-card--offers .sf-home-card__cta {
    background: #fefce8;
    border-color: #fde047;
    color: #854d0e;
}

.sf-home-card--pre_order .sf-home-card__cta {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

/* Mobile card readability after 6-up desktop density */
@media (max-width: 359px) {
    .sf-home-grid {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .sf-home-card__body {
        padding: 0.55rem 0.6rem 0.65rem;
        gap: 0.24rem;
    }

    .sf-home-card__title {
        font-size: 0.88rem;
        line-height: 1.32;
    }

    .sf-home-card__price-row {
        font-size: 0.8rem;
        gap: 0.22rem 0.3rem;
    }

    .sf-home-card__meta {
        font-size: 0.74rem;
    }

    .sf-home-card__cta {
        font-size: 0.7rem;
        padding: 0.36rem 0.5rem;
        min-height: 34px;
    }
}

@media (min-width: 360px) and (max-width: 639px) {
    .sf-home-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.8rem;
    }

    .sf-home-card__title {
        font-size: 0.84rem;
        line-height: 1.3;
    }

    .sf-home-card__price-row {
        font-size: 0.76rem;
    }

    .sf-home-card__meta {
        font-size: 0.7rem;
    }

    .sf-home-card__cta {
        font-size: 0.66rem;
        padding: 0.32rem 0.44rem;
        min-height: 32px;
    }
}
