/* ══════════════════════════════════════════════════════════════
   YALOSHOP — Categories Slider  (component bundle, v9.16.0)
   ──────────────────────────────────────────────────────────────
   ONE component, ONE stylesheet, ONE behaviour file
   (assets/js/cats-slider.js). Used by the home page and by the
   listing page with no per-page variants beyond a modifier class.

   LAYOUT CONTRACT — the single source of truth for "how many
   columns fit" is the custom property --ycat-cols, declared here
   and read back by the JS through getComputedStyle(). Before
   9.16.0 the breakpoints were written twice — once in CSS, once
   as a colsPerView() ladder in JS — and the two disagreed, so the
   arrows paged by a different amount than the grid actually laid
   out. A value that two languages must agree on is declared in
   one of them and read by the other.

       phone   (<640px)   3 columns × 2 rows
       tablet  (≥640px)   6 columns × 2 rows
       desktop (≥1024px) 10 columns × 2 rows
══════════════════════════════════════════════════════════════ */

/* ── Section shell ──────────────────────────────────────────── */
.ycat {
    --ycat-cols: 3;
    --ycat-gap: 10px;
    padding: 28px 0 0;
}
@media (min-width: 640px)  { .ycat { --ycat-cols: 6;  } }
@media (min-width: 1024px) { .ycat { --ycat-cols: 10; } }

.ycat--store {
    background: var(--clr-surface);
    border-bottom: 1px solid var(--clr-border);
    padding: 16px 0 12px;
    margin-bottom: 4px;
}

/* ── Header row ─────────────────────────────────────────────── */
.ycat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
}
.ycat-header--center { justify-content: center; }

.ycat-title {
    font-size: clamp(17px, 3vw, 22px);
    font-weight: 900;
    color: var(--clr-text);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.ycat-title i { color: var(--clr-primary); font-size: 16px; }

.ycat-viewall {
    font-size: 13px;
    font-weight: 700;
    color: var(--clr-primary);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
    transition: opacity .2s;
    white-space: nowrap;
}
.ycat-viewall:hover { opacity: .75; }
/* Physical glyph mirrored by direction — no PHP branch. */
[dir="rtl"] .ycat-viewall i { transform: scaleX(-1); }

/* ── Swipe hint (home): arrows flanking the centred title ───── */
.ycat-hint-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    /* Fixed LTR order: [hint] [title] [hint] in every language. */
    direction: ltr;
}
.ycat-hint-row .ycat-title { direction: inherit; flex-shrink: 0; }
.ycat-hint {
    display: flex;
    align-items: center;
    color: var(--clr-primary);
    opacity: .55;
    font-size: 12px;
    pointer-events: none;
    flex-shrink: 0;
}
.ycat-hint i + i { margin-left: -5px; opacity: .5; }
.ycat-hint--start { animation: ycat-hint-start 1.6s ease-in-out infinite; }
.ycat-hint--end   { animation: ycat-hint-end   1.6s ease-in-out infinite; }
@keyframes ycat-hint-start {
    0%,100% { transform: translateX(0);    opacity: .55; }
    50%     { transform: translateX(-4px); opacity: 1;   }
}
@keyframes ycat-hint-end {
    0%,100% { transform: translateX(0);   opacity: .55; }
    50%     { transform: translateX(4px); opacity: 1;   }
}
body.dark-mode .ycat-hint { opacity: .7; }

