/* ═══════════════════════════════════════════════════════════════════════════════
   utilities.css — layout primitives and a11y helpers.
   ═══════════════════════════════════════════════════════════════════════════════ */

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

.container-narrow {
  width: 100%;
  max-width: 760px;
  margin-inline: auto;
  padding-inline: var(--gutter);
}

/* Vertical rhythm without margin collapsing surprises. */
.stack { display: flex; flex-direction: column; }
.stack-1 { gap: var(--s1); }
.stack-2 { gap: var(--s2); }
.stack-3 { gap: var(--s3); }
.stack-4 { gap: var(--s4); }
.stack-5 { gap: var(--s5); }
.stack-6 { gap: var(--s6); }

.row {
  display: flex;
  align-items: center;
  gap: var(--s2);
  flex-wrap: wrap;
}

.center { text-align: center; }
.center-x { margin-inline: auto; }
.row-center { justify-content: center; }

/* ── Spacing helpers ──────────────────────────────────────────────────────────
   These exist because the CSP is style-src 'self' with no 'unsafe-inline', which
   strips inline style attributes. Every one-off nudge needs a class. */
.mt-1 { margin-block-start: var(--s1); }
.mt-2 { margin-block-start: var(--s2); }
.mt-3 { margin-block-start: var(--s3); }
.mt-4 { margin-block-start: var(--s4); }
.mt-5 { margin-block-start: var(--s5); }
.mb-1 { margin-block-end: var(--s1); }
.mb-3 { margin-block-end: var(--s3); }
.mb-5 { margin-block-end: var(--s5); }
.block { display: block; }

/* An element standing in for something not yet configured — e.g. the App Store
   badge before the numeric app id is filled in. */
.is-pending { opacity: .5; }

/* Reduced-emphasis text that sits ON an accent panel, where --text-faint-strong
   (tuned for --bg) would be wrong. */
.on-accent-dim { opacity: .74; }
.on-accent-faint { opacity: .68; }

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

/* Any element whose glyph points somewhere — chevrons, arrows, a reply corner.
   Everything else mirrors for free via logical properties. */
.icon-dir { display: inline-block; }
[dir="rtl"] .icon-dir { transform: scaleX(-1); }

/* Latin handles, numbers, times, and the word "wisp" inside Arabic sentences.
   Without isolation the @ or + lands on the wrong side of the token. */
bdi, .ltr {
  unicode-bidi: isolate;
}
.ltr { direction: ltr; }

/* Wide content must scroll inside its own box rather than the page. */
.scroll-x {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}

/* ── Reveal on scroll ─────────────────────────────────────────────────────────
   site.js adds .is-in via IntersectionObserver. The pre-state is applied only
   when JS is present (html.js), so with JS off everything is simply visible. */
.js .reveal {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity var(--t-slow) var(--e-glide),
    transform var(--t-slow) var(--e-glide);
}
.js .reveal.is-in {
  opacity: 1;
  transform: none;
}

@media (prefers-reduced-motion: reduce) {
  .js .reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
