/* ===== Blog admin editor ===== */

.blog-editor-toolbar {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .5rem .75rem;
    border: 1px solid var(--bs-border-color);
    border-bottom: 0;
    background: var(--bs-body-bg);
    border-top-left-radius: .375rem;
    border-top-right-radius: .375rem;
}

.blog-editor-toolbar-left {
    display: flex;
    align-items: center;
    flex: 1;
    min-width: 0;
    gap: .5rem;
}

.blog-editor-toolbar-right {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-shrink: 0;
}

.blog-editor-title-input {
    flex: 1;
    min-width: 0;
    font-size: 1.125rem;
    font-weight: 600;
    border: 1px solid transparent;
    background: transparent;
    padding: .375rem .5rem;
    border-radius: .25rem;
    outline: none;
    color: var(--bs-body-color);
}

.blog-editor-title-input:focus {
    border-color: var(--bs-primary);
    background: var(--bs-body-bg);
}

.blog-editor-title-error {
    border-color: var(--bs-danger) !important;
    background: rgba(220, 53, 69, 0.05) !important;
}

.blog-editor-layout {
    display: flex;
    gap: 0;
    border: 1px solid var(--bs-border-color);
    border-top: 0;
    border-bottom-left-radius: .375rem;
    border-bottom-right-radius: .375rem;
    /* Fixed height so the MarkdownEditor's MinHeight="100%" fills the available
       space instead of collapsing to its default 300px. Subtract the host
       chrome (topbar ~60px + editor toolbar ~52px + a small breathing gutter)
       from the viewport. */
    height: calc(100vh - 140px);
    overflow: hidden;
}

.blog-editor-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: .75rem;
}

.blog-editor-main .EasyMDEContainer {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.blog-editor-main .EasyMDEContainer .CodeMirror {
    flex: 1;
    overflow-y: auto;
}

.blog-editor-sidebar {
    width: 320px;
    min-width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    border-left: 1px solid var(--bs-border-color);
    padding: 1rem;
    overflow-y: auto;
}

.blog-editor-section {
    padding-bottom: .75rem;
    border-bottom: 1px dashed var(--bs-border-color);
}

.blog-editor-section:last-child {
    border-bottom: 0;
}

@media (max-width: 991.98px) {
    .blog-editor-layout {
        flex-direction: column;
        height: auto;
        min-height: calc(100vh - 140px);
    }

    .blog-editor-main {
        min-height: 60vh;
    }

    .blog-editor-sidebar {
        width: 100%;
        border-left: 0;
        border-top: 1px solid var(--bs-border-color);
        max-height: none;
        overflow-y: visible;
    }
}

/* ===== Post-link picker modal ===== */

.blog-link-picker-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 1050;
}

.blog-link-picker {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(460px, 92vw);
    max-height: 80vh;
    background: var(--bs-body-bg);
    border: 1px solid var(--bs-border-color);
    border-radius: .375rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .3);
    z-index: 1055;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.blog-link-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--bs-border-color);
}

.blog-link-picker-list {
    max-height: 50vh;
    overflow-y: auto;
}

/* ===== Public blog listing + post ===== */

.blog-public {
    max-width: 1000px;
}

.blog-card-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

/* ===== Layout containers ===== */

.blog-card-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* ===== Card base ===== */

.blog-card {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--bs-border-color);
    border-radius: .5rem;
    background: var(--bs-body-bg);
    overflow: hidden;
    transition: transform .15s, box-shadow .15s;
}

.blog-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 28px rgba(0, 0, 0, .10);
    border-color: var(--bs-primary);
}

.blog-card .blog-card-readmore {
    color: var(--bs-primary);
    text-decoration: none;
    transition: gap .15s;
    display: inline-flex;
    align-items: center;
    gap: .3rem;
}

.blog-card:hover .blog-card-readmore {
    gap: .55rem;
}

.blog-card-pinned {
    border-color: var(--bs-warning);
}

.blog-card-image {
    display: block;
    aspect-ratio: 16 / 9;
    background: var(--bs-tertiary-bg);
    overflow: hidden;
    flex-shrink: 0;
}

.blog-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform .2s;
}

.blog-card:hover .blog-card-image img {
    transform: scale(1.03);
}

.blog-card-body {
    padding: 1rem 1.25rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
}

.blog-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0;
}

.blog-card-tags .badge {
    font-weight: 500;
}

/* ===== Image-position variants ===== */

/* Horizontal row: image next to the body. */
.blog-card-image-left,
.blog-card-image-right {
    flex-direction: row;
    align-items: stretch;
}

.blog-card-image-left > .blog-card-image,
.blog-card-image-right > .blog-card-image {
    width: 35%;
    min-width: 140px;
    max-width: 280px;
    aspect-ratio: auto;
}

.blog-card-image-right {
    flex-direction: row-reverse;
}

/* Hero: taller image on top (full-width) for a headliner card. */
.blog-card-image-hero > .blog-card-image {
    aspect-ratio: 21 / 9;
    min-height: 240px;
}

.blog-card-image-hero .blog-card-body {
    padding: 1.5rem 1.75rem;
}

.blog-card-image-hero h2 {
    font-size: 1.75rem;
}

/* No image: body fills the whole card. */
.blog-card-image-none > .blog-card-image { display: none; }

/* Compact layout collapse: when there's no image at all, reduce padding. */
.blog-card-image-none .blog-card-body {
    padding: .75rem 1rem;
}

.blog-card-image-none .blog-card-readmore { display: none; }

@media (max-width: 575.98px) {
    .blog-card-image-left,
    .blog-card-image-right {
        flex-direction: column;
    }
    .blog-card-image-left > .blog-card-image,
    .blog-card-image-right > .blog-card-image {
        width: 100%;
        max-width: none;
        aspect-ratio: 16 / 9;
    }
}

