/* Blog posts and project pages (blogs/*.html, feedback-app.html): the panel, back link, category, date,
   title, title picture and the text. Each page adds its own parts in its <style>. */

/* One blog post: a window like the portfolio projects, with the picture on top and the text below. */

main {
    padding-bottom: var(--page-bottom);
}

.back_link {
    display: block;
    width: var(--column);
    margin: var(--page-top) auto 0;
    color: var(--color-border);
    font-size: var(--fs-text);
    line-height: var(--lh-text);
    text-decoration: none;
}

@media (hover: hover) {
    .back_link:hover {
        text-decoration: underline;
        text-underline-offset: 4px;
    }
}

.post {
    width: var(--column);
    margin: var(--space-title) auto 0;  /* 16px below "← All posts", like a heading above its panel on the blog page */
    padding: var(--panel-inset);
    box-sizing: border-box;
    color: var(--color-text-soft);
    container: post / inline-size;  /* pictures and frames inside take their height from its width (cqi), see below */
}

/* Category and date, as in the boxes on the blog page */
.post_meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 6px 16px;
    font-size: var(--fs-small);
}

/* Same chip as on the blog page and the portfolio */
.post_category {
    padding: 2px 12px;
    line-height: var(--lh-chip);
    border: 2px solid var(--color-border);
    border-radius: 6px;
    color: var(--color-border);
    font-size: var(--fs-chip);
}

.post_date {
    align-self: flex-start;
    line-height: var(--lh-small);         /* 24px, from the type scale */
    margin-top: calc(-0.25em - 1.5px);    /* the digits start level with the category frame, see the blog page */
    color: var(--color-secondary);
}

/* The post's title is the page title: size and spacing from the type scale in general.css */
.post h1 {
    margin-top: 16px;
    overflow-wrap: anywhere;
}

/* Same black "screen" frame as the screenshots on the portfolio page */
.post_image {
    margin: 0 0 32px;
    overflow: hidden;
}

.post_image img {
    display: block;
    width: 100%;
    max-height: 556px;  /* with the 2px border: the box is at most 560px tall */
    object-fit: contain;
}

/* Snapped to the 16px grid, in CSS: a picture's height follows from the panel's width (100cqi, inside the 2px
   border: - 4px) and its proportions (--r = height / width, set in the post's stylesheet; without it: the natural height), rounded down so the frame ends on
   the grid. The small + 0.16px keeps a height that is a hair under a grid line on it. Screen only. */
@media screen {
    .post_image img {
        height: calc(round(down, min((100cqi - 4px) * var(--r), 556px) + 4.16px, 16px) - 4px);
    }
}

/* ---------- The text from the Markdown file ---------- */
.post_body {
    font-size: var(--fs-text);
    line-height: var(--lh-text);
}

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

.post_body p,
.post_body ul,
.post_body ol {
    margin: 0 0 16px;
}

.post_body ul,
.post_body ol {
    padding-left: 32px;
}

/* Headings in the text: sizes from the type scale in general.css */
.post_body h2,
.post_body h3 {
    margin-top: 32px;
}

.post_body a {
    color: var(--color-border);
}

.post_body img {
    display: block;
    margin: 16px 0;
    border: 2px solid var(--color-line);
    border-radius: 8px;
}

.post_body code {
    font: inherit;  /* the pixel font, so the line keeps its 32px height */
    padding: 0 4px;
    border-radius: 4px;
    background-color: var(--color-screen);
}
