/* Font */
@import url("https://fonts.googleapis.com/css2?family=Inter&display=swap");

/* Settings */
:root {
    --color-dark: #1a1a1a;
    --color-light: #fafafa;
    --color-primary: #1a8fe3;
    --size-step-0: clamp(1rem, calc(0.96rem + 0.22vw), 1.13rem);
    --size-step-1: clamp(1.25rem, calc(1.16rem + 0.43vw), 1.5rem);
    --size-step-2: clamp(1.56rem, calc(1.41rem + 0.76vw), 2rem);
    --size-step-3: clamp(1.95rem, calc(1.71rem + 1.24vw), 2.66rem);
    --size-step-4: clamp(2.44rem, calc(2.05rem + 1.93vw), 3.55rem);
    --spacing: 1.5rem;
    --font-stack:
        Inter, system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans",
        sans-serif, "Apple Color Emoji", "Segoe UI Emoji",
        "Segoe UI Symbol", "Noto Color Emoji";
}
@media (prefers-color-scheme: dark) {
    :root {
        --color-dark: #fafafa;
        --color-light: #1a1a1a;
    }
}
/* HTML Styles */
body {
    background: var(--color-light);
    color: var(--color-dark);
    padding: var(--spacing)
        clamp(
            calc(var(--spacing) / 2),
            5vw,
            calc(var(--spacing) * 3)
        );
    font-family: var(--font-stack);
    font-size: var(--size-step-1);
    line-height: 1.7;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
}
* {
    box-sizing: border-box;
}
header,
main,
footer {
    width: 100%;
}
header {
    padding-bottom: var(--spacing);
}
main {
    flex: 1;
    /* the last block already contributes its own trailing margin, so this
       padding only needs to top the total up to one full step */
    padding-bottom: var(--spacing);
}
a {
    color: currentColor;
    -webkit-text-decoration-color: var(--color-primary);
    text-decoration-color: var(--color-primary);
    text-decoration-thickness: 0.2ex;
    text-underline-offset: 0.3ex;
}
a:hover {
    text-decoration-thickness: 0.3ex;
}
img,
video {
    display: block;
    max-width: 100%;
    height: auto;
}
h1,
h2,
h3,
h4,
h5 {
    font-weight: 800;
    line-height: 1.3;
    text-wrap: balance;
}
h1 {
    font-size: var(--size-step-4);
}
h2 {
    font-size: var(--size-step-3);
}
h3 {
    font-size: var(--size-step-2);
}
h4 {
    font-size: var(--size-step-1);
}
h5 {
    font-size: var(--size-step-0);
}
ul,
ol {
    -webkit-padding-start: var(--spacing);
    padding-inline-start: var(--spacing);
}
li {
    --flow-space: 1em;
    margin-block-start: var(--flow-space, 1em);
}
/* Flow and rythm */
:is(h1, h2, h3, h4, h5) {
    --flow-space: calc(var(--spacing) * 2);
    margin-block: 0 calc(var(--spacing) / 2);
}
:is(h1, h2, h3, h4, h5) + * {
    --flow-space: calc(var(--spacing) / 3);
}
:is(h1, h2, h3, h4, h5) + :where(h2, h3, h4, h5) {
    --flow-space: calc(var(--spacing) * 2);
}

/* Line lengths */
main,
header,
footer {
    max-width: 65ch;
    margin-inline: auto;
}
h1 {
    max-width: 24ch;
}
h2,
h3 {
    max-width: 32ch;
}
/* Bear Content */
header h1 {
    font-size: var(--size-step-2);
}
.title {
    text-decoration: none;
}
nav p {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing);
    row-gap: 0;
}
/* Product sections: text beside media on wide screens */
.split {
    display: grid;
    gap: var(--spacing);
    margin-block-end: calc(var(--spacing) * 2);
}
/* Readable measure, kept in step with the section text columns on desktop */
.prose {
    max-width: 65ch;
}
.prose:not(:last-child) {
    margin-block-end: calc(var(--spacing) * 2);
}
/* The section jump list is a secondary element, so it gets extra room before
   the first section instead of the standard 48px break. The :not() is repeated
   to outrank the rule above. */
.prose:has(> nav):not(:last-child) {
    margin-block-end: calc(var(--spacing) * 3);
}
footer {
    padding: var(--spacing) 0;
}
footer p {
    margin-block: calc(var(--spacing) * 1.5);
}
footer > :first-child {
    margin-block-start: 0;
}
footer > :last-child {
    margin-block-end: 0;
}
@media screen and (min-width: 60em) {
    header,
    main,
    footer {
        max-width: 96ch;
    }
    header {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        justify-content: space-between;
        gap: var(--spacing);
    }
    .prose {
        max-width: 48ch;
    }
    /* Tools has no media column, so it takes the full page width and splits
       the list itself two-up instead of using the .split text/media pairing. */
    .tools {
        max-width: none;
    }
    .tools > p {
        max-width: 60ch;
    }
    .tools ul {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        column-gap: calc(var(--spacing) * 2);
        align-items: start;
    }
    .split {
        grid-template-columns: 1.15fr 0.85fr;
        column-gap: calc(var(--spacing) * 2);
        align-items: center;
    }
}
