/* ==========================================================================
   TEKWALA PRODUCTION CSS — v6.4 (FINAL PRODUCTION READY)
   Devanagari-safe • Auto Table Header • Multi-Ad CLS Guard • Perfect Sticky
   ========================================================================== */

/* ==========================================================================
   0. DESIGN TOKENS
   ========================================================================== */

:root {
  /* Layout */
  --header-height: 90px;

  /* Brand */
  --color-primary: #4f46e5;
  --color-primary-hover: #4338ca;
  --color-primary-dark: #3730a3;
  --color-primary-light: #eef2ff;
  --color-accent-link: #2563eb;
  --color-accent-link-hover: #1d4ed8;

  /* Neutrals */
  --color-bg-body: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-subtle: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-subtle: #edf2f7;

  /* Text */
  --color-text-main: #2d3748;
  --color-text-dark: #0f172a;
  --color-text-muted: #55657a;

  /* Tables */
  --table-header-bg: var(--color-primary);
  --table-header-bg-hover: var(--color-primary-hover);
  --table-header-text: #ffffff;

  /* Font stack */
  --font-body: "Mukta", "Noto Sans Devanagari", "Hind", system-ui, -apple-system,
    "Segoe UI", Roboto, Arial, sans-serif;

  /* Type scale */
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1.125rem;
  --text-lg: 1.25rem;
  --text-xl: 1.5rem;
  --text-2xl: 1.75rem;

  /* Spacing */
  --space-sm: 0.5rem;
  --space-md: 1rem;
  --space-lg: 1.5rem;
  --space-xl: 2.25rem;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 12px 30px rgba(0, 0, 0, 0.08);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==========================================================================
   1. GLOBAL & ACCESSIBILITY
   ========================================================================== */

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: var(--font-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
th, td, .entry-meta, .entry-meta a,
.widget-title, .read-more {
  letter-spacing: 0;
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

::selection {
  background: var(--color-primary);
  color: #fff;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
.search-field:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.screen-reader-text,
.sr-only {
  border: 0;
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
  word-wrap: normal !important;
}

/* ==========================================================================
   2. HEADER & NAVIGATION
   ========================================================================== */

.site-header {
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
}

.main-navigation.is_stuck,
.site-header.sticky-enabled {
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-normal);
}

/* ==========================================================================
   3. ARCHIVE / BLOG CARDS
   ========================================================================== */

.archive .inside-article,
.blog .inside-article {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: transform var(--transition-normal),
    box-shadow var(--transition-normal),
    border-color var(--transition-normal);
}

.archive .post-image,
.blog .post-image { overflow: hidden; }

.archive .post-image img,
.blog .post-image img {
  aspect-ratio: 16 / 9;
  display: block;
  height: auto;
  object-fit: cover;
  transition: transform 400ms ease;
  width: 100%;
}

@media (hover: hover) {
  .archive .inside-article:hover,
  .blog .inside-article:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
  }
  .inside-article:hover .post-image img { transform: scale(1.03); }
}

/* ==========================================================================
   4. SINGLE POST & DEVANAGARI TYPOGRAPHY
   ========================================================================== */

.single-post .inside-article {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-xl);
}

.single-post .entry-content {
  color: var(--color-text-main);
  font-size: var(--text-base);
  line-height: 1.85;
  overflow-wrap: break-word;
  word-break: normal;
}

.single-post h1.entry-title {
  color: var(--color-text-dark);
  font-size: clamp(1.75rem, 3.5vw + 0.75rem, 2.5rem);
  font-weight: 800;
  line-height: 1.4;
}

.single-post .entry-content h2 {
  border-left: 4px solid var(--color-primary);
  color: var(--color-text-dark);
  font-size: clamp(1.35rem, 2.5vw + 0.4rem, var(--text-2xl));
  font-weight: 700;
  line-height: 1.45;
  margin: 2em 0 0.75em;
  padding-left: var(--space-sm);
  scroll-margin-top: calc(var(--header-height) + 10px);
}

.single-post .entry-content h3 {
  color: var(--color-text-dark);
  font-size: clamp(1.2rem, 2vw + 0.25rem, var(--text-xl));
  font-weight: 700;
  line-height: 1.45;
  margin: 1.75em 0 0.75em;
  scroll-margin-top: calc(var(--header-height) + 10px);
}

.entry-content p { margin-bottom: 1.5em; }

.entry-content a {
  border-bottom: 1.5px solid rgba(37, 99, 235, 0.25);
  color: var(--color-accent-link);
  padding-bottom: 1px;
  text-decoration: none;
  transition: color var(--transition-fast),
    border-color var(--transition-fast),
    background-color var(--transition-fast);
}

.entry-content a:hover {
  background-color: rgba(37, 99, 235, 0.06);
  border-bottom-color: var(--color-accent-link-hover);
  border-radius: 2px;
  color: var(--color-accent-link-hover);
}

.entry-content ol li,
.entry-content ul li {
  line-height: 1.8;
  margin-bottom: var(--space-sm);
}

.entry-content hr {
  background: linear-gradient(to right, transparent, var(--color-border), transparent);
  border: 0;
  height: 1px;
  margin: 2.5rem 0;
}

.entry-content img {
  height: auto;
  max-width: 100%;
}

.wp-caption-text,
figcaption {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  font-style: normal;
  margin-top: var(--space-sm);
  text-align: center;
}

/* ==========================================================================
   5. META & BADGES
   ========================================================================== */

.entry-meta {
  align-items: center;
  background: var(--color-bg-body);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: var(--space-md) 0 var(--space-lg);
  padding: 10px 14px;
}

.posted-on .published,
.posted-on .updated {
  border-radius: var(--radius-full);
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 4px 10px;
}

.posted-on .published { background: var(--color-primary-light); color: var(--color-primary); }
.posted-on .published::before { content: "प्रकाशित: "; }

.posted-on .updated { background: #ecfdf5; color: #047857; }
.posted-on .updated::before { content: "अपडेट: "; }

.entry-meta a[rel="category tag"] {
  background-color: var(--color-primary-light);
  border: 1px solid rgba(79, 70, 229, 0.15);
  border-radius: var(--radius-full);
  color: var(--color-primary);
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 700;
  padding: 4px 12px;
  text-decoration: none;
  transition: background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

.entry-meta a[rel="category tag"]:hover {
  background-color: var(--color-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* ==========================================================================
   6. DATA TABLES (AUTO HEADER & TEXT ALIGNMENT SAFE)
   ========================================================================== */

.entry-content .wp-block-table {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin: 2rem 0;
  overflow-x: auto;
  width: 100%;
}

.entry-content table,
.entry-content table.has-fixed-layout {
  border-collapse: collapse;
  margin: 0;
  table-layout: auto;
  width: 100%;
}

/* Fallback for basic TH */
.entry-content table th {
  background-color: var(--table-header-bg);
  border-bottom: 2px solid var(--table-header-bg-hover);
  color: var(--table-header-text);
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 14px 18px;
  text-align: left;
}

/* Safe Fallback for THEAD */
.entry-content table thead th,
.entry-content table thead td {
  background-color: var(--table-header-bg) !important;
  border-bottom: 2px solid var(--table-header-bg-hover) !important;
  color: var(--table-header-text) !important;
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 14px 18px;
  text-align: left;
}

/* जर Header Section बंद राहिला असेल, तरीही पहिल्या ओळीला आपोआप जांभळा रंग देणे */
@supports selector(:has(thead)) {
  .entry-content table:not(:has(thead)) tr:first-child :is(th, td) {
    background-color: var(--table-header-bg) !important;
    border-bottom: 2px solid var(--table-header-bg-hover) !important;
    color: var(--table-header-text) !important;
    font-size: var(--text-sm);
    font-weight: 700;
    padding: 14px 18px;
    text-align: left;
  }
}

/* टेबलमधील Right आणि Center अलाईनमेंट सुरक्षित ठेवणे */
.entry-content table th.has-text-align-right,
.entry-content table td.has-text-align-right { text-align: right !important; }

.entry-content table th.has-text-align-center,
.entry-content table td.has-text-align-center { text-align: center !important; }

.entry-content table thead a,
.entry-content table:not(:has(thead)) tr:first-child a {
  border-bottom-color: rgba(255, 255, 255, 0.5);
  color: #fff !important;
}

.entry-content td {
  border-bottom: 1px solid var(--color-border-subtle);
  color: var(--color-text-main);
  font-size: var(--text-sm);
  line-height: 1.7;
  padding: 14px 18px;
  vertical-align: middle;
}

.entry-content table tbody tr:nth-child(even) { background-color: var(--color-bg-body); }
.entry-content table tbody tr:hover { background-color: var(--color-surface-subtle); }

/* ==========================================================================
   7. BLOCKQUOTE, CALLOUTS & FAQ
   ========================================================================== */

.entry-content blockquote {
  background: var(--color-bg-body);
  border-left: 4px solid var(--color-primary);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--color-text-main);
  font-style: normal;
  font-weight: 500;
  margin: 2rem 0;
  padding: 1.25rem 1.5rem 1.25rem 2rem;
}

.key-highlights,
.related-link-box {
  background: #eff6ff;
  border-radius: var(--radius-md);
  margin: 1.75rem 0;
  padding: 1.25rem;
}

.key-highlights { border: 1px solid #bfdbfe; }
.key-highlights ul { margin: 0; padding-left: 1.25rem; }
.related-link-box { border-left: 4px solid var(--color-primary); }

.rank-math-list-item,
.schema-faq-section,
.faq-block {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 1rem;
  padding: 1.25rem;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.rank-math-list-item:hover,
.schema-faq-section:hover,
.faq-block:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.rank-math-question,
.faq-question {
  color: var(--color-text-dark);
  font-size: var(--text-base);
  font-weight: 700;
  line-height: 1.5;
  margin-bottom: 0.5rem;
}

.rank-math-answer,
.faq-answer {
  color: var(--color-text-main);
  font-size: 1rem;
  line-height: 1.75;
}

/* ==========================================================================
   8. SIDEBAR, WIDGETS & ADSENSE
   ========================================================================== */

.sidebar .widget {
  --widget-pad: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: var(--space-lg);
  overflow: hidden;
  padding: var(--widget-pad);
}

.sidebar .widget:has(.adsbygoogle) { padding: 8px; }

/* सर्व जाहिरातींसाठी CLS संरक्षण (साईडबार + लेखाच्या आतील जाहिराती) */
.sidebar .adsbygoogle,
.entry-content .code-block:not(.ai-empty-code),
.ad-container {
  display: block;
  min-height: 250px;
  text-align: center;
}

/* जाहिरात उपलब्ध नसेल (Unfilled) तर रिकामा डबा आपोआप बंद व्हावा */
.adsbygoogle[data-ad-status="unfilled"],
ins.adsbygoogle[data-ad-status="unfilled"],
.code-block:has([data-ad-status="unfilled"]) {
  display: none !important;
  min-height: 0 !important;
}

.sidebar .widget:has(.adsbygoogle) .widget-title,
.sidebar .widget:has(.adsbygoogle) h2,
.sidebar .widget:has(.adsbygoogle) h3,
.sidebar .widget:has(.adsbygoogle) h4 {
  background: none;
  border: 0;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
  font-weight: 500;
  margin: 0 0 6px;
  padding: 0;
  text-align: center;
}

.sidebar .widget .widget-title,
.sidebar .widget h2,
.sidebar .widget h3,
.sidebar .widget h4 {
  background-color: var(--color-primary);
  border-bottom: 3px solid var(--color-primary-dark);
  color: #fff;
  font-size: var(--text-lg);
  font-weight: 700;
  line-height: 1.4;
  margin: calc(var(--widget-pad) * -1) calc(var(--widget-pad) * -1) 20px;
  padding: 14px var(--widget-pad);
  text-align: center;
}

/* Latest posts */
.wp-block-latest-posts {
  list-style: none;
  margin: 0;
  padding: 0;
}

.wp-block-latest-posts li {
  align-items: center;
  border-bottom: 1px dashed var(--color-border);
  display: flex;
  gap: 14px;
  margin: 0;
  padding: 12px 0;
}

.wp-block-latest-posts li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.wp-block-latest-posts__featured-image {
  flex-shrink: 0;
  margin: 0;
}

.site-content .sidebar .wp-block-latest-posts__featured-image img {
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  display: block;
  height: 54px !important;
  max-width: 96px !important;
  object-fit: cover;
  transition: transform var(--transition-fast);
  width: 96px !important;
}

.wp-block-latest-posts li:hover .wp-block-latest-posts__featured-image img { transform: scale(1.08); }

.wp-block-latest-posts__post-title {
  color: var(--color-text-dark);
  flex-grow: 1;
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.55;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.wp-block-latest-posts li:hover .wp-block-latest-posts__post-title { color: var(--color-primary); }

/* Categories */
.sidebar .widget_categories ul,
.sidebar .wp-block-categories-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar .widget_categories ul li,
.sidebar .wp-block-categories-list li {
  align-items: center;
  background: var(--color-bg-body);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  padding: 12px 16px;
  transition: background-color var(--transition-fast),
    border-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
}

.sidebar .widget_categories ul li:last-child,
.sidebar .wp-block-categories-list li:last-child { margin-bottom: 0; }

.sidebar .widget_categories ul li a,
.sidebar .wp-block-categories-list li a {
  color: var(--color-text-main);
  flex-grow: 1;
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.sidebar .widget_categories ul li .count,
.sidebar .widget_categories ul li span,
.sidebar .wp-block-categories-list li span {
  background: var(--color-primary-light);
  border-radius: var(--radius-full);
  color: var(--color-primary-dark);
  font-size: var(--text-xs);
  font-weight: 700;
  min-width: 35px;
  padding: 4px 12px;
  text-align: center;
}

@media (hover: hover) {
  .sidebar .widget_categories ul li:hover,
  .sidebar .wp-block-categories-list li:hover {
    background: #fff;
    border-color: var(--color-primary);
    box-shadow: 0 4px 15px rgba(79, 70, 229, 0.08);
    transform: translateX(4px);
  }
  .sidebar .widget_categories ul li:hover a,
  .sidebar .wp-block-categories-list li:hover a { color: var(--color-primary); }
}

.search-field {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  padding: 10px 16px;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.search-field:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
  outline: none;
}

.search-submit { border-radius: var(--radius-full); }

#ez-toc-container,
.ez-toc-container {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  border-top: 4px solid var(--color-primary);
  box-shadow: var(--shadow-sm);
  padding: var(--space-lg);
}

.ez-toc-title {
  border-bottom: 2px solid var(--color-surface-subtle);
  color: var(--color-text-dark);
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
}

#ez-toc-container a {
  color: var(--color-text-muted);
  display: inline-block;
  font-weight: 500;
  text-decoration: none;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

#ez-toc-container a:hover {
  color: var(--color-primary);
  transform: translateX(4px);
}

/* ==========================================================================
   9. BUTTONS & UI CONTROLS
   ========================================================================== */

a.read-more,
.read-more-container a {
  align-items: center;
  background-color: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-main);
  display: inline-flex;
  font-size: var(--text-sm);
  font-weight: 700;
  padding: 8px 18px;
  text-decoration: none;
  transition: background-color var(--transition-fast),
    color var(--transition-fast),
    transform var(--transition-fast);
}

a.read-more::after,
.read-more-container a::after {
  content: "→";
  margin-left: 6px;
  transition: transform var(--transition-fast);
}

a.read-more:hover,
.read-more-container a:hover {
  background-color: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
  transform: translateY(-1px);
}

a.read-more:hover::after,
.read-more-container a:hover::after { transform: translateX(3px); }

a.generate-back-to-top {
  align-items: center;
  background-color: var(--color-primary);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-md);
  display: flex;
  height: 44px;
  justify-content: center;
  transition: background-color var(--transition-fast),
    transform var(--transition-fast),
    box-shadow var(--transition-fast);
  width: 44px;
}

a.generate-back-to-top:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

/* ==========================================================================
   10. DESKTOP STICKY SIDEBAR
   ========================================================================== */

@media (min-width: 1024px) {
  .inside-right-sidebar {
    height: calc(100% - 40px);
  }
  .inside-right-sidebar .widget:last-child {
    position: sticky;
    top: var(--header-height);
  }
}

/* ==========================================================================
   11. MOBILE / TABLET
   ========================================================================== */

@media (max-width: 768px) {
  .single-post .inside-article {
    border-radius: var(--radius-md);
    padding: var(--space-lg);
  }

  .sidebar .widget,
  .widget-area .widget { --widget-pad: 20px; }

  .sidebar .widget .widget-title,
  .sidebar .widget h2,
  .sidebar .widget h3,
  .sidebar .widget h4 {
    font-size: var(--text-base);
    padding: 12px var(--widget-pad);
  }

  .entry-content th,
  .entry-content td {
    font-size: var(--text-sm);
    min-width: 130px;
    padding: 10px 12px;
    white-space: normal;
  }

  /* Optimized Mobile Table Scroll */
  .entry-content .wp-block-table {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Custom Scrollbar for better visibility */
  .entry-content .wp-block-table::-webkit-scrollbar {
    height: 6px;
  }
  
  .entry-content .wp-block-table::-webkit-scrollbar-track {
    background: var(--color-surface-subtle);
    border-radius: var(--radius-full);
  }

  .entry-content .wp-block-table::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
  }
}

/* ==========================================================================
   12. PRINT
   ========================================================================== */

@media print {
  .site-header,
  .sidebar,
  .widget-area,
  .adsbygoogle,
  a.generate-back-to-top,
  .entry-meta,
  #ez-toc-container {
    display: none !important;
  }

  .single-post .inside-article {
    box-shadow: none;
    padding: 0;
  }

  .entry-content a {
    color: var(--color-text-dark);
    text-decoration: underline;
  }

  .entry-content a[href^="http"]::after {
    color: var(--color-text-muted);
    content: " (" attr(href) ")";
    font-size: 0.85em;
  }
}