/**
 * DealerHub Vehicles Pro - Featured Block Styles
 *
 * The [dealerhub_featured] block: one large vehicle plus a set of smaller ones.
 * Mobile first - every layout starts as a single column with the small vehicles
 * in a 2x2 grid, and only splits into columns once there is room for it.
 *
 * Every colour, radius, shadow and image ratio here comes from the same custom
 * properties the cards use, so the block follows the Styling page and the
 * dark/modern/classic theme classes without any settings of its own.
 */

/* ========================================
   BLOCK SHELL
   ======================================== */

.dh-featured {
    display: block;
    width: 100%;
}

.dh-featured-heading {
    margin: 0 0 var(--dh-spacing-lg);
    color: var(--dh-heading-color);
    font-size: var(--dh-font-size-2xl);
    line-height: var(--dh-line-height-tight);
}

.dh-featured-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--dh-grid-gap);
    align-items: stretch;
}

/* With a single vehicle in stock there are no tiles, so the hero takes the
   whole width instead of leaving an empty column beside it. */
.dh-featured-layout > :only-child {
    grid-column: 1 / -1;
}

.dh-featured-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--dh-grid-gap);
    align-content: start;
}

.dh-featured-footer {
    margin-top: var(--dh-spacing-lg);
    text-align: center;
}

/* ========================================
   HERO
   ======================================== */

.dh-featured-hero {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--dh-card-bg);
    border: 1px solid var(--dh-card-border);
    border-radius: var(--dh-card-radius);
    box-shadow: var(--dh-card-shadow);
    transition: box-shadow var(--dh-transition-base), transform var(--dh-transition-base);
}

.dh-featured-hero:hover {
    box-shadow: var(--dh-card-shadow-hover);
    transform: translateY(-4px);
}

.dh-featured-hero-media {
    position: relative;
    display: block;
    width: 100%;
    padding-top: 56.25%; /* Fallback for aspect-ratio (16:9) */
    aspect-ratio: var(--dh-image-aspect-ratio, 16 / 9);
    overflow: hidden;
    background-color: var(--dh-bg-tertiary);
}

@supports (aspect-ratio: 16 / 9) {
    .dh-featured-hero-media {
        padding-top: 0;
    }
}

.dh-featured-hero-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    /* Driven by the "Vertical Image Position" control on the Styling page. */
    object-position: var(--dh-image-position-x, center) var(--dh-image-position-y, 50%);
    transition: transform var(--dh-transition-slow);
}

.dh-featured-hero:hover .dh-featured-hero-media img {
    transform: scale(1.04);
}

.dh-featured-hero-media .dh-vehicle-card-image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: var(--dh-font-size-4xl);
}

.dh-featured-hero-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--dh-spacing-sm);
    padding: var(--dh-spacing-lg);
}

.dh-featured-hero-title {
    margin: 0;
    color: var(--dh-heading-color);
    font-size: var(--dh-font-size-xl);
    line-height: var(--dh-line-height-tight);
}

.dh-featured-hero-title a {
    color: inherit;
}

.dh-featured-year {
    color: var(--dh-text-light);
    font-weight: 600;
}

.dh-featured-hero-price {
    margin: 0;
    color: var(--dh-primary-color);
    font-size: var(--dh-font-size-2xl);
    font-weight: 700;
    line-height: var(--dh-line-height-tight);
}

.dh-featured-specs {
    display: flex;
    flex-wrap: wrap;
    gap: var(--dh-spacing-sm);
    margin: 0;
    padding: 0;
    list-style: none;
}

.dh-featured-spec {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background-color: var(--dh-attr-bg);
    border: 1px solid var(--dh-attr-border);
    border-radius: var(--dh-attr-radius);
    color: var(--dh-attr-value-color);
    font-size: var(--dh-font-size-sm);
    white-space: nowrap;
}

/* margin-top:auto keeps the buttons on the bottom edge when the hero is
   stretched to match the height of the tiles beside it. */
.dh-featured-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--dh-spacing-sm);
    margin-top: auto;
    padding-top: var(--dh-spacing-sm);
}

/* ========================================
   TILES
   ======================================== */

.dh-featured-tile {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--dh-card-bg);
    border: 1px solid var(--dh-card-border);
    border-radius: var(--dh-card-radius);
    box-shadow: var(--dh-card-shadow);
    color: var(--dh-text-primary);
    transition: box-shadow var(--dh-transition-base), transform var(--dh-transition-base);
}

