/* ════════════════════════════════════════════════════════════════
   Nextino Market Research — polished document styling
   Light theme, modern typography, generous whitespace, RTL-aware.
   ════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&family=Vazirmatn:wght@400;500;600;700;800&display=swap');

:root {
  --color-primary: #2563eb;
  --color-primary-dark: #1e3a8a;
  --color-primary-light: #dbeafe;
  --color-accent: #7c3aed;
  --color-success: #059669;
  --color-warning: #d97706;
  --color-danger: #dc2626;

  --color-text: #0f172a;
  --color-text-muted: #475569;
  --color-text-subtle: #64748b;
  --color-border: #e2e8f0;
  --color-border-strong: #cbd5e1;
  --color-bg: #ffffff;
  --color-bg-soft: #f8fafc;
  --color-bg-card: #ffffff;

  --shadow-sm: 0 1px 2px 0 rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --shadow-lg: 0 10px 20px -5px rgba(0,0,0,0.08), 0 4px 8px -4px rgba(0,0,0,0.06);

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.72;
  color: var(--color-text);
  max-width: 900px;
  margin: 0 auto;
  padding: 60px 40px 80px;
  background: var(--color-bg);
  background-image:
    radial-gradient(circle at 8% -10%, rgba(124,58,237,0.04) 0%, transparent 35%),
    radial-gradient(circle at 95% 5%, rgba(37,99,235,0.05) 0%, transparent 35%);
  background-attachment: fixed;
  font-feature-settings: "kern", "liga", "calt", "ss01";
  -webkit-font-smoothing: antialiased;
}

/* ──────────── RTL — Persian ──────────── */
*[dir="rtl"],
html[dir="rtl"] body,
html[lang="fa"] body {
  font-family: 'Vazirmatn', 'Inter', 'IRANSans', 'Tahoma', sans-serif;
  font-feature-settings: "kern", "liga";
}
html[dir="rtl"] body { direction: rtl; }

/* ──────────── Title (h1) ──────────── */
h1 {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--color-text);
  margin: 0 0 28px;
  padding-bottom: 20px;
  position: relative;
  border-bottom: none;
}
h1::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 80px;
  height: 4px;
  background: linear-gradient(90deg, var(--color-primary) 0%, var(--color-accent) 100%);
  border-radius: 4px;
}
html[dir="rtl"] h1::after { left: auto; right: 0; }

/* ──────────── Section heading (h2) ──────────── */
h2 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--color-text);
  margin: 56px 0 20px;
  padding: 0;
  border: none;
  position: relative;
  padding-left: 18px;
}
h2::before {
  content: "";
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 5px;
  background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-accent) 100%);
  border-radius: 3px;
}
html[dir="rtl"] h2 { padding-left: 0; padding-right: 18px; }
html[dir="rtl"] h2::before { left: auto; right: 0; }

/* ──────────── Sub-section (h3) ──────────── */
h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
  margin: 36px 0 14px;
}

h4 {
  font-size: 17px;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 22px 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
}

/* ──────────── Paragraphs ──────────── */
p { margin: 14px 0; }

/* ──────────── Links ──────────── */
a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: 500;
  border-bottom: 1.5px solid transparent;
  background-image: linear-gradient(180deg, transparent 88%, rgba(37,99,235,0.25) 88%);
  background-size: 100% 100%;
  background-repeat: no-repeat;
  transition: all 0.2s ease;
  padding: 0 1px;
}
a:hover {
  color: var(--color-primary-dark);
  background-image: linear-gradient(180deg, transparent 0%, rgba(37,99,235,0.18) 0%);
}

/* ──────────── Strong / em ──────────── */
strong {
  font-weight: 700;
  color: var(--color-text);
}
em {
  color: var(--color-text-muted);
  font-style: italic;
}

/* ──────────── Inline code ──────────── */
code {
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, Monaco, Consolas, monospace;
  font-size: 0.86em;
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
  padding: 2px 7px;
  border-radius: 5px;
  font-weight: 500;
  white-space: nowrap;
}
html[dir="rtl"] code { direction: ltr; unicode-bidi: embed; }

/* ──────────── Code blocks ──────────── */
pre {
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  color: #e2e8f0;
  padding: 22px 26px;
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: 'JetBrains Mono', 'SF Mono', Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 22px 0;
  box-shadow: var(--shadow-md);
  border: 1px solid rgba(255,255,255,0.04);
  position: relative;
}
pre code {
  background: transparent;
  color: inherit;
  padding: 0;
  white-space: pre;
  font-size: inherit;
}
html[dir="rtl"] pre { direction: ltr; text-align: left; }

