/* Post cards: the homepage Insights bento grid and the blog listing. Rendered by static/posts.js. Mobile-first. */

:root {
    --post-radius: 1.125rem; /* 18px */
    --post-media-radius: 0.75rem;
    --post-gap: 0.5rem; /* tight, like the reference */
    --post-pad: 1.25rem;

    --post-bg: #f4f4f5; /* blog page: a stripe's hover fill */
    --post-card-bg: #f2f2f2; /* homepage Insights cards: the outer fill */
    --post-ink: #0a0a0a;
    --post-ink-2: #525252;
    --post-ink-3: #737373; /* small grey labels: 4.7:1 on white */
    --post-ink-faint: #a3a3a3;

    --post-title-s: clamp(1rem, 0.97rem + 0.12vw, 1.0625rem); /* picture cards: 16px on phones, 17px on desktop */
    --post-title-m: clamp(1.125rem, 1rem + 0.5vw, 1.375rem); /* text and wide cards: 18-22px */
    --post-title-l: clamp(1.125rem, 1rem + 0.45vw, 1.5rem); /* featured card: 18-24px */
    --post-label: 0.625rem; /* 10px, as the founder asked; CLAUDE.md's minimum is 12px */
    --post-zoom: scale(1.05); /* hover: only the picture moves */
    --blog-radius: 0.25rem; /* blog page card outlines: 4px */
    --blog-cover-radius: 0.25rem; /* blog page cover images: 4px */
}

/* ---------- Homepage section ---------- */
.insights {
    padding-block: clamp(4rem, 3rem + 4vw, 7rem);
    padding-left: max(var(--gutter), env(safe-area-inset-left));
    padding-right: max(var(--gutter), env(safe-area-inset-right));
    font-family: "Geist", -apple-system, system-ui, sans-serif;
}

.insights__head {
    display: flex;
    flex-direction: column; /* phones: heading, then "View all" below it, both on the left edge */
    align-items: flex-start;
    gap: 0.25rem;
    margin-bottom: clamp(1.5rem, 1rem + 1.5vw, 2.5rem);
}

@media (min-width: 768px) {
    .insights__head {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.5rem 2rem;
    }
}

.insights__title {
    margin: 0;
    color: var(--post-ink);
    font-family: "Geist", sans-serif;
    font-size: var(--section-title, 2.625rem); /* the same size as every homepage section heading (site-header.css) */
    font-weight: 400;
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.insights__all {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    min-height: 2.75rem;
    color: var(--post-ink);
    font-size: 0.9375rem;
    text-decoration: none;
    transition: color 0.2s ease;
}

/* Turns light grey on hover, only on devices with a mouse (touch screens would keep it "stuck" after a tap) */
@media (hover: hover) and (pointer: fine) {
    .insights__all:hover {
        color: var(--post-ink-faint);
    }
}

.insights__all:focus-visible {
    outline: 2px solid var(--post-ink);
    outline-offset: 3px;
}

/* ---------- Grids ---------- */
.post-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--post-gap);
}

.post-grid__error {
    margin: 0;
    color: var(--post-ink-2);
}

/* Homepage grid:
   phones  - the first 4 posts, one column, every card the same (picture, then title)
   tablets - the same 4 cards in two columns
   desktop - all 7 in the bento: featured (2x2) | text card over two picture cards; then picture | wide card | picture */
.post-grid--home > .post-card:nth-child(n + 5) {
    display: none;
}

