/* ─────────────────────────────────────────────────────────────────────
 * single.css — long-form blog single layout
 *
 * Layout:
 *   ≥900px:  [main 1fr] [sidebar 260px]   sticky TOC + share
 *   <900px:  single column; TOC becomes inline <details> above body
 *
 * A11y:
 *   - reduced-motion respected
 *   - focus-visible polished
 *   - heading anchor icons reachable by keyboard
 *   - skip link visible on focus
 *
 * SEO/UX:
 *   - prose width capped at ~72ch
 *   - LCP-friendly hero image, no above-the-fold JS-blocking
 * ─────────────────────────────────────────────────────────────────── */

:root {
    --ha-prose-max: 65ch;        /* ~600px — NN/g 50–75 sweet spot */
    --ha-single-outer: 1120px;   /* canonical outer for hero + body layout */
    --ha-sidebar-w: 260px;
    --ha-sidebar-gap: 4rem;
    --ha-sticky-top: 96px;
}

/* ─── Reading progress bar ───────────────────────────────────────── */
.ha-read-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    border: 0;
    background: transparent;
    z-index: 70;
    appearance: none;
    -webkit-appearance: none;
}

.ha-read-progress::-webkit-progress-bar { background: transparent; }
.ha-read-progress::-webkit-progress-value {
    background: var(--ha-blue-500, rgb(0, 167, 225));
    transition: width 60ms linear;
}
.ha-read-progress::-moz-progress-bar {
    background: var(--ha-blue-500, rgb(0, 167, 225));
}

/* ─── Container helper — single canonical width for the page ──────── */
.ha-single .ha-container,
.ha-single .ha-container--prose {
    max-width: var(--ha-single-outer);
    margin-left: auto;
    margin-right: auto;
    padding-left: 1.5rem;
    padding-right: 1.5rem;
    box-sizing: border-box;
}

/* ─── Main / focus management ────────────────────────────────────── */
.ha-single {
    outline: none;
    /* compensate for fixed header from theme parts */
    padding-top: 2rem;
}

/* ─── Hero ───────────────────────────────────────────────────────── */
.ha-single__hero {
    padding-top: 1rem;
}

.ha-single__hero .yoast-breadcrumbs,
.ha-single__hero .ha-breadcrumbs {
    font-size: 0.875rem;
    color: var(--ha-gray-600, rgb(125, 129, 134));
    margin-bottom: 1.5rem;
}

.ha-single__hero .yoast-breadcrumbs a,
.ha-single__hero .ha-breadcrumbs a {
    color: var(--ha-gray-600, rgb(125, 129, 134));
    text-decoration: none;
}

.ha-single__hero .yoast-breadcrumbs a:hover,
.ha-single__hero .ha-breadcrumbs a:hover {
    text-decoration: underline;
}

.ha-single__eyebrow {
    margin: 0 0 1rem;
    font-family: 'BrutalType', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 0.8125rem;
    color: var(--ha-gray-600, rgb(125, 129, 134));
}

.ha-single__cat {
    color: var(--ha-blue-500, rgb(0, 167, 225));
    text-decoration: none;
    font-weight: 600;
}

.ha-single__cat:hover { text-decoration: underline; }

.ha-single__sep {
    margin: 0 0.5rem;
    color: var(--ha-gray-200, rgb(230, 232, 235));
}

.ha-single__title {
    font-family: 'Nexa', sans-serif;
    font-weight: 700;
    /* fluid type: scales with viewport, clamped */
    font-size: clamp(1.875rem, 3.5vw + 1rem, 3rem);
    line-height: 1.15;
    margin: 0 0 1.5rem;
    color: var(--ha-gray-800, rgb(38, 45, 53));
    letter-spacing: -0.01em;
    /* Limit title line-length for readability */
    max-width: 22ch;
}

/* Eyebrow + byline + breadcrumbs sit at full container width — no max-width clamp */

.ha-single__byline {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 2rem;
    font-size: 0.9375rem;
    color: var(--ha-gray-600, rgb(125, 129, 134));
}

.ha-single__avatar {
    border-radius: 9999px;
    width: 36px;
    height: 36px;
    margin-right: 0.5rem;
}

.ha-single__author {
    color: var(--ha-gray-800, rgb(38, 45, 53));
    font-weight: 500;
}

/* Hero image sits inside the canonical container so it aligns with body */
.ha-single__hero-image {
    max-width: var(--ha-single-outer);
    margin: 2rem auto 3rem;
    padding: 0 1.5rem;
    box-sizing: border-box;
}

