/* Archive header */
.archive-header {
    margin-bottom: 2rem;
}

.archive-header__title {
    font-size: clamp(1.6rem, 4vw, 2.25rem);
    margin-bottom: 0.5rem;
}

.archive-header__desc {
    color: var(--text-secondary);
    max-width: 42rem;
}

.archive-footer-content {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.archive-footer-content__inner {
    max-width: 48rem;
    margin-inline: auto;
}

.archive-footer-content__inner.rte-content {
    font-size: 1rem;
    line-height: 1.75;
    color: var(--text-secondary);
}

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-muted);
    background: var(--card-bg);
    border: 1px dashed var(--border);
    border-radius: var(--radius-md);
}

/* Post grid + cards */
.archive-infinite {
    margin-top: 1.5rem;
}

.archive-infinite__sentinel {
    height: 1px;
}

.archive-infinite__status,
.archive-infinite__end {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.92rem;
    margin: 1rem 0 0;
}

.post-card {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.post-card:hover {
    transform: translateY(-3px);
    border-color: color-mix(in srgb, var(--accent) 40%, var(--border));
    box-shadow: var(--shadow-md);
}

.post-card__media {
    display: block;
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--bg-secondary);
    overflow: hidden;
}

.post-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.post-card__media--has-video::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(15, 23, 42, 0.35));
    pointer-events: none;
}

.post-card__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.post-card__play-btn {
    width: 3rem;
    height: 3rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.42);
    border: 2px solid rgba(255, 255, 255, 0.75);
    color: rgba(255, 255, 255, 0.85);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.post-card__media--has-video:hover .post-card__play-btn {
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent);
    transform: scale(1.06);
}

.post-card__placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--accent-ink, var(--accent));
    font-weight: 700;
    font-size: 1.5rem;
    background: var(--accent-soft);
}

.post-card__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1rem;
}

.post-card__title {
    font-size: 1.1rem;
    line-height: 1.5;
}

.post-card__title a {
    color: var(--text-primary);
}

.post-card__title a:hover {
    color: var(--accent-ink, var(--accent));
}

.post-card__excerpt {
    color: var(--text-secondary);
    font-size: 0.92rem;
    flex: 1;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.post-card__excerpt--lines-1 { -webkit-line-clamp: 1; }
.post-card__excerpt--lines-2 { -webkit-line-clamp: 2; }
.post-card__excerpt--lines-3 { -webkit-line-clamp: 3; }
.post-card__excerpt--lines-4 { -webkit-line-clamp: 4; }
.post-card__excerpt--lines-5 { -webkit-line-clamp: 5; }
.post-card__excerpt--lines-6 { -webkit-line-clamp: 6; }

.post-card__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border);
    padding-top: 0.6rem;
}

.post-card__date,
.single-post__date {
    unicode-bidi: plaintext;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

/* Pagination */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: center;
    margin-top: 2.5rem;
}

.pagination__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 42px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    background: var(--card-bg);
}

