/* ===========================================================================
   Blog — the home-page rail, the index, and the article page.
   Generated content; the markup comes from apps/app/scripts/export-blog.mjs.

   Palette is the site's: #c96a2f accent, #1c0f08 headings, #4a3d34 body,
   #8a7261 muted, #ece2d6 rules, #f6f1ea / #faf7f3 grounds.
   ========================================================================= */

/* --- Shared card ---------------------------------------------------------
   One card definition for all three places a post appears, so a post looks
   the same on the homepage, on the index and in the recommendations.
   ------------------------------------------------------------------------ */
.blog-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    text-decoration: none;
    color: inherit;
    background: #fff;
    border: 1px solid #ece2d6;
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.2s, transform 0.2s;
}
.blog-card:hover {
    border-color: #e28244;
    box-shadow: 0 8px 24px rgba(28, 15, 8, 0.09);
    transform: translateY(-2px);
}
.blog-card:focus-visible {
    outline: 2px solid #c96a2f;
    outline-offset: 3px;
}

/*
 * The aspect ratio is declared, not inherited from the file. Infinite scroll
 * appends cards below what you are reading, and an image that only claims its
 * height once it has loaded would shove the page around underneath you.
 */
.blog-card__photo {
    aspect-ratio: 16 / 10;
    background: linear-gradient(135deg, #b48a64 0%, #5e3a22 100%);
    overflow: hidden;
}
.blog-card__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}
.blog-card:hover .blog-card__photo img {
    transform: scale(1.04);
}

/*
 * A post with no photograph — every generated draft starts that way — gets a
 * deliberate block rather than a broken tile, so a coverless card reads as a
 * choice instead of a missing file.
 */
.blog-card__photo--none {
    display: flex;
    align-items: flex-end;
    padding: 18px;
    background: linear-gradient(135deg, #2a1810 0%, #5e3a22 100%);
}
.blog-card__photo--none span {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.4px;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.85);
}