.ha-single__hero-image img {
    width: 100%;
    height: auto;
    max-height: 480px;
    object-fit: cover;
    aspect-ratio: 16 / 9;
    border-radius: 1rem;
    display: block;
}

/* ─── Two-column layout ───────────────────────────────────────────── */
.ha-single__layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--ha-sidebar-gap);
    align-items: start;
}

@media (min-width: 900px) {
    .ha-single__layout {
        grid-template-columns: minmax(0, 1fr) var(--ha-sidebar-w);
    }
}

/* ─── Body / prose ────────────────────────────────────────────────── */
.ha-single__body {
    min-width: 0; /* allow grid item to shrink properly */
}

.ha-single__prose {
    max-width: var(--ha-prose-max);
    margin: 0 auto;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--ha-gray-800, rgb(38, 45, 53));
}

@media (min-width: 900px) {
    .ha-single__prose {
        margin: 0;
    }
}

/* Generous spacing between block-level children */
.ha-single__prose > * + * {
    margin-top: 1.25rem;
}

.ha-single__prose > h2,
.ha-single__prose > h3,
.ha-single__prose > h4 {
    margin-top: 2.75rem;
    margin-bottom: 0.5rem;
    line-height: 1.25;
    font-family: 'Nexa', sans-serif;
    font-weight: 700;
    color: var(--ha-gray-800, rgb(38, 45, 53));
    position: relative;
    scroll-margin-top: var(--ha-sticky-top);
}

.ha-single__prose > h2 { font-size: 1.75rem; }
.ha-single__prose > h3 { font-size: 1.375rem; }
.ha-single__prose > h4 { font-size: 1.125rem; }

/* Heading anchor: #-icon reveals on hover/focus; copies link */
.ha-single__prose > :is(h2, h3, h4) .ha-anchor-link {
    opacity: 0;
    margin-left: 0.5rem;
    font-weight: 400;
    color: var(--ha-blue-500, rgb(0, 167, 225));
    text-decoration: none;
    font-size: 0.85em;
    transition: opacity 0.15s;
}

.ha-single__prose > :is(h2, h3, h4):hover .ha-anchor-link,
.ha-single__prose > :is(h2, h3, h4) .ha-anchor-link:focus {
    opacity: 1;
}

/* Inline links in prose */
.ha-single__prose a {
    color: var(--ha-blue-500, rgb(0, 167, 225));
    text-decoration: underline;
    text-underline-offset: 0.15em;
    text-decoration-thickness: 1px;
    transition: color 0.15s;
}

.ha-single__prose a:hover {
    color: var(--ha-blue-600, rgb(46, 124, 192));
}

/* Better looking images in prose */
.ha-single__prose img {
    max-width: 100%;
    height: auto;
}

/* Allow wide/full alignment to break out of prose width */
.ha-single__prose .alignwide {
    max-width: min(1100px, 90vw);
    margin-left: 50%;
    transform: translateX(-50%);
}

.ha-single__prose .alignfull {
    width: 100vw;
    max-width: 100vw;
    margin-left: 50%;
    transform: translateX(-50%);
}

/* Article footer */
.ha-single__article-footer {
    margin-top: 3rem;
    padding-top: 2rem;
    border-top: 1px solid var(--ha-gray-200, rgb(230, 232, 235));
    max-width: var(--ha-prose-max);
}

@media (min-width: 900px) {
    .ha-single__article-footer { margin-left: 0; }
}

.ha-single__tags {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ha-single__tags a {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: var(--ha-blue-100, rgb(204, 237, 249));
    color: var(--ha-gray-800, rgb(38, 45, 53));
    text-decoration: none;
    font-size: 0.875rem;
}

.ha-single__tags a:hover {
    background: var(--ha-blue-500, rgb(0, 167, 225));
    color: #fff;
}

/* ─── Sidebar ─────────────────────────────────────────────────────── */
.ha-single__sidebar {
    /* mobile: sidebar appears after the body, no special treatment */
    min-width: 0;
}

@media (min-width: 900px) {
    /* Sticky goes on the grid item itself. `align-self: start` is REQUIRED:
     * grid items default to stretching to row height, which leaves the
     * sticky element with no room to slide within its row.
     */
    .ha-single__sidebar {
        position: sticky;
        top: var(--ha-sticky-top);
        align-self: start;
        max-height: calc(100vh - var(--ha-sticky-top) - 1rem);
        overflow-y: auto;
        /* small inner padding so focus rings on TOC links don't get clipped */
        padding-right: 0.25rem;
        /* slim, on-hover scrollbar */
        scrollbar-width: thin;
        scrollbar-color: rgba(125, 129, 134, 0.3) transparent;
    }

    .ha-single__sidebar::-webkit-scrollbar { width: 6px; }
    .ha-single__sidebar::-webkit-scrollbar-thumb { background: rgba(125, 129, 134, 0.3); border-radius: 3px; }
    .ha-single__sidebar::-webkit-scrollbar-thumb:hover { background: rgba(125, 129, 134, 0.5); }
}

/* TOC sidebar */
.ha-toc-sidebar {
    margin-bottom: 2rem;
    border-left: 2px solid var(--ha-gray-200, rgb(230, 232, 235));
    padding: 0.25rem 0 0.25rem 1rem;
}

.ha-toc-sidebar__title {
    margin: 0 0 0.75rem;
    font-family: 'Nexa', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ha-gray-600, rgb(125, 129, 134));
}

