/**
 * Article hero
 * Feature image becomes the full-bleed background of the article title.
 * Loaded on post pages only (see `default.hbs`).
 *
 * Readability is guaranteed by layering, never by hoping the photo is dark:
 *   1. a vertical veil that is darkest where the text block sits (bottom);
 *   2. a horizontal veil that darkens the left column the text starts in;
 *   3. a soft text shadow on the title / excerpt / meta.
 * The composed background under the text stays above 4.8:1 at the worst pixel,
 * measured against a pure white image and a high-contrast checkerboard
 * (WCAG AA needs 4.5:1 for normal text, 3:1 for large text).
 * Preview + measurement harness lives in `preview/` next to the theme.
 */

/* Remove the default 8rem gap so the hero sits flush under the site header */
.gh-main--hero {
    padding-top: 0;
}

/* Same thing without relying on the class, so a custom template that reuses the
   hero markup still lines up under the site header */
body:has(.gh-article-header--hero) .gh-main {
    padding-top: 0;
}

/* Hero shell — still a .gh-canvas grid, so the title keeps the body's column */
.gh-article-header--hero {
    position: relative;
    isolation: isolate;
    align-content: end;
    /* 48vh keeps the body — and the table of contents — inside the first screen
       on common laptop viewports (1366x768, 1440x900) without shrinking the
       title block itself: the hero grows with the text when it needs to. */
    min-height: clamp(24rem, 48vh, 56rem);
    padding-top: 6.4rem;
    padding-bottom: 4.4rem;
    overflow: hidden;
    color: var(--color-white, #fff);
    background-color: #0d1014;
}

/**
 * Everything except the background layer paints above it.
 * `stretch` (instead of the theme's `justify-items: start`) gives each block the
 * full canvas column, which is what lets the breadcrumb truncate instead of
 * overflowing the page.
 */
.gh-article-header--hero > * {
    position: relative;
    z-index: 1;
    justify-self: stretch;
}

/**
 * Background layer: bleeds past the grid columns to the viewport edges.
 * An absolutely positioned child of a grid container is sized by its grid area,
 * so it must opt out of the canvas placement (`.gh-canvas > *` sets
 * `grid-column: main`); with `auto` placement the containing block is the
 * hero's padding box, i.e. the full viewport width.
 */
.gh-article-header--hero .gh-article-hero-media {
    position: absolute;
    grid-area: auto;
    inset: 0;
    z-index: 0;
    margin: 0;
    overflow: hidden;
}

.gh-article-header--hero .gh-article-hero-media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center 40%;
}

/**
 * Readability veils.
 * The text block is bottom-aligned but grows upwards with the title, so the
 * veil cannot be "dark only at the bottom": the whole text zone has to stay
 * dark enough for white text on a bright photo. Measured with `preview/measure.py`
 * against a pure white image (worst case):
 *   vertical   0.28 → 0.36 → 0.56 → 0.78 → 0.92 (top → bottom)
 *   horizontal 0.42 → 0.15 → 0               (left → right)
 * The top third of the image carries no text, so it stays light and shows the
 * photo; the veil only bites from the breadcrumb line down.
 * Tune these alphas to trade image visibility for more contrast, then re-run
 * the harness; every sample should stay above its WCAG AA threshold.
 */
.gh-article-header--hero .gh-article-hero-scrim {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(
            180deg,
            rgba(6, 9, 13, 0.28) 0%,
            rgba(6, 9, 13, 0.36) 22%,
            rgba(6, 9, 13, 0.56) 44%,
            rgba(6, 9, 13, 0.78) 72%,
            rgba(6, 9, 13, 0.92) 100%
        ),
        linear-gradient(
            90deg,
            rgba(6, 9, 13, 0.42) 0%,
            rgba(6, 9, 13, 0.15) 52%,
            rgba(6, 9, 13, 0) 88%
        );
}

