.vehicle-page {
    width: 100%;
    line-height: 1.5;
}

.vehicle-hero {
    background-color: var(--navy);
    color: #ffffff;
}

.vehicle-hero-inner,
.vehicle-body {
    max-width: var(--page-width);
    margin: 0 auto;
    padding-inline: 32px;
}

.vehicle-hero-inner {
    padding-top: 24px;
    padding-bottom: 32px;
}

.vehicle-back {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    font-weight: 700;
    font-size: 15px;
    color: var(--navy-text);

    &:hover {
        color: #ffffff;
    }
}

/*
 * Desktop: the first photo large, up to four more beside it, arranged by how many there are. The list clips
 * the outer corners. Phones: one swipeable strip of every photo.
 */
.vehicle-photos {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
    gap: 10px;
    aspect-ratio: 3;
    overflow: hidden;
    border-radius: var(--radius);
    list-style: none;
    padding: 0;

    > li {
        position: relative;
        min-height: 0;

        &:first-child {
            grid-row: span 2;
        }

        &:nth-child(n + 6) {
            display: none;
        }
    }

    /* One photo: it takes the row */
    &:has(> li:only-child) {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr;
        aspect-ratio: 2;
    }

    /* Two: side by side */
    &:has(> li:nth-child(2):last-child) {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr;
        aspect-ratio: 8 / 3;
    }

    /* Three: the first large, two stacked beside it */
    &:has(> li:nth-child(3):last-child) {
        grid-template-columns: 2fr 1fr;
    }

    /* Four: the first large, two stacked, the last tall */
    &:has(> li:nth-child(4):last-child) > li:nth-child(4) {
        grid-column: 3;
        grid-row: 1 / span 2;
    }
}

.vehicle-photos-wrap {
    position: relative;
}

.vehicle-photo {
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;

    img {
        display: block;
        width: 100%;
        height: 100%;
        object-fit: cover;
        background-color: var(--navy-deep);
        background-size: cover;
        background-position: center;
        border-radius: 4px;
    }
}

.vehicle-all-photos {
    position: absolute;
    right: 14px;
    bottom: 14px;
    padding: 10px 16px;
    border: 0;
    border-radius: 8px;
    background: #ffffff;
    box-shadow: var(--shadow-card);
    color: var(--navy);
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
}

.vehicle-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 48px;
    align-items: start;
    padding-top: 32px;
}

.vehicle-make {
    font-size: 17px;
    color: var(--navy-text);
}

.vehicle-model {
    margin-bottom: 20px;
    font-weight: 800;
    font-size: 52px;
    line-height: 1.02;
    letter-spacing: -0.02em;
    color: #ffffff;
    text-wrap: balance;
}

.vehicle-main h2 {
    margin-top: 36px;
    font-weight: 800;
    font-size: 24px;
    color: var(--navy);
}

.vehicle-facts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px 24px;
    padding: 0 0 24px;
    border-bottom: 1px solid var(--rule);

    dt {
        font-size: 14px;
        color: var(--ink-soft);
    }

    dd {
        font-weight: 700;
        font-size: 18px;
        line-height: 1.3;
    }
}

.vehicle-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 28px;
    margin-top: 14px;
    padding: 0;
    list-style: none;

    li {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        font-weight: 500;
    }

    .icon {
        color: var(--red);
    }
}

.vehicle-specs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    column-gap: 40px;
    margin-top: 12px;

    > div {
        display: flex;
        justify-content: space-between;
        gap: 16px;
        padding: 12px 0;
        border-bottom: 1px solid var(--rule);
        font-size: 16px;
    }

    dt {
        color: var(--ink-soft);
    }

    dd {
        font-weight: 700;
        text-align: right;
    }
}

.vehicle-panel {
    position: sticky;
    top: 108px;
    padding: 28px;
    border-radius: var(--radius);
    background: #ffffff;
    box-shadow: var(--shadow-card-hover);
}

.vehicle-price {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 40px;
    line-height: 1;
    color: var(--red);

    small {
        margin-left: 6px;
        font-family: var(--font-body);
        font-weight: 700;
        font-size: 15px;
        letter-spacing: 0.02em;
        color: var(--ink-soft);
    }
}

