/* Main application styles */

:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --surface-alt: #f8f9fa;
    --border: #dee2e6;
    --border-soft: #ecf0f1;
    --text: #24292f;
    --text-muted: #555555;
    --text-faint: #6a737d;
    --heading: #2c3e50;
    --heading-2: #34495e;
    --header-bg: #2c3e50;
    --header-text: #ffffff;
    --accent: #2563eb;
    --accent-hover: #1e40af;
    --on-accent: #ffffff;
    --code-bg: #f4f4f4;
    --highlight-bg: #f8f8f8;
    --highlight-border: #cccccc;
    --edit-link: #95a5a6;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-hover: rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] {
    --bg: #0d1117;
    --surface: #161b22;
    --surface-alt: #1c2128;
    --border: #30363d;
    --border-soft: #21262d;
    --text: #c9d1d9;
    --text-muted: #b1bac4;
    --text-faint: #8b949e;
    --heading: #e6edf3;
    --heading-2: #c9d1d9;
    --header-bg: #161b22;
    --header-text: #e6edf3;
    --accent: #58a6ff;
    --accent-hover: #79c0ff;
    --on-accent: #0d1117;
    --code-bg: #1f2630;
    --highlight-bg: #1f2630;
    --highlight-border: #30363d;
    --edit-link: #8b949e;
    --shadow: rgba(0, 0, 0, 0.4);
    --shadow-hover: rgba(0, 0, 0, 0.55);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--bg);
    color: var(--text);
    transition: background-color 0.2s ease, color 0.2s ease;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 0.6rem 0;
    margin-bottom: 1.5rem;
}

.header-inner {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

header h1 {
    margin: 0;
    text-align: center;
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

header h1 a {
    color: inherit;
    text-decoration: none;
    opacity: 0.85;
    transition: opacity 0.2s;
}

header h1 a:visited {
    color: inherit;
}

header h1 a:hover {
    opacity: 1;
    text-decoration: underline;
}

/* Theme toggle */
.theme-toggle {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.25);
    border-radius: 8px;
    background: transparent;
    color: var(--header-text);
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.4);
}

.theme-toggle-icon {
    width: 20px;
    height: 20px;
}

.theme-toggle-icon-light {
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    display: none;
}

.theme-toggle-icon-dark {
    fill: currentColor;
    stroke: none;
    display: block;
}

[data-theme="dark"] .theme-toggle-icon-light {
    display: block;
}

[data-theme="dark"] .theme-toggle-icon-dark {
    display: none;
}

.course-nav {
    text-align: center;
    margin-bottom: 2rem;
}

.course-nav a {
    display: inline-block;
    padding: 8px 16px;
    margin: 4px;
    background: var(--accent);
    color: var(--on-accent);
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s;
}

.course-nav a:visited {
    color: var(--on-accent);
}

.course-nav a:hover {
    background: var(--accent-hover);
}

.content {
    background: var(--surface);
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px var(--shadow);
    font-size: 1.05em;
}

.content > p a,
.content > ul a {
    color: var(--accent);
    text-decoration: none;
}

.content > p a:visited,
.content > ul a:visited {
    color: var(--accent);
}

.content > p a:hover,
.content > ul a:hover {
    text-decoration: underline;
}

.section {
    margin-bottom: 3rem;
}

.section h2 {
    color: var(--heading);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 0.5rem;
}

.question {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-soft);
}

.question:last-child {
    border-bottom: none;
}

.question h3 {
    color: var(--heading-2);
    margin-bottom: 1rem;
    position: relative;
}

.anchor-link {
    position: absolute;
    left: -30px;
    top: 0;
    color: var(--accent);
    text-decoration: none;
    font-weight: normal;
    opacity: 0;
    transition: opacity 0.2s;
}

.anchor-link:visited {
    color: var(--accent);
}

.question:hover .anchor-link {
    opacity: 1;
}

.anchor-link:hover {
    text-decoration: none;
}

.question-content {
    color: var(--text-muted);
}

.question-content img {
    max-width: 100%;
    height: auto;
    margin: 1rem 0;
    border-radius: 4px;
    box-shadow: 0 2px 8px var(--shadow);
}

.question-content > pre {
    background: var(--code-bg);
    padding: 1rem;
    border-radius: 4px;
    overflow-x: auto;
}

.inline-code {
    background: var(--code-bg);
    padding: 2px 4px;
    border-radius: 2px;
    font-family: 'Monaco', 'Consolas', monospace;
}

.highlight {
    background: var(--highlight-bg);
    border: 1px solid var(--highlight-border);
    border-radius: 4px;
    padding: 1rem;
    margin: 1rem 0;
    overflow-x: auto;
}

.highlight pre {
    background: none !important;
    padding: 0 !important;
    margin: 0 !important;
    border: none !important;
}

.question-content a {
    color: var(--accent);
    text-decoration: none;
}

.question-content a:visited {
    color: var(--accent);
}

.question-content a:hover {
    text-decoration: underline;
}

.question-meta {
    margin-top: 1rem;
    text-align: right;
}

.edit-link {
    color: var(--edit-link);
    text-decoration: none;
    font-size: 0.85em;
    font-style: italic;
}

.edit-link:visited {
    color: var(--edit-link);
}

.edit-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.course-links {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1rem;
    margin: 2rem 0;
}

.course-link {
    padding: 1.5rem;
    background: var(--surface-alt);
    border-radius: 8px;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.course-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px var(--shadow-hover);
}

.course-link a {
    text-decoration: none;
    color: inherit;
    display: block;
}

.course-link a:visited {
    color: inherit;
}

.course-link h3 {
    margin: 0 0 0.5rem 0;
    color: var(--heading);
    font-size: 1.2em;
}

.course-description {
    color: var(--text-faint);
    font-size: 0.9em;
}

.table-of-contents {
    background: var(--surface-alt);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.table-of-contents ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.table-of-contents li {
    margin-bottom: 0.5rem;
}

.table-of-contents a {
    color: var(--accent);
    text-decoration: none;
}

.table-of-contents a:visited {
    color: var(--accent);
}

.table-of-contents a:hover {
    text-decoration: underline;
}

.contribute-banner {
    margin-bottom: 1.5rem;
    font-size: 1.17em;
}

.contribute-banner p {
    margin: 0;
    color: var(--text-muted);
}

.contribute-banner a {
    color: var(--accent);
    text-decoration: none;
}

.contribute-banner a:visited {
    color: var(--accent);
}

.contribute-banner a:hover {
    text-decoration: underline;
}

footer {
    text-align: center;
    padding: 2rem 0;
    color: var(--text-faint);
    border-top: 1px solid var(--border-soft);
    margin-top: 3rem;
}

footer a {
    color: var(--accent);
    text-decoration: none;
}

footer a:visited {
    color: var(--accent);
}

footer a:hover {
    text-decoration: underline;
}

@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    header h1 {
        font-size: 1.05rem;
    }
    .content {
        padding: 1rem;
    }
    .course-links {
        grid-template-columns: 1fr;
    }
}
