/* ==========================================================================
   olympiads.ru/moscow - Main Stylesheet (/moscow/style.css)
   ========================================================================== */

:root {
    --bg-page: #f3f6fa;
    --bg-surface: #ffffff;
    --bg-subtle: #f8fafd;
    --bg-accent-soft: #eef4fb;

    --navy-900: #1e467a;
    --navy-800: #23528f;
    --navy-700: #2f6ab5;
    --blue-600: #1d5bbf;
    --blue-500: #2563eb;
    --blue-100: #dbeafe;

    --text-main: #1e293b;
    --text-muted: #526277;
    --text-on-dark: #f8fafc;

    --border-color: #dce4ef;
    --border-strong: #c4d1e2;

    --date-bg: #eef4fb;
    --date-text: #1b4b9c;
    --date-border: #c3d9f7;

    --radius-sm: 6px;
    --radius-md: 10px;
    --shadow-sm: 0 1px 3px rgba(17, 34, 56, 0.06), 0 1px 2px rgba(17, 34, 56, 0.04);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-main);
    line-height: 1.65;
    font-size: 16px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

a {
    color: var(--blue-600);
    text-decoration: none;
    transition: color 0.15s ease, background-color 0.15s ease;
}

a:hover {
    color: var(--navy-900);
    text-decoration: underline;
}

/* Header & Top Navigation */

.site-header {
    background: linear-gradient(135deg, #245594 0%, #3472bd 100%);
    color: var(--text-on-dark);
    border-bottom: 1px solid rgba(255, 255, 255, 0.18);
}

.site-header__inner {
    max-width: 1380px;
    margin: 0 auto;
    padding: 20px 24px 16px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
}

.site-title {
    margin: 0;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.25;
    color: #ffffff;
}

.site-title a {
    color: #ffffff;
    text-decoration: none;
}

.site-title a:hover {
    color: #dbeafe;
    text-decoration: none;
}

.site-parent {
    margin: 0;
    font-size: 0.9rem;
    color: rgba(248, 250, 252, 0.85);
}

.site-parent a {
    color: #e0f2fe;
    font-weight: 500;
    text-decoration: none;
    border-bottom: 1px solid rgba(224, 242, 254, 0.5);
}

.site-parent a:hover {
    color: #ffffff;
    border-bottom-color: #ffffff;
    text-decoration: none;
}

.site-nav {
    background-color: #1e4980;
    border-bottom: 1px solid #183b68;
    box-shadow: 0 2px 6px rgba(24, 59, 104, 0.08);
}

.site-nav__inner {
    max-width: 1380px;
    margin: 0 auto;
    padding: 4px 16px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 2px 6px;
}

.site-nav a,
a.top {
    display: inline-block;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.81rem;
    font-weight: 500;
    padding: 6px 7px;
    border-radius: var(--radius-sm);
    text-decoration: none;
    line-height: 1.3;
    white-space: nowrap;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.site-nav a:hover,
a.top:hover {
    background-color: rgba(255, 255, 255, 0.14);
    color: #ffffff;
    text-decoration: none;
}

/* Page Grid: Sidebar + Main Content */

.page-layout {
    max-width: 1380px;
    width: 100%;
    margin: 22px auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 255px minmax(0, 1fr);
    gap: 22px;
    align-items: start;
    flex: 1;
}

.sidebar {
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 18px 18px;
    box-shadow: var(--shadow-sm);
    font-size: 0.92rem;
    line-height: 1.5;
}

.sidebar h3,
.sidebar h4 {
    margin: 18px 0 8px;
    padding-top: 14px;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--navy-700);
}

.sidebar h3:first-child,
.sidebar h4:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.sidebar p {
    margin: 6px 0;
    color: var(--text-muted);
}

.sidebar p:first-child {
    margin-top: 0;
}

.sidebar a {
    color: var(--blue-600);
    font-weight: 500;
    display: inline-block;
    padding: 2px 0;
}

.sidebar a:hover {
    color: var(--navy-900);
    text-decoration: underline;
}

.sidebar ul {
    margin: 6px 0 10px 18px;
    padding: 0;
}

.sidebar li {
    margin: 4px 0;
}

/* Legacy table-based toc.html support (2002-2023) */
.sidebar table {
    width: 100%;
    border-collapse: collapse;
    border: none;
    background: transparent;
    margin: 0;
}

.sidebar table + table {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

.sidebar th,
.sidebar td {
    border: none;
    background: transparent !important;
    padding: 3px 0;
    vertical-align: top;
    color: var(--text-main);
    font-size: 0.91rem;
}

.sidebar img[src^="/school/images/"] {
    display: none;
}

.sidebar td:first-child:empty,
.sidebar td:first-child:has(img[src^="/school/images/"]) {
    width: 0;
    padding: 0;
}

.sidebar td[style*="font-size"] b {
    display: block;
    margin: 14px 0 4px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--navy-700);
}

.sidebar tr:first-child td[style*="font-size"] b {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

.sidebar img {
    max-width: 170px;
    height: auto;
}

/* Main Content Area */

.main-content {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 26px 32px 34px;
    box-shadow: var(--shadow-sm);
    min-width: 0;
    overflow-x: auto;
}

.season-heading,
.main-content > h4[align="center"]:first-child {
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    text-align: left;
}

.main-content h2 {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--navy-900);
    margin: 28px 0 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-color);
}