.vehicle-included {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-weight: 500;

    .icon {
        color: var(--red);
    }
}

.vehicle-call {
    width: 100%;
    margin-top: 20px;
}

.vehicle-call-note {
    margin-top: 8px;
    font-size: 15px;
    color: var(--ink-soft);
}

.vehicle-staff {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--rule);
}

.vehicle-status {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-weight: 700;
    font-size: 14px;

    &.is-published {
        background: #e3f4e8;
        color: #1d6b36;
    }

    &.is-draft {
        background: #fbe7ea;
        color: var(--red);
    }
}

.vehicle-staff-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;

    .button {
        min-height: 44px;
        font-size: 15px;
    }
}

.vehicle-delete {
    display: inline-block;
    margin-top: 14px;
    font-weight: 700;
    font-size: 15px;
    color: var(--red);

    &:hover {
        text-decoration: underline;
    }
}

/* Only the gallery scrolls while it's open */
html:has(.vehicle-gallery[open]) {
    overflow: hidden;
}

.vehicle-gallery {
    overflow-y: auto;
    overscroll-behavior: contain;
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: var(--navy-deep);
    color: #ffffff;

    &::backdrop {
        background: rgba(13, 27, 47, 0.8);
    }

    &[open] {
        animation: gallery-in 200ms var(--ease-out);
    }
}

@keyframes gallery-in {
    from {
        opacity: 0;
    }
}

.vehicle-gallery-bar {
    position: sticky;
    top: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 20px;
    background: var(--navy-deep);
    border-bottom: 1px solid var(--navy-line);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 18px;
}

.vehicle-gallery-close {
    display: flex;
    padding: 10px;
    border: 0;
    background: none;
    color: #ffffff;
    cursor: pointer;

    .icon {
        width: 28px;
        height: 22px;
    }
}

.vehicle-gallery-photos {
    display: grid;
    gap: 12px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 20px;

    /* Space held at the photo's shape, with the blurred preview until it loads */
    img {
        display: block;
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
        object-fit: cover;
        background-color: var(--navy);
        background-size: cover;
        background-position: center;
        border-radius: 4px;
        scroll-margin-top: 80px;
    }
}

.more-from-lot {
    width: 100%;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 72px 32px 80px;
}

.more-from-lot-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 24px;

    h2 {
        font-weight: 800;
        font-size: 40px;
        line-height: 1.1;
        letter-spacing: -0.015em;
        color: var(--navy);
    }

    a {
        font-weight: 700;
        color: var(--red);
    }
}

@media (width < 900px) {
    .vehicle-hero-inner {
        padding: 16px 0 24px;
    }

    .vehicle-back,
    .vehicle-make,
    .vehicle-model {
        margin-inline: 16px;
    }

    .vehicle-model {
        margin-bottom: 20px;
    }

    .vehicle-photos,
    .vehicle-photos:has(> li) {
        display: flex;
        gap: 8px;
        aspect-ratio: auto;
        overflow-y: hidden;
        border-radius: 0;
        padding: 0 16px;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding-inline: 16px;
        scrollbar-width: none;

        > li,
        > li:nth-child(n + 6) {
            display: block;
            flex: 0 0 calc(100% - 24px);
            scroll-snap-align: start;
        }

        > li:only-child {
            flex-basis: 100%;
        }

        img,
        > li:first-child img,
        > li:nth-child(n) img {
            aspect-ratio: 4 / 3;
            border-radius: var(--radius);
        }
    }

    .vehicle-all-photos {
        right: 28px;
    }

    .vehicle-body {
        grid-template-columns: 1fr;
        gap: 28px;
        padding: 24px 16px 0;
    }

    .vehicle-facts {
        padding-top: 0;
    }

    .vehicle-panel {
        position: static;
        order: -1;
    }

    .vehicle-model {
        font-size: 38px;
    }

    .vehicle-facts {
        grid-template-columns: 1fr 1fr;
    }

    .vehicle-specs {
        grid-template-columns: 1fr;
    }

    .more-from-lot {
        padding: 48px 16px 56px;
    }

    .more-from-lot-head h2 {
        font-size: 30px;
    }
}
