/*
 * Services Browse widget — tabbed photo carousel
 * Markup: laravel_app/resources/views/widgets/services_browse.blade.php
 * Data seed: laravel_app/config/services_browse.php (expanded into page HTML on add)
 *
 * Tuned to match the rest of AmeriFreight:
 * - .container max-width 1400px
 * - section padding like TextSection / py-lg-5
 * - navy #002868, red #ca0538, soft ground #f4f6fa
 * - body-scale type (14–16px), h2 ~32px / weight 700
 */

.svcb {
    --svcb-navy: #002868;
    --svcb-red: #ca0538;
    --svcb-text: #222;
    --svcb-muted: #5b6470;
    --svcb-line: #e3e6eb;
    --svcb-bg: #f4f6fa;
    --svcb-radius: 12px;
    --svcb-card-h: 320px;

    background: var(--svcb-bg);
    color: var(--svcb-text);
    padding: 56px 0 64px;
    font-size: 14px;
    line-height: 1.5;
}

/* Header — same rhythm as .all-headings blocks */
.svcb__header {
    max-width: 780px;
    margin: 0 0 28px;
}

.svcb__eyebrow {
    display: inline-block;
    margin: 0 0 12px;
    padding: .4rem 1.1rem;
    border-radius: 50px;
    background: rgba(202, 5, 56, .09);
    color: var(--svcb-red);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .14em;
    text-transform: uppercase;
    line-height: 1.2;
}

.svcb__title {
    margin: 0 0 14px;
    color: #0b1f4d;
    font-size: clamp(1.5rem, 2.4vw, 2rem); /* ~24–32px, matches site h2 */
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: -.01em;
}

.svcb__intro {
    margin: 0;
    color: var(--svcb-muted);
    font-size: 15px;
    line-height: 1.7;
}

.svcb__browse-label {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .04em;
    color: var(--svcb-navy);
}

/* Tabs */
.svcb__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 28px;
    padding: 0;
    list-style: none;
}

.svcb__tab {
    border: 1px solid var(--svcb-line);
    background: #fff;
    color: var(--svcb-navy);
    padding: 9px 16px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 13px;
    line-height: 1.25;
    cursor: pointer;
    transition: border-color .18s ease, background-color .18s ease, color .18s ease;
}

.svcb__tab:hover {
    border-color: var(--svcb-navy);
}

.svcb__tab.is-active,
.svcb__tab[aria-selected="true"] {
    background: var(--svcb-navy);
    color: #fff;
    border-color: var(--svcb-navy);
}

.svcb__tab:focus {
    outline: none;
}

.svcb__tab:focus-visible {
    outline: 3px solid var(--svcb-navy);
    outline-offset: 3px;
}

/* Category head */
.svcb__category-head {
    display: flex;
    justify-content: space-between;
    gap: 16px 24px;
    align-items: flex-end;
    margin: 0 0 18px;
}

.svcb__category-title {
    margin: 0;
    flex: 0 1 auto;
    color: var(--svcb-navy);
    font-size: clamp(1.125rem, 1.6vw, 1.375rem); /* ~18–22px */
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -.01em;
}

.svcb__category-note {
    margin: 0;
    flex: 1 1 auto;
    min-width: 0;
    color: var(--svcb-muted);
    font-size: 14px;
    text-align: right;
    line-height: 1.4;
    white-space: nowrap; /* keep the category blurb on one line on desktop */
}

/* Carousel shell */
.svcb__shell {
    position: relative;
    padding: 0 28px;
}

.svcb__track {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
}

.svcb__card {
    position: relative;
    height: var(--svcb-card-h);
    min-height: var(--svcb-card-h);
    overflow: hidden;
    border-radius: var(--svcb-radius);
    background: #111827;
    border: 1px solid rgb(0 40 104 / .06);
    box-shadow: 0 4px 16px rgb(0 40 104 / .08);
}

.svcb__card.is-hidden {
    display: none;
}

.svcb__card img {
    width: 100%;
    height: 100%;
    max-width: none;
    object-fit: cover;
    object-position: center 40%;
    position: absolute;
    inset: 0;
    filter: saturate(.96);
    transition: transform .28s ease;
}

.svcb__card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgb(0 0 0 / .04) 18%, rgb(0 0 0 / .78) 100%);
    transition: background .25s ease;
    pointer-events: none;
}

.svcb__card-body {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    padding: 18px 18px 20px;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    min-height: 108px;
}