@media (min-width: 768px) {
    .post-grid--home {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .post-grid--home {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .post-grid--home > .post-card:nth-child(n + 5) {
        display: flex;
    }

    .post-grid--home .post-card--featured {
        grid-column: 1 / 3;
        grid-row: 1 / 3;
    }

    .post-grid--home .post-card--text {
        grid-column: 3 / 5;
    }

    .post-grid--home .post-card--wide {
        grid-column: span 2;
    }
}

/* ---------- Cards ---------- */
/* Every card has a frame holding a picture (image or gradient) and the category tag.
   Picture cards put the title below the frame; featured and text cards put it inside. */
.post-card {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
    padding: var(--post-pad);
    border-radius: var(--post-radius);
    background-color: var(--post-card-bg);
    color: var(--post-ink);
    text-decoration: none;
    overflow-wrap: anywhere;
}

.post-card:focus-visible {
    outline: 2px solid var(--post-ink);
    outline-offset: 3px;
}

.post-card__frame {
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    isolation: isolate;
    border-radius: var(--post-media-radius);
}

.post-card__picture {
    position: absolute;
    inset: 0;
    z-index: -2;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.post-card:focus-visible .post-card__picture {
    transform: var(--post-zoom);
}

@media (hover: hover) and (pointer: fine) {
    .post-card:hover .post-card__picture {
        transform: var(--post-zoom);
    }
}

.post-card__title {
    margin: 0;
    font-size: var(--post-title-s);
    font-weight: 400;
    line-height: 1.35;
    letter-spacing: -0.01em;
    text-wrap: pretty;
}

/* Tag: small square icon plus an uppercase label, inside the picture */
.post-tag {
    display: inline-flex;
    align-items: flex-start; /* a long category that wraps keeps the chevron on its first line */
    gap: 0.5rem;
    align-self: flex-start;
    color: #ffffff;
    font-size: var(--post-label);
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

/* A small ">" chevron before the label */
.post-tag__icon {
    flex-shrink: 0;
    width: 0.4375rem;
    height: 0.4375rem;
    margin-top: 0.3em; /* centered on the first line of the label */
    border-top: 1.5px solid currentColor;
    border-right: 1.5px solid currentColor;
    transform: rotate(45deg);
}

/* Every card: picture with the tag in its top-left, title below. Below 1024px all cards keep this layout. */
.post-card__frame {
    aspect-ratio: 16 / 10;
    padding: 1rem;
}

/* A soft dark fade behind the tag keeps it readable on light pictures */
.post-card__frame::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.35) 0%, rgba(0, 0, 0, 0) 45%);
}

/* Pictures without an image are the post's cover (static/post-covers.css). On a light cover the tag turns
   dark and the top fade goes, so the tag stays readable. */
.post-card--light .post-card__frame::before {
    content: none;
}

.post-card--light .post-tag {
    color: var(--post-ink-2);
}

/* Desktop bento: featured, text and wide cards become one big picture with the title laid over it */
@media (min-width: 1024px) {
    .post-grid--home .post-card--featured,
    .post-grid--home .post-card--text,
    .post-grid--home .post-card--wide {
        position: relative;
        padding: 0;
    }

    .post-grid--home .post-card--featured .post-card__frame,
    .post-grid--home .post-card--text .post-card__frame,
    .post-grid--home .post-card--wide .post-card__frame {
        flex: 1;
        aspect-ratio: auto;
        padding: var(--post-pad);
        border-radius: var(--post-radius);
    }

    .post-grid--home .post-card--featured .post-card__frame {
        min-height: 30rem;
    }

    .post-grid--home .post-card--wide .post-card__frame {
        min-height: 16rem;
    }

    .post-grid--home .post-card--text .post-card__frame {
        min-height: 16rem;
    }

    /* Fades at the top (tag) and bottom (title) keep the white text readable */
    .post-grid--home .post-card--featured .post-card__frame::before,
    .post-grid--home .post-card--text .post-card__frame::before,
    .post-grid--home .post-card--wide .post-card__frame::before {
        background-image: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 0%, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0) 50%, rgba(0, 0, 0, 0.45) 100%);
    }

    .post-grid--home .post-card--featured .post-card__title,
    .post-grid--home .post-card--text .post-card__title,
    .post-grid--home .post-card--wide .post-card__title {
        position: absolute;
        left: var(--post-pad);
        right: var(--post-pad);
        bottom: var(--post-pad);
        color: #ffffff;
        line-height: 1.2;
    }

    .post-grid--home .post-card--featured .post-card__title {
        max-width: 26ch;
        font-size: var(--post-title-l);
        letter-spacing: -0.02em;
    }

    .post-grid--home .post-card--wide .post-card__title {
        max-width: 24ch;
        font-size: var(--post-title-m);
        letter-spacing: -0.015em;
    }

    .post-grid--home .post-card--text .post-card__title {
        max-width: 30ch;
        font-size: var(--post-title-m);
        letter-spacing: -0.015em;
    }

    /* A light cover under a laid-over title: dark title, no fades */
    .post-grid--home .post-card--light .post-card__frame::before {
        content: none;
    }

    .post-grid--home .post-card--light .post-card__title {
        color: var(--post-ink);
    }
}

