/* ============================
   KHURAL.MN — modernperfect ROUNDED
   Round corners applied comprehensively. Loaded LAST in layout
   so it overrides earlier sharp-corner rules.
   ============================ */

/* ============ Redefine radius tokens for this theme ============ */
:root {
    --r-xs:        6px;
    --r-sm:        10px;
    --r-md:        16px;
    --r-lg:        24px;
    --r-xl:        32px;
    --card-radius: 16px;
    /* Legacy aliases used in modern CSS */
    --radius:      16px;
    --radius-lg:   24px;
}

/* ============ Images (framed photos, media cards) ============ */
.news-img, .list-card-img, .news-card .news-img,
.hero-slide, .page-main img, .cat-sidebar img,
.media-tile, .gallery-item, .photo-tile,
.chairman-photo,
article img, .post-cover img,
.sub-cv-photo, .sub-cv-img,
.list-card img, .news-list img {
    border-radius: var(--r-md);
}

.news-card.featured .news-img { border-radius: var(--r-lg); }

/* ============ Cards (news, service, forum, poll, fund, etc.) ============ */
.news-card, .list-card, .service-card, .forum-card, .forum-row,
.poll-card, .fund-col, .fund-row, .experience-item, .chart-card,
.rank-card, .aimag-card, .duureg-card, .aimag-card-outer,
.card, .card--flat, .card--elevated, .card--brand, .card--hoverable,
.cat-sidebar, .section-sidebar, .section-sidebar-box,
.breaking-ticker, .surgalt-item, .top-news-card, .latest-news-card,
.san-item, .turshlaga-item, .lesson-card,
.article-row, .forum-detail, .poll-row,
.search-item, .search-tab, .search-hero,
.media-news-section .section-head, .media-news-section .card {
    border-radius: var(--r-md);
}

/* Larger cards get bigger radius */
.hero-slide, .hero, .search-hero, .cta-band, .cta-text,
.chair-card, .chair-panel, .sessions-panel, .stat-card,
.dashboard-card, .fund-col.accent-col {
    border-radius: var(--r-lg);
}

/* ============ Buttons (make them friendly pill-ish) ============ */
.btn, .btn-primary, .btn-gold, .btn-outline, .btn-ghost, .btn-white, .btn-sm {
    border-radius: var(--r-pill);
}
.btn-sq { border-radius: var(--r-md); }    /* escape hatch */

/* ============ Form controls (inputs, selects, textareas) ============ */
input[type="text"], input[type="email"], input[type="password"],
input[type="search"], input[type="tel"], input[type="url"],
input[type="number"], input[type="date"],
textarea, select,
.input, .textarea, .select,
.form-control, .sub-input, .sub-select, .sub-textarea,
.search-big-form, .header-search form, .search-form {
    border-radius: var(--r-md);
}

/* Big search bars pill */
.search-big-form, .header-search form, .search-form,
.search-bar, .hero-search-form {
    border-radius: var(--r-pill);
}

/* ============ Chips / badges / pills (already pill but normalize) ============ */
.chip, .chip--sm, .chip--light, .chip--brand,
.badge, .badge-live, .badge-closed, .badge-warn,
.news-cat, .news-tag, .sub-badge, .status-pill,
.hero-tag, .eyebrow-tag, .category-tag {
    border-radius: var(--r-pill);
}

/* ============ Sidebars + Panels ============ */
.cat-sidebar, .section-sidebar, .section-sidebar-box,
.page-sidebar, .sidebar-widget, .aimag-selector,
.right-fixed-menu, .rfm-item, .geo-panel,
.chat-sidebar-head, .forum-sidebar, .togtool-sidebar,
.filter-panel, .filter-bar, .filter-wrap {
    border-radius: var(--r-md);
}
.geo-panel.floating { border-radius: var(--r-lg); }
.rfm-item { border-radius: var(--r-md) 0 0 var(--r-md); }

/* ============ Pagination (round all page buttons) ============ */
.pagination, .search-pagination, .cat-pagination,
.sub-pagination, .sub-pagination ul {
    border-radius: 0; /* wrapper can stay flat */
}
.pagination a, .pagination span,
.search-pagination a, .search-pagination span, .search-pagination .page-link,
.cat-pagination a, .cat-pagination span, .cat-pagination .page-link,
.sub-pagination a, .sub-pagination span, .sub-pagination .page-link {
    border-radius: var(--r-pill) !important;
}

