/* =========================================================
   Article Detail — IranSQLClub (Nikseo-inspired layout)
   Colors: #0798e8 · #111827 · #eaf8ff
   ========================================================= */

:root {
    --pd-primary: #0798e8;
    --pd-primary-dark: #0079bd;
    --pd-primary-light: #eaf8ff;
    --pd-dark: #111827;
    --pd-dark-mid: #1a2d47;
    --pd-text: #252a31;
    --pd-muted: #7b8794;
    --pd-border: #e9edf1;
    --pd-bg: #f5f7fa;
    --pd-radius: 16px;
}

/* ── Page ── */

body {
    background: var(--pd-bg);
}

.article-page {
    width: 100%;
    padding-bottom: 80px;
}

.article-container {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}

/* ── HERO (dark header like reference) ── */

.article-hero {
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #111827 0%, #0f2744 50%, #162f50 100%);
    padding-bottom: 0;
}

.article-hero::before {
    content: "";
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 80% at 85% 20%, rgba(7, 152, 232, .18) 0%, transparent 60%),
        radial-gradient(ellipse 40% 60% at 10% 80%, rgba(7, 152, 232, .08) 0%, transparent 50%);
    pointer-events: none;
}

.article-hero__inner {
    position: relative;
    z-index: 1;
}

.article-hero .article-breadcrumb {
    padding: 22px 0 0;
    font-size: 13px;
    color: rgba(255, 255, 255, .5);
}

.article-hero .article-breadcrumb a {
    color: rgba(255, 255, 255, .75);
    text-decoration: none;
    transition: color .2s;
}

.article-hero .article-breadcrumb a:hover {
    color: var(--pd-primary);
}

.article-hero .breadcrumb-separator {
    color: rgba(255, 255, 255, .3);
}

.article-hero .breadcrumb-current {
    color: rgba(255, 255, 255, .45);
}

.article-hero__grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 380px;
    gap: 36px;
    align-items: center;
    padding: 28px 0 48px;
}

.article-hero__info {
    min-width: 0;
}

.article-hero__category {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    margin-bottom: 16px;
    border-radius: 50px;
    background: rgba(7, 152, 232, .18);
    border: 1px solid rgba(7, 152, 232, .35);
    color: #7dd3fc;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background .2s;
}

.article-hero__category:hover {
    background: rgba(7, 152, 232, .3);
    color: #fff;
}

.article-hero h1 {
    margin: 0 0 22px;
    font-size: clamp(26px, 3.2vw, 38px);
    line-height: 1.55;
    font-weight: 800;
    color: #ffffff;
    letter-spacing: -.3px;
}

.article-hero .article-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 14px;
    margin-bottom: 0;
}

.article-hero .meta-item {
    color: rgba(255, 255, 255, .65);
    font-size: 13px;
}

.article-hero .meta-item svg {
    color: rgba(255, 255, 255, .45);
}

.article-hero .author-label {
    color: rgba(255, 255, 255, .45);
}

.article-hero .author-name {
    color: #fff;
    font-weight: 700;
}

.article-hero .author-name a {
    color: #7dd3fc;
    text-decoration: none;
    transition: color .2s;
}

.article-hero .author-name a:hover {
    color: #fff;
}

.article-hero .author-role {
    color: rgba(255, 255, 255, .5);
}

.article-hero .author-avatar {
    border-color: rgba(255, 255, 255, .2);
}

.article-hero .article-excerpt {
    margin-top: 20px;
    padding: 14px 18px;
    background: rgba(255, 255, 255, .06);
    border-right: 3px solid var(--pd-primary);
    border-radius: 10px;
    color: rgba(255, 255, 255, .75);
    font-size: 14px;
    line-height: 1.9;
}

.article-hero__image {
    width: 100%;
    height: 270px;
    border-radius: var(--pd-radius);
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(0, 0, 0, .4);
    border: 1px solid rgba(255, 255, 255, .08);
}

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

/* ── Main layout ── */

