/* ====================================================================
   News / Blog styles — article pages (news/<slug>.php, news/view.php)
   and the listing page (news/index.php).

   All colors come from the theme tokens defined in /styles.css, so these
   pages follow light/dark mode automatically instead of hardcoding a
   dark palette that broke the moment light mode was introduced.

   This file also provides the full typographic system for article BODY
   content — tables, code blocks, blockquotes, figures, callouts and
   nested lists — so HTML pasted into the admin editor renders as a
   properly designed article instead of raw unstyled markup.
   ==================================================================== */

/* ---------------------------------------------------------------- */
/* Shared section chrome                                             */
/* ---------------------------------------------------------------- */
.article-section,
.news-section {
    padding: 44px;
    background-color: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

/* The article column stays readable — long-form text at the full 1240px
   container width would run to ~150 characters per line. The container
   itself is wide (cards, listing grid, ads use that width); the prose
   inside is capped at a comfortable measure and centered. */
.article-section {
    max-width: 860px;
    margin-inline: auto;
}

/* ---------------------------------------------------------------- */
/* Single article page                                               */
/* ---------------------------------------------------------------- */
.article-section h1 {
    font-size: 40px;
    font-weight: 800;
    color: var(--text-strong);
    line-height: 1.15;
    letter-spacing: -0.025em;
    margin-bottom: 14px;
}

.article-section .author-info {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.article-content {
    font-size: 18px;
    color: var(--text);
    line-height: 1.75;
    overflow-wrap: break-word;
}

/* ---- Headings ----
   Tight bottom margins: a heading belongs to what comes AFTER it, so
   the gap below a heading is always much smaller than the gap above. */
.article-content h2 {
    font-size: 28px;
    font-weight: 700;
    color: var(--text-strong);
    line-height: 1.25;
    letter-spacing: -0.015em;
    margin-top: 42px;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.article-content h3 {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-strong);
    line-height: 1.3;
    margin-top: 30px;
    margin-bottom: 8px;
}

.article-content h4 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-strong);
    margin-top: 24px;
    margin-bottom: 6px;
}

.article-content > :first-child {
    margin-top: 0;
}

.article-content p {
    margin-bottom: 20px;
    color: var(--text);
}

/* ---- Lists ----
   The old rule was `margin: 0 0 20px 22px` with no padding control, so
   browser default padding (~40px) stacked on top of the margin and
   pushed bullets far from the heading/paragraph they belonged to. Now
   the indent is a single, modest padding-inline-start, and a list that
   directly follows a heading or its intro paragraph sits right under
   it. */
.article-content ul,
.article-content ol {
    margin: 10px 0 20px;
    padding-inline-start: 24px;
    color: var(--text);
}

.article-content li {
    margin-bottom: 8px;
    padding-inline-start: 4px;
}

.article-content li::marker {
    color: var(--accent);
    font-weight: 600;
}

.article-content li > p {
    margin-bottom: 8px;
}

/* Nested lists stay close to their parent item. */
.article-content li > ul,
.article-content li > ol {
    margin: 6px 0 6px;
}

/* A list right after a heading hugs it. */
.article-content h2 + ul,
.article-content h2 + ol,
.article-content h3 + ul,
.article-content h3 + ol,
.article-content h4 + ul,
.article-content h4 + ol {
    margin-top: 8px;
}

.article-content p + ul,
.article-content p + ol {
    margin-top: 2px;
}

/* ---- Links ---- */
.article-content a {
    color: var(--accent-text);
    text-decoration: underline;
    text-underline-offset: 2px;
    text-decoration-thickness: 1px;
}

.article-content a:hover,
.article-content a:focus-visible {
    text-decoration-thickness: 2px;
}

.article-content strong,
.article-content b {
    color: var(--text-strong);
    font-weight: 700;
}

.article-content em { font-style: italic; }

.article-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 36px 0;
}

/* ---- Tables ----
   Wrapped in .table-wrap by the renderer so a wide table scrolls inside
   its own box instead of blowing out the page width on mobile. */
.article-content .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 18px 0 26px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

.article-content table {
    width: 100%;
    border-collapse: collapse;
    font-size: 16px;
    min-width: 420px;
}

/* A bare table (not wrapped) still behaves. */
.article-content > table {
    display: block;
    overflow-x: auto;
}

.article-content thead th {
    background: var(--surface-3);
    color: var(--text-strong);
    font-weight: 700;
    text-align: start;
    font-size: 14.5px;
    letter-spacing: 0.01em;
}

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

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

.article-content tbody tr:nth-child(even) {
    background: var(--surface-2);
}

.article-content tbody tr:hover {
    background: var(--accent-soft);
}

.article-content table caption {
    caption-side: bottom;
    padding: 10px 16px;
    font-size: 13.5px;
    color: var(--text-muted);
    text-align: start;
}

/* ---- Code ---- */
.article-content code {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
                 "Liberation Mono", monospace;
    font-size: 0.88em;
    background: var(--code-bg);
    color: var(--code-text);
    padding: 0.15em 0.4em;
    border-radius: 5px;
    border: 1px solid var(--border);
    overflow-wrap: break-word;
}

.article-content pre {
    background: var(--pre-bg);
    color: var(--pre-text);
    padding: 18px 20px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 18px 0 26px;
    font-size: 14.5px;
    line-height: 1.6;
    border: 1px solid var(--border);
    tab-size: 2;
}

/* Inside a <pre>, <code> must not repeat the inline pill styling. */
.article-content pre code {
    background: none;
    border: none;
    padding: 0;
    color: inherit;
    font-size: inherit;
    white-space: pre;
}