/* Touch screens: press feedback, since there's no hover. The card and "View all" fade while pressed. */
@media (hover: none) {
    .post-card,
    .insights__all {
        transition: opacity 0.1s ease-out, color 0.2s ease;
    }

    .post-card:active,
    .insights__all:active {
        opacity: 0.6;
    }
}

@media (prefers-reduced-motion: reduce) {
    .post-card__picture,
    .insights__all {
        transition: none;
    }
}

/* ---------- Blog listing page ----------
   A featured post on top (cover left, text right), then one row of three cards with covers,
   then every other post as a stripe: month and year, title, category. */
/* Page heading above the filters and search */
/* The subheading sits midway: the same space above it (to the heading) and below it (to the category tags),
   20px on phones growing to 32px at 1440px */
.blog-intro {
    --blog-intro-gap: clamp(1.25rem, 0.875rem + 1.25vw, 2rem);
    margin-bottom: var(--blog-intro-gap);
}

/* From 1280px the tags share a row with the 44px search field and are centered on it, which pushes the 32px
   tags 6px down; take that back so the gap under the subheading still matches the gap above it */
@media (min-width: 1280px) {
    .blog-intro {
        margin-bottom: calc(var(--blog-intro-gap) - 0.375rem);
    }
}

.blog-intro__title {
    margin: 0;
    color: var(--post-ink);
    font-family: "Geist", sans-serif;
    font-size: clamp(2rem, 1.2rem + 3.2vw, 3.75rem); /* fluid: 32px on phones, about 44px on a 768px tablet, 52px at 1024px, 60px from 1280px */
    font-weight: 400;
    line-height: 1.05;
    letter-spacing: -0.035em;
}

.blog-intro__lede {
    max-width: 60ch;
    margin: var(--blog-intro-gap) 0 0;
    color: #676767; /* 5.7:1 on white */
    font-family: "Geist", sans-serif;
    font-size: 1rem; /* 16px on phones (one line from 360px wide); 18px from 640px */
    line-height: 1.5;
}

@media (min-width: 640px) {
    .blog-intro__lede {
        font-size: 1.125rem;
    }
}


.blog-list {
    display: grid;
    gap: 2rem;
    margin-top: 2rem; /* a line of white space below the filters and search */
}

/* Until the posts arrive, hold a screen's height, so the space below doesn't jump down when they appear */
.blog-list.is-loading {
    min-height: 100vh;
    min-height: 100svh;
}

.blog-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 2rem;
}

@media (min-width: 768px) {
    .blog-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .blog-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.blog-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    padding: 0.75rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    border-radius: var(--blog-radius);
    background-color: #ffffff;
    color: var(--post-ink);
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: border-color 0.3s ease;
}

/* Border darkens on hover, only on devices with a mouse */
@media (hover: hover) and (pointer: fine) {
    .blog-card:hover {
        border-color: var(--post-ink);
    }
}

.blog-card:focus-visible {
    outline: 2px solid var(--post-ink);
    outline-offset: 3px;
}

/* The cover sits in a clipped frame, so on hover it can zoom in slightly without spilling out, exactly like the
   homepage cards' pictures (--post-zoom, the same 0.6s ease) */
.blog-card__media {
    display: block;
    overflow: hidden;
    isolation: isolate;
    width: 100%;
    aspect-ratio: 16 / 9;
    border-radius: var(--blog-cover-radius);
}

.blog-card__cover {
    display: grid; /* centers the cover's symbol (static/post-covers.css) */
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}

.blog-card:focus-visible .blog-card__cover {
    transform: var(--post-zoom);
}

@media (hover: hover) and (pointer: fine) {
    .blog-card:hover .blog-card__cover {
        transform: var(--post-zoom);
    }
}

.blog-card__body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 13.75rem;
    padding: 1.25rem 0.75rem 0.75rem;
}

.blog-card__title {
    margin: 0 0 1rem;
    font-size: 1.375rem; /* 22px on phones (every card, the featured one included, since it stacks like the others); 18px from 768px, 28px on the featured post */
    font-weight: 400;
    line-height: 1.3;
    text-wrap: pretty;
}

