/* =============================================================
   Base — reset, typography, RTL/LTR, helpers
   ============================================================= */

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

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

body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background var(--t), color var(--t);
}

/* Latin text inside an RTL doc reads LTR naturally; keep direction logical */
[dir="ltr"] body { letter-spacing: -0.01em; }

h1, h2, h3, h4 { font-weight: 700; line-height: 1.25; color: var(--text); }
.display { font-family: var(--font-display); font-weight: 700; }
[dir="ltr"] .display { font-family: var(--font-latin-display); }

a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
/* default icon size scales with font-size; component rules override as needed */
svg { display: block; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; width: 1.1em; height: 1.1em; }
/* icon-span wrappers (hydrated via data-icon) */
[data-icon] { display: inline-flex; align-items: center; justify-content: center; }
[data-icon] svg { width: 18px; height: 18px; }
ul { list-style: none; }

/* ---- Scrollbars ---- */
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; border: 2px solid transparent; background-clip: content-box; }
*::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

::selection { background: var(--gold-tint-2); color: var(--text); }

/* ---- Focus ---- */
:focus-visible { outline: none; box-shadow: var(--sh-focus); border-radius: var(--r-xs); }

/* ---- Helpers ---- */
.hidden { display: none !important; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.flex { display: flex; }
.center { display: flex; align-items: center; justify-content: center; }
.items-center { align-items: center; }
.between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: 6px; } .gap-2 { gap: 10px; } .gap-3 { gap: 16px; } .gap-4 { gap: 24px; }
.grow { flex: 1; }
.wrap { flex-wrap: wrap; }
.col { display: flex; flex-direction: column; }
.text-end { text-align: end; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: var(--fs-sm); letter-spacing: -.01em; }

/* page intro */
.page-head { margin-bottom: 22px; }
.page-head h2 { font-size: var(--fs-2xl); font-family: var(--font-display); }
[dir="ltr"] .page-head h2 { font-family: var(--font-latin-display); }
.page-head p { color: var(--text-2); font-size: var(--fs-md); margin-top: 3px; }

/* directional flip for arrow-type glyphs in LTR */
[dir="ltr"] .flip-x { transform: scaleX(-1); }

/* animations */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideInEnd { from { opacity: 0; transform: translateX(calc(14px * var(--dir, 1))); } to { opacity: 1; transform: translateX(0); } }
@keyframes pop { 0% { transform: scale(.96); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }
@keyframes spin { to { transform: rotate(360deg); } }

.anim-fade { animation: fadeIn var(--t) both; }
.anim-up { animation: slideUp var(--t) both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
