/*
    Card / List views for the opportunity listing pages (CR-01,
    Documentation/G2_FINAL_ENHANCEMENTS_CHANGE_LOG_2026-10-15.md). Pairs with
    wwwroot/js/job-seeker/opportunity-view.js. Load after the page's own stylesheets.

    List view = today's /Jobs full-width boxes (Q5); Training and Volunteering adopt the same box.
    Card view = the Training card: 1 per row on phones, 2 beside the filter column, 3 on very
    wide screens. Every result keeps the same order: badges, title, organization, place, when,
    short description, actions.

    Accessibility: 44px touch targets, visible focus, 3:1 control borders (WCAG 1.4.11), a
    word on every button (never icon-only), Windows high-contrast support.
*/

/* ---------- Results-count row: count on the left, switch on the right ---------- */
.rw-results-bar,
.rw-opportunity-results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 12px;
}

.rw-results-bar > h2,
.rw-opportunity-results-header > .rw-volunteering__status {
    min-height: 0;
    margin: 0;
}

.rw-results-bar__slot,
.rw-opportunity-results-header [data-rw-view-switch] {
    margin-left: auto;
}

[data-rw-view-switch][hidden] {
    display: none !important;
}

/* ---------- The switch ---------- */
.rw-view-switch {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rw-view-switch__label {
    color: var(--rw-ink, #172033);
    font-size: .9375rem;
    font-weight: 600;
    white-space: nowrap;
}

.rw-view-switch__buttons {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid #6b7a90;
    border-radius: 10px;
    background: #fff;
}

.rw-view-switch__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
    padding: 0 16px;
    border: 0;
    border-radius: 7px;
    background: transparent;
    color: var(--rw-ink, #172033);
    font-size: .9375rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.rw-view-switch__btn:hover {
    background: #eaf1ff;
}

.rw-view-switch__btn[aria-pressed="true"] {
    background: var(--rw-primary, #0c61e7);
    color: #fff;
}

.rw-view-switch__btn:focus-visible {
    outline: 3px solid #0b2a63;
    outline-offset: 2px;
}

@media (forced-colors: active) {
    .rw-view-switch__buttons { border-color: ButtonText; }
    .rw-view-switch__btn { border: 1px solid transparent; }
    .rw-view-switch__btn[aria-pressed="true"] {
        background: Highlight;
        color: HighlightText;
        border-color: Highlight;
    }
}

/* Phones: the switch takes its own line under the count, kept to the left and narrow enough to
   stay clear of the floating help-chat button in the bottom-right corner. */
@media (max-width: 575.98px) {
    .rw-results-bar__slot,
    .rw-opportunity-results-header [data-rw-view-switch] {
        width: 100%;
        margin-left: 0;
    }

    .rw-view-switch { justify-content: flex-start; }
    .rw-view-switch__buttons { flex: 1; max-width: 210px; }
    .rw-view-switch__btn { flex: 1; }
}

/* The volunteering pages stack this header on narrow screens; keep the switch aligned left there. */
@media (max-width: 767.98px) {
    .rw-volunteering .rw-opportunity-results-header [data-rw-view-switch] { margin-left: 0; }
}

/* ======================================================================
   Training & Volunteering results (rendered by volunteering.js renderCard)
   ====================================================================== */
#volunteering-results.rw-opp-results {
    display: grid;
    gap: 12px;
}

#volunteering-results.rw-opp-results[data-view="list"] {
    grid-template-columns: minmax(0, 1fr);
}

#volunteering-results.rw-opp-results[data-view="card"] {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

/* The same box in both views, matching the /Jobs result. */
#volunteering-results.rw-opp-results .rw-volunteering-card {
    min-height: 0;
    margin: 0;
    padding: 20px;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(22, 42, 76, .06);
}

#volunteering-results.rw-opp-results .rw-volunteering-card h2 {
    margin: 0 0 6px;
    color: #0759cf;
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
}

#volunteering-results.rw-opp-results .rw-volunteering-card p {
    color: #40516c;
    line-height: 1.55;
}

/* Card view: actions always sit at the bottom so a row of cards lines up. */
#volunteering-results.rw-opp-results[data-view="card"] .rw-volunteering-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

#volunteering-results.rw-opp-results[data-view="card"] .rw-volunteering-card__actions {
    margin-top: auto;
    padding-top: 14px;
}

