/* ============================================================
   Content details (article) page
   Narrow, reading-focused single column (Inter body type) + related grid band.
   Linked globally in ApplicationRoots/App.razor.
   ============================================================ */

/* Sit just under the sticky header (.tg-header__inner is 4rem tall). */
.article-progress {
    top: 4rem;
}

.article-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: var(--tg-text-muted);
}

.article-loading__inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ---------- Reading column ---------- */
.article-wrap {
    max-width: 50rem;
    margin: 0 auto;
    padding: 2rem 1rem 1rem;
}

@media (min-width: 768px) {
    .article-wrap {
        padding: 3rem 1.5rem 1.5rem;
    }
}

/* ---------- Aside (table of contents + most read) ---------- */
.article-aside {
    display: none;
}

@media (min-width: 1152px) {
    .article-shell--aside {
        display: grid;
        grid-template-columns: minmax(0, 50rem) 22rem;
        justify-content: center;
        gap: 3rem;
        max-width: 78rem;
        margin: 0 auto;
        padding: 0 1.5rem;
    }

    .article-shell--aside .article-wrap {
        max-width: none;
        margin: 0;
        padding-left: 0;
        padding-right: 0;
    }

    .article-aside {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
        min-width: 0;
        padding-top: 4.75rem;
        padding-bottom: 2rem;
    }
}

.article-toc {
    position: sticky;
    top: 5.5rem;
    padding: 1.5rem;
    background-color: var(--tg-bg-elev);
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-2xl);
}

.article-toc__title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--tg-text);
}

.article-toc__title .material-symbols-outlined {
    font-size: 20px;
    color: var(--tg-primary);
}

.article-toc__list {
    margin: 0;
    padding: 0;
    list-style: none;
    border-left: 2px solid var(--tg-border);
}

.article-toc__item a {
    display: block;
    margin-left: -2px;
    padding: 0.5rem 0 0.5rem 1rem;
    font-size: 0.9rem;
    line-height: 1.45;
    color: #4b5563;
    border-left: 2px solid transparent;
    text-decoration: none;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.article-toc__item a:hover {
    color: var(--tg-primary);
}

.article-toc__item a.is-active {
    font-weight: 600;
    color: var(--tg-primary);
    border-left-color: var(--tg-primary);
}

.article-toc__item--sub a {
    padding-left: 2rem;
    font-size: 0.85rem;
}

.article-head {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.article-head .article-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.article-head .article-cat {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--tg-accent-fg);
    background-color: var(--tg-accent);
    border-radius: 9999px;
    text-decoration: none;
    transition: background-color 0.2s ease;
}

.article-head .article-cat:hover {
    background-color: #d9e5fb;
}

.article-title {
    margin: 0;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--tg-reading-strong);
}

@media (min-width: 768px) {
    .article-title {
        font-size: 2.25rem;
    }
}

.article-excerpt {
    margin: 0;
    font-size: 1.125rem;
    line-height: 1.65;
    color: #4b5563;
}

/* ---------- Meta bar ---------- */
.article-metabar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 0;
    border-top: 1px solid var(--tg-border);
    border-bottom: 1px solid var(--tg-border);
}

.article-author {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.article-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 2.5rem;
    height: 2.5rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--tg-primary);
    background-color: rgba(37, 99, 235, 0.1);
    border-radius: 9999px;
}

.article-author__name {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tg-text);
}

.article-author__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.75rem;
    color: var(--tg-text-muted);
}

.article-author__meta span.inline {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.article-author__meta .material-symbols-outlined {
    font-size: 0.875rem;
}

.article-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.article-actions .article-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--tg-text);
    background-color: transparent;
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-lg);
    cursor: pointer;
    transition: border-color 0.2s ease, color 0.2s ease, background-color 0.2s ease;
}

.article-actions .article-btn:hover {
    color: var(--tg-primary);
    border-color: rgba(37, 99, 235, 0.4);
    background-color: var(--tg-bg-elev-2);
}

.article-actions .material-symbols-outlined {
    font-size: 1rem;
}

/* ---------- Cover ---------- */
.article-cover {
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 9;
    margin: 2rem 0;
    border: 1px solid var(--tg-border);
    border-radius: 1rem;
}

