/*
 * Storefront readability and touch pass, loaded last, for every theme.
 *
 * Colours come from ThemeConfig::readableCss(), which prints only the tokens
 * a theme needs (WCAG 2.2 AA 4.5:1 on its light grounds):
 *   --theme-color-primary-ink  main colour used as text (prices, links,
 *                              outline buttons); the text colour when the
 *                              main colour is too light (Tekno yellow)
 *   --theme-color-text-muted / -success / -danger  deepened when they fail
 * Touch targets follow WCAG 2.5.8 (24px minimum), 40px+ where thumbs land.
 */

/* ---------- Main colour as text ---------- */
html[data-tb] .sfx-price,
html[data-tb] .sf-sticky-order .js-price,
html[data-tb] .js-toggle-label,
html[data-tb] .sfx-eyebrow a,
html[data-tb] .breadcrumbs a,
html[data-tb] .sfx-checkout a:not(.btn),
html[data-tb] a.sfx-link-btn,
html[data-theme] .sf-row-link,
html[data-theme] .sx-eyebrow:not(.sx-countdown .sx-eyebrow),
html[data-tb] .sfx-cart a:not(.btn) {
    color: var(--theme-color-primary-ink, var(--theme-color-primary));
}

html[data-tb] #add-to-cart-btn,
html[data-tb] .sf-sticky-cart,
html[data-tb] .sfx-buy-actions .btn-outline-primary {
    color: var(--theme-color-primary-ink, var(--theme-color-primary));
    border-color: var(--theme-color-primary-ink, var(--theme-color-primary));
}