.ha-toc-sidebar__list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: ha-toc;
}

.ha-toc-sidebar__list li {
    counter-increment: ha-toc;
    margin-bottom: 0.625rem;
    line-height: 1.4;
}

.ha-toc-sidebar__list a {
    display: block;
    padding: 0.25rem 0;
    color: var(--ha-gray-600, rgb(125, 129, 134));
    text-decoration: none;
    font-size: 0.9375rem;
    border-left: 2px solid transparent;
    padding-left: 0.75rem;
    margin-left: -0.875rem;
    transition: color 0.15s, border-color 0.15s;
}

.ha-toc-sidebar__list a::before {
    content: counter(ha-toc) ". ";
    color: var(--ha-gray-200, rgb(230, 232, 235));
    margin-right: 0.25rem;
}

.ha-toc-sidebar__list a:hover {
    color: var(--ha-blue-500, rgb(0, 167, 225));
}

.ha-toc-sidebar__list a[aria-current="true"] {
    color: var(--ha-blue-500, rgb(0, 167, 225));
    font-weight: 600;
    border-left-color: var(--ha-blue-500, rgb(0, 167, 225));
}

.ha-toc-sidebar__list a[aria-current="true"]::before {
    color: var(--ha-blue-500, rgb(0, 167, 225));
}

/* Mobile: TOC becomes inline collapsible */
@media (max-width: 899.98px) {
    .ha-toc-sidebar {
        border: 1px solid var(--ha-gray-200, rgb(230, 232, 235));
        border-radius: 0.75rem;
        padding: 1rem;
        margin: 0 0 1.5rem;
    }
}

/* ─── Share ───────────────────────────────────────────────────────── */
.ha-share {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--ha-gray-200, rgb(230, 232, 235));
}

.ha-share__title {
    margin: 0 0 0.75rem;
    font-family: 'Nexa', sans-serif;
    font-weight: 700;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ha-gray-600, rgb(125, 129, 134));
}

.ha-share__list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

.ha-share__list a,
.ha-share__copy {
    color: var(--ha-blue-500, rgb(0, 167, 225));
    text-decoration: none;
    font-size: 0.9375rem;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.ha-share__list a:hover,
.ha-share__copy:hover {
    text-decoration: underline;
}

.ha-share__copy.is-copied {
    color: var(--ha-gray-800, rgb(38, 45, 53));
}

/* ─── Author box & related (existing components fine) ─────────────── */
.ha-single__author-box {
    margin-top: 4rem;
}

.ha-related {
    margin-top: 4rem;
    padding: 3rem 0 4rem;
    background: rgba(204, 237, 249, 0.2);
}

.ha-related__title {
    font-family: 'Nexa', sans-serif;
    font-weight: 700;
    font-size: 1.75rem;
    margin: 0 0 2rem;
    text-align: center;
    color: var(--ha-gray-800, rgb(38, 45, 53));
}

/* ─── Reduced motion ──────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ha-read-progress::-webkit-progress-value { transition: none; }
    .ha-single__prose > :is(h2, h3, h4) .ha-anchor-link { transition: none; }
    .ha-single__prose a,
    .ha-toc-sidebar__list a,
    .ha-single__tags a { transition: none; }
}

/* ─── Focus polish ─────────────────────────────────────────────────── */
.ha-single__prose a:focus-visible,
.ha-toc-sidebar__list a:focus-visible,
.ha-share__list a:focus-visible,
.ha-share__copy:focus-visible,
.ha-single__tags a:focus-visible {
    outline: 2px solid var(--ha-blue-500, rgb(0, 167, 225));
    outline-offset: 3px;
    border-radius: 4px;
}
