/* ============================================================
   single.css — Article / blog template styles
   Science for Rehab
   ============================================================ */

/* ── Reading progress bar ───────────────────────────────────── */
.reading-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 3px;
    background: var(--gradient-btn);
    z-index: 1000;
    transition: width .1s linear;
    pointer-events: none;
}

/* ── Article header ─────────────────────────────────────────── */
.article-header {
    padding: clamp(40px, 6vw, 72px) 0 clamp(24px, 3vw, 40px);
    border-bottom: 1px solid var(--color-border);
}

.article-header__title {
    font-size: clamp(1.75rem, 4.5vw, 3rem);
    font-weight: 800;
    line-height: 1.15;
    letter-spacing: -0.025em;
    color: var(--color-text);
    margin-bottom: 20px;
    max-width: 760px;
}

.article-header__meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 4px;
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.article-header__meta-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.article-header__sep {
    color: var(--color-border);
    margin: 0 4px;
}

.article-header__author {
    color: var(--color-primary);
    font-weight: 600;
    text-decoration: none;
}

.article-header__author:hover {
    text-decoration: underline;
}

.article-header__date,
.article-header__updated {
    color: var(--color-text-muted);
}

/* ── Featured image ─────────────────────────────────────────── */
.article-featured-img {
    padding: 32px 0;
    background: var(--color-bg-alt);
}

.article-featured-img__img {
    width: 100%;
    max-height: 480px;
    object-fit: cover;
    border-radius: var(--radius-lg);
    display: block;
}

/* ── Two-column layout (main + sidebar) ─────────────────────── */
.article-layout {
    display: grid;
    grid-template-columns: 1fr 260px;
    gap: 56px;
    padding-block: clamp(40px, 6vw, 72px);
    align-items: start;
}

.article-main {
    min-width: 0; /* prevent grid blowout */
}

/* ── TOC — desktop ──────────────────────────────────────────── */
/* Stretch to the full row height; with the grid's align-items: start the
   sidebar would be only as tall as the TOC, leaving sticky no room to move */
.article-sidebar {
    min-width: 0;
    align-self: stretch;
}

.article-toc--desktop {
    position: sticky;
    top: calc(var(--nav-h) + 24px);
    max-height: calc(100vh - var(--nav-h) - 48px);
    overflow-y: auto;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
}

.article-toc__title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 14px;
}

.article-toc__list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.article-toc__link {
    display: block;
    padding: 6px 10px;
    font-size: 0.83rem;
    line-height: 1.45;
    color: var(--color-text-muted);
    text-decoration: none;
    border-radius: 6px;
    border-left: 2px solid transparent;
    transition: color .15s, background .15s, border-color .15s;
}

.article-toc__link:hover {
    color: var(--color-primary);
    background: rgba(2, 78, 255, .05);
}

.article-toc__link.is-active {
    color: var(--color-primary);
    border-left-color: var(--color-primary);
    background: rgba(2, 78, 255, .06);
    font-weight: 600;
}

/* ── TOC — mobile ───────────────────────────────────────────── */
.article-toc--mobile {
    margin-bottom: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

/* Desktop keeps the sticky sidebar TOC only — JS unhides the mobile
   TOC purely based on heading count, not viewport, so force it off
   above the tablet breakpoint to avoid showing both at once. */
@media (min-width: 861px) {
    .article-toc--mobile {
        display: none;
    }
}

.article-toc__toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 14px 18px;
    background: var(--color-bg-alt);
    border: none;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    text-align: left;
}

.article-toc__toggle-chevron {
    margin-left: auto;
    transition: transform .2s;
    flex-shrink: 0;
}

.article-toc__toggle[aria-expanded="true"] .article-toc__toggle-chevron {
    transform: rotate(180deg);
}

.article-toc__nav--mobile {
    border-top: 1px solid var(--color-border);
    padding: 12px 16px;
    background: #fff;
}

.article-toc__nav--mobile .article-toc__list {
    gap: 0;
}

/* ── Article body content ───────────────────────────────────── */
.article-content {
    font-size: 1.05rem;
    line-height: 1.8;
    color: var(--color-text);
    max-width: 720px;
}

/* First paragraph styled as intro */
.article-content > p:first-of-type {
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1.7;
    color: var(--color-text);
    margin-bottom: 1.5em;
}

.article-content h2 {
    font-size: clamp(1.35rem, 3vw, 1.75rem);
    font-weight: 700;
    margin-top: 2.25em;
    margin-bottom: .6em;
    scroll-margin-top: calc(var(--nav-h) + 32px);
}

.article-content h3 {
    font-size: clamp(1.1rem, 2vw, 1.3rem);
    font-weight: 700;
    margin-top: 1.75em;
    margin-bottom: .5em;
}

.article-content p {
    margin-bottom: 1.25em;
}

.article-content ul,
.article-content ol {
    list-style: revert;
    padding-left: 1.6em;
    margin-bottom: 1.25em;
}

.article-content li {
    margin-bottom: .4em;
}

.article-content a {
    color: var(--color-primary);
    text-decoration: underline;
    text-decoration-color: rgba(2, 78, 255, .35);
    text-underline-offset: 2px;
}

.article-content a:hover {
    text-decoration-color: var(--color-primary);
}

.article-content strong {
    font-weight: 700;
}

.article-content img {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
    margin-block: 1.5em;
}

