/**
 * ==========================================================================
 * Custom Single Post Stylesheet - K-Tech Child Theme
 * Scoped to .ktech-single-post-wrapper and its sub-elements
 * ==========================================================================
 */

:root {
    --ktech-post-primary: #003366;
    --ktech-post-primary-hover: #002244;
    --ktech-post-accent: var(--primary-color);
    --ktech-post-text-dark: #1e293b;
    --ktech-post-text-body: #334155;
    --ktech-post-text-muted: #64748b;
    --ktech-post-bg-light: #f8fafc;
    --ktech-post-border: #e2e8f0;
    --ktech-post-radius-sm: 6px;
    --ktech-post-radius-md: 10px;
    --ktech-post-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
    --ktech-post-transition: all 0.3s ease;
}

/* 1. Global Wrapper */
.ktech-single-post-wrapper {
    background-color: #ffffff;
    padding: 10px 0 60px;
    color: var(--ktech-post-text-body);
    font-family: inherit;
}

/* 2. Breadcrumbs */
.ktech-post-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 14px 0 18px;
    font-size: 13px;
    color: var(--ktech-post-text-muted);
}

.ktech-post-breadcrumb a {
    color: var(--ktech-post-text-muted);
    text-decoration: none;
    transition: var(--ktech-post-transition);
}

.ktech-post-breadcrumb a:hover {
    color: var(--ktech-post-primary);
    text-decoration: underline;
}

.ktech-post-breadcrumb .ktech-sep {
    color: #cbd5e1;
    font-size: 12px;
}

.ktech-post-breadcrumb .ktech-current {
    color: var(--ktech-post-text-dark);
    font-weight: 500;
    max-width: 400px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 3. Layout Grid (Desktop: Main ~70%, Sidebar ~30%) */
.ktech-single-post-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 330px;
    gap: 36px;
    align-items: start;
    margin-top: 5px;
    width: 100%;
}

.ktech-post-main-col {
    min-width: 0;
    width: 100%;
}

.ktech-post-sidebar-col {
    min-width: 0;
    width: 100%;
}

.ktech-post-sidebar-sticky {
    position: -webkit-sticky;
    position: sticky;
    top: 90px;
    display: flex;
    flex-direction: column;
    gap: 30px;
}

/* 4. Post Header: Title & Meta */
.ktech-post-header {
    margin-bottom: 24px;
}

.ktech-post-title {
    font-size: 30px;
    line-height: 1.35;
    font-weight: 700;
    color: var(--ktech-post-primary);
    margin: 0 0 14px;
    letter-spacing: -0.01em;
}

.ktech-post-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 20px;
    font-size: 13.5px;
    color: var(--ktech-post-text-muted);
    padding-bottom: 16px;
    border-bottom: 1px solid var(--ktech-post-border);
}

.ktech-post-meta-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ktech-post-meta-item i,
.ktech-post-meta-item svg {
    color: var(--ktech-post-primary);
    font-size: 14px;
}

.ktech-post-meta-item a {
    color: inherit;
    text-decoration: none;
    transition: var(--ktech-post-transition);
}

.ktech-post-meta-item a:hover {
    color: var(--ktech-post-accent);
}

/* 5. Table of Contents (TOC) Box */
.ktech-toc-box {
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: var(--ktech-post-radius-sm);
    padding: 16px 20px;
    margin: 20px 0 28px;
    transition: var(--ktech-post-transition);
}

.ktech-toc-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
}

.ktech-toc-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--ktech-post-text-dark);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ktech-toc-toggle {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    width: 40px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--ktech-post-text-dark);
    transition: var(--ktech-post-transition);
    padding: 0;
    margin: 0;
}

.ktech-toc-toggle:hover {
    background: var(--ktech-post-primary);
    color: #ffffff;
    border-color: var(--ktech-post-primary);
}

.ktech-toc-arrow {
    display: inline-block;
    font-size: 14px;
    line-height: 1;
    transition: transform 0.3s ease;
}

.ktech-toc-box.is-collapsed .ktech-toc-arrow {
    transform: rotate(180deg);
}

.ktech-toc-body {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed #cbd5e1;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease;
}

.ktech-toc-box.is-collapsed .ktech-toc-body {
    display: none;
}

.ktech-toc-list {
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.ktech-toc-list ol,
.ktech-toc-list ul {
    list-style: none;
    padding-left: 18px;
    margin: 4px 0 6px;
}

.ktech-toc-item {
    margin-bottom: 6px;
    font-size: 14px;
    line-height: 1.5;
}

.ktech-toc-link {
    color: var(--ktech-post-text-body);
    text-decoration: none;
    transition: var(--ktech-post-transition);
    display: inline-block;
}

.ktech-toc-link:hover {
    color: var(--ktech-post-accent);
    text-decoration: underline;
}

.ktech-toc-num {
    font-weight: 600;
    color: var(--ktech-post-primary);
    margin-right: 4px;
}

/* 6. Post Body Content */
.ktech-post-content {
    font-size: 16px;
    line-height: 1.8;
    color: #334155;
}

.ktech-post-content p {
    margin-bottom: 20px;
}

.ktech-post-content h2,
.ktech-post-content h3,
.ktech-post-content h4 {
    color: var(--ktech-post-primary);
    font-weight: 700;
    margin-top: 32px;
    margin-bottom: 16px;
    line-height: 1.35;
    scroll-margin-top: 100px;
    /* Offset for smooth scroll when sticky header is present */
}

.ktech-post-content h2 {
    font-size: 22px;
}

.ktech-post-content h3 {
    font-size: 19px;
}

.ktech-post-content h4 {
    font-size: 17px;
}

.ktech-post-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--ktech-post-radius-sm);
    margin: 18px 0;
}

