/**
 * Single Blog Article — editorial layout
 * @package SwitchAndSave_EPOS
 */

/* ── Reading-progress bar ─────────────────────────────────── */
.sb-progress-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 0%;
    height: 3px;
    background: linear-gradient(90deg, #2563eb 0%, #10b981 100%);
    z-index: 9999;
    transition: width .1s linear;
    pointer-events: none;
}

/* ── Page wrapper ─────────────────────────────────────────── */
.sb-page {
    background: #f8fafc;
    font-family: var(--font-sans, 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif);
    color: #0f172a;
}

/* ── Breadcrumb ───────────────────────────────────────────── */
.sb-breadcrumb {
    background: #fff;
    border-bottom: 1px solid #e2e8f0;
    padding: 0.65rem 0;
}

.sb-breadcrumb-inner {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 1.25rem;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.8rem;
    color: #64748b;
}

.sb-breadcrumb a {
    color: #64748b;
    text-decoration: none;
    transition: color .15s;
}
.sb-breadcrumb a:hover { color: #2563eb; }

.sb-breadcrumb-sep {
    color: #cbd5e1;
    font-size: 0.75rem;
}

.sb-breadcrumb-current {
    color: #0f172a;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

/* ── Hero ─────────────────────────────────────────────────── */
.sb-hero {
    background: #fff;
    padding: 2.5rem 0 2rem;
    border-bottom: 1px solid #e2e8f0;
}

.sb-hero-inner {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 1.25rem;
}

.sb-category-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.85rem;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    margin-bottom: 1.1rem;
    text-decoration: none;
    transition: opacity .15s;
}
.sb-category-badge:hover { opacity: .85; }

.sb-hero-title {
    font-size: clamp(1.75rem, 4.5vw, 2.75rem);
    font-weight: 800;
    line-height: 1.18;
    letter-spacing: -0.025em;
    color: #0f172a;
    margin: 0 0 1.25rem;
}

.sb-hero-excerpt {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #475569;
    margin: 0 0 1.5rem;
    max-width: 640px;
}

/* ── Meta bar ─────────────────────────────────────────────── */
.sb-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    font-size: 0.85rem;
    color: #64748b;
    padding: 0.85rem 0;
    border-top: 1px solid #f1f5f9;
    border-bottom: 1px solid #f1f5f9;
}

.sb-meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.sb-meta-item svg { flex-shrink: 0; }

.sb-meta-divider {
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #cbd5e1;
    flex-shrink: 0;
}

.sb-meta-author {
    font-weight: 600;
    color: #334155;
}

/* ── Featured image ───────────────────────────────────────── */
.sb-featured-image {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.25rem 0;
}

.sb-featured-image-frame {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(15,23,42,.06), 0 20px 48px rgba(15,23,42,.12);
    background: #e2e8f0;
    aspect-ratio: 16 / 7;
}

.sb-featured-image-frame img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ── Body layout ──────────────────────────────────────────── */
.sb-body {
    max-width: 900px;
    margin: 0 auto;
    padding: 2.5rem 1.25rem 4rem;
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 0 2rem;
    align-items: start;
}

/* ── Sticky share sidebar ─────────────────────────────────── */
.sb-share-sidebar {
    position: sticky;
    top: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.sb-share-label {
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform: rotate(180deg);
    margin-bottom: 4px;
}

.sb-share-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: transform .18s, box-shadow .18s;
    color: #fff;
    flex-shrink: 0;
}
.sb-share-btn:hover {
    transform: translateY(-2px) scale(1.08);
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
}