/* ============ Navigation menu items ============ */
.main-nav > ul > li > a,
.main-menu-bar .main-nav > ul > li > a,
.aimag-tab, .news-tab, .tab, .filter-tab,
.sub-chip, .search-tab {
    border-radius: var(--r-pill);
}
.main-menu-bar .main-nav > ul > li > a { border-radius: var(--r-md); }

/* Dropdown menus */
.dropdown-menu, .sub-menu, .main-nav .submenu {
    border-radius: var(--r-md);
    overflow: hidden;
}

/* ============ Alerts + notifications ============ */
.alert, .sub-alert, .notice, .flash-message,
.success-message, .error-message, .warning-message {
    border-radius: var(--r-md);
}

/* ============ Hero + header special treatments ============ */
.header-search form { border-radius: var(--r-pill); overflow: hidden; }
.header-search input { border-radius: 0; background: transparent; }
.header-search button { border-radius: var(--r-pill); }

.hero { border-radius: 0; } /* hero stays full-bleed */
.hero-content { border-radius: var(--r-lg); }
.hero-actions .btn { border-radius: var(--r-pill); }

/* ============ Code blocks + document rows ============ */
.togtool-row, .doc-row, .sub-togtool-row,
.file-row, .attachment-row {
    border-radius: var(--r-md);
}

/* ============ Dashboard specifics ============ */
.stat-card, .kpi-card, .rank-card, .chart-card {
    border-radius: var(--r-lg);
}
.rank-bar, .rank-fill, .progress-bar, .progress-fill,
.poll-bar, .sub-poll-fill, .sub-poll-bar {
    border-radius: var(--r-pill);
}

/* ============ Comment avatars, icon buttons ============ */
.comment-avatar, .avatar, .user-avatar, .sub-comment-avatar,
.icon-btn, .icon-btn-base {
    border-radius: 50%;
}

/* ============ Toggles, chips, tags ============ */
.toggle, .switch, .filter-toggle,
.topic-tag, .category-chip, .skill-pill {
    border-radius: var(--r-pill);
}

/* ============ Breadcrumbs (if they have backgrounds) ============ */
.breadcrumb, .page-breadcrumbs {
    border-radius: var(--r-md);
}

/* ============ Overrides for hard-coded 0 cases we know about ============ */
.btn-sm, .btn-icon, .icon-btn-base { border-radius: var(--r-pill); }
.poll-option, .asuult-option { border-radius: var(--r-md); }
.breaking-ticker { border-radius: var(--r-md); }

/* Modern .card--brand hero inset */
.card--brand, .card--hoverable { border-radius: var(--r-md); }

/* Overlay nav / mobile drawer */
.mobile-drawer, .side-panel, .modal, .modal-content {
    border-radius: var(--r-lg);
}

/* ============ Containers / Dividers DO NOT round (full-bleed sections) ============ */
.section, .container, .wrapper, .main-content,
.site-header, .site-footer, .footer-bottom, .top-bar {
    border-radius: 0 !important;
}

/* Hide the hard "square" look everywhere — fallback */
article, .article, .post-card, .content-card, .entry {
    border-radius: var(--r-md);
}

/* Responsive polish */
@media (max-width: 580px) {
    :root {
        --card-radius: 14px;
        --r-md: 14px;
        --r-lg: 20px;
    }
}

/* ============================
   Top bar icon centering fix.
   Global `.top-bar i { margin-right: 6px }` pushes icons off-center
   inside circular buttons. Reset where icon is the ONLY child.
   ============================ */
.top-bar-right a i,
.top-bar .a11y-trigger-icon i,
.top-bar .sp-back i,
.a11y-trigger i {
    margin-right: 0 !important;
}

