/* ==========================================================================
   Mailsoftly Blog Engine — Front-end Styles
   ========================================================================== */

/* ---------- Scroll offset for sticky header ---------- */
/* Ensures TOC anchor links scroll to the right position */
html {
    scroll-padding-top: 90px;
}

/* ---------- Breadcrumbs ---------- */

.msbe-breadcrumbs {
    margin-top: 0;
    margin-bottom: 1.5rem;
    font-size: 0.85rem;
    line-height: 1.4;
    color: #6b7280;
}

.msbe-breadcrumbs__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0;
}

.msbe-breadcrumbs__item {
    display: inline-flex;
    align-items: center;
}

.msbe-breadcrumbs__link {
    color: #2563eb;
    text-decoration: none;
}

.msbe-breadcrumbs__link:hover {
    text-decoration: underline;
}

.msbe-breadcrumbs__current {
    color: #374151;
    font-weight: 500;
}

.msbe-breadcrumbs__sep {
    margin: 0 0.35rem;
    color: #9ca3af;
}

/* ---------- Footer fallback: hide elements until JS relocates them ---------- */

/* When rendered into wp_footer and not yet moved to a column, hide them.
   JS removes display:none after appending to the correct column.
   Use a data-attribute to track "not yet relocated" state. */
.msbe-sticky-cta[data-msbe-pending],
.msbe-toc[data-msbe-pending] {
    display: none;
}

/* ---------- Table of Contents ---------- */

/* Show desktop copy only on desktop, mobile copy only on mobile.
   Using min/max-width on each class avoids !important conflicts. */
.msbe-toc--desktop {
    display: block;
}
.msbe-toc--mobile {
    display: none;
}

@media (max-width: 1023px) {
    .msbe-toc--desktop {
        display: none;
    }
    .msbe-toc--mobile {
        display: block;
    }
}

/* ---------- Table of Contents — Desktop (Left Column) ---------- */

.msbe-toc--desktop {
    font-size: 0.8rem;
    line-height: 1.5;
    position: sticky;
    top: var(--msbe-navbar-height, 100px);
    max-width: 200px;
    width: 100%;
    box-sizing: border-box;
    margin-left: auto;
}

.msbe-toc__header {
    padding-bottom: 0.5rem;
    margin-bottom: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    cursor: default;
    padding-left: 0;
    padding-right: 0;
}

.msbe-toc__title {
    font-size: 0.95rem;
    font-weight: 700;
    color: #1e293b;
}

.msbe-toc__chevron {
    display: none;
    color: #64748b;
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.msbe-toc__header[aria-expanded="true"] .msbe-toc__chevron {
    transform: rotate(180deg);
}

.msbe-toc__list-wrap {
    position: relative;
}

.msbe-toc__list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 50vh;
    overflow-y: scroll;
    counter-reset: toc-counter;
    /* Always reserve scrollbar space, but make it transparent */
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}

.msbe-toc__list::-webkit-scrollbar {
    width: 3px;
}

.msbe-toc__list::-webkit-scrollbar-track {
    background: transparent;
}

.msbe-toc__list::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
}

/* Show scrollbar thumb on hover */
.msbe-toc__list-wrap:hover .msbe-toc__list {
    scrollbar-color: #cbd5e1 transparent;
}

.msbe-toc__list-wrap:hover .msbe-toc__list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
}

/* Bottom fade overlay to hint more content */
.msbe-toc__list-wrap::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: linear-gradient(to bottom, transparent, #fff);
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.2s ease;
}

/* Hide fade when scrolled to bottom (toggled by JS) */
.msbe-toc__list-wrap--at-bottom::after {
    opacity: 0;
}

.msbe-toc__item {
    margin: 0;
    counter-increment: toc-counter;
}

