/* ==========================================================
   Single Post — Editorial Reading Experience
   Scoped to .single-editorial. Loaded only on single posts
   (see bishalaryal_enqueue_single in functions.php).
   Reuses the theme's CSS custom properties from style.css.
   ========================================================== */

/* The hero replaces the wrapper's top padding: it clears the fixed
   glass nav internally. Only bottom padding remains on the wrapper. */
.single-editorial {
    /* No sidebar on single posts, so the content column can breathe.
       Head / content / toc / end sections / comments share this width
       where applicable (the hero spans the full site width). Scoped —
       global containers untouched. */
    --single-content-width: 960px;

    padding: 0 0 4rem;
    overflow-wrap: break-word;
}

html {
    scroll-padding-top: 7rem;
}

/* ----------------------------------------------------------
   1. ARTICLE HEAD — full-width hero
   Featured image is a background layer; the centered
   category / title / metadata sit on top with a subtle
   overlay for contrast.
   ---------------------------------------------------------- */
.single-head {
    position: relative;
    width: 100%;
    max-width: none;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-height: clamp(380px, 55vh, 620px);
    padding: clamp(6.5rem, 14vw, 8.5rem) 1.5rem clamp(3rem, 6vw, 4.5rem);
    color: #ffffff;
    background: var(--color-accent); /* fallback when no featured image */
}

.single-hero-bg {
    position: absolute;
    inset: 0;
}

.single-hero-bg img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

.single-hero-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(
        180deg,
        rgba(18, 27, 38, 0.58) 0%,
        rgba(18, 27, 38, 0.22) 45%,
        rgba(18, 27, 38, 0.74) 100%
    );
}

.single-hero-content {
    position: relative;
    max-width: 1100px;
    margin: 0 auto;
}

.single-category {
    display: inline-block;
    margin-bottom: 1.25rem;
}

.single-category a {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #ffffff;
    text-decoration: none;
    border-bottom: 2px solid rgba(255, 255, 255, 0.4);
    padding-bottom: 0.2rem;
    transition: border-color var(--transition-fast), color var(--transition-fast);
}

.single-category a:hover,
.single-category a:focus-visible {
    color: #ffffff;
    border-color: #ffffff;
    text-decoration: none;
}

.single-title {
    font-family: var(--font-heading);
    font-size: clamp(2.2rem, 3.5vw + 1rem, 4rem);
    font-weight: 800;
    line-height: 1.1;
    letter-spacing: -0.02em;
    color: #ffffff;
    text-shadow: 0 1px 4px rgba(9, 15, 23, 0.35);
    margin: 0 0 1.5rem;
    overflow-wrap: break-word;
    word-break: break-word;
    text-wrap: balance;
}

.single-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.3rem 0.75rem;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.9);
}

.single-meta a {
    color: #ffffff;
    font-weight: 600;
    text-decoration: none;
}

.single-meta a:hover,
.single-meta a:focus-visible {
    color: #ffffff;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.single-meta .meta-sep {
    color: rgba(255, 255, 255, 0.4);
    user-select: none;
}

.single-meta time {
    color: inherit;
}

.single-updated {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.75);
}

/* ----------------------------------------------------------
   3. TABLE OF CONTENTS — compact, collapsible, native
   ---------------------------------------------------------- */
.toc {
    max-width: var(--single-content-width);
    margin: 2.5rem auto 0;
    padding: 0 1.5rem;
}

.toc details {
    border-top: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    padding: 0.75rem 1rem;
}

.toc summary {
    list-style: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-accent);
    user-select: none;
}

.toc summary::-webkit-details-marker {
    display: none;
}

.toc summary::after {
    content: '+';
    font-weight: 600;
    transition: transform var(--transition-fast);
}

.toc details[open] summary::after {
    content: '\2212';
}

.toc summary:hover,
.toc summary:focus-visible {
    color: var(--color-primary);
}

.toc ol {
    list-style: none;
    margin: 0.75rem 0 0;
    padding: 0;
}

.toc li {
    margin: 0;
}

.toc a {
    display: block;
    padding: 0.5rem 0.25rem;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-border);
    font-size: 0.95rem;
    line-height: 1.4;
    text-decoration: none;
}

.toc li:last-child a {
    border-bottom: none;
}

.toc a:hover,
.toc a:focus-visible {
    color: var(--color-primary);
    padding-left: 0.5rem;
}

/* ----------------------------------------------------------
   4. ARTICLE BODY — optimized reading column
   ---------------------------------------------------------- */
.single-body {
    max-width: var(--single-content-width);
    margin: 3rem auto 0;
    padding: 0 1.5rem;
    font-size: 1.1875rem;
    line-height: 1.8;
    color: var(--color-text);
}