.article-main {
    margin-top: -28px;
    position: relative;
    z-index: 2;
}

.article-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 28px;
    align-items: start;
}

/* ── Article card ── */

.article-card {
    background: #fff;
    border: 1px solid var(--pd-border);
    border-radius: var(--pd-radius);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(15, 23, 42, .07);
}

.article-body {
    padding: 42px 48px 28px;
}

/* ── Typography ── */

.content-typography {
    max-width: 800px;
    margin: 0 auto;
    color: #303841;
    font-size: 17px;
    line-height: 2.15;
    overflow-wrap: break-word;
}

.content-typography p { margin: 0 0 25px; }

.content-typography h2 {
    position: relative;
    margin: 52px 0 20px;
    padding-right: 16px;
    font-size: 25px;
    line-height: 1.6;
    font-weight: 800;
    color: var(--pd-dark);
}

.content-typography h2::before {
    content: "";
    position: absolute;
    right: 0;
    top: 7px;
    width: 4px;
    height: calc(100% - 14px);
    border-radius: 4px;
    background: var(--pd-primary);
}

.content-typography h3 {
    margin: 38px 0 15px;
    font-size: 21px;
    font-weight: 750;
    color: #202830;
}

.content-typography h4 {
    margin: 30px 0 12px;
    font-size: 18px;
    font-weight: 700;
    color: #303841;
}

.content-typography a {
    color: var(--pd-primary);
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

.content-typography a:hover { color: var(--pd-primary-dark); }

.content-typography ul,
.content-typography ol {
    margin: 20px 0 28px;
    padding-right: 28px;
}

.content-typography li { margin-bottom: 10px; }
.content-typography li::marker { color: var(--pd-primary); }

.content-typography img {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 32px auto;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .06);
}

.content-typography code {
    direction: ltr;
    display: inline-block;
    padding: 2px 7px;
    border-radius: 5px;
    background: #f1f3f5;
    color: #c2410c;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: .88em;
    unicode-bidi: plaintext;
}

.content-typography pre {
    direction: ltr;
    margin: 30px 0;
    padding: 22px;
    overflow-x: auto;
    border-radius: 12px;
    background: #18191b;
    color: #e5e7eb;
    font-family: "Cascadia Code", "Fira Code", Consolas, monospace;
    font-size: 14px;
    line-height: 1.8;
    text-align: left;
}

.content-typography pre code {
    display: block;
    padding: 0;
    background: transparent;
    color: inherit;
    white-space: pre;
}

.content-typography blockquote {
    margin: 30px 0;
    padding: 18px 22px;
    background: var(--pd-primary-light);
    border-right: 4px solid var(--pd-primary);
    border-radius: 10px;
    color: #4b5563;
}

.content-typography table {
    width: 100%;
    margin: 30px 0;
    border-collapse: collapse;
    font-size: 14px;
}

.content-typography th,
.content-typography td {
    padding: 10px 14px;
    border: 1px solid var(--pd-border);
    text-align: right;
}

.content-typography th {
    background: var(--pd-primary-light);
    color: var(--pd-dark);
    font-weight: 700;
}

/* ── Code copy ── */

.code-wrapper { position: relative; margin: 30px 0; }
.code-wrapper pre { margin: 0; }

.copy-code-btn {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    border: 1px solid rgba(255, 255, 255, .12);
    background: rgba(255, 255, 255, .08);
    color: #d1d5db;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: 11px;
    cursor: pointer;
    transition: all .2s;
}

