/* Blog styles: card layout, sidebar tweaks, and responsive spacing */

/* Blog styles should use centralized brand tokens defined in the compiled stylesheet (e.g. src/output.css) */

.blog-hero {
    background: linear-gradient(180deg, rgba(99,102,241,0.06), rgba(236,72,153,0.03));
}

article.post-card {
    /* ensure cards are column flex containers and can stretch to match
       their grid/flex row siblings so footers (CTA + avatar) align */
    display: flex;
    flex-direction: column;
    height: 100%;
    transition: transform .15s ease, box-shadow .15s ease;
}
article.post-card:hover {
    transform: translateY(-6px);
}

.page-blog .search-form input[type="search"] {
    padding: var(--space-sm) .75rem;
    border-radius: .375rem;
    border: 1px solid var(--brand-border);
}

@media (min-width: 1024px) {
    .page-blog main {
        min-height: 400px;
    }
}

/* Small adjustments to pagination */
.pagination {
    display: flex;
    gap: .5rem;
}

.pagination .page-numbers {
    padding: var(--space-sm) .75rem;
    border-radius: .375rem;
    border: 1px solid var(--brand-border);
}

.pagination .current {
    background: var(--brand-primary);
    color: #fff;
    border-color: transparent;
}

/* Breadcrumb styles (scoped to blog templates) */
.page-blog nav[aria-label="Breadcrumb"] ol {
    display: flex;
    gap: .5rem;
    align-items: center;
}
.page-blog nav[aria-label="Breadcrumb"] a {
    color: var(--brand-muted);
    text-decoration: none;
}
.page-blog nav[aria-label="Breadcrumb"] a:hover {
    color: var(--brand-accent);
}
.page-blog nav[aria-label="Breadcrumb"] li + li {
    margin-left: 0.25rem;
}

