/* ==========================================================================
   WinMarket AI — الأساس: تهيئة، طباعة عربية، أدوات مساعدة
   ========================================================================== */

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

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

body.wmai {
  margin: 0;
  background: var(--wmai-ink);
  color: var(--wmai-text);
  font-family: var(--wmai-font-body);
  font-size: var(--wmai-fs-body);
  line-height: var(--wmai-lh-body);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
}

/* نسيج خفيف جدًا خلف الواجهة — لا تدرّجات صاخبة */
body.wmai::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -8%, rgba(139, 92, 246, 0.09), transparent 60%),
    radial-gradient(700px 400px at 8% 4%, rgba(0, 214, 143, 0.045), transparent 60%);
}

img,
svg,
video {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4,
h5 {
  margin: 0;
  font-family: var(--wmai-font-display);
  line-height: var(--wmai-lh-tight);
  text-wrap: balance;
}

h1 { font-size: var(--wmai-fs-h1); font-weight: 900; }
h2 { font-size: var(--wmai-fs-h2); font-weight: 800; }
h3 { font-size: var(--wmai-fs-h3); font-weight: 700; }
h4 { font-size: var(--wmai-fs-h4); font-weight: 700; }

p {
  margin: 0;
  max-width: 68ch;
}

a {
  color: var(--wmai-brand-2);
  text-underline-offset: 3px;
}

a:hover {
  color: var(--wmai-brand);
}

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

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

/* التركيز مرئي دائمًا — شرط وصول لا تفاوض فيه */
:focus-visible {
  outline: 2px solid var(--wmai-brand-2);
  outline-offset: 3px;
  border-radius: var(--wmai-r-xs);
}

::selection {
  background: var(--wmai-brand);
  color: #fff;
}

/* ---- الأرقام: غربية، أحادية المسافة، متراصّة عموديًا ---- */
.wmai-num {
  font-family: var(--wmai-font-data);
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}

/* ---- تسمية لاتينية صغيرة. التباعد للاتينية فقط، فالعربية تنكسر حروفها ---- */
.wmai-label {
  font-family: var(--wmai-font-data);
  font-size: var(--wmai-fs-micro);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  direction: ltr;
  color: var(--wmai-muted);
}

.wmai-hint {
  font-size: var(--wmai-fs-xs);
  color: var(--wmai-muted);
}

.wmai-hint--ok { color: var(--wmai-rise); }
.wmai-hint--error { color: var(--wmai-fall); }

/* ---- أدوات تخطيط صغيرة ---- */
.wmai-stack { display: flex; flex-direction: column; gap: var(--wmai-s3); }
.wmai-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--wmai-s3); }
.wmai-row--between { justify-content: space-between; }
.wmai-grid { display: grid; gap: var(--wmai-s4); }
.wmai-grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.wmai-grid--3 { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.wmai-grid--4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.wmai-divider { height: 1px; background: var(--wmai-line-soft); border: 0; margin: var(--wmai-s4) 0; }
.wmai-mt-auto { margin-top: auto; }

/* المحتوى العريض يمرّر داخل نفسه، لا الصفحة كلها */
.wmai-scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.wmai-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;
}

/* رابط التخطّي: يُخفى بالقصّ لا بالإزاحة.
   الإزاحة بـ -9999px تُنشئ تجاوزًا أفقيًا في RTL لأنها تدفع العنصر خارج الحافة اليمنى. */
.wmai-skip {
  position: absolute;
  top: 0;
  inset-inline-start: var(--wmai-s4);
  z-index: 200;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  clip-path: inset(50%);
  white-space: nowrap;
  background: var(--wmai-brand);
  color: #fff;
  border-radius: 0 0 var(--wmai-r-sm) var(--wmai-r-sm);
}

.wmai-skip:focus {
  width: auto;
  height: auto;
  padding: 10px 18px;
  overflow: visible;
  clip: auto;
  clip-path: none;
  color: #fff;
}

/* ---- من يفضّل تقليل الحركة، لا يرى حركة ---- */
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }

  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
