/* ==========================================================================
   Base — reset, document defaults, shared primitives
   Mobile-first. Everything here applies at 360px and is widened by min-width
   queries further on.
   ========================================================================== */

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

* {
    margin: 0;
    padding: 0;
}

/* The [hidden] attribute (portal.js toggles it on the redundant search-submit
   button, say) has the same low specificity as an author rule like .button's
   own `display: inline-flex` — without !important, whichever rule is later in
   the cascade wins and an element can end up "hidden" but still visible. */
[hidden] {
    display: none !important;
}

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

body {
    background: var(--color-canvas);
    color: var(--color-text);
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

h1, h2, h3, h4 {
    color: var(--color-ink);
    font-family: var(--font-display);
    font-weight: var(--weight-regular);
    line-height: var(--leading-snug);
}

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

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

/* Body links stay underlined: colour alone is not a distinguishing mark.
   Navigation, buttons and cards opt out through their own components; a button
   in a paragraph is left out here, on every page (:where keeps the selector's
   weight as it was, so components still override it). */
.site-main p a:where(:not(.button)) {
    text-decoration: underline;
    text-underline-offset: 0.15em;
}

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

ul {
    list-style: none;
}

button,
input,
select,
textarea {
    font: inherit;
    color: inherit;
}

/* --- Focus ------------------------------------------------------------- */

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

/* --- Skip link ---------------------------------------------------------- */

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: var(--space-4);
    z-index: 100;
    padding: var(--space-3) var(--space-5);
    background: var(--color-surface-dark);
    color: var(--color-ink-inverse);
    border-radius: var(--radius-pill);
    font-weight: var(--weight-semibold);
    transform: translateY(-200%);
    transition: transform var(--transition-fast);
}

.skip-link:focus {
    color: var(--color-ink-inverse);
    transform: translateY(0);
}

/* Read by screen readers, not shown. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

/* --- Layout primitives -------------------------------------------------- */

.shell {
    width: 100%;
    max-width: var(--shell-max);
    margin-inline: auto;
    padding-inline: var(--shell-gutter);
}

.site-main {
    display: block;
}

/* --- Shared text primitives --------------------------------------------- */

.arrow {
    display: inline-block;
    transition: transform var(--transition-fast);
}

.link-arrow {
    color: var(--color-accent-text);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    white-space: nowrap;
}

.link-arrow:hover .arrow,
a:hover > .arrow {
    transform: translateX(3px);
}

/* --- Motion ------------------------------------------------------------- */

@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(28px);
    }

    to {
        opacity: 1;
        transform: none;
    }
}

@keyframes glowpulse {
    0%, 100% {
        opacity: 0.34;
        transform: scale(1);
    }

    50% {
        opacity: 0.58;
        transform: scale(1.12);
    }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