/* ── Back button (category pages) ───────────────────────────── */
.ycat-back {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    font-weight: 700;
    color: var(--clr-primary);
    background: color-mix(in srgb, var(--clr-primary) 8%, var(--clr-surface));
    border: 1.5px solid color-mix(in srgb, var(--clr-primary) 25%, transparent);
    border-radius: var(--radius-sm);
    padding-block: 7px;
    padding-inline: 10px 14px;
    text-decoration: none;
    transition: color .18s, border-color .18s, background .18s, box-shadow .18s;
    white-space: nowrap;
    max-width: 180px;
    overflow: hidden;
}
.ycat-back-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    font-size: 9px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--clr-primary) 15%, transparent);
    flex-shrink: 0;
    transition: background .18s, transform .22s cubic-bezier(.34,1.56,.64,1);
}
[dir="rtl"] .ycat-back-arrow i { transform: scaleX(-1); }
.ycat-back:hover {
    border-color: color-mix(in srgb, var(--clr-primary) 50%, transparent);
    background: color-mix(in srgb, var(--clr-primary) 12%, var(--clr-surface));
    box-shadow: 0 2px 10px color-mix(in srgb, var(--clr-primary) 20%, transparent);
}
.ycat-back:hover .ycat-back-arrow {
    background: color-mix(in srgb, var(--clr-primary) 22%, transparent);
    transform: translateX(-2px);
}
[dir="rtl"] .ycat-back:hover .ycat-back-arrow { transform: translateX(2px); }
.ycat-back-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    max-width: 120px;
}
body.dark-mode .ycat-back {
    background: color-mix(in srgb, var(--clr-primary) 10%, var(--clr-surface-2));
    border-color: color-mix(in srgb, var(--clr-primary) 28%, transparent);
}
body.dark-mode .ycat-back:hover {
    background: color-mix(in srgb, var(--clr-primary) 16%, var(--clr-surface-2));
}

/* ── Track: two rows, column flow, horizontal scroll ────────── */
.ycat-track {
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-auto-flow: column;
    /* A page is exactly the visible width: N columns + the N-1 gaps
       between them. Deriving it from --ycat-cols means changing the
       column count at a breakpoint changes the column WIDTH, the page
       width and the JS paging step together — they cannot drift. */
    grid-auto-columns: calc((100% - (var(--ycat-cols) - 1) * var(--ycat-gap)) / var(--ycat-cols));
    gap: var(--ycat-gap);
    /* Explicit on both axes: `overflow-y:visible` next to a scrolling
       x-axis computes to `auto`, which quietly makes the track a
       vertical scroll container too. Padding, not overflow, is what
       makes room for the hover lift and its shadow. */
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: auto;   /* JS owns smooth scrolling */
    overscroll-behavior-x: contain;
    scrollbar-width: none;
    padding: 6px 0 12px;
    /* pan-y keeps a vertical swipe that starts on the track scrolling
       the PAGE; the horizontal axis stays with the track. */
    touch-action: pan-x pan-y;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}
.ycat-track::-webkit-scrollbar { display: none; }
.ycat-track.is-grabbing { cursor: grabbing; }

/* Fewer items than one visible page → a single row reads better than
   a stubby two-row block with dead space beside it. Declarative, so it
   also re-evaluates on resize with no JS involved. */
.ycat-track:not(:has(> .ycat-item:nth-child(4)))  { grid-template-rows: auto; }
@media (min-width: 640px) {
    .ycat-track:not(:has(> .ycat-item:nth-child(7)))  { grid-template-rows: auto; }
}
@media (min-width: 1024px) {
    .ycat-track:not(:has(> .ycat-item:nth-child(11))) { grid-template-rows: auto; }
}

/* ── Item ───────────────────────────────────────────────────── */
.ycat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    min-width: 0;
    padding: 8px 4px 6px;
    border-radius: var(--radius);
    border: 1.5px solid transparent;
    background: transparent;
    text-decoration: none;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    /* Override the track's pan-x so a tap resolves as a click. */
    touch-action: manipulation;
    transition: background .18s, border-color .18s, transform .2s cubic-bezier(.34,1.56,.64,1);
}
.ycat-item:active { transform: scale(.93); }
.ycat-item.is-active {
    background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 8%, var(--clr-surface));
    border-color: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 30%, transparent);
}
.ycat-item:focus-visible {
    outline: 2px solid var(--ycat-color, var(--clr-primary));
    outline-offset: 2px;
}
@media (min-width: 1024px) {
    .ycat-item { padding: 6px 4px 4px; gap: 6px; }
    .ycat-item:hover {
        transform: translateY(-3px);
        background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 6%, var(--clr-surface));
    }
}

