/* ============================================================
   FILE: 02-reset.css
   ROLE: Modern CSS Reset + Base Styles
   PROJECT: BarakatHub — پلتفرم رسانه‌ای چندزبانه
   VERSION: 1.0.0
   DEPENDS ON: 01-tokens.css (باید قبل از این فایل لود شود)
   ============================================================ */

/* ────────────────────────────────────────────────────────────
   1. BOX MODEL & RESET
   ──────────────────────────────────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;                     /* Base: 1rem = 16px */
  scroll-behavior: smooth;
  text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
  tab-size: 4;
}

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-ltr-body);   /* پیش‌فرض: LTR — با :lang() override می‌شود */
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition-base),
              color var(--transition-base);
}

/* ────────────────────────────────────────────────────────────
   2. MULTILINGUAL FONT ASSIGNMENTS
   هر lang attribute فونت مناسب خود را دریافت می‌کند
   ──────────────────────────────────────────────────────────── */

/* فارسی */
:lang(fa),
[lang="fa"] {
  font-family: var(--font-rtl-body);
  direction: rtl;
  line-height: var(--leading-rtl);
  text-align: right;
}

/* عربی */
:lang(ar),
[lang="ar"] {
  font-family: var(--font-rtl-body);
  direction: rtl;
  line-height: var(--leading-rtl);
  text-align: right;
}

/* اردو — نیاز به line-height بیشتر دارد (Nastaliq) */
:lang(ur),
[lang="ur"] {
  font-family: 'Gulzar', 'Noto Nastaliq Urdu', var(--font-rtl-body);
  direction: rtl;
  line-height: var(--leading-urdu);
  text-align: right;
  font-size: 1.05em;   /* اردو کمی بزرگ‌تر خوانایی بهتری دارد */
}

/* ترکی آذری (az) و ترکی استانبولی (tr) */
:lang(tr),
[lang="tr"],
:lang(az),
[lang="az"] {
  font-family: var(--font-ltr-body);
  direction: ltr;
}

/* روسی (Cyrillic) — PT Sans/Serif برای Cyrillic بهینه است */
:lang(ru),
[lang="ru"] {
  font-family: 'PT Serif', 'DM Sans', var(--font-ltr-body);
  direction: ltr;
}

/* انگلیسی */
:lang(en),
[lang="en"] {
  font-family: var(--font-ltr-body);
  direction: ltr;
}

/* ────────────────────────────────────────────────────────────
   3. HEADINGS — پیش‌فرض
   ──────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  text-wrap: balance;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

/* Display فونت‌ها برای RTL زبان‌ها */
:lang(fa) h1, :lang(fa) h2,
:lang(ar) h1, :lang(ar) h2,
[lang="fa"] h1, [lang="fa"] h2,
[lang="ar"] h1, [lang="ar"] h2 {
  font-family: var(--font-rtl-display);
  line-height: var(--leading-snug);
}

/* Display فونت برای LTR */
:lang(en) h1, :lang(en) h2,
:lang(ru) h1, :lang(ru) h2,
:lang(tr) h1, :lang(tr) h2 {
  font-family: var(--font-ltr-display);
}

/* ────────────────────────────────────────────────────────────
   4. PARAGRAPH & INLINE ELEMENTS
   ──────────────────────────────────────────────────────────── */
p {
  max-width: 75ch;        /* خوانایی بهینه */
  text-wrap: pretty;
}

a {
  color: var(--link-color);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--link-hover);
  text-decoration-thickness: 2px;
}

strong, b { font-weight: var(--weight-semibold); }
em, i { font-style: italic; }

small { font-size: var(--text-sm); }

abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

/* ────────────────────────────────────────────────────────────
   5. LISTS
   ──────────────────────────────────────────────────────────── */
ul, ol {
  list-style: none;
}

/* در محتوای مقاله، list style فعال می‌شود */
.prose ul { list-style: disc; padding-inline-start: 1.5em; }
.prose ol { list-style: decimal; padding-inline-start: 1.5em; }
.prose li { margin-bottom: var(--space-1); }

/* ────────────────────────────────────────────────────────────
   6. MEDIA
   ──────────────────────────────────────────────────────────── */
img, video, svg, canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

img {
  object-fit: cover;
}

/* ────────────────────────────────────────────────────────────
   7. FORM ELEMENTS RESET
   ──────────────────────────────────────────────────────────── */
button, input, textarea, select {
  font: inherit;
  color: inherit;
  background: transparent;
  border: none;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

button {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

/* ────────────────────────────────────────────────────────────
   8. TABLE RESET
   ──────────────────────────────────────────────────────────── */
table {
  border-collapse: collapse;
  width: 100%;
}

th, td {
  padding: var(--space-3) var(--space-4);
  text-align: start;   /* RTL-safe (start = right در RTL) */
}

/* ────────────────────────────────────────────────────────────
   9. HR & SEPARATOR
   ──────────────────────────────────────────────────────────── */
hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: var(--space-6) 0;
}

/* ────────────────────────────────────────────────────────────
   10. CODE & PRE
   ──────────────────────────────────────────────────────────── */
code, kbd, samp {
  font-family: var(--font-ltr-mono);
  font-size: 0.875em;
  background-color: var(--bg-code);
  padding: 0.1em 0.35em;
  border-radius: var(--radius-sm);
}

pre {
  font-family: var(--font-ltr-mono);
  font-size: var(--text-sm);
  background-color: var(--bg-code);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  overflow-x: auto;
  line-height: var(--leading-relaxed);
}

pre code {
  background: none;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
}

/* ────────────────────────────────────────────────────────────
   11. BLOCKQUOTE
   ──────────────────────────────────────────────────────────── */
blockquote {
  border-inline-start: 4px solid var(--color-primary-500);
  padding-inline-start: var(--space-6);
  padding-block: var(--space-4);
  color: var(--text-secondary);
  font-style: italic;
  margin-block: var(--space-6);
}

/* ────────────────────────────────────────────────────────────
   12. FOCUS VISIBLE — دسترسی‌پذیری
   ──────────────────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--color-primary-500);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

:focus:not(:focus-visible) {
  outline: none;
}

/* ────────────────────────────────────────────────────────────
   13. SELECTION
   ──────────────────────────────────────────────────────────── */
::selection {
  background-color: var(--color-primary-200);
  color: var(--color-primary-900);
}

[data-theme="dark"] ::selection {
  background-color: var(--color-primary-700);
  color: var(--color-primary-50);
}

/* ────────────────────────────────────────────────────────────
   14. SCROLLBAR (Webkit)
   ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 8px; height: 8px; }
::-webkit-scrollbar-track  { background: var(--bg-base); }
::-webkit-scrollbar-thumb  { background: var(--color-neutral-400); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-neutral-500); }

/* ────────────────────────────────────────────────────────────
   15. REDUCED MOTION
   ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ────────────────────────────────────────────────────────────
   16. PRINT
   ──────────────────────────────────────────────────────────── */
@media print {
  body {
    background: white;
    color: black;
    font-size: 12pt;
  }
  a::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: #555;
  }
  .no-print { display: none !important; }
}