/* Title */
.gh-article-header--hero .gh-article-title {
    font-size: clamp(3.6rem, 4.6vw, 5rem);
    line-height: 1.16;
    letter-spacing: -0.01em;
    color: var(--color-white, #fff);
    text-shadow: 0 0.2rem 1.2rem rgba(0, 0, 0, 0.55), 0 0.1rem 0.3rem rgba(0, 0, 0, 0.35);
}

/* Excerpt */
.gh-article-header--hero .gh-article-excerpt {
    margin-top: 1.6rem;
    font-size: 1.9rem;
    line-height: 1.65;
    color: rgba(255, 255, 255, 0.88);
    text-shadow: 0 0.1rem 0.6rem rgba(0, 0, 0, 0.5);
}

/* Author / date row: the desktop sidebar becomes an inline row inside the hero */
.gh-article-header--hero .gh-article-sidebar {
    position: static;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1.2rem;
    grid-column: main-start / main-end;
    margin-top: 2.4rem;
    padding-right: 0;
}

.gh-article-header--hero .gh-author-image-list {
    margin: 0;
}

.gh-article-header--hero .gh-author-image-list .gh-author-image {
    width: 3.6rem;
    height: 3.6rem;
    margin-bottom: 0;
    border-color: rgba(255, 255, 255, 0.85);
}

.gh-article-header--hero .gh-author-image-list .gh-author-image:only-child {
    width: 4rem;
    height: 4rem;
}

.gh-article-header--hero .gh-author-image-list .gh-author-image + .gh-author-image {
    margin-left: -1.2rem;
}

.gh-article-header--hero .gh-author-name-list {
    align-items: center;
    color: var(--color-white, #fff);
}

.gh-article-header--hero .gh-author-name,
.gh-article-header--hero .gh-author-name a {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-white, #fff);
}

.gh-article-header--hero .gh-article-meta {
    margin-top: 0;
    color: rgba(255, 255, 255, 0.78);
    text-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.45);
}

/* Breadcrumb over the image */
.gh-article-header--hero .gh-breadcrumb {
    background: transparent;
}

/* One line only: the last crumb repeats the H1, so it truncates instead of wrapping */
.gh-article-header--hero .gh-breadcrumb-list {
    flex-wrap: nowrap;
}

.gh-article-header--hero .gh-breadcrumb-item {
    flex: 0 0 auto;
    min-width: 0;
}

.gh-article-header--hero .gh-breadcrumb-current {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
}

.gh-article-header--hero .gh-breadcrumb-current span {
    display: block;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.gh-article-header--hero .gh-breadcrumb-item,
.gh-article-header--hero .gh-breadcrumb-item:not(:last-child)::after,
.gh-article-header--hero .gh-breadcrumb-link {
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 0.1rem 0.4rem rgba(0, 0, 0, 0.5);
}

.gh-article-header--hero .gh-breadcrumb-link:hover,
.gh-article-header--hero .gh-breadcrumb-current,
.gh-article-header--hero .gh-breadcrumb-current span {
    color: var(--color-white, #fff);
}

/* Feature image caption, kept below the hero in the body column */
.gh-article-hero-caption {
    margin-top: 1.2rem;
}

.gh-article-hero-caption-text {
    padding: 0;
    font-size: 1.3rem;
    line-height: 1.6;
    color: var(--color-secondary-text, #999);
    text-align: left;
}

@media (max-width: 767px) {
    .gh-article-header--hero {
        min-height: clamp(28rem, 46vh, 42rem);
        padding-top: 4.8rem;
        padding-bottom: 3.2rem;
    }

    .gh-article-header--hero .gh-article-title {
        font-size: clamp(2.8rem, 7.4vw, 3.6rem);
        line-height: 1.2;
    }

    .gh-article-header--hero .gh-article-excerpt {
        margin-top: 1.2rem;
        font-size: 1.7rem;
    }

    .gh-article-header--hero .gh-article-sidebar {
        margin-top: 2rem;
    }
}

/* Short viewports (laptops in landscape): keep the text block in view */
@media (max-height: 700px) and (min-width: 768px) {
    .gh-article-header--hero {
        min-height: 34rem;
        padding-top: 4.8rem;
        padding-bottom: 3.2rem;
    }
}
