/* assets/css/pages/service-area.css
   Template: Service Area — Horizontal Product Slider
   -------------------------------------------------- */

/* ── Section ───────────────────────────────────────── */
.sa-products-section {
    padding-block: clamp(64px, 10vw, 120px);
    background-color: var(--wp--preset--color--bg, #f5f3ef);
}

.sa-products-container {
    width: 100%;
    max-width: calc(var(--layout-max-width, 1400px) + 2 * var(--layout-padding, clamp(24px, 4vw, 40px)));
    margin-inline: auto;
    padding-inline: var(--layout-padding, clamp(24px, 4vw, 40px));
    box-sizing: border-box;
}

/* ── Header (aligned with blk-related-products) ──── */
.sa-products-header {
    display: flex;
    align-items: baseline;
    gap: 16px;
    margin-bottom: clamp(40px, 6vw, 72px);
    padding-bottom: 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Override: use heading schema for section title */
.sa-products-header .sa-products-title {
    font-size: var(--t1-heading-section); /* Schema: 28–36px fluid */
    font-weight: 400;
    letter-spacing: -0.02em;
    margin: 0;
}

.sa-products-header .blk-related-products__count {
    margin-left: auto;
    align-self: center;
    text-transform: uppercase;
}

/* ── Slider — Full-viewport width, no clipping ────── */
.sa-slider {
    position: relative;
    width: 100%;
    overflow: visible;
}

/* Track: horizontal scroll spanning full viewport.
   First card aligns with .container via a spacer element (injected by JS).
   Cards are NEVER clipped — visible on both edges. */
.sa-slider__track {
    display: flex;
    gap: 10px;
    overflow-x: scroll;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;

    /* Snap alignment: match container content edges */
    scroll-padding-left: max(
        var(--layout-padding, 40px),
        calc((100vw - var(--layout-max-width, 1400px)) / 2)
    );
    scroll-padding-right: max(
        var(--layout-padding, 40px),
        calc((100vw - var(--layout-max-width, 1400px)) / 2)
    );

    /* Hide scrollbar */
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Spacer: invisible first child that pushes cards to the container edge */
.sa-slider__spacer {
    flex: none;
    /* Width set by JS to match container content offset */
}

.sa-slider__track::-webkit-scrollbar {
    display: none;
}

/* ── Arrow Navigation ─────────────────────────────── */
.sa-slider__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: var(--wp--preset--color--bg, #FAF9F6);
    color: var(--wp--preset--color--text-main, #121212);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition:
        background 0.25s ease,
        border-color 0.25s ease,
        opacity 0.25s ease,
        box-shadow 0.25s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.sa-slider__arrow:disabled {
    opacity: 0;
    pointer-events: none;
}

.sa-slider__arrow--prev {
    left: max(
        calc(var(--layout-padding, 40px) - 56px),
        calc((100vw - var(--layout-max-width, 1400px)) / 2 - 56px)
    );
    transform: translateY(-50%);
}

/* Rotate arrow for prev direction */
.sa-slider__arrow--prev .arrow-icon {
    transform: rotate(180deg);
}

.sa-slider__arrow--next {
    right: var(--layout-padding, 40px);
    transform: translateX(50%) translateY(-50%);
}


/* ── Card ──────────────────────────────────────────── */
.sa-product-card {
    flex: 0 0 clamp(280px, 30vw, 380px);
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: clamp(24px, 3vw, 40px);
    background-color: #fff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    text-decoration: none;
    color: var(--wp--preset--color--text-main, #121212);
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease;
    position: relative;
    scroll-snap-align: start;

    /* Initial state for scroll animation */
    opacity: 0;
    transform: translateY(20px);
}

/* Last card snaps its right edge to the container right edge */
.sa-product-card:last-of-type {
    scroll-snap-align: end;
}

.sa-product-card.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.sa-product-card:hover {
    border-color: var(--wp--preset--color--accent, #fc490b);
}

/* Draft indicator */
.sa-product-card--draft {
    opacity: 0.6;
}

.sa-product-card--draft::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        -45deg,
        transparent,
        transparent 8px,
        rgba(0,0,0,0.015) 8px,
        rgba(0,0,0,0.015) 16px
    );
    pointer-events: none;
}

/* ── Card Top ──────────────────────────────────────── */
.sa-product-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 28px;
}

.sa-card-num {
    font-family: var(--wp--preset--font-family--body), monospace;
    font-size: var(--wp--preset--font-size--xs);
    font-weight: 700;
    letter-spacing: 0.15em;
    color: var(--wp--preset--color--accent, #fc490b);
}

.sa-card-status {
    font-family: var(--wp--preset--font-family--body), monospace;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(18, 18, 18, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
}

/* ── Card Body ─────────────────────────────────────── */
.sa-product-card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 32px;
}

.sa-card-kicker {
    font-family: var(--wp--preset--font-family--body), monospace;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(18, 18, 18, 0.35);
    display: block;
}

.sa-card-title {
    font-family: var(--wp--preset--font-family--heading), sans-serif;
    font-size: clamp(18px, 2vw, 24px);
    font-weight: 400;
    letter-spacing: -0.02em;
    line-height: 1.2;
    margin: 0;
    color: var(--wp--preset--color--text-main, #121212);
}

.sa-card-desc {
    font-size: var(--wp--preset--font-size--sm);
    line-height: 1.55;
    color: var(--wp--preset--color--text-muted);
    margin: 0;
    font-weight: 300;
    /* Clamp to 2 lines */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Title link — inherits card typography, no underline */
.sa-card-title-link {
    color: inherit;
    text-decoration: none;
}

.sa-product-card:hover .sa-card-title-link {
    color: var(--wp--preset--color--accent, #fc490b);
}

/* ── Card Footer ───────────────────────────────────── */
.sa-product-card-footer {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    padding-top: 20px;
}

.sa-card-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--wp--preset--font-family--body), sans-serif;
    font-size: var(--wp--preset--font-size--xs);
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--wp--preset--color--text-main, #121212);
    text-decoration: none;
    transition: color 0.25s ease;
}

/* Stretched link: CTA covers entire card → whole card is clickable */
.sa-card-cta::after {
    content: '';
    position: absolute;
    inset: 0;
}

.sa-card-cta svg {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    flex-shrink: 0;
}

.sa-product-card:hover .sa-card-cta {
    color: var(--wp--preset--color--accent, #fc490b);
}

.sa-product-card:hover .sa-card-cta svg {
    transform: translateX(5px);
}

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 640px) {
    .sa-product-card {
        flex: 0 0 60vw;
    }

    /* Show full description on mobile — no line clamp */
    .sa-card-desc {
        -webkit-line-clamp: unset;
        display: block;
        overflow: visible;
    }

    .sa-slider__arrow {
        display: none;
    }

    /* Mobile: disable stretched link — only CTA + title are tappable */
    .sa-card-cta::after {
        display: none;
    }

    /* Enlarge CTA tap target — padding for comfort, negative margin to keep flush */
    .sa-card-cta {
        padding: 12px 16px;
        margin: -12px -16px;
        border-radius: 8px;
    }

    .sa-card-cta:active {
        background: rgba(0, 0, 0, 0.03);
    }
}

/* ── Reduced Motion ────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .sa-slider__track {
        scroll-behavior: auto;
    }

    .sa-product-card {
        opacity: 1;
        transform: none;
    }
}

/* ── Drag cursor ───────────────────────────────────── */
.sa-slider__track.is-dragging {
    cursor: grabbing;
    scroll-snap-type: none;
    scroll-behavior: auto;
}

/* During drag, disable pointer events on card children
   so the track captures the drag even when clicking on cards */
.sa-slider__track.is-dragging .sa-product-card {
    pointer-events: none;
}

/* Same for touch-scroll — cards are non-clickable while scrolling */
.sa-slider__track.is-scrolling .sa-product-card {
    pointer-events: none;
}

.sa-slider__track:not(.is-dragging) {
    cursor: grab;
}
