/* A quiet, paper-like reading page: the justified text is the design. */

:root {
    --paper: #faf7f2;
    --ink: #211d16;
    --ink-soft: #6d6558;
    --accent: #8c2f1b;
    --rule: #e2dbcf;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #171410;
        --ink: #ddd5c7;
        --ink-soft: #938a7a;
        --accent: #d07a5e;
        --rule: #2e2a23;
    }
}

* {
    margin: 0;
    box-sizing: border-box;
}

body {
    background: var(--paper);
    color: var(--ink);
    font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    font-size: clamp(1.0625rem, 0.95rem + 0.5vw, 1.1875rem);
    line-height: 1.65;
}

main {
    max-width: 38rem;
    margin: 0 auto;
    padding: clamp(3rem, 8vh, 6rem) 1.5rem 4rem;
}

header {
    margin-bottom: 3rem;
    text-align: center;
}

h1 {
    font-size: 2.4rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.subtitle {
    margin-top: 0.75rem;
    color: var(--ink-soft);
    font-size: 0.95em;
    font-style: italic;
}

/* The comparison switch: justif's layout vs. the browser's. */
.switch {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    font-size: 0.8rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-soft);
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.switch .track {
    width: 2.1rem;
    height: 1.2rem;
    border-radius: 0.6rem;
    border: 1px solid var(--rule);
    background: transparent;
    position: relative;
    transition: background 0.15s ease;
}

.switch .track::after {
    content: "";
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 50%;
    background: var(--ink-soft);
    transition:
        transform 0.15s ease,
        background 0.15s ease;
}

.switch input:checked + .track {
    background: var(--accent);
    border-color: var(--accent);
}

.switch input:checked + .track::after {
    transform: translateX(0.9rem);
    background: var(--paper);
}

.switch input:focus-visible + .track {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

h2 {
    margin: 2.25rem 0 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

/* The point of the demo: candidates justify, justif takes them from there. */
article p,
blockquote p {
    text-align: justify;
}

/* Soften the cloak reveal: the plugin's data-justif-cloak attribute holds
 * paragraphs at opacity 0, and its removal fades the typeset text in. */
article p,
blockquote p {
    transition: opacity 0.25s ease;
}

html[data-justif-cloak] :is(article p, blockquote p) {
    opacity: 0;
}

article > p + p {
    margin-top: 1em;
}

blockquote {
    margin: 2.5rem 0 0;
    padding: 0 1.25rem;
    border-inline-start: 2px solid var(--rule);
    font-style: italic;
}

blockquote footer {
    margin-top: 0.5em;
    font-style: normal;
    font-size: 0.85em;
    color: var(--ink-soft);
    text-align: right;
}

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 2px;
}

code {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 0.85em;
}

.colophon {
    margin-top: 3.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--rule);
    font-size: 0.8em;
    color: var(--ink-soft);
}