.blog-post-hero {
    margin: 0;
    border-radius: .5rem;
    overflow: hidden;
    background: var(--bs-tertiary-bg);
}

.blog-post-hero img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 500px;
    object-fit: cover;
}

.blog-post-excerpt {
    color: var(--bs-body-color);
    border-left: 4px solid var(--bs-primary);
    padding: .25rem 0 .25rem 1rem;
    font-style: italic;
}

.blog-post-body {
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--bs-body-color);
}

.blog-post-body h2,
.blog-post-body h3,
.blog-post-body h4 {
    margin-top: 2rem;
    margin-bottom: .75rem;
    font-weight: 600;
}

.blog-post-body p {
    margin-bottom: 1.25rem;
}

.blog-post-body img {
    max-width: 100%;
    height: auto;
    border-radius: .375rem;
    margin: 1rem 0;
}

.blog-post-body blockquote {
    border-left: 4px solid var(--bs-border-color);
    padding: .5rem 1rem;
    color: var(--bs-secondary-color);
    margin: 1.25rem 0;
}

.blog-post-body pre {
    background: var(--bs-tertiary-bg);
    padding: 1rem;
    border-radius: .375rem;
    overflow-x: auto;
}

.blog-post-body code:not(pre code) {
    background: var(--bs-tertiary-bg);
    padding: .1em .35em;
    border-radius: .25rem;
    font-size: .9em;
}

.blog-post-body a {
    color: var(--bs-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

.blog-post-body a:hover {
    text-decoration-thickness: 2px;
}

.blog-post-body ul,
.blog-post-body ol {
    margin-bottom: 1.25rem;
}

/* ===== Sidebar blocks ===== */

.blog-block {
    margin-bottom: 1.5rem;
}

/* Consistent header across every sidebar widget: small caps, primary-
   coloured left accent. Applies to any h3 inside a .blog-block-*
   section so hosts don't have to style per-block. */
.blog-block-latest > h3,
.blog-block-featured > h3,
.blog-block-pinned > h3,
.blog-block-categories > h3,
.blog-block-tagcloud > h3,
.blog-block-archive > h3,
.blog-block-post-list > h3 {
    position: relative;
    font-size: .85rem;
    letter-spacing: .06em;
    text-transform: uppercase;
    padding-left: .75rem;
    margin-bottom: .9rem;
}

.blog-block-latest > h3::before,
.blog-block-featured > h3::before,
.blog-block-pinned > h3::before,
.blog-block-categories > h3::before,
.blog-block-tagcloud > h3::before,
.blog-block-archive > h3::before,
.blog-block-post-list > h3::before {
    content: "";
    position: absolute;
    left: 0;
    top: .2em;
    bottom: .2em;
    width: 3px;
    border-radius: 2px;
    background: var(--bs-primary);
}

.blog-block-nav {
    margin-bottom: 0;
}

.blog-block-nav li {
    border-bottom: 1px solid var(--bs-border-color);
}

.blog-block-nav li:last-child {
    border-bottom: 0;
}

.blog-block-nav a {
    display: flex;
    justify-content: space-between;
    padding: .45rem .25rem;
    color: var(--bs-body-color);
    text-decoration: none;
    border-radius: .25rem;
}

.blog-block-nav a:hover {
    background: var(--bs-tertiary-bg);
    color: var(--bs-primary);
}

/* ===== Tag cloud ===== */

.blog-tag-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem .5rem;
    line-height: 1.8;
}

.blog-tag-cloud-item {
    color: var(--bs-primary);
    text-decoration: none;
    opacity: .85;
    transition: opacity .1s;
}

.blog-tag-cloud-item:hover {
    opacity: 1;
    text-decoration: underline;
}

/* ===== Public comments ===== */

.blog-comment-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Child list sits inside its parent's <li>. Padding-left produces the
   nesting indent; depth-capped via .blog-comment-depth-N classes below
   so runaway threads don't drift off-screen. */
.blog-comment-children {
    margin-top: 1rem;
    padding-left: 1.5rem;
    border-left: 2px solid var(--bs-border-color);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Depth 5+ stops adding visual indent — the replies keep threading,
   they just don't push further right. */
.blog-comment-depth-5 .blog-comment-children,
.blog-comment-depth-6 .blog-comment-children,
.blog-comment-depth-7 .blog-comment-children,
.blog-comment-depth-8 .blog-comment-children {
    padding-left: 0.5rem;
    border-left-color: transparent;
}

@media (max-width: 575.98px) {
    /* On phones, tighten the indent so deep replies don't push the
       reading column into single-word lines. */
    .blog-comment-children {
        padding-left: 0.75rem;
    }
}

.blog-comment-card {
    padding: 1rem 1.25rem;
    background: var(--bs-tertiary-bg);
    border-radius: .5rem;
    border-left: 3px solid var(--bs-primary);
}

.blog-comment-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: .5rem;
    margin-bottom: .5rem;
}

.blog-comment-body {
    color: var(--bs-body-color);
    line-height: 1.6;
}

.blog-comment-reply {
    margin-top: .75rem;
}

.blog-comment-reply summary {
    cursor: pointer;
    user-select: none;
}

.blog-comment-reply summary:hover {
    color: var(--bs-primary);
}

/* Honeypot — visually hidden but still focusable so accessibility
   tooling sees it (we don't want to game a11y). Bots typically don't
   render CSS but do fill the form; legitimate users never touch it. */
.blog-comment-honeypot {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.blog-comment-form-reply .form-control-sm,
.blog-comment-form-reply textarea {
    font-size: .875rem;
}