.sb-share-btn--x       { background: #000; }
.sb-share-btn--fb      { background: #1877f2; }
.sb-share-btn--li      { background: #0a66c2; }
.sb-share-btn--copy    { background: #64748b; }
.sb-share-btn--copy.copied { background: #10b981; }

.sb-share-btn svg { display: block; }

/* ── Article content ──────────────────────────────────────── */
.sb-article {
    min-width: 0;
}

/* Anchor scroll offset — prevents headings hiding behind sticky header */
.sb-content h2,
.sb-content h3,
.sb-content h4 {
    scroll-margin-top: 90px;
}

/* Typography */
.sb-content {
    font-size: 1.0625rem;
    line-height: 1.85;
    color: #1e293b;
}

.sb-content p { margin: 0 0 1.5rem; }

.sb-content h2 {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    color: #0f172a;
    margin: 2.5rem 0 1rem;
    line-height: 1.25;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #eff6ff;
}

.sb-content h3 {
    font-size: clamp(1.1rem, 2.5vw, 1.35rem);
    font-weight: 700;
    color: #0f172a;
    margin: 2rem 0 0.75rem;
    line-height: 1.3;
}

.sb-content h4 {
    font-size: 1rem;
    font-weight: 700;
    color: #334155;
    margin: 1.5rem 0 0.5rem;
}

.sb-content ul,
.sb-content ol {
    margin: 0 0 1.5rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sb-content ul { list-style: none; padding: 0; margin-left: 0; }

.sb-content ul li {
    padding-left: 1.5rem;
    position: relative;
}
.sb-content ul li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0.65em;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #2563eb;
}

.sb-content ol {
    list-style: decimal;
    padding-left: 1.5rem;
    margin-left: 0;
}

.sb-content li { line-height: 1.7; }

.sb-content a {
    color: #2563eb;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: color .15s;
}
.sb-content a:hover { color: #1d4ed8; }

.sb-content strong {
    font-weight: 700;
    color: #0f172a;
}

.sb-content em { font-style: italic; }

.sb-content blockquote {
    margin: 2rem 0;
    padding: 1.25rem 1.5rem;
    border-left: 4px solid #2563eb;
    background: #eff6ff;
    border-radius: 0 10px 10px 0;
    font-style: italic;
    color: #334155;
    font-size: 1.05rem;
}

.sb-content blockquote p:last-child { margin-bottom: 0; }

.sb-content img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    display: block;
    margin: 1.5rem auto;
    box-shadow: 0 4px 20px rgba(15,23,42,.1);
}

.sb-content figure { margin: 2rem 0; }
.sb-content figcaption {
    text-align: center;
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 0.5rem;
    font-style: italic;
}

.sb-content pre {
    background: #0f172a;
    color: #e2e8f0;
    padding: 1.25rem 1.5rem;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 1.5rem 0;
}

.sb-content code {
    background: #f1f5f9;
    color: #db2777;
    padding: 0.15em 0.4em;
    border-radius: 4px;
    font-size: 0.88em;
    font-family: ui-monospace, 'Cascadia Code', monospace;
}

.sb-content pre code {
    background: none;
    color: inherit;
    padding: 0;
    font-size: inherit;
}

.sb-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 1.5rem 0;
    font-size: 0.9rem;
}
.sb-content th {
    background: #f8fafc;
    font-weight: 700;
    padding: 0.65rem 0.85rem;
    border: 1px solid #e2e8f0;
    text-align: left;
    color: #0f172a;
}
.sb-content td {
    padding: 0.6rem 0.85rem;
    border: 1px solid #e2e8f0;
    color: #334155;
    vertical-align: top;
}
.sb-content tr:nth-child(even) td { background: #f8fafc; }

/* ── Table of Contents ────────────────────────────────────── */
.sb-toc {
    background: #f8fafc;
    border: 1.5px solid #e2e8f0;
    border-radius: 12px;
    padding: 1.1rem 1.4rem 1.2rem;
    margin-bottom: 2rem;
    font-family: var(--font-sans, 'Inter', sans-serif);
}
.sb-toc-heading {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #64748b;
    margin: 0 0 0.7rem;
}
.sb-toc-toggle {
    margin-left: auto;
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: #94a3b8;
    display: inline-flex;
    align-items: center;
    transition: color .15s;
}
.sb-toc-toggle:hover { color: #2563eb; }
.sb-toc-toggle svg { transition: transform .2s; }
.sb-toc-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    counter-reset: toc-counter;
}
.sb-toc-item a {
    display: block;
    padding: 0.28rem 0.5rem;
    font-size: 0.9rem;
    color: #334155;
    text-decoration: none;
    border-radius: 6px;
    transition: background .12s, color .12s;
    line-height: 1.4;
}
.sb-toc-item a:hover,
.sb-toc-item a.sb-toc-active {
    background: #eff6ff;
    color: #2563eb;
}
.sb-toc-h3 a {
    padding-left: 1.4rem;
    font-size: 0.84rem;
    color: #64748b;
}
.sb-toc-h3 a:hover,
.sb-toc-h3 a.sb-toc-active { color: #2563eb; }

/* ── Article footer ───────────────────────────────────────── */
.sb-article-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 2px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Tags */
.sb-tags-label {
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.6rem;
}

.sb-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.sb-tag {
    display: inline-block;
    padding: 0.3rem 0.75rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    color: #475569;
    text-decoration: none;
    transition: background .15s, color .15s;
}
.sb-tag:hover {
    background: #eff6ff;
    color: #2563eb;
    border-color: #bfdbfe;
}

/* Bottom share row */
.sb-share-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.sb-share-row-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    margin-right: 0.25rem;
}

.sb-share-row-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    color: #fff;
    transition: opacity .15s, transform .15s;
    border: none;
    cursor: pointer;
}
.sb-share-row-btn:hover { opacity: .88; transform: translateY(-1px); }
.sb-share-row-btn--x  { background: #000; }
.sb-share-row-btn--fb { background: #1877f2; }
.sb-share-row-btn--li { background: #0a66c2; }
.sb-share-row-btn--copy { background: #64748b; }
.sb-share-row-btn--copy.copied { background: #10b981; }

/* ── Author bio ───────────────────────────────────────────── */
.sb-author {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 1.75rem 2rem;
    display: flex;
    gap: 1.5rem;
    align-items: flex-start;
    box-shadow: 0 2px 12px rgba(15,23,42,.05);
    margin-top: 2.5rem;
}

.sb-author-avatar {
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background: #e2e8f0;
}

.sb-author-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sb-author-body {}

.sb-author-eyebrow {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.sb-author-name {
    font-size: 1.05rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 0.45rem;
}

.sb-author-bio {
    font-size: 0.875rem;
    line-height: 1.65;
    color: #475569;
    margin: 0;
}

/* ── CTA strip ────────────────────────────────────────────── */
.sb-cta {
    background: linear-gradient(135deg, #004a8d 0%, #1d4ed8 100%);
    padding: 2.5rem 1.25rem;
    text-align: center;
    margin-top: 3rem;
}

.sb-cta-inner {
    max-width: 600px;
    margin: 0 auto;
}

.sb-cta-title {
    font-size: clamp(1.25rem, 3vw, 1.75rem);
    font-weight: 800;
    color: #fff;
    margin: 0 0 0.6rem;
    line-height: 1.25;
}

.sb-cta-sub {
    font-size: 0.95rem;
    color: rgba(255,255,255,.82);
    margin: 0 0 1.5rem;
    line-height: 1.6;
}

.sb-cta-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 2rem;
    background: #fff;
    color: #004a8d;
    font-weight: 800;
    font-size: 0.95rem;
    border-radius: 10px;
    text-decoration: none;
    transition: transform .18s, box-shadow .18s;
    box-shadow: 0 4px 18px rgba(0,0,0,.2);
}
.sb-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(0,0,0,.28);
    color: #004a8d;
}

/* ── Related articles ─────────────────────────────────────── */
.sb-related {
    max-width: 900px;
    margin: 0 auto;
    padding: 3rem 1.25rem;
}

.sb-related-heading {
    font-size: 1.35rem;
    font-weight: 800;
    color: #0f172a;
    margin: 0 0 1.5rem;
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sb-related-heading::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.sb-related-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.sb-related-card {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: transform .2s, box-shadow .2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
}
.sb-related-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 32px rgba(15,23,42,.12);
}

.sb-related-card-img {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    background: #e2e8f0;
    flex-shrink: 0;
}

.sb-related-card-img img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .35s;
}
.sb-related-card:hover .sb-related-card-img img {
    transform: scale(1.05);
}

.sb-related-card-body {
    padding: 1rem 1.1rem 1.25rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sb-related-card-date {
    font-size: 0.72rem;
    color: #94a3b8;
    font-weight: 500;
}

.sb-related-card-title {
    font-size: 0.925rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.4;
    margin: 0;
    flex: 1;
}

.sb-related-card-read {
    font-size: 0.8rem;
    font-weight: 700;
    color: #2563eb;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: auto;
}

/* ── Back to blog ─────────────────────────────────────────── */
.sb-back {
    text-align: center;
    padding: 0 1.25rem 3rem;
}

.sb-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.75rem;
    background: #fff;
    color: #0f172a;
    font-weight: 700;
    font-size: 0.9rem;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    text-decoration: none;
    transition: border-color .15s, background .15s, color .15s;
}
.sb-back-link:hover {
    border-color: #2563eb;
    color: #2563eb;
    background: #eff6ff;
}

/* ── Responsive ───────────────────────────────────────────── */

/* Tablet landscape – 2-col related grid */
@media (max-width: 960px) {
    .sb-related-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.1rem;
    }
}

/* Tablet portrait / large phone */
@media (max-width: 768px) {
    /* Layout: kill sidebar column, collapse to 1-col */
    .sb-body {
        grid-template-columns: 1fr;
        gap: 0;
        padding: 1.5rem 1rem 3rem;
    }
    .sb-share-sidebar { display: none; }

    /* Hero */
    .sb-hero { padding: 1.75rem 0 1.5rem; }
    .sb-hero-title { font-size: clamp(1.45rem, 5.5vw, 2rem); }
    .sb-hero-excerpt { font-size: 0.95rem; line-height: 1.65; }

    /* Featured image */
    .sb-featured-image { padding: 1.25rem 1rem 0; }
    .sb-featured-image-frame {
        border-radius: 12px;
        aspect-ratio: 16 / 9;
    }

    /* Article content */
    .sb-content { font-size: 1rem; }
    .sb-content h2 { font-size: clamp(1.2rem, 4.5vw, 1.5rem); margin-top: 2rem; }
    .sb-content h3 { font-size: clamp(1.05rem, 3.5vw, 1.25rem); margin-top: 1.5rem; }
    /* Tables — make horizontally scrollable on mobile */
    .sb-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }
    /* Pre blocks — ensure scroll */
    .sb-content pre { font-size: 0.82rem; }

    /* TOC */
    .sb-toc { padding: 0.9rem 1.1rem 1rem; margin-bottom: 1.5rem; }
    .sb-toc-item a { font-size: 0.88rem; }

    /* Author card */
    .sb-author {
        flex-direction: column;
        gap: 1rem;
        padding: 1.25rem;
    }

    /* CTA strip */
    .sb-cta { padding: 2rem 1rem; margin-top: 2rem; }

    /* Related */
    .sb-related { padding: 2rem 1rem; }
    .sb-related-grid { grid-template-columns: repeat(2, 1fr); gap: 1rem; }
}

/* Medium phone – switch related to 1-col */
@media (max-width: 560px) {
    .sb-related-grid { grid-template-columns: 1fr; gap: 0.9rem; }

    /* CTA + back button: full width */
    .sb-cta-btn {
        width: 100%;
        justify-content: center;
        padding: 0.875rem 1rem;
    }
    .sb-back-link {
        width: 100%;
        justify-content: center;
    }
}

/* Small phone */
@media (max-width: 480px) {
    .sb-hero-inner { padding: 0 1rem; }
    .sb-hero-title { font-size: clamp(1.3rem, 7vw, 1.7rem); }

    .sb-meta { gap: 0.35rem 0.7rem; font-size: 0.78rem; flex-wrap: wrap; }
    /* Hide divider dots when meta wraps */
    .sb-meta-divider { display: none; }

    .sb-breadcrumb-inner { font-size: 0.76rem; }
    .sb-breadcrumb-current { max-width: 150px; }

    .sb-content { font-size: 0.97rem; line-height: 1.8; }
    .sb-content blockquote { padding: 1rem 1.1rem; margin: 1.5rem 0; }
    .sb-content h2 { font-size: 1.2rem; }
    .sb-content h3 { font-size: 1.05rem; }

    /* TOC tighter on small phones */
    .sb-toc { padding: 0.75rem 0.9rem 0.85rem; }
    .sb-toc-item a { font-size: 0.83rem; padding: 0.22rem 0.4rem; }
    .sb-toc-h3 a { padding-left: 1rem; font-size: 0.78rem; }

    .sb-share-row { gap: 0.45rem; flex-wrap: wrap; }
    .sb-share-row-btn { padding: 0.4rem 0.7rem; font-size: 0.77rem; }

    .sb-back { padding: 0 1rem 2rem; }
    .sb-related-heading { font-size: 1.1rem; }
}

/* Ultra-small (iPhone SE 1st gen, Galaxy A13 etc.) */
@media (max-width: 360px) {
    .sb-hero-inner { padding: 0 0.75rem; }
    .sb-body { padding: 1.25rem 0.75rem 2.5rem; }
    .sb-featured-image { padding: 1rem 0.75rem 0; }
    .sb-content { font-size: 0.95rem; }
    .sb-cta { padding: 1.75rem 0.75rem; }
    .sb-related { padding: 1.75rem 0.75rem; }
    .sb-back { padding: 0 0.75rem 1.75rem; }
    .sb-toc { padding: 0.65rem 0.75rem 0.75rem; }
    .sb-share-row-btn { padding: 0.35rem 0.6rem; font-size: 0.74rem; }
}

/* ── Reduced motion ───────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .sb-related-card,
    .sb-share-btn,
    .sb-cta-btn,
    .sb-back-link { transition: none; }
    .sb-related-card-img img { transition: none; }
}
