/* SCD-463 — Site search page styles.
 *
 * Practical baseline: gets the page rendering recognizably close to the
 * Figma design (file 6jVr7YbefLWCQjcGuvD59L, node 1393:10502) without
 * obsessing over every pixel. The strict Figma 1:1 polish step (per the
 * project memory rule) runs at the end of the build order and adjusts
 * paddings/font sizes/colors using the exact spec block values.
 */

/* ---- Page shell --------------------------------------------------- */
.search-page { padding: 32px 0 64px; }
.search-page__container { max-width: 1280px; }

.search-page__header { margin-bottom: 16px; }
.search-page__heading {
    font-size: 32px;
    line-height: 1.25;
    font-weight: 600;
    color: #1F2533;
    margin: 0;
}
.search-page__heading strong { color: #465DA6; }

/* ---- Tabs --------------------------------------------------------- */
.search-tabs {
    display: flex;
    gap: 32px;
    border-bottom: 1px solid #E5E7EB;
    margin-bottom: 24px;
    padding: 0;
}
.search-tabs__tab {
    display: inline-block;
    padding: 12px 0;
    font-size: 16px;
    font-weight: 500;
    color: #6B7280;
    text-decoration: none;
    position: relative;
    cursor: pointer;
}
.search-tabs__tab:hover { color: #1F2533; }
.search-tabs__tab.is-active { color: #465DA6; }
.search-tabs__tab.is-active::after {
    content: "";
    position: absolute;
    left: 0; right: 0; bottom: -1px;
    height: 2px;
    background: currentColor;
}

/* ---- Two-column body --------------------------------------------- */
.search-page__body {
    /* Figma node 1393:10502: main column 864 + 32 gap + side rail 384,
       inside a 1440 frame with 80px gutters (= 1280 content). */
    display: grid;
    grid-template-columns: minmax(0, 1fr) 384px;
    gap: 32px;
    align-items: start;
}
.search-page__main { min-width: 0; transition: opacity 120ms ease-out; }
.search-page__main.is-loading { opacity: 0.5; pointer-events: none; }

@media (max-width: 992px) {
    .search-page__body { grid-template-columns: 1fr; }
}

/* ---- Main column cards (Article / Multimedia row) ---------------- */
.search-results { display: block; }
/* 32px between cards — Figma Category Post height 160, y-spacing 216 → gap 32. */
.search-results__list { display: flex; flex-direction: column; gap: 32px; }
.search-results__list--contributors { gap: 12px; }
.search-results__list--grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 24px;
}
@media (max-width: 720px) {
    .search-results__list--grid { grid-template-columns: 1fr; }
}

.search-card {
    /* Figma Category Post (frame 1220:18223): thumb 220×160, 16px gap,
       body 564 wide, total card height 160. */
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: 16px;
    align-items: start;
}
.search-card--course,
.search-card--event {
    display: block; /* vertical card for course/event grids */
}
.search-card__thumb {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    background: #F4F5FA;
    aspect-ratio: 3 / 2;
}
.search-card--course .search-card__thumb,
.search-card--event .search-card__thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    margin-bottom: 12px;
}
.search-card__thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.search-card__thumb-placeholder {
    display: block;
    width: 100%; height: 100%;
    background: linear-gradient(135deg, #E5E7EB, #F4F5FA);
}
/* Category badge overlay — Figma frame 1220:18226 (Badge component, instance
   "Sustainability"): light-teal bg #EAF8F6, teal text #269387, 4/12 padding,
   16-px radius, 14/20 Inter Medium. Same chip is reused on Articles and
   Multimedia cards; positioned at top-left of the thumbnail with 8-px inset. */
.search-card__thumb-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #EAF8F6;
    color: #269387;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
    white-space: nowrap;
}
/* Multimedia play-icon chip — Figma frame 1229:2647: 50×22 box, 8 px from
   bottom & right edges of the 220×160 thumbnail. We size the chip to the
   icon for now (duration text would slot in here once PostViewModel exposes
   video runtime). */
.search-card__thumb-play {
    position: absolute;
    bottom: 8px;
    right: 8px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.92);
}
.search-card__thumb-play img { display: block; }

