/* ===========================
   Theme Variables
=========================== */
:root {
  --bg-color: #ffffff;
  --text-color: #222222;
  --link-color: #0066cc;
  --link-hover: #004c99;
  --table-border: #ccc;
  --table-header-bg: #f5f5f5;
  --code-bg: #f7f7f7;
  --footer-color: #666;
  --footer-border: #eee;
}

[data-theme="dark"] {
  --bg-color: #0f0f0f;
  --text-color: #e0e0e0;
  --link-color: #4dabf7;
  --link-hover: #82cfff;
  --table-border: #333;
  --table-header-bg: #1f1f1f;
  --code-bg: #1e1e1e;
  --footer-color: #999;
  --footer-border: #333;
}

/* ===========================
   Global Styles
=========================== */

body {
  font-family: "Vazirmatn", sans-serif;
  line-height: 1.55;
  font-size: 1rem;
  color: var(--text-color);
  background-color: var(--bg-color);
  direction: rtl;
  text-align: right;
  margin: 1.4rem;

  /* Font rendering improvements */
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  font-feature-settings: "liga", "kern";
}

h1, h2, h3, h4, h5, h6 {
  font-weight: bold;
  margin-block: 1.5rem 0.75rem;
  line-height: 1.35;
}

ul, ol {
  padding-right: 2rem;
  padding-left: 0; /* remove LTR padding */
  text-align: right;
}

/* ===========================
   Links
=========================== */

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* ===========================
   Tables (responsive, no HTML wrapper needed)
=========================== */

table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 1rem;
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: normal;
}

th, td {
  border: 1px solid var(--table-border);
  padding: 0.6rem 0.75rem;
  text-align: right;
  vertical-align: top;
}

th {
  background-color: var(--table-header-bg);
  font-weight: bold;
}

/* ===========================
   Code blocks
=========================== */

code, pre {
  font-family: "Fira Code", monospace;
  background: var(--code-bg);
  border-radius: 4px;
  font-size: 0.95rem;
}

code {
  padding: 0.2rem 0.4rem;
}

pre {
  padding: 0.8rem 1rem;
  overflow-x: auto;
  margin: 1rem 0;
}

/* ===========================
   Footer (optional override)
=========================== */

.site-footer {
  margin-top: 3rem;
  padding: 1.5rem 0;
  text-align: center;
  font-size: 0.9rem;
  color: #666;
  border-top: 1px solid #eee;
}

.site-footer p {
  margin: 0;
}

.theme-toggle {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  z-index: 999;
  background: var(--code-bg);
  color: var(--text-color);
  border: 1px solid var(--table-border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background 0.3s, color 0.3s;
}

.theme-toggle:hover {
  background: var(--table-header-bg);
}

/* ===========================
   Responsive Laptop/Desktop Enhancements
=========================== */

/* Medium screens (tablets, small laptops) */
@media (min-width: 768px) {
  body {
    font-size: 1.05rem;
    line-height: 1.6;
    margin: 2rem auto;
    max-width: 50rem;
  }

  h1, h2, h3, h4, h5, h6 {
    line-height: 1.3;
  }

  table {
    font-size: 1rem;
  }
}

/* Large screens (laptops, desktops) */
@media (min-width: 1200px) {
  body {
    font-size: 1.1rem;
    line-height: 1.65;   /* adjusted for better readability */
    margin: 3rem auto;
    max-width: 65ch;
  }

  p, li {
    margin-bottom: 1rem;
  }
}


/* ===========================
   Images (responsive, text-width)
=========================== */

img {
  display: block;
  max-width: 80%;   /* make images smaller than text width */
  height: auto;     /* keep aspect ratio */
  margin: 1.5rem auto;
  border-radius: 6px;
}

@media (min-width: 1200px) {
  img {
    max-width: 60%;  /* on big screens, keep images smaller */
  }
}

figure {
  margin: 1.5rem auto;
  max-width: 100%;
  text-align: center;
}

figcaption {
  font-size: 0.9rem;
  color: var(--footer-color);
  margin-top: 0.5rem;
  line-height: 1.4;
}