/*
 * Blog listing and article page layout.
 *
 * Structure only -- spacing, grid and responsive behaviour. Colours and fonts
 * are placeholders that inherit from the stub chrome; when the real
 * energysafety.africa stylesheet arrives, the values here get replaced while
 * the structure stays.
 *
 * Kept separate from article.css deliberately: article.css is the typography
 * shared with the Quill editor, this is page furniture the editor never sees.
 */

/* Screen-reader-only text -- used to give repeated "Read more" links a
   distinguishable accessible name. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Page frame -------------------------------------------------------------- */

/* The blog, article and 404 pages emit their content straight into <main>
   with no .container of their own -- this frames all three to the same
   centered measure as the rest of the site, with breathing room top and
   bottom. */
body.page-blog main,
body.page-article main,
body.page-404 main {
    display: block;
    width: min(calc(100% - 40px), var(--container));
    margin: 0 auto;
    padding: 3.5rem 0 4.5rem;
}

/* Listing header --------------------------------------------------------- */

.blog-header {
    margin-bottom: 2.75rem;
}

.blog-header h1 {
    font-size: 2.4rem;
    line-height: 1.2;
    margin: 0 0 0.6rem;
    color: var(--text);
}

.blog-intro {
    margin: 0;
    color: var(--text-soft);
    font-size: 1.02rem;
    max-width: 38rem;
}

.blog-empty {
    color: var(--text-soft);
    padding: 3rem 0;
    text-align: center;
}

/* Post grid -------------------------------------------------------------- */

.post-grid {
    display: grid;
    /* auto-fill with a minimum keeps the grid responsive without media
       queries -- 3 columns wide, 2 on tablet, 1 on phone. */
    grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
    gap: 1.75rem;
}

.post-card {
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.post-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.post-card-media {
    display: block;
    /* Fixed ratio so cards line up whether or not a post has an image. */
    aspect-ratio: 16 / 9;
    background: var(--bg-soft);
    overflow: hidden;
}

.post-card-media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.post-card-placeholder {
    display: block;
    width: 100%;
    height: 100%;
    background: repeating-linear-gradient(
        45deg,
        var(--bg-soft),
        var(--bg-soft) 10px,
        var(--primary-soft) 10px,
        var(--primary-soft) 20px
    );
}

.post-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 1.15rem 1.25rem 1.35rem;
}

.post-card-date {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.5rem;
}

.post-card-title {
    font-size: 1.12rem;
    line-height: 1.35;
    margin: 0 0 0.6rem;
}

.post-card-title a {
    color: var(--text);
    text-decoration: none;
}

.post-card-title a:hover {
    color: var(--primary);
}

.post-card-excerpt {
    margin: 0 0 1rem;
    color: var(--text-soft);
    font-size: 0.93rem;
    line-height: 1.6;
}

/* Pushes the link to the bottom so cards of differing text length still
   align their call to action. */
.post-card-more {
    margin-top: auto;
    align-self: flex-start;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.post-card-more:hover {
    text-decoration: underline;
}

/* Pager ------------------------------------------------------------------ */

.pager {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--line);
}

.pager-link {
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
}

.pager-link:hover { text-decoration: underline; }

.pager-link.is-disabled {
    color: var(--line-strong);
    pointer-events: none;
}

.pager-status {
    font-size: 0.9rem;
    color: var(--muted);
}

/* Article ---------------------------------------------------------------- */

.article {
    max-width: 42rem;
    margin: 0 auto;
}

.article-header {
    margin-bottom: 1.75rem;
}

.article-title {
    font-size: 2.15rem;
    line-height: 1.18;
    margin: 0 0 0.75rem;
    color: var(--text);
}

.article-meta {
    margin: 0;
    font-size: 0.88rem;
    color: var(--muted);
}

.article-author::before {
    content: "·";
    margin: 0 0.45rem;
}

.article-figure {
    margin: 0 0 2rem;
}

.article-figure img {
    width: 100%;
    height: auto;
    border-radius: 5px;
    display: block;
}

/* Previous / next -------------------------------------------------------- */

.article-nav {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: 1rem;
    max-width: 42rem;
    margin: 3rem auto 0;
    padding-top: 1.75rem;
    border-top: 1px solid var(--line);
}

.article-nav-link {
    display: block;
    padding: 0.9rem 1.1rem;
    border: 1px solid var(--line);
    border-radius: 5px;
    text-decoration: none;
    color: var(--text);
}

.article-nav-link:hover {
    border-color: var(--primary);
}

/* Right-align the "next" card so the pair reads outward from the centre. */
.article-nav-link.is-next {
    text-align: right;
}

.article-nav-label {
    display: block;
    font-size: 0.76rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.3rem;
}

.article-nav-title {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.4;
}

.back-to-blog {
    max-width: 42rem;
    margin: 2rem auto 0;
}

/* Same link, placed above the title instead of below the nav -- spacing runs
   the other direction so it sits close to the heading it precedes. */
.back-to-blog-top {
    margin: 0 auto 1.5rem;
}

.back-to-blog a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

/* Draft preview banner --------------------------------------------------- */

.preview-banner {
    background: #fff4d6;
    border: 1px solid #f0dca8;
    border-radius: 5px;
    color: #6b5312;
    padding: 0.8rem 1.1rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
}

.preview-banner a {
    color: #6b5312;
    font-weight: 600;
}

/* 404 -------------------------------------------------------------------- */

.notice-page {
    max-width: 34rem;
    margin: 0 auto;
    padding: 3rem 0;
    text-align: center;
}

.notice-page h1 {
    font-size: 1.8rem;
    margin: 0 0 0.75rem;
    color: var(--text);
}

.notice-page p {
    color: var(--text-soft);
    margin: 0 0 1rem;
}

.notice-page a {
    color: var(--primary);
    font-weight: 600;
}

/* Small screens ---------------------------------------------------------- */

@media (max-width: 40rem) {
    .article-title { font-size: 1.65rem; }
    .blog-header h1 { font-size: 1.7rem; }
    .post-grid { gap: 1.25rem; }
    .article-nav-link.is-next { text-align: left; }
}