.blog-card__body {
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 8px;
    padding: 18px 20px 20px;
}
.blog-card__meta {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    /* The accent, darkened to reach 4.5:1 at this size. */
    color: #a65727;
}
.blog-card__title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.35;
    color: #1c0f08;
}
.blog-card__excerpt {
    margin: 0;
    font-size: 14.5px;
    line-height: 1.6;
    color: #4a3d34;
    /* Three lines, so cards in a row stay the same height whatever the copy. */
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.blog-card__when {
    margin-top: auto;
    padding-top: 6px;
    font-size: 12.5px;
    color: #8a7261;
}

/* --- The rail ------------------------------------------------------------
   Used on the homepage and under an article. Scroll-snap rather than a
   carousel library: a touch swipe is the browser's own, and it degrades to a
   plain scrollable row with no JavaScript at all.
   ------------------------------------------------------------------------ */
.lcco-blog {
    padding: 96px 0 104px;
    background: #f6f1ea;
}
.lcco-blog--tint {
    background: #fff;
}
.lcco-blog__inner {
    max-width: 1220px;
    margin: 0 auto;
    padding: 0 32px;
}
.lcco-blog__header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 34px;
}
.lcco-blog__kicker {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1.6px;
    text-transform: uppercase;
    /* The accent, darkened to reach 4.5:1 at this size. */
    color: #a65727;
}
.lcco-blog__title {
    margin: 0;
    font-size: clamp(30px, 4vw, 44px);
    font-weight: 700;
    line-height: 1.1;
    color: #1c0f08;
}
.lcco-blog__lede {
    margin: 12px 0 0;
    max-width: 52ch;
    font-size: 16px;
    line-height: 1.65;
    color: #4a3d34;
}
.lcco-blog__actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.lcco-blog__all {
    font-size: 14px;
    font-weight: 600;
    color: #1c0f08;
    text-decoration: none;
    border-bottom: 1.5px solid #c96a2f;
    padding-bottom: 2px;
    transition: color 0.15s;
    white-space: nowrap;
}
.lcco-blog__all:hover { color: #c96a2f; }

.lcco-blog__arrow {
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    border: 1px solid #ddcdbb;
    border-radius: 50%;
    background: #fff;
    color: #1c0f08;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s, opacity 0.15s;
}
.lcco-blog__arrow:hover:not(:disabled) {
    background: #c96a2f;
    border-color: #c96a2f;
    color: #fff;
}
/* Disabled at the ends rather than hidden: a control that vanishes reads as a
   bug, and the row's position is the only thing that changed. */
.lcco-blog__arrow:disabled {
    opacity: 0.35;
    cursor: default;
}

.lcco-blog__rail {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 300px;
    gap: 26px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    /* No scroll-behavior: smooth. It turned the browser's first snap of this
       row into an animated scroll, and Chrome stops measuring a page's largest
       paint the moment anything scrolls, so pages with a rail never got an LCP
       at all. The arrows still glide: blog.js asks for "smooth" itself. */
    /* Room for the card's lifted hover state and its shadow. */
    padding: 6px 4px 22px;
    margin: -6px -4px -22px;
    scrollbar-width: none;
}
.lcco-blog__rail::-webkit-scrollbar { display: none; }
.lcco-blog__rail > * { scroll-snap-align: start; }

/*
 * A fixed track, not minmax().
 *
 * `minmax(0, 33.333%)` reads as "at most a third" — and a grid with room to
 * spare honours the minimum instead, shrinking four cards until they all fit
 * and leaving nothing to scroll. The rail then has arrows that do nothing.
 * A bare length is the width, and the row overflows as it is meant to.
 */
@media (min-width: 900px) {
    .lcco-blog__rail { grid-auto-columns: calc(33.333% - 18px); }
}
@media (max-width: 899px) {
    .lcco-blog__rail { grid-auto-columns: calc(50% - 13px); }
}
@media (max-width: 640px) {
    .lcco-blog { padding: 68px 0 76px; }
    .lcco-blog__inner { padding: 0 20px; }
    .lcco-blog__rail { grid-auto-columns: 82%; gap: 16px; }
    .lcco-blog__header { flex-direction: column; align-items: flex-start; }
}

/* --- The index -----------------------------------------------------------
   A grid rather than a rail: this is the page you come to in order to browse,
   and everything published belongs on it.
   ------------------------------------------------------------------------ */
.blog-index {
    padding: 56px 0 96px;
    background: #faf7f3;
    min-height: 60vh;
}
.blog-index__inner {
    max-width: 1220px;
    margin: 0 auto;
    padding: 0 32px;
}
.blog-index__head { margin-bottom: 40px; }
.blog-index__grid {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
}
.blog-index__grid > li { margin: 0; }
@media (max-width: 980px) {
    .blog-index__grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
    .blog-index__inner { padding: 0 20px; }
    .blog-index__grid { grid-template-columns: 1fr; gap: 20px; }
}

/*
 * The infinite-scroll foot.
 *
 * It reserves its height whether or not it is spinning, so the sentinel does
 * not jump the moment loading starts — the page must not move under a reader
 * while the next batch arrives.
 */
.blog-more {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 92px;
    margin-top: 40px;
    font-size: 14px;
    color: #8a7261;
}
.blog-more__spinner {
    width: 22px;
    height: 22px;
    border: 2.5px solid #e6d9c9;
    border-top-color: #c96a2f;
    border-radius: 50%;
    animation: blog-spin 0.75s linear infinite;
}
@keyframes blog-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    .blog-more__spinner { animation-duration: 2.4s; }
    .lcco-blog__rail { scroll-behavior: auto; }
    .blog-card, .blog-card__photo img { transition: none; }
}

/* The manual fallback. Shown only when scripting is off or the observer never
   fires, so a reader is never stranded halfway down the archive. */
.blog-more__button {
    padding: 12px 26px;
    font: inherit;
    font-weight: 600;
    color: #1c0f08;
    background: #fff;
    border: 1px solid #ddcdbb;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.blog-more__button:hover {
    background: #c96a2f;
    border-color: #c96a2f;
    color: #fff;
}

/* --- The article ----------------------------------------------------------
   The cover runs in the text column, below the standfirst. It used to sit
   above the masthead, which showed the reader a photograph before telling
   them what it was of.
   -------------------------------------------------------------------------- */
.blog-post__cover {
    margin: 0 0 30px;
    padding: 0;
}

/*
 * The crop widens as the screen does.
 *
 * One ratio for all sizes cannot work here: the column is a fixed 720px on a
 * desktop but nearly the whole screen on a phone, so a shape that is a tidy
 * banner on one is either a sliver or a wall on the other. Mobile gets the
 * tallest crop because a wide one at 335px is a letterbox with nothing in it;
 * the desktop gets the shallowest because 405px of photograph pushed the
 * opening paragraph off the screen entirely.
 *
 * height:auto is load-bearing. The tag carries width/height attributes so the
 * browser reserves the right box before the file arrives — but those also make
 * the height definite, and a definite height beats aspect-ratio. Without it
 * the cover rendered its full 900px as a tall strip.
 */
.blog-post__cover img {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 3;
    object-fit: cover;
    display: block;
    border-radius: 12px;
}

@media (min-width: 641px) {
    .blog-post__cover { margin-bottom: 32px; }
    .blog-post__cover img {
        aspect-ratio: 16 / 9;
        border-radius: 14px;
    }
}

@media (min-width: 1024px) {
    .blog-post__cover img { aspect-ratio: 21 / 9; }
}
