/* Self-hosted JetBrains Mono (SIL OFL 1.1 - see fonts/OFL.txt).
   One variable file per subset covers every weight the design uses, and keeps
   the render off Google's servers: no third-party DNS, TLS or GDPR question. */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('/static/fonts/jetbrains-mono-latin.18be4527.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* Latin Extended carries the c-acute in "Jelic". */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 100 800;
    font-display: swap;
    src: url('/static/fonts/jetbrains-mono-latin-ext.79bfdab9.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* GitHub Dark Colorblind palette - "modern terminal" theme */
    --bg: #0d1117;
    --bg-subtle: #161b22;
    --bg-inset: #010409;
    --fg: #c9d1d9;
    --fg-muted: #8b949e;
    --fg-subtle: #6e7681;
    --border: #30363d;
    --border-muted: #21262d;
    --accent: #58a6ff;
    --accent-emphasis: #1f6feb;
    --attention: #d29922;
    --done: #a371f7;
    --danger: #d47616;
}

body {
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    line-height: 1.7;
    color: var(--fg);
    background-color: var(--bg);
    margin: 0;
    padding: 0;
    min-height: 100vh;
}

/* Header */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 1.5rem 0;
    margin-bottom: 4rem;
}

nav {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 2rem;
}

.nav-prompt {
    color: var(--fg-muted);
    margin-right: 0.5rem;
    white-space: nowrap;
}

.nav-user {
    color: var(--done);
}

.nav-punct {
    color: var(--fg-subtle);
}

.nav-path {
    color: var(--accent);
}

.nav-cursor {
    display: inline-block;
    width: 0.6em;
    height: 1.1em;
    background: var(--accent);
    margin-left: 0.25rem;
    vertical-align: text-bottom;
    animation: blink 1s steps(1, jump-none) infinite;
}

@keyframes blink {

    0%,
    49% {
        opacity: 1;
    }

    50%,
    100% {
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .nav-cursor {
        animation: none;
        opacity: 1;
    }
}

nav a {
    text-decoration: none;
    color: var(--fg-muted);
    font-weight: 500;
    font-size: 1.05rem;
    transition: color 0.3s ease;
    position: relative;
    padding: 0.5rem 0;
}

nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: 0;
    left: 0;
    background-color: var(--accent);
    transition: width 0.3s ease;
}

nav a:hover {
    color: var(--accent);
}

nav a:hover::after {
    width: 100%;
}

main {
    animation: fadeIn 0.8s ease-out;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    color: var(--fg);
    letter-spacing: -0.02em;
}

h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 1.5rem;
}

h2 {
    font-size: 2rem;
    margin-top: 3rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-muted);
    padding-bottom: 0.5rem;
}

h3 {
    font-size: 1.5rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
    color: var(--accent);
}

.term-comment {
    color: var(--fg-subtle);
    font-size: 0.85em;
    margin: 0 0 0.75rem 0;
}

#cv {
    line-height: 1.8;
}

#cv p {
    margin-bottom: 1.5rem;
}

#cv ul {
    margin-left: 1.5rem;
    margin-bottom: 1.5rem;
}

#cv li {
    margin-bottom: 0.5rem;
}

#cv blockquote {
    border-left: 4px solid var(--accent);
    background: var(--bg-subtle);
    padding: 1.5rem;
    margin: 2rem 0;
    color: var(--fg);
    font-style: italic;
}

#cv hr {
    border: none;
    border-top: 1px solid var(--border-muted);
    margin: 3rem 0;
}

#cv a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
    transition: color 0.2s ease, border-color 0.2s ease;
}

#cv a:hover {
    color: var(--accent-emphasis);
    border-bottom-style: solid;
}

#cv aside {
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 4px solid var(--done);
    padding: 1.5rem;
    margin: 2rem 0;
    color: var(--fg);
}

/* Strategies Page */
.strategies-section {
    max-width: 900px;
    margin: 0 auto;
}

.intro-text {
    margin-bottom: 2rem;
    color: var(--fg-muted);
}

