/*
 * Shared by every generated page: design tokens, base typography, buttons,
 * the site header with the light/dark toggle, and the site footer.
 */

/*
 * Dark is the default theme. The inline script in partials/head.hbs sets html[data-theme]
 * before the first paint, from the saved choice of the theme toggle or the system setting.
 */
:root {
    color-scheme: dark;

    /* Warm neutrals. The brand blue is the only accent and marks what you can interact with. */
    --color-bg: #121110;
    --color-surface: #1b1a18;
    --color-rule: #2e2c29;
    --color-ink: #f0eee9;
    --color-text: #d3d0c9;
    --color-muted: #9d9990;
    --color-accent: #42b7f3;
    --color-on-accent: #0b1620;

    --font-sans: "Schibsted Grotesk", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;

    --radius: 4px;
    --page-width: 72rem;
    --page-gutter: clamp(1rem, 4vw, 2.5rem);
    --header-height: 4rem;

    /* Every page uses the same two columns: a narrow rail and the text column next to it. */
    --rail-width: 18rem;
    --rail-gap: clamp(3rem, 6vw, 6rem);

    --layer-sticky: 10;
    --layer-menu: 20;
}

:root[data-theme="light"] {
    color-scheme: light;

    --color-bg: #f4f3ef;
    --color-surface: #eae8e2;
    --color-rule: #d8d5cd;
    --color-ink: #151413;
    --color-text: #33312d;
    --color-muted: #69655e;
    --color-accent: #0a6ea8;
    --color-on-accent: #ffffff;
}

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

/* Keeps [hidden] working on elements that set their own display value. */
[hidden] {
    display: none !important;
}

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

@media (prefers-reduced-motion: no-preference) {
    html {
        scroll-behavior: smooth;
    }
}

body {
    margin: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

img {
    max-width: 100%;
    height: auto;
}

a {
    color: inherit;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
}

a:hover {
    color: var(--color-accent);
}

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

pre {
    white-space: pre-wrap;
    line-break: anywhere;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Icons are inline SVGs from partials/icon.hbs and take the text colour. */
.icon {
    width: 1rem;
    height: 1rem;
    flex: none;
    fill: currentColor;
}

.button {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.5rem;
    padding: 0 0.875rem;
    border: 1px solid var(--color-rule);
    border-radius: var(--radius);
    background: none;
    color: var(--color-ink);
    font: 500 0.875rem/1 var(--font-sans);
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 150ms ease;
}

.button:hover {
    border-color: currentColor;
}

.button:active {
    transform: translateY(1px);
}

.icon-button {
    display: grid;
    place-items: center;
    flex: none;
    width: 2.75rem;
    height: 2.75rem;
    padding: 0;
    border: 0;
    background: none;
    color: var(--color-muted);
    cursor: pointer;
}

.icon-button:hover {
    color: var(--color-ink);
}

@media (pointer: coarse) {
    .button {
        min-height: 2.75rem;
    }
}

/* Site header */

.site-header {
    position: relative;
    z-index: var(--layer-menu);
    border-bottom: 1px solid var(--color-rule);
    background: var(--color-bg);
}

.site-header-inner {
    display: flex;
    align-items: center;
    gap: 1rem;
    max-width: var(--page-width);
    min-height: var(--header-height);
    margin: 0 auto;
    padding: 0 var(--page-gutter);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-right: auto;
    color: var(--color-ink);
    font: 700 1.125rem/1 var(--font-sans);
    letter-spacing: -0.01em;
    text-decoration: none;
}

.brand img {
    width: 2rem;
    height: 2rem;
}

.site-menu {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.site-links,
.social-links {
    display: flex;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
}

.site-links {
    gap: 1.5rem;
}

.site-links a {
    color: var(--color-text);
    font-size: 0.9375rem;
    font-weight: 500;
    text-decoration: none;
}

.site-links a:hover {
    color: var(--color-accent);
}

.site-links a[aria-current="page"] {
    color: var(--color-ink);
    text-decoration-line: underline;
    text-decoration-thickness: 2px;
    text-decoration-color: var(--color-accent);
    text-underline-offset: 0.45em;
}

.social-links {
    gap: 0.25rem;
}

.social-links a {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    color: var(--color-muted);
}

.social-links a:hover {
    color: var(--color-accent);
}

.site-menu-extras {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.theme-toggle {
    width: 2rem;
    height: 2rem;
}

.theme-toggle .icon {
    width: 1.125rem;
    height: 1.125rem;
}

.menu-toggle {
    display: none;
}

/* Small screens: the header stays on top while scrolling, the menu folds into a panel. */
@media (max-width: 59.99rem) {
    .site-header {
        position: sticky;
        top: 0;
    }
}

@media (max-width: 47.99rem) {
    .site-header-inner {
        gap: 0.25rem;
    }

    .menu-toggle {
        display: grid;
        margin-right: -0.75rem;
        color: var(--color-ink);
    }

    .menu-toggle .icon {
        width: 1.25rem;
        height: 1.25rem;
    }

    .menu-toggle[aria-expanded="true"] .icon-menu,
    .menu-toggle[aria-expanded="false"] .icon-close {
        display: none;
    }

    .site-menu {
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        display: none;
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
        padding: 0.5rem var(--page-gutter) 1.5rem;
        border-bottom: 1px solid var(--color-rule);
        background: var(--color-bg);
    }

    .site-menu.is-open {
        display: flex;
    }

    .site-links {
        flex-direction: column;
        align-items: stretch;
        gap: 0;
    }

    .site-links a {
        display: block;
        padding: 0.625rem 0;
        color: var(--color-ink);
        font-size: 1.5rem;
        font-weight: 600;
        line-height: 1.2;
        letter-spacing: -0.01em;
    }

    .site-menu-extras {
        margin-left: -0.75rem;
    }

    .social-links a,
    .theme-toggle {
        width: 2.75rem;
        height: 2.75rem;
    }
}

/* Site footer */

.site-footer {
    border-top: 1px solid var(--color-rule);
    color: var(--color-muted);
    font-size: 0.8125rem;
}

.site-footer-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem 2rem;
    max-width: var(--page-width);
    margin: 0 auto;
    padding: 1.75rem var(--page-gutter) 2.25rem;
}

.site-footer p {
    margin: 0;
}

.site-footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.5rem;
    margin: 0 auto 0 0;
    padding: 0;
    list-style: none;
}

.site-footer-links a {
    color: var(--color-text);
}

.site-footer-links a:hover {
    color: var(--color-accent);
}

.product-hunt img {
    display: block;
    width: 150px;
}
