/* ==========================================================================
   leo/blog — design system
   Typography & sizing derived from cowsay.io (Atkinson Hyperlegible).
   Layout structure inspired by stfn.pl.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Tokens
   -------------------------------------------------------------------------- */
:root {
    --font-body: "Atkinson Hyperlegible", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --link: #1d4ed8;
    --link-visited: #7e22ce;

    --bg: #f5f5f5;
    --text: #444;
    --muted: rgba(0, 0, 0, 0.55);
    --border: rgba(0, 0, 0, 0.12);

    --measure: 650px;
    --top-gap: 40px;
    --line-height: 1.6;
    --base-size: 18px;
    --small-size: 0.9em;

    --code-bg: rgb(244, 247, 250);
    --code-border: rgb(232, 235, 237);
    --code-color: rgb(3, 47, 98);
}

/* Colour scheme follows the visitor's device preference (no manual toggle) */
@media (prefers-color-scheme: dark) {
    :root {
        --link: #3b82f6;
        --link-visited: #a855f7;

        --bg: #141414;
        --text: #e2e8f0;
        --muted: rgba(226, 232, 240, 0.6);
        --border: rgba(255, 255, 255, 0.14);

        --code-bg: rgb(17, 19, 25);
        --code-border: rgba(255, 255, 255, 0.1);
        --code-color: rgb(206, 145, 120);
    }
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--gh-font-body, var(--font-body));
    font-size: var(--base-size);
    line-height: var(--line-height);
    color: var(--text);
    background-color: var(--bg);
    max-width: var(--measure);
    margin: var(--top-gap) auto;
    padding: 0 10px;
    box-sizing: content-box; /* match cowsay.io: max-width excludes the 10px gutters */
    overflow-wrap: break-word;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    font-family: var(--gh-font-heading, var(--font-body));
    line-height: 1.2;
    margin: 1.5em 0 0.5em;
}

p {
    margin: 1em 0;
}

a {
    color: var(--link);
}

a:visited {
    color: var(--link-visited);
}

a:focus-visible,
button:focus-visible,
input:focus-visible {
    outline: 2px solid var(--link);
    outline-offset: 2px;
}

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

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

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

.skip-link:focus {
    left: 0;
    z-index: 10;
}

time {
    font-style: italic;
}

/* --------------------------------------------------------------------------
   Header
   -------------------------------------------------------------------------- */
.site-header {
    margin-bottom: 1.5em;
    padding-bottom: 1em;
    border-bottom: 1px solid var(--border);
}

.site-brand {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1em;
}

.site-title {
    font-size: 2.5em;
    line-height: 1.2;
    margin: 0;
    word-wrap: break-word;
}

.site-title a,
.site-title a:visited {
    color: var(--text);
    text-decoration: none;
}

.site-logo {
    display: block;
    height: 2.5em;
    width: auto;
    flex-shrink: 0;
}

.site-tagline {
    font-weight: 700;
    margin: 0.4em 0 0;
}

.site-nav {
    margin-top: 0.5em;
}

.site-nav:not(:has(a)) {
    display: none;
}

.site-nav .nav {
    list-style: disc;
    margin: 0;
    padding-left: 1.2em;
}

.site-nav .nav li {
    display: list-item;
}

.site-nav .nav a,
.site-nav .nav a:visited {
    color: var(--link);
    text-decoration: none;
    text-transform: lowercase;
}

/* --------------------------------------------------------------------------
   Subscribe form
   -------------------------------------------------------------------------- */
.site-subscribe {
    text-align: left;
    margin-bottom: 1.5em;
}

.post-subscribe {
    margin-top: 0;
}

.site-subscribe-heading {
    font-weight: 700;
    margin: 0;
}

.site-subscribe-subhead {
    color: var(--muted);
    margin: 0.25em 0 0.75em;
    font-size: var(--small-size);
}

.subscribe-form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
}