/* Event card status pill — uses the badge colors per state. */
.search-card__status {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #EAF8F6;
    color: #269387;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
}
.search-card__status--upcoming { background: #EEF1FB; color: #465DA6; }
.search-card__status--ongoing { background: #E6F4EE; color: #168A52; }
.search-card__status--past { background: #F4F5FA; color: #6B7280; }

/* Course card category overlay (vertical card variant) — reuses the same
   palette as the article thumb badge for consistency. */
.search-card__category-overlay {
    position: absolute;
    top: 8px;
    left: 8px;
    background: #EAF8F6;
    color: #269387;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 500;
}
.search-card__body { min-width: 0; }
.search-card__title {
    /* Figma title block (frame 1220:18228): 2 lines × ~25 line-height → 20px. */
    font-size: 20px;
    font-weight: 600;
    line-height: 1.25;
    margin: 0 0 8px;
    color: #1F2533;
}
.search-card__title a {
    color: inherit;
    text-decoration: none;
}
.search-card__title a:hover { text-decoration: underline; }
.search-card__byline {
    /* Figma "Date & Read" row (frame 1220:18231): 14px text in a 24-high
       line, with a 14×14 user-edit icon 8px before the author name. */
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.45;
    color: #6B7280;
}
.search-card__byline-icon { width: 14px; height: 14px; flex: 0 0 auto; display: block; }
.search-card__author {
    color: #1F2533;
    font-weight: 600;
    text-decoration: none;
}
/* Dot separator — Figma uses a 4×4 ellipse between author and org. */
.search-card__sep {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #C9CBD1;
    margin: 0 4px;
    flex: 0 0 auto;
}
.search-card__tags { display: flex; gap: 6px; flex-wrap: wrap; padding: 0; margin: 0; list-style: none; }
.search-card__tag {
    background: #F4F5FA;
    color: #4B5563;
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
}
.search-card__facts {
    display: flex; flex-wrap: wrap; gap: 16px;
    margin: 8px 0 0; padding: 0; list-style: none;
    color: #6B7280; font-size: 13px;
}
.search-card__fact { display: inline-flex; align-items: center; gap: 6px; }
.search-card__fact-icon { display: block; }
.search-card__fact--free { color: #168A52; font-weight: 600; }

.search-card__event-when { font-size: 13px; color: #6B7280; margin: 0 0 6px; }
.search-card__excerpt { font-size: 14px; color: #4B5563; margin: 0 0 12px; }
.search-card__cta { display: inline-block; }

/* ---- Contributors list ------------------------------------------- */
.search-contributor {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    gap: 12px;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #F0F1F4;
}
.search-contributor__avatar {
    display: block;
    width: 48px; height: 48px;
    border-radius: 50%;
    overflow: hidden;
    background: #F4F5FA;
}
.search-contributor__avatar img { width: 100%; height: 100%; object-fit: cover; }
.search-contributor__avatar-placeholder {
    display: flex; align-items: center; justify-content: center;
    width: 100%; height: 100%;
    color: #6B7280; font-weight: 600;
}
.search-contributor__name {
    display: block;
    color: #1F2533;
    text-decoration: none;
    font-weight: 600;
}
.search-contributor__name:hover { color: #465DA6; }
.search-contributor__meta {
    margin: 2px 0 0;
    color: #6B7280;
    font-size: 13px;
}
.search-contributor__sep { margin: 0 6px; opacity: .5; }
.search-contributor__follow { white-space: nowrap; }

/* ---- Show More button -------------------------------------------- */
.search-show-more {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}
.search-show-more.is-hidden { display: none; }

/* ---- Empty state -------------------------------------------------- */
/* Figma "No results - Articles" frame 1316:19094:
 *   headline 28h, 8 gap, subline 24h  (total 60 with 16px top padding ⇒ 76)
 *   then 32 gap to "Suggested Articles" header (28h)
 *   then 32 gap to the first article card. */
.search-empty {
    padding: 16px 0 0;
    text-align: left;
    background: transparent;
}
.search-empty--articles { padding-top: 16px; }
.search-empty__headline {
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
    color: #1F2533;
    margin: 0 0 8px;
}
.search-empty__subline {
    margin: 0;
    font-size: 14px;
    line-height: 24px;
    color: #6B7280;
}

/* ---- Suggested articles fallback (Articles tab no-results) ------- */
.search-suggested { margin-top: 32px; }
.search-suggested__heading {
    font-size: 20px;
    line-height: 28px;
    font-weight: 600;
    color: #1F2533;
    margin: 0 0 32px;
}
.search-suggested__list {
    display: flex; flex-direction: column; gap: 32px;
}

/* ---- Side rail --------------------------------------------------- */
/* Figma frame 1220:18532 (384 wide). Blocks at 32-px y intervals;
 * block header at y=32 (24h, 14px text); first row at y=72 (88h);
 * subsequent rows at 16-px gap each. */
.search-rail { display: flex; flex-direction: column; gap: 32px; }
.search-rail__block { background: transparent; }

.search-rail__block-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 16px;
}
.search-rail__block-title {
    font-size: 14px;
    line-height: 24px;
    margin: 0;
    color: #1F2533;
}
/* Two-part Figma label: bold name + lighter "on '<q>'" suffix. */
.search-rail__block-title-main {
    font-weight: 600;
    color: #1F2533;
}
.search-rail__block-title-suffix {
    font-weight: 400;
    color: #6B7280;
}
.search-rail__block-link {
    font-size: 14px;
    line-height: 24px;
    color: #465DA6;
    text-decoration: none;
    font-weight: 500;
    flex: 0 0 auto;
}
.search-rail__block-link:hover { text-decoration: underline; }

.search-rail__list { padding: 0; margin: 0; list-style: none; display: flex; flex-direction: column; gap: 16px; }
.search-rail__row { padding: 0; border: 0; }
.search-rail__row-link {
    /* 48 leading + 16 gap + body — generic baseline; per-kind variants
       (e.g. multimedia's 32-px play icon) are layered as CSS overrides
       under [data-rail-block="multimedia"] when needed. */
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 16px;
    color: inherit;
    text-decoration: none;
}
.search-rail__row-thumb {
    display: block;
    width: 48px; height: 48px;
    object-fit: cover;
    border-radius: 6px;
    background: #F4F5FA;
}
.search-rail__row-thumb--placeholder { background: #F4F5FA; }
.search-rail__row-body { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.search-rail__row-title {
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 16px;
    line-height: 24px;
    font-weight: 500;
    color: #1F2533;
}
.search-rail__row-sub {
    display: block;
    color: #6B7280;
    font-size: 14px;
    line-height: 22px;
}
.search-rail__row-link:hover .search-rail__row-title { color: #465DA6; }

/* Multimedia rail — Figma uses a 40×40 circular brand-blue button with a
   white play triangle centred, in place of a content thumbnail. */
[data-rail-block="multimedia"] .search-rail__row-link {
    grid-template-columns: 40px 1fr;
}
[data-rail-block="multimedia"] .search-rail__row-thumb,
[data-rail-block="multimedia"] .search-rail__row-thumb--placeholder {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #465DA6;
    /* The play-solid SVG ships with a dark fill, so we mask it instead of
       referencing the file directly — keeps the icon crisp at any size. */
    background-image: none;
    position: relative;
    overflow: hidden;
}
[data-rail-block="multimedia"] .search-rail__row-thumb img {
    display: none; /* hide any source image; multimedia rail is icon-only. */
}
[data-rail-block="multimedia"] .search-rail__row-thumb::after {
    content: "";
    position: absolute;
    inset: 0;
    background: #fff;
    -webkit-mask: url('/images/search/icons/play-solid.svg') center / 14px 14px no-repeat;
            mask: url('/images/search/icons/play-solid.svg') center / 14px 14px no-repeat;
}

/* ---- Contributors rail block ------------------------------------- */
/* Figma rail rows: 40px avatar (with optional verified badge overlay),
   name + org + role stacked, and a Follow button aligned right. */
.search-rail__list--contributors {
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.search-rail__contributor {
    display: grid;
    grid-template-columns: 40px 1fr auto;
    gap: 12px;
    align-items: start;
}
.search-rail__contributor-avatar {
    position: relative;
    display: block;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    overflow: visible; /* keep verified badge visible outside the avatar */
    background: #F4F5FA;
}
.search-rail__contributor-avatar img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
}
.search-rail__contributor-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    background: #EEF1FB;
    color: #465DA6;
    font-weight: 600;
}
.search-rail__contributor-verified {
    position: absolute;
    right: -3px;
    bottom: -3px;
    width: 14px;
    height: 14px;
    line-height: 0;
}
.search-rail__contributor-body {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    line-height: 1.4;
}
.search-rail__contributor-name {
    color: #1F2533;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    line-height: 20px;
}
.search-rail__contributor-name:hover { color: #465DA6; }
.search-rail__contributor-org {
    color: #1F2533;
    font-size: 13px;
    line-height: 18px;
}
.search-rail__contributor-role {
    color: #6B7280;
    font-size: 12px;
    line-height: 16px;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
}
.search-rail__contributor-follow {
    flex: 0 0 auto;
    align-self: center;
    background: transparent;
    color: #1F2533;
    border: 1px solid #D5D7DA;
    border-radius: 999px;
    padding: 4px 14px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.search-rail__contributor-follow:hover {
    border-color: #465DA6;
    color: #465DA6;
}

/* ---- Layout helpers ---------------------------------------------- */
.search-layout__main { display: block; }

/* Default: hide the mobile-only body-category chip and the mobile-only
   summary excerpt. The breakpoint below turns them on. */
.search-card__category-body { display: none; }
.search-card__excerpt-mobile { display: none; }

/* =================================================================
   Mobile (≤768) — Figma file Qkw1rAqYvxShVppu34QlEv, node 1342:4080.
   Single-column body, compact 80-px-thumb cards, scrolling tab strip,
   chip moves from thumb-overlay to body, byline simplified to author
   only, no-results headline centered.
   ================================================================= */
@media (max-width: 768px) {

    .search-page {
        padding: 16px 0 32px;
    }
    .search-page__container {
        padding: 0 16px;
    }
    .search-page__heading {
        font-size: 24px;
        line-height: 30px;
    }
    .search-page__header { margin-bottom: 8px; }

    /* Tabs — horizontally scrollable strip (Figma frame 1320:3670 cuts
       off "Events" at the right edge, confirming overflow). */
    .search-tabs {
        gap: 24px;
        overflow-x: auto;
        flex-wrap: nowrap;
        white-space: nowrap;
        scrollbar-width: none;
        -ms-overflow-style: none;
        margin-bottom: 16px;
    }
    .search-tabs::-webkit-scrollbar { display: none; }
    .search-tabs__tab {
        flex: 0 0 auto;
        padding: 8px 0;
        font-size: 14px;
    }

    .search-page__body {
        grid-template-columns: 1fr;
        gap: 24px;
    }
    /* Side rail is suppressed on mobile — Figma's mobile result pages are
       a single column with no cross-category preview. */
    .search-rail { display: none; }

    /* Article / Multimedia row — 80×80 thumb, body stack. */
    .search-card {
        grid-template-columns: 80px 1fr;
        gap: 12px;
    }
    .search-card__thumb {
        aspect-ratio: 1 / 1;
        border-radius: 8px;
    }
    .search-card__thumb-badge { display: none; }
    .search-card__thumb-play {
        width: 24px;
        height: 24px;
        bottom: 4px;
        right: 4px;
    }
    .search-card__category-body {
        display: inline-flex;
        align-items: center;
        background: #EAF8F6;
        color: #269387;
        padding: 2px 10px;
        border-radius: 16px;
        font-size: 12px;
        line-height: 18px;
        font-weight: 500;
        margin-bottom: 6px;
        max-width: max-content;
    }
    .search-card__title {
        font-size: 16px;
        line-height: 22px;
        margin: 0 0 6px;
    }
    .search-card__excerpt-mobile {
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
        font-size: 13px;
        line-height: 18px;
        color: #4B5563;
        margin: 0 0 6px;
    }
    .search-card__byline {
        font-size: 13px;
        line-height: 18px;
        gap: 6px;
        color: #465DA6;
    }
    .search-card__byline-icon { width: 12px; height: 12px; }
    .search-card__author { color: #465DA6; }
    /* Drop the org + dot on mobile rows — Figma shows author only. */
    .search-card__byline .search-card__sep,
    .search-card__byline .search-card__org { display: none; }
    .search-card__tags { display: none; }

    /* Course / Event grids collapse to single column. */
    .search-results__list { gap: 16px; }
    .search-results__list--grid { grid-template-columns: 1fr; }
    .search-results__list--grid .search-card {
        grid-template-columns: 80px 1fr;
        gap: 12px;
    }
    .search-results__list--grid .search-card--course .search-card__thumb,
    .search-results__list--grid .search-card--event .search-card__thumb {
        width: 80px;
        aspect-ratio: 1 / 1;
        margin-bottom: 0;
    }

    /* Show More */
    .search-show-more { margin-top: 24px; }

    /* No-results — headline + subline centered (Figma 1322:11788). */
    .search-empty {
        padding: 32px 16px 16px;
        text-align: center;
    }
    .search-empty__headline { font-size: 20px; line-height: 28px; }
    .search-empty__subline { max-width: 280px; margin: 0 auto; }

    /* Suggested Articles heading stays left-aligned per Figma. */
    .search-suggested { text-align: left; margin-top: 24px; }
    .search-suggested__heading {
        font-size: 18px;
        line-height: 26px;
        margin-bottom: 16px;
    }
    .search-suggested__list { gap: 16px; }
}

