:root {
    color-scheme: light;
    --bg-color: #ffffff;
    --text-color: #333333;
    --text-muted: #666666;
    --text-light: #999999;
    --border-color: #cccccc;
    --border-light: #dddddd;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --shadow-light: rgba(0, 0, 0, 0.25);
    --card-bg: #ffffff;
    --card-bg-muted: #fafafa;
    --link-color: #0969da;
    --link-hover: #0550ae;
    --toggle-bg: #f3f4f6;
    --toggle-bg-hover: #e5e7eb;
    --toggle-text: #333333;
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --bg-color: #0d1117;
    --text-color: #c9d1d9;
    --text-muted: #8b949e;
    --text-light: #6e7681;
    --border-color: #30363d;
    --border-light: #21262d;
    --shadow-color: rgba(0, 0, 0, 0.4);
    --shadow-light: rgba(0, 0, 0, 0.5);
    --card-bg: #161b22;
    --card-bg-muted: #21262d;
    --link-color: #79c0ff;
    --link-hover: #a5d6ff;
    --toggle-bg: #21262d;
    --toggle-bg-hover: #30363d;
    --toggle-text: #c9d1d9;
}

/* No-JS fallback: honor system dark mode when no explicit theme is set. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        color-scheme: dark;
        --bg-color: #0d1117;
        --text-color: #c9d1d9;
        --text-muted: #8b949e;
        --text-light: #6e7681;
        --border-color: #30363d;
        --border-light: #21262d;
        --shadow-color: rgba(0, 0, 0, 0.4);
        --shadow-light: rgba(0, 0, 0, 0.5);
        --card-bg: #161b22;
        --card-bg-muted: #21262d;
        --link-color: #79c0ff;
        --link-hover: #a5d6ff;
        --toggle-bg: #21262d;
        --toggle-bg-hover: #30363d;
        --toggle-text: #c9d1d9;
    }
}

body {
    height: 100%;
    min-height: 100vh;
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Inter", sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.emphasised,
.less-emphasised {
    width: 100%;
    /* Set a fixed width */
    max-width: 800px;
    /* Optional: set a maximum width */
}

.emphasised {
    border: 1px solid var(--border-color);
    padding: 30px;
    text-align: center;
    background-color: var(--card-bg);
    box-shadow: 0 10px 20px var(--shadow-color), 0 6px 6px var(--shadow-light);
    border-radius: 8px;
    margin-top: 10px;
    margin-bottom: 10px;
    /* Add margin-bottom for spacing */
    transition: background-color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.emphasised h1 {
    margin: 0;
    font-size: 35px;
    color: var(--text-color);
}

.emphasised p,
.emphasised i {
    margin: 10px 0;
    font-size: 18px;
    color: var(--text-muted);
}

.less-emphasised {
    font-size: 16px;
    color: var(--text-light);
    padding: 20px;
    border: 1px solid var(--border-light);
    background-color: var(--card-bg-muted);
    border-radius: 8px;
    margin-bottom: 10px;
    /* Add margin-bottom for spacing */
    transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.less-emphasised ul {
    padding-left: 20px;
}

.coursework-inline-list {
    list-style: none;
    padding-left: 0;
    margin-top: 0;
    margin-bottom: 0.75rem;
}

.coursework-inline-list li {
    display: inline;
}

.coursework-inline-list li:not(:last-child)::after {
    content: " · ";
}

#RoundedPhoto {
    width: 250px;
    height: 250px;
    margin: 0px auto;
    background-image: url("david-2024.jpeg");
    background-size: 250px 250px;
    background-color: var(--card-bg);
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background-clip: padding-box;
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

.alert {
    color: rgb(185, 0, 0) !important;
    font-style: italic;
    padding: 0px !important;
}

/* Link styling */
a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.3s ease;
}

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

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

.muted-link:hover {
    color: var(--text-color);
}

.site-footer {
    width: 100%;
    max-width: 800px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    color: var(--text-light);
}

.theme-toggle {
    border: 1px solid var(--border-color);
    background-color: var(--toggle-bg);
    color: var(--toggle-text);
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.theme-toggle:hover {
    background-color: var(--toggle-bg-hover);
    border-color: var(--border-color);
    color: var(--text-color);
}

.theme-toggle:focus-visible {
    outline: 2px solid var(--link-color);
    outline-offset: 2px;
}

/* Substack icon color adaptation */
.bi-substack {
    filter: none;
    transition: filter 0.3s ease;
}

/* Homepage-only typographic refinement system. */
body.home-page {
    font-size: 17px;
    line-height: 1.58;
    text-rendering: optimizeLegibility;
    font-kerning: normal;
    font-variant-ligatures: common-ligatures contextual;
    font-variant-numeric: oldstyle-nums proportional-nums;
    font-feature-settings: normal;
}

body.home-page #content {
    width: min(100%, 800px);
}

body.home-page .emphasised,
body.home-page .less-emphasised,
body.home-page .site-footer {
    max-width: 800px;
}

body.home-page .emphasised {
    padding: clamp(24px, 2.6vw, 34px);
}

body.home-page .emphasised h1 {
    font-family: "Didot", "Bodoni 72", "Bodoni MT", "Iowan Old Style", "Baskerville", "Times New Roman", Times, serif;
    font-size: clamp(2.15rem, 4vw, 2.7rem);
    line-height: 1.08;
    letter-spacing: -0.015em;
    font-weight: 500;
    text-wrap: balance;
}

:root[data-theme="dark"] body.home-page .emphasised h1 {
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) body.home-page .emphasised h1 {
        font-weight: 600;
    }
}

body.home-page .emphasised p,
body.home-page .less-emphasised p,
body.home-page .less-emphasised li {
    line-height: 1.58;
    text-wrap: pretty;
    hanging-punctuation: first allow-end;
}

body.home-page .less-emphasised p,
body.home-page .less-emphasised ul,
body.home-page .coursework-inline-list {
    max-width: 66ch;
    margin-left: auto;
    margin-right: auto;
}

body.home-page .less-emphasised {
    font-size: 1rem;
    line-height: 1.62;
}

body.home-page .less-emphasised ul {
    padding-left: 1.2em;
}

body.home-page .less-emphasised li+li {
    margin-top: 0.5rem;
}

body.home-page .coursework-inline-list li+li {
    margin-top: 0;
}

body.home-page .coursework-inline-list {
    line-height: 1.75;
}

body.home-page .site-footer {
    font-size: 0.93rem;
    letter-spacing: 0.01em;
}

@media (max-width: 768px) {
    body.home-page {
        font-size: 16px;
        line-height: 1.55;
    }

    body.home-page .emphasised,
    body.home-page .less-emphasised {
        padding-left: 18px;
        padding-right: 18px;
    }
}