/* --- tokens --- */

:root {
    /* colors, just two: dark brown ink on warm paper. dark mode has its own pair below. */
    --color-bg: hsl(45 25% 95%);
    --color-text: hsl(45 50% 10%);

    /* container sizes */
    --container-width: 30rem;
    --post-min-height: 120px;

    /* spacing */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 2rem;
    --space-xl: 5rem;

    /* fonts: the device's own, sans-serif for writing and monospace for code */
    --font-sans: system-ui, sans-serif;
    --font-mono: ui-monospace, Menlo, Consolas, monospace;
    --font-size-sm: 1rem;
    --font-size-md: 1.5rem;
    --font-size-lg: 2rem;

    /* line heights (box heights of a line of text) */
    --line-height-body: 1.6;
    --line-height-heading: 1.2;

    color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #1f1f21;
        --color-text: #e8d9c0;
    }
}

/* --- base --- */

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

::selection {
    background: var(--color-text);
    color: var(--color-bg);
}

body, h1, h2, p, ul, ol, blockquote, pre {
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-body);
    min-height: 100dvh;
}

button, input, textarea {
    background-color: inherit;
    border: none;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
}

button {
    cursor: pointer;
    padding: 0;
}

textarea {
    padding: 0;
}

/* --- elements --- */

h1, h2 {
    line-height: var(--line-height-heading);
    text-wrap: balance;
}

h1 {
    font-size: var(--font-size-lg);
}

h2 {
    font-size: var(--font-size-md);
}

/*
links, and buttons that look like links, are underlined.
hovering removes the underline.
*/
a, .admin-action-btn {
    color: inherit;
    text-decoration-line: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 1px;
}

a:hover, .admin-action-btn:hover {
    text-decoration-line: none;
}

a:focus-visible, button:focus-visible {
    background-color: var(--color-text);
    color: var(--color-bg);
    outline: none;
}

ul {
    padding-inline-start: var(--space-md);
}

blockquote {
    border-inline-start: 1px solid currentColor;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding-inline-start: var(--space-md);
}

code {
    font-family: var(--font-mono);
}

pre {
    border: 1px solid currentColor;
    overflow-x: auto;
    padding: var(--space-sm);
}

/* --- layout --- */

.stack {
    display: flex;
    flex-direction: column;
}

.row {
    display: flex;
    gap: var(--space-sm);
}

.blog {
    flex-grow: 1;
    padding-block: var(--space-lg);
    padding-inline: var(--space-md);
    max-width: calc(var(--container-width) + var(--space-md) * 2);
    margin-inline: auto;
    width: 100%;
}

.blog > main {
    flex-grow: 1;
}

.gap-lg {
    gap: var(--space-lg);
}

.gap-md {
    gap: var(--space-md);
}

/* --- components --- */

/* one line tall even when empty, so every page starts at the same height */
.admin-bar {
    min-height: calc(var(--line-height-body) * 1rem);
}

.admin-action-btn {
    width: fit-content;
}

/* a "yes" button and a "no" link, side by side */
.confirm {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.login-form {
    max-width: 24rem;
}

.login-form input {
    border-bottom: 2px solid currentColor;
    padding-block: var(--space-sm);
}

.login-form input:focus-visible {
    border-bottom-width: 3px;
    outline: none;
}

.post-form textarea {
    resize: vertical;
    width: 100%;
}

/*
grow textareas to fit their text. browsers that can't do this
scroll the textarea instead, and let you drag it taller.
*/
@supports (field-sizing: content) {
    .post-form textarea {
        field-sizing: content;
        overflow-y: hidden;
        resize: none;
    }
}

.post-form textarea::placeholder {
    color: inherit;
    opacity: 0.5;
}

.post-form textarea:focus-visible {
    outline: none;
}

.post-form-title {
    font-size: var(--font-size-lg);
    font-weight: bold;
    line-height: var(--line-height-heading);
    text-wrap: balance;
}

.post-form-hint {
    opacity: 0.5;
}

.post-form-body {
    min-height: var(--post-min-height);
}

.post-form-date input {
    border-bottom: 1px solid currentColor;
}

/* on the home page, a post's date links to the post */
.permalink {
    width: fit-content;
}

/*
on the home page, a post's title runs into the start of its
summary, in bold, like a heading in an old book, and "Read more"
follows its end. the summary is always a single paragraph.
*/
.excerpt h2,
.excerpt p {
    display: inline;
}

.excerpt h2 {
    font-size: inherit;
    line-height: inherit;
}

.post-dates {
    font-style: italic;
}

.post-nav {
    display: flex;
}

/* keep "Newer" on the right, even on the oldest post, where it's alone */
.post-nav .newer {
    margin-inline-start: auto;
}

/* --- utilities --- */

.active {
    cursor: default;
}