.msbe-toc__link {
    color: #4b5563;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
    display: block;
    padding: 0.4rem 0.6rem;
    border-left: 3px solid #e5e7eb;
    font-size: 0.78rem;
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.msbe-toc__link::before {
    content: counter(toc-counter) ". ";
    font-weight: 600;
    color: #94a3b8;
}

.msbe-toc__link:hover {
    color: #2563eb;
    border-left-color: #2563eb;
}

.msbe-toc__link:hover::before {
    color: #2563eb;
}

.msbe-toc__link.msbe-toc__link--active {
    color: #1e3a5f;
    font-weight: 600;
    border-left-color: #2563eb;
}

.msbe-toc__link.msbe-toc__link--active::before {
    color: #2563eb;
}

/* ---------- Share Icons (below TOC) ---------- */

.msbe-share {
    margin-top: 1.25rem;
    padding-top: 0.75rem;
}

.msbe-share__title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.msbe-share__icons {
    display: flex;
    gap: 0.6rem;
    align-items: center;
}

.msbe-share__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: #64748b;
    transition: color 0.15s ease, background 0.15s ease;
}

.msbe-share__link:hover {
    color: #1e293b;
    background: #f1f5f9;
}

.msbe-share__link svg {
    width: 18px;
    height: 18px;
}

/* ---------- Inline CTA — Base ---------- */

.msbe-inline-cta {
    margin: 2.5rem 0;
    padding: 1.5rem;
    border-radius: 8px;
    text-align: center;
}

.msbe-inline-cta__inner {
    max-width: 480px;
    margin: 0 auto;
}

.msbe-inline-cta__headline {
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0 0 0.4rem;
}

.msbe-inline-cta__subtext {
    font-size: 0.88rem;
    margin: 0 0 1rem;
    line-height: 1.5;
}

.msbe-inline-cta__button {
    display: inline-block;
    padding: 0.6rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease;
}

.msbe-inline-cta__button:hover {
    transform: translateY(-1px);
}

.msbe-inline-cta__trust {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.78rem;
}

/* ---------- Inline CTA — Style: highlight (position 1) ---------- */

.msbe-inline-cta--highlight {
    background: linear-gradient(135deg, #eff6ff 0%, #f0f9ff 100%);
    border: 1px solid #bfdbfe;
}

.msbe-inline-cta--highlight .msbe-inline-cta__headline {
    color: #1e3a5f;
}

.msbe-inline-cta--highlight .msbe-inline-cta__subtext {
    color: #475569;
}

.msbe-inline-cta--highlight .msbe-inline-cta__button {
    background: #2563eb;
    color: #fff;
}

.msbe-inline-cta--highlight .msbe-inline-cta__button:hover {
    background: #1d4ed8;
    color: #fff;
}

.msbe-inline-cta--highlight .msbe-inline-cta__trust {
    color: #6b7280;
}

/* ---------- Inline CTA — Style: subtle (position 2) ---------- */

.msbe-inline-cta--subtle {
    background: #f9fafb;
    border-left: 3px solid #2563eb;
    text-align: left;
    border-radius: 0 8px 8px 0;
}

.msbe-inline-cta--subtle .msbe-inline-cta__inner {
    max-width: 100%;
}

.msbe-inline-cta--subtle .msbe-inline-cta__headline {
    color: #1e293b;
    font-size: 1rem;
}

.msbe-inline-cta--subtle .msbe-inline-cta__subtext {
    color: #64748b;
    font-size: 0.85rem;
}

.msbe-inline-cta--subtle .msbe-inline-cta__button {
    background: transparent;
    color: #2563eb;
    border: 1.5px solid #2563eb;
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
}

.msbe-inline-cta--subtle .msbe-inline-cta__button:hover {
    background: #2563eb;
    color: #fff;
}

.msbe-inline-cta--subtle .msbe-inline-cta__trust {
    color: #94a3b8;
    font-size: 0.75rem;
}

/* ---------- Inline CTA — Style: bold (position 3) ---------- */

.msbe-inline-cta--bold {
    background: linear-gradient(135deg, #1e3a5f 0%, #2563eb 100%);
    border: none;
    padding: 2rem 1.5rem;
}

.msbe-inline-cta--bold .msbe-inline-cta__headline {
    color: #fff;
    font-size: 1.15rem;
}

.msbe-inline-cta--bold .msbe-inline-cta__subtext {
    color: rgba(255, 255, 255, 0.85);
}

.msbe-inline-cta--bold .msbe-inline-cta__button {
    background: #fff;
    color: #1e3a5f;
    font-weight: 700;
}

.msbe-inline-cta--bold .msbe-inline-cta__button:hover {
    background: #f0f7ff;
    color: #1e3a5f;
}

.msbe-inline-cta--bold .msbe-inline-cta__trust {
    color: rgba(255, 255, 255, 0.7);
}

/* ---------- Sticky CTA (Right Column) ---------- */

.msbe-sticky-cta {
    position: sticky;
    top: 100px; /* overridden by JS */
    max-width: 280px;
    padding: 1.25rem;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    text-align: center;
}

.msbe-sticky-cta__headline {
    font-size: 1rem;
    font-weight: 700;
    color: #1e3a5f;
    margin: 0 0 0.5rem;
}

.msbe-sticky-cta__subtext {
    font-size: 0.85rem;
    color: #475569;
    margin: 0 0 1rem;
    line-height: 1.5;
}

.msbe-sticky-cta__button {
    display: block;
    padding: 0.6rem 1rem;
    background: #2563eb;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.2s ease;
    text-align: center;
}

.msbe-sticky-cta__button:hover {
    background: #1d4ed8;
    color: #fff;
}

.msbe-sticky-cta__trust {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #6b7280;
}

/* ---------- Table of Contents — Mobile (Fixed Bar) ---------- */

.msbe-toc--mobile {
    position: fixed;
    top: 70px; /* JS overrides this with exact navbar bottom */
    left: 0;
    right: 0;
    z-index: 99;
    max-width: 100%;
    border-bottom: 1px solid #e5e7eb;
    margin-bottom: 0;
    padding: 0.75rem 1rem;
    background: #fff;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    box-sizing: border-box;
    font-size: 0.8rem;
    line-height: 1.5;
}

.msbe-toc--mobile .msbe-toc__header {
    cursor: pointer;
    padding-bottom: 0;
    margin-bottom: 0;
}

.msbe-toc--mobile .msbe-toc__chevron {
    display: block;
}

.msbe-toc--mobile .msbe-toc__list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), margin-top 0.4s ease;
    margin-top: 0;
}