#volunteering-results.rw-opp-results[data-view="card"] .rw-volunteering-card__actions > .rw-btn {
    flex: 1;
    min-height: 44px;
}

/* List view on tablet and up: actions on the right of the title, like /Jobs. */
@media (min-width: 768px) {
    #volunteering-results.rw-opp-results[data-view="list"] .rw-volunteering-card {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        column-gap: 24px;
        align-items: start;
    }

    #volunteering-results.rw-opp-results[data-view="list"] .rw-volunteering-card > * {
        grid-column: 1;
    }

    #volunteering-results.rw-opp-results[data-view="list"] .rw-volunteering-card > .rw-volunteering-card__actions {
        grid-column: 2;
        grid-row: 1 / span 2;
        margin-top: 0;
        padding-top: 0;
    }

    #volunteering-results.rw-opp-results[data-view="list"] .rw-volunteering-card__actions > .rw-btn {
        min-height: 44px;
    }
}

/* The empty-state and error boxes always span the full width. */
#volunteering-results.rw-opp-results > .rw-volunteering__empty,
#volunteering-results.rw-opp-results > .rw-btn {
    grid-column: 1 / -1;
}

/* ======================================================================
   Jobs results (/Jobs, Views/Shared/Jobs/_listelastic.cshtml)
   List view is left exactly as today; only Card view restyles the box.
   ====================================================================== */
.rw-job-results[data-view="card"] {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

/* Bootstrap utility classes on the <li> use !important, so these must too. */
.rw-job-results[data-view="card"] > li.job-listing {
    height: 100%;
    margin: 0 !important;
    padding: 20px !important;
    border: 1px solid #dbe4f0 !important;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(22, 42, 76, .06) !important;
}

.rw-job-results[data-view="card"] > li.job-listing > [class*="col-"] {
    display: flex;
    flex-direction: column;
    padding: 0;
}

.rw-job-results[data-view="card"] .jobs-item {
    display: flex;
    flex: 1;
    flex-direction: column;
}

/* Unwrap the first row so the title and the action bar can be placed independently. */
.rw-job-results[data-view="card"] .jobs-item > .row:first-child {
    display: contents;
}

.rw-job-results[data-view="card"] .jobs-item .row {
    margin-left: 0;
    margin-right: 0;
}

/* Every column fills the card's width; nothing is right-aligned inside a narrow card. */
.rw-job-results[data-view="card"] .jobs-item [class*="col-"] {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
    padding-left: 0;
    padding-right: 0;
    float: none !important;
    text-align: left !important;
}

.rw-job-results[data-view="card"] .jobs-item h3 {
    margin-bottom: 8px;
    font-size: 1.0625rem;
    line-height: 1.3;
}

.rw-job-results[data-view="card"] .rw-job-card__title { order: 1; }
.rw-job-results[data-view="card"] .jobs-item > .row:nth-child(2) { order: 2; }
.rw-job-results[data-view="card"] .jobs-item > .divDescription { order: 3; }

/* Action bar: last, pinned to the bottom of the card. */
.rw-job-results[data-view="card"] .rw-job-card__actions {
    order: 4;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid #e6ecf4;
}

.rw-job-results[data-view="card"] .rw-job-card__actions > .row {
    justify-content: flex-start !important;
    align-items: center;
    gap: 8px;
}

.rw-job-results[data-view="card"] .rw-job-card__actions > .row > * {
    width: auto;
    margin: 0 !important;
}

/* The big practice button gets its own full-width line in a card. */
.rw-job-results[data-view="card"] .rw-job-card__actions a.btn-blue {
    flex: 1 1 100%;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

/* "Posted on" moves from the action bar to the facts block in Card view. */
.rw-job-results .rw-job-posted--card { display: none; }
.rw-job-results[data-view="card"] .rw-job-posted--card { display: block; }
.rw-job-results[data-view="card"] .rw-job-posted--inline { display: none !important; }

/* Keep cards an even height: the description is cut to four lines (the full text is on the job page). */
.rw-job-results[data-view="card"] .divDescription p.break-word {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Shared column counts for Card view ---------- */
@media (min-width: 1600px) {
    #volunteering-results.rw-opp-results[data-view="card"],
    .rw-job-results[data-view="card"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 767.98px) {
    #volunteering-results.rw-opp-results[data-view="card"],
    .rw-job-results[data-view="card"] {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (prefers-reduced-motion: no-preference) {
    .rw-view-switch__btn { transition: background-color .15s ease, color .15s ease; }
}