.pagination__link:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.pagination__link.is-active {
    background: var(--accent-btn, var(--accent));
    border-color: var(--accent-btn, var(--accent));
    color: var(--accent-fg, #ffffff);
}

.post-preview-banner {
    text-align: center;
    padding: 0.55rem 1rem;
    margin: 1rem 0 0;
    border-radius: var(--radius-sm, 8px);
    background: color-mix(in srgb, var(--accent) 10%, var(--bg-secondary, #f5f5f5));
    border: 1px solid var(--border);
    font-size: 0.9rem;
}

/* Single post */
.single-post {
    padding: 2rem 0 3rem;
}

.single-post__header {
    margin-bottom: 1.5rem;
}

.single-post__title {
    font-size: clamp(1.8rem, 4.5vw, 2.6rem);
    line-height: 1.3;
    margin-bottom: 0.75rem;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.single-post__title:has(+ .single-post__badges) {
    margin-bottom: 0;
}

.single-post__title--underline {
    width: fit-content;
    max-width: 100%;
}

/*
 * Accent bar under the post title.
 * linear-gradient() only accepts physical sides (left/right) — "to inline-end"
 * is invalid and drops the entire background (invisible bar).
 * RTL: solid at inline-start (right) → fade toward left.
 * LTR: solid at inline-start (left) → fade toward right.
 */
.single-post__title--underline::after {
    content: "";
    display: block;
    width: 100%;
    height: 3px;
    margin-top: 0.7rem;
    border-radius: 999px;
    background: linear-gradient(
        to left,
        var(--accent-btn, var(--accent, var(--color-primary))) 0%,
        var(--accent-btn, var(--accent, var(--color-primary))) 62%,
        color-mix(
            in srgb,
            var(--accent-btn, var(--accent, var(--color-primary))) 48%,
            transparent
        ) 86%,
        transparent 100%
    );
}

html[dir="ltr"] .single-post__title--underline::after {
    background: linear-gradient(
        to right,
        var(--accent-btn, var(--accent, var(--color-primary))) 0%,
        var(--accent-btn, var(--accent, var(--color-primary))) 62%,
        color-mix(
            in srgb,
            var(--accent-btn, var(--accent, var(--color-primary))) 48%,
            transparent
        ) 86%,
        transparent 100%
    );
}

.single-post__badges {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
    margin: 0.85rem 0 0.55rem;
}

.single-post__badge {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: 0.32rem 0.95rem;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 0.82rem;
    line-height: 1.45;
    text-decoration: none;
    white-space: normal;
}

.single-post__badge--category {
    color: #2f3550;
    background: #eef0fb;
    border-color: #c9ceea;
}

.single-post__badge--category:hover {
    background: #e4e7f8;
    border-color: #b4bbdf;
}

.single-post__badge--date {
    color: #1f6b45;
    background: #e8f8ef;
    border-color: #9fd4b3;
}

.single-post__badge--updated {
    box-shadow: 0 0 0 1px color-mix(in srgb, #3cb371 18%, transparent),
        0 0 14px color-mix(in srgb, #3cb371 28%, transparent);
}

.single-post__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.single-post__cover {
    margin: 0 0 2rem;
    border-radius: var(--radius-md);
    overflow: hidden;
}

.single-post__cover.single-post__cover--playing {
    overflow: visible;
}

.single-post__cover img,
.single-post__cover-trigger img {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}

.single-post__cover-trigger {
    display: block;
    width: 100%;
    border: 0;
    padding: 0;
    margin: 0;
    background: none;
    cursor: pointer;
    position: relative;
    text-align: inherit;
    font: inherit;
}

.single-post__cover-placeholder {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, var(--bg-secondary), var(--border));
}

.post-hero-play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.05), rgba(15, 23, 42, 0.28));
    transition: background 0.2s ease;
}

.single-post__cover-trigger:hover .post-hero-play,
.single-post__cover-trigger:focus-visible .post-hero-play {
    background: linear-gradient(180deg, rgba(15, 23, 42, 0.12), rgba(15, 23, 42, 0.42));
}

.single-post__cover-inner {
    position: relative;
    width: 100%;
}

.single-post__cover-player {
    position: relative;
    width: 100%;
    background: #000;
}

.single-post__cover-player[hidden],
.single-post__cover-trigger[hidden] {
    display: none !important;
}

.single-post__cover-player:has(iframe) {
    aspect-ratio: 16 / 9;
    position: relative;
}

.single-post__cover-player iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.post-hero-play__btn {
    width: 5.75rem;
    height: 5.75rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.38);
    border: 2px solid rgba(255, 255, 255, 0.72);
    color: rgba(255, 255, 255, 0.82);
    box-shadow: 0 8px 28px rgba(15, 23, 42, 0.22);
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.single-post__cover-trigger:hover .post-hero-play__btn,
.single-post__cover-trigger:focus-visible .post-hero-play__btn {
    background: rgba(255, 255, 255, 0.95);
    color: var(--accent);
    border-color: #fff;
    transform: scale(1.06);
    box-shadow: 0 12px 32px rgba(15, 23, 42, 0.28);
}

.post-hero-play__icon {
    display: block;
    margin-inline-start: 0.2rem;
}

.single-post__layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 2rem;
    align-items: start;
    min-width: 0;
}

.single-post__layout--full {
    grid-template-columns: minmax(0, 1fr);
}

.single-post__main {
    min-width: 0;
    max-width: 100%;
}

.single-post__sidebar {
    position: sticky;
    top: calc(var(--site-header-height, 72px) + 1.5rem);
    align-self: start;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    min-width: 0;
}

/* Table of contents */
.post-toc {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
}

.post-toc__title {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.post-toc__list {
    list-style: none;
    counter-reset: toc-h2;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.post-toc__item {
    min-width: 0;
}

.post-toc__item--h2 {
    counter-increment: toc-h2;
    display: block;
}

.post-toc__row--h2 {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
}

.post-toc__sublist {
    list-style: none;
    margin: 0.3rem 0 0.1rem;
    padding: 0;
    counter-reset: toc-h3;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.post-toc__item--h3 {
    counter-increment: toc-h3;
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
}

.post-toc__row--h2::before,
.post-toc__item--h3::before {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    unicode-bidi: isolate;
    color: var(--text-secondary);
}

.post-toc__row--h2::before {
    content: counter(toc-h2) "-";
}

.post-toc__item--h3::before {
    content: counter(toc-h3) "-";
}

.post-toc__row--h2 a,
.post-toc__item--h3 a {
    min-width: 0;
    flex: 1;
    color: var(--text-primary);
}

.post-toc__row--h2 a:hover,
.post-toc__item--h3 a:hover {
    color: var(--accent);
}

.post-toc__item--h3 {
    margin-inline-start: 1.5rem;
    font-size: 0.92rem;
}

/* Optional modern TOC style (per-post) */
.post-toc--modern {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-sm);
}

.post-toc--modern .post-toc__title {
    color: var(--text-primary);
    margin-bottom: 0.8rem;
}

.post-toc--modern .post-toc__item--h2 {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--bg-primary);
    padding: 0.6rem 0.75rem 0.45rem;
}

.post-toc--modern .post-toc__item--h2 + .post-toc__item--h2 {
    margin-top: 0.55rem;
}

.post-toc--modern .post-toc__row--h2::before,
.post-toc--modern .post-toc__item--h3::before {
    color: var(--text-secondary);
}

.post-toc--modern .post-toc__row--h2 a,
.post-toc--modern .post-toc__item--h3 a {
    color: var(--text-primary);
    font-weight: 500;
}

.post-toc--modern .post-toc__row--h2 a:hover,
.post-toc--modern .post-toc__item--h3 a:hover {
    color: var(--accent);
}

.post-toc--modern .post-toc__row--h2 a {
    font-weight: 700;
}

.post-toc--modern .post-toc__item--h3 {
    margin-inline-start: 0;
    font-size: 0.9rem;
    min-width: 0;
}

.post-toc--modern .post-toc__item--h3 a {
    opacity: 0.95;
}

.post-toc--modern .post-toc__sublist {
    margin-top: 0.55rem;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.35rem 0.7rem;
}

.post-toc--modern .post-toc__item--h3 {
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.35rem 0.5rem;
}

@media (max-width: 960px) {
    .post-toc--modern .post-toc__sublist {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .post-toc--modern .post-toc__sublist {
        grid-template-columns: 1fr;
    }
}

/* Post content */
.post-content {
    line-height: 1.9;
    font-size: 1.05rem;
    color: var(--text-primary);
    max-width: 100%;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: normal;
}

.post-content p,
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6,
.post-content li,
.post-content blockquote {
    overflow-wrap: break-word;
    word-break: normal;
    min-width: 0;
    max-width: 100%;
}

.post-content .cb-content {
    max-width: 100%;
    overflow-x: hidden;
}

.post-content .cb-faq,
.post-content .cb-accordion,
.post-content .cb-faq__item summary,
.post-content .cb-faq__answer,
.post-content .cb-faq__answer p,
.post-content .cb-accordion__item summary,
.post-content .cb-accordion__body,
.post-content .cb-accordion__body p {
    word-break: break-word;
}

.post-content h2,
.post-content h3 {
    margin: 2rem 0 1rem;
    scroll-margin-top: 90px;
}

.post-content p {
    margin: 0 0 1.25rem;
}

.post-content img {
    border-radius: var(--radius-md);
    margin: 1.5rem 0;
}

.post-content ul,
.post-content ol {
    margin: 0 0 1.25rem;
    padding-inline-start: 1.5rem;
}

.post-content li {
    margin-bottom: 0.5rem;
}

.post-content blockquote {
    margin: 1.5rem 0;
    padding: 1rem 1.25rem;
    border-inline-start: 4px solid var(--accent);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
}

.post-content pre:not(.pb-code-block pre) {
    overflow-x: auto;
    max-width: 100%;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--code-bg);
    border: 1px solid var(--border);
    direction: ltr;
    text-align: left;
}

.post-content code {
    font-family: var(--font-mono);
    font-size: 0.92em;
}

.post-content :not(pre) > code {
    background: var(--code-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
}

/* Responsive video embeds */
.post-content .video-embed {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 1.5rem 0;
}

.post-content .video-embed iframe,
.post-content .video-embed video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: var(--radius-md);
}

/* Tags */
.post-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

.post-tags__label {
    color: var(--text-muted);
}

.post-tags__item {
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.85rem;
}

/* Sidebar widgets */
.sidebar-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin: 0;
}

.sidebar-box__title {
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
}

.sidebar-box__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-box__list a {
    color: var(--text-secondary);
}

.sidebar-box__list a:hover {
    color: var(--accent-ink, var(--accent));
}

.sidebar-share {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.sidebar-share__link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--text-secondary);
    background: var(--bg-primary);
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sidebar-share__link:hover {
    color: var(--accent-ink, var(--accent));
    border-color: color-mix(in srgb, var(--accent-ink, var(--accent)) 35%, var(--border));
    background: var(--accent-soft);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 12%, transparent);
}