/* ──────────── Tables ──────────── */
table {
  border-collapse: collapse;
  width: 100%;
  margin: 26px 0;
  font-size: 14.5px;
  background: var(--color-bg-card);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--color-border);
}

table th {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
  color: white;
  font-weight: 600;
  padding: 14px 16px;
  text-align: left;
  letter-spacing: 0.01em;
  font-size: 13.5px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--color-primary-dark);
}
html[dir="rtl"] table th { text-align: right; }

table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
  color: var(--color-text);
}

table tr:last-child td { border-bottom: none; }

table tr:nth-child(even) td { background: var(--color-bg-soft); }

table tr:hover td {
  background: var(--color-primary-light);
  transition: background 0.15s ease;
}

table code {
  font-size: 0.85em;
  white-space: normal;
}

/* ──────────── Blockquotes ──────────── */
blockquote {
  border-left: 4px solid var(--color-primary);
  margin: 22px 0;
  padding: 16px 24px;
  background: linear-gradient(135deg, var(--color-primary-light) 0%, #f0f9ff 100%);
  border-radius: 0 var(--radius) var(--radius) 0;
  color: var(--color-primary-dark);
  font-size: 15.5px;
  line-height: 1.7;
  box-shadow: var(--shadow-sm);
}
blockquote p { margin: 8px 0; }
blockquote strong { color: var(--color-primary-dark); }
html[dir="rtl"] blockquote {
  border-left: none;
  border-right: 4px solid var(--color-primary);
  border-radius: var(--radius) 0 0 var(--radius);
}

/* ──────────── Lists ──────────── */
ul, ol {
  padding-left: 32px;
  margin: 14px 0;
}
html[dir="rtl"] ul, html[dir="rtl"] ol {
  padding-left: 0;
  padding-right: 32px;
}

li {
  margin: 7px 0;
  line-height: 1.7;
}

li::marker {
  color: var(--color-primary);
  font-weight: 700;
}

/* ──────────── HR ──────────── */
hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--color-border-strong) 50%, transparent 100%);
  margin: 50px 0;
}

/* ──────────── Table of contents ──────────── */
#TOC {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 22px 28px;
  margin: 32px 0 48px;
  box-shadow: var(--shadow-md);
  position: relative;
}
#TOC::before {
  content: "📖";
  position: absolute;
  top: -14px;
  left: 22px;
  background: var(--color-bg);
  padding: 0 8px;
  font-size: 20px;
}
html[dir="rtl"] #TOC::before { left: auto; right: 22px; }
#TOC ul {
  list-style: none;
  padding-left: 0;
  margin: 0;
}
html[dir="rtl"] #TOC ul { padding-right: 0; }
#TOC > ul > li {
  margin: 6px 0;
  font-weight: 600;
}
#TOC ul ul {
  padding-left: 20px;
  margin: 4px 0 8px;
  font-weight: 400;
  font-size: 0.95em;
}
html[dir="rtl"] #TOC ul ul { padding-left: 0; padding-right: 20px; }
#TOC li::marker { content: ""; }
#TOC a {
  background-image: none;
  border: none;
  color: var(--color-text-muted);
  font-weight: inherit;
}
#TOC a:hover {
  color: var(--color-primary);
  background-image: none;
}

/* ──────────── Emoji + rating-friendly inline ──────────── */
/* Slightly larger emoji for readability */
body { font-variant-emoji: emoji; }

/* ──────────── Print ──────────── */
@media print {
  body {
    background: white;
    background-image: none;
    margin: 0;
    padding: 20px;
    max-width: none;
    font-size: 11pt;
    line-height: 1.5;
  }
  h1, h2, h3 { page-break-after: avoid; }
  table, pre, blockquote { page-break-inside: avoid; }
  a { color: var(--color-primary); }
  #TOC { box-shadow: none; }
}

/* ──────────── Mobile ──────────── */
@media (max-width: 700px) {
  body { padding: 32px 18px 50px; font-size: 15px; }
  h1 { font-size: 28px; }
  h2 { font-size: 22px; margin-top: 40px; }
  h3 { font-size: 18px; }
  table { font-size: 13px; }
  table th, table td { padding: 10px 12px; }
  pre { padding: 16px; font-size: 12.5px; }
}