/* ── Icon frame ─────────────────────────────────────────────── */
.ycat-icon-box {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-width: 100px;
    border-radius: var(--cat-icon-radius);
    background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 11%, white);
    border: 1.5px solid color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 18%, transparent);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    transition: box-shadow .22s, background .18s;
}
.ycat-item:hover .ycat-icon-box,
.ycat-item.is-active .ycat-icon-box {
    box-shadow: 0 6px 18px color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 35%, transparent);
    background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 16%, white);
}
/* The frame has NO exception for photos.
   It used to: `.has-img { background: none; border: 0 }` stripped the tint
   and the ring whenever a category had an image, on the reasoning that a
   photo should fill the circle edge to edge. In a row where every other
   tile is a tinted, ringed circle, the one photo tile then read as
   unframed — a flat cut-out floating between framed neighbours — and a
   product shot on a white studio background lost its outline against the
   page entirely.

   The ring is what makes the row a row, so it is drawn for every tile and
   the class that opted out is gone rather than neutralised. The image is
   clipped to the padding box by `overflow: hidden`, so the border renders
   outside it and stays fully visible at any radius; the tint underneath
   now shows through transparent PNGs, which is the same treatment an icon
   gets and costs nothing for an opaque photo. */
@media (min-width: 1024px) {
    .ycat-icon-box { max-width: none; border-radius: var(--cat-icon-radius); }
}

.ycat-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .28s cubic-bezier(.34,1.56,.64,1);
}
.ycat-item:hover .ycat-img,
.ycat-item.is-active .ycat-img { transform: scale(1.1); }

.ycat-fa-icon {
    font-size: 30px;
    color: var(--ycat-color, var(--clr-primary));
    transition: font-size .22s ease;
}
.ycat-item:hover .ycat-fa-icon,
.ycat-item.is-active .ycat-fa-icon { font-size: 35px; }
@media (min-width: 1024px) {
    .ycat-fa-icon { font-size: 28px; }
    .ycat-item:hover .ycat-fa-icon,
    .ycat-item.is-active .ycat-fa-icon { font-size: 32px; }
}

.ycat-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ycat-color, var(--clr-primary));
}

/* ── Label ──────────────────────────────────────────────────── */
.ycat-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--clr-text-2);
    text-align: center;
    line-height: 1.25;
    max-width: 100%;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    word-break: break-word;
    transition: color .18s;
}
.ycat-item:hover .ycat-label,
.ycat-item.is-active .ycat-label { color: var(--ycat-color, var(--clr-primary)); }
@media (min-width: 1024px) { .ycat-label { font-size: 10.5px; } }

/* ── Navigation: back arrow · page dots · forward arrow ──────
   DOM order is [backward] [dots] [forward]. The row inherits the page
   direction, so in RTL the backward control lands on the right by
   itself and the glyphs mirror with scaleX(-1). Nothing about which
   button does what depends on the language. */
.ycat-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 10px;
    padding-bottom: 2px;
}
.ycat-nav[hidden] { display: none; }

.ycat-dots { display: flex; justify-content: center; gap: 5px; }
.ycat-pip {
    width: 5px;
    height: 5px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--clr-border);
    cursor: pointer;
    transition: background .2s, width .25s, border-radius .25s;
}
.ycat-pip.is-active {
    background: var(--clr-primary);
    width: 14px;
    border-radius: 3px;
}

.ycat-arrow {
    display: none;   /* touch breakpoints navigate by swipe */
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--clr-surface);
    border: 1.5px solid var(--clr-border);
    color: var(--clr-text);
    font-size: 12px;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    transition: background .2s, border-color .2s, color .2s, box-shadow .2s, opacity .2s;
}
[dir="rtl"] .ycat-arrow i { transform: scaleX(-1); }
.ycat-arrow:hover:not(:disabled) {
    background: var(--clr-primary);
    border-color: var(--clr-primary);
    color: #fff;
    box-shadow: 0 3px 10px color-mix(in srgb, var(--clr-primary) 32%, transparent);
}
.ycat-arrow:disabled { opacity: .35; cursor: default; }
@media (min-width: 1024px) { .ycat-arrow { display: inline-flex; } }

/* ── Dark mode ──────────────────────────────────────────────── */
body.dark-mode .ycat-icon-box {
    background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 14%, #1e293b);
    border-color: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 22%, transparent);
}
body.dark-mode .ycat-item:hover .ycat-icon-box,
body.dark-mode .ycat-item.is-active .ycat-icon-box {
    background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 20%, #1e293b);
}
body.dark-mode .ycat-item.is-active {
    background: color-mix(in srgb, var(--ycat-color, var(--clr-primary)) 10%, #1e293b);
}

/* ── Reduced motion ─────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ycat-hint { animation: none; }
    .ycat-item, .ycat-img, .ycat-icon-box, .ycat-fa-icon { transition: none; }
}
