/**
 * Element Trending Posts — frontend styles.
 *
 * Translated from the EGFR-Revamp Figma frames:
 *   featured post     615:610 (desktop 818, tablet 550, mobile 375)
 *   trending post     230:29
 *   trending speakers 236:145
 *   trending tags     230:84
 *
 * Every value that a designer might want to move lives in a custom property on
 * .etp-trending, so the global custom-CSS field in Settings can retheme the
 * output by overriding tokens rather than fighting selectors.
 */

.etp-trending {
    /* Palette (Figma variables) */
    --etp-surface: #f9fafb;
    --etp-navy: #072d51;
    --etp-navy-alt: #0d355a;
    --etp-bright-blue: #2d71d2;
    --etp-dark-gray: #2e2e2e;
    --etp-light-gray: #797979;
    --etp-chip-bg: #dceeff;
    --etp-light-yellow: #fcf0b7;
    --etp-on-blue: #f9fafb;

    /* Shape */
    --etp-radius-card: 12px;
    --etp-radius-media: 6px;
    --etp-radius-chip: 4px;
    --etp-card-padding: 24px;
    --etp-shadow:
        -1px 3px 4px rgba(168, 168, 168, 0.1),
        -2px 14px 7px rgba(168, 168, 168, 0.09),
        -5px 31px 9.5px rgba(168, 168, 168, 0.05),
        -8px 56px 11.5px rgba(168, 168, 168, 0.01);

    /* Layout */
    --etp-gap: 24px;
    --etp-header-gap: 16px;

    box-sizing: border-box;
}

.etp-trending *,
.etp-trending *::before,
.etp-trending *::after {
    box-sizing: inherit;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

.etp-trending__header {
    display: flex;
    align-items: center;
    gap: var(--etp-header-gap);
    margin-bottom: var(--etp-gap);
}

.etp-trending__icon {
    flex: 0 0 auto;
    width: 20px;
    height: auto;
    color: var(--etp-bright-blue);
}

.etp-trending__title {
    font-family: Roboto, system-ui, sans-serif;
    font-weight: 500;
    font-size: 14px;
    line-height: 24px;
    text-transform: uppercase;
    color: var(--etp-navy-alt);
}

/* The speakers frame sits on a dark band: yellow type in a translucent pill. */
.etp-trending--dark .etp-trending__header {
    display: inline-flex;
    padding: 8px 10px;
    border-radius: var(--etp-radius-media);
    background: rgba(252, 240, 183, 0.15);
}

.etp-trending--dark .etp-trending__title,
.etp-trending--dark .etp-trending__icon {
    color: var(--etp-light-yellow);
}

/* The larger heading ("Discover Trending Tags", node 79:85). Font family is
   inherited so the theme's display face applies, matching the post titles. */
.etp-trending__heading {
    margin: 0 0 var(--etp-gap);
    font-size: 20px;
    font-weight: 500;
    line-height: 1.2;
    text-transform: capitalize;
    color: var(--etp-navy);
}

.etp-trending--dark .etp-trending__heading {
    color: var(--etp-on-blue);
}

/* ── Trending posts (230:29) ─────────────────────────────────────────────── */

.etp-trending--posts .etp-trending__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--etp-gap);
}

.etp-post {
    background: var(--etp-surface);
    border-radius: var(--etp-radius-card);
    box-shadow: var(--etp-shadow);
    overflow: hidden;
}

.etp-post__link {
    display: flex;
    flex-direction: column;
    gap: 26px;
    padding: var(--etp-card-padding);
    text-decoration: none;
    color: inherit;
}

.etp-post__link:hover .etp-post__title,
.etp-post__link:focus-visible .etp-post__title {
    color: var(--etp-bright-blue);
}

/* Banner: featured image, navy scrim, centred headshot stack. */
.etp-post__media {
    position: relative;
    height: 82px;
    border-radius: var(--etp-radius-media);
    overflow: hidden;
    background: #ddd;
}

.etp-post__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.etp-post__scrim {
    position: absolute;
    inset: 0;
    background: var(--etp-navy);
    opacity: 0.8;
}

.etp-post__avatars {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Overlapping stack — the design shows headshots tucked behind each other. */
.etp-post__avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    border: 2px solid var(--etp-surface);
}

.etp-post__avatar + .etp-post__avatar {
    margin-left: -14px;
}

.etp-post__body {
    display: flex;
    flex-direction: column;
    gap: var(--etp-gap);
}

/* Attribute chips (speaker names). */
.etp-post__attributes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.etp-attr {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: var(--etp-radius-chip);
    background: var(--etp-chip-bg);
    color: var(--etp-navy);
    font-family: Roboto, system-ui, sans-serif;
    font-size: 12px;
    line-height: 24px;
    text-transform: uppercase;
    text-align: center;
}