.strategy-controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    flex-wrap: wrap;
}

.strategy-btn {
    display: inline-block;
    text-decoration: none;
    background: transparent;
    border: 1px solid var(--border);
    padding: 0.75rem 1.5rem;
    cursor: pointer;
    font-family: inherit;
    font-weight: 500;
    color: var(--fg);
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}

.strategy-btn::before {
    content: "[ ";
    color: var(--fg-subtle);
}

.strategy-btn::after {
    content: " ]";
    color: var(--fg-subtle);
}

.strategy-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.strategy-btn.active {
    background: var(--accent-emphasis);
    color: var(--bg);
    border-color: var(--accent-emphasis);
}

.strategy-btn.active::before,
.strategy-btn.active::after {
    color: inherit;
}

.strategy-content {
    background: var(--bg-subtle);
    padding: 2rem;
    border: 1px solid var(--border);
    animation: fadeIn 0.3s ease-in-out;
}

.strategy-content h1 {
    margin-top: 0;
    font-size: 1.75rem;
    margin-bottom: 1.5rem;
    color: var(--accent);
}

.strategy-content h2 {
    font-size: 1.4rem;
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.strategy-content pre {
    background: var(--bg-inset);
    color: var(--fg);
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-muted);
}

.strategy-content code {
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.9em;
}

.strategy-content p code {
    background: var(--bg-inset);
    padding: 0.2rem 0.4rem;
    color: var(--accent);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {

    main,
    .content-wrapper main,
    .strategy-content,
    .blog-post {
        animation: none;
    }
}

#cv code {
    background-color: var(--bg-inset);
    color: var(--accent);
    padding: 0.2rem 0.6rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-muted);
}

/* Footer */
footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border);
    background: var(--bg-subtle);
}

.footer-content {
    width: 100%;
    padding: 0 2rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    color: var(--fg-muted);
    font-size: 0.9rem;
}

.contact-info {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    justify-content: center;
}

.contact-info > span,
.contact-info > a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.social-links {
    display: flex;
    gap: 1.5rem;
}

.footer-content a {
    color: var(--fg-muted);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-content a:hover {
    color: var(--accent);
}

@media (max-width: 600px) {
    .footer-content {
        gap: 1.5rem;
    }

    .contact-info {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--fg-muted);
}

/* Content Wrapper with Sidebar */
.content-wrapper {
    display: flex;
    gap: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem 4rem;
}

.content-wrapper main {
    flex: 1;
    min-width: 0;
    /* Allows flex item to shrink below content size */
    padding: 0;
    animation: fadeIn 0.8s ease-out;
}

/* Sidebar */
.sidebar {
    width: 280px;
    flex-shrink: 0;
    position: sticky;
    top: 120px;
    align-self: flex-start;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    padding: 1.5rem;
}

.sidebar h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    color: var(--fg);
    border-bottom: 1px solid var(--border-muted);
    padding-bottom: 0.5rem;
}

.blog-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.blog-item {
    margin-bottom: 1rem;
}

.blog-link {
    text-decoration: none;
    display: block;
    padding: 0.75rem;
    transition: color 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
    border: 1px solid transparent;
}

.blog-link:hover {
    background: var(--bg-subtle);
    border-color: var(--accent);
}

.blog-link.active {
    background: var(--bg-subtle);
    border-color: var(--done);
}

.blog-link.active .blog-link-title {
    color: var(--done);
}

.blog-link-title {
    display: block;
    margin: 0 0 0.25rem 0;
    font-size: 0.95rem;
    color: var(--accent);
    font-weight: 500;
    line-height: 1.4;
}

.blog-link time {
    display: block;
    font-size: 0.85rem;
    color: var(--fg-muted);
}

.no-posts {
    color: var(--fg-subtle);
    font-size: 0.9rem;
    font-style: italic;
}

/* Blog Page Styles */
.blog-section {
    line-height: 1.8;
}

.blog-display {
    width: 100%;
}

.blog-post {
    width: 100%;
    animation: fadeIn 0.3s ease-in-out;
}

