/* ══════════════════════════════════════════════════════════════
   Advanced Single Post – full stylesheet
   Preserves all original class names + adds sp-* namespace
   ══════════════════════════════════════════════════════════════ */

/* ── Base & Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

/* ── CSS Variables ────────────────────────────────────────────── */
:root {
    --sp-text:        #1a1916;
    --sp-muted:       #1a1916;
    --sp-border:      #e5e2db;
    --sp-surface:     #f7f5f1;
    --sp-accent:      #2c5f2e;
    --sp-accent-lt:   #1a1916;
    --sp-link:        #2c5f2e;
    --sp-tag-bg:      #eef3ee;
    --sp-tag-text:    #2c5f2e;
    --sp-radius:      8px;
    --sp-hero-height: min(80vh, 680px);
    --sp-content-w:   740px;
    --sp-sidebar-w:   240px;
    --sp-gap:         3rem;
}

/* ── Reading Progress Bar ─────────────────────────────────────── */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    background: var(--sp-accent);
    z-index: 9999;
    transition: width 0.1s linear;
    transform-origin: left;
}

/* ── Hero Image ───────────────────────────────────────────────── */
.sp-hero {
    position: relative;
    width: 100%;
    height: var(--sp-hero-height);
    overflow: hidden;
}

.sp-hero .post-thumbnail {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    /* Lightweight CSS parallax via transform */
    will-change: transform;
}

.sp-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        to bottom,
        transparent 40%,
        rgba(0, 0, 0, 0.55) 100%
    );
    pointer-events: none;
}

/* ── Blog Details / Header ───────────────────────────────────── */
.blog-details {
    position: relative;  /* override original absolute positioning */
    top: auto;
    left: auto;
    right: auto;
    margin: 0 auto;
    max-width: calc(var(--sp-content-w) + var(--sp-sidebar-w) + var(--sp-gap));
    padding: 2.5rem clamp(1rem, 5vw, 3rem) 2rem;
    background: transparent;
    color: var(--sp-text);
    z-index: auto;
}

/* ── Breadcrumb ──────────────────────────────────────────────── */
.sp-breadcrumb ol {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    list-style: none;
    padding: 0;
    margin: 0 0 1.25rem;
    font-size: 0.75rem;
    color: var(--sp-muted);
}

.sp-breadcrumb li + li::before { content: '/'; margin-right: 4px; color: var(--sp-border); }

.sp-breadcrumb a {
    color: var(--sp-muted);
    text-decoration: none;
    transition: color 0.2s;
}
.sp-breadcrumb a:hover { color: var(--sp-accent); }

/* ── Categories ──────────────────────────────────────────────── */
.post-categories {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-bottom: 0.85rem;
    padding-left: 0;
    font-size: 0.72rem;
}

.post-category {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--sp-tag-text);
    background: var(--sp-tag-bg);
    padding: 4px 10px;
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.post-category:hover { background: var(--sp-accent); color: #fff; }

.cat-sep { color: var(--sp-border); }

/* ── Entry Title ─────────────────────────────────────────────── */
.entry-title {
    font-size: clamp(1.8rem, 4vw, 3.2rem);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.03em;
    color: var(--sp-text);
    margin: 0 0 1.25rem;
    padding-left: 0;
    max-width: 100%;
}

/* ── Meta Row ────────────────────────────────────────────────── */
.sp-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.25rem;
    font-size: 0.82rem;
    color: var(--sp-muted);
}

.sp-author-mini {
    display: flex;
    align-items: center;
    gap: 7px;
}

.sp-avatar-mini {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50%;
    object-fit: cover;
}

.sp-author-name {
    color: var(--sp-text);
    font-weight: 500;
    text-decoration: none;
    font-size: 0.82rem;
}
.sp-author-name:hover { color: var(--sp-accent); }

.sp-meta-sep { color: var(--sp-border); }

.post-date {
    font-size: 0.8rem;
    color: var(--sp-muted);
    font-weight: 400;
    padding-left: 0;
    margin-bottom: 0;
}

.sp-read-time { font-size: 0.8rem; }