/* ---- Blockquote ---- */
.article-content blockquote {
    margin: 22px 0;
    padding: 4px 22px;
    border-inline-start: 4px solid var(--accent);
    background: var(--surface-2);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text);
    font-style: italic;
}

[dir="rtl"] .article-content blockquote {
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}

.article-content blockquote p:last-child {
    margin-bottom: 0;
}

.article-content blockquote cite {
    display: block;
    margin-top: 8px;
    font-size: 14px;
    font-style: normal;
    color: var(--text-muted);
}

/* ---- Figures & images ---- */
.article-content figure {
    margin: 24px 0;
}

.article-content figcaption {
    margin-top: 8px;
    font-size: 14px;
    color: var(--text-muted);
    text-align: center;
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
}

/* ---- Callout boxes (class="note" | "tip" | "warning") ---- */
.article-content .note,
.article-content .tip,
.article-content .warning {
    margin: 22px 0;
    padding: 16px 20px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.article-content .tip {
    border-inline-start: 4px solid var(--success);
    background: var(--success-soft);
}

.article-content .warning {
    border-inline-start: 4px solid var(--accent);
    background: var(--accent-soft);
}

.article-content .note p:last-child,
.article-content .tip p:last-child,
.article-content .warning p:last-child {
    margin-bottom: 0;
}

/* Featured / inline images */
.featured-image {
    width: 100%;
    height: auto;
    max-height: 440px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    margin-bottom: 30px;
    border: 1px solid var(--border);
    background: var(--surface-2);
}

.article-inline-image {
    width: 100%;
    height: auto;
    border-radius: var(--radius-sm);
    margin: 20px 0;
    border: 1px solid var(--border);
    display: block;
}

/* Footer link back to /news */
.article-footer,
.admin-panel-footer {
    margin-top: 36px;
    padding-top: 22px;
    border-top: 1px solid var(--border);
    text-align: start;
    color: var(--text-muted);
}

.article-footer a,
.article-section .admin-panel-footer a {
    color: var(--accent-text);
    text-decoration: none;
    font-weight: 600;
}

.article-footer a:hover,
.article-section .admin-panel-footer a:hover {
    text-decoration: underline;
}

/* ---------------------------------------------------------------- */
/* Related articles (internal linking / topical authority)           */
/* ---------------------------------------------------------------- */
.related-articles {
    max-width: 860px;
    margin: 24px auto 0;
    padding: 32px 44px 36px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.related-articles h2 {
    font-size: 22px;
    color: var(--text-strong);
    margin-bottom: 16px;
}

.related-list {
    list-style: none;
    display: grid;
    gap: 12px;
    padding: 0;
    margin: 0;
}

.related-list li {
    margin: 0;
}

.related-list a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--text);
    font-weight: 600;
    font-size: 15.5px;
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.related-list a:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent-text);
}

.related-list img {
    width: 76px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    flex-shrink: 0;
    background: var(--surface-3);
}

/* ---------------------------------------------------------------- */
/* News LISTING page (news/index.php)                                */
/* ---------------------------------------------------------------- */
.news-section h1 {
    font-size: 34px;
    font-weight: 800;
    color: var(--text-strong);
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.news-section .tagline {
    font-size: 17px;
    color: var(--text-muted);
    margin-bottom: 30px;
}

.news-content {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.post {
    background-color: var(--surface-2);
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 22px;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.post:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow);
}

.post .thumbnail {
    width: 230px;
    height: 154px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    background-color: var(--surface-3);
    border: 1px solid var(--border);
}

.post-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1;
}

.post h2 {
    font-size: 22px;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 6px;
}

.post h2 a {
    color: var(--text-strong);
    text-decoration: none;
}

.post h2 a:hover,
.post h2 a:focus-visible {
    color: var(--accent-text);
    text-decoration: underline;
}

.post .post-meta {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 10px;
    text-align: start;
    order: -1;
}

.post p {
    font-size: 15px;
    color: var(--text-muted);
    line-height: 1.6;
    margin-bottom: 12px;
}

.post .read-more {
    font-size: 14px;
    color: var(--accent-text);
    text-decoration: none;
    font-weight: 700;
    align-self: flex-start;
}

.post .read-more:hover,
.post .read-more:focus-visible {
    text-decoration: underline;
}

.news-section a {
    color: var(--accent-text);
}

/* ---------------------------------------------------------------- */
/* Responsive                                                         */
/* ---------------------------------------------------------------- */
@media (max-width: 768px) {
    .article-section,
    .news-section {
        padding: 24px 18px;
    }

    .related-articles {
        padding: 24px 18px 28px;
    }

    .article-section h1 { font-size: 28px; }
    .article-content { font-size: 16.5px; }
    .article-content h2 { font-size: 23px; margin-top: 32px; }
    .article-content h3 { font-size: 19.5px; margin-top: 24px; }
    .article-content pre { font-size: 13.5px; padding: 14px 16px; }
    .article-content table { font-size: 14.5px; }
    .article-content th,
    .article-content td { padding: 10px 12px; }

    .news-section h1 { font-size: 26px; }
    .news-section .tagline { font-size: 15px; }

    .post {
        flex-direction: column;
    }
    .post .thumbnail {
        width: 100%;
        height: 190px;
    }
    .post h2 { font-size: 19px; }

    .related-list a { font-size: 14.5px; }
    .related-list img { width: 60px; height: 42px; }
}

@media (max-width: 480px) {
    .article-section h1 { font-size: 24px; }
    .news-section h1 { font-size: 22px; }
    .post .thumbnail { height: 165px; }
}
