/* =========================================================================
   Base · Reset, Typography, Utilities, Animations
   ========================================================================= */

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-en);
  font-size: var(--fs-body-md);
  line-height: var(--lh-normal);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

html[lang="ar"], html[lang="ar"] body {
  font-family: var(--font-ar);
  line-height: var(--lh-arabic);
}

a {
  color: var(--text-link);
  text-decoration: none;
}
a:hover { text-decoration: underline; }

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: pointer;
  padding: 0;
}
button:disabled { cursor: not-allowed; opacity: 0.55; }

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

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
h1 { font-size: var(--fs-headline-lg); line-height: var(--lh-tight); }
h2 { font-size: var(--fs-headline-md); line-height: var(--lh-snug); }
h3 { font-size: var(--fs-headline-sm); line-height: var(--lh-snug); }
p  { margin: 0; }

/* Material Symbols */
.icon, .material-symbols-rounded {
  font-family: var(--font-icon);
  font-weight: normal;
  font-style: normal;
  font-size: 20px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: "liga";
  -webkit-font-smoothing: antialiased;
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
  vertical-align: middle;
  user-select: none;
}
.icon--filled { font-variation-settings: "FILL" 1, "wght" 500, "GRAD" 0, "opsz" 24; }
.icon--sm { font-size: 18px; }
.icon--xs { font-size: 16px; }
.icon--lg { font-size: 24px; }

/* Scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track);
}
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--scrollbar-track); }
*::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

/* Boot splash */
.app-boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  background: var(--bg);
  z-index: 999;
}
.app-boot__logo {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--accent);
  color: var(--text-on-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--fw-bold);
  font-size: 22px;
  letter-spacing: -0.02em;
}
.app-boot__title {
  font-size: var(--fs-headline-sm);
  font-weight: var(--fw-semibold);
}
.app-boot__spinner {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Animations */
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes slide-up { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes slide-in-end { from { transform: translateX(16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slide-in-start { from { transform: translateX(-16px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.5; }
}
@keyframes ping {
  0%   { transform: scale(1);   opacity: 0.7; }
  75%, 100% { transform: scale(2); opacity: 0; }
}
@keyframes shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

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

/* Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.cluster { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.stack   { display: flex; flex-direction: column; gap: var(--space-3); }
.grow    { flex: 1; }
.spacer  { flex: 1; }

.text-muted     { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-strong    { color: var(--text-primary); font-weight: var(--fw-semibold); }
.text-mono      { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.text-overline  { font-size: var(--fs-label-sm); letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); font-weight: var(--fw-semibold); }

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