/*
 * The category band (delta-category-band.php).
 *
 * Colours are the ones already on the page: #0a1428 the label bar the old slider used, #dde5ff the
 * tint shop.css gives the selected category card, #03c7ff the accent from the corporate design.
 */

/* The band is as wide as an "alignwide" block, which is what the construction it replaced was —
 * not edge to edge. Without the cap it spanned the whole viewport on a wide screen while every
 * other section stayed boxed at the content width. */
.delta-band {
    max-width: var(--wp--style--global--wide-size, 1400px);
    margin: 24px auto 40px;
}

/* ------------------------------------------------------------------- cards */

.delta-band__card {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border-radius: 8px;
    background: #f5f6f8;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.delta-band__card:is(:hover, :focus-visible) {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgb(10 20 40 / 12%);
}

.delta-band__card:focus-visible {
    outline: 2px solid #03c7ff;
    outline-offset: 2px;
}

/* A fixed height, not a ratio: the cards are wider on the front page, where four share a row, than
 * on a category page with eight, and a ratio would make the same tile a different size on each.
 * overflow, because a flex line grows past a fixed height and the picture runs under the label. */
.delta-band__media {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 170px;
    padding: 12px;
    overflow: hidden;
}

.delta-band__image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

/* Two lines' worth, so the bars of a row start on one line where a name wraps and its neighbour
 * does not. */
.delta-band__text {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 64px;
    margin-top: auto;
    padding: 10px 12px;
    background: #0a1428;
    color: #fff;
    text-align: center;
}

/* "Hausanschlussverstärker" is 29px wider than the 150px a tile is based on, which pushed the
 * row 12px past its box around 768px: the arrows appeared for four tiles that fit, and the
 * fourth was clipped. Whether it happened depended on the visitor's scrollbar style. */
.delta-band__name {
    font-size: clamp(14px, 1.1vw, 17px);
    font-weight: 500;
    line-height: 1.25;
    hyphens: auto;
    overflow-wrap: anywhere;
}

.delta-band__count {
    margin-top: 2px;
    font-size: 12px;
    color: rgb(255 255 255 / 65%);
}

/* --------------------------------------------------------- the four tops */

/* 150px and not 190: at 390px the content column is 342px, and 2 x 190 + 24 gap is 404 — the four
 * cards fell into one column each and the band grew by 618px. */
.delta-band__row--tops {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 150px), 1fr));
    gap: 24px;
    margin: 0 0 28px;
    padding: 0;
    list-style: none;
}

.delta-band__row--tops .delta-band__item {
    margin: 0;
}

/* 72px is the height the menu images had in shop.css, and the 5px gap below them comes from there
 * too, so the strip reads at the size of the one it replaces. */
.delta-band__card--top {
    background: #eaeffd;
    cursor: pointer;
}

.delta-band__card--top:hover {
    background: #dde5ff;
}

.delta-band__card--top .delta-band__media {
    height: 72px;
    padding: 30px 16px 0;
}

.delta-band__card--top .delta-band__image {
    height: 100%;
    width: auto;
}

.delta-band__card--top .delta-band__text {
    min-height: 0;
    padding: 5px 12px 28px;
    background: none;
    color: #0a1428;
}

.delta-band__card--top .delta-band__name {
    font-size: clamp(15px, 1.4vw, 20px);
}

/* Off screen, not display:none — a hidden input cannot be reached with the keyboard, and the
 * switch would stop working for anyone not using a mouse. */
.delta-band__radio {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip-path: inset(50%);
}

/* Radio n opens panel n and marks card n. One line per category — a fifth category needs a fifth
 * line here. The pairing goes by position, see the note in delta_band_html(). Without CSS every
 * panel stands open, which is four labelled rows and still a usable page. */
.delta-band__panel {
    display: none;
}

.delta-band__radio:nth-of-type(1):checked ~ .delta-band__panel:nth-of-type(1),
.delta-band__radio:nth-of-type(2):checked ~ .delta-band__panel:nth-of-type(2),
.delta-band__radio:nth-of-type(3):checked ~ .delta-band__panel:nth-of-type(3),
.delta-band__radio:nth-of-type(4):checked ~ .delta-band__panel:nth-of-type(4) {
    display: block;
}

.delta-band__radio:nth-of-type(1):checked ~ .delta-band__row--tops .delta-band__item:nth-child(1) .delta-band__card--top,
.delta-band__radio:nth-of-type(2):checked ~ .delta-band__row--tops .delta-band__item:nth-child(2) .delta-band__card--top,
.delta-band__radio:nth-of-type(3):checked ~ .delta-band__row--tops .delta-band__item:nth-child(3) .delta-band__card--top,
.delta-band__radio:nth-of-type(4):checked ~ .delta-band__row--tops .delta-band__item:nth-child(4) .delta-band__card--top {
    background: #dde5ff;
}