/* Tables */
.article-content table {
    width: 100%;
    border-collapse: collapse;
    margin-block: 1.75em;
    font-size: 0.93rem;
}

.article-content .sfr-table-wrap {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-block: 1.75em;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.article-content .sfr-table-wrap table {
    margin-block: 0;
    border: none;
    min-width: 480px;
}

.article-content th,
.article-content td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.article-content th {
    background: var(--color-bg-alt);
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
}

.article-content tbody tr:last-child th,
.article-content tbody tr:last-child td {
    border-bottom: none;
}

.article-content tbody tr:nth-child(even) {
    background: rgba(2, 78, 255, .02);
}

/* Callout block (blue left border) */
.article-content blockquote,
.article-content .wp-block-quote {
    border-left: 3px solid var(--color-primary);
    background: rgba(2, 78, 255, .04);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 16px 20px;
    margin-block: 1.75em;
    font-style: normal;
    color: var(--color-text);
}

.article-content blockquote p:last-child,
.article-content .wp-block-quote p:last-child {
    margin-bottom: 0;
}

/* ── Inline CTA (shortcode [sfr_cta]) ──────────────────────── */
.article-inline-cta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-primary);
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    padding: 24px 28px;
    margin-block: 2em;
}

.article-inline-cta__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.article-inline-cta__text {
    font-size: 0.93rem;
    color: var(--color-text-muted);
    line-height: 1.65;
    margin: 0;
}

/* ── FAQ ────────────────────────────────────────────────────── */
.article-faq {
    margin-top: clamp(40px, 6vw, 64px);
    padding-top: clamp(32px, 4vw, 48px);
    border-top: 1px solid var(--color-border);
    max-width: 720px;
}

.article-faq__heading {
    font-size: clamp(1.3rem, 3vw, 1.65rem);
    font-weight: 700;
    margin-bottom: 24px;
}

.article-faq__list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.article-faq__item + .article-faq__item {
    border-top: 1px solid var(--color-border);
}

.article-faq__q-heading {
    margin: 0;
    font-size: inherit;
    font-weight: inherit;
}

.article-faq__q {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    padding: 18px 22px;
    background: #fff;
    border: none;
    text-align: left;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    transition: background .15s;
}

.article-faq__q:hover {
    background: var(--color-bg-alt);
}

.article-faq__q[aria-expanded="true"] {
    color: var(--color-primary);
    background: rgba(2, 78, 255, .04);
}

.article-faq__chevron {
    flex-shrink: 0;
    transition: transform .22s ease;
    color: var(--color-text-muted);
}

.article-faq__q[aria-expanded="true"] .article-faq__chevron {
    transform: rotate(180deg);
    color: var(--color-primary);
}

.article-faq__a-inner {
    padding: 14px 22px 20px;
    font-size: 0.93rem;
    line-height: 1.75;
    color: var(--color-text-muted);
}

.article-faq__a-inner p:last-child {
    margin-bottom: 0;
}

/* ── Author block ───────────────────────────────────────────── */
.article-author {
    display: flex;
    gap: 20px;
    align-items: flex-start;
    margin-top: clamp(40px, 6vw, 64px);
    padding: 28px 32px;
    background: var(--color-bg-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    max-width: 720px;
}

.article-author__avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid var(--color-border);
}

.article-author__info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.article-author__label {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    margin-bottom: 2px;
}

.article-author__name {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}

.article-author__name:hover {
    color: var(--color-primary);
}

.article-author__bio {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    line-height: 1.65;
    margin: 6px 0 8px;
}

.article-author__link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}

.article-author__link:hover {
    text-decoration: underline;
}

/* ── Related articles ───────────────────────────────────────── */
.article-related__title {
    margin-bottom: clamp(24px, 4vw, 40px);
}

.article-related__grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.article-rel-card {
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: box-shadow .2s, transform .2s;
}

.article-rel-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

.article-rel-card__img-wrap {
    display: block;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.article-rel-card__img-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .3s;
    border-radius: 0;
    margin: 0;
}

.article-rel-card:hover .article-rel-card__img-wrap img {
    transform: scale(1.04);
}

.article-rel-card__body {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.article-rel-card__title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.35;
    margin-bottom: 8px;
}

.article-rel-card__title a {
    color: var(--color-text);
    text-decoration: none;
}

.article-rel-card__title a:hover {
    color: var(--color-primary);
}

.article-rel-card__excerpt {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    flex: 1;
    margin-bottom: 16px;
}

.article-rel-card__link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.83rem;
    font-weight: 600;
    color: var(--color-primary);
    text-decoration: none;
}

.article-rel-card__link:hover {
    text-decoration: underline;
}

.article-related__cta {
    text-align: center;
    margin-top: 36px;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .article-layout {
        grid-template-columns: 1fr 220px;
        gap: 40px;
    }
}

@media (max-width: 860px) {
    .article-layout {
        grid-template-columns: 1fr;
    }
    .article-sidebar {
        display: none; /* TOC moves to mobile position above content */
    }
    .article-related__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 600px) {
    .article-header__meta {
        font-size: 0.8rem;
    }
    .article-content {
        font-size: 1rem;
    }
    .article-author {
        flex-direction: column;
        padding: 20px;
    }
    .article-related__grid {
        grid-template-columns: 1fr;
    }
    .article-content .sfr-table-wrap table {
        font-size: 0.85rem;
    }
    .article-content th,
    .article-content td {
        padding: 10px 12px;
    }
}