/* Make sure circular top-bar buttons are perfect circles with centered icon */
.top-bar-right a {
    width: 32px;
    height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.top-bar-right a i { font-size: 0.78rem; line-height: 1; }
.a11y-trigger-icon { line-height: 1; }
.a11y-trigger-icon i { font-size: 0.72rem; }

/* ============================
   AGGRESSIVE OVERRIDES — force rounded corners everywhere
   Use !important to win any cascade / specificity battle.
   ============================ */

/* Cards — force rounded */
.list-card,
.news-card,
.service-card,
.forum-card,
.forum-row,
.poll-card,
.aimag-card,
.aimag-card-outer,
.fund-col,
.search-item,
.card,
article.card,
.chair-card,
.sessions-panel,
.stat-card,
.rank-card,
.chart-card,
.top-news-card,
.latest-news-card,
.breaking-ticker,
.surgalt-item,
.lesson-card,
.media-card,
.media-tile {
    border-radius: var(--r-md) !important;
    overflow: hidden !important;
}

/* Larger cards */
.news-card.featured,
.hero-content,
.chair-card,
.cta-band {
    border-radius: var(--r-lg) !important;
}

/* Images inside cards */
.list-card-img,
.news-img,
.sub-cv-photo,
.sub-cv-img,
.chairman-photo,
.media-thumb,
.news-card .news-img,
.list-card img,
.aimag-card img,
.search-item img,
.news-card img {
    border-radius: 0 !important; /* inside overflow:hidden parent — no need */
}

/* Standalone images (not inside card) */
.page-main > img,
.article-body img,
.sub-prose img,
.prose img {
    border-radius: var(--r-md) !important;
}

/* ============ Menu bar — rounded items + remove dividers ============ */
.main-menu-bar {
    border-top: none !important;              /* remove top horizontal rule */
}
.main-menu-bar .main-nav > ul {
    gap: 4px !important;
    padding: 6px 0 !important;
}
.main-menu-bar .main-nav > ul > li {
    border-right: none !important;
    border-left: none !important;
}
.main-menu-bar .main-nav > ul > li + li {
    border-left: none !important;
}
.main-menu-bar .main-nav > ul > li > a {
    border-radius: var(--r-pill) !important;
    padding: 10px var(--s-4) !important;    /* 16px left + right */
    transition: background var(--motion-fast), color var(--motion-fast) !important;
}
.main-menu-bar .main-nav > ul > li > a::after {
    display: none !important;              /* hide underline hover */
}
.main-menu-bar .main-nav > ul > li > a:hover {
    background: var(--c-bg-soft) !important;
    color: var(--c-brand) !important;
}
.main-menu-bar .main-nav > ul > li > a.active,
.main-menu-bar .main-nav > ul > li > a.is-active {
    background: var(--c-brand) !important;
    color: #fff !important;
}

/* Dropdown */
.main-menu-bar .dropdown {
    border-radius: var(--r-md) !important;
    overflow: hidden !important;
    margin-top: 4px !important;
}
.main-menu-bar .dropdown li a {
    border-radius: var(--r-sm) !important;
    margin: 2px 4px !important;
}

/* Sidebars + panels force rounded */
.cat-sidebar,
.section-sidebar,
.page-sidebar,
.aimag-selector,
.filter-panel,
.filter-bar,
.widget {
    border-radius: var(--r-md) !important;
    overflow: hidden !important;
}
.cat-sidebar-head,
.section-sidebar-title {
    border-radius: var(--r-md) var(--r-md) 0 0 !important;
}

/* Form controls */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="date"],
textarea,
select {
    border-radius: var(--r-md) !important;
}

/* Buttons */
.btn,
.btn-primary,
.btn-gold,
.btn-outline,
.btn-ghost,
.btn-white {
    border-radius: var(--r-pill) !important;
}

/* Chips / tags / badges */
.list-card-site,
.list-card-cat,
.news-cat,
.news-tag,
.chip,
.badge,
.badge-live,
.badge-closed,
.hero-tag,
.eyebrow-tag,
.sub-badge,
.pill,
.status-pill {
    border-radius: var(--r-pill) !important;
}

/* Pagination */
.pagination a, .pagination span,
.search-pagination a, .search-pagination span, .search-pagination .page-link,
.cat-pagination a, .cat-pagination span, .cat-pagination .page-link,
.sub-pagination a, .sub-pagination span, .sub-pagination .page-link {
    border-radius: var(--r-pill) !important;
}

/* Right-fixed menu (аймгууд) */
.rfm-item {
    border-radius: var(--r-md) 0 0 var(--r-md) !important;
}