.delta-band__radio:nth-of-type(1):checked ~ .delta-band__row--tops .delta-band__item:nth-child(1) .delta-band__name,
.delta-band__radio:nth-of-type(2):checked ~ .delta-band__row--tops .delta-band__item:nth-child(2) .delta-band__name,
.delta-band__radio:nth-of-type(3):checked ~ .delta-band__row--tops .delta-band__item:nth-child(3) .delta-band__name,
.delta-band__radio:nth-of-type(4):checked ~ .delta-band__row--tops .delta-band__item:nth-child(4) .delta-band__name {
    color: #03c7ff;
}

/* No focus rule: a radio group is entered at the one that is checked, and the arrow keys check
 * what they move to — so a focused card here is always the chosen card. */

/* ------------------------------------------------------------- the slider */

.delta-band__slider {
    position: relative;
}

.delta-band__slider .delta-band__row {
    display: flex;
    gap: 24px;
    margin: 0;
    padding: 0 0 8px;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-snap-type: x proximity;
    scroll-behavior: smooth;
}

/* Five cards at 1440px, two and a bit at 390px — and one cut off at the edge, which is what says
 * there is more to the right. grow, so four fill the row instead of leaving a hole; where they
 * overflow there is no free space to grow into. */
.delta-band__slider .delta-band__item {
    flex: 1 0 clamp(150px, 19%, 250px);
    margin: 0;
    scroll-snap-align: start;
}

/* Once the arrows are there the scrollbar is a second control for the same thing; until the script
 * runs it is the only sign the row moves, so it stays. */
.delta-band__slider.is-scrollable .delta-band__row {
    scrollbar-width: none;
}

.delta-band__slider.is-scrollable .delta-band__row::-webkit-scrollbar {
    display: none;
}

.delta-band__arrow {
    position: absolute;
    top: calc(50% - 22px);
    z-index: 2;
    display: none;   /* the script turns them on; without it the row still scrolls */
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #0a1428;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 2px 10px rgb(10 20 40 / 25%);
}

.delta-band__slider.is-scrollable .delta-band__arrow {
    display: grid;
}

.delta-band__arrow[disabled] {
    opacity: 0;
    pointer-events: none;
}

.delta-band__arrow:hover {
    background: #03c7ff;
    color: #0a1428;
}

.delta-band__arrow--prev { left: -14px; }
.delta-band__arrow--next { right: -14px; }

/* The glyph sits high in the font. */
.delta-band__arrow span {
    margin-top: -3px;
}

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

    .delta-band__card:is(:hover, :focus-visible) {
        transform: none;
    }

    .delta-band__slider .delta-band__row {
        scroll-behavior: auto;
    }
}

/* ------------------------------------- the best sellers on the start page (delta-bestsellers.php) */

.delta-bestsellers {
    margin-block: 24px;
}

/* Four at a time, which is what the slider this replaces showed. Two on a tablet, one and a bit on
 * a phone — there the cut-off card is what says there is more to the right. 24px is the row's gap. */
.delta-bestsellers .delta-band__item {
    flex: 0 0 calc((100% - 3 * 24px) / 4);
}

@media (max-width: 1023px) {
    .delta-bestsellers .delta-band__item {
        flex-basis: calc((100% - 24px) / 2);
    }
}

@media (max-width: 599px) {
    .delta-bestsellers .delta-band__item {
        flex-basis: calc(100% - 56px);
    }
}

/* A product card, not a category tile: the picture is a photograph on white, and below it stand a
 * price and a button, which the band's dark bar has no room for. */
.delta-bestsellers .delta-band__card--product {
    background: #fff;
    border: 1px solid #e2e8f0;
}

.delta-bestsellers .delta-band__text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 8px;
    justify-content: flex-start;
    min-height: 0;
    padding: 12px;
    background: transparent;
    color: #0a1428;
}

.delta-bestsellers .delta-band__name {
    color: #0a1428;
    text-decoration: none;
    /* The names run to "Faserpigtail SC/APC, 12 Pigtails, 9/125µm G657A1", and a card that grows to
     * fit the longest one makes every card in the row that tall. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.delta-bestsellers .delta-band__name:is(:hover, :focus-visible) {
    color: #03c7ff;
}

/* The price, or the sentence standing in for it while nobody is logged in. */
.delta-bestsellers__price {
    font-size: 14px;
    line-height: 1.3;
}

.delta-bestsellers__price a {
    color: #0a1428;
}

/* Every card's button on the same line, however long the name above it. */
.delta-bestsellers__cta {
    margin-top: auto;
    align-self: center;
}
