/* ==========================================================================
   Base — reset and element defaults
   Depends on tokens.css.
   ========================================================================== */

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

html {
    /* Prevent iOS Safari from inflating text in landscape. */
    -webkit-text-size-adjust: 100%;
    /* Reserve the scrollbar track so pages do not shift horizontally when
       content grows past the viewport. */
    scrollbar-gutter: stable;
}

body {
    margin: 0;
    background-color: var(--color-bg-primary);
    color: var(--color-text-primary);
    font-family: var(--font-body);
    font-size: var(--font-size-base);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-base);
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-synthesis: none;
    overflow-wrap: break-word;
    /* Nothing may cause sideways scrolling (DESIGN.md 34). */
    overflow-x: hidden;
}

/* --------------------------------------------------------------------------
   Typography defaults
   -------------------------------------------------------------------------- */

/* Cormorant Garamond is a high-contrast serif with a small x-height: it wants
   to be set large, light and tight. Below ~1.25rem it stops reading as display
   type, so h4-h6 hand back to Inter. */
h1,
h2,
h3 {
    margin: 0;
    font-family: var(--font-display);
    font-weight: var(--font-weight-regular);
    line-height: var(--line-height-tight);
    letter-spacing: var(--letter-spacing-tight);
    text-wrap: balance;
}

h4,
h5,
h6 {
    margin: 0;
    font-family: var(--font-body);
    font-weight: var(--font-weight-semibold);
    line-height: var(--line-height-snug);
    letter-spacing: var(--letter-spacing-snug);
    text-wrap: balance;
}

h1 {
    font-size: var(--font-size-4xl);
    line-height: var(--line-height-display);
    letter-spacing: var(--letter-spacing-display);
}

h2 {
    font-size: var(--font-size-3xl);
}

h3 {
    font-size: var(--font-size-2xl);
    line-height: var(--line-height-snug);
}

h4 {
    font-size: var(--font-size-lg);
}

h5,
h6 {
    font-size: var(--font-size-base);
}

p {
    margin: 0;
    text-wrap: pretty;
}

small {
    font-size: var(--font-size-sm);
}

strong,
b {
    font-weight: var(--font-weight-semibold);
}

ul,
ol {
    margin: 0;
    padding: 0;
}

/* Lists used for layout carry no semantic bullet; content lists opt back in. */
:where(ul, ol):not([class]) {
    padding-inline-start: var(--space-5);
}

figure,
blockquote,
dl,
dd {
    margin: 0;
}

address {
    font-style: normal;
}

code,
kbd,
pre,
samp {
    font-family: var(--font-mono);
    font-size: 0.9em;
}

/* --------------------------------------------------------------------------
   Links
   -------------------------------------------------------------------------- */

a {
    color: inherit;
    text-decoration-color: var(--color-border-strong);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.2em;
    transition: color var(--transition-fast),
        text-decoration-color var(--transition-fast);
}

a:hover {
    /* The darker accent, not the brand fill: at body size the fill only
       reaches 4.4:1 on the page ground. */
    color: var(--color-accent-text);
    text-decoration-color: currentColor;
}

/* --------------------------------------------------------------------------
   Media
   Images always declare width/height or an aspect-ratio at the component level
   so they reserve space before loading (DESIGN.md 30).
   -------------------------------------------------------------------------- */

img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}

img,
video {
    height: auto;
}

svg {
    fill: currentColor;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

input,
button,
textarea,
select {
    margin: 0;
    font: inherit;
    color: inherit;
    letter-spacing: inherit;
}

button {
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

textarea {
    resize: vertical;
}

:disabled {
    cursor: not-allowed;
}

/* Touch targets stay comfortable on phones (DESIGN.md 34, 37). */
button,
[role="button"],
input[type="submit"],
input[type="button"] {
    min-height: 44px;
    touch-action: manipulation;
}

/* --------------------------------------------------------------------------
   Focus
   Keyboard focus is always visible; pointer focus is not decorated.
   -------------------------------------------------------------------------- */

:focus-visible {
    outline: var(--focus-ring-width) solid var(--focus-ring-color);
    outline-offset: var(--focus-ring-offset);
    border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
    outline: none;
}

/* --------------------------------------------------------------------------
   Misc
   -------------------------------------------------------------------------- */

::selection {
    background-color: var(--color-accent-subtle);
    color: var(--color-text-primary);
}

hr {
    border: 0;
    border-top: var(--border-subtle);
    margin: 0;
}

[hidden] {
    display: none !important;
}

/* --------------------------------------------------------------------------
   Reduced motion
   The only sanctioned use of !important in the project: it must override every
   component and library animation, including inline styles set by Motion.
   Durations are near-zero rather than zero so animation end events still fire
   and JavaScript that waits on them does not stall.
   -------------------------------------------------------------------------- */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}