/* Breaking ticker */
.breaking-ticker,
.breaking-bar {
    border-radius: var(--r-md) !important;
}

/* Avatars */
.comment-avatar,
.avatar,
.user-avatar,
.aimag-icon,
.author-avatar {
    border-radius: 50% !important;
}

/* Attachment rows / document rows */
.file-row,
.attachment-row,
.togtool-row,
.doc-row {
    border-radius: var(--r-md) !important;
}

/* CTA / hero sections */
.cta-band,
.cta-text,
.search-hero,
.chair-panel {
    border-radius: var(--r-lg) !important;
}

/* Hero itself stays full-bleed (no radius on outer) */
.hero,
.site-header,
.site-footer,
.footer-bottom,
.top-bar,
.main-menu-bar,
section.section,
.container {
    border-radius: 0 !important;
}

/* ============================
   Section rhythm — ensure breathing room between stacked sections
   The base rule `.section + .section { padding-top: 0 }` collapses
   top padding. Restore it so each section stands clearly on its own.
   ============================ */
.section + .section {
    padding-top: var(--s-7) !important;   /* 48px */
}

/* Larger breathing on home page sections */
section.section {
    padding-top: var(--s-7) !important;
    padding-bottom: var(--s-7) !important;
}

/* Section head internal spacing */
.section-head {
    margin-top: var(--s-2) !important;
    margin-bottom: var(--s-6) !important;
}

/* ============================
   Remove stray horizontal lines between sections
   ============================ */
.main-menu-bar {
    border-top: none !important;
    border-bottom: none !important;
}
.breaking-ticker {
    border-top: none !important;
    border-bottom: none !important;
}
.site-header {
    border-bottom: none !important;
}

/* Keep visual separation via spacing instead of lines */
.breaking-ticker {
    margin-top: var(--s-2);
}

/* ============================
   FORCE rounded on sidebar small news cards (latest-news / top-news)
   ============================ */
.latest-news-card,
.latest-news-card.featured,
.top-news-card,
.top-news-card.featured,
.latest-news-grid > *,
.top-news-grid > * {
    border-radius: var(--r-md) !important;
    overflow: hidden !important;
}
.latest-news-img,
.top-news-img {
    border-radius: 0 !important;  /* inside overflow:hidden parent */
}
/* Standalone images inside those cards (for rows laid side-by-side) */
.latest-news-card > .latest-news-img:first-child,
.top-news-card > .top-news-img:first-child {
    border-radius: 0 !important;
}

/* ============================
   Section rhythm & alternating backgrounds
   Give each stacked section its own breathing room + soft background on odd ones
   for visual variety.
   ============================ */
section.section {
    padding-top: var(--s-6) !important;        /* 32px top (1/2 of original) */
    padding-bottom: var(--s-6) !important;     /* 32px bottom */
    background: #fff;
}

/* Alternate: every second section gets soft bg */
section.section:nth-of-type(even) {
    background: var(--c-bg-soft);
}

/* Specific sections that should always have soft bg */
section.media-news-section,
section.lessons-section,
section.funds-section,
section.forums-section,
section.turshlaga-section {
    background: var(--c-bg-soft);
}

/* Explicitly white sections */
section.top-news-section,
section.latest-news-section,
section.hero,
section.cta-band-section {
    background: #fff;
}

/* Stacked section spacing — the `.section + .section` padding-top: 0 rule must
   be overridden consistently */
.section + .section {
    padding-top: var(--s-6) !important;
}

/* ============================
   Section head consistency
   ============================ */
.section-head {
    margin-top: 0 !important;
    margin-bottom: var(--s-5) !important;
    padding-bottom: var(--s-3);
    border-bottom: 1px solid var(--c-line);
}
.section-head h2,
.section-head h3 {
    margin: 0 !important;
}

/* ============================
   ZIG-ZAG section backgrounds — alternating white / warm cream
   so every section stands clearly on its own.
   Order on home: hero > top-news > latest-news > photo-news > video-news
                  > lessons > sans > turshlaga > cta
   ============================ */
