/*
 * Hailey Job Ads
 * Every rule is scoped to .hailey-job-ads so the theme (Salient) is not affected,
 * and the theme's generic h3/p/a/img rules are reset inside the cards.
 */

.hailey-job-ads {
    --hailey-border: #e3e3e3;
    --hailey-text: #222;
    --hailey-muted: #666;
    --hailey-accent: #111;
    --hailey-accent-text: #fff;
    --hailey-alert: #b3261e;
    --hailey-lines: 4;
    margin: 0 0 40px;
    color: var(--hailey-text);
    overflow-wrap: anywhere; /* long words/URLs wrap instead of pushing the page sideways */
}

/* ---- Grid ------------------------------------------------------------- */

/* Default ("auto"): as many 300px+ columns as fit; never wider than the container. */
.hailey-job-ads__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
    gap: 24px;
}

/* columns="N": mobile 1, tablet up to 2, desktop N. */
.hailey-job-ads--cols-1 .hailey-job-ads__grid,
.hailey-job-ads--cols-2 .hailey-job-ads__grid,
.hailey-job-ads--cols-3 .hailey-job-ads__grid,
.hailey-job-ads--cols-4 .hailey-job-ads__grid {
    grid-template-columns: minmax(0, 1fr);
}

@media (min-width: 768px) {
    .hailey-job-ads--cols-2 .hailey-job-ads__grid,
    .hailey-job-ads--cols-3 .hailey-job-ads__grid,
    .hailey-job-ads--cols-4 .hailey-job-ads__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .hailey-job-ads--cols-3 .hailey-job-ads__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    .hailey-job-ads--cols-4 .hailey-job-ads__grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Phones: always one column, whatever the setting. */
@media (max-width: 480px) {
    .hailey-job-ads .hailey-job-ads__grid {
        grid-template-columns: minmax(0, 1fr);
    }
}

/* ---- Card ------------------------------------------------------------- */

.hailey-job-ads__card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: #fff;
    border: 1px solid var(--hailey-border);
    border-radius: 10px;
}

/* Hailey cover images are 16:9 (1575x886), so the box matches them: nothing is cropped. */
.hailey-job-ads__media {
    position: relative;
    aspect-ratio: 16 / 9;
    background: #ddd; /* only visible while the image loads, or if it fails */
}

/*
 * Theme-proof images. Themes style every <img> (Salient: ".row .col img { margin-bottom: 15px;
 * height: auto }" and ".row .col img:not([srcset]) { width: auto }"), which left a grey strip under
 * the cover. These selectors are more specific than such theme rules, so ours always win.
 */
.hailey-job-ads .hailey-job-ads__card img.hailey-job-ads__cover,
.hailey-job-ads .hailey-job-ads__card img.hailey-job-ads__logo {
    max-width: none;
    margin: 0;
    border: 0;
    vertical-align: top;
}

/* The cover fills the 16:9 box exactly (taken out of the flow, so no gaps are possible). */
.hailey-job-ads .hailey-job-ads__card .hailey-job-ads__media img.hailey-job-ads__cover {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hailey-job-ads .hailey-job-ads__card .hailey-job-ads__media img.hailey-job-ads__logo {
    position: absolute;
    left: 16px;
    bottom: -24px;
    width: 56px;
    height: 56px;
    margin: 0;
    padding: 4px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

/* Logo without a cover image: shown at the top of the text. */
.hailey-job-ads .hailey-job-ads__card .hailey-job-ads__body img.hailey-job-ads__logo {
    position: static;
    display: block;
    width: 56px;
    height: 56px;
    margin: 0 0 12px;
    padding: 4px;
    object-fit: contain;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.hailey-job-ads__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    padding: 16px;
}

/* Room for the logo that overlaps the cover's bottom edge. */
.hailey-job-ads__card--logo-overlap .hailey-job-ads__body {
    padding-top: 36px;
}

.hailey-job-ads .hailey-job-ads__title {
    margin: 0 0 4px;
    padding: 0;
    font-size: 20px;
    line-height: 1.3;
}

.hailey-job-ads .hailey-job-ads__subtitle,
.hailey-job-ads .hailey-job-ads__meta,
.hailey-job-ads .hailey-job-ads__closes {
    margin: 0 0 8px;
    padding: 0;
    font-size: 13px;
    line-height: 1.4;
    color: var(--hailey-muted);
}

.hailey-job-ads .hailey-job-ads__closes {
    color: var(--hailey-alert);
}

.hailey-job-ads__description {
    margin: 4px 0 16px;
    font-size: 14px;
    line-height: 1.55;
}

/* lines="N": cut the description after N lines with "…". The full text stays in the HTML. */
.hailey-job-ads--clamp .hailey-job-ads__description {
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: var(--hailey-lines);
    line-clamp: var(--hailey-lines);
    overflow: hidden;
}

/* Button sticks to the bottom so buttons line up across cards. */
.hailey-job-ads .hailey-job-ads__button {
    align-self: flex-start;
    display: inline-block;
    margin-top: auto;
    padding: 10px 18px;
    font-size: 14px;
    line-height: 1.2;
    color: var(--hailey-accent-text);
    text-decoration: none;
    background: var(--hailey-accent);
    border-radius: 6px;
}

.hailey-job-ads .hailey-job-ads__button:hover,
.hailey-job-ads .hailey-job-ads__button:focus {
    color: var(--hailey-accent-text);
    opacity: 0.85;
}

.hailey-job-ads .hailey-job-ads__empty {
    margin: 0;
    padding: 24px;
    color: var(--hailey-muted);
    background: #fff;
    border: 1px solid var(--hailey-border);
    border-radius: 10px;
}

.hailey-job-ads__debug {
    margin: 16px 0;
    padding: 12px;
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    background: #f4f4f4;
}