.subscribe-input {
    flex: 1 1 12em;
    min-width: 0;
    font: inherit;
    font-size: var(--small-size);
    padding: 0.4em 0.7em;
    color: var(--text);
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.subscribe-input:focus {
    outline: 2px solid var(--link);
    outline-offset: 1px;
}

.subscribe-button {
    font: inherit;
    font-size: var(--small-size);
    padding: 0.4em 1em;
    border: 1px solid var(--link);
    border-radius: 999px;
    background: none;
    color: var(--link);
    cursor: pointer;
}

.subscribe-button:hover {
    background: var(--link);
    border-color: var(--link);
    color: #fff;
}

.subscribe-button .subscribe-loading,
.subscribe-button .subscribe-sent {
    display: none;
}

.subscribe-form.loading .subscribe-label,
.subscribe-form.success .subscribe-label {
    display: none;
}

.subscribe-form.loading .subscribe-loading {
    display: inline;
}

.subscribe-form.success .subscribe-sent {
    display: inline;
}

.subscribe-form.success .subscribe-input {
    opacity: 0.5;
}

.subscribe-error {
    flex-basis: 100%;
    margin: 0;
    color: #c0392b;
    font-size: var(--small-size);
}

.subscribe-error:empty {
    display: none;
}

/* --------------------------------------------------------------------------
   Post list
   -------------------------------------------------------------------------- */
.post-list {
    margin: 1em 0 0;
    padding: 0;
    list-style: none;
}

.post-list-item {
    margin-top: 2.5em;
}

.post-list-item .post-link {
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}

.post-list-item .post-link:hover {
    color: var(--link);
}

.post-list-item .post-excerpt {
    display: block;
}

.post-date {
    display: block;
    float: right;
    font-style: italic;
    font-size: var(--small-size);
    color: var(--muted);
}

/* clear the float on the following item */
.post-list-item::after {
    content: "";
    display: table;
    clear: both;
}

/* --------------------------------------------------------------------------
   Filter chips
   -------------------------------------------------------------------------- */
.post-filters {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5em;
    margin: 0 0 0.5em;
}

.filter-chip {
    display: inline-block;
    font-size: var(--small-size);
    padding: 0.15em 0.7em;
    border: 1px solid var(--border);
    border-radius: 999px;
    color: var(--muted);
    text-decoration: none;
    text-transform: lowercase;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.filter-chip:visited {
    color: var(--muted);
}

.filter-chip:hover,
.filter-chip.is-active {
    color: var(--link);
    border-color: var(--link);
}

/* --------------------------------------------------------------------------
   Article / page content
   -------------------------------------------------------------------------- */
.post-header,
.page-header {
    margin-bottom: 1.5em;
}

/* Ornamental divider — only inside the body of a blog post */
.post-content hr {
    position: relative;
    height: 0;
    margin: 2.5em 0;
    border: 0;
    border-top: 1px solid var(--border);
    overflow: visible;
}

.post-content hr::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 2.5em;
    height: 1em;
    transform: translate(-50%, -50%);
    background-color: var(--bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 16'%3E%3Cpath fill='%238a8a8a' d='M20 1c1 5 2 6 7 7-5 1-6 2-7 7-1-5-2-6-7-7 5-1 6-2 7-7z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 1.4em 0.56em;
}

.post-title,
.page-title {
    margin-top: 0;
}

.post-content a,
.page-content a {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

.post-content code,
.page-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 80%;
    padding: 3px 4px;
    border: 1px solid var(--code-border);
    border-radius: 4px;
    background: var(--code-bg);
    color: var(--code-color);
}

.post-content pre,
.page-content pre {
    overflow-x: auto;
    padding: 1em;
    border: 1px solid var(--code-border);
    border-radius: 4px;
}

.post-content pre code,
.page-content pre code {
    padding: 0;
    border: 0;
    background: none;
    font-size: 0.85em;
}

.post-content blockquote,
.page-content blockquote {
    margin: 1.5em 0;
    padding-left: 1em;
    border-left: 3px solid var(--border);
    font-style: italic;
}

.post-content figure,
.page-content figure {
    margin: 1.5em 0;
}

.post-content figcaption,
.page-content figcaption {
    font-size: var(--small-size);
    color: var(--muted);
    text-align: center;
}

/* Ghost editor cards */
.kg-width-wide {
    width: 100%;
}

.kg-width-full {
    width: 100%;
}

.kg-card {
    margin: 1.5em 0;
}

/* --------------------------------------------------------------------------
   Collections
   -------------------------------------------------------------------------- */
.collection-header {
    margin-bottom: 1.5em;
}

.collection-title {
    margin: 0;
}

.collection-description {
    margin: 0.4em 0 0;
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Single post / page
   -------------------------------------------------------------------------- */
.back-link {
    display: inline-block;
    margin-bottom: 1em;
    color: var(--link);
    text-decoration: none;
    text-transform: lowercase;
}

.back-link:hover {
    text-decoration: underline;
}

.post-header,
.page-header {
    margin-bottom: 1.5em;
}

.post-title,
.page-title {
    margin: 0;
}

.post-header .post-date {
    float: none;
    display: block;
    margin-top: 0.4em;
}

.post-image {
    margin: 1.5em 0;
}

.post-image img {
    display: block;
    width: 100%;
}

.post-tags {
    margin-top: 0.4em;
    font-size: var(--small-size);
}

.post-tag {
    color: var(--muted);
    text-decoration: none;
    margin-right: 0.75em;
    text-transform: lowercase;
}

.post-tag:hover {
    color: var(--link);
}

/* --------------------------------------------------------------------------
   Pagination
   -------------------------------------------------------------------------- */
.pagination {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1em;
    margin: 3em 0 0;
    padding: 0;
    font-size: var(--small-size);
}

.pagination:not(:has(a)) {
    display: none;
}

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

.pagination .page-count {
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Error
   -------------------------------------------------------------------------- */
.error-code {
    font-size: 3em;
    margin: 0;
}

.error-message {
    color: var(--muted);
}

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */
.site-footer {
    margin-top: 2.5em;
    padding-top: 0;
    text-align: right;
}

.site-footer-social {
    display: flex;
    justify-content: flex-end;
    gap: 0.5em;
    margin-top: 1em;
}

.site-footer-social:not(:has(a)) {
    display: none;
}

.site-footer-social a {
    color: var(--muted);
    display: inline-flex;
}

.site-footer-social a:hover {
    color: var(--link);
}

.site-footer-social svg {
    width: 1.3em;
    height: 1.3em;
    fill: currentColor;
}

.site-footer-meta {
    margin-top: 1em;
    font-size: var(--small-size);
    color: var(--muted);
}

.site-footer-meta a {
    color: inherit;
}
