/*
 * Blog: the hero of the game page, then the posts as cards, the latest one leading the first page on a wide card. The
 * page of a post narrows to a reading column, its cover between the hero and the body; the body comes from the editor
 * of the back office, so its elements are styled by tag.
 */
.news-page {
    --news-measure: 46rem;
    --news-cover-width: calc(64rem + 2 * var(--home-gutter));
}

/* A longer title than the game page, hence a smaller size. */
.news-hero__title {
    font-size: clamp(2.75rem, 8vw, 7rem);
    text-wrap: balance;
}

/* List */
.news-list {
    max-width: var(--home-content-width);
    /* Leaves room below the name engraved at the bottom of the hero. */
    margin: clamp(2rem, 5vw, 3.5rem) auto 0;
    padding: 0 var(--home-gutter) var(--home-section-space);
}

.news-list__empty {
    margin: 0;
    padding: var(--space-l);
    border: 1px dashed var(--home-line-strong);
    border-radius: var(--home-radius-inner);
    color: var(--home-text-muted);
    text-align: center;
}

.news-list__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
    gap: clamp(1rem, 2vw, 1.5rem);
    margin: 0 0 var(--space-l);
    padding: 0;
    list-style: none;
}

.news-list__item--featured {
    grid-column: 1 / -1;
}

/* Card */
.post-card {
    position: relative;
    isolation: isolate;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    border: 1px solid var(--home-line);
    border-radius: var(--home-radius-inner);
    background-color: var(--home-surface);
    color: var(--home-text);
    transition:
        transform 0.6s var(--home-ease),
        box-shadow 0.6s var(--home-ease),
        border-color 0.6s ease;
}

.post-card:hover {
    border-color: color-mix(in srgb, var(--home-gold) 60%, transparent);
    box-shadow: 0 30px 70px -30px color-mix(in srgb, var(--home-gold) 55%, transparent);
    transform: translateY(-6px);
}

/* The link is stretched over the card: the card shows its focus. */
.post-card:has(.post-card__link:focus-visible) {
    outline: 3px solid var(--color-focus-ring);
    outline-offset: 3px;
}

/* Without a cover, a night landscape lit in gold, like the map tiles of the game page. */
.post-card__media {
    display: grid;
    place-items: center;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background-image:
        linear-gradient(transparent 55%, var(--home-surface)),
        linear-gradient(160deg, transparent 60%, var(--art-landscape-hill) 60%),
        linear-gradient(205deg, transparent 50%, var(--art-landscape-mountain) 50% 68%, transparent 68%),
        radial-gradient(circle at 70% 35%, color-mix(in srgb, var(--home-gold) 45%, transparent), transparent 55%),
        linear-gradient(var(--art-landscape-sky-top), var(--art-landscape-sky-bottom));
}

.post-card__image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 1.2s var(--home-ease);
}

.post-card:hover .post-card__image {
    transform: scale(1.04);
}

.post-card__crown {
    width: clamp(2.5rem, 6vw, 4rem);
    height: auto;
    color: var(--home-gold);
    opacity: 0.6;
}

.post-card__body {
    display: grid;
    grid-template-rows: auto auto auto 1fr auto;
    gap: var(--space-s);
    flex-grow: 1;
    padding: var(--space-m) 1.25rem 1.25rem;
}