.blog-card__excerpt {
    display: -webkit-box;
    margin: 0 0 auto;
    overflow: hidden;
    color: #4b5563;
    font-size: 1rem; /* 16px on phones; 14px from 768px, 16px on the featured post */
    line-height: 1.6;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.blog-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin: 2rem 0 0;
    color: var(--post-ink);
    font-family: "Geist Mono", ui-monospace, monospace;
    font-size: 0.625rem; /* 10px, as the founder asked; CLAUDE.md §13's minimum for reading-time labels is 12px */
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

/* Featured post: stacked on phones, cover on the left (45%) and text on the right from 768px.
   Its cover is a little taller than the other cards': 16:9, on phones and beside the text */
.blog-card--featured .blog-card__media {
    aspect-ratio: 16 / 9;
}

@media (min-width: 768px) {
    .blog-card--featured {
        flex-direction: row;
        align-items: stretch;
    }

    .blog-card--featured .blog-card__media {
        flex: 0 0 45%;
        min-width: 0; /* keeps it at 45%: without this the 280px minimum height pushes it wider on tablets */
        aspect-ratio: 16 / 9;
        min-height: 17.5rem;
    }

    .blog-card--featured .blog-card__body {
        justify-content: center;
        min-height: 17.5rem;
        padding: 2rem 2.5rem;
    }

    .blog-card__title {
        font-size: 1.125rem; /* 18px */
    }

    .blog-card__excerpt {
        font-size: 0.875rem; /* 14px */
    }

    .blog-card--featured .blog-card__title {
        font-size: 1.75rem; /* 28px */
        line-height: 1.25;
    }

    .blog-card--featured .blog-card__excerpt {
        max-width: 42rem;
        margin-bottom: 0;
        font-size: 1rem; /* 16px */
    }
}

/* Stripes: phones put the date and category on one line above the title; from 768px it's one row */
.blog-more {
    margin-top: 1.5rem;
}

.blog-more__title {
    display: flex;
    align-items: center;
    gap: 0; /* the arrow's own leading space gives one letter of space */
    margin: 0 0 0.75rem;
    padding-inline: 1rem; /* lines up with the stripe text */
    color: var(--post-ink-3);
    font-size: 0.8125rem; /* 13px */
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.blog-rows {
    margin: 0;
    padding: 0;
    list-style: none;
}

.blog-row + .blog-row {
    border-top: 1px solid rgba(15, 23, 42, 0.1);
}

.blog-row__link {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem 1.5rem;
    align-items: center;
    padding: 1.75rem 1rem;
    border-radius: var(--blog-radius);
    color: var(--post-ink);
    text-decoration: none;
    overflow-wrap: anywhere;
    transition: background-color 0.2s ease;
}

.blog-row__date,
.blog-row__category {
    color: var(--post-ink-3);
    font-size: 0.75rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.blog-row__category {
    text-align: right;
}

.blog-row__title {
    grid-column: 1 / -1;
    grid-row: 2;
    margin: 0;
    font-size: clamp(1.25rem, 1.05rem + 0.9vw, 1.75rem);
    font-weight: 400;
    line-height: 1.25;
    letter-spacing: -0.015em;
    text-wrap: pretty;
}

@media (min-width: 768px) {
    .blog-row__link {
        grid-template-columns: 8rem minmax(0, 1fr) auto;
        gap: 2rem;
        padding-block: 2.75rem;
    }

    .blog-row__title {
        grid-column: 2;
        grid-row: 1;
    }
}

/* The whole stripe turns light grey on hover, only on devices with a mouse */
@media (hover: hover) and (pointer: fine) {
    .blog-row__link:hover {
        background-color: var(--post-bg);
    }
}

.blog-row__link:focus-visible {
    outline: 2px solid var(--post-ink);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .blog-card,
    .blog-card__cover,
    .blog-row__link {
        transition: none;
    }
}

/* No-JavaScript fallback: a plain list of links */
.post-links {
    display: grid;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
}

.post-links a {
    display: inline-flex;
    align-items: center;
    min-height: 2.75rem;
    color: var(--post-ink);
}