.main-content h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--navy-900);
    margin: 24px 0 12px;
    line-height: 1.35;
}

.main-content h3[align="center"],
.main-content p.header {
    text-align: left;
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--navy-900);
    margin-top: 4px;
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 2px solid var(--bg-accent-soft);
}

.main-content h4 {
    font-size: 1.06rem;
    font-weight: 700;
    color: var(--navy-800);
    margin: 20px 0 8px;
}

.main-content h4[align="center"] {
    text-align: left;
}

.main-content p {
    margin: 0 0 14px;
}

.main-content ul,
.main-content ol {
    margin: 0 0 16px 24px;
    padding: 0;
}

.main-content li {
    margin-bottom: 6px;
}

.main-content hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 22px 0;
}

/* News Date Badges (<font color="#D00000">, <font color="#B00000">, <font color="red">) */
.main-content font[color="#D00000"],
.main-content font[color="#d00000"],
.main-content font[color="#B00000"],
.main-content font[color="#b00000"],
.main-content p > font[color="red"]:first-child,
.news-date {
    display: inline-block;
    background-color: var(--date-bg);
    color: var(--date-text);
    border: 1px solid var(--date-border);
    font-weight: 600;
    font-size: 0.84rem;
    line-height: 1.3;
    padding: 2px 9px;
    border-radius: var(--radius-sm);
    margin-right: 6px;
    vertical-align: baseline;
}

/* Code Blocks (<pre>, <code>) */
.main-content pre {
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--navy-700);
    border-radius: var(--radius-sm);
    padding: 14px 18px;
    margin: 10px 0 18px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--navy-900);
    overflow-x: auto;
}

.main-content code {
    background-color: var(--bg-accent-soft);
    color: var(--navy-900);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.88em;
}

/* Tables (Results, Schedules, Verdicts, Software) */
.main-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0 24px;
    font-size: 0.88rem;
    line-height: 1.4;
    border: 1px solid var(--border-color);
    background-color: var(--bg-surface);
}

.main-content th,
.main-content td {
    border: 1px solid var(--border-color);
    padding: 6px 8px;
    text-align: left;
    vertical-align: top;
}

.main-content th {
    background-color: var(--navy-800);
    color: #ffffff;
    font-weight: 600;
    white-space: nowrap;
}

.main-content tr:nth-child(even) td {
    background-color: var(--bg-subtle);
}

.main-content tr:hover td {
    background-color: var(--bg-accent-soft);
}

/* Footer */

.site-footer {
    max-width: 1380px;
    width: 100%;
    margin: 0 auto 24px;
    padding: 14px 24px 0;
    color: var(--text-muted);
    font-size: 0.85rem;
    text-align: center;
}

/* Responsive */

@media (max-width: 900px) {
    .page-layout {
        grid-template-columns: 1fr;
        margin: 16px auto;
        padding: 0 12px;
        gap: 16px;
    }

    .site-header__inner {
        padding: 16px 16px 14px;
    }

    .site-title {
        font-size: 1.35rem;
    }

    .site-nav__inner {
        padding: 6px 12px;
        justify-content: flex-start;
    }

    .main-content {
        padding: 20px 18px 24px;
    }
}
