/* ==========================================================================
   TEKWALA PRODUCTION CSS — v4 (ULTIMATE OPTIMIZED)
   Optimized • Responsive • Accessible • Premium Sidebar
   ========================================================================== */

/* ==========================================================================
   0. DESIGN TOKENS & SYSTEM BASE
   ========================================================================== */

:root {
  /* Brand & Interactive */
  --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;

  /* Typography */
  --color-text-main: #2d3748;
  --color-text-dark: #0f172a;
  --color-text-muted: #64748b;

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

  /* Typography Scale */
  --text-xs: 0.75rem;    /* 12px */
  --text-sm: 0.875rem;   /* 14px */
  --text-base: 1.125rem; /* 18px */
  --text-lg: 1.25rem;    /* 20px */
  --text-xl: 1.5rem;     /* 24px */
  --text-2xl: 1.75rem;   /* 28px */

  /* Spacing Variables */
  --space-sm: 0.5rem;   /* 8px */
  --space-md: 1rem;     /* 16px */
  --space-lg: 1.5rem;   /* 24px */
  --space-xl: 2.25rem;  /* 36px */

  /* 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);
}

/* ==========================================================================
   GLOBAL & ACCESSIBILITY
   ========================================================================== */

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

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

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;
}

/* ==========================================================================
   1. HEADER & NAVIGATION
   ========================================================================== */

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

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

/* ==========================================================================
   2. 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 .inside-article:hover,
.blog .inside-article:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-lg);
  transform: translateY(-4px);
}

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

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

.inside-article:hover .post-image img { transform: scale(1.03); }

/* ==========================================================================
   3. SINGLE POST CONTENT & 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.75;
}

.single-post h1.entry-title {
  color: var(--color-text-dark);
  font-size: clamp(2rem, 4vw + 1rem, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.single-post .entry-content h2 {
  border-left: 4px solid var(--color-primary);
  color: var(--color-text-dark);
  font-size: clamp(1.4rem, 2.5vw + 0.5rem, var(--text-2xl));
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 2em 0 0.75em;
  padding-left: var(--space-sm);
}

.single-post .entry-content h3 {
  color: var(--color-text-dark);
  font-size: clamp(1.2rem, 2vw + 0.25rem, var(--text-xl));
  font-weight: 700;
  margin: 1.75em 0 0.75em;
}

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

/* CONTENT LINKS */
.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);
}

/* LISTS & HR */
.entry-content ol li,
.entry-content ul li {
  line-height: 1.7;
  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;
}

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

/* ==========================================================================
   4. META & BADGES
   ========================================================================== */

.entry-meta {
  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;
  letter-spacing: 0.3px;
  padding: 4px 10px;
}

.posted-on .published { background: var(--color-primary-light); color: var(--color-primary); }
.posted-on .published::before { content: "Published: "; }

.posted-on .updated { background: #ecfdf5; color: #059669; }
.posted-on .updated::before { content: "Updated: "; }

.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;
  letter-spacing: 0.3px;
  padding: 4px 12px;
  text-decoration: none;
  text-transform: uppercase;
  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: #ffffff;
  transform: translateY(-1px);
}

/* ==========================================================================
   5. DATA TABLES (GUTENBERG OPTIMIZED & MERGED)
   ========================================================================== */

/* The WordPress Block Wrapper - This handles the scrolling now */
.single-post .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; /* Scroll enabled strictly on wrapper */
  -webkit-overflow-scrolling: touch;
  width: 100%;
}

.single-post .entry-content table {
  border-collapse: collapse;
  margin: 0;
  width: 100%;
}

.single-post .entry-content table thead th,
.single-post .entry-content table thead td {
  background: 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;
  letter-spacing: 0.5px;
  padding: 14px 18px;
  text-align: left;
  text-transform: uppercase;
}

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

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

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

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: italic;
  margin: 2rem 0;
  padding: 1.25rem 1.5rem 1.25rem 2rem;
  position: relative;
}

.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;
  margin-bottom: 0.5rem;
}

.rank-math-answer, .faq-answer {
  color: var(--color-text-muted);
  font-size: var(--text-sm);
  line-height: 1.6;
}

/* ==========================================================================
   6. SIDEBAR & WIDGETS
   ========================================================================== */

.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);
  padding: var(--widget-pad);
  overflow: hidden; 
}

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

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

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

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

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

.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);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: color var(--transition-fast);
  flex-grow: 1;
}

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

.sidebar .widget_categories { padding: var(--space-lg); }
.sidebar .widget_categories ul { list-style: none; padding: 0; margin: 0; }

.sidebar .widget_categories ul li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 10px;
  background: var(--color-bg-body);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  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 { margin-bottom: 0; }

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

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

.sidebar .widget_categories ul li:hover {
  background: #ffffff;
  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 { 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); }

/* TABLE OF CONTENTS */
#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);
  font-weight: 500;
  text-decoration: none;
  display: inline-block;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

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

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

a.read-more, .read-more-container a {
  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;
  align-items: center;
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 8px 18px;
  text-decoration: none;
  text-transform: uppercase;
  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: #ffffff;
  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);
}

/* ==========================================================================
   8. DESKTOP SIDEBAR
   ========================================================================== */

@media (min-width: 1024px) {
  .right-sidebar .sidebar, .widget-area {
    position: sticky;
    top: 90px;
  }
}

/* ==========================================================================
   9. MOBILE / TABLET (Unified Single Block)
   ========================================================================== */

@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 {
    font-size: var(--text-base);
    padding: 12px var(--widget-pad);
  }

  /* Table Mobile Layout - Unified from your appended code */
  .single-post .entry-content th, 
  .single-post .entry-content td {
    /* nowrap ensures text stays on one line so horizontal scroll triggers properly */
    white-space: nowrap; 
    min-width: 120px; 
    padding: 10px;
    font-size: var(--text-sm);
  }

  /* PRO SCROLL SHADOW (Works perfectly with .wp-block-table) */
  .wp-block-table {
    background-image:
      linear-gradient(to right, var(--color-surface) 30%, rgba(255, 255, 255, 0)),
      linear-gradient(to right, rgba(255, 255, 255, 0), var(--color-surface) 70%),
      radial-gradient(farthest-side at 0 50%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0)),
      radial-gradient(farthest-side at 100% 50%, rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-position: 0 0, 100% 0, 0 0, 100% 0;
    background-attachment: local, local, scroll, scroll;
  }
}

/* ==========================================================================
   10. PRINT STYLES
   ========================================================================== */

@media print {
  .site-header,
  .sidebar,
  .widget-area,
  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 {
    content: " (" attr(href) ")";
    font-size: 0.85em;
    color: var(--color-text-muted);
  }
}