/* ==========================================================================
   Finance for Cambodians - style.css
   Simple, Wikipedia-style design. Replace the whole old file with this one.
   Colors and sizes are set once in :root below, so you can change them there.
   ========================================================================== */

:root {
    --text: #202122;
    --muted: #54595d;
    --link: #0645ad;
    --link-hover: #0b0080;
    --border: #a2a9b1;
    --border-light: #eaecf0;
    --panel: #f8f9fa;
    --accent: #032ea1;
    --accent-text: #ffffff;
    --bg: #ffffff;
    --max-width: 1000px;
    --font: "Hanuman", "Khmer OS Battambang", "Noto Sans Khmer", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.8;
}

[hidden] { display: none !important; }
img, video { max-width: 100%; height: auto; }

a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

h1, h2, h3, h4 { line-height: 1.4; margin: 1.2em 0 0.5em; font-weight: 700; color: var(--text); }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.45rem; border-bottom: 1px solid var(--border); padding-bottom: 0.2em; }
h3 { font-size: 1.15rem; }
p  { margin: 0.6em 0 1em; }
ul, ol { margin: 0.5em 0 1em; padding-left: 1.6em; }
li { margin-bottom: 0.4em; }

/* ---------- Header: logo + name on the left, menu on the right (built by main.js) ---------- */
header { background: var(--panel); border-bottom: 1px solid var(--border); }

.topbar-inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 8px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 20px;
}
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); }
.brand:hover { color: var(--text); text-decoration: none; }
.brand img { height: 40px; width: auto; display: block; }
.brand-name { font-size: 1.15rem; font-weight: 700; line-height: 1.3; white-space: nowrap; }

