/* ==========================================================================
   base.css — the foundation: reset, page, typography, accessibility helpers.
   Loaded AFTER legacy.css, so anything here wins over the old rules.
   ========================================================================== */

*, *::before, *::after { box-sizing: border-box; }

/* Elements with the [hidden] attribute must really disappear, even when a
   class gives them display:flex. */
[hidden] { display: none !important; }

html {
    scroll-behavior: smooth;
    scroll-padding-top: 96px;          /* anchor links stop below the sticky header */
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--fs-base);
    font-weight: 400;
    line-height: var(--lh-body);
    color: var(--ink);
    background-color: var(--paper);
    /* The grain texture at 20% strength, with no extra layer. A paper-coloured
       veil at 80% over the image gives exactly the same look as the old
       "opacity: 0.2" layer, but it is just a background. */
    background-image:
        linear-gradient(rgba(246, 242, 234, 0.8), rgba(246, 242, 234, 0.8)),
        url("../images/bg-texture.e329a9ad5ad2.jpg");
    background-size: auto, 400px;
    font-synthesis: none;              /* never fake bold/italic: use real weights */
}

/* The old wildcard forced a font onto form controls. Without it browsers fall
   back to their own font, so tell them to inherit ours. */
input, button, select, textarea {
    font-family: inherit;
    letter-spacing: inherit;
}

h1, h2, h3, h4 {
    font-family: var(--font-display);
    font-weight: 700;
    line-height: var(--lh-heading);
    text-wrap: balance;                /* avoids one lonely word on the last line */
}

p { text-wrap: pretty; }

/* IMPORTANT for Persian: never add letter-spacing to Persian text. It breaks
   the joins between letters. Headings stay at 0. */
.display-heading {
    font-family: var(--font-display);
    font-weight: 800;
    line-height: var(--lh-display);
    letter-spacing: 0;
}

.container {
    max-width: var(--container);
    padding-inline: var(--page-margin);
}

::selection { background: var(--teal-100); color: var(--ink); }

/* Keyboard focus ring: only for keyboard users (:focus-visible), in the
   AA-contrast turquoise. */
:focus-visible {
    outline: 2px solid var(--teal-700);
    outline-offset: 3px;
}

/* Hidden visually, still read by screen readers. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* Safety net: people who ask their device for less motion get (almost) none,
   from every animation and transition on the site, old or new. */
@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;
    }
}