/* Breadcrumb responsive behavior and truncation */
nav[aria-label="Breadcrumb"], .breadcrumb, .breadcrumbs {
    font-size: .95rem;
}
nav[aria-label="Breadcrumb"] ol, .breadcrumb, .breadcrumbs {
    display: flex;
    align-items: center;
    gap: .5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    overflow: hidden;
}
nav[aria-label="Breadcrumb"] li, .breadcrumb li, .breadcrumbs li {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
@media (max-width: 768px) {
    nav[aria-label="Breadcrumb"] a, .breadcrumb a { display: inline-block; max-width: 6.5rem; overflow: hidden; text-overflow: ellipsis; }
}

/* Disable breadcrumb truncation on WooCommerce product and products (archive) pages */
body.single-product nav[aria-label="Breadcrumb"] a,
body.single-product nav[aria-label="Breadcrumb"] span,
body.post-type-archive-product nav[aria-label="Breadcrumb"] a,
body.post-type-archive-product nav[aria-label="Breadcrumb"] span {
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
}

body.single-product nav[aria-label="Breadcrumb"] li,
body.post-type-archive-product nav[aria-label="Breadcrumb"] li {
    white-space: normal;
    overflow: visible;
}

/* Breadcrumb separators are inserted by JS as inline SVG elements inside the
    previous visible <li> (class `.planc-sep`). This avoids duplicate or dangling
    separators when intermediate breadcrumb items are hidden. */
.planc-breadcrumb-wrap {
    max-width: 100%;
    margin: 0 auto 1rem;
}

/* Breadcrumb list layout */
nav[aria-label="Breadcrumb"] ol, .breadcrumb, .breadcrumbs {
    display: flex;
    align-items: center;
    gap: .25rem;
    list-style: none;
    padding: 0;
    margin: 0;
    flex-wrap: wrap;
}

.breadcrumb-item {
    display: inline-flex;
    align-items: center;
    color: var(--brand-muted, #6b7280);
    font-weight: 500;
}

.breadcrumb-item a {
    color: inherit;
    text-decoration: none;
}
.breadcrumb-item a,
.breadcrumb-item span {
    /* ensure anchors and spans inside breadcrumb items align their content
       to the center so the separator (SVG background) sits perfectly level */
    display: inline-flex;
    align-items: center;
    line-height: 1;
}
.breadcrumb-item { line-height: 1; }
.breadcrumb-item a:hover { color: var(--brand-accent); text-decoration: underline; }

/* Separator shown via class added by JS to visible items */
.planc-sep {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: .88em;
    height: .88em;
    margin-left: .35rem;
    margin-right: .25rem;
    vertical-align: middle;
    color: var(--brand-muted, #9ca3af);
    flex: 0 0 auto;
}
.planc-sep svg { width: 100%; height: 100%; display: block; stroke-width: 1.6; }

/* Numeric ID badge for last breadcrumb on mobile */
.planc-breadcrumb-id > a, .planc-breadcrumb-id > span {
    display: inline-block;
    background: rgba(59,130,246,0.08); /* subtle blue tint */
    color: var(--brand-primary, #3b82f6);
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-weight: 700;
    font-size: 0.9rem;
    border: 1px solid rgba(59,130,246,0.12);
}

/* Truncated last breadcrumb when not numeric (lighter style) */
.breadcrumb-truncated a, .breadcrumb-truncated span {
    display: inline-block;
    max-width: 12ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    color: var(--brand-text, #111827);
}


/* Card content: ensure excerpts don't grow cards unevenly. Clamp to 3 lines. */
.entry-excerpt {
    display: -webkit-box;
    /* preferred modern property (some linters request it) */
    line-clamp: 6;
    -webkit-line-clamp: 6;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Ensure the immediate card body grows to push the footer down so CTAs align */
article.post-card .entry-content,
article.post-card .post-card-body,
article.post-card .card-body,
article.post-card .post-content {
    flex: 1 1 auto;
}

/* Anchor footer/CTA to the bottom of the card */
article.post-card .entry-footer,
article.post-card .post-card-footer,
article.post-card .card-footer {
    margin-top: auto;
}

/* Encourage grid/flex parents to allow children to stretch vertically.
   Add some common wrapper selectors used by themes/blocks; keep this
   lightweight so it won't interfere with unrelated components. */
.page-blog .posts-grid,
.page-blog .posts-list,
.page-blog .cards,
.page-blog .post-list,
.posts-grid,
.posts-list,
.cards,
.post-list,
.wp-block-query .wp-block-post-template {
    align-items: stretch;
}

/* Clamp titles to two lines to avoid pushing CTA/author alignment out of sync. 
   This block is written to be robust against utility classes that may force
   anchors or headings to inline-flex/inline-block. We set an explicit
   line-height and a calc'd max-height so non-WebKit UAs that respect max-height
   also hide overflow. Use !important sparingly but where needed to override
   higher-specificity utility rules from the compiled CSS. */
main#primary .entry-title {
    /* predictable line-height for max-height calc */
    /* keep a defensive fallback for any non-scoped usage */
    line-height: 1.2;
}
/* Stronger rules: ensure both the heading and the anchor are block-level and use
   the -webkit-box model so clamping works even when utility classes apply to
   either the h2 or the anchor. We explicitly set display:block first, then
   the -webkit-box display for webkit line-clamp support. */
main#primary article.post-card h2.entry-title,
main#primary article.post-card h2.entry-title > a,
main#primary article.post-card .entry-title,
main#primary article.post-card .entry-title > a,
main#primary article.post-card .entry-title a {
    /* make the text container a WebKit box so -webkit-line-clamp works */
    display: block;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    /* standard property for linters/modern UAs */
    line-clamp: 2;

    /* hide anything beyond two lines */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: normal; /* ensure wrapping inside the box */
    word-break: break-word;

    /* a hard constraint to help non-webkit UAs: 2 * line-height */
    max-height: calc(2 * 1.2em);
    width: 100%;
}

/* If the anchor wraps inner inline elements, ensure those don't force an inline formatting context */
main#primary article.post-card .entry-title a > * {
    display: inline;
}

@media (max-width: 768px) {
    nav[aria-label="Breadcrumb"] { font-size: 0.95rem; }
    .planc-breadcrumb-wrap { padding: 0 .75rem; }
    /* slightly smaller badge on narrow devices */
    .planc-breadcrumb-id > a, .planc-breadcrumb-id > span {
        padding: 0.12rem 0.38rem;
        font-size: 0.82rem;
    }

/* Temporary homepage layout fallbacks removed — rely on compiled utilities (src/output.css) */

/* Article meta (author box + reading time) */
.planc-article-meta {
    display: block;
    background: #ffffff;
    border: 1px solid var(--brand-border-2);
}
.planc-article-meta .avatar {
    border-radius: 9999px;
    overflow: hidden;
}
.planc-article-meta .text-sm a {
    color: var(--brand-text);
}
.planc-article-meta .text-gray-500 {
    color: var(--brand-muted);
}

/* Reading time badge */
.planc-article-meta .reading-time {
    display: inline-block;
    background: var(--brand-badge-bg);
    color: var(--brand-accent);
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 0.5rem;
}

/* Category chips */
.page-blog .mb-4.text-sm a {
    display: inline-block;
    padding: var(--space-xs) 0.5rem;
    background: var(--brand-bg);
    border-radius: 9999px;
    border: 1px solid var(--brand-border-2);
}
.page-blog .mb-4.text-sm a:hover {
    background: var(--brand-chip-hover);
    border-color: var(--brand-chip-border);
}

/* Single post content spacing tweaks */
@media (min-width: 768px) {
    .planc-article-meta { padding: 1rem; }
}

/* Constrain content images and embeds to the article/content width
   This prevents very large images from overflowing or appearing visually full-width
   and keeps them centered to match the header/content column. */
.prose img,
.entry-content img,
.post img {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1.25rem auto;
    border-radius: 0.5rem;
}

.prose figure,
.entry-content figure,
.post figure {
    max-width: 100%;
    margin: 0 auto 1.25rem;
}

/* Gutenberg wide images: keep them within content column */
.entry-content .alignwide, .entry-content .wp-block-image.alignwide {
    max-width: 100%;
}

.entry-content iframe,
.entry-content embed,
.entry-content video {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 1rem auto;
}

/* Fix comment / footer layout on single posts
   - constrain comment form and tags to content width
   - ensure flex in footer wraps nicely and centers on narrow screens
   - make form inputs full width inside the constrained column */
.single .entry-footer,
.single .comments-area,
.single .comment-respond {
    max-width: 56rem; /* matches max-w-4xl */
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

.single .entry-footer .flex {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
}

.single .entry-footer .flex > div,
.single .entry-footer .flex > .author-box {
    flex: 0 1 auto;
}

/* Stack and center share button under author on small screens */
@media (max-width: 767px) {
    .single .entry-footer .flex {
        flex-direction: column;
        text-align: center;
    }
    .single .entry-footer .flex > div {
        width: 100%;
        margin-bottom: 0.75rem;
    }
}

/* Comment form fields full width and readable */
.comment-respond .comment-form input[type="text"],
.comment-respond .comment-form input[type="email"],
.comment-respond .comment-form input[type="url"],
.comment-respond .comment-form textarea,
.comment-respond .comment-form input[type="search"] {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: .6rem .7rem;
    border: 1px solid var(--brand-border-2);
    border-radius: .375rem;
    background: #fff;
}

.comment-respond .comment-form p.form-submit {
    text-align: left;
}

/* Keep comment list centered */
.comment-list {
    max-width: 56rem;
    margin: 1.5rem auto;
    padding: 0 1rem;
}

/* Ensure the overall comments wrapper matches the article/content width
   so comments don't render full-bleed across the container. The article
   content uses max-w-4xl (≈56rem), so constrain the comments area to the
   same width and let inner lists/forms size to 100% of that area. */
#comments, .comments-area {
    max-width: 56rem;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}
.comments-area .comment-list,
.comments-area .comment-respond {
    max-width: 100%;
}

/* Small visual tweak: author box spacing */
.entry-footer .avatar {
    margin-right: .75rem;
}

/* Comment list and form — improved layout and spacing */
.comment-list .comment {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    margin-bottom: 1.25rem;
}
.comment-list .comment .comment-body {
    flex: 1 1 auto;
}
.comment-list .comment .comment-author img,
.comment-list .comment .avatar img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 9999px;
    display: block;
}
.comment-list .comment .fn {
    font-weight: 600;
    color: var(--brand-text, #111827);
}
.comment-list .comment .comment-meta {
    font-size: 0.875rem;
    color: var(--brand-muted, #6b7280);
    margin-bottom: 0.5rem;
}
.comment-list .comment .comment-content {
    color: var(--brand-text, #111827);
    line-height: 1.6;
}
.comment-list .children {
    margin-left: 3rem;
}

/* Comment form adjustments */
.comment-respond {
    max-width: 56rem;
    margin: 1.5rem auto 2rem;
    padding: 1rem;
    background: #fff;
    border: 1px solid var(--brand-border-2);
    border-radius: .75rem;
}
.comment-respond .comment-form .comment-form-comment textarea {
    min-height: 140px;
}
.comment-respond .comment-form .form-row {
    display: flex;
    gap: .75rem;
}
.comment-respond .comment-form .form-row .form-field {
    flex: 1 1 auto;
}
.comment-respond .comment-form p.form-submit {
    text-align: right;
    margin-top: .75rem;
}

/* Ensure each form row has clear vertical spacing when stacked
   (some resets remove default paragraph spacing). Also give inputs
   a small top margin so labels (sr-only) don't visually clash. */
.comment-respond .comment-form p.form-row {
    margin-bottom: .75rem;
}
.comment-respond .comment-form p.form-row input,
.comment-respond .comment-form p.form-row textarea {
    margin-top: .25rem;
}

@media (max-width: 767px) {
    .comment-list .comment { flex-direction: row; }
    .comment-list .children { margin-left: 1.25rem; }
    .comment-respond .comment-form .form-row { flex-direction: column; }
    .comment-respond .comment-form p.form-submit { text-align: center; }
}

/* Additional WP default markup compatibility fixes */
ol.comment-list, ul.comment-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
ol.comment-list > li.comment, ul.comment-list > li.comment {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(0,0,0,0.04);
}
.comment-reply-title {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
}
.comment-respond .comment-form label {
    display: block;
    margin-bottom: .35rem;
    font-size: .9rem;
    color: var(--brand-muted, #6b7280);
}
.comment-respond .comment-form input[type="text"],
.comment-respond .comment-form input[type="email"],
.comment-respond .comment-form input[type="url"],
.comment-respond .comment-form textarea {
    display: block;
    width: 100%;
}
.comment-form-author,
.comment-form-email,
.comment-form-url {
    margin-bottom: .75rem;
}
.comment-respond .logged-in-as {
    margin-bottom: .75rem;
    font-size: .9rem;
}