.ktech-post-content ul,
.ktech-post-content ol {
    margin-bottom: 22px;
    padding-left: 24px;
}

.ktech-post-content li {
    margin-bottom: 8px;
}

.ktech-post-content blockquote {
    margin: 24px 0;
    padding: 16px 20px;
    background: var(--ktech-post-bg-light);
    border-left: 4px solid var(--ktech-post-primary);
    border-radius: 0 var(--ktech-post-radius-sm) var(--ktech-post-radius-sm) 0;
    font-style: italic;
    color: #475569;
}

/* 7. Previous / Next Navigation Row (Image 2 reference) */
.ktech-post-nav-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    padding: 24px 0;
    margin: 40px 0 35px;
    border-top: 1px solid var(--ktech-post-border);
    border-bottom: 1px solid var(--ktech-post-border);
}

.ktech-nav-col {
    flex: 1;
    min-width: 0;
}

.ktech-nav-prev {
    text-align: left;
}

.ktech-nav-next {
    text-align: right;
}

.ktech-nav-label {
    display: inline-block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ktech-post-text-muted);
    margin-bottom: 6px;
}

.ktech-nav-title {
    display: block;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    color: var(--ktech-post-primary);
    text-decoration: none;
    transition: var(--ktech-post-transition);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.ktech-nav-title:hover {
    color: var(--ktech-post-accent);
}

/* 8. Author Box */
.ktech-author-box {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    background: #f8fafc;
    border: 1px solid var(--ktech-post-border);
    border-radius: var(--ktech-post-radius-sm);
    padding: 22px;
    margin-bottom: 40px;
}

.ktech-author-avatar {
    flex: 0 0 70px;
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
}

.ktech-author-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.ktech-author-info {
    flex: 1;
    min-width: 0;
}

.ktech-author-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--ktech-post-primary);
    margin: 0 0 6px;
}

.ktech-author-desc {
    font-size: 14px;
    line-height: 1.6;
    color: var(--ktech-post-text-muted);
    margin: 0;
}

/* 9. Comments Section */
.ktech-comments-area {
    margin-top: 40px;
}

/* 10. Sidebar Blocks */
.ktech-sidebar-block {
    background: #ffffff;
    border: 1px solid #e9eff5;
    border-radius: var(--ktech-post-radius-md);
    padding: 24px 20px;
    box-shadow: var(--ktech-post-shadow);
}

.ktech-sidebar-title {
    position: relative;
    font-size: 16px;
    font-weight: 700;
    color: var(--ktech-post-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 18px;
    padding-bottom: 10px;
    border-bottom: 2px solid #eef2f6;
}

.ktech-sidebar-title::after {
    content: "";
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 45px;
    height: 2px;
    background-color: var(--ktech-post-accent);
}

/* Search Form */
.ktech-search-input-group {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.ktech-search-field {
    width: 100%;
    padding: 10px 42px 10px 14px;
    border: 1px solid #cbd5e1;
    border-radius: var(--ktech-post-radius-sm);
    font-size: 14px;
    color: var(--ktech-post-text-dark);
    outline: none;
    transition: var(--ktech-post-transition);
    background-color: #fcfcfc;
}

.ktech-search-field:focus {
    border-color: var(--ktech-post-primary);
    background-color: #ffffff;
    box-shadow: 0 0 0 3px rgba(0, 51, 102, 0.1);
}

.ktech-search-submit {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: transparent;
    border: none;
    padding: 8px 10px;
    cursor: pointer;
    color: var(--ktech-post-primary);
    font-size: 14px;
    transition: var(--ktech-post-transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.ktech-search-submit:hover {
    color: var(--ktech-post-accent);
    transform: translateY(-50%) scale(1.1);
}

/* Latest Posts List */
.ktech-latest-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ktech-latest-item {
    display: flex;
    gap: 14px;
    align-items: flex-start;
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f5f9;
}

.ktech-latest-item:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.ktech-latest-thumb-link {
    flex: 0 0 75px;
    width: 75px;
    height: 75px;
    border-radius: var(--ktech-post-radius-sm);
    overflow: hidden;
    display: block;
    background: #f1f5f9;
}

.ktech-latest-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}

.ktech-latest-item:hover .ktech-latest-thumb-img {
    transform: scale(1.08);
}

.ktech-latest-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e2e8f0;
    color: #94a3b8;
}

.ktech-latest-info {
    flex: 1;
    min-width: 0;
}

.ktech-latest-item-title {
    font-size: 13.5px;
    line-height: 1.4;
    font-weight: 600;
    margin: 0 0 5px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ktech-latest-item-title a {
    color: var(--ktech-post-text-dark);
    text-decoration: none;
    transition: var(--ktech-post-transition);
}

.ktech-latest-item-title a:hover {
    color: var(--ktech-post-primary);
}

.ktech-latest-excerpt {
    font-size: 12px;
    color: var(--ktech-post-text-muted);
    line-height: 1.4;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ktech-latest-meta {
    font-size: 11.5px;
    color: #94a3b8;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* 11. Responsive Breakpoints */
@media (max-width: 1024px) {
    .ktech-single-post-layout {
        grid-template-columns: minmax(0, 1fr) 280px;
        gap: 24px;
    }
}

@media (max-width: 850px) {
    .ktech-single-post-layout {
        grid-template-columns: 1fr;
        gap: 40px;
    }

    .ktech-post-sidebar-sticky {
        position: static;
    }

    .ktech-post-title {
        font-size: 24px;
    }
}

@media (max-width: 600px) {
    .ktech-post-meta-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .ktech-post-nav-row {
        flex-direction: column;
        gap: 16px;
    }

    .ktech-nav-next {
        text-align: left;
    }

    .ktech-post-title {
        font-size: 21px;
    }
}