/*
 * Visual language ported from archlinux.org (archweb.css / navbar.css / generic.css).
 *
 * Values taken from the live Arch stylesheets:
 *   --archlinux-blue        #08c    links, 5px navbar underline
 *   --archlinux-blue-bright #0ae
 *   navbar                  #333 bg, #999 links, #fff hover, 14px bold sans-serif
 *   body                    #f6f9fc bg, #222 text, sans-serif, 13px content (0.812em)
 *   div.box                 #ecf2f5 bg, #bcd border
 *   h2                      1px solid #888 bottom rule
 *   code / pre              #ffd / #dfd on #bdb
 *   table.pretty2           #bbb border, #eee header
 *
 * archlinux.org itself ships light-only (no prefers-color-scheme, no toggle). The dark
 * palette below is derived from the dark surfaces Arch defines in its shared generic.css
 * (--archlinux-blue-dark1 #2a2e33, --archlinux-blue-dark2 #191b1e), which is also the
 * family the Arch Wiki dark theme uses.
 *
 * Font sizing follows the Arch convention of ems against a 16px default:
 *   14px = 0.875em   13px = 0.812em   12px = 0.75em   11px = 0.6875em
 */

/* ============================== theme tokens ============================== */

:root {
    /* Arch brand constants — identical in both themes, they are the signature */
    --arch-blue: #08c;
    --arch-blue-bright: #0ae;
    --arch-logo-blue: #1793d1;

    /* light theme */
    --bg: #f6f9fc;
    --surface: #fff;
    --fg: #222;
    --fg-muted: #666;
    --fg-faint: #888;

    --link: var(--arch-blue);
    --rule: #888;
    --rule-soft: #dde4ea;

    --navbar-bg: #333;
    --navbar-fg: #999;
    --navbar-fg-hover: #fff;
    --navbar-underline: var(--arch-blue);
    --navbar-btn-border: #5a6068;

    --box-bg: #ecf2f5;
    --box-border: #bcd;

    --code-bg: #ffd;
    --code-fg: #222;
    --pre-bg: #dfd;
    --pre-border: #bdb;

    --table-border: #bbb;
    --table-header-bg: #eee;

    --tag-bg: #e4eeff;
    --tag-border: #bcd;

    --focus-ring: var(--arch-blue);

    color-scheme: light;
}

/* System preference drives the theme until the visitor picks one explicitly. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #191b1e;
        --surface: #2a2e33;
        --fg: #d5d8db;
        --fg-muted: #9aa1a9;
        --fg-faint: #7d848c;

        --link: var(--arch-blue-bright);
        --rule: #4a4f57;
        --rule-soft: #33383f;

        --navbar-bg: #111315;
        --navbar-fg: #9aa1a9;
        --navbar-fg-hover: #fff;
        --navbar-btn-border: #4a4f57;

        --box-bg: #23262a;
        --box-border: #363b42;

        --code-bg: #33301f;
        --code-fg: #e8e2c4;
        --pre-bg: #1d251d;
        --pre-border: #35452f;

        --table-border: #3a3f46;
        --table-header-bg: #2a2e33;

        --tag-bg: #23303d;
        --tag-border: #344658;

        --focus-ring: var(--arch-blue-bright);

        color-scheme: dark;
    }
}

/* Explicit choice from the toggle. Must win over the media query in both directions. */
:root[data-theme="dark"] {
    --bg: #191b1e;
    --surface: #2a2e33;
    --fg: #d5d8db;
    --fg-muted: #9aa1a9;
    --fg-faint: #7d848c;

    --link: var(--arch-blue-bright);
    --rule: #4a4f57;
    --rule-soft: #33383f;

    --navbar-bg: #111315;
    --navbar-fg: #9aa1a9;
    --navbar-fg-hover: #fff;
    --navbar-btn-border: #4a4f57;

    --box-bg: #23262a;
    --box-border: #363b42;

    --code-bg: #33301f;
    --code-fg: #e8e2c4;
    --pre-bg: #1d251d;
    --pre-border: #35452f;

    --table-border: #3a3f46;
    --table-header-bg: #2a2e33;

    --tag-bg: #23303d;
    --tag-border: #344658;

    --focus-ring: var(--arch-blue-bright);

    color-scheme: dark;
}

/* ================================= reset ================================= */

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