section.hero                    { background: #fff !important; }
section.top-news-section        { background: var(--c-bg-soft) !important; }
section.latest-news-section     { background: #fff !important; }
section.photo-news-section      { background: var(--c-bg-soft) !important; }
section.video-news-section      { background: #fff !important; }
section.lessons-section         { background: var(--c-bg-soft) !important; }
section.sans-section            { background: #fff !important; }
section.turshlaga-section       { background: var(--c-bg-soft) !important; }
section.media-news-section      { background: var(--c-bg-soft) !important; }
section.funds-section           { background: #fff !important; }
section.forums-section          { background: var(--c-bg-soft) !important; }
section.cta-band-section        { background: #fff !important; }

/* Fallback alternation if order changes */
section.section:nth-of-type(even) { background: var(--c-bg-soft) !important; }
section.section:nth-of-type(odd)  { background: #fff !important; }

/* ============================
   FORCE round corners on <article> news cards (specific tag)
   ============================ */
article.latest-news-card,
article.latest-news-card.featured,
article.top-news-card,
article.top-news-card.featured,
article.news-card,
article.list-card,
article.search-item {
    border-radius: 16px !important;
    overflow: hidden !important;
    border: 1px solid var(--c-line) !important;
}

/* Explicit corner radius on images inside */
article.latest-news-card .latest-news-img,
article.latest-news-card .latest-news-body,
article.top-news-card .top-news-img,
article.top-news-card .top-news-body {
    border-radius: 0 !important;
}

/* Chips inside image corners should be fully rounded pill */
article.latest-news-card .chip-dark,
article.latest-news-card .site-tag,
article.latest-news-card .loc,
article.top-news-card .chip-dark {
    border-radius: 999px !important;
}

/* ============================
   Main menu — soft bg + subtle bottom hairline for structure
   Padding equalized to match other gaps.
   ============================ */
.main-menu-bar {
    background: var(--c-bg-soft, #f7f8fb) !important;
    box-shadow: inset 0 -1px 0 var(--c-line) !important;
    padding: var(--s-4) 0 !important;        /* 16px top + bottom */
    margin: 0 !important;
}
.main-menu-bar.is-stuck {
    background: #fff !important;
    box-shadow: 0 2px 12px rgba(15,23,42,.08) !important;
}

/* Soft brand hover state */
.main-menu-bar .main-nav > ul > li > a:hover {
    background: rgba(11,61,145,.06) !important;
    color: var(--c-brand) !important;
}
.main-menu-bar .main-nav > ul > li > a.active,
.main-menu-bar .main-nav > ul > li > a.is-active {
    background: var(--c-brand) !important;
    color: #fff !important;
}

/* ============================
   Breaking ticker (now embedded inside top-news section)
   ============================ */
.top-news-section .breaking-ticker {
    background: #fff !important;
    border: 1px solid var(--c-line) !important;
    border-radius: var(--r-md) !important;
    margin-bottom: var(--s-5) !important;
    padding: 0 var(--s-4) !important;
    box-shadow: 0 2px 12px rgba(15,23,42,.04);
}
.top-news-section .breaking-ticker-inner {
    padding: 10px 0 !important;
    display: flex;
    align-items: center;
    gap: var(--s-3);
}
.top-news-section .breaking-ticker .breaking-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--c-brand);
    color: #fff;
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    white-space: nowrap;
}
.top-news-section .breaking-ticker .breaking-label i {
    color: var(--c-gold, #c9a227);
    margin-right: 0;
}

/* ============================
   Menu → first section — tighter transition
   The first .section after the main menu should not have big top padding,
   because the menu is already transparent and visually belongs to the section above.
   ============================ */
#main-content > section:first-child,
#main-content > section.section:first-of-type,
.main-menu-bar + section.section,
.main-menu-bar + * + section.section {
    padding-top: 0 !important;
}

/* Equalize 3 gaps: header→menu, menu→breaking, breaking→hero */
.site-header,
.header-hero {
    padding-bottom: var(--s-4) !important;   /* 16px (gap 1: header → menu) */
}
.top-news-section .breaking-ticker {
    margin-bottom: var(--s-4) !important;    /* 16px (gap 3: breaking → hero) */
    margin-top: 0 !important;
}
/* Gap 2 is handled by menu padding (16px bottom) + top-news section padding-top */
#main-content > section:first-child,
#main-content > section.section:first-of-type,
.main-menu-bar + section.section {
    padding-top: var(--s-4) !important;      /* 16px (gap 2: menu → breaking) */
}