.etp-post__title {
    margin: 0;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 400;
    color: var(--etp-dark-gray);
    transition: color 0.15s ease;
}

.etp-post__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    font-family: Roboto, system-ui, sans-serif;
    font-weight: 500;
    font-size: 10px;
    line-height: 24px;
}

.etp-post__date {
    color: var(--etp-light-gray);
}

.etp-post__readtime,
.etp-post__views {
    position: relative;
    color: var(--etp-bright-blue);
}

/* The bullet separator from the design, drawn rather than marked up. */
.etp-post__meta > * + *::before {
    content: "";
    position: absolute;
    left: -9px;
    top: 50%;
    width: 3px;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Featured post (615:610) ─────────────────────────────────────────────── */

.etp-featured {
    /* Padding is the only thing the desktop (818), tablet (550) and mobile
       (375) frames disagree on, so it is what the breakpoints move. */
    --etp-featured-padding: 50px;
    --etp-featured-gap: 30px;
    --etp-featured-chip-bg: rgba(220, 238, 255, 0.2);
    --etp-featured-avatar: 48px;

    position: relative;
    display: flex;
    align-items: flex-start;
    padding: var(--etp-featured-padding);
    border-radius: var(--etp-radius-card);
    box-shadow: var(--etp-shadow);
    /* Only the legacy card stack overflows; harmless for the redesign. */
    overflow: hidden;
    background: linear-gradient(269.98deg, var(--etp-navy) 0%, var(--etp-bright-blue) 69.562%);
}

.etp-featured__body {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--etp-featured-gap);
}

/* The top row: eyebrow pill left, headshot stack right. */
.etp-featured__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--etp-featured-gap);
    width: 100%;
}

.etp-featured__eyebrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 8px 6px;
    border-radius: var(--etp-radius-chip);
    background: var(--etp-light-yellow);
    color: var(--etp-navy-alt);
    font-family: Roboto, system-ui, sans-serif;
    font-weight: 500;
    font-size: 12px;
    line-height: 24px;
    text-transform: uppercase;
}

.etp-featured__eyebrow-icon {
    flex: 0 0 auto;
    width: 12px;
    height: 12px;
}

/* Overlapping headshots; source order is front-to-back, so no z-index. */
.etp-featured__avatars {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
}

.etp-featured__avatar {
    display: block;
    width: var(--etp-featured-avatar);
    height: var(--etp-featured-avatar);
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--etp-surface);
}

.etp-featured__avatar + .etp-featured__avatar {
    margin-left: -9px;
}

/* Speaker name chips. Each is its own link to the resources page filtered to
   that term, which is why they sit outside the post link rather than in it. */
.etp-featured__speakers {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.etp-featured__speaker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 6px;
    border-radius: var(--etp-radius-chip);
    background: var(--etp-featured-chip-bg);
    color: var(--etp-on-blue);
    font-family: Roboto, system-ui, sans-serif;
    font-weight: 400;
    font-size: 12px;
    line-height: 24px;
    text-align: center;
    text-transform: uppercase;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

a.etp-featured__speaker:hover,
a.etp-featured__speaker:focus-visible {
    background: var(--etp-chip-bg);
    color: var(--etp-navy);
}

/* The post link wraps only the headline and meta line. */
.etp-featured__link {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--etp-featured-gap);
    max-width: 100%;
    text-decoration: none;
    color: inherit;
}

.etp-featured__title {
    margin: 0;
    font-size: 24px;
    line-height: 1.2;
    font-weight: 400;
    color: var(--etp-on-blue);
    transition: color 0.15s ease;
}

a.etp-featured__link:hover .etp-featured__title,
a.etp-featured__link:focus-visible .etp-featured__title {
    color: var(--etp-light-yellow);
}

.etp-featured__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
    font-family: Roboto, system-ui, sans-serif;
    font-weight: 500;
    font-size: 10px;
    line-height: 24px;
}

.etp-featured__date {
    color: var(--etp-on-blue);
}

.etp-featured__readtime {
    position: relative;
    color: var(--etp-light-yellow);
}

/* Same drawn bullet separator as the trending cards. */
.etp-featured__meta > * + *::before {
    content: "";
    position: absolute;
    left: -9px;
    top: 50%;
    width: 3px;
    height: 3px;
    margin-top: -1.5px;
    border-radius: 50%;
    background: currentColor;
}

/* ── Featured attribute cards (432:7) ────────────────────────────────────────
   Superseded by the avatar stack above; reachable with media="cards". One
   grid cell holds every card, so the later cards' margins grow the cell and
   source order supplies the z-order (later cards sit on top, as in the
   design). */

.etp-featured__cards {
    display: inline-grid;
    flex: 0 0 auto;
    align-self: center;
}