.post-card__kicker,
.post-card__date {
    margin: 0;
    font-family: var(--font-family-ui);
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.post-card__kicker {
    color: var(--home-gold);
}

.post-card__date {
    color: var(--home-text-muted);
}

.post-card__title {
    margin: 0;
    font-size: clamp(1.25rem, 1.8vw, 1.5rem);
    line-height: 1.2;
    text-wrap: balance;
}

.post-card__link {
    color: inherit;
    text-decoration: none;
}

.post-card__link:focus-visible {
    outline: none;
}

.post-card__link::after {
    content: '';
    position: absolute;
    z-index: 1;
    inset: 0;
}

.post-card__excerpt {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: var(--home-text-muted);
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
    line-clamp: 3;
}

.post-card__action {
    display: grid;
    place-items: center;
    justify-self: end;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid var(--home-line-strong);
    border-radius: 50%;
    color: var(--home-gold);
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease,
        color 0.3s ease,
        transform 0.5s var(--home-ease);
}

/* The arrow turns towards the post, like those of the "Explore" cards of the home page. */
.post-card:hover .post-card__action {
    border-color: var(--home-gold);
    background-color: var(--home-gold);
    color: var(--home-surface);
    transform: rotate(45deg) scale(1.08);
}

.post-card__icon {
    width: 1.125rem;
    height: 1.125rem;
}

/* The latest post: the cover beside the text on wide screens, a larger title and the whole excerpt. */
.post-card--featured .post-card__title {
    font-size: clamp(1.75rem, 3.4vw, 2.75rem);
}

.post-card--featured .post-card__excerpt {
    display: block;
    font-size: clamp(1.0625rem, 1.4vw, 1.25rem);
}

@media (min-width: 56rem) {
    /* minmax(0, …): the columns keep their share whatever the size of the image. */
    .post-card--featured {
        display: grid;
        grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
    }

    /*
     * The cover fills the height of the card, whatever the length of the text. Without its aspect ratio: kept beside a
     * stretched height, it would widen the cover over the text. The image is taken out of the flow, so that only the
     * text and the minimum height size the card.
     */
    .post-card--featured .post-card__media {
        position: relative;
        aspect-ratio: auto;
        min-height: 22rem;
    }

    .post-card--featured .post-card__image {
        position: absolute;
        inset: 0;
    }

    .post-card--featured .post-card__body {
        align-content: center;
        padding: var(--space-l);
    }
}

/* Post */
/* Less room above than the game page: the back link opens the hero, with room of its own below it. */
.news-post__hero {
    padding-block: clamp(1.5rem, 4vw, 2.5rem);
}

/* Aligned on the left edge of the cover. */
.news-post__top {
    max-width: var(--news-cover-width);
    margin: 0 auto clamp(2.5rem, 6vw, 4.5rem);
    padding-inline: var(--home-gutter);
}

.news-post__hero .game-hero__inner {
    max-width: calc(var(--news-measure) + 2 * var(--home-gutter));
}

.news-post__back {
    display: inline-flex;
    align-items: center;
    gap: var(--space-s);
    color: var(--home-gold);
    font-family: var(--font-family-ui);
    font-size: 0.8125rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    text-decoration: none;
    text-transform: uppercase;
}

.news-post__back:hover {
    color: var(--home-text);
}

.news-post__back-icon {
    width: 1.125em;
    height: 1.125em;
    transform: rotate(180deg);
    transition: transform 0.4s var(--home-ease);
}

.news-post__back:hover .news-post__back-icon {
    transform: rotate(180deg) translateX(3px);
}

.news-post__title {
    font-size: clamp(2.25rem, 6vw, 4.5rem);
    line-height: 1.05;
    text-wrap: balance;
}

.news-post__lead {
    max-width: none;
}

.news-post__cover {
    max-width: var(--news-cover-width);
    margin: 0 auto clamp(2rem, 5vw, 3.5rem);
    padding-inline: var(--home-gutter);
}

/* Cropped to 16:9 by its filter, unless the uploaded image was smaller: the cover keeps the shape anyway. */
.news-post__cover-image {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border: 1px solid var(--home-line);
    border-radius: var(--home-radius-inner);
}

/* Body: the elements allowed by the post sanitizer (config/packages/html_sanitizer.yaml). */
.news-post__body {
    max-width: calc(var(--news-measure) + 2 * var(--home-gutter));
    margin-inline: auto;
    padding-inline: var(--home-gutter);
    font-size: clamp(1.125rem, 1.4vw, 1.25rem);
    line-height: 1.7;
    overflow-wrap: break-word;
}

.news-post__body > :first-child {
    margin-top: 0;
}

.news-post__body :is(p, ul, ol, blockquote, figure, pre, table) {
    margin-block: 0 1.25em;
}

.news-post__body :is(h2, h3, h4) {
    margin-block: 1.75em 0.5em;
    line-height: 1.2;
    text-wrap: balance;
}

.news-post__body h2 {
    font-size: clamp(1.625rem, 2.6vw, 2rem);
}

.news-post__body h3 {
    font-size: clamp(1.375rem, 2.2vw, 1.625rem);
}

.news-post__body h4 {
    color: var(--home-gold);
    font-family: var(--font-family-ui);
    font-size: 0.9375rem;
    letter-spacing: 0.16em;
    text-transform: uppercase;
}

.news-post__body a {
    color: var(--home-gold);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

.news-post__body a:hover {
    color: var(--home-text);
}

.news-post__body :is(ul, ol) {
    padding-inline-start: 1.5em;
}

.news-post__body li + li {
    margin-top: 0.375em;
}

.news-post__body li::marker {
    color: var(--home-gold);
}

.news-post__body blockquote {
    margin-inline: 0;
    padding: var(--space-s) 0 var(--space-s) 1.25em;
    border-left: 3px solid var(--home-gold);
    color: var(--home-text-muted);
    font-style: italic;
}

.news-post__body figure {
    margin-inline: 0;
}

.news-post__body img {
    max-width: 100%;
    height: auto;
    border-radius: var(--home-radius-inner);
}

.news-post__body figcaption {
    margin-top: var(--space-s);
    color: var(--home-text-muted);
    font-size: 0.875em;
    text-align: center;
}

/* Tables scroll on their own on phones rather than widening the page. */
.news-post__body figure.table {
    overflow-x: auto;
}

.news-post__body table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-family-ui);
    font-size: 0.875em;
}

.news-post__body :is(th, td) {
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--home-line);
    text-align: start;
}

.news-post__body th {
    background-color: var(--home-glass);
}

.news-post__body pre {
    padding: var(--space-m);
    overflow-x: auto;
    border: 1px solid var(--home-line);
    border-radius: var(--home-radius-inner);
    background-color: var(--home-glass);
    line-height: 1.5;
}

.news-post__body code {
    font-family: ui-monospace, 'Cascadia Code', 'Source Code Pro', Menlo, Consolas, monospace;
    font-size: 0.875em;
}

.news-post__body hr {
    margin-block: 2.5em;
    border: 0;
    border-top: 1px dashed var(--home-line-strong);
}

/* Sized by its width rather than a padding, so its top border stops at the reading column. */
.news-post__footer {
    width: min(var(--news-measure), 100% - 2 * var(--home-gutter));
    margin: clamp(2rem, 5vw, 3.5rem) auto 0;
    padding: var(--space-l) 0 var(--home-section-space);
    border-top: 1px solid var(--home-line);
}

/* Preview of a post from the back office: what visitors see of it, above the page as they would see it. */
.news-preview {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-s) var(--space-m);
    margin: 0;
    padding: var(--space-s) var(--home-gutter);
    background-color: var(--color-gold-light);
    color: var(--color-night-deep);
    font-family: var(--font-family-ui);
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
}

.news-preview__link {
    color: inherit;
}

@media (prefers-reduced-motion: reduce) {
    .post-card,
    .post-card__image,
    .post-card__action,
    .news-post__back-icon {
        transition: none;
    }

    .post-card:hover,
    .post-card:hover .post-card__image,
    .post-card:hover .post-card__action {
        transform: none;
    }
}
