/* =========================================================================
 * TDW Dynamic Landing Page
 *
 * Renderet af [tdw_landing] shortcode. Replaces hand-rolled UX Builder
 * pages with one source-of-truth-driven layout.
 *
 * Layout:
 *   - Heading + intro
 *   - Horizontal scrolling cards (always 1 row, peek next on mobile)
 *   - Product rows (heading + desc + grid)
 *
 * Cards bruger CSS scroll-snap for at give "peek af næste card" effekten
 * uanset viewport — desktop ser typisk 5 cards, mobile ser 2-3 + peek.
 * ========================================================================= */

.tdw-landing {
    --tdw-card-radius: 14px;
    --tdw-row-gap: 48px;
    --tdw-card-bg: #fff;
    --tdw-card-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
    --tdw-card-shadow-hover: 0 4px 8px rgba(0, 0, 0, 0.08), 0 12px 28px rgba(0, 0, 0, 0.10);

    margin: 0 auto;
    padding: 0 0 32px;
}

/* ---- Page header -------------------------------------------------------- */
.tdw-landing__header {
    padding: 32px 16px 24px;
    text-align: center;
    max-width: 720px;
    margin: 0 auto;
}

.tdw-landing__title {
    font-size: clamp(1.75rem, 3vw, 2.5rem);
    font-weight: 700;
    line-height: 1.15;
    margin: 0 0 12px;
}

.tdw-landing__intro {
    font-size: 15px;
    line-height: 1.55;
    color: rgba(0, 0, 0, 0.65);
}

.tdw-landing__intro p:last-child { margin-bottom: 0; }

/* ---- Cards row --------------------------------------------------------- */
.tdw-landing__cards-wrapper {
    position: relative;
    margin: 0 0 var(--tdw-row-gap);
    /* Side gradient masks indikerer scrollability */
    -webkit-mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
    mask-image: linear-gradient(to right, transparent 0, #000 16px, #000 calc(100% - 16px), transparent 100%);
}

.tdw-landing__cards {
    list-style: none !important;
    margin: 0 !important;
    padding: 8px 16px !important;
    display: flex;
    gap: 12px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-padding: 16px;
    scrollbar-width: none;       /* Firefox */
    -ms-overflow-style: none;    /* IE/Edge legacy */
    -webkit-overflow-scrolling: touch;
}

.tdw-landing__cards::-webkit-scrollbar { display: none; }

.tdw-landing__card-item {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    flex: 0 0 auto;
    /* Card width controlled here. Peek behavior comes from container width
     * minus N cards. We use a flexible width that scales:
     *   - Mobile: ~42vw (so 2.3 cards visible = peek of 3rd)
     *   - Tablet: 180px (3-4 visible + peek)
     *   - Desktop: 200px (5+ visible) */
    width: 42vw;
    max-width: 220px;
    min-width: 140px;
    scroll-snap-align: start;
}

@media (min-width: 600px) {
    .tdw-landing__card-item { width: 180px; }
}
@media (min-width: 1100px) {
    .tdw-landing__card-item { width: 200px; }
}

.tdw-landing__card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 18px 12px 16px;
    background: var(--tdw-card-bg);
    border-radius: var(--tdw-card-radius);
    box-shadow: var(--tdw-card-shadow);
    color: inherit;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    height: 100%;
}

.tdw-landing__card:hover,
.tdw-landing__card:focus-visible {
    transform: translateY(-2px);
    box-shadow: var(--tdw-card-shadow-hover);
    color: inherit;
}

.tdw-landing__card-image-wrap {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.tdw-landing__card-image {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s ease;
}

.tdw-landing__card:hover .tdw-landing__card-image {
    transform: scale(1.05);
}

.tdw-landing__card-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    color: #1a1a1a;
}

@media (min-width: 1100px) {
    .tdw-landing__card { padding: 22px 14px 18px; }
    .tdw-landing__card-image-wrap { width: 96px; height: 96px; }
    .tdw-landing__card-label { font-size: 15px; }
}