.etp-featured__card {
    grid-area: 1 / 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 160px;
    padding: 12px;
    background: var(--etp-surface);
    border-radius: 10px;
    box-shadow:
        0 4px 4px rgba(140, 140, 140, 0.1),
        1px 14px 7.5px rgba(140, 140, 140, 0.09),
        3px 33px 10px rgba(140, 140, 140, 0.05);
}

.etp-featured__card:nth-child(2) {
    margin: 62px 0 0 110px;
}

.etp-featured__card:nth-child(3) {
    margin: 124px 0 0 220px;
}

.etp-featured__card-media {
    display: block;
    width: 100%;
    aspect-ratio: 136 / 90;
    border-radius: 9px;
    overflow: hidden;
    background: #ddd;
}

.etp-featured__card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.etp-featured__card-name {
    font-family: Roboto, system-ui, sans-serif;
    font-size: 14px;
    line-height: 1.2;
    text-transform: capitalize;
    color: var(--etp-light-gray);
}

/* ── Trending tags (230:84) ──────────────────────────────────────────────── */

.etp-trending--terms.etp-trending--chips {
    padding: var(--etp-card-padding);
    background: var(--etp-surface);
    border-radius: var(--etp-radius-card);
    box-shadow: var(--etp-shadow);
}

.etp-trending--chips .etp-trending__list {
    display: flex;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 8px;
}

.etp-term--chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 12px;
    border-radius: var(--etp-radius-chip);
    background: var(--etp-bright-blue);
    color: var(--etp-on-blue);
    font-size: 14px;
    line-height: 1.2;
    text-decoration: none;
    transition: background-color 0.15s ease;
}

.etp-term--chip:hover,
.etp-term--chip:focus-visible {
    background: var(--etp-navy-alt);
    color: var(--etp-on-blue);
}

.etp-term--chip .etp-term__count {
    opacity: 0.7;
    font-size: 12px;
}

/* ── Trending speakers (236:145) ─────────────────────────────────────────── */

.etp-trending--cards .etp-trending__list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 20px;
}

.etp-term--card {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 12px;
    background: var(--etp-surface);
    border-radius: var(--etp-radius-card);
    box-shadow:
        0 4px 4px rgba(140, 140, 140, 0.1),
        1px 14px 7.5px rgba(140, 140, 140, 0.09),
        3px 33px 10px rgba(140, 140, 140, 0.05);
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.etp-term--card:hover,
.etp-term--card:focus-visible {
    transform: translateY(-2px);
}

/* Pinned cards get the highlight ring from the design. */
.etp-term--card.etp-term--pinned {
    box-shadow: 0 0 0 8px rgba(198, 227, 255, 0.36);
}

.etp-term__media {
    position: relative;
    display: block;
    width: 100%;
    aspect-ratio: 166 / 110;
    border-radius: 9px;
    overflow: hidden;
    background: #ddd;
}

.etp-term__image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Blue wash rising from the bottom of the headshot. */
.etp-term__scrim {
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 4%, var(--etp-bright-blue) 96%);
    opacity: 0.55;
}

.etp-term--card .etp-term__name {
    font-size: 14px;
    line-height: 1.2;
    text-transform: capitalize;
    color: var(--etp-light-gray);
}

.etp-term__subtitle {
    font-size: 10px;
    line-height: 1.2;
    color: var(--etp-light-gray);
}

.etp-term__cta {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    line-height: 1.2;
    text-transform: capitalize;
    color: var(--etp-bright-blue);
}

.etp-term__cta-icon {
    width: 11px;
    height: auto;
    color: currentColor;
}

.etp-term--card .etp-term__count {
    font-size: 10px;
    color: var(--etp-light-gray);
}

/* ── Small screens ───────────────────────────────────────────────────────── */

/* The banner's tablet frame (550) differs from desktop only in padding. */
@media (max-width: 900px) {
    .etp-featured {
        --etp-featured-padding: 40px;
    }
}

@media (max-width: 600px) {
    .etp-trending {
        --etp-card-padding: 16px;
        --etp-gap: 16px;
    }

    .etp-trending--posts .etp-trending__list {
        grid-template-columns: 1fr;
    }

    .etp-trending--cards .etp-trending__list {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .etp-featured {
        --etp-featured-padding: 30px;
    }

    /* The mobile frame drops the top row: the headshot stack moves under the
       pill rather than sitting opposite it. */
    .etp-featured__header {
        flex-direction: column;
        align-items: flex-start;
    }

    /* Legacy cards mode stacks: the card pile sits above the headline, with
       tighter cards and offsets so three still fit a phone screen. */
    .etp-featured--cards {
        flex-direction: column-reverse;
    }

    .etp-featured__cards {
        align-self: center;
        margin: 0 0 var(--etp-featured-gap);
    }

    .etp-featured__card {
        width: 132px;
    }

    .etp-featured__card:nth-child(2) {
        margin: 48px 0 0 88px;
    }

    .etp-featured__card:nth-child(3) {
        margin: 96px 0 0 176px;
    }
}
