/* Base layout */
html {
    scroll-behavior: smooth;
}

html, body {
    font-family: var(--font-family, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif);
    color: var(--color-text, #333);
    line-height: var(--line-height-relaxed, 1.75);
    margin: 0;
    padding: 0;
    background-color: #e3eae9;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Typography - Heading Hierarchy */
h1, h2, h3, h4, h5, h6 {
    line-height: var(--line-height-tight, 1.25);
    font-weight: var(--font-weight-semibold, 600);
    letter-spacing: var(--letter-spacing-tight, -0.025em);
    margin-top: 0;
}

h1 {
    font-size: var(--font-size-3xl, 2rem);
    font-weight: var(--font-weight-bold, 700);
}

h2 {
    font-size: var(--font-size-2xl, 1.5rem);
}

h3 {
    font-size: var(--font-size-xl, 1.25rem);
}

h4 {
    font-size: var(--font-size-lg, 1.125rem);
}

h5, h6 {
    font-size: var(--font-size-base, 1rem);
}

p {
    margin-bottom: 1em;
}

/* Selection styling */
::selection {
    background-color: var(--color-accent, #c9a227);
    color: white;
}

/* Focus styles for accessibility */
:focus-visible {
    outline: 2px solid var(--color-accent, #c9a227);
    outline-offset: 2px;
}

body {
    background-image: url('../images/kazakh_steppe.webp');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
}

/* Dark mode background overlay */
[data-theme="dark"] body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    pointer-events: none;
    z-index: -1;
}

#page-container {
    display: flex;
    flex-direction: column;
    min-height: 100vh; /* Ensures minimum height for the flex container */
}

#content-wrap {
    display: flex;
    flex: 1; /* Allows the content to expand and fill the space */
    background-color: transparent;
}

/* Header */
header {
    background-color: var(--color-header-bg, #52cce2b5);
    padding-top: 1vh;
}

header .container {
    width: 80%;
    margin: 0 auto;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Brand heading — an h1 on the homepage, a p elsewhere, styled identically */
header .site-heading {
    margin: 0;
    font-size: 2em;
    font-weight: var(--font-weight-bold, 700);
    line-height: var(--line-height-tight, 1.25);
    letter-spacing: var(--letter-spacing-tight, -0.025em);
    color: var(--color-primary, #2a2521);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary, #2a2521);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

.theme-toggle:hover {
    background-color: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

[data-theme="dark"] .theme-toggle:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.theme-toggle .hidden {
    display: none;
}

.theme-toggle svg {
    transition: transform 0.3s ease;
}

/* Navigation */
nav ul {
    list-style: none;
    padding: 0;
}

nav ul li {
    display: inline;
    margin-right: 20px;
}

nav ul li a {
    color: var(--color-primary, #2a2520);
    padding: 4px 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

nav ul li a:hover {
    color: var(--color-primary, #2a2520);
    background-color: rgba(255, 255, 255, 0.2);
    text-decoration: none;
}

nav ul li a.active {
    font-weight: 600;
    background-color: rgba(255, 255, 255, 0.25);
}

/* Site title link */
.site-title {
    color: var(--color-primary, #2a2521);
    text-decoration: none;
}

.site-title:hover {
    text-decoration: none;
    color: var(--color-primary-light, #594a40);
}

/* Brand logo styling */
.brand-logo {
    font-family: 'SF Mono', Monaco, 'Cascadia Code', Consolas, monospace;
    font-weight: 500;
    letter-spacing: -0.5px;
}

.brand-logo::after {
    content: '.';
    color: var(--color-accent, #c9a227);
    font-weight: 900;
    font-size: 1.2em;
}

/* Main content */
main {
    width: 80%;
    margin: 40px auto;
    background-color: #fff; /* Retained the white background for content area */
}

/* Footer */
footer {
    text-align: center;
    padding: 20px 0;
    background-color: var(--color-footer-bg, #d2925bb3);
    flex-shrink: 0;
}

.footer-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

footer p {
    margin: 0;
    color: var(--color-primary, #2a2521);
}

.footer-links {
    display: flex;
    gap: 20px;
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-primary, #2a2521);
    text-decoration: none;
    font-size: 0.9em;
    transition: color var(--transition-fast, 0.15s ease);
}

.footer-link:hover {
    color: var(--color-accent, #c9a227);
    text-decoration: none;
}

.footer-link svg {
    flex-shrink: 0;
}

/* Skip to content link (accessibility) */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--color-accent, #c9a227);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* Breadcrumbs */
.breadcrumbs {
    padding: 12px 0;
    margin-bottom: 10px;
}

.breadcrumbs ol {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.breadcrumbs li {
    display: flex;
    align-items: center;
}

.breadcrumbs li:not(:last-child)::after {
    content: '›';
    margin-left: 8px;
    color: #999;
}

.breadcrumbs a {
    color: var(--color-text-light, #666);
    text-decoration: none;
}

.breadcrumbs a:hover {
    color: var(--color-accent, #c9a227);
    text-decoration: none;
}

.breadcrumbs span[aria-current="page"] {
    color: var(--color-primary, #2a2521);
    font-weight: 500;
}

/* Links */
a {
    color: var(--color-accent-dark, #a8861f);
    text-decoration: none;
    transition: color var(--transition-fast, 0.15s ease);
}

a:hover {
    text-decoration: underline;
    color: var(--color-accent, #c9a227);
}

/* Buttons base styles */
button {
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-fast, 0.15s ease);
}

button:active {
    transform: scale(0.98);
}

/* Interactive elements transition */
.interactive {
    transition: transform var(--transition-fast, 0.15s ease),
                box-shadow var(--transition-fast, 0.15s ease),
                background-color var(--transition-fast, 0.15s ease);
}

.interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md, 0 4px 6px rgba(0, 0, 0, 0.1));
}

/* Fade in animation */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

/* Utility classes */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-text-muted, #888); }
.font-mono { font-family: var(--font-family-mono, monospace); }

/* Particle Animation */
.particles-container {
    width: 100%;
    height: 200px;
    border-radius: var(--radius-md, 8px);
    overflow: hidden;
    cursor: crosshair;
}

.particles-container canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Responsive design - Tablet */
@media (max-width: 1024px) {
    header .container, main {
        width: 90%;
    }

    h1 {
        font-size: var(--font-size-2xl, 1.5rem);
    }

    h2 {
        font-size: var(--font-size-xl, 1.25rem);
    }
}

/* Responsive design - Mobile */
@media (max-width: 768px) {
    html, body {
        font-size: 15px;
    }

    header .container, main {
        width: 95%;
    }

    .header-top {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .header-actions {
        width: 100%;
        justify-content: space-between;
    }

    .header-top .search-wrapper {
        flex: 1;
        max-width: calc(100% - 50px);
    }

    nav ul {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    nav ul li {
        display: inline-block;
        margin-right: 0;
        margin-bottom: 4px;
    }

    nav ul li a {
        padding: 8px 12px;
        display: block;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    #content-wrap {
        display: contents;
        border-radius: 0%;
    }

    /* Improve touch targets */
    button, .btn, a.btn {
        min-height: 44px;
        min-width: 44px;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    html, body {
        font-size: 14px;
    }

    header .container, main {
        width: 100%;
        padding: 0 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}