/* Smooth scroll for #anchor jumps */
html { scroll-behavior: smooth; }

/* ---- Product rows ------------------------------------------------------ */
.tdw-landing__row {
    padding: 24px 16px;
    margin-bottom: var(--tdw-row-gap);
    scroll-margin-top: calc(var(--flatsome--header--sticky-height, 80px) + 16px);
}

.tdw-landing__row-header {
    margin-bottom: 20px;
    max-width: 720px;
}

.tdw-landing__row-title {
    font-size: clamp(1.25rem, 2vw, 1.75rem);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 8px;
}

.tdw-landing__row-desc {
    font-size: 14.5px;
    line-height: 1.55;
    color: rgba(0, 0, 0, 0.65);
}

.tdw-landing__row-desc p:last-child { margin-bottom: 0; }

/* "Se alle"-link nederst */
.tdw-landing__row-more {
    margin: 16px 0 0;
    text-align: right;
}

.tdw-landing__row-more-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: var(--fs-color-primary, #11519B);
    text-decoration: none;
    transition: gap 0.2s ease;
}

.tdw-landing__row-more-link:hover {
    gap: 8px;
}

/* Constrain shortcode output to row container */
.tdw-landing__row-products {
    /* Flatsome's [ux_products] outputs at full width — let it breathe */
}

/* ---- Mobile fine-tuning ------------------------------------------------- */
@media (max-width: 599px) {
    .tdw-landing__header { padding: 24px 16px 16px; }
    .tdw-landing__row { padding: 16px 12px; margin-bottom: 32px; }
    .tdw-landing__row-more { text-align: center; }
}



/* =========================================================================
 * Custom Product Scroller (replaces Flatsome [ux_products] slider)
 *
 * Native horizontal scroll with CSS scroll-snap. No Flickity, no Flatsome
 * slider conflicts. Arrows positioned absolute outside the cards via parent
 * padding, JS handles prev/next click + dots-update.
 *
 * Each product still uses Flatsome's standard product-small markup, so AJAX
 * cart, hover effects, sale badges all work.
 * ========================================================================= */

.tdw-landing__scroller {
    position: relative;
    /* INGEN padding — produkterne fylder hele bredden. Pilene overlejer
     * kanterne af første/sidste kort som hvide cirkler (Netflix-stil). */
}