.single-body > * {
    margin-bottom: 1.6em;
}

.single-body p {
    margin-bottom: 1.6em;
}

.single-body h2,
.single-body h3,
.single-body h4 {
    color: var(--color-accent);
    line-height: 1.25;
    scroll-margin-top: 6.5rem;
}

.single-body h2 {
    font-size: 1.65rem;
    margin: 2.4em 0 0.8em;
}

.single-body h3 {
    font-size: 1.3rem;
    margin: 2em 0 0.7em;
}

.single-body h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.9em 0 0.6em;
}

.single-body a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 3px;
}

.single-body a:hover,
.single-body a:focus-visible {
    color: var(--color-accent);
}

.single-body ul,
.single-body ol {
    margin: 0 0 1.6em;
    padding-left: 1.4em;
}

.single-body ul {
    list-style: disc;
}

.single-body ol {
    list-style: decimal;
}

.single-body li {
    margin-bottom: 0.45em;
}

.single-body li > ul,
.single-body li > ol {
    margin-bottom: 0;
}

.single-body blockquote {
    margin: 2em 0;
    padding: 0.4em 0 0.4em 1.5em;
    border-left: 4px solid var(--color-accent);
    font-style: italic;
    font-size: 1.2em;
    color: var(--color-text-light);
}

.single-body blockquote p {
    margin-bottom: 0.6em;
}

.single-body blockquote p:last-child {
    margin-bottom: 0;
}

.single-body img {
    height: auto;
    border-radius: 8px;
}

.single-body figure {
    margin: 2em 0;
}

.single-body figure img {
    margin: 0;
}

.single-body figcaption,
.single-body .wp-caption-text {
    font-size: 0.85rem;
    color: var(--color-text-light);
    text-align: center;
    margin-top: 0.6em;
    line-height: 1.5;
}

.single-body .wp-caption {
    max-width: 100%;
}

.single-body pre {
    margin: 2em 0;
    padding: 1.25em;
    background: var(--color-card-bg);
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9em;
    line-height: 1.6;
}

.single-body code {
    background: var(--color-card-bg);
    padding: 0.15em 0.35em;
    border-radius: 4px;
    font-size: 0.875em;
}

.single-body pre code {
    background: none;
    padding: 0;
}

.single-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 2em 0;
    font-size: 0.95em;
}

.single-body th,
.single-body td {
    padding: 0.7em 0.9em;
    border-bottom: 1px solid var(--color-border);
    text-align: left;
}

.single-body th {
    font-weight: 600;
    color: var(--color-accent);
    background: var(--color-card-bg);
}

.single-body iframe,
.single-body video {
    max-width: 100%;
}

.single-body hr,
.single-body .wp-block-separator {
    border: 0;
    border-top: 1px solid var(--color-border);
    margin: 3em auto;
}

.single-body .wp-block-button {
    margin: 2em 0;
}

.single-body .wp-block-button__link {
    background: var(--color-accent);
    color: #fff;
    padding: 0.75em 1.6em;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
    transition: background var(--transition-fast);
}

.single-body .wp-block-button__link:hover {
    background: var(--color-primary);
}

.single-body .alignwide {
    margin-left: auto;
    margin-right: auto;
    max-width: 880px;
}

.single-body .alignfull {
    width: 100%;
    margin-left: -1.5rem;
    margin-right: -1.5rem;
    max-width: none;
}

.single-body .page-links {
    margin: 2em 0;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    font-weight: 600;
    color: var(--color-text-light);
    border-top: 1px solid var(--color-border);
    padding-top: 1.5em;
}

/* ----------------------------------------------------------
   5. ARTICLE END — author box, prev/next
   ---------------------------------------------------------- */
.end-sections {
    max-width: var(--single-content-width);
    margin: 3.5rem auto 0;
    padding: 0 1.5rem;
}

.article-author {
    border-top: 1px solid var(--color-border);
    padding-top: 2rem;
}

.article-author .author-meta {
    margin-top: 0;
}

.single-prevnext {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5rem;
    border-top: 1px solid var(--color-border);
    margin-top: 3rem;
    padding-top: 2rem;
}

.single-prevnext .label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-accent);
    margin-bottom: 0.4rem;
}

.single-prevnext h3 {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.35;
    margin: 0;
    transition: color var(--transition-fast);
}

.single-prevnext a {
    text-decoration: none;
    color: var(--color-text);
}

.single-prevnext a:hover h3,
.single-prevnext a:focus-visible h3 {
    color: var(--color-primary);
}

.single-prevnext .next {
    text-align: right;
}