.dh-featured-tile:hover,
.dh-featured-tile:focus-visible {
    box-shadow: var(--dh-card-shadow-hover);
    transform: translateY(-4px);
    color: var(--dh-text-primary);
}

.dh-featured-tile-media {
    position: relative;
    display: block;
    width: 100%;
    padding-top: 75%; /* Fallback for aspect-ratio (4:3) */
    aspect-ratio: var(--dh-image-aspect-ratio, 4 / 3);
    overflow: hidden;
    background-color: var(--dh-bg-tertiary);
}

@supports (aspect-ratio: 4 / 3) {
    .dh-featured-tile-media {
        padding-top: 0;
    }
}

.dh-featured-tile-media img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: var(--dh-image-position-x, center) var(--dh-image-position-y, 50%);
}

.dh-featured-tile-media .dh-vehicle-card-image-placeholder {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: var(--dh-font-size-2xl);
}

.dh-featured-tile-body {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: var(--dh-spacing-xs);
    padding: var(--dh-spacing-md);
}

.dh-featured-tile-title {
    display: block;
    color: var(--dh-heading-color);
    font-size: var(--dh-font-size-sm);
    font-weight: 600;
    line-height: var(--dh-line-height-tight);
}

.dh-featured-tile-price {
    display: block;
    margin-top: auto;
    color: var(--dh-primary-color);
    font-size: var(--dh-font-size-base);
    font-weight: 700;
}

/* ========================================
   LAYOUTS - only once there is room to split
   ======================================== */

@media (min-width: 900px) {
    /* Spotlight: hero on the left, 2x2 of tiles on the right. */
    .dh-featured--spotlight .dh-featured-layout {
        grid-template-columns: 1.4fr 1fr;
    }

    /* Showcase: hero on the left, tiles stacked as rows on the right. */
    .dh-featured--showcase .dh-featured-layout {
        grid-template-columns: 1.4fr 1fr;
    }

    .dh-featured--showcase .dh-featured-tiles {
        grid-template-columns: 1fr;
    }

    .dh-featured--showcase .dh-featured-tile {
        flex-direction: row;
        align-items: stretch;
    }

    .dh-featured--showcase .dh-featured-tile-media {
        flex: 0 0 40%;
        width: 40%;
        padding-top: 0;
        aspect-ratio: auto;
    }

    .dh-featured--showcase .dh-featured-tile-body {
        justify-content: center;
    }

    .dh-featured--showcase .dh-featured-tile-price {
        margin-top: 0;
    }

    /* Banner: hero across the top, tiles in a row beneath it. */
    .dh-featured--banner .dh-featured-tiles {
        grid-template-columns: repeat(4, 1fr);
    }

    .dh-featured--banner .dh-featured-hero {
        flex-direction: row;
    }

    .dh-featured--banner .dh-featured-hero-media {
        flex: 0 0 55%;
        width: 55%;
        padding-top: 0;
        aspect-ratio: auto;
        min-height: 320px;
    }

    .dh-featured--banner .dh-featured-hero-body {
        justify-content: center;
    }

    /* The banner hero is a row, so its text block is centred against the image
       rather than stretched. Pinning the buttons to the bottom edge here would
       just open a gap under the specs. */
    .dh-featured--banner .dh-featured-hero-actions {
        margin-top: var(--dh-spacing-md);
    }

    /* The hero stretches to match the tile column, so let the image take up
       whatever height the text does not. */
    .dh-featured--spotlight .dh-featured-hero-media,
    .dh-featured--showcase .dh-featured-hero-media {
        flex: 1 1 auto;
        padding-top: 0;
        aspect-ratio: auto;
        min-height: 280px;
    }

    .dh-featured-hero-title {
        font-size: var(--dh-font-size-2xl);
    }

    .dh-featured-hero-price {
        font-size: var(--dh-font-size-3xl);
    }
}

@media (prefers-reduced-motion: reduce) {
    .dh-featured-hero,
    .dh-featured-tile,
    .dh-featured-hero-media img {
        transition: none;
    }

    .dh-featured-hero:hover,
    .dh-featured-tile:hover,
    .dh-featured-tile:focus-visible {
        transform: none;
    }

    .dh-featured-hero:hover .dh-featured-hero-media img {
        transform: none;
    }
}