* {
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

/* ================================= base ================================== */

html {
    font-size: 100%;
}

body {
    background: var(--bg);
    color: var(--fg);
    font: normal 100% / 1.4 sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-wrap: break-word;
}

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

a:hover,
a:focus-visible {
    text-decoration: underline;
}

:focus-visible {
    outline: 2px solid var(--focus-ring);
    outline-offset: 2px;
}

p {
    margin: .33em 0 1em;
}

ol,
ul {
    margin-bottom: 1em;
    padding-left: 2em;
}

ul {
    list-style: square;
}

hr {
    border: none;
    border-top: 1px solid var(--rule);
    margin: 1.5em 0;
}

img {
    border: 0;
    max-width: 100%;
    height: auto;
}

blockquote {
    margin: 1.5em 0 1.5em 1em;
    padding-left: 1em;
    border-left: 3px solid var(--box-border);
    color: var(--fg-muted);
}

code {
    font-family: monospace, monospace;
    background: var(--code-bg);
    color: var(--code-fg);
    padding: 0.15em 0.25em;
}

pre {
    font-family: monospace, monospace;
    border: 1px solid var(--pre-border);
    background: var(--pre-bg);
    padding: 0.5em;
    margin: 1em 0;
    overflow-x: auto;
}

pre code {
    display: block;
    background: none;
    color: inherit;
    padding: 0;
    white-space: pre;
}

/* ================================ headings =============================== */

h1 {
    font-size: 1.75em;
    margin-bottom: 0.5em;
}

h2 {
    font-size: 1.5em;
    margin-bottom: 0.5em;
    border-bottom: 1px solid var(--rule);
}

h3 {
    font-size: 1.25em;
    margin-top: .5em;
}

h4 {
    font-size: 1.15em;
    margin-top: 1em;
}

h5 {
    font-size: 1em;
    margin-top: 1em;
}

/* Arch reveals a paragraph anchor on heading hover. */
a.headerlink {
    visibility: hidden;
    padding-left: 0.5em;
}

h2:hover > a.headerlink,
h3:hover > a.headerlink {
    visibility: visible;
}

/* ================================= navbar ================================ */

#archnavbar {
    background: var(--navbar-bg);
    border-bottom: 5px solid var(--navbar-underline);
    padding: 10px 15px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px 20px;
    min-height: 40px;
}

/*
 * Text wordmark rather than the Arch logo — the Arch "A" and wordmark are project
 * trademarks. Same ~40px bar height and logo blue so the bar reads the same.
 */
#logo {
    flex: 0 0 auto;
}

#logo a {
    display: block;
    font-size: 1.5em;
    font-weight: bold;
    letter-spacing: -0.02em;
    line-height: 40px;
    color: #fff;
    text-decoration: none;
}

#logo a:hover {
    text-decoration: none;
}

#logo .logo-mark {
    color: var(--arch-logo-blue);
}

#archnavbarlist {
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0 30px;
    list-style: none;
    margin: 0;
    padding: 0;
}

#archnavbarlist li {
    font-size: 0.875em; /* 14px */
    line-height: 1.4;
}

#archnavbarlist li a {
    color: var(--navbar-fg);
    font-weight: bold;
    text-decoration: none;
}

#archnavbarlist li a:hover,
#archnavbarlist li a:focus-visible {
    color: var(--navbar-fg-hover);
    text-decoration: underline;
}

/* Current section marker — Arch has no equivalent, so it stays understated.
   NavLink adds .active; aria-current is covered too in case that changes. */
#archnavbarlist li a.active,
#archnavbarlist li a[aria-current="page"] {
    color: var(--navbar-fg-hover);
}

/* ============================== theme toggle ============================== */

.theme-toggle {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    gap: 0.4em;
    background: transparent;
    border: 1px solid var(--navbar-btn-border);
    border-radius: 2px;
    color: var(--navbar-fg);
    font: bold 0.75em sans-serif; /* 12px */
    padding: 0.4em 0.6em;
    cursor: pointer;
}

.theme-toggle:hover {
    color: var(--navbar-fg-hover);
    border-color: var(--navbar-fg-hover);
}

.theme-toggle svg {
    width: 1.15em;
    height: 1.15em;
    fill: currentColor;
    flex: 0 0 auto;
}

/* Show the icon and label for the theme the button will switch TO. */
.theme-toggle .for-dark {
    display: none;
}

:root[data-theme="dark"] .theme-toggle .for-dark {
    display: inline;
}

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

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .theme-toggle .for-light {
        display: none;
    }

    :root:not([data-theme="light"]) .theme-toggle .for-dark {
        display: inline;
    }
}

/* ================================= layout ================================ */

#content {
    width: 95%;
    max-width: 1200px;
    margin: 1.5em auto 0;
    font-size: 0.812em; /* 13px — Arch's dense content scale */
    flex: 1 0 auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 0 40px;
    align-items: start;
}

/* Pages without a sidebar span the full grid. */
#content.no-sidebar {
    grid-template-columns: minmax(0, 1fr);
}

#content-left,
#content-right {
    min-width: 0;
}

div.box {
    margin-bottom: 1.5em;
    padding: 0.65em;
    background: var(--box-bg);
    border: 1px solid var(--box-border);
}

#footer {
    margin: 3em auto 1em;
    width: 95%;
    max-width: 1200px;
    padding-top: 1em;
    border-top: 1px solid var(--rule-soft);
    flex: 0 0 auto;
}

#footer p {
    margin: 0;
    text-align: center;
    font-size: 0.85em;
    color: var(--fg-muted);
}

/*
 * archlinux.org is fixed-width (min-width: 650px) and does not adapt. A personal site
 * in 2026 has to, so the sidebar drops below the content instead of forcing a
 * horizontal scroll. Everything above this point is the Arch look, unchanged.
 */