html[data-tb] #add-to-cart-btn:hover,
html[data-tb] .sfx-buy-actions .btn-outline-primary:hover {
    color: var(--theme-color-text-inverse, #fff);
    background: var(--theme-color-primary);
    border-color: var(--theme-color-primary);
}

/* Notes on tinted cards (selected payment option) */
html[data-tb] .sfx-pay-option small {
    color: var(--theme-color-text);
    opacity: 0.85;
}

/* Saving pill on its own green tint */
html[data-theme][data-tb] .sx-save {
    color: color-mix(in srgb, var(--theme-color-success, #16a34a) 72%, #000);
}

/* Promo tile tag: a white wash on the main colour lowered white text to 3.4:1 */
html[data-theme] .sf-promo-tile:not(.is-alt) .sf-promo-tag {
    background: rgba(0, 0, 0, 0.22);
}

html[data-theme] .sf-promo-tile.is-alt .sf-promo-text {
    color: var(--theme-color-text);
}

/* Theme colours that were written as fixed values */
html[data-theme="hyper"] {
    --hy-green: var(--theme-color-success, #117c38);
    --hy-red: var(--theme-color-danger, #d32136);
}

html[data-theme="tekno"] {
    --tk-sale: var(--theme-color-danger, #cd3333);
}

/* Tekno: the accent is a fill; on white it is text only through the ink */
html[data-theme="tekno"] .sfx-link-btn,
html[data-theme="tekno"] .tk-now,
html[data-theme="tekno"] .tk-week-card .tk-card-title a {
    color: var(--theme-color-primary-ink, var(--tk-ink));
}

/* Glow: category label in pink on white */
html[data-theme="glow"] .gl-card-cat {
    color: var(--theme-color-primary-ink, var(--gl-accent));
}

/* Moda: white on orange is 2:1; dark text keeps the orange */
html[data-theme="moda"] .md-flag.is-new {
    color: #1c1c1c;
}

html[data-theme="moda"] .md-slide-eyebrow {
    color: #a65300;
}

html[data-theme="moda"] .md-saver-save {
    color: #7d4d00;
}

/* Glow: pink labels on the blush and lavender cards */
html[data-theme="glow"] .gl-timer > span,
html[data-theme="glow"] .gl-promo small {
    color: #a8155a;
}

/* Tekno newsletter band sits on the accent: its title takes the accent's text colour */
html[data-theme="tekno"] .tk-news h2,
html[data-theme="tekno"] .tk-news-title {
    color: var(--tk-on-accent);
}

/* Bayt WhatsApp button: white on #25d366 is 2:1 */
html[data-theme="bayt"] .by-help-btn.is-wa {
    background: #0e7a3c;
}

/* ---------- Theme footers ----------
   themes.css paints every <footer> with the surface colour !important, which
   turned the Glow and Moda footers into white text on a pale pink / pale blue
   background (1.1:1, unreadable). Each theme keeps its own footer colours. */
html[data-theme="glow"] footer.gl-footer {
    background-color: var(--gl-teal) !important;
    color: rgba(255, 255, 255, 0.78) !important;
}

html[data-theme="moda"] footer.md-footer {
    background-color: var(--md-navy) !important;
    color: rgba(255, 255, 255, 0.78) !important;
}

html[data-theme="tekno"] footer.tk-footer {
    background-color: #fff !important;
    color: var(--tk-ink) !important;
}

html[data-theme="bayt"] footer.by-footer {
    background-color: var(--by-linen) !important;
    color: var(--by-ink) !important;
}

html[data-theme="glow"] .gl-footer a,
html[data-theme="moda"] .md-footer a {
    color: rgba(255, 255, 255, 0.78);
}

/* ---------- Arabic: no tracking on joined script ---------- */
html[lang^="ar"] body :is(h1, h2, h3, h4, h5, h6, p, a, span, small, strong, b, li, label, button, .btn) {
    letter-spacing: normal !important;
}

/* ---------- Touch targets ---------- */
@media (max-width: 767.98px) {
    /* Footer link lists: 17-18px tall rows become 36px rows */
    footer[data-tb-part="footer"] li > a,
    footer[data-tb-part="footer"] .sf-footer-link {
        display: inline-flex;
        align-items: center;
        min-height: 36px;
    }

    /* Top bar links (phone, contact, sign in), footer e-mail and policy links */
    :is(.tk-topbar-links, .md-topbar-links, .by-service-links) > li > a,
    .gl-topbar-end > a,
    footer[data-tb-part="footer"] p > a,
    footer[data-tb-part="footer"] nav > a {
        display: inline-flex;
        align-items: center;
        min-height: 32px;
    }

    /* "View all" links beside section titles, card category links */
    :is(.sf-row-link, .sx-more, .by-more, .hy-link-all),
    html[data-theme="tekno"] .tk-card-cat {
        display: inline-flex;
        align-items: center;
        min-height: 32px;
    }

    html[data-theme="tekno"] .tk-card-cat {
        min-height: 24px;
    }

    /* Breadcrumbs */
    .breadcrumbs a {
        display: inline-flex;
        align-items: center;
        min-height: 32px;
    }

    /* Cart: remove, empty cart, continue shopping */
    .sfx-link-btn {
        min-height: 36px;
        padding-inline: 4px;
    }

    /* Listing sort */
    html[data-theme] .sf-sort-select {
        min-height: 40px;
    }
}

/* Slider dots: 8px dots keep their look, the tap area grows to 24px */
.swiper-pagination-bullet {
    position: relative;
}

.swiper-pagination-bullet::after {
    content: "";
    position: absolute;
    inset: -8px;
}

/* Glow: on touch the full-width "Add to bag" bar hid the lower third of the
   photo; it becomes a round button in the corner like the other themes. */
@media (hover: none) {
    html[data-theme="glow"] .gl-add {
        inset-inline: auto 8px;
        bottom: 8px;
        width: 42px;
        height: 42px;
        padding: 0;
        border-radius: 50%;
        font-size: 0;
        background: #fff;
        color: var(--gl-ink);
        box-shadow: 0 6px 16px -4px rgba(0, 0, 0, 0.25);
    }

    html[data-theme="glow"] .gl-add .bi {
        font-size: 18px;
    }
}