.msbe-toc--mobile.msbe-toc--open .msbe-toc__list {
    max-height: 50vh;
    overflow-y: auto;
    margin-top: 0.5rem;
}

.msbe-toc--mobile .msbe-toc__list-wrap::after {
    display: none;
}

.msbe-toc--mobile .msbe-share {
    display: none;
}

/* ---------- Responsive ---------- */

@media (max-width: 767px) {
    .msbe-sticky-cta {
        display: none !important;
    }
}

/* Tablet: TOC and CTA adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    .msbe-toc--desktop {
        position: sticky;
        top: var(--msbe-navbar-height, 80px);
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 0.5rem;
    }

    .msbe-sticky-cta {
        max-width: 220px;
        font-size: 0.85rem;
    }

    .msbe-sticky-cta__headline {
        font-size: 0.9rem;
    }
}

/* ---------- Pillar Uplink ---------- */

.msbe-pillar-uplink {
    margin: 0.75rem 0 1.25rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.82rem;
    color: #64748b;
    border-left: 3px solid #2563eb;
    background: #f8fafc;
    border-radius: 0 4px 4px 0;
    line-height: 1.5;
}

.msbe-pillar-uplink__icon {
    font-size: 0.9rem;
}

.msbe-pillar-uplink a {
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.msbe-pillar-uplink a:hover {
    text-decoration: underline;
}

/* ---------- Related Posts ---------- */

.msbe-related-posts {
    margin: 3rem 0 1.5rem;
    padding-top: 2rem;
    border-top: 1px solid #e5e7eb;
}

.msbe-related-posts__title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 1.25rem;
}

.msbe-related-posts__grid {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.msbe-related-posts__grid::-webkit-scrollbar {
    height: 4px;
}

.msbe-related-posts__grid::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.msbe-related-posts__card {
    display: flex;
    flex-direction: column;
    flex: 0 0 160px;
    scroll-snap-align: start;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.msbe-related-posts__card:hover {
    border-color: #2563eb;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.1);
}

.msbe-related-posts__thumb {
    width: 100%;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f1f5f9;
}

.msbe-related-posts__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.msbe-related-posts__text {
    padding: 0.5rem;
}

.msbe-related-posts__card-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ---------- Print ---------- */

@media print {
    .msbe-sticky-cta,
    .msbe-inline-cta,
    .msbe-toc,
    .msbe-related-posts,
    .msbe-pillar-uplink {
        display: none !important;
    }
}