.mainnav { background: transparent; border: 0; }
.nav-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; align-items: center; }
.nav-item { margin: 0; }
.nav-link {
    display: block;
    padding: 8px 14px;
    color: var(--link);
    font-weight: 700;
    border-bottom: 3px solid transparent;
}
.nav-link:hover { background: var(--border-light); text-decoration: none; }
.nav-link.current { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- Footer (built by main.js) ---------- */
footer {
    background: var(--panel);
    border-top: 1px solid var(--border);
    margin-top: 40px;
    color: var(--muted);
    font-size: 0.93rem;
}
.footer-inner { max-width: var(--max-width); margin: 0 auto; padding: 22px 16px 14px; }

.footer-follow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--border);
}
.footer-follow h3 { margin: 0 0 2px; font-size: 1.1rem; color: var(--text); }
.footer-follow p { margin: 0; }
.footer-follow-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.footer-btn {
    display: inline-block;
    padding: 7px 14px;
    background: var(--accent);
    color: var(--accent-text);
    border: 1px solid var(--accent);
    border-radius: 2px;
    font-weight: 700;
}
.footer-btn:hover { background: #02227a; color: var(--accent-text); text-decoration: none; }
.footer-btn-ghost { background: #fff; color: var(--accent); }
.footer-btn-ghost:hover { background: var(--panel); color: var(--accent); }

.footer-cols {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    padding: 18px 0;
}
.footer-col h4 { margin: 0 0 6px; font-size: 1rem; border: 0; padding: 0; }
.footer-col-list { list-style: none; margin: 0; padding: 0; }
.footer-col-list li { margin: 0 0 3px; }

.footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 6px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 0.88rem;
}

/* ---------- Page layout ---------- */
.container { max-width: var(--max-width); margin: 0 auto; padding: 20px 16px 10px; }

/* ---------- Top section (title + search) ---------- */
.hero {
    text-align: center;
    padding: 32px 16px 28px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.hero h1 { margin: 0 0 0.3em; font-size: 2rem; border: 0; }
.hero p { margin: 0 auto 1em; max-width: 700px; color: var(--muted); }
.hero.small { padding: 22px 16px; }
.hero.small h1 { font-size: 1.7rem; margin-bottom: 0.2em; }
.hero.small p { margin-bottom: 0.5em; }
.hero-actions { margin-top: 16px; display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }

/* ---------- Search ---------- */
.search-box { display: flex; max-width: 620px; margin: 14px auto 0; }
.search-box input {
    flex: 1;
    min-width: 0;
    padding: 10px 12px;
    font: inherit;
    border: 1px solid var(--border);
    border-right: 0;
    border-radius: 2px 0 0 2px;
    background: #fff;
    color: var(--text);
}
.search-box button {
    padding: 10px 18px;
    font: inherit;
    font-weight: 700;
    background: var(--panel);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0 2px 2px 0;
    cursor: pointer;
}
.search-box button:hover { background: var(--border-light); }

/* ---------- Buttons ---------- */
.btn-cta, .btn-ghost, .see-all-btn {
    display: inline-block;
    padding: 9px 18px;
    border-radius: 2px;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid var(--accent);
}
.btn-cta { background: var(--accent); color: var(--accent-text); }
.btn-cta:hover { background: #02227a; color: var(--accent-text); text-decoration: none; }
.btn-ghost, .see-all-btn { background: #fff; color: var(--accent); }
.btn-ghost:hover, .see-all-btn:hover { background: var(--panel); text-decoration: none; }

/* ---------- Category buttons (filter on Home and Articles pages) ---------- */
.categories-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.cat-chip {
    padding: 5px 14px;
    font: inherit;
    font-size: 0.92rem;
    background: var(--panel);
    color: var(--link);
    border: 1px solid var(--border);
    border-radius: 2px;
    cursor: pointer;
}
.cat-chip:hover { background: var(--border-light); }
.cat-chip.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---------- Section title + tabs ---------- */
.section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}
.section-header h2 { margin: 0; border: 0; padding: 0 0 4px; }
.tabs { display: flex; gap: 2px; }
.tab-btn {
    padding: 6px 14px;
    font: inherit;
    font-size: 0.92rem;
    background: transparent;
    color: var(--link);
    border: 0;
    border-bottom: 3px solid transparent;
    cursor: pointer;
}
.tab-btn:hover { background: var(--panel); }
.tab-btn.active { color: var(--text); font-weight: 700; border-bottom-color: var(--accent); }

.result-count { margin: 6px 0 14px; color: var(--muted); font-size: 0.9rem; }

/* ---------- Article cards (built by main.js) ---------- */
.article-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 18px;
}
.article-card {
    display: block;
    border: 1px solid var(--border-light);
    background: #fff;
    color: var(--text);
    overflow: hidden;
}
.article-card:hover { border-color: var(--border); text-decoration: none; }
.article-card:hover h3 { color: var(--link); text-decoration: underline; }

.thumbnail-wrapper { position: relative; background: var(--border-light); }
.thumbnail-wrapper img { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.watermark {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 1px 8px;
    background: var(--accent);
    color: var(--accent-text);
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1.6;
}

.article-content-box { padding: 10px 12px 12px; }
.article-category-tag { display: block; color: var(--muted); font-size: 0.82rem; }
.article-card h3 { margin: 2px 0 4px; font-size: 1.05rem; line-height: 1.5; }
.article-desc {
    margin: 0 0 6px;
    font-size: 0.92rem;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.article-meta { font-size: 0.82rem; color: var(--muted); }

.status-msg { grid-column: 1 / -1; padding: 20px 10px; text-align: center; color: var(--muted); }
.article-grid .ad-in-feed { grid-column: 1 / -1; }

.see-all-container { text-align: center; margin: 26px 0; }

/* ---------- Call-to-action box ---------- */
.cta-box {
    margin: 32px 0;
    padding: 18px 20px;
    background: var(--panel);
    border: 1px solid var(--border);
    text-align: center;
}
.cta-box h2 { margin: 0 0 0.3em; border: 0; padding: 0; font-size: 1.25rem; }
.cta-box p { margin: 0 0 1em; color: var(--muted); }

/* ---------- Text pages (About, Contact) ---------- */
.page-content { max-width: 800px; margin: 0 auto; }
.page-content br { display: none; }
.page-content h2 { margin-top: 1.6em; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    margin: 1em 0;
}
.info-card { border: 1px solid var(--border); background: var(--panel); padding: 12px 16px; }
.info-card h3 { margin: 0 0 0.3em; font-size: 1.05rem; }
.info-card p { margin: 0; font-size: 0.95rem; color: var(--muted); }

/* Contact page */
.contact-container { max-width: 900px; margin: 0 auto; }
.purpose-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.purpose-card { border: 1px solid var(--border); background: #fff; padding: 14px 18px; }
.purpose-card h2 { margin: 0 0 0.4em; padding: 0; border: 0; font-size: 1.1rem; }
.purpose-card p { margin: 0; color: var(--muted); font-size: 0.95rem; }
.purpose-card strong { color: var(--text); }

.channels-card { border: 1px solid var(--border); background: var(--panel); padding: 18px 20px; text-align: center; }
.channels-card h2 { margin: 0 0 0.2em; padding: 0; border: 0; font-size: 1.2rem; }
.channels-card p.subtitle { margin: 0 0 14px; color: var(--muted); font-size: 0.95rem; }
.channels-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; }
.channel-item { border: 1px solid var(--border); background: #fff; padding: 12px; }
.channel-item h3 { margin: 0 0 4px; font-size: 1rem; }
.channel-item a { font-weight: 700; word-break: break-all; }

/* ---------- Article pages ---------- */
main blockquote {
    margin: 1em 0;
    padding: 0.4em 1em;
    border-left: 4px solid var(--border);
    background: var(--panel);
    color: var(--muted);
}
main table { border-collapse: collapse; max-width: 100%; display: block; overflow-x: auto; }
main th, main td { border: 1px solid var(--border); padding: 6px 10px; }
main th { background: var(--panel); }
main pre, main code { font-family: Consolas, "Courier New", monospace; font-size: 0.92em; background: var(--panel); }
main pre { padding: 10px; overflow-x: auto; border: 1px solid var(--border-light); }
main code { padding: 0 3px; }
.art-thumb { display: block; width: 100%; height: auto; margin: 0 0 1em; }

/* Table of contents box (like Wikipedia "Contents") */
.toc-box { display: table; max-width: 100%; margin: 1em 0; padding: 8px 14px; background: var(--panel); border: 1px solid var(--border); }
.toc-title { padding: 0; font: inherit; font-weight: 700; background: none; border: 0; color: var(--text); cursor: pointer; }
.toc-list { margin: 6px 0 0; padding-left: 1.4em; }
.toc-list li { margin-bottom: 2px; }
.toc-list a.active { font-weight: 700; color: var(--text); }

/* Reading progress line at the top of the screen */
.read-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 100; }

/* "Popular" mini list in the sidebar */
.mini-item { display: flex; align-items: center; gap: 10px; padding: 6px 0; color: var(--link); }
.mini-item img { width: 96px; height: 54px; object-fit: cover; flex: none; }

/* Share buttons */
[data-share] { display: inline-block; margin: 0 6px 6px 0; padding: 4px 12px; border: 1px solid var(--border); background: var(--panel); border-radius: 2px; cursor: pointer; font: inherit; }
[data-share]:hover { background: var(--border-light); text-decoration: none; }

/* ---------- Article page layout (articles/template.html) ---------- */
.article-layout {
    max-width: 1100px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 280px;
    gap: 32px;
    align-items: start;
}
.article-layout > div { min-width: 0; }

.breadcrumb { margin-bottom: 10px; font-size: 0.9rem; color: var(--muted); }

.art-title { margin: 0.2em 0 0.3em; font-size: 1.9rem; border: 0; padding: 0; }
.art-meta-info { margin-bottom: 12px; font-size: 0.92rem; color: var(--muted); }
.art-description {
    margin: 0 0 1.2em;
    padding-left: 12px;
    border-left: 3px solid var(--border);
    font-size: 1.05rem;
    color: var(--muted);
}

.article-body { line-height: 1.95; }
.article-body h2 { scroll-margin-top: 16px; }
.article-body img { display: block; max-width: 100%; height: auto; }

.share-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 24px 0;
    padding: 12px 0;
    border-top: 1px solid var(--border-light);
    border-bottom: 1px solid var(--border-light);
}
.share-bar [data-share] { margin: 0; }

.related { margin-top: 24px; }

.side-box { margin-bottom: 16px; padding: 10px 14px; background: var(--panel); border: 1px solid var(--border); }
.side-box h2 { margin: 0 0 6px; padding: 0; border: 0; font-size: 1.1rem; }
.mini-item span { font-size: 0.92rem; line-height: 1.5; }

@media (max-width: 860px) {
    .article-layout { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .art-title { font-size: 1.5rem; }
}

/* ---------- Telegram promo boxes/buttons are shown in the footer only ---------- */
/* This also hides them on old article-N.html files that still contain them. */
main .cta-box,
main .btn-cta { display: none !important; }

/* ---------- Ads (hidden until ads-loader.js shows them) ---------- */
.ad-slot:not([hidden]) { max-width: var(--max-width); margin: 12px auto; padding: 0 16px; text-align: center; }
.ad-slot img { display: inline-block; }

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
    body { font-size: 0.98rem; }
    h1, .hero h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }

    /* Header: logo + name centered on one line, menu centered on the next line */
    .topbar-inner { flex-direction: column; justify-content: center; gap: 2px; padding: 8px 12px 4px; }
    .brand { justify-content: center; }
    .mainnav { width: 100%; }
    .mainnav { overflow-x: auto; scrollbar-width: none; }
    .mainnav::-webkit-scrollbar { display: none; }
    .nav-list { justify-content: center; flex-wrap: nowrap; }
    .nav-link { padding: 6px 9px; font-size: 0.9rem; white-space: nowrap; }

    /* Category buttons: one row, swipe left and right */
    .categories-bar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        margin: 0 -16px 16px;
        padding: 0 16px 4px;
    }
    .categories-bar::-webkit-scrollbar { display: none; }
    .cat-chip { flex: none; white-space: nowrap; }

    .article-grid { grid-template-columns: 1fr; }
    .section-header { flex-direction: column; align-items: flex-start; }
}

/* ---------- Print ---------- */
@media print {
    header, footer, .ad-slot, .search-box, .categories-bar, .cta-box, .hero-actions, .read-progress { display: none !important; }
    body { font-size: 12pt; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}