.article-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Body ---------- */
.article-body .editorjs-content-wrapper {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    font-size: 1.1875rem;
    line-height: 1.75;
    letter-spacing: -0.005em;
    color: var(--tg-reading-text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.article-body .editorjs-content-wrapper p {
    margin: 0 0 1.35em;
}

.article-body .editorjs-content-wrapper > p:first-child {
    font-size: 1.3125rem;
    line-height: 1.65;
    color: var(--tg-reading-strong);
}

.article-body .editorjs-content-wrapper b,
.article-body .editorjs-content-wrapper strong {
    font-weight: 700;
    color: var(--tg-reading-strong);
}

.article-body .editorjs-content-wrapper mark {
    padding: 0.05em 0.25em;
    color: inherit;
    background-color: #fde68a;
    border-radius: 0.25em;
}

.article-body .editorjs-content-wrapper a {
    font-weight: 500;
    color: var(--tg-primary);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    text-decoration-color: rgba(37, 99, 235, 0.35);
    transition: text-decoration-color 0.15s ease;
}

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

.article-body .editorjs-content-wrapper h2,
.article-body .editorjs-content-wrapper h3,
.article-body .editorjs-content-wrapper h4 {
    font-family: 'Montserrat', sans-serif;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.015em;
    color: var(--tg-reading-strong);
    scroll-margin-top: 5.5rem;
}

.article-body .editorjs-content-wrapper h2 {
    position: relative;
    margin: 2.4em 0 0.9em;
    padding-bottom: 0.6rem;
    font-size: 1.75rem;
    border-bottom: 1px solid var(--tg-border);
}

.article-body .editorjs-content-wrapper h2::after {
    content: "";
    position: absolute;
    left: 0;
    bottom: -2px;
    width: 3rem;
    height: 3px;
    border-radius: 9999px;
    background: linear-gradient(90deg, var(--tg-primary), var(--tg-accent-purple));
}

.article-body .editorjs-content-wrapper h3 {
    margin: 2em 0 0.7em;
    padding-left: 0.75rem;
    font-size: 1.375rem;
    border-left: 4px solid var(--tg-primary);
}

.article-body .editorjs-content-wrapper h4 {
    margin: 1.75em 0 0.6em;
    font-size: 1.15rem;
    color: var(--tg-primary-dark);
}

.article-body .editorjs-content-wrapper ul,
.article-body .editorjs-content-wrapper ol {
    margin: 0 0 1.5em;
    padding-left: 1.5rem;
}

.article-body .editorjs-content-wrapper li {
    margin: 0.45em 0;
    padding-left: 0.3rem;
}

.article-body .editorjs-content-wrapper li::marker {
    font-weight: 700;
    color: var(--tg-primary);
}

.article-body .editorjs-content-wrapper li > ul,
.article-body .editorjs-content-wrapper li > ol {
    margin: 0.3em 0 0;
}

.article-body .editorjs-content-wrapper blockquote {
    margin: 2em 0;
    padding: 1.25rem 1.5rem;
    font-size: 1.25rem;
    font-style: normal;
    font-weight: 500;
    line-height: 1.6;
    color: var(--tg-reading-strong);
    background-color: #eef3ff;
    border-left: 4px solid var(--tg-primary);
    border-radius: 0 var(--tg-radius-xl) var(--tg-radius-xl) 0;
}

.article-body .editorjs-content-wrapper blockquote p {
    margin: 0;
}

.article-body .editorjs-content-wrapper blockquote cite {
    display: block;
    margin-top: 0.75rem;
    font-size: 0.9rem;
    font-style: normal;
    font-weight: 600;
    color: var(--tg-text-muted);
}

.article-body .editorjs-content-wrapper blockquote cite::before {
    content: "— ";
}

.article-body .editorjs-content-wrapper hr.ce-delimiter {
    height: auto;
    margin: 2.5em 0;
    overflow: visible;
    border: 0;
    text-align: center;
}

.article-body .editorjs-content-wrapper hr.ce-delimiter::before {
    content: "• • •";
    font-size: 1.25rem;
    letter-spacing: 0.75em;
    color: #9aa3b2;
}

.article-body .editorjs-content-wrapper code {
    padding: 0.15em 0.4em;
    font-family: ui-monospace, 'Cascadia Code', Consolas, monospace;
    font-size: 0.85em;
    color: #3730a3;
    background-color: #eef2ff;
    border-radius: 0.3rem;
}

.article-body .editorjs-content-wrapper pre {
    margin: 1.75em 0;
    padding: 1.1rem 1.25rem;
    overflow-x: auto;
    font-size: 0.95rem;
    line-height: 1.6;
    color: #e2e8f0;
    background-color: #0f172a;
    border-radius: var(--tg-radius-xl);
}

.article-body .editorjs-content-wrapper pre code {
    padding: 0;
    font-size: inherit;
    color: inherit;
    background: none;
}

.article-body .ce-table {
    margin: 1.75em 0;
    overflow-x: auto;
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-xl);
}

.article-body .ce-table table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 1rem;
    line-height: 1.55;
}