@media (max-width: 900px) {
    #content {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    #content-right {
        margin-top: 1em;
    }

    #archnavbarlist {
        justify-content: flex-start;
        gap: 0 18px;
    }
}

/* ================================= tables ================================ */

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
}

th {
    vertical-align: middle;
    font-weight: bold;
}

td {
    vertical-align: top;
}

table .wrap {
    white-space: normal;
}

/* Arch's table.pretty2 */
table.pretty2 {
    width: auto;
    margin-top: 0.25em;
    margin-bottom: 0.5em;
    border: 1px solid var(--table-border);
}

.pretty2 th {
    padding: 0.35em;
    background: var(--table-header-bg);
    border: 1px solid var(--table-border);
}

.pretty2 td {
    padding: 0.35em;
    border: 1px dotted var(--table-border);
}

/* Wide tables scroll inside their own container, never the page. */
.table-scroll {
    overflow-x: auto;
    margin-bottom: 1em;
}

/* ============================== page sections ============================ */

#intro p.readmore {
    margin-top: 1em;
    font-weight: bold;
}

.timestamp {
    color: var(--fg-muted);
    font-size: 0.85em;
    white-space: nowrap;
}

.meta {
    color: var(--fg-muted);
    font-size: 0.9em;
    margin: 0.25em 0 1em;
}

.rss-icon {
    font-size: 0.85em;
    font-weight: normal;
}

/* --- post listing (mirrors Arch's #news blocks) --- */

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

.post-list > li {
    margin-bottom: 1.5em;
    padding-bottom: 1.25em;
    border-bottom: 1px solid var(--rule-soft);
}

.post-list > li:last-child {
    border-bottom: none;
}

.post-list h3 {
    margin-top: 0;
    font-size: 1.15em;
}

.post-list p {
    margin: 0.4em 0 0.5em;
}

/* --- tags --- */

.tag-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4em;
}

.tag {
    display: inline-block;
    background: var(--tag-bg);
    border: 1px solid var(--tag-border);
    padding: 0.1em 0.45em;
    font-size: 0.9em;
    white-space: nowrap;
}

.tag:hover {
    text-decoration: none;
    border-color: var(--link);
}

.tag .count {
    color: var(--fg-muted);
}

/* --- experience / roles --- */

.role {
    margin-bottom: 2em;
}

.role-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: baseline;
    gap: 0 1em;
    border-bottom: 1px solid var(--rule-soft);
    padding-bottom: 0.3em;
    margin-bottom: 0.5em;
}

.role-head h3 {
    margin: 0;
    font-size: 1.15em;
}

.role-company {
    color: var(--fg-muted);
}

.stack {
    list-style: none;
    padding: 0;
    margin: 0.6em 0 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35em;
}

.stack li {
    background: var(--box-bg);
    border: 1px solid var(--box-border);
    padding: 0.1em 0.45em;
    font-size: 0.9em;
    color: var(--fg-muted);
    white-space: nowrap;
}

/* --- projects --- */

.project {
    margin-bottom: 1.75em;
    padding-bottom: 1.25em;
    border-bottom: 1px solid var(--rule-soft);
}

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

.project h3 {
    margin-top: 0;
    font-size: 1.15em;
}

.project-links {
    margin-top: 0.5em;
    font-size: 0.9em;
    display: flex;
    gap: 1em;
    flex-wrap: wrap;
}

/* --- sidebar --- */

#content-right h4 {
    margin-top: 0;
    font-size: 1em;
    border-bottom: 1px solid var(--rule-soft);
    padding-bottom: 0.25em;
    margin-bottom: 0.5em;
}

#content-right ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

#content-right ul.link-list li {
    padding: 0.15em 0;
}

/* --- rendered markdown body --- */

.post-body > :first-child {
    margin-top: 0;
}

.post-body h2 {
    margin-top: 1.5em;
    font-size: 1.35em;
}

.post-body h3 {
    margin-top: 1.25em;
}

/* Diagrams are SVG files referenced with Markdown image syntax — the Markdig pipeline
   calls DisableHtml, so inline <svg> in a post would be escaped rather than drawn. An
   <img>-loaded SVG cannot inherit page CSS either, so each file carries its own
   prefers-color-scheme rules. */
.post-body img {
    display: block;
    margin: 1.75em auto;
}

.post-body table {
    width: auto;
    margin: 1em 0;
    border: 1px solid var(--table-border);
}

.post-body th {
    padding: 0.35em;
    background: var(--table-header-bg);
    border: 1px solid var(--table-border);
}

.post-body td {
    padding: 0.35em;
    border: 1px dotted var(--table-border);
}

.post-body li {
    margin-bottom: 0.25em;
}

/* --- prev/next --- */

.post-nav {
    display: flex;
    justify-content: space-between;
    gap: 1em;
    margin-top: 2em;
    padding-top: 1em;
    border-top: 1px solid var(--rule-soft);
    font-size: 0.95em;
}

/* ============================== utilities =============================== */

.center {
    text-align: center;
}

.muted {
    color: var(--fg-muted);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--surface);
    color: var(--link);
    padding: 0.5em 1em;
    z-index: 100;
}

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