/* === CSS Custom Properties === */
:root {
  --bg: #ffffff;
  --bg-secondary: #f7f8fa;
  --text: #1a1a2e;
  --text-secondary: #64748b;
  --accent: #6366f1;
  --accent-hover: #4f46e5;
  --border: #e2e8f0;
  --card-bg: #ffffff;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --card-shadow-hover: 0 10px 25px rgba(0,0,0,0.1);
  --badge-bg: #f1f5f9;
  --badge-text: #475569;
  --badge-project-bg: #ede9fe;
  --badge-project-text: #6366f1;
  --badge-category-bg: #ecfdf5;
  --badge-category-text: #059669;
  --badge-tag-bg: #fef3c7;
  --badge-tag-text: #d97706;
  --impact-bg: #fef3c7;
  --impact-text: #92400e;
  --code-bg: #f8fafc;
  --blockquote-border: #6366f1;
  --nav-bg: rgba(255,255,255,0.85);
}

[data-theme="dark"] {
  --bg: #0c1222;
  --bg-secondary: #151d2e;
  --text: #f1f5f9;
  --text-secondary: #8b9cb8;
  --accent: #818cf8;
  --accent-hover: #a5b4fc;
  --border: #2a3548;
  --card-bg: #151d2e;
  --card-shadow: 0 2px 8px rgba(0,0,0,0.3);
  --card-shadow-hover: 0 12px 28px rgba(0,0,0,0.5);
  --badge-bg: #1e293b;
  --badge-text: #94a3b8;
  --badge-project-bg: #312e81;
  --badge-project-text: #c4b5fd;
  --badge-category-bg: #064e3b;
  --badge-category-text: #6ee7b7;
  --badge-tag-bg: #78350f;
  --badge-tag-text: #fcd34d;
  --impact-bg: #78350f;
  --impact-text: #fde68a;
  --code-bg: #151d2e;
  --blockquote-border: #818cf8;
  --nav-bg: rgba(12,18,34,0.9);
}

/* === Reset === */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* === Base === */
body {
  font-family: 'Heebo', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.7;
  color: var(--text);
  background: var(--bg);
  direction: rtl;
  text-align: right;
  transition: background 0.3s, color 0.3s;
}

/* === Layout === */
header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--nav-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

header nav {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.logo-dot {
  color: var(--accent);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

.nav-links a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--accent);
}

.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  transition: color 0.2s, border-color 0.2s;
}

.theme-toggle:hover {
  color: var(--accent);
  border-color: var(--accent);
}

[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon, :root:not([data-theme]) .icon-moon { display: none; }
[data-theme="dark"] .icon-moon { display: block; }

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* === Hero === */
.hero {
  padding: 2rem 0 2.5rem;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.5rem;
}

.hero-sub {
  font-size: 1.1rem;
  color: var(--text-secondary);
  max-width: 560px;
}

/* === Section Titles === */
.section-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 1.25rem;
}

/* === Featured Card === */
.featured-section {
  margin-bottom: 3rem;
}

.featured-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: linear-gradient(135deg, var(--accent) 0%, #8b5cf6 100%);
  border-radius: 16px;
  padding: 3px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.featured-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

.featured-card-inner {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 2rem;
}

.featured-card h3 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0.75rem 0 0.5rem;
}

/* Featured card with image */
.featured-card.has-image {
  display: grid;
  grid-template-columns: 1fr 1.5fr;
  padding: 3px;
}

.featured-card-image {
  border-radius: 14px 0 0 14px;
  overflow: hidden;
  min-height: 250px;
}

.featured-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.featured-card.has-image:hover .featured-card-image img {
  transform: scale(1.05);
}

.featured-card.has-image .featured-card-inner {
  border-radius: 0 14px 14px 0;
}

/* === Grid === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.25rem;
}

/* === Cards === */
.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: var(--text);
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
  border-color: var(--accent);
}

.card h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0.5rem 0 0.25rem;
}

