/* ---------------------------------------------------------------------------
   Home sections — product rails and category tiles.

   The rail is native overflow scrolling with scroll-snap. No slider library:
   the browser already does touch momentum, trackpad gestures, keyboard arrows
   and reduced-motion properly, and the arrow buttons are a mouse convenience
   layered on top rather than the mechanism.
   --------------------------------------------------------------------------- */

.gms-rail {
    margin: 0 0 clamp(28px, 5vw, 52px);
}

.gms-rail__head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 14px;
}

.gms-rail__titles {
    /* Without this the long-title case pushes the arrows off the row instead
       of wrapping — a flex item defaults to min-width:auto. */
    min-width: 0;
}

.gms-rail__title {
    margin: 0;
    color: var(--gms-ink, #1a1a1a);
    font-size: clamp(1.15rem, 2.4vw, 1.6rem);
    font-weight: 650;
    line-height: 1.25;
    letter-spacing: -0.01em;
}

.gms-rail__sub {
    margin: 4px 0 0;
    color: var(--gms-ink-soft, #6b6b6b);
    font-size: 0.9rem;
    line-height: 1.5;
}

.gms-rail__tools {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 12px;
}

.gms-rail__more {
    color: var(--gms-ink, #1a1a1a);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    text-underline-offset: 3px;
    white-space: nowrap;
}

.gms-rail__more:hover,
.gms-rail__more:focus-visible {
    text-decoration: underline;
}

.gms-rail__nav {
    display: flex;
    gap: 6px;
}

/* Arrows are a pointer affordance. On touch, where swiping is the natural
   gesture, they only take up room. */
@media (hover: none) {
    .gms-rail__nav {
        display: none;
    }
}

.gms-rail__arrow {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--gms-line, #e4e4e4);
    border-radius: 999px;
    background: var(--gms-surface, #fff);
    color: var(--gms-ink, #1a1a1a);
    cursor: pointer;
    transition: border-color 0.15s ease, opacity 0.15s ease;
}

.gms-rail__arrow:hover {
    border-color: var(--gms-ink, #1a1a1a);
}

/* At either end the button stays in place rather than disappearing — a nav
   that changes size as you scroll makes the whole row jump. */
.gms-rail__arrow[disabled] {
    opacity: 0.3;
    cursor: default;
}

.gms-rail__chev {
    display: block;
    width: 7px;
    height: 7px;
    border-top: 2px solid currentColor;
    border-right: 2px solid currentColor;
    transform: translateX(-1px) rotate(45deg);
}

.gms-rail__chev--left {
    transform: translateX(1px) rotate(-135deg);
}

.gms-rail__track {
    display: grid;
    grid-auto-flow: column;
    /* A fixed track width, so a card is the same size whether the row holds
       three products or thirty, and the row overflows rather than dividing the
       space up. Not minmax(0, X): a zero minimum lets every card collapse to a
       sliver instead of overflowing, which is exactly what it did. */
    grid-auto-columns: var(--gms-rail-card, 210px);
    /* Stretch, so every card in a row is the same height. One product with a
       low-stock line would otherwise sit taller than its neighbours and leave
       the row of buttons ragged. */
    align-items: stretch;
    gap: var(--gms-rail-gap, 14px);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    /* Bleed to the viewport edge on a phone so the last card is visibly cut
       off — that is what signals there is more to swipe to. */
    margin-inline: calc(var(--gms-rail-bleed, 0px) * -1);
    padding-inline: var(--gms-rail-bleed, 0px);
    padding-bottom: 4px;
    scrollbar-width: none;
}

.gms-rail__track::-webkit-scrollbar {
    display: none;
}

.gms-rail__track:focus-visible {
    outline: 2px solid var(--gms-accent, #1a1a1a);
    outline-offset: 3px;
    border-radius: 4px;
}

.gms-rail__item {
    min-width: 0;
    scroll-snap-align: start;
}

/* The item stretches; the card has to fill it, or equal-height tracks just
   leave white space under short cards. */
.gms-rail__item > * {
    height: 100%;
}

@media (prefers-reduced-motion: reduce) {
    .gms-rail__track {
        scroll-behavior: auto;
    }
}

@media (max-width: 782px) {
    .gms-rail {
        --gms-rail-card: 158px;
        --gms-rail-gap: 10px;
        --gms-rail-bleed: 16px;
    }
}

/* ---------------------------------------------------------------------------
   Category tiles
   --------------------------------------------------------------------------- */

.gms-cats {
    margin: 0 0 clamp(28px, 5vw, 52px);
}

.gms-cats__track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
    gap: 18px 12px;
}

.gms-cats__track--rail {
    grid-auto-flow: column;
    grid-template-columns: none;
    grid-auto-columns: 96px;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    margin-inline: calc(var(--gms-rail-bleed, 0px) * -1);
    padding-inline: var(--gms-rail-bleed, 0px);
    scrollbar-width: none;
}

.gms-cats__track--rail::-webkit-scrollbar {
    display: none;
}

.gms-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    min-width: 0;
    color: inherit;
    text-align: center;
    text-decoration: none;
    scroll-snap-align: start;
}

.gms-cat__badge {
    display: grid;
    place-items: center;
    width: 72px;
    height: 72px;
    overflow: hidden;
    border-radius: 999px;
    background: var(--gms-muted, #f1f1ef);
    color: var(--gms-ink, #1a1a1a);
    transition: transform 0.18s ease;
}

.gms-cats--square .gms-cat__badge {
    width: 100%;
    height: auto;
    aspect-ratio: 1;
    border-radius: 14px;
}

.gms-cat:hover .gms-cat__badge,
.gms-cat:focus-visible .gms-cat__badge {
    transform: translateY(-2px);
}

/* Doubled for the same reason as the card image: as `.gms-cat__badge img`
   this was (0,1,1), an exact tie with a builder's `.elementor img`, and a tie
   is settled by whichever stylesheet happens to load second. That is not a
   thing to leave to chance on somebody else's site. */
.gms-cat__badge.gms-cat__badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Raised in step with the rule above, or the tile would win the tie and the
   icon would fill the disc edge to edge. */
.gms-cats--circle .gms-cat__badge.gms-cat__badge img {
    /* An icon, not a photograph — inset so it reads as a symbol on the disc
       rather than filling it edge to edge. */
    width: 60%;
    height: 60%;
    object-fit: contain;
}

.gms-cat__initial {
    font-size: 1.5rem;
    font-weight: 600;
    line-height: 1;
}

.gms-cat__name {
    color: var(--gms-ink, #1a1a1a);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    /* Two lines then ellipsis: a long category name must not make one tile
       taller than its neighbours and ragged the whole row. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.gms-cat__count {
    color: var(--gms-ink-soft, #6b6b6b);
    font-size: 0.6875rem;
    line-height: 1;
}

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

    .gms-cat:hover .gms-cat__badge,
    .gms-cat:focus-visible .gms-cat__badge {
        transform: none;
    }
}

/* ---------------------------------------------------------------------------
   A hand-picked grid.
   Wraps rather than scrolls: this is a chosen set with a first and a last, so
   showing all of it at once is the point.
   --------------------------------------------------------------------------- */

.gms-picked {
    margin: 0 0 clamp(28px, 5vw, 52px);
}

.gms-picked__grid {
    display: grid;
    /* minmax(0, 1fr), not 1fr — a 1fr track takes its minimum from the content,
       so one long product name widens the column and the row stops matching. */
    grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr));
    gap: var(--gms-rail-gap, 14px);
    align-items: stretch;
}

.gms-picked__grid > * {
    min-width: 0;
    height: 100%;
}

@media (max-width: 782px) {
    .gms-picked__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }
}
