/* ============================================================
   Related Insights — reusable template-part component
   template-parts/related-posts.php
   End-of-article "keep reading" strip. Cards reuse the same photo-or-
   placeholder media block + floating category badge + inverting CTA
   bar signature as .ssd-post-card (style.css) elsewhere on the site,
   so this reads as the same system rather than a one-off component.
   Background is deliberately not set here — pass 'bg' to the template
   part per page, same as faq-compact / conversion-compact.
   ============================================================ */

.ssd-related {
    border-top: 1px solid var(--ssd-rule);
    padding: 2.5rem 0 3rem;
}
/* style.css has a sitewide ".ssd-wrap section" rule that force-adds
   padding-left/right: clamp(20px, 5vw, 56px) !important to EVERY raw
   <section> under .ssd-wrap (a fluid gutter meant for location-page
   sections) — since this component is also a <section>, it was getting
   that AND .ssd-related__inner's own stepped-gutter padding at once,
   double-insetting the content relative to the header above it, which
   only uses the stepped system once. .ssd-wrap .ssd-related (two
   classes) outranks .ssd-wrap section (one class + one type) so this
   safely cancels just the generic padding, leaving centering/max-width
   from that same rule intact and harmless (it no longer constrains
   anything once this section's own padding is zero). */
.ssd-wrap .ssd-related {
    padding-left: 0 !important;
    padding-right: 0 !important;
}

/* Border-box gutter technique — matches faq-compact.css/conversion-
   compact.css: content area equals exactly --ssd-container-w (the
   header's own width) once the box hits its cap; below that, width:
   100% takes over and the mobile gutter still holds. Kept independent
   of .ssd-wrap/.ssd-ed-wrap's own container rules since this part is
   shared across both. */
.ssd-related__inner {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: max(var(--gutter-mobile, 20px), calc((100% - var(--ssd-container-w)) / 2));
    padding-right: max(var(--gutter-mobile, 20px), calc((100% - var(--ssd-container-w)) / 2));
}
@media (min-width: 768px) {
    .ssd-related__inner {
        padding-left: max(var(--gutter-tablet, 32px), calc((100% - var(--ssd-container-w)) / 2));
        padding-right: max(var(--gutter-tablet, 32px), calc((100% - var(--ssd-container-w)) / 2));
    }
}
@media (min-width: 1280px) {
    .ssd-related__inner {
        padding-left: max(var(--gutter-desk, 56px), calc((100% - var(--ssd-container-w)) / 2));
        padding-right: max(var(--gutter-desk, 56px), calc((100% - var(--ssd-container-w)) / 2));
    }
}

.ssd-related__header {
    margin-bottom: 1.25rem;
}
.ssd-related__eyebrow {
    margin: 0 0 .4rem;
    font-size: .68rem;
    font-weight: 800;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--ssd-primary);
}
.ssd-related__heading {
    margin: 0;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -.02em;
    color: var(--ssd-text);
}
@media (min-width: 768px) { .ssd-related__heading { font-size: 1.6rem; } }

/* ── Grid — mobile: horizontal scroll-snap shelf; tablet: 2-up; desktop: 3-up ── */
.ssd-related__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}
@media (max-width: 767px) {
    .ssd-related__grid {
        display: flex;
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        scroll-padding-left: var(--gutter-mobile, 20px);
        gap: .875rem;
        /* Bleed to the viewport edge so the next card visibly peeks in,
           then re-add the same gutter as padding so the first card still
           lines up with the heading above it. */
        margin-left: calc(-1 * var(--gutter-mobile, 20px));
        margin-right: calc(-1 * var(--gutter-mobile, 20px));
        /* padding: 0 var(--gutter-mobile, 20px) .5rem; */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }
    .ssd-related__grid::-webkit-scrollbar { display: none; }
    .ssd-related__card {
        flex: 0 0 78%;
        scroll-snap-align: start;
    }
}
@media (min-width: 480px) and (max-width: 767px) {
    .ssd-related__card { flex-basis: 62%; }
}
@media (min-width: 768px) and (max-width: 1023px) {
    .ssd-related__grid { grid-template-columns: repeat(2, 1fr); gap: 1.25rem; }
}
@media (min-width: 1024px) {
    .ssd-related__grid { grid-template-columns: repeat(3, 1fr); gap: 1.5rem; }
}

/* ── Card ── */
.ssd-related__card {
    background: var(--ssd-white);
    border: 1px solid var(--ssd-border);
    border-radius: 14px;
    overflow: hidden;
    transition: box-shadow 220ms ease, border-color 220ms ease, transform 220ms ease;
}
.ssd-related__card:hover,
.ssd-related__card:focus-within {
    box-shadow: 0 16px 36px -18px rgba(var(--ssd-primary-rgb), .32);
    border-color: var(--ssd-primary-light);
    transform: translateY(-3px);
}
@media (prefers-reduced-motion: reduce) {
    .ssd-related__card { transition: none; }
    .ssd-related__card:hover, .ssd-related__card:focus-within { transform: none; }
}

.ssd-related__card-link,
.ssd-related__card-link:hover,
.ssd-related__card-link:focus,
.ssd-related__card-link:active,
.ssd-related__card-link:visited {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
}
/* Bootstrap 5 (loaded on blog pages) sets a global "a:hover" rule whose
   type-selector + pseudo-class combination outranks a plain class
   selector's specificity — the block above alone still lost the
   underline fight specifically on hover. Matching that same shape
   (class + pseudo-class) guarantees this wins regardless of what else
   targets bare <a> elements on the page. */
.ssd-related__card-link:focus-visible {
    outline: 2px solid var(--ssd-primary-dark);
    outline-offset: 2px;
}

/* ── Media: real photo or themed placeholder, same signature as
   .ssd-post-card elsewhere on the site ── */
.ssd-related__media {
    position: relative;
    display: block;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: var(--ssd-primary-light);
}
.ssd-related__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
    transition: transform 500ms ease;
}
.ssd-related__card:hover .ssd-related__img { transform: scale(1.045); }
@media (prefers-reduced-motion: reduce) {
    .ssd-related__img { transition: none; }
    .ssd-related__card:hover .ssd-related__img { transform: none; }
}
.ssd-related__media--placeholder {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--ssd-primary-light) 0%, var(--ssd-light-bg) 100%);
    color: var(--ssd-primary);
}
.ssd-related__badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--ssd-primary);
    color: var(--ssd-white);
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .08em;
    padding: 5px 10px;
    border-radius: 999px;
}

/* ── Body ── */
.ssd-related__body {
    padding: 16px 18px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
}
.ssd-related__title {
    margin: 0;
    font-size: .98rem;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    color: var(--ssd-text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ssd-related__excerpt {
    margin: 0;
    font-size: .83rem;
    line-height: 1.55;
    color: var(--ssd-muted);
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.ssd-related__footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-top: auto;
    padding-top: .6rem;
    border-top: 1px solid var(--ssd-border);
}
.ssd-related__time {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .72rem;
    font-weight: 600;
    color: var(--ssd-muted);
}
.ssd-related__time svg { flex-shrink: 0; color: var(--ssd-primary); }
.ssd-related__cta {
    font-size: .75rem;
    font-weight: 700;
    color: var(--ssd-primary-dark);
    transition: color 200ms ease;
}
.ssd-related__card:hover .ssd-related__cta,
.ssd-related__card:focus-within .ssd-related__cta {
    color: var(--ssd-primary);
}
