/* ==========================================================================
   blog.css  --  blog listing and single post
   All selectors are prefixed .blog- to stay clear of dashboard.css.
   ========================================================================== */

.blog-wrap {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 24px;
    align-items: start;
}

/* ---- filter panel ------------------------------------------------------- */
/* Sticky rather than fixed. The dashboard sidebar is fixed and translates off
   the left edge; this one lives in the content flow so that when the grid
   collapses it simply stacks above the list instead of sliding in. */
.blog-filters {
    position: sticky;
    top: calc(var(--header-height, 60px) + 16px);
    max-height: calc(100vh - var(--header-height, 60px) - 32px);
    overflow-y: auto;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 16px;
}

.blog-filter-toggle {
    display: none;
}

.blog-filter-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.blog-filter-head h4 {
    margin: 0;
    font-size: .95rem;
}

.blog-clear {
    font-size: .78rem;
    color: var(--text-muted, #6b7280);
}

.blog-filter-group {
    margin-bottom: 18px;
}

.blog-filter-label {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-muted, #6b7280);
    margin-bottom: 7px;
}

.blog-search {
    width: 100%;
    padding: 7px 10px;
    border: 1px solid var(--border-color, #ccd2dc);
    border-radius: 5px;
    font: inherit;
    font-size: .88rem;
    box-sizing: border-box;
}

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

.blog-facet li {
    margin-bottom: 3px;
}

.blog-facet label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 6px;
    border-radius: 4px;
    cursor: pointer;
    font-size: .87rem;
}

.blog-facet label:hover {
    background: var(--hover-bg, #f4f6f9);
}

.blog-facet input {
    margin: 0;
    flex: none;
}

.blog-facet-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.blog-facet-count {
    flex: none;
    font-size: .75rem;
    color: var(--text-muted, #6b7280);
    background: var(--hover-bg, #eef1f5);
    border-radius: 10px;
    padding: 1px 7px;
}

.blog-facet-any {
    font-style: italic;
    color: var(--text-muted, #6b7280);
}

/* Tag lists grow without bound, so cap the height rather than pushing the
   rest of the panel off-screen. */
.blog-facet-scroll {
    max-height: 260px;
    overflow-y: auto;
}

/* ---- list --------------------------------------------------------------- */
.blog-list-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.blog-result-count {
    font-size: .85rem;
    color: var(--text-muted, #6b7280);
}

/* .blog-new-btn moved to css/global.css, where it is defined as .solid-btn with
   .blog-new-btn kept as an alias -- so the markup here is unchanged.
   It left because this stylesheet only loads on the dashboard, and the button
   is used in the editor too. New markup should ask for .solid-btn. */

.blog-card {
    display: flex;
    gap: 16px;
    background: var(--card-bg, #fff);
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 14px;
}

.blog-card-img {
    flex: none;
    width: 180px;
}

/* The placeholder is decoration, not content, so it sits back a little rather
   than competing with real hero images further down the list. */
.blog-card-img-default img {
    opacity: .55;
}

.blog-card-img img {
    width: 100%;
    max-height: 200px;
    object-fit: contain;
    border-radius: 6px;
    display: block;
}

.blog-card-body {
    flex: 1 1 auto;
    min-width: 0;
}

.blog-card-title {
    margin: 8px 0 6px;
    font-size: 1.12rem;
    line-height: 1.3;
}

.blog-card-title a {
    color: inherit;
    text-decoration: none;
}

.blog-card-title a:hover {
    color: var(--primary, #e85347);
}

.blog-card-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    font-size: .78rem;
    color: var(--text-muted, #6b7280);
    margin-bottom: 8px;
}

.blog-card-excerpt {
    margin: 0 0 10px;
    font-size: .9rem;
    line-height: 1.5;
    color: var(--text-body, #4b5563);
}

.blog-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.blog-chip {
    display: inline-block;
    font-size: .74rem;
    padding: 2px 9px;
    border-radius: 11px;
    background: var(--hover-bg, #eef1f5);
    color: var(--text-muted, #4b5563);
    text-decoration: none;
}

.blog-chip:hover {
    background: var(--border-color, #dfe3ea);
}

.blog-chip-cat {
    background: rgba(232, 83, 71, .1);
    color: var(--primary, #e85347);
    font-weight: 600;
}

.blog-post-head .blog-chip-cat {
    font-size: .86rem;
    padding: 3px 12px;
    border-radius: 13px;
}

.blog-empty {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted, #6b7280);
}

.blog-empty i {
    font-size: 2rem;
    opacity: .35;
}

.blog-empty p {
    margin: 0;
}

.blog-pager {
    display: flex;
    gap: 6px;
    justify-content: center;
    margin-top: 22px;
    flex-wrap: wrap;
}

.blog-page {
    min-width: 34px;
    padding: 6px 10px;
    text-align: center;
    border: 1px solid var(--border-color, #e5e7eb);
    border-radius: 5px;
    text-decoration: none;
    color: inherit;
    font-size: .85rem;
}

.blog-page:hover {
    background: var(--hover-bg, #f4f6f9);
}

.blog-page.current {
    background: var(--primary, #e85347);
    border-color: var(--primary, #e85347);
    color: #fff;
}

.blog-list.is-loading {
    opacity: .45;
    pointer-events: none;
    transition: opacity .12s;
}

/* ---- single post -------------------------------------------------------- */
.blog-post {
    max-width: 760px;
    margin: 0 auto;
}

.blog-post-nav {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.blog-post-head {
    margin-bottom: 20px;
}

.blog-post-title {
    font-size: 2rem;
    line-height: 1.2;
    margin: 10px 0 12px;
}

.blog-post-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
    font-size: .85rem;
    color: var(--text-muted, #6b7280);
}

/* Mirrors the byline on script summary pages. */
.blog-author {
    display: flex;
    align-items: center;
    gap: 8px;
    width: fit-content;
}

.blog-author-avatar {
    width: 32px;
    height: 32px;
    flex: none;
    border-radius: 50%;
    background: var(--primary-dim);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    overflow: hidden;
}

.blog-author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.blog-author-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.blog-draft-badge {
    background: #fef3c7;
    color: #92400e;
    padding: 2px 9px;
    border-radius: 4px;
    font-weight: 600;
}

.blog-post-hero {
    width: 100%;
    max-height: 500px;
    /* contain, not cover: a hero is chosen for what it shows, so constraining a
       tall image beats cropping its subject out. Background stays transparent --
       a fill behind a narrow image reads as a rendering artifact. */
    object-fit: contain;
    border-radius: 8px;
    margin-bottom: 24px;
    display: block;
}

.blog-post-content {
    font-size: 1.03rem;
    line-height: 1.7;
}

.blog-post-content p {
    margin: 0 0 1.15em;
}

.blog-post-content h2 {
    font-size: 1.5rem;
    margin: 1.8em 0 .6em;
}

.blog-post-content h3 {
    font-size: 1.22rem;
    margin: 1.5em 0 .5em;
}

/* Editor content can carry explicit width/height attributes; override so wide
   images cannot break the column on small screens. */
.blog-post-content img {
    max-width: 100%;
    /* Uploads are capped at 1600px on the long edge, so a portrait shot can still
       run several screens tall inline. 70vh keeps any single image within roughly
       one screen without hardcoding a pixel height that fights small viewports. */
    max-height: 70vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 6px;
}

.blog-post-content iframe {
    max-width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border-radius: 6px;
}

.blog-post-content table {
    max-width: 100%;
}

.blog-post-content blockquote {
    margin: 1.4em 0;
    padding: .3em 0 .3em 1.1em;
    border-left: 3px solid var(--primary, #e85347);
    color: var(--text-muted, #4b5563);
}

/* Sits directly under the category chip, so the spacing is tight above and
   opens up before the title. */
.blog-post-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
    margin: 8px 0 0;
}

/* The listing chips are deliberately small; at the top of a post they are a real
   navigation affordance and need to be readable. */
.blog-post-tags .blog-chip {
    font-size: .86rem;
    padding: 3px 12px;
    border-radius: 13px;
}

.blog-post-foot {
    display: flex;
    gap: 18px;
    margin-top: 28px;
    padding-top: 18px;
    border-top: 1px solid var(--border-color, #e5e7eb);
}

.blog-back {
    font-size: .88rem;
    text-decoration: none;
    color: var(--text-muted, #6b7280);
}

.blog-back:hover {
    color: var(--primary, #e85347);
}

/* ---- narrow layout ------------------------------------------------------ */
/* 900px, well below the 1200px breakpoint where the dashboard sidebar hides,
   so the two collapses never happen at the same moment. */
@media (max-width: 900px) {
    .blog-wrap {
        grid-template-columns: minmax(0, 1fr);
    }

    .blog-filter-toggle {
        display: flex;
        align-items: center;
        gap: 8px;
        width: 100%;
        padding: 10px 14px;
        background: var(--card-bg, #fff);
        border: 1px solid var(--border-color, #e5e7eb);
        border-radius: 8px;
        font: inherit;
        font-size: .9rem;
        font-weight: 600;
        cursor: pointer;
    }

    .blog-filter-caret {
        margin-left: auto;
        transition: transform .18s;
    }

    .blog-filter-toggle.open .blog-filter-caret {
        transform: rotate(180deg);
    }

    /* Static, not sticky: pinning a full-height panel above the list on a phone
       leaves nothing visible to scroll. */
    .blog-filters {
        display: none;
        position: static;
        max-height: none;
        margin-top: 10px;
    }

    .blog-filters.open {
        display: block;
    }

    .blog-card {
        flex-direction: column;
    }

    .blog-card-img {
        width: 100%;
    }

    .blog-post-title {
        font-size: 1.55rem;
    }
}

/* ---- staff-only view controls ------------------------------------------- */
.blog-staff-only {
    border: 1px dashed var(--border-color, #d6d0bf);
    border-radius: 6px;
    padding: 10px 12px;
    background: rgba(0, 0, 0, .015);
}

.blog-staff-only .blog-filter-label {
    margin-bottom: 5px;
}

.blog-status-badge {
    display: inline-block;
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 2px 8px;
    border-radius: 4px;
    margin-right: 6px;
    background: #e5e7eb;
    color: #4b5563;
}

.blog-status-draft {
    background: #fef3c7;
    color: #92400e;
}

.blog-status-scheduled,
.blog-status-published {
    background: #dbeafe;
    color: #1e40af;
}

.blog-status-archived {
    background: #f3f4f6;
    color: #6b7280;
}

.blog-card-edit {
    display: inline-block;
    font-size: .78rem;
    margin: 0 0 8px;
    text-decoration: none;
    color: var(--text-muted, #6b7280);
}

.blog-card-edit:hover {
    color: var(--primary, #e85347);
}