.svcb__card-title {
    margin: 0 0 8px;
    font-size: 17px;
    line-height: 1.2;
    font-weight: 700;
    min-height: 40px;
    display: flex;
    align-items: flex-end;
    color: #fff;
    text-transform: none;
    letter-spacing: 0;
}

.svcb__card-text {
    margin: 0 0 12px;
    font-size: 13px;
    line-height: 1.5;
    color: rgb(255 255 255 / .92);
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(8px);
    transition: opacity .22s ease, transform .22s ease, max-height .22s ease, margin .22s ease;
}

.svcb__card-link {
    color: #fff;
    font-weight: 700;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.35;
    min-height: 32px;
    display: flex;
    align-items: flex-end;
    gap: 4px;
}

.svcb__card-link:hover,
.svcb__card-link:focus {
    color: #fff;
    text-decoration: none;
}

.svcb__card-link:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 3px;
    border-radius: 2px;
}

.svcb__card-link::after {
    content: "→";
}

@media (hover: hover) and (pointer: fine) {
    .svcb__card:hover img {
        transform: scale(1.03);
    }

    .svcb__card:hover::after {
        background: linear-gradient(180deg, rgb(0 0 0 / .4) 0%, rgb(0 0 0 / .92) 100%);
    }

    .svcb__card:hover .svcb__card-body {
        min-height: 100%;
        background: linear-gradient(180deg, rgb(0 0 0 / .1) 0%, rgb(0 0 0 / .32) 45%, rgb(0 0 0 / .7) 100%);
    }

    .svcb__card:hover .svcb__card-text {
        opacity: 1;
        max-height: 160px;
        transform: translateY(0);
        margin: 0 0 12px;
    }
}

/* Arrows */
.svcb__arrow {
    position: absolute;
    top: 50%;
    z-index: 5;
    width: 42px;
    height: 42px;
    transform: translateY(-50%);
    border: 1.5px solid var(--svcb-navy);
    border-radius: 999px;
    background: #fff;
    color: var(--svcb-navy);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin: 0;
    appearance: none;
    cursor: pointer;
    box-shadow: 0 4px 14px rgb(0 40 104 / .12);
    transition: background-color .18s ease, color .18s ease;
}

.svcb__arrow svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.svcb__arrow--prev { left: 0; }
.svcb__arrow--next { right: 0; }

.svcb__arrow.is-hidden {
    display: none !important;
}

.svcb__arrow:focus {
    outline: none;
}

.svcb__arrow:focus-visible {
    outline: 3px solid var(--svcb-navy);
    outline-offset: 3px;
}

@media (hover: hover) and (pointer: fine) {
    .svcb__arrow:hover {
        background: var(--svcb-navy);
        color: #fff;
    }
}

.svcb__panel[hidden] {
    display: none !important;
}

/* Tablet */
@media (max-width: 991px) {
    .svcb {
        --svcb-card-h: 300px;
        padding: 48px 0 56px;
    }

    .svcb__track {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 14px;
    }

    .svcb__category-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .svcb__category-note {
        text-align: left;
        white-space: normal; /* wrap again when stacked on tablet/mobile */
    }

    .svcb__shell {
        padding: 0 24px;
    }

    .svcb__arrow {
        width: 40px;
        height: 40px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .svcb {
        --svcb-card-h: 280px;
        padding: 40px 0 48px;
    }

    .svcb__header {
        margin-bottom: 22px;
    }

    .svcb__title {
        font-size: 1.5rem;
    }

    .svcb__intro {
        font-size: 14px;
        line-height: 1.65;
    }

    .svcb__track {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .svcb__card-text {
        display: none;
    }

    .svcb__card-body {
        min-height: 100px;
        padding: 16px;
    }

    .svcb__card-title {
        font-size: 16px;
        min-height: 0;
    }

    .svcb__shell {
        padding: 0 20px;
    }

    .svcb__arrow {
        width: 38px;
        height: 38px;
    }

    .svcb__arrow svg {
        width: 16px;
        height: 16px;
    }

    .svcb__tabs {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 8px;
        margin-bottom: 22px;
    }

    .svcb__tab {
        width: 100%;
        min-height: 42px;
        padding: 8px 10px;
        text-align: center;
        font-size: 12px;
        line-height: 1.25;
    }

    .svcb__tab:last-child {
        grid-column: 1 / -1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .svcb__card img,
    .svcb__card-text,
    .svcb__tab,
    .svcb__arrow {
        transition: none;
    }

    .svcb__card:hover img {
        transform: none;
    }
}