/* ── Share Buttons ───────────────────────────────────────────── */
.sp-share {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.sp-share-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    border: 1px solid var(--sp-border);
    background: transparent;
    color: var(--sp-text);
    transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.sp-share-btn:hover {
    background: var(--sp-surface);
    border-color: var(--sp-muted);
}
.sp-share-tw:hover  { background: #000; color: #fff; border-color: #000; }
.sp-share-fb:hover  { background: #1877f2; color: #fff; border-color: #1877f2; }

/* ── Content Layout: sidebar + main ─────────────────────────── */
.sp-content-wrap {
    display: grid;
    grid-template-columns: var(--sp-sidebar-w) 1fr;
    gap: var(--sp-gap);
    max-width: calc(var(--sp-content-w) + var(--sp-sidebar-w) + var(--sp-gap) + 6rem);
    margin: 0 auto;
    padding: 0 clamp(1rem, 5vw, 3rem);
    align-items: start;
}

/* ── Sidebar / TOC ───────────────────────────────────────────── */
.sp-sidebar {
    position: sticky;
    top: 5rem;
    max-height: calc(100vh - 7rem);
    overflow-y: auto;
    padding-right: 1rem;
    scrollbar-width: thin;
}

.toc {
    border-left: 2px solid var(--sp-border);
    padding-left: 1rem;
}

.toc-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sp-muted);
    margin: 0 0 0.75rem;
}

.toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    counter-reset: toc-counter;
}

.toc-item a {
    font-size: 0.78rem;
    color: var(--sp-muted);
    text-decoration: none;
    line-height: 1.45;
    display: block;
    padding: 2px 0;
    transition: color 0.2s;
}
.toc-item a:hover { color: var(--sp-accent); }
.toc-h3 a { padding-left: 0.9rem; font-size: 0.73rem; }

/* Mobile TOC (inline, hidden on desktop) */
.toc-mobile { display: none; }

/* ── Main Content ────────────────────────────────────────────── */
.blog-content {
    max-width: var(--sp-content-w);
    width: 100%;
    margin: 0;
    padding-top: 0;
}

/* ── Entry Content Typography ────────────────────────────────── */
.entry-content {
    font-size: clamp(1rem, 1.8vw, 1.08rem);
    line-height: 1.8;
    color: var(--sp-text);
    margin: 0;
    padding: 0;
}

.entry-content h2,
.entry-content h3,
.entry-content h4 {
    margin-top: 2.5em;
    margin-bottom: 0.75em;
    line-height: 1.25;
    scroll-margin-top: 5rem;
}

.entry-content h2 { font-size: 1.55rem; font-weight: 700; letter-spacing: -0.02em; }
.entry-content h3 { font-size: 1.2rem;  font-weight: 600; }
.entry-content h4 { font-size: 1rem;    font-weight: 600; }

.entry-content p { margin-bottom: 1.5em; }

.entry-content a {
    color: var(--sp-link);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.entry-content blockquote {
    border-left: 3px solid var(--sp-accent);
    margin: 2em 0;
    padding: 1em 1.5em;
    background: var(--sp-accent-lt);
    border-radius: 0 var(--sp-radius) var(--sp-radius) 0;
    font-style: italic;
    color: var(--sp-text);
}

.entry-content code {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    background: var(--sp-surface);
    padding: 2px 6px;
    border-radius: 4px;
    border: 0.5px solid var(--sp-border);
}

.entry-content pre {
    background: #1a1916;
    color: #f0ede8;
    border-radius: var(--sp-radius);
    padding: 1.5rem;
    overflow-x: auto;
    font-size: 0.85rem;
    margin: 2em 0;
}
.entry-content pre code { background: none; border: none; padding: 0; color: inherit; }

/* ── Images ──────────────────────────────────────────────────── */
.entry-content img,
.wp-block-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: var(--sp-radius);
}

.post-thumbnail {
    width: 100%;
    height: auto;
    max-height: 800px;
    object-fit: cover;
    display: block;
}

.blog-feature-image.full-width { max-width: 100%; margin: 0 auto; }

/* ── Captions ─────────────────────────────────────────────────── */
.wp-caption { margin: 1em 0; max-width: 100%; }
.wp-caption-text { font-size: 0.85em; color: var(--sp-muted); margin-top: 0.4em; }

/* ── Tags ────────────────────────────────────────────────────── */
.sp-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 2.5rem 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--sp-border);
}

.sp-tags-label {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--sp-muted);
}