.blog-meta {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-muted);
}

.blog-meta time {
    color: var(--fg-muted);
    font-size: 0.9rem;
}

.blog-summary {
    font-style: italic;
    color: var(--fg-muted);
    margin-bottom: 1.5rem;
    font-size: 1.05rem;
}

.blog-content {
    color: var(--fg);
}

.blog-content p {
    margin-bottom: 1.5rem;
}

.blog-content h1,
.blog-content h2,
.blog-content h3 {
    color: var(--fg);
    margin-top: 2rem;
}

.blog-content a {
    color: var(--accent);
    text-decoration: none;
    border-bottom: 1px dashed var(--accent);
    transition: color 0.2s ease, border-color 0.2s ease;
}

.blog-content a:hover {
    color: var(--accent-emphasis);
    border-bottom-style: solid;
}

.blog-content code {
    background-color: var(--bg-inset);
    color: var(--accent);
    padding: 0.2rem 0.6rem;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', monospace;
    font-size: 0.9em;
    border: 1px solid var(--border-muted);
}

.blog-content pre {
    background: var(--bg-inset);
    padding: 1rem;
    overflow-x: auto;
    margin: 1rem 0;
    border: 1px solid var(--border-muted);
}

.blog-content pre code {
    background: none;
    border: none;
    padding: 0;
}

/* Responsive Design */
@media (max-width: 900px) {
    .content-wrapper {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        position: static;
        max-height: none;
        order: -1;
    }

    h1 {
        font-size: 2rem;
    }

    .blog-post {
        padding: 1.25rem;
    }
}

@media (max-width: 600px) {
    nav {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .nav-prompt {
        display: block;
        margin: 0 0 0.5rem 0;
    }

    .content-wrapper {
        padding: 0 1rem 2rem;
    }

    .sidebar {
        padding: 1rem;
    }

    .strategy-controls {
        flex-direction: column;
    }

    .strategy-btn {
        width: 100%;
    }

    .blog-link {
        padding: 0.6rem;
    }

    .footer-content {
        padding: 0 1rem;
    }

    .contact-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
}

/* ---------------------------------------------------------------------------
   Server-rendered navigation components
   --------------------------------------------------------------------------- */

/* Keyboard users land here first and can jump past the nav. */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    z-index: 200;
    padding: 0.75rem 1.25rem;
    background: var(--bg-subtle);
    border: 1px solid var(--accent);
    color: var(--accent);
    text-decoration: none;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
}

/* A visible focus ring everywhere, since the hover underline is not enough. */
a:focus-visible,
.strategy-btn:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
}

/* Current section in the top nav. */
nav a[aria-current="page"] {
    color: var(--accent);
}

nav a[aria-current="page"]::after {
    width: 100%;
}

/* Index listings for /blog and /strategies */
.doc-index {
    list-style: none;
    padding: 0;
    margin: 0;
}

.doc-index-item {
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border);
    border-left: 3px solid var(--border);
    transition: border-color 0.2s ease;
}

.doc-index-item:hover {
    border-left-color: var(--accent);
}

.doc-index-item h2 {
    font-size: 1.35rem;
    margin: 0 0 0.35rem 0;
    border-bottom: none;
    padding-bottom: 0;
}

.doc-index-item h2 a {
    color: var(--accent);
    text-decoration: none;
}

.doc-index-item h2 a:hover {
    text-decoration: underline;
}

.doc-index-item time {
    display: block;
    color: var(--fg-muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
}

.doc-index-summary {
    color: var(--fg);
    margin: 0 0 1rem 0;
}

.doc-index-more {
    color: var(--fg-muted);
    text-decoration: none;
    font-size: 0.9rem;
}

.doc-index-more:hover {
    color: var(--accent);
}

/* "cd .." link at the foot of a document */
.doc-footer-nav {
    margin-top: 3rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-muted);
}

.doc-footer-nav a {
    color: var(--fg-muted);
    text-decoration: none;
}