.article-body .ce-table th,
.article-body .ce-table td {
    padding: 0.7rem 0.95rem;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
    border-bottom: 1px solid var(--tg-border);
}

.article-body .ce-table th + th,
.article-body .ce-table td + td {
    border-left: 1px solid var(--tg-border);
}

.article-body .ce-table tr:last-child td {
    border-bottom: 0;
}

.article-body .ce-table th {
    font-weight: 700;
    color: var(--tg-reading-strong);
    background-color: #f1f5f9;
}

.article-body .ce-table tr:nth-child(even) td {
    background-color: #f8fafc;
}

.article-body aside.ce-warning {
    display: block;
    margin: 1.75em 0;
    padding: 1rem 1.25rem;
    font-size: 1.0625rem;
    color: #78350f;
    background-color: #fffbeb;
    border-left: 4px solid #f59e0b;
    border-radius: 0 var(--tg-radius-xl) var(--tg-radius-xl) 0;
}

.article-body aside.ce-warning strong {
    color: #92400e;
}

.article-body figure.ce-embed {
    margin: 1.75em 0;
}

.article-body figure.ce-embed iframe {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: var(--tg-radius-xl);
}

.article-body figure.ce-embed figcaption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    text-align: center;
    color: var(--tg-text-muted);
}

@media (max-width: 640px) {
    .article-body .editorjs-content-wrapper {
        font-size: 1.0625rem;
        line-height: 1.7;
    }

    .article-body .editorjs-content-wrapper > p:first-child {
        font-size: 1.15rem;
    }

    .article-body .editorjs-content-wrapper h2 {
        font-size: 1.45rem;
    }

    .article-body .editorjs-content-wrapper h3 {
        font-size: 1.2rem;
    }

    .article-body .editorjs-content-wrapper blockquote {
        font-size: 1.1rem;
    }
}

.article-body figure.ce-image {
    margin: 1.5rem auto;
    text-align: center;
}

.article-body figure.ce-image img {
    display: block;
    max-width: 100%;
    height: auto;
    max-height: 80vh;
    object-fit: contain;
    margin: 0 auto;
    border-radius: var(--tg-radius-xl);
}

.article-body figure.ce-image figcaption {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--tg-text-muted);
    font-style: italic;
}

/* ---------- Tags ---------- */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 2.5rem;
}

.article-tags__label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tg-text-muted);
}

.article-tags .article-tag {
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--tg-text-muted);
    background: transparent;
    border: 1px solid var(--tg-border);
    border-radius: 9999px;
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.article-tags .article-tag:hover {
    color: var(--tg-primary);
    border-color: rgba(37, 99, 235, 0.4);
}

/* ---------- Related band ---------- */
.article-related {
    margin-top: 3rem;
    border-top: 1px solid var(--tg-border);
    background-color: #f2f4f8;
}

@media (min-width: 1024px) {
    .article-shell,
    .article-related {
        zoom: var(--tg-article-scale);
    }
}

.article-related__inner {
    max-width: 84rem;
    margin: 0 auto;
    padding: 2.5rem 1rem 3rem;
}

@media (min-width: 1024px) {
    .article-related__inner {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

.article-related__title {
    margin: 0 0 1.5rem;
    font-family: 'Montserrat', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--tg-text);
}

.article-related__text {
    font-size: 0.875rem;
    color: var(--tg-text-muted);
}

.article-related__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

@media (min-width: 640px) {
    .article-related__grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .article-related__grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.article-back {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    margin-top: 2rem;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--tg-text);
    background-color: var(--tg-bg-elev);
    border: 1px solid var(--tg-border);
    border-radius: var(--tg-radius-lg);
    text-decoration: none;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.article-back:hover {
    color: var(--tg-primary);
    border-color: rgba(37, 99, 235, 0.4);
}

.related-skeleton {
    height: 260px;
    border-radius: var(--tg-radius-xl);
    background: linear-gradient(90deg,
        rgba(15, 23, 42, 0.04) 25%,
        rgba(15, 23, 42, 0.08) 37%,
        rgba(15, 23, 42, 0.04) 63%);
    background-size: 400% 100%;
    animation: related-shimmer 1.4s ease infinite;
}

@keyframes related-shimmer {
    0% { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}
