/* JMilo — ported from jmilo.html */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; color-scheme: dark; }
html.light { color-scheme: light; }

:root {
  --bg: #050505;
  --bg2: #0A0A0A;
  --bg3: #111111;
  --text: #E5E5E5;
  --muted: #888888;
  --accent: #7C3AED;
  --accent2: #06B6D4;
  --border: rgba(255,255,255,0.05);
  --border2: rgba(255,255,255,0.1);
  --card-hover-border: rgba(124,58,237,0.3);
  --code-bg: #0A0A0A;
  --math-color: #E5E5E5;
  --selection-bg: rgba(124,58,237,0.4);
}

html.light {
  --bg: #FAFAFA;
  --bg2: #F0F0F0;
  --bg3: #E8E8E8;
  --text: #1A1A1A;
  --muted: #666666;
  --accent: #6D28D9;
  --accent2: #0891B2;
  --border: rgba(0,0,0,0.06);
  --border2: rgba(0,0,0,0.1);
  --card-hover-border: rgba(109,40,217,0.25);
  --code-bg: #F5F5F5;
  --math-color: #1A1A1A;
  --selection-bg: rgba(109,40,217,0.2);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Vazirmatn', 'Inter', sans-serif;
  transition: background 0.4s, color 0.4s;
}

/* Base links — replaces Tailwind preflight defaults */
a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  color: var(--accent2);
}
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}

.site-brand,
.site-brand:hover {
  color: var(--text);
  text-decoration: none;
}

.mobile-nav-link {
  color: var(--text);
  text-decoration: none;
}
.mobile-nav-link:hover {
  color: var(--accent);
}

.card-hover h1 a,
.card-hover h2 a,
.card-hover h3 a,
.card-hover h4 a {
  text-decoration: none;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--accent);
}

.pagination a,
.pagination .page-numbers {
  text-decoration: none;
}

.comments-area a {
  color: var(--accent);
}
.comments-area a:hover {
  color: var(--accent2);
}

::selection { background: var(--selection-bg); color: #fff; }
html.light ::selection { background: var(--selection-bg); color: #fff; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

.noise::before {
  content: '';
  position: fixed; inset: 0; z-index: 9999;
  pointer-events: none; opacity: 0.025;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
html.light .noise::before { opacity: 0.015; }

#starfield { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
html.light #starfield { opacity: 0.15; }

.glow-line {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), var(--accent2), transparent);
}

.card-hover {
  transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid var(--border);
  background: var(--bg2);
}
.card-hover:hover {
  border-color: var(--card-hover-border);
  box-shadow: 0 0 40px rgba(124,58,237,0.06);
  transform: translateY(-2px);
}
html.light .card-hover:hover {
  box-shadow: 0 8px 30px rgba(0,0,0,0.08);
}

.tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 9999px;
  border: 1px solid var(--border2); color: var(--muted);
  transition: all 0.3s; display: inline-block; cursor: pointer;
  background: transparent; font-family: inherit;
  text-decoration: none;
}
.tag:hover { border-color: var(--card-hover-border); color: var(--text); }
.tag-accent { border-color: rgba(124,58,237,0.4) !important; color: var(--accent) !important; }
.tag-cyan { border-color: rgba(6,182,212,0.3); color: var(--accent2); }
.tag-green { border-color: rgba(16,185,129,0.3); color: #10B981; }
.tag-yellow { border-color: rgba(234,179,8,0.3); color: #EAB308; }
.tag-pink { border-color: rgba(236,72,153,0.3); color: #EC4899; }

.section-label {
  font-size: 10px; font-weight: 600; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--accent); font-family: 'Inter', sans-serif;
}

.nav-link {
  font-size: 13px; font-weight: 400; color: var(--muted); transition: color 0.3s;
  position: relative; text-decoration: none;
}
.nav-link:hover { color: var(--text); }
.nav-link::after {
  content: ''; position: absolute; bottom: -4px; right: 0;
  width: 0; height: 1px; background: var(--accent); transition: width 0.3s;
}
.nav-link:hover::after { width: 100%; }
.nav-link.active { color: var(--text); }
.nav-link.active::after { width: 100%; }

.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1), transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.reveal.visible { opacity: 1; transform: translateY(0); }
.no-js .reveal { opacity: 1; transform: none; }

.en-section { direction: ltr; text-align: left; font-family: 'Inter', sans-serif; }
.is-english .post-content,
.is-english .en-section { direction: ltr; text-align: left; font-family: 'Inter', sans-serif; }

.float-indicator { animation: float 3s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }

.pulse-ring { animation: pulseRing 2s ease-out infinite; }
@keyframes pulseRing { 0% { box-shadow: 0 0 0 0 rgba(124,58,237,0.4); } 100% { box-shadow: 0 0 0 12px rgba(124,58,237,0); } }

.mobile-menu {
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.mobile-menu.open { transform: translateX(0); }
html[dir="rtl"] .mobile-menu { transform: translateX(-100%); }
html[dir="rtl"] .mobile-menu.open { transform: translateX(0); }

.math-block {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 20px 24px; overflow-x: auto;
}
.math-block mjx-container, mjx-container { color: var(--math-color) !important; }

.theorem-block {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px 20px; margin: 12px 0;
  border-inline-end: 3px solid var(--accent2);
}
.theorem-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent2);
  font-family: 'Inter', sans-serif; margin-bottom: 6px;
}

