/* ==========================================================================
   Base: reset, typography, links, focus and the utilities every page uses.
   Reads tokens.css; holds no colour, type size or pixel length of its own.
   ========================================================================== */

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-block-start: calc(var(--scroll-pad) + var(--acting-offset));
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--fs-lg);
  font-weight: var(--fw-regular);
  line-height: var(--lh-body);
  color: var(--text);
  background: var(--bg);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: var(--fw-bold);
  line-height: var(--lh-heading);
  text-wrap: balance;
}

p,
ul,
ol,
dl,
dd,
figure {
  margin: 0;
}

p,
dd,
li {
  text-wrap: pretty;
}

ul,
ol {
  padding: 0;
  list-style: none;
}

a {
  color: inherit;
  text-decoration: none;
}

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

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

button {
  cursor: pointer;
}

fieldset {
  min-inline-size: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

legend {
  padding: 0;
}

svg,
img {
  display: block;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: var(--line-focus) solid var(--focus);
  outline-offset: var(--line-focus);
}

::selection {
  background: var(--accent-line);
}

/* Utilities ---------------------------------------------------------------- */

.sr-only {
  position: absolute;
  inline-size: var(--line);
  block-size: var(--line);
  margin: calc(-1 * var(--line));
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  inset-block-start: calc(-1 * var(--sp-24));
  inset-inline-start: var(--sp-4);
  z-index: var(--z-skip);
  display: inline-flex;
  align-items: center;
  min-block-size: var(--tap);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-full);
  background: var(--paper);
  color: var(--on-paper);
  font-size: var(--fs-md);
}
.skip-link:focus {
  inset-block-start: var(--sp-3);
}

.container {
  inline-size: min(100% - 2 * var(--gutter), var(--container));
  margin-inline: auto;
}

/* Tabular figures, for a left-to-right Latin value only: a code, an id.
   Never on Persian digits: Vazirmatn's tabular set spaces out the zero. */
.num {
  font-variant-numeric: var(--num-data);
}

/* A Latin value inside Persian text: a phone number, a code, an address */
.ltr {
  display: inline-block;
  direction: ltr;
  unicode-bidi: isolate;
}

.muted {
  color: var(--text-muted);
}

/* The white gradient, by opacity, on a few words of a heading */
.accent-text {
  display: inline-block;
  padding-block: var(--descender-pad);
  background: var(--accent-text);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
}

/* A link inside running text or under a form */
.link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  border-radius: var(--r-xs);
  color: var(--accent);
  font-weight: var(--fw-bold);
  transition: color var(--dur) var(--ease);
}
.link:hover {
  color: var(--accent-hi);
}
/* A link on a line of its own in a list (a session under its speaker): a
   finger's height, and a long title wraps instead of being cut (F2-2) */
.link--line {
  display: flex;
  min-block-size: var(--tap);
  overflow-wrap: anywhere;
}
/* Inside a sentence, colour alone does not say «link»: it is underlined too */
:is(p, li, .note, .card__sub, .page-header__lead) .link {
  text-decoration: underline;
  text-decoration-color: var(--accent-line);
  text-underline-offset: var(--nudge-sm);
}
/* A name that leads to its page (a person, an organisation) looks like the
   name it is, in every list and header: the text's own colour and weight,
   underlined while pointed at or focused. Where a finger is used it is a
   full tap target (layout.css). */
.name-link {
  color: inherit;
  font-weight: inherit;
  text-decoration: none;
  transition: color var(--dur) var(--ease);
}
.name-link:hover,
.name-link:focus-visible {
  color: var(--text);
  text-decoration: underline;
  text-decoration-color: var(--hairline-strong);
  text-underline-offset: var(--nudge-sm);
}
.link .icon {
  transition: transform var(--dur) var(--ease);
}
.link:hover .icon {
  transform: translateX(calc(-1 * var(--sp-fine)));
}
/* the nudge goes toward the inline end, which is the right on a left-to-right page */
[dir="ltr"] .link:hover .icon {
  transform: translateX(var(--sp-fine));
}

/* Children one under another with the same gap */
.stack {
  display: grid;
  /* a track that may shrink below its content, so a long word or a wide
     child scrolls or wraps inside the stack instead of widening the page */
  grid-template-columns: minmax(0, 1fr);
  gap: var(--sp-4);
}

/* Two fields side by side on a wide screen, one under the other on a phone */
.split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--measure-sm)), 1fr));
  gap: var(--sp-4);
}

/* Children side by side, wrapping when they run out of room */
.cluster {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--sp-2);
}

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

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

/* An element an address names (a confirmation drawn on the page, ``?lead=1#lead-confirm``):
   scrolled to clear of the sticky header, and of the acting band when it shows */
:target {
  scroll-margin-block-start: calc(var(--scroll-pad) + var(--acting-offset));
}