.doc-footer-nav a:hover {
    color: var(--accent);
}

/* Currently open post, highlighted in the sidebar */
.blog-link[aria-current="page"] {
    background: var(--bg-inset);
    border-color: var(--done);
}

.blog-link[aria-current="page"] .blog-link-title {
    color: var(--done);
}

/* 404 */
.notfound h1 {
    font-size: 5rem;
    margin-bottom: 0.5rem;
    color: var(--danger);
}

.notfound .doc-footer-nav {
    border-top: none;
    margin-top: 1.5rem;
    padding-top: 0;
}

/* ---------------------------------------------------------------------------
   CV download
   --------------------------------------------------------------------------- */

.cv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

/* Scoped under #cv to outrank the generic `#cv p` and `#cv a` rules. */
#cv .cv-toolbar .term-comment {
    margin: 0;
}

#cv .cv-download {
    padding: 0.4rem 1rem;
    font-size: 0.9em;
    color: var(--accent);
    border: 1px solid var(--border);
}

#cv .cv-download:hover {
    border-color: var(--accent);
}

.print-only {
    display: none;
}

/* ---------------------------------------------------------------------------
   Print - also what the downloadable PDF is rendered from (see Dockerfile).
   A dark terminal theme on paper is a page of toner, so print swaps to a light
   palette and keeps only the document: no nav, sidebar, footer or animation.
   --------------------------------------------------------------------------- */

@page {
    size: A4;
    margin: 14mm 16mm;
}

@media print {
    :root {
        --bg: #ffffff;
        --bg-subtle: #ffffff;
        --bg-inset: #f6f8fa;
        --fg: #1f2328;
        --fg-muted: #4b535d;
        --fg-subtle: #6e7781;
        --border: #d0d7de;
        --border-muted: #d8dee4;
        --accent: #0550ae;
        --accent-emphasis: #0550ae;
        --done: #6639ba;
    }

    /* The page declares color-scheme: dark, which would paint the page
       margins dark even with a white body. */
    html {
        font-size: 9.5pt;
        color-scheme: light;
    }

    html,
    body {
        background: var(--bg);
    }

    body {
        min-height: 0;
        line-height: 1.5;
    }

    header,
    .sidebar,
    footer,
    .skip-link,
    .cv-toolbar,
    .screen-only {
        display: none !important;
    }

    .print-only {
        display: revert;
    }

    main,
    .content-wrapper main {
        animation: none;
    }

    .content-wrapper {
        display: block;
        max-width: none;
        padding: 0;
    }

    h1 {
        font-size: 2.2rem;
        margin: 0 0 0.25rem;
    }

    h2 {
        font-size: 1.3rem;
        margin: 1.4rem 0 0.6rem;
        padding-bottom: 0.25rem;
        break-after: avoid;
    }

    #cv {
        line-height: 1.5;
    }

    #cv p {
        margin: 0 0 0.35rem;
    }

    #cv ul {
        margin: 0.25rem 0 0.25rem 1.25rem;
        padding-left: 0;
    }

    /* Sections may break across pages; a single bullet may not. */
    #cv li {
        margin-bottom: 0.2rem;
        break-inside: avoid;
    }

    /* h2 already draws the rule; the markdown's own --- would double it. */
    #cv hr {
        display: none;
    }

    #cv blockquote {
        font-style: normal;
        padding: 0 0 0 0.9rem;
        margin: 0 0 0.9rem;
        border-left-width: 2px;
    }

    #cv blockquote p {
        margin: 0 0 0.2rem;
    }

    #cv aside {
        padding: 0.6rem 0.9rem;
        margin: 0.9rem 0;
        border-left-width: 2px;
    }

    #cv aside p {
        margin: 0;
    }

    #cv a {
        border-bottom: none;
    }

    .cv-contact .contact-info {
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start;
        gap: 0.25rem 1.25rem;
        margin-bottom: 0.5rem;
        color: var(--fg-muted);
    }

    .cv-contact .contact-info a {
        color: var(--fg-muted);
        text-decoration: none;
    }
}
