/*
 * Weeklies: shared base styles, loaded by every page.
 *
 * Paper, thin rules, a serif for dates and headings, the system face for the rest: the app's
 * own look. The tokens mirror the app's asset catalog (ios/Weeklies/Assets.xcassets: Paper,
 * Card, Ink, SecondaryInk, Rule, AccentColor, AccentSoft, Today, MarkdownMark), which holds
 * the "Kraft" scheme since 2026-10-02 (AccentSoft, MarkdownMark and the Increase Contrast
 * variants are the app's own, not Kraft's). When the owner swaps the app's scheme, swap these
 * values to match. Text pairs pass WCAG AA (the app's PaletteContrastTests).
 *
 * Page-specific rules live next door: home.css (home pages only), prose.css (support,
 * privacy, impressum).
 */

/* =========================================================================
   Tokens
   ========================================================================= */

:root {
    color-scheme: light dark;

    --paper: #FBF7EE;
    --card: #FFFDF8;
    --ink: #1F1D1A;
    --ink-2: #6B6355;          /* SecondaryInk */
    --rule: #DDD5C4;
    --accent: #8A5A2B;         /* AccentColor: chestnut */
    --accent-soft: #F1E6D6;
    --today: #B4561F;
    --mark: #8C8473;           /* MarkdownMark: dimmed on purpose (3:1) */
    --desk: #EFE8DA;           /* the ground the pages lie on */
    --shadow: 0 1px 2px rgb(31 29 26 / 0.08), 0 18px 40px -18px rgb(31 29 26 / 0.35);

    --serif: ui-serif, "New York", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
    --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --measure: 36rem;
    --gutter: clamp(16px, 4vw, 48px);
    --page-width: 70rem;
}

@media (prefers-color-scheme: dark) {
    :root {
        --paper: #1C1A16;      /* night paper */
        --card: #25221D;
        --ink: #EDE7DB;
        --ink-2: #AAA293;
        --rule: #3B362D;
        --accent: #DCAA72;
        --accent-soft: #3A2E21;
        --today: #EC9A62;
        --mark: #7E786C;
        --desk: #12110E;       /* darker than night paper, as the light desk is darker than paper */
        --shadow: 0 0 0 1px rgb(237 231 219 / 0.06), 0 18px 40px -18px rgb(0 0 0 / 0.7);
    }
}

@media (prefers-contrast: more) {
    :root { --ink-2: #5C574E; --rule: #948C7C; --mark: #6D675D; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
    :root { --ink-2: #C4BDB0; --rule: #756E62; --mark: #A29B8D; }
}

/* =========================================================================
   Base
   ========================================================================= */

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

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

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font: 1.0625rem/1.6 var(--sans);
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 600;
    line-height: 1.15;
    text-wrap: balance;
    margin: 0 0 0.5em;
}
h1 { font-size: clamp(2.5rem, 7vw, 4.5rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.6rem, 3.4vw, 2.25rem); letter-spacing: -0.01em; }
h3 { font-size: 1.25rem; }

p { margin: 0 0 1em; max-width: var(--measure); }

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

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 2px; }

kbd {
    display: inline-block; min-width: 1.9em; text-align: center;
    padding: 0.1em 0.45em; margin-inline-end: 0.15em;
    background: var(--card); color: var(--ink);
    border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 5px;
    font: 0.9em/1.4 var(--sans);
}

.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; inset-inline-start: 1rem; top: -4rem; z-index: 10;
    background: var(--accent); color: var(--card); padding: 0.5rem 1rem; font-weight: 600;
}
.skip-link:focus { top: 1rem; }

.wrap { max-width: var(--page-width); margin-inline: auto; padding-inline: var(--gutter); }

/* =========================================================================
   Header: the wordmark and the navigation, above one ruled line
   ========================================================================= */

.site-header .wrap {
    display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
    gap: 0.5rem 1.5rem;
    padding-block: 1.25rem 0.9rem;
    border-bottom: 1px solid var(--rule);
}

/* The app icon and the serif name. The icon stays inline, so the header keeps aligning the
   navigation on the name's baseline. */
.wordmark {
    font-family: var(--serif); font-size: 1.6rem; font-weight: 600; letter-spacing: -0.01em;
    color: var(--ink); text-decoration: none; white-space: nowrap;
}
.wordmark img { width: 1.25em; height: 1.25em; vertical-align: -0.28em; margin-inline-end: 0.35em; }

.site-nav ul { display: flex; flex-wrap: wrap; gap: 0.25rem 1.25rem; list-style: none; margin: 0; padding: 0; }
.site-nav a { color: var(--ink); text-decoration: none; padding-block: 0.25rem; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--accent); text-decoration: underline; }
.site-nav .lang { color: var(--ink-2); }

/* =========================================================================
   Footer
   ========================================================================= */

.site-footer { margin-top: clamp(3rem, 8vw, 6rem); color: var(--ink-2); font-size: 0.92rem; }
.site-footer .wrap { padding-block: 1.5rem 2.5rem; border-top: 1px solid var(--rule); }
.site-footer ul { display: flex; flex-wrap: wrap; gap: 0.5rem 1.5rem; list-style: none; margin: 0 0 0.75rem; padding: 0; }
.site-footer a { color: var(--ink); }
.site-footer p { margin: 0; max-width: none; }