/* ---- Track (the horizontal scrolling list) ----------------------------- */
.tdw-landing__scroller-track {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.tdw-landing__scroller-track::-webkit-scrollbar { display: none; }

.tdw-landing__scroller-item {
    list-style: none !important;
    margin: 0 !important;
    padding: 0 !important;
    /* 2 cards visible per "page" på mobile, 3 på tablet, 4 på desktop */
    flex: 0 0 calc(50% - 6px);
    scroll-snap-align: start;
    min-width: 0;
}

@media (min-width: 600px) {
    .tdw-landing__scroller-item {
        flex: 0 0 calc(33.333% - 8px);
    }
}

@media (min-width: 1100px) {
    .tdw-landing__scroller-item {
        flex: 0 0 calc(25% - 9px);
    }
}

/* Reset Flatsome's .col styling inside our scroller — it expects to be in a
 * .row with grid-percentage widths, but we use flex-basis instead */
.tdw-landing__scroller-item .product-small.col {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    flex: 1 1 auto !important;
}

/* ---- Prev/Next arrows --------------------------------------------------- */
.tdw-landing__scroller-arrow {
    /* Position: fast placering der rammer midt på produktbilledet.
     * 110px svarer til midten af et 220px-kort på mobile, og lander pænt
     * på desktop også fordi billede-højden vokser sammen med kort-bredden
     * (aspect-ratio 1:1). Statisk = ingen "hop" mellem first paint og JS. */
    position: absolute;
    top: 110px;
    transform: translateY(-50%);
    z-index: 50;
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #1a1a1a;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background-color 0.18s ease, color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.tdw-landing__scroller-arrow--prev { left: 8px; }
.tdw-landing__scroller-arrow--next { right: 8px; }

@media (min-width: 600px) {
    .tdw-landing__scroller-arrow {
        top: 140px;    /* tablet: 3 cards, image ~240-280px tall */
    }
}

@media (min-width: 850px) {
    .tdw-landing__scroller-arrow {
        width: 46px;
        height: 46px;
    }
    .tdw-landing__scroller-arrow--prev { left: 12px; }
    .tdw-landing__scroller-arrow--next { right: 12px; }
}

@media (min-width: 1100px) {
    .tdw-landing__scroller-arrow {
        top: 150px;    /* desktop: 4 cards, image ~280-300px tall (container-capped) */
    }
}

/* Skjul scroller-controls helt hvis alle produkter passer i viewport
 * (sat via JS via .tdw-landing__scroller--no-overflow class) */
.tdw-landing__scroller--no-overflow .tdw-landing__scroller-arrow,
.tdw-landing__scroller--no-overflow .tdw-landing__scroller-dots {
    display: none !important;
}

.tdw-landing__scroller-arrow:hover,
.tdw-landing__scroller-arrow:focus-visible {
    background-color: var(--fs-color-primary, #11519B);
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    outline: none;
}

/* Disabled state (e.g. at start/end of scroll, no-wrap) */
.tdw-landing__scroller-arrow[disabled] {
    opacity: 0.35;
    cursor: default;
}
.tdw-landing__scroller-arrow[disabled]:hover {
    background-color: #fff;
    color: #1a1a1a;
}

/* ---- Pagination dots ----------------------------------------------------
 * Bemærk: Flatsome har button-styling (min-height/padding) der ellers ville
 * stretche dotsene. Vi nulstiller alt med !important + flex-shrink:0 så de
 * holder den rette 8x8 cirkel-form. */
.tdw-landing__scroller-dots {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    align-items: center;             /* uden denne stretches dotsene vertikalt */
    padding: 16px 0 0;
}

.tdw-landing__scroller-dots:empty {
    display: none;
}

.tdw-landing__scroller-dot {
    appearance: none !important;
    -webkit-appearance: none !important;
    box-sizing: content-box !important;
    display: block !important;
    width: 12px !important;
    height: 12px !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: 12px !important;
    max-height: 12px !important;
    padding: 0 !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 50% !important;
    background: rgba(0, 0, 0, 0.25) !important;
    line-height: 0 !important;
    font-size: 0 !important;
    flex: 0 0 12px !important;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.tdw-landing__scroller-dot:hover,
.tdw-landing__scroller-dot:focus-visible {
    background: rgba(0, 0, 0, 0.5) !important;
    outline: none;
}

.tdw-landing__scroller-dot.is-active {
    background: #000 !important;
}

.tdw-landing__empty {
    text-align: center;
    color: rgba(0, 0, 0, 0.5);
    padding: 24px;
}

/* Cards-wrapper fix: even though we're now in container, mobile peek still
 * needs visible overflow. Override -16px margin technique to break out of container
 * padding so cards align with container edges but DO scroll past them. */
.tdw-landing__cards-wrapper {
    margin-left: -16px;
    margin-right: -16px;
}

@media (min-width: 850px) {
    .tdw-landing__cards-wrapper {
        margin-left: 0;
        margin-right: 0;
    }
    /* Disable mask gradient on desktop since we usually see all cards anyway */
    .tdw-landing__cards-wrapper {
        -webkit-mask-image: none;
        mask-image: none;
    }
}

/* =========================================================================
 * Sticky compact cards (mobile only)
 *
 * Pille-bar der sticker lige under Flatsome's nav når brugeren har scrollet
 * forbi de store cards. CSS-only show/hide via position:sticky — JS bruges
 * kun til at sætte --tdw-header-h og til scroll-spy active state.
 *
 * On desktop: hidden (de store cards er stadig i viewporten ofte nok).
 * ========================================================================= */

.tdw-landing__sticky-cards {
    display: none;
}

@media (max-width: 849px) {
    .tdw-landing__sticky-cards {
        display: block;
        position: sticky;
        top: var(--tdw-header-h, 64px);
        z-index: 9999;
        margin: 0 -16px 24px;                 /* break out af container padding */
        background: #fff;
        box-shadow: 0 1px 0 rgba(0, 0, 0, 0.06), 0 2px 10px rgba(0, 0, 0, 0.04);
        /* Subtle gradient masks i siderne så pillerne fader ud */
        -webkit-mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
        mask-image: linear-gradient(to right, transparent 0, #000 12px, #000 calc(100% - 12px), transparent 100%);
    }

    .tdw-landing__sticky-cards-list {
        list-style: none !important;
        margin: 0 !important;
        padding: 10px 16px !important;
        display: flex;
        gap: 8px;
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
    .tdw-landing__sticky-cards-list::-webkit-scrollbar { display: none; }

    .tdw-landing__sticky-card-item {
        list-style: none !important;
        margin: 0 !important;
        padding: 0 !important;
        flex: 0 0 auto;
    }

    .tdw-landing__sticky-card {
        display: block;
        padding: 8px 14px;
        font-size: 13px;
        font-weight: 600;
        line-height: 1.2;
        color: rgba(0, 0, 0, 0.7);
        background: #f1f3f5;
        border-radius: 999px;
        text-decoration: none;
        white-space: nowrap;
        transition: background-color 0.18s ease, color 0.18s ease;
    }

    .tdw-landing__sticky-card:hover,
    .tdw-landing__sticky-card:focus-visible {
        background: #e4e7ea;
        color: rgba(0, 0, 0, 0.9);
    }

    .tdw-landing__sticky-card.is-active {
        background: var(--fs-color-primary, #11519B);
        color: #fff;
    }
}

/* Også opdater scroll-margin-top på rows så native anchor-jumps respekterer
 * sticky bar højden (i tilfælde af no-JS / hash-navigation). */
@media (max-width: 849px) {
    .tdw-landing__row {
        scroll-margin-top: calc(var(--tdw-header-h, 64px) + 56px + 16px);
    }
}

/* =========================================================================
 * Grouped landing pages (hovedkategori-niveau)
 *
 * Multiple sections per page, each with its own heading + cards-row +
 * product-rows. Used on /indvendig-bilpleje/, /eksterioer/, etc.
 * ========================================================================= */

.tdw-landing--grouped .tdw-landing__section {
    margin-bottom: 48px;
    padding-top: 16px;
    scroll-margin-top: calc(var(--tdw-header-h, 64px) + 16px);
}

.tdw-landing__section-header {
    padding: 0 16px;
    margin: 0 0 20px;
}

.tdw-landing__section-title {
    font-size: clamp(1rem, 1.4vw, 1.25rem);
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    margin: 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--fs-color-primary, #11519B);
    display: inline-block;
    color: rgba(0, 0, 0, 0.75);
}

.tdw-landing__section-title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.18s ease;
}

.tdw-landing__section-title a:hover {
    color: var(--fs-color-primary, #11519B);
}

/* In grouped mode, row title is h3 (not h1/h2) — slightly smaller */
.tdw-landing--grouped .tdw-landing__row-title {
    font-size: clamp(1.1rem, 1.75vw, 1.5rem);
}

/* Reduce top-level header spacing in grouped mode (sections supply their own) */
.tdw-landing--grouped .tdw-landing__header {
    padding-bottom: 16px;
}

/* ---- Row title wrap (titel + "Gå til" link side om side) -------------- */
.tdw-landing__row-title-wrap {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.tdw-landing__row-title-wrap .tdw-landing__row-title {
    margin: 0;
}
.tdw-landing__row-title-wrap .tdw-landing__row-more-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 14px;
    font-weight: 600;
    color: #007cba;
    text-decoration: none;
    white-space: nowrap;
    flex-shrink: 0;
}
.tdw-landing__row-title-wrap .tdw-landing__row-more-link:hover {
    color: #005a87;
    text-decoration: underline;
}
@media (max-width: 600px) {
    .tdw-landing__row-title-wrap .tdw-landing__row-more-link {
        font-size: 13px;
    }
}

/* ---- Mobile: sænk arrows z-index så sticky cards vinder ------------- */
@media (max-width: 849px) {
    .tdw-landing__scroller-arrow {
        z-index: 1;
    }
}

/* ---- Grid mode (kategorier uden Menu Builder children) -------------- */
.tdw-landing--grid .tdw-landing__header {
    margin-bottom: 24px;
}
.tdw-landing--grid .tdw-landing__toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 28px;
    padding: 14px 16px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    flex-wrap: wrap;
}
.tdw-landing--grid .tdw-landing__count {
    margin: 0;
    color: #666;
    font-size: 14px;
    font-weight: 500;
}
.tdw-landing--grid .tdw-landing__sort-form {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
}
.tdw-landing--grid .tdw-landing__sort-label {
    font-size: 14px;
    color: #555;
    margin: 0;
    font-weight: 500;
    white-space: nowrap;
}
.tdw-landing--grid .tdw-landing__sort-select {
    width: auto;
    max-width: 220px;
    padding: 7px 32px 7px 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: #fff url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>") no-repeat right 10px center;
    font-size: 14px;
    line-height: 1.4;
    color: #2c2c2c;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    height: auto;
    box-shadow: none;
}
.tdw-landing--grid .tdw-landing__sort-select:hover {
    border-color: #007cba;
}
.tdw-landing--grid .tdw-landing__sort-select:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.15);
}

/* Grid layout: 4 kolonner desktop, responsivt på mindre skærme.
 * Override Flatsome's .products row-styling så vi får clean grid. */
.tdw-landing--grid .tdw-landing__grid.products {
    display: grid !important;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 24px 16px;
    list-style: none;
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
}
.tdw-landing--grid .tdw-landing__grid.products::before,
.tdw-landing--grid .tdw-landing__grid.products::after {
    display: none !important;
}
.tdw-landing--grid .tdw-landing__grid.products > .product {
    width: auto !important;
    max-width: none !important;
    float: none !important;
    margin: 0 !important;
    padding: 0 !important;
    clear: none !important;
}
@media (max-width: 1100px) {
    .tdw-landing--grid .tdw-landing__grid.products {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
@media (max-width: 849px) {
    .tdw-landing--grid .tdw-landing__grid.products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 20px 12px;
    }
}
@media (max-width: 480px) {
    .tdw-landing--grid .tdw-landing__grid.products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 16px 10px;
    }
}

.tdw-landing--grid .tdw-landing__pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 40px 0 16px;
    flex-wrap: wrap;
}
.tdw-landing--grid .tdw-landing__pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 38px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    color: #2c2c2c;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.tdw-landing--grid .tdw-landing__pagination .page-numbers:hover {
    background: #f5f8fb;
    border-color: #007cba;
    color: #007cba;
}
.tdw-landing--grid .tdw-landing__pagination .page-numbers.current {
    background: #007cba;
    border-color: #007cba;
    color: #fff;
    font-weight: 600;
}
.tdw-landing--grid .tdw-landing__pagination .page-numbers.dots {
    border: 0;
    background: transparent;
    cursor: default;
}
.tdw-landing--grid .tdw-landing__empty {
    text-align: center;
    padding: 60px 20px;
    color: #888;
    font-size: 16px;
}
@media (max-width: 600px) {
    .tdw-landing--grid .tdw-landing__toolbar {
        gap: 12px;
        padding: 12px 14px;
    }
    .tdw-landing--grid .tdw-landing__sort-form {
        flex: 1 1 auto;
        justify-content: flex-end;
    }
    .tdw-landing--grid .tdw-landing__sort-select {
        font-size: 13px;
        flex: 1 1 auto;
        max-width: none;
    }
}