.sidebar-share__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
}

.sidebar-share__icon.site-icon {
    width: auto;
    height: auto;
}

/* Brand buttons */
.sidebar-share--brand .sidebar-share__link {
    width: 2.65rem;
    height: 2.65rem;
    border: none;
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.sidebar-share--brand .sidebar-share__link:hover {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.sidebar-share--brand .sidebar-share__link--telegram { background: linear-gradient(145deg, #2aabee, #229ed9); }
.sidebar-share--brand .sidebar-share__link--linkedin { background: linear-gradient(145deg, #0a66c2, #004182); }
.sidebar-share--brand .sidebar-share__link--x { background: linear-gradient(145deg, #111, #333); }
.sidebar-share--brand .sidebar-share__link--medium { background: linear-gradient(145deg, #1a1a1a, #000); }
.sidebar-share--brand .sidebar-share__link--quora { background: linear-gradient(145deg, #b92b27, #8b1f1c); }

/* Colored icons */
.sidebar-share--color .sidebar-share__link {
    width: 2.65rem;
    height: 2.65rem;
    border: none;
    background: transparent;
    box-shadow: none;
}

.sidebar-share--color .sidebar-share__link:hover {
    background: color-mix(in srgb, var(--bg-secondary) 80%, transparent);
    box-shadow: none;
    transform: translateY(-1px);
}

.sidebar-share--color .sidebar-share__link--telegram { color: #229ed9; }
.sidebar-share--color .sidebar-share__link--linkedin { color: #0a66c2; }
.sidebar-share--color .sidebar-share__link--x { color: var(--text-primary); }
.sidebar-share--color .sidebar-share__link--medium { color: #000; }
.sidebar-share--color .sidebar-share__link--quora { color: #b92b27; }

.sidebar-share--color .sidebar-share__icon {
    width: 1.25rem;
    height: 1.25rem;
}

.sidebar-actions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-actions__btn {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    column-gap: 0.65rem;
    width: 100%;
    min-height: 2.65rem;
    padding: 0.5rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: var(--sidebar-actions-radius, var(--radius-md));
    color: var(--text-secondary);
    background: var(--bg-primary);
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sidebar-actions__label {
    font-size: 0.82rem;
    line-height: 1.35;
    color: inherit;
    min-width: 0;
    text-align: start;
}

.sidebar-actions__btn:hover {
    color: var(--accent-ink, var(--accent));
    border-color: color-mix(in srgb, var(--accent-ink, var(--accent)) 35%, var(--border));
    background: var(--accent-soft);
    box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 12%, transparent);
    transform: translateY(-1px);
}

.sidebar-actions__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    justify-self: center;
    font-size: 1.1rem;
}

.sidebar-actions__icon.site-icon {
    width: auto;
    height: auto;
}

/* Related */
.related-posts {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.related-posts__title {
    font-size: 1.4rem;
    margin-bottom: 1.25rem;
}

/* Responsive */
@media (max-width: 900px) {
    .single-post__layout {
        grid-template-columns: minmax(0, 1fr);
    }

    .single-post__sidebar {
        position: static;
        top: auto;
    }
}
