/*
 * Storefront — marketplace layout
 * Dense retail layout: announcement ticker, search-first masthead, category bar,
 * hero with promo tiles, category chips, product rails and budget tiers.
 * Uses only the semantic tokens from themes.css, so all six themes keep working.
 */

html[data-theme] {
    --theme-font-family: "Readex Pro", "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, sans-serif;
    --sf-mk-gap: 12px;
    --sf-mk-radius: var(--theme-radius-md);
}

/* Swiper 10 styles target .swiper; the markup also carries the legacy
   .swiper-container class, which on its own let slides overflow the page. */
.swiper-container {
    position: relative;
    overflow: hidden;
}

/* ---------- Announcement ticker ---------- */

.sf-ticker {
    overflow: hidden;
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary-hover);
    border-bottom: 1px solid var(--theme-color-border);
    font-size: var(--theme-font-size-xs);
}

.sf-ticker-track {
    display: flex;
    width: max-content;
    animation: sf-ticker 38s linear infinite;
}

.sf-ticker:hover .sf-ticker-track,
.sf-ticker:focus-within .sf-ticker-track {
    animation-play-state: paused;
}

.sf-ticker-list {
    display: flex;
    gap: 2.5rem;
    margin: 0;
    padding: 0.45rem 1.25rem;
    list-style: none;
    white-space: nowrap;
}

.sf-ticker-list li {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

html[data-theme] .sf-ticker a,
html[data-theme] .sf-ticker a:hover {
    color: inherit;
    text-decoration: none;
}

@keyframes sf-ticker {
    from { transform: translateX(0); }
    to { transform: translateX(-50%); }
}

[dir="rtl"] .sf-ticker-track {
    animation-name: sf-ticker-rtl;
}

@keyframes sf-ticker-rtl {
    from { transform: translateX(0); }
    to { transform: translateX(50%); }
}

@media (prefers-reduced-motion: reduce) {
    .sf-ticker-track {
        animation: none;
        width: auto;
    }

    .sf-ticker-list[aria-hidden="true"] {
        display: none;
    }

    .sf-ticker-list {
        flex-wrap: wrap;
        justify-content: center;
        row-gap: 0.25rem;
    }
}

/* ---------- Masthead ---------- */

.sf-masthead {
    background: var(--theme-navbar-bg);
    border-bottom: 1px solid var(--theme-color-border);
}

.sf-masthead-row {
    display: flex;
    align-items: center;
    gap: 0.75rem 1.5rem;
    min-height: 72px;
}

.sf-masthead .sf-search {
    flex: 1;
    display: flex;
    max-width: 720px;
}

html[data-theme] .sf-masthead .sf-search-input {
    height: 46px;
    padding-inline: 16px 12px;
    border: 2px solid var(--theme-color-primary);
    border-inline-end: 0;
    border-radius: var(--sf-mk-radius);
    border-start-end-radius: 0;
    border-end-end-radius: 0;
    background: var(--theme-color-surface-raised);
    font-size: var(--theme-font-size-sm);
}

html[data-theme] .sf-masthead .sf-search-input:focus {
    box-shadow: none;
}

.sf-search-btn {
    flex: none;
    width: 54px;
    border: 0;
    border-radius: 0 var(--sf-mk-radius) var(--sf-mk-radius) 0;
    background: var(--theme-color-primary);
    color: var(--theme-color-text-inverse);
    font-size: 1.1rem;
}

[dir="rtl"] .sf-search-btn {
    border-radius: var(--sf-mk-radius) 0 0 var(--sf-mk-radius);
}

.sf-search-btn:hover {
    background: var(--theme-color-primary-hover);
}

.sf-search-btn:focus-visible {
    outline: 3px solid var(--theme-focus-ring);
    outline-offset: 2px;
}

.sf-masthead-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin-inline-start: auto;
}

.sf-action {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 56px;
    padding: 4px 8px;
    border-radius: var(--theme-radius-sm);
    color: var(--theme-color-text);
    font-size: var(--theme-font-size-xs);
    text-decoration: none;
}

html[data-theme] .sf-action {
    color: var(--theme-color-text);
}

.sf-action .bi {
    font-size: 1.35rem;
    line-height: 1;
}