.proof-block {
  border-inline-end: 2px solid var(--accent);
  padding-inline-end: 16px; margin: 12px 0;
}
.proof-block::before {
  content: 'اثبات'; display: block;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--accent);
  font-family: 'Inter', sans-serif; margin-bottom: 8px;
}
.proof-end::after {
  content: '∎'; font-size: 16px; color: var(--accent); margin-inline-end: 4px;
}

.theme-toggle {
  position: relative; width: 40px; height: 22px;
  border-radius: 11px; background: var(--border2);
  cursor: pointer; transition: background 0.3s; border: none;
}
.theme-toggle::after {
  content: '';
  position: absolute;
  top: 3px;
  right: 3px;
  left: auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  transition: left 0.3s, right 0.3s;
}
html.light .theme-toggle::after {
  right: auto;
  left: 3px;
}
html[dir="rtl"] .theme-toggle::after {
  right: auto;
  left: 3px;
}
html[dir="rtl"].light .theme-toggle::after {
  left: auto;
  right: 3px;
}

.line-clamp-3 {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.site-navbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  transition: background 0.4s;
}

body.admin-bar .site-navbar {
  top: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar .site-navbar {
    top: 46px;
  }
}

body.admin-bar #mobileMenu {
  padding-top: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar #mobileMenu {
    padding-top: 46px;
  }
}

.custom-logo-link {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
}

.custom-logo {
  width: 2rem;
  height: 2rem;
  object-fit: cover;
  border-radius: 0.5rem;
}

.brand-mark {
  width: 2rem; height: 2rem; border-radius: 0.5rem;
  background: linear-gradient(to bottom right, #9333ea, #06b6d4);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 0.875rem; font-weight: 700;
}

.post-content { line-height: 1.85; color: var(--text); font-size: 1rem; }
.post-content p { margin-bottom: 1rem; }
.post-content a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.post-content a:hover { color: var(--accent2); }
.post-content h1,
.post-content h2,
.post-content h3,
.post-content h4,
.post-content h5,
.post-content h6 {
  color: var(--text);
  font-weight: 700;
  line-height: 1.35;
  margin: 1.75rem 0 0.85rem;
}
.post-content h1 { font-size: 2rem; }
.post-content h2 { font-size: 1.65rem; }
.post-content h3 { font-size: 1.35rem; }
.post-content h4 { font-size: 1.15rem; }
.post-content h5 { font-size: 1.05rem; }
.post-content h6 { font-size: 0.95rem; color: var(--muted); }
.post-content ul,
.post-content ol { margin: 0 0 1rem; padding-inline-start: 1.5rem; }
.post-content blockquote {
  margin: 1.25rem 0;
  padding: 0.85rem 1rem;
  border-inline-start: 3px solid var(--accent);
  background: var(--bg2);
  border-radius: 0 8px 8px 0;
  color: var(--muted);
}
.post-content pre, .post-content code {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.post-content code { padding: 0.15rem 0.4rem; font-size: 0.9em; }
.post-content pre { padding: 1rem; overflow-x: auto; }
.post-content pre code { border: none; padding: 0; background: transparent; }
.post-content img { border-radius: 8px; max-width: 100%; height: auto; }

.single-title {
  font-size: clamp(1.75rem, 4vw, 2.75rem);
  font-weight: 700;
  line-height: 1.25;
  margin-bottom: 1rem;
}

.comments-area { color: var(--text); }
.comments-area .comment-list { list-style: none; margin: 0 0 1.5rem; padding: 0; }
.comments-area .comment {
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg2);
}
.comments-area .comment-author { font-weight: 600; margin-bottom: 0.35rem; }
.comments-area .comment-meta { font-size: 0.75rem; color: var(--muted); margin-bottom: 0.75rem; }
.comments-area .comment-form label {
  display: block;
  font-size: 0.8125rem;
  color: var(--muted);
  margin-bottom: 0.35rem;
}
.comments-area .comment-form input[type="text"],
.comments-area .comment-form input[type="email"],
.comments-area .comment-form input[type="url"],
.comments-area .comment-form textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  margin-bottom: 0.85rem;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--bg2);
  color: var(--text);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.comments-area .comment-form textarea {
  min-height: 8rem;
  resize: vertical;
  line-height: 1.6;
}
.comments-area .comment-form input:focus,
.comments-area .comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.15);
}
.comments-area .form-submit input[type="submit"],
.comments-area .comment-form .submit {
  background: #9333ea;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.comments-area .form-submit input[type="submit"]:hover,
.comments-area .comment-form .submit:hover {
  background: #7e22ce;
}

.social-link {
  color: var(--muted);
  transition: color 0.3s;
  display: inline-flex;
  align-items: center;
}
.social-link:hover { color: var(--accent); }
.social-link svg { width: 1rem; height: 1rem; }

.screen-reader-text {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap;
}

.pagination .nav-links { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-top: 3rem; }
.pagination .page-numbers {
  width: 2.5rem; height: 2.5rem; display: inline-flex; align-items: center; justify-content: center;
  border-radius: 0.5rem; font-size: 0.875rem; text-decoration: none;
  border: 1px solid var(--border2); color: var(--muted); transition: all 0.2s;
}
.pagination .page-numbers.current { background: #9333ea; color: #fff; border-color: #9333ea; }
.pagination .page-numbers:hover:not(.current) { border-color: var(--card-hover-border); color: var(--text); }

.tag-overlay {
  background: color-mix(in srgb, var(--bg) 80%, transparent);
  backdrop-filter: blur(8px);
}