.copy-code-btn:hover { background: rgba(255, 255, 255, .15); color: #fff; }
.copy-code-btn.copied { background: var(--pd-primary); color: #fff; }

/* ── Actions ── */

.post-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    max-width: 800px;
    margin: 36px auto 0;
    padding-top: 28px;
    border-top: 1px solid var(--pd-border);
}

.like-section { display: flex; gap: 10px; }

.like-btn,
.dislike-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 50px;
    border: 1px solid var(--pd-border);
    background: #fff;
    color: #59636e;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.like-btn:hover,
.dislike-btn:hover {
    border-color: var(--pd-primary);
    color: var(--pd-primary);
}

.like-btn.active {
    background: var(--pd-primary-light);
    border-color: var(--pd-primary);
    color: var(--pd-primary-dark);
}

.dislike-btn.active {
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
}

.share-section { display: flex; gap: 8px; }

.share-btn {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--pd-border);
    background: #fff;
    color: #59636e;
    cursor: pointer;
    font-size: 15px;
    transition: all .2s;
}

.share-btn:hover {
    border-color: var(--pd-primary);
    color: var(--pd-primary);
    transform: translateY(-2px);
}

/* ── Sidebar ── */

.article-sidebar {
    position: sticky;
    top: 85px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.toc-card {
    background: #fff;
    border: 1px solid var(--pd-border);
    border-radius: 14px;
    padding: 20px;
    box-shadow: 0 5px 20px rgba(15, 23, 42, .04);
}

.toc-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 750;
    color: var(--pd-dark);
}

.toc-title svg { color: var(--pd-primary); flex-shrink: 0; }

.toc-list {
    margin: 0;
    padding: 0;
    list-style: none;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.toc-list li { margin: 2px 0; }

.toc-list a {
    display: block;
    padding: 7px 9px;
    border-radius: 7px;
    color: #69737e;
    text-decoration: none;
    font-size: 12px;
    line-height: 1.8;
    transition: all .2s;
}

.toc-list a:hover {
    background: var(--pd-primary-light);
    color: var(--pd-primary);
}

.toc-list a.active {
    background: var(--pd-primary-light);
    color: var(--pd-primary-dark);
    font-weight: 600;
}

.toc-list .toc-h3 {
    padding-right: 24px;
    font-size: 11.5px;
}

.toc-empty {
    color: #9aa1aa;
    font-size: 12px;
    line-height: 1.8;
}

/* Sidebar CTA */

.sidebar-cta {
    background: linear-gradient(135deg, var(--pd-dark) 0%, #1a3a5c 100%);
    border-radius: 14px;
    padding: 22px 20px;
    text-align: center;
    border: 1px solid rgba(7, 152, 232, .2);
}

.sidebar-cta__icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.sidebar-cta__title {
    margin: 0 0 8px;
    font-size: 15px;
    font-weight: 800;
    color: #fff;
}

.sidebar-cta__text {
    margin: 0 0 16px;
    font-size: 12px;
    line-height: 1.8;
    color: rgba(255, 255, 255, .65);
}

.sidebar-cta__btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: 50px;
    background: var(--pd-primary);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    transition: background .2s, transform .2s;
    box-shadow: 0 6px 18px rgba(7, 152, 232, .3);
}

.sidebar-cta__btn:hover {
    background: var(--pd-primary-dark);
    transform: translateY(-2px);
    color: #fff;
}

/* ── Related posts ── */

.related-posts-section {
    max-width: 800px;
    margin: 48px auto 0;
    padding-top: 32px;
    border-top: 1px solid #edf0f2;
}

.related-posts-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.related-posts-header svg { color: var(--pd-primary); }

.related-posts-header h3 {
    margin: 0;
    font-size: 21px;
    font-weight: 750;
    color: var(--pd-dark);
}

.related-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
}

.related-post-card {
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--pd-border);
    background: #fff;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .25s, border-color .25s, transform .25s;
}

.related-post-card:hover {
    border-color: #c5e8fa;
    box-shadow: 0 10px 28px rgba(7, 152, 232, .12);
    transform: translateY(-3px);
}

.related-post-image {
    height: 130px;
    overflow: hidden;
    background: #eef1f4;
}

.related-post-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .4s;
}

.related-post-card:hover .related-post-image img {
    transform: scale(1.04);
}

.related-post-content { padding: 14px 16px 16px; }

.related-post-title {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--pd-dark);
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.related-post-card:hover .related-post-title { color: var(--pd-primary); }