html[data-theme] .sf-action:hover {
    color: var(--theme-color-primary);
    background: var(--theme-color-primary-soft);
}

.sf-action .sf-cart-badge {
    top: -6px;
    inset-inline-end: -10px;
}

@media (max-width: 991.98px) {
    .sf-masthead-row {
        flex-wrap: wrap;
        padding-block: 0.6rem;
        min-height: 0;
    }

    .sf-masthead .sf-search {
        order: 10;
        flex-basis: 100%;
        max-width: none;
    }

    html[data-theme] .sf-masthead .sf-search-input {
        height: 42px;
    }

    .sf-action-label {
        display: none;
    }

    .sf-action {
        min-width: 44px;
        min-height: 44px;
        justify-content: center;
    }
}

/* ---------- Category bar ---------- */

.sf-catbar {
    background: var(--theme-navbar-bg);
    border-bottom: 1px solid var(--theme-color-border);
}

.sf-catbar-list {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sf-catbar-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.7rem 0.75rem;
    border-bottom: 2px solid transparent;
    color: var(--theme-color-text);
    font-size: var(--theme-font-size-sm);
    font-weight: var(--theme-weight-medium);
    white-space: nowrap;
    text-decoration: none;
}

html[data-theme] .sf-catbar-link {
    color: var(--theme-color-text);
}

html[data-theme] .sf-catbar-link:hover,
html[data-theme] .sf-catbar-link.active {
    color: var(--theme-color-primary);
    border-bottom-color: var(--theme-color-primary);
}

html[data-theme] .sf-catbar-link.is-all {
    font-weight: var(--theme-weight-semibold);
}

.sf-catbar-secondary.is-push {
    margin-inline-start: auto;
}

.sf-catbar-secondary .sf-catbar-link {
    color: var(--theme-color-text-muted);
    font-weight: var(--theme-weight-regular);
}

@media (min-width: 992px) {
    .sf-catbar .offcanvas-body {
        overflow-x: auto;
        scrollbar-width: none;
    }

    .sf-catbar .offcanvas-body::-webkit-scrollbar {
        display: none;
    }
}

@media (max-width: 991.98px) {
    .sf-catbar {
        border: 0;
    }

    .sf-catbar .offcanvas-lg {
        background: var(--theme-color-surface-raised);
    }

    .sf-catbar-list {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .sf-catbar-link {
        width: 100%;
        padding: 0.85rem 0.25rem;
        border-bottom: 1px solid var(--theme-color-border);
    }

    .sf-catbar-secondary.is-push {
        margin-inline-start: 0;
    }
}

/* ---------- Home layout ---------- */

html[data-theme] .sf-main:has(.sf-home) {
    background: var(--theme-color-surface);
}

.sf-home {
    padding-block: 1rem 2.5rem;
}

.sf-block {
    margin-top: 2rem;
}

.sf-row-head {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
    margin-bottom: 0.85rem;
}

html[data-theme] .sf-row-title {
    margin: 0;
    color: var(--theme-color-text);
    font-size: clamp(1.15rem, 1rem + 0.6vw, 1.4rem);
    font-weight: var(--theme-weight-bold);
    line-height: 1.3;
}

.sf-row-meta {
    color: var(--theme-color-text-muted);
    font-size: var(--theme-font-size-sm);
}

.sf-row-link {
    margin-inline-start: auto;
    font-size: var(--theme-font-size-sm);
    font-weight: var(--theme-weight-semibold);
    white-space: nowrap;
    text-decoration: none;
}

[dir="rtl"] .sf-arrow.bi-chevron-right {
    display: inline-block;
    transform: scaleX(-1);
}

/* ---------- Hero ---------- */

.sf-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
    gap: var(--sf-mk-gap);
}

.sf-hero-main {
    min-width: 0;
    border-radius: var(--theme-radius-lg);
    overflow: hidden;
}

.sf-hero-main .swiper-hero,
.sf-hero-main .hero-slide {
    height: clamp(240px, 32vw, 380px);
}

.sf-hero-main .hero-slide {
    background-size: cover;
    background-position: center;
}

.sf-hero-main .hero-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: flex-end;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.55), rgba(0, 0, 0, 0) 65%);
}