/* ----------------------------------------------------------
   6. RELATED POSTS — same design language as the blog archive
   ---------------------------------------------------------- */
.related-wrap {
    max-width: var(--container-width);
    margin: 4rem auto 0;
    padding: 0 1.5rem;
}

.related-wrap .related-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--color-accent);
    margin: 0 0 1.75rem;
}

/* ----------------------------------------------------------
   7. COMMENTS
   ---------------------------------------------------------- */
.comments-area {
    max-width: var(--single-content-width);
    margin: 4rem auto 0;
    padding: 0 1.5rem;
}

.comments-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 1.5rem;
}

.comment-list {
    list-style: none;
    margin: 0 0 2.5rem;
    padding: 0;
}

.comment-body {
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--color-border);
}

.comment-author {
    font-weight: 600;
    color: var(--color-accent);
}

.comment-author .avatar {
    border-radius: 999px;
    float: left;
    margin-right: 0.9rem;
}

.comment-metadata {
    font-size: 0.85rem;
    margin: 0.25rem 0 0.75rem;
}

.comment-metadata a {
    color: var(--color-text-light);
    text-decoration: none;
}

.comment-content {
    font-size: 1rem;
    line-height: 1.7;
}

.comment-content a {
    color: var(--color-primary);
}

.reply a {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-accent);
    text-decoration: none;
}

.reply a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.no-comments {
    color: var(--color-text-light);
    font-style: italic;
}

.comment-respond {
    margin-top: 2.5rem;
    border-top: 1px solid var(--color-border);
    padding-top: 1.75rem;
}

.comment-reply-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-accent);
    margin-bottom: 1.25rem;
}

.comment-form p {
    margin-bottom: 1.25rem;
}

.comment-form label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.comment-form input[type='text'],
.comment-form input[type='email'],
.comment-form input[type='url'],
.comment-form textarea {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--color-text);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.comment-form input:focus,
.comment-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12);
}

.comment-form .submit {
    background: var(--color-accent);
    color: #fff;
    padding: 0.75rem 1.6rem;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.comment-form .submit:hover,
.comment-form .submit:focus-visible {
    background: var(--color-primary);
}

/* ----------------------------------------------------------
   8. READING PROGRESS — thin fixed line at the top of the
   viewport, tracking scroll position within .single-body.
   scaleX is driven by reading-progress.js; no layout cost.
   ---------------------------------------------------------- */
.read-progress {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    z-index: 99;
    background: var(--color-primary);
    transform: scaleX(0);
    transform-origin: left top;
    pointer-events: none;
    will-change: transform;
}

/* ----------------------------------------------------------
   9. RESPONSIVE
   ---------------------------------------------------------- */
@media (max-width: 900px) {
    .single-head {
        min-height: clamp(340px, 52vh, 520px);
        padding: 6rem 1.5rem 3.5rem;
    }

    .related-wrap {
        max-width: var(--container-width);
    }
}

@media (max-width: 640px) {
    .read-progress {
        height: 2px;
    }

    .single-head,
    .single-hero-content {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .single-head {
        min-height: clamp(320px, 50vh, 440px);
        padding: 5.25rem 1.25rem 3rem;
    }

    .single-body,
    .toc,
    .end-sections,
    .comments-area {
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .toc {
        margin-top: 2rem;
    }

    .single-body {
        font-size: 1.0625rem;
        margin-top: 2.5rem;
    }

    .single-body .alignfull {
        margin-left: -1.25rem;
        margin-right: -1.25rem;
    }

    .single-prevnext {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .single-prevnext .next {
        text-align: left;
        border-top: 1px solid var(--color-border);
        padding-top: 1.5rem;
    }

    /* Tables scroll instead of overflowing */
    .single-body .wp-block-table {
        overflow-x: auto;
        display: block;
    }
}

/* Small phones: keep the hero headline from ballooning and
   keep long titles readable with natural line breaks. */
@media (max-width: 480px) {
    .single-head {
        min-height: 300px;
        padding: 4.75rem 1.25rem 2.5rem;
    }

    .single-title {
        font-size: clamp(1.85rem, 8vw, 2.4rem);
        line-height: 1.15;
        margin-bottom: 1.25rem;
    }

    .single-meta {
        font-size: 0.875rem;
    }

    .single-body {
        font-size: 1rem;
        margin-top: 2.25rem;
    }

    .single-category a {
        font-size: 0.75rem;
    }

    .related-wrap {
        margin-top: 3rem;
        padding-left: 1.25rem;
        padding-right: 1.25rem;
    }

    .single-prevnext {
        margin-top: 2.5rem;
    }

    .comments-area {
        margin-top: 3rem;
    }
}