.card time {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.card-excerpt {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin: 0.5rem 0;
  flex: 1;
}

.card-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-bottom {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Card with image */
.card.has-image {
  padding: 0;
  overflow: hidden;
}

.card.has-image .card-body {
  padding: 1.25rem;
}

.card-image {
  width: 100%;
  height: 180px;
  overflow: hidden;
}

.card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.card.has-image:hover .card-image img {
  transform: scale(1.05);
}

/* === Badges === */
.badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.2em 0.7em;
  border-radius: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-project {
  background: var(--badge-project-bg);
  color: var(--badge-project-text);
}

.badge-category {
  background: var(--badge-category-bg);
  color: var(--badge-category-text);
}

.badge-tag {
  background: var(--badge-tag-bg);
  color: var(--badge-tag-text);
}

/* === Tools === */
.tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.tool-badge {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  background: var(--badge-bg);
  color: var(--badge-text);
}

/* === Impact === */
.impact {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--impact-text);
  background: var(--impact-bg);
  padding: 0.25em 0.75em;
  border-radius: 6px;
  display: inline-block;
  width: fit-content;
}

.impact-banner {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--impact-text);
  background: var(--impact-bg);
  padding: 0.5em 1em;
  border-radius: 8px;
  margin: 0.75rem 0;
  display: inline-block;
}

/* === Post Page === */
.post-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.post-meta time {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.post h1 {
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
}

/* Post Featured Image */
.post-featured-image {
  margin: 1.5rem 0 2rem;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--card-shadow);
}

.post-featured-image img {
  width: 100%;
  height: auto;
  display: block;
}

/* === Post Content === */
.post-content {
  font-size: 1.05rem;
}

.post-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--accent);
  display: inline-block;
}

.post-content h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.post-content p {
  margin-bottom: 1.25rem;
}

.post-content ul, .post-content ol {
  margin-bottom: 1.25rem;
  padding-right: 1.5rem;
}

.post-content li {
  margin-bottom: 0.5rem;
}

.post-content strong {
  font-weight: 600;
}

.post-content pre {
  background: var(--code-bg);
  border: 1px solid var(--border);
  padding: 1.25rem;
  overflow-x: auto;
  border-radius: 10px;
  margin-bottom: 1.5rem;
  direction: ltr;
  text-align: left;
  position: relative;
}

.post-content code {
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.85em;
}

.post-content p code,
.post-content li code {
  background: var(--badge-bg);
  color: var(--accent);
  padding: 0.15em 0.4em;
  border-radius: 5px;
  font-size: 0.85em;
}

.post-content img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
  margin: 1.5rem 0;
  display: block;
}

.post-content blockquote {
  border-right: 4px solid var(--blockquote-border);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  background: var(--bg-secondary);
  border-radius: 8px 0 0 8px;
  color: var(--text-secondary);
  font-style: italic;
}

/* === Copy Button === */
.copy-btn {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.25em 0.6em;
  font-size: 0.7rem;
  font-weight: 500;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
}

pre:hover .copy-btn {
  opacity: 1;
}

/* === Mermaid === */
.mermaid {
  text-align: center;
  margin: 1.5rem 0;
  direction: ltr;
}

/* === About === */
.about {
  max-width: 680px;
}

.about h1 {
  font-size: 2rem;
  margin-bottom: 1.25rem;
}

.about h2 {
  font-size: 1.3rem;
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

.about p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
  line-height: 1.8;
}

.about p a {
  color: var(--accent);
}