.sf-hero-main .hero-content {
    max-width: 30rem;
    padding: clamp(1.25rem, 3vw, 2.25rem);
    color: #fff;
}

.sf-hero-tag {
    display: inline-block;
    margin-bottom: 0.6rem;
    padding: 2px 10px;
    border-radius: var(--theme-radius-sm);
    background: rgba(255, 255, 255, 0.92);
    color: #111;
    font-size: var(--theme-font-size-xs);
    font-weight: var(--theme-weight-semibold);
}

html[data-theme] .sf-hero-title {
    white-space: normal;
    margin: 0 0 0.4rem;
    color: #fff;
    font-size: clamp(1.5rem, 1rem + 2.2vw, 2.4rem);
    font-weight: var(--theme-weight-bold);
    line-height: 1.2;
}

html[data-theme] .sf-hero-text {
    margin: 0 0 1rem;
    color: rgba(255, 255, 255, 0.9);
    font-size: var(--theme-font-size-md);
}

html[data-theme] .sf-btn-light {
    background: #fff;
    border-color: #fff;
    color: #111;
    font-weight: var(--theme-weight-semibold);
}

html[data-theme] .sf-btn-light:hover {
    background: rgba(255, 255, 255, 0.88);
    color: #111;
}

/* Swipe and dots are enough on a short banner; arrows covered the copy. */
.sf-hero-main .swiper-button-next,
.sf-hero-main .swiper-button-prev {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    color: #111;
}

.sf-hero-main .swiper-button-next::after,
.sf-hero-main .swiper-button-prev::after {
    font-size: 14px;
    font-weight: 700;
}

.sf-hero-main .swiper-pagination-bullet {
    background: #fff;
    opacity: 0.6;
}

.sf-hero-main .swiper-pagination-bullet-active {
    opacity: 1;
    width: 18px;
    border-radius: 4px;
}

.sf-hero-side {
    display: grid;
    grid-template-rows: 1fr 1fr;
    gap: var(--sf-mk-gap);
}

.sf-hero-side.is-full {
    grid-column: 1 / -1;
    grid-template-rows: none;
    grid-template-columns: 1fr 1fr;
}

.sf-promo-tile {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.25rem 1.5rem;
    border-radius: var(--theme-radius-lg);
    background: var(--theme-color-primary);
    color: var(--theme-color-text-inverse);
    text-decoration: none;
}

/* Second tile is the light counterpart of the first */
html[data-theme] .sf-promo-tile.is-alt,
html[data-theme] .sf-promo-tile.is-alt:hover {
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary-hover);
    box-shadow: inset 0 0 0 1px var(--theme-color-border);
}

.sf-promo-tile.is-alt .sf-promo-tag {
    background: var(--theme-color-surface-raised);
}

html[data-theme] .sf-promo-tile,
html[data-theme] .sf-promo-tile:hover {
    color: var(--theme-color-text-inverse);
}

.sf-promo-tile .sf-promo-tag {
    align-self: flex-start;
    padding: 1px 8px;
    border-radius: var(--theme-radius-sm);
    background: rgba(255, 255, 255, 0.2);
    font-size: var(--theme-font-size-xs);
}

.sf-promo-title {
    font-size: 1.3rem;
    font-weight: var(--theme-weight-bold);
    line-height: 1.25;
}

.sf-promo-text {
    font-size: var(--theme-font-size-sm);
    opacity: 0.9;
}

.sf-promo-cta {
    margin-top: 0.35rem;
    font-size: var(--theme-font-size-sm);
    font-weight: var(--theme-weight-semibold);
}

.sf-promo-tile:hover .sf-promo-cta {
    text-decoration: underline;
}

@media (max-width: 767.98px) {
    .sf-hero-grid {
        grid-template-columns: 1fr;
    }

    .sf-hero-side {
        grid-template-rows: none;
        grid-template-columns: 1fr 1fr;
    }

    .sf-promo-tile {
        padding: 1rem;
    }

    .sf-promo-title {
        font-size: 1.05rem;
    }

    .sf-promo-text {
        display: none;
    }
}

/* ---------- Category chips ---------- */