.related-post-meta {
    font-size: 11px;
    color: var(--pd-muted);
}

/* ── Comments ── */

.comments-section {
    max-width: 800px;
    margin: 48px auto 0;
    padding-top: 32px;
    border-top: 1px solid #edf0f2;
}

.comments-section h3 {
    margin: 0 0 24px;
    font-size: 21px;
    font-weight: 750;
    color: var(--pd-dark);
}

.comment-item {
    padding: 18px 0;
    border-bottom: 1px solid #f0f2f4;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.comment-author {
    font-size: 14px;
    font-weight: 700;
    color: var(--pd-dark);
}

.comment-date {
    color: #a0a7ae;
    font-size: 11px;
}

.comment-content {
    color: #59636d;
    font-size: 14px;
    line-height: 1.9;
}

.comment-form {
    margin-top: 30px;
    padding: 24px;
    border: 1px solid #e8ecef;
    border-radius: 14px;
    background: #fafbfc;
}

.comment-form h4 {
    margin: 0 0 20px;
    font-size: 17px;
    font-weight: 700;
    color: #303841;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-group { margin-bottom: 18px; }

.form-group label {
    display: block;
    margin-bottom: 7px;
    color: #555f69;
    font-size: 13px;
    font-weight: 600;
}

.form-group input,
.form-group textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 11px 13px;
    border: 1px solid #dfe4e8;
    border-radius: 8px;
    background: #fff;
    color: #303841;
    font-family: inherit;
    font-size: 13px;
    transition: all .2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--pd-primary);
    box-shadow: 0 0 0 3px rgba(7, 152, 232, .1);
}

.submit-btn {
    padding: 11px 22px;
    border: 0;
    border-radius: 8px;
    background: var(--pd-primary);
    color: #fff;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all .2s;
}

.submit-btn:hover {
    background: var(--pd-primary-dark);
    transform: translateY(-1px);
}

.alert {
    padding: 11px 14px;
    margin-bottom: 18px;
    border-radius: 8px;
    font-size: 13px;
}

.alert-success {
    background: var(--pd-primary-light);
    color: var(--pd-primary-dark);
}

/* ── Mobile TOC ── */

.toc-mobile {
    display: none;
    margin-bottom: 18px;
    border: 1px solid var(--pd-border);
    border-radius: 12px;
    background: #fff;
    overflow: hidden;
}

.toc-mobile summary {
    padding: 14px 16px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 650;
    color: #303841;
}

.toc-mobile .toc-list {
    padding: 0 12px 12px;
    max-height: 350px;
}

/* ── Author (shared) ── */

.author-info {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.author-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.author-label {
    font-size: 11px;
    color: #9aa4b2;
    font-weight: 600;
}

.author-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #f0f2f4;
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
}

.meta-item svg { flex-shrink: 0; }

/* ── Responsive ── */

@media (max-width: 1050px) {
    .article-layout { grid-template-columns: 1fr; }
    .article-sidebar { display: none; }
    .toc-mobile { display: block; }

    .article-hero__grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .article-hero__image {
        order: -1;
        height: 240px;
    }
}

@media (max-width: 850px) {
    .article-body { padding: 32px 28px 20px; }
    .content-typography { font-size: 16px; line-height: 2.05; }
    .related-posts-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 600px) {
    .article-container { width: min(100% - 20px, 100%); }
    .article-hero h1 { font-size: 23px; }
    .article-hero__image { height: 200px; }
    .article-body { padding: 25px 18px 15px; }
    .content-typography { font-size: 15.5px; }
    .content-typography h2 { font-size: 21px; margin-top: 42px; }
    .related-posts-grid { grid-template-columns: 1fr; }
    .post-actions { flex-direction: column; align-items: stretch; }
    .like-section { width: 100%; }
    .like-btn, .dislike-btn { flex: 1; justify-content: center; }
    .form-grid { grid-template-columns: 1fr; }
}