.about-author {
  display: flex;
  gap: 1.25rem;
  align-items: flex-start;
  margin: 2rem 0;
  padding: 1.5rem;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.about-author h2 {
  margin-top: 0 !important;
  margin-bottom: 0.5rem;
}

.about-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.about-tools {
  margin-top: 0.5rem;
}

/* === Footer === */
footer {
  max-width: 900px;
  margin: 3rem auto 0;
  padding: 0 1.5rem 2rem;
}

.footer-cta {
  text-align: center;
  padding: 2rem;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.footer-cta p {
  font-size: 1.1rem;
  font-weight: 500;
  margin-bottom: 0.75rem;
}

.cta-link {
  display: inline-block;
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
  transition: opacity 0.2s;
}

.cta-link:hover {
  opacity: 0.8;
}

.footer-bottom {
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

/* === Reading Time === */
.reading-time {
  font-size: 0.8rem;
  color: var(--text-secondary);
  background: var(--badge-bg);
  padding: 0.15em 0.5em;
  border-radius: 4px;
}

/* === Scroll to Top === */
.scroll-top {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  box-shadow: var(--card-shadow);
  z-index: 90;
}

.scroll-top.visible {
  opacity: 1;
  pointer-events: auto;
}

.scroll-top:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  color: var(--accent);
}

/* === Tags Section === */
.tags-section {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.tags-search {
  margin-bottom: 1rem;
}

.tags-search input {
  width: 100%;
  max-width: 320px;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  direction: rtl;
}

.tags-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.tags-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tag-btn {
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.35em 0.8em;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.tag-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.tag-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* === Share Widget === */
.share-widget {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 2.5rem;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.share-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.share-buttons {
  display: flex;
  gap: 0.5rem;
  flex-direction: row-reverse;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  border: none;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
}

.share-btn svg {
  width: 20px;
  height: 20px;
}

.share-whatsapp {
  background: #25D366;
  color: #fff;
}
.share-whatsapp:hover {
  background: #1da851;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.share-twitter {
  background: #000;
  color: #fff;
}
[data-theme="dark"] .share-twitter {
  background: #fff;
  color: #000;
}
.share-twitter:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}
[data-theme="dark"] .share-twitter:hover {
  box-shadow: 0 4px 12px rgba(255, 255, 255, 0.2);
}

.share-linkedin {
  background: #0A66C2;
  color: #fff;
}
.share-linkedin:hover {
  background: #004182;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(10, 102, 194, 0.4);
}

.share-email {
  background: var(--accent);
  color: #fff;
}
.share-email:hover {
  background: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.share-copy {
  background: var(--badge-bg);
  color: var(--text-secondary);
  border: 1px solid var(--border);
}
.share-copy:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-2px);
}

.share-copy.copied {
  background: #059669;
  color: #fff;
  border-color: #059669;
}

/* === Related Posts === */
.related-posts {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.related-posts h2 {
  margin-bottom: 1.25rem;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.related-card {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: var(--text);
  transition: all 0.2s;
  min-height: 120px;
}

.related-card:hover {
  border-color: var(--accent);
  transform: translateY(-3px);
  box-shadow: var(--card-shadow-hover);
}

.related-card h3 {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.5;
  margin: 0;
  color: var(--text);
}

.related-card .badge {
  font-size: 0.65rem;
  width: fit-content;
}

/* Related card with image */
.related-card-image {
  margin: -1.25rem -1.25rem 0.75rem -1.25rem;
  height: 120px;
  overflow: hidden;
  border-radius: 12px 12px 0 0;
}

.related-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.related-card:hover .related-card-image img {
  transform: scale(1.05);
}

.related-card-content {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* === Focus & Skip Link === */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  top: -100%;
  left: 0;
  background: var(--accent);
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0 0 8px 8px;
  z-index: 200;
  font-weight: 600;
  text-decoration: none;
}

.skip-link:focus {
  top: 0;
}

/* === Responsive === */
@media (max-width: 640px) {
  .hero h1 {
    font-size: 1.75rem;
  }

  .hero-sub {
    font-size: 1rem;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .featured-card-inner {
    padding: 1.25rem;
  }

  .featured-card h3 {
    font-size: 1.2rem;
  }

  .featured-card.has-image {
    grid-template-columns: 1fr;
  }

  .featured-card-image {
    border-radius: 14px 14px 0 0;
    min-height: 180px;
  }

  .featured-card.has-image .featured-card-inner {
    border-radius: 0 0 14px 14px;
  }

  .related-card-image {
    height: 80px;
  }

  .post h1 {
    font-size: 1.5rem;
  }

  .nav-links {
    gap: 1rem;
  }

  .nav-links a {
    font-size: 0.8rem;
  }

  .related-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
  }

  .related-card {
    padding: 1rem;
    min-height: 100px;
  }

  .related-card h3 {
    font-size: 0.8rem;
  }

  .share-widget {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .share-buttons {
    width: 100%;
    justify-content: flex-end;
  }

  .share-btn {
    width: 38px;
    height: 38px;
  }

  .share-btn svg {
    width: 18px;
    height: 18px;
  }
}