.sf-chips {
    display: flex;
    gap: 0.75rem;
    margin: 0;
    padding: 0 0 0.25rem;
    list-style: none;
    overflow-x: auto;
    scroll-snap-type: x proximity;
    scrollbar-width: thin;
}

.sf-chips li {
    flex: none;
    scroll-snap-align: start;
}

.sf-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.45rem;
    width: 96px;
    text-decoration: none;
}

.sf-chip-media {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--theme-color-surface-raised);
    border: 2px solid var(--theme-color-border);
}

.sf-chip-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sf-chip-media.is-icon {
    color: var(--theme-color-primary);
    font-size: 1.6rem;
}

.sf-chip:hover .sf-chip-media,
.sf-chip:focus-visible .sf-chip-media {
    border-color: var(--theme-color-primary);
}

html[data-theme] .sf-chip-label {
    color: var(--theme-color-text);
    font-size: var(--theme-font-size-sm);
    font-weight: var(--theme-weight-medium);
    text-align: center;
    line-height: 1.3;
}

/* ---------- Product rail ---------- */

.sf-rail {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: var(--sf-mk-gap);
}

@media (max-width: 1199.98px) {
    .sf-rail {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .sf-rail {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

/* Phones: one swipeable row instead of a tall grid */
@media (max-width: 767.98px) {
    .sf-rail {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 46%;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        padding-bottom: 0.25rem;
        scrollbar-width: none;
    }

    .sf-rail::-webkit-scrollbar {
        display: none;
    }

    .sf-rail-item {
        scroll-snap-align: start;
    }
}

/* ---------- Product card (all listings) ---------- */

html[data-theme] .sf-product-card {
    border-radius: var(--sf-mk-radius);
    border-color: var(--theme-color-border);
    background: var(--theme-color-surface-raised);
    transition: border-color 150ms ease, box-shadow 150ms ease;
}

html[data-theme] .sf-product-card:hover {
    transform: none;
    border-color: var(--theme-color-primary);
    box-shadow: var(--theme-shadow-sm);
}

html[data-theme] .sf-product-card .sf-product-media {
    background: #fff;
    border-bottom: 1px solid var(--theme-color-border);
}

.sf-product-card .sf-product-media img {
    object-fit: contain;
    padding: 6%;
}

.sf-product-card:hover .sf-product-media img {
    transform: none;
}

.sf-product-flags {
    position: absolute;
    top: 8px;
    inset-inline-start: 8px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.sf-flag {
    padding: 2px 8px;
    border-radius: var(--theme-radius-sm);
    background: var(--theme-color-danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: var(--theme-weight-semibold);
    line-height: 1.5;
}

.sf-flag.is-rank {
    background: var(--theme-color-text);
    color: var(--theme-color-bg);
}

.sf-flag.is-warning {
    background: var(--theme-color-warning);
}

.sf-flag.is-muted {
    background: var(--theme-color-text-muted);
}

.sf-product-card.is-out .sf-product-media img {
    opacity: 0.45;
}

html[data-theme] .sf-product-card .sf-product-body {
    gap: 0.35rem;
    padding: 0.7rem 0.75rem 0.8rem;
}

html[data-theme] .sf-product-card .sf-product-title {
    font-size: 0.875rem;
    font-weight: var(--theme-weight-regular);
    line-height: 1.4;
    min-height: 2.8em;
}

html[data-theme] .sf-product-card .sf-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    color: var(--theme-color-text);
}

.sf-price-value {
    font-size: 1.15rem;
    font-weight: var(--theme-weight-bold);
    font-variant-numeric: tabular-nums;
}

.sf-price-currency {
    font-size: var(--theme-font-size-xs);
    font-weight: var(--theme-weight-semibold);
    color: var(--theme-color-text-muted);
}

.sf-product-perks {
    margin: 0;
    padding: 0;
    list-style: none;
    color: var(--theme-color-success);
    font-size: 0.75rem;
}

.sf-product-perks li {
    display: flex;
    align-items: center;
    gap: 4px;
}

html[data-theme] .sf-product-card .sf-product-actions {
    margin-top: 0.35rem;
}

html[data-theme] .sf-product-card .sf-product-actions .btn {
    min-height: 36px;
    font-size: 0.8125rem;
}

html[data-theme] .sf-btn-disabled,
html[data-theme] .sf-btn-disabled:disabled {
    background: var(--theme-color-surface);
    border: 1px solid var(--theme-color-border);
    color: var(--theme-color-text-muted);
    opacity: 1;
}

/* ---------- Shop by budget ---------- */

.sf-budget {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--sf-mk-gap);
}

.sf-budget-card {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 1rem;
    border: 1px solid var(--theme-color-border);
    border-radius: var(--sf-mk-radius);
    background: var(--theme-color-surface-raised);
    text-decoration: none;
}

html[data-theme] .sf-budget-card:hover {
    border-color: var(--theme-color-primary);
}

.sf-budget-label {
    color: var(--theme-color-text-muted);
    font-size: var(--theme-font-size-sm);
}

html[data-theme] .sf-budget-amount {
    color: var(--theme-color-text);
    font-size: 1.5rem;
    font-weight: var(--theme-weight-bold);
    line-height: 1.2;
}

.sf-budget-thumbs {
    display: flex;
    margin-top: 0.75rem;
}

.sf-budget-thumbs img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    background: #fff;
    border: 2px solid var(--theme-color-surface-raised);
    box-shadow: 0 0 0 1px var(--theme-color-border);
}

.sf-budget-thumbs img + img {
    margin-inline-start: -12px;
}

@media (max-width: 991.98px) {
    .sf-budget {
        grid-template-columns: none;
        grid-auto-flow: column;
        grid-auto-columns: 40%;
        overflow-x: auto;
        scrollbar-width: none;
    }
}

/* ---------- Reasons ---------- */

.sf-reasons {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--sf-mk-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}

.sf-reason {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 1rem;
    border-radius: var(--sf-mk-radius);
    background: var(--theme-color-surface-raised);
    border: 1px solid var(--theme-color-border);
}

.sf-reason > .bi {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--theme-color-primary-soft);
    color: var(--theme-color-primary);
    font-size: 1.25rem;
}

.sf-reason strong {
    display: block;
    color: var(--theme-color-text);
    font-size: var(--theme-font-size-sm);
}

.sf-reason span span {
    color: var(--theme-color-text-muted);
    font-size: var(--theme-font-size-xs);
}

@media (max-width: 991.98px) {
    .sf-reasons {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 575.98px) {
    .sf-reason {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ---------- Brands ---------- */

.sf-brands {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: var(--sf-mk-gap);
    margin: 0;
    padding: 0;
    list-style: none;
}

.sf-brands .sf-brand-logo {
    height: 72px;
    border-radius: var(--sf-mk-radius);
    background: var(--theme-color-surface-raised);
}

/* ---------- FAQ & newsletter ---------- */

html[data-theme] .sf-faq .accordion-item {
    margin-bottom: 0.5rem;
    border: 1px solid var(--theme-color-border);
    border-radius: var(--sf-mk-radius);
    overflow: hidden;
    background: var(--theme-color-surface-raised);
}

html[data-theme] .sf-faq .accordion-button {
    font-weight: var(--theme-weight-medium);
    background: var(--theme-color-surface-raised);
    color: var(--theme-color-text);
}

.sf-newsletter {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem 2rem;
    flex-wrap: wrap;
    padding: 1.5rem;
    border: 1px solid var(--theme-color-border);
    border-radius: var(--sf-mk-radius);
    background: var(--theme-color-surface-raised);
    color: var(--theme-color-text-muted);
}

.sf-newsletter-form {
    display: flex;
    gap: 0.5rem;
    flex: 1 1 320px;
    max-width: 460px;
}

.sf-newsletter-form .form-control {
    height: 44px;
}

/* ---------- Page-builder home page ---------- */

/* Product grid (Products widget, layout: grid) stays a grid on phones */
.sf-rail.sf-rail--grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    grid-auto-flow: row;
    overflow: visible;
}

@media (max-width: 767.98px) {
    .sf-rail.sf-rail--grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-columns: auto;
    }
}

.sf-home--builder .sf-builder-products:first-child {
    margin-top: 0;
}

/* Units sold on product cards: hidden unless a theme shows it */
.sf-sold {
    display: none;
}

/* Phone tab bar: hidden unless a theme turns it on */
.sf-tabbar {
    display: none;
}