.sp-tag {
    font-size: 0.75rem;
    color: var(--sp-tag-text);
    background: var(--sp-tag-bg);
    padding: 4px 11px;
    border-radius: 20px;
    text-decoration: none;
    transition: background 0.2s, color 0.2s;
}
.sp-tag:hover { background: var(--sp-accent); color: #fff; }

/* ── End Ornament ─────────────────────────────────────────────── */
.blog-content-sign {
    text-align: center;
    font-size: 1.5rem;
    color: var(--sp-border);
    margin: 2.5rem 0;
    letter-spacing: 0.3em;
}

/* ── Author Card ─────────────────────────────────────────────── */
.sp-author-card {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
    background: var(--sp-surface);
    border: 1px solid var(--sp-border);
    border-radius: 12px;
    padding: 1.5rem;
    margin: 2.5rem 0;
}

.sp-author-avatar {
    width: 72px !important;
    height: 72px !important;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.sp-author-info { flex: 1; }

.sp-author-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--sp-muted);
    margin: 0 0 0.2rem;
}

.sp-author-card-name {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--sp-text);
    text-decoration: none;
    margin-bottom: 0.5rem;
}
.sp-author-card-name:hover { color: var(--sp-accent); }

.sp-author-bio {
    font-size: 0.85rem;
    color: var(--sp-muted);
    line-height: 1.6;
    margin: 0 0 0.6rem;
}

.sp-author-web {
    font-size: 0.8rem;
    color: var(--sp-accent);
    text-decoration: none;
    font-weight: 500;
}
.sp-author-web:hover { text-decoration: underline; }

/* ── Post Navigation ─────────────────────────────────────────── */
.sp-post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 2.5rem 0;
    padding-top: 1.5rem;
    border-top: 1px solid var(--sp-border);
}

.sp-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    text-decoration: none;
    color: var(--sp-text);
    background: var(--sp-surface);
    transition: border-color 0.2s, background 0.2s;
    min-width: 0;
}
.sp-nav-link:hover { border-color: var(--sp-accent); background: var(--sp-accent-lt); }
.sp-nav-next { justify-content: flex-end; }

.sp-nav-thumb {
    width: 52px;
    height: 52px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
}
.sp-nav-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sp-nav-text {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}
.sp-nav-next .sp-nav-text { text-align: right; }

.sp-nav-label {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--sp-muted);
}

.sp-nav-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Related Posts wrapper ───────────────────────────────────── */
.space {
    max-width: calc(var(--sp-content-w) + var(--sp-sidebar-w) + var(--sp-gap) + 6rem);
    margin: 3rem auto 5rem;
    padding: 0 clamp(1rem, 5vw, 3rem);
}

.related-posts {
    margin-top: 0;
    margin-bottom: 0;
    width: 100%;
    padding: 0;
}

/* ── Responsive ──────────────────────────────────────────────── */

/* Tablet */
@media (max-width: 1024px) {
    .sp-content-wrap {
        grid-template-columns: 1fr;
    }
    .sp-sidebar { display: none; }
    .toc-mobile {
        display: block;
        margin-bottom: 2rem;
    }
    .toc-mobile .toc { border-left: none; padding-left: 0; }
    .toc-mobile .toc-list { flex-direction: row; flex-wrap: wrap; gap: 6px; }
    .toc-mobile .toc-item a {
        background: var(--sp-surface);
        border: 1px solid var(--sp-border);
        padding: 4px 10px;
        border-radius: 20px;
        font-size: 0.75rem;
    }
    .toc-mobile .toc-h3 a { padding-left: 10px; }
    .toc-mobile .toc-title { display: none; }
}

/* Mobile */
@media (max-width: 640px) {
    .sp-hero { height: 55vw; min-height: 220px; }

    .blog-details { padding: 1.5rem 1rem 1rem; }

    .entry-title { font-size: 1.6rem; }

    .sp-meta-row { gap: 6px; font-size: 0.75rem; }

    .sp-post-nav { grid-template-columns: 1fr; }
    .sp-nav-next { justify-content: flex-start; }
    .sp-nav-next .sp-nav-text { text-align: left; }

    .sp-author-card { flex-direction: column; align-items: center; text-align: center; }
    .sp-author-label, .sp-author-bio { text-align: left; }

    .entry-content { font-size: 1rem; }

    .blog-content { padding-top: 0; }

    .sp-content-wrap { padding: 0 1rem; }

    .space { padding: 0 1rem; margin-bottom: 3rem; }
}

/* Very small */
@media (max-width: 380px) {
    .sp-share { gap: 6px; }
    .sp-share-btn { padding: 5px 10px; font-size: 0.7rem; }
}