@font-face {
    font-family: "OpenDyslexic";
    src: local("OpenDyslexic"),
         url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic/files/opendyslexic-latin-400-normal.woff2") format("woff2");
    font-weight: normal;
}

@font-face {
    font-family: "OpenDyslexic";
    src: local("OpenDyslexic Bold"),
         url("https://cdn.jsdelivr.net/npm/@fontsource/opendyslexic/files/opendyslexic-latin-700-normal.woff2") format("woff2");
    font-weight: bold;
}

/* Design tokens. Every color, spacing value and font size used below comes from here. */
:root {
    /* Black text on the orange background is about 9.8:1, so it is used for text and links alike. */
    --color-bg: #FF9933;
    --color-text: #000000;

    --font-body: "OpenDyslexic", sans-serif;
    --weight-regular: 400;
    --weight-bold: 700;

    --text-2xs: 0.625rem;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 2rem;
    --text-4xl: 3rem;

    --line-heading: 1.2;
    --line-body: 1.6;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;
    --space-16: 4rem;

    --border-width: 2px;

    /* OpenDyslexic has wide glyphs, so a 45rem column keeps long text at a readable line length. */
    --width-content: 45rem;
}

/* Base layout */
html,
body {
    height: 100%;
    margin: 0;
}

body {
    background-color: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-body);
    font-weight: var(--weight-regular);
    line-height: var(--line-body);
    display: flex;
    flex-direction: column;
    text-align: center;
}

main {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

h1 {
    font-size: var(--text-4xl);
    font-weight: var(--weight-bold);
    line-height: var(--line-heading);
    text-decoration: underline;
    margin: 0 0 var(--space-4);
}

p {
    font-size: var(--text-base);
    margin: 0;
}

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

a:hover {
    text-decoration-thickness: var(--border-width);
}

a:focus-visible {
    outline: var(--border-width) solid var(--color-text);
    outline-offset: var(--space-1);
}

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

footer {
    font-size: var(--text-xs);
    font-style: italic;
    padding: var(--space-4);
}

/* Small corner links on the home page. Absolute so they do not push the centered content off center. */
.corner-nav {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-2xs);
}

/* Legal page: long-form text, so it is left aligned in a single narrow column */
.legal {
    justify-content: flex-start;
    align-items: stretch;
    box-sizing: border-box;
    width: 100%;
    max-width: var(--width-content);
    margin: 0 auto;
    padding: var(--space-8) var(--space-4);
    text-align: left;
    /* Lets long words and URLs wrap instead of overflowing at 320px wide. */
    overflow-wrap: anywhere;
}

.legal h2 {
    font-size: var(--text-3xl);
    line-height: var(--line-heading);
    margin: 0 0 var(--space-2);
}

.legal h3 {
    font-size: var(--text-xl);
    line-height: var(--line-heading);
    margin: var(--space-8) 0 var(--space-2);
}

.legal h4 {
    font-size: var(--text-lg);
    line-height: var(--line-heading);
    margin: var(--space-6) 0 var(--space-2);
}

.legal p,
.legal ul,
.legal ol {
    margin: 0 0 var(--space-4);
}

.legal ul,
.legal ol {
    padding-left: var(--space-6);
}

.legal li + li {
    margin-top: var(--space-2);
}

.legal code {
    font-size: var(--text-sm);
}

.legal-toc {
    margin-top: var(--space-8);
}

.legal-toc h2 {
    font-size: var(--text-2xl);
}

.legal .legal-toc ul {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-6);
    padding-left: 0;
    list-style: none;
}

.legal .legal-toc li + li {
    margin-top: 0;
}

/*
 * One document at a time without JavaScript: only the section matching the URL hash
 * (or containing the hashed element, such as #privacy-age) is shown, and plain /legal
 * shows the Terms. Browsers without :has() fall back to showing both sections.
 */
@supports selector(:has(*)) {
    .legal-section:not(:target):not(:has(:target)) {
        display: none;
    }

    /* The browser scrolls to the hashed section; a full-viewport margin clamps that to the page top so the header and contents stay in view. */
    .legal-section {
        scroll-margin-top: 100vh;
    }

    .legal:not(:has(.legal-section:target, .legal-section :target)) #tos {
        display: block;
    }

    .legal:not(:has(#privacy:target, #privacy :target)) .legal-toc a[href="#tos"],
    .legal:has(#privacy:target, #privacy :target) .legal-toc a[href="#privacy"] {
        font-weight: var(--weight-bold);
    }
}

.legal-section {
    margin-top: var(--space-12);
    padding-top: var(--space-8);
    border-top: var(--border-width) solid var(--color-text);
}

.legal-updated {
    font-style: italic;
}
