/* ================================================
   KNOWLEDGE CENTER - SHARED STYLES
   free-english.co.il
   ================================================ */

@import url('https://fonts.googleapis.com/css2?family=Andika:ital,wght@0,400;0,700;1,400;1,700&display=swap');

/* --- Category color variables --- */
:root {
  --kc-vocab: #d97706;
  --kc-vocab-light: #fef3c7;
  --kc-grammar: #0284c7;
  --kc-grammar-light: #e0f2fe;
  --kc-pronunciation: #ea580c;
  --kc-pronunciation-light: #ffedd5;
  --kc-tips: #16a34a;
  --kc-tips-light: #dcfce7;
  --kc-reading: #7c3aed;
  --kc-reading-light: #ede9fe;
}

body, html {
  font-family: 'Andika', 'Rubik', sans-serif !important;
}

/* ---- Reading Progress Bar ---- */
#kc-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  z-index: 9999;
  pointer-events: none;
}

#kc-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #F0C42A 0%, #67C2E1 100%);
  transition: width 0.12s ease;
  border-radius: 0 2px 2px 0;
}

/* ---- Breadcrumb ---- */
.kc-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.83rem;
  color: #94a3b8;
  padding: 1.5rem 0 0;
  flex-wrap: wrap;
}

.kc-breadcrumb a {
  color: #94a3b8;
  text-decoration: none;
  transition: color 0.15s;
}

.kc-breadcrumb a:hover {
  color: #1E6A3A;
}

.kc-breadcrumb-sep {
  color: #cbd5e0;
  font-size: 0.7rem;
}

/* ---- Category Badge ---- */
.kc-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.22rem 0.7rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* --- Category Icons --- */
.kc-cat-icon {
  width: 1.1em;
  height: 1.1em;
  vertical-align: middle;
  margin-inline-end: 0; /* Handled by flex gap */
  stroke-width: 2.5px;
  flex-shrink: 0;
}

.kc-badge .kc-cat-icon {
  width: 1em;
  height: 1em;
}

.kc-badge-vocab {
  background: var(--kc-vocab-light);
  color: var(--kc-vocab);
}

.kc-badge-grammar {
  background: var(--kc-grammar-light);
  color: var(--kc-grammar);
}

.kc-badge-pronunciation {
  background: var(--kc-pronunciation-light);
  color: var(--kc-pronunciation);
}

.kc-badge-tips {
  background: var(--kc-tips-light);
  color: var(--kc-tips);
}

.kc-badge-reading {
  background: var(--kc-reading-light);
  color: var(--kc-reading);
}

/* ---- Meta info (read time, etc.) ---- */
.kc-meta {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: 0.83rem;
  color: #94a3b8;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.kc-meta-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* ---- Article outer container ---- */
.kc-article-outer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 1.5rem 5rem;
}

/* ---- Two-column layout (content + TOC) ---- */
.kc-layout {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 2.5rem;
  align-items: start;
  margin-top: 2rem;
}

@media (max-width: 880px) {
  .kc-layout {
    grid-template-columns: 1fr;
  }

  .kc-toc-sidebar {
    display: none;
  }
}

/* ---- Article content typography ---- */
.kc-content {
  min-width: 0;
}

.kc-content h2 {
  font-size: 1.45rem;
  font-weight: 800;
  color: #1a2e4a;
  margin: 2.5rem 0 0.9rem;
  padding-bottom: 0.6rem;
  border-bottom: 2px solid #f0f4f8;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  line-height: 1.3;
}

.kc-content h2 .kc-h2-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #67C2E1, #38bdf8);
  color: white;
  border-radius: 50%;
  font-size: 0.85rem;
  font-weight: 900;
  flex-shrink: 0;
}

.kc-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #334155;
  margin: 1.75rem 0 0.6rem;
}

.kc-content p {
  font-size: 1.05rem;
  line-height: 1.85;
  color: #374151;
  margin-bottom: 1.1rem;
}

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

.kc-content li {
  font-size: 1.02rem;
  line-height: 1.8;
  color: #374151;
  margin-bottom: 0.4rem;
}

strong {
  font-weight: 700;
}

/* ---- Callout Boxes ---- */
.kc-tip,
.kc-example,
.kc-warning,
.kc-key {
  border-radius: 12px;
  padding: 1.1rem 1.4rem;
  margin: 1.5rem 0;
  display: flex;
  gap: 0.85rem;
  align-items: flex-start;
  font-size: 1rem;
  line-height: 1.75;
}

.kc-box-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

.kc-tip {
  background: #f0fdf4;
  border-right: 4px solid #16a34a;
  color: #14532d;
}

.kc-key {
  background: #fefce8;
  border-right: 4px solid #F0C42A;
  color: #78350f;
}

.kc-warning {
  background: #fff7ed;
  border-right: 4px solid #f97316;
  color: #7c2d12;
}

.kc-example {
  background: #f0f9ff;
  border-right: 4px solid #67C2E1;
  color: #0c4a6e;
  direction: ltr;
  text-align: left;
  font-family: 'Andika', sans-serif;
}

/* ---- Pull Quote ---- */
.kc-pull-quote {
  border-right: 5px solid #F0C42A;
  padding: 0.75rem 1.4rem;
  margin: 2rem 0;
  font-size: 1.15rem;
  font-weight: 600;
  color: #1a2e4a;
  background: #fefce8;
  border-radius: 0 10px 10px 0;
  line-height: 1.6;
}

/* ---- Wrong / Right example pairs ---- */
.kc-pair-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

@media (max-width: 580px) {
  .kc-pair-grid {
    grid-template-columns: 1fr;
  }
}

.kc-wrong,
.kc-right {
  border-radius: 10px;
  padding: 0.85rem 1.1rem;
  font-size: 0.95rem;
  direction: ltr;
  text-align: left;
  font-family: 'Andika', sans-serif;
  font-weight: 500;
  line-height: 1.6;
}

.kc-wrong {
  background: #fee2e2;
  border: 1.5px solid #fca5a5;
  color: #7f1d1d;
}

.kc-wrong::before {
  content: '✗ ';
  font-weight: 800;
  color: #ef4444;
}

.kc-right {
  background: #dcfce7;
  border: 1.5px solid #86efac;
  color: #14532d;
}

.kc-right::before {
  content: '✓ ';
  font-weight: 800;
  color: #16a34a;
}

/* ---- Key Takeaways Box ---- */
.kc-takeaways {
  background: linear-gradient(135deg, #1a2e4a 0%, #0f172a 100%);
  color: white;
  border-radius: 16px;
  padding: 1.75rem 2rem;
  margin: 2.5rem 0;
}

.kc-takeaways h3 {
  color: #F0C42A;
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.kc-takeaways ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.kc-takeaways li {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.85);
  line-height: 1.6;
}

.kc-takeaways li::before {
  content: '✓';
  color: #F0C42A;
  font-weight: 700;
  flex-shrink: 0;
  margin-top: 0.15rem;
}

/* ---- TOC Sidebar ---- */
.kc-toc-sidebar {
  position: sticky;
  top: 78px;
}

.kc-toc-inner {
  background: white;
  border-radius: 14px;
  border: 1.5px solid #f0f4f8;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 2px 14px rgba(0, 0, 0, 0.05);
}

.kc-toc-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #94a3b8;
  margin-bottom: 0.8rem;
}

.kc-toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.kc-toc-list a {
  display: block;
  padding: 0.42rem 0.6rem;
  font-size: 0.85rem;
  color: #64748b;
  border-radius: 7px;
  text-decoration: none;
  border-right: 2px solid transparent;
  transition: all 0.15s ease;
  line-height: 1.45;
}

.kc-toc-list a:hover,
.kc-toc-list a.kc-active {
  background: #f0fdf4;
  color: #1E6A3A;
  border-right-color: #1E6A3A;
}

/* ---- Related Articles ---- */
.kc-related {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid #f0f4f8;
}

.kc-related-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #1a2e4a;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

@media (max-width: 580px) {
  .kc-related-grid {
    grid-template-columns: 1fr;
  }
}

.kc-related-card {
  background: white;
  border-radius: 12px;
  border: 1.5px solid #f0f4f8;
  padding: 1.1rem 1.25rem;
  text-decoration: none;
  color: inherit;
  transition: all 0.22s ease;
  display: block;
}

.kc-related-card:hover {
  border-color: #67C2E1;
  box-shadow: 0 4px 20px rgba(103, 194, 225, 0.15);
  transform: translateY(-2px);
  color: inherit;
}

.kc-related-card-cat {
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 0.35rem;
  display: block;
}

.kc-related-card-title {
  font-size: 0.93rem;
  font-weight: 700;
  color: #1a2e4a;
  line-height: 1.45;
}

.kc-related-card-time {
  font-size: 0.78rem;
  color: #94a3b8;
  margin-top: 0.35rem;
  display: block;
}

/* ---- Article Hero (Standardized) ---- */
.kc-article-hero {
  --hero-bg-1: #f8fafc;
  --hero-bg-2: #f1f5f9;
  --hero-border: #e2e8f0;
  --hero-pattern: rgba(148, 163, 184, 0.05);
  
  background: linear-gradient(160deg, var(--hero-bg-1) 0%, var(--hero-bg-2) 100%);
  padding: 3.5rem 1.5rem 4rem;
  border-bottom: 2px solid var(--hero-border);
  position: relative;
  overflow: hidden;
}

/* Category Theme Overrides */
.kc-article-hero.kc-hero-vocab {
  --hero-bg-1: #fffbeb;
  --hero-bg-2: #fef3c7;
  --hero-border: #fde68a;
  --hero-pattern: rgba(217, 119, 6, 0.05);
}

.kc-article-hero.kc-hero-grammar {
  --hero-bg-1: #f0f9ff;
  --hero-bg-2: #e0f2fe;
  --hero-border: #bae6fd;
  --hero-pattern: rgba(2, 132, 199, 0.05);
}

.kc-article-hero.kc-hero-pronunciation {
  --hero-bg-1: #fff7ed;
  --hero-bg-2: #ffedd5;
  --hero-border: #fed7aa;
  --hero-pattern: rgba(234, 88, 12, 0.05);
}

.kc-article-hero.kc-hero-tips {
  --hero-bg-1: #f0fdf4;
  --hero-bg-2: #dcfce7;
  --hero-border: #bbf7d0;
  --hero-pattern: rgba(22, 163, 74, 0.05);
}

.kc-article-hero.kc-hero-reading {
  --hero-bg-1: #f5f3ff;
  --hero-bg-2: #ede9fe;
  --hero-border: #ddd6fe;
  --hero-pattern: rgba(124, 58, 237, 0.05);
}

.kc-article-hero.kc-hero-dark {
  --hero-bg-1: #0f172a;
  --hero-bg-2: #1e293b;
  --hero-border: #334155;
  --hero-pattern: rgba(255, 255, 255, 0.03);
  color: white;
}

.kc-article-hero.kc-hero-dark h1 { color: white; }
.kc-article-hero.kc-hero-dark .kc-intro { color: #94a3b8; }
.kc-article-hero.kc-hero-dark .kc-breadcrumb a { color: #64748b; }

.kc-article-hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(var(--hero-pattern) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.kc-article-hero::after {
  content: '';
  position: absolute;
  top: -20%;
  left: -10%;
  width: 40%;
  height: 140%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.4) 0%, transparent 70%);
  transform: rotate(-15deg);
  pointer-events: none;
}

.kc-article-hero-inner {
  max-width: 1100px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}

.kc-article-hero h1 {
  font-size: clamp(1.85rem, 4.5vw, 2.6rem);
  font-weight: 900;
  color: #1a2e4a;
  line-height: 1.25;
  margin: 1.25rem 0 1rem;
  letter-spacing: -0.01em;
}

.kc-article-hero .kc-intro {
  font-size: 1.15rem;
  color: #475569;
  line-height: 1.8;
  max-width: 780px;
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .kc-article-hero {
    padding: 2.5rem 1.25rem 3rem;
  }
}

/* ---- TTS Speak Button ---- */
/* Standard speaker icon utility */
.kc-icon-speaker {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  vertical-align: middle;
  flex-shrink: 0;
}

.kc-speak-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: #f1f5f9;
  border-radius: 50%;
  border: none;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
  vertical-align: middle;
  position: relative;
  padding: 0;
  overflow: hidden;
}

/* Default icon using ::after */
.kc-speak-btn::after {
  content: "";
  display: block;
  width: 16px;
  height: 16px;
  background-color: currentColor;
  -webkit-mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Cpath d='M3 9v6h4l5 5V4L7 9H3zm13.5 3c0-1.77-1.02-3.29-2.5-4.03v8.05c1.48-.73 2.5-2.25 2.5-4.02zM14 3.23v2.06c2.89.86 5 3.54 5 6.71s-2.11 5.85-5 6.71v2.06c4.01-.91 7-4.49 7-8.77s-2.99-7.86-7-8.77z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
}

.kc-speak-btn:hover {
  background: #4f46e5;
  color: white;
  transform: scale(1.1);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

/* Support for internal icon span - hide ::after if it exists */
.kc-speak-btn:has(.kc-icon-speaker)::after {
  display: none;
}

/* Allow internal icons if they exist */
.kc-speak-btn svg, 
.kc-speak-btn img,
.kc-speak-btn .inline-mic {
  width: 16px;
  height: 16px;
}

/* Ensure inline SVGs are visible if user adds them */
.kc-sound-example svg {
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
}

/* Support for internal icon span */
.kc-speak-btn .kc-icon-speaker {
  display: inline-block !important;
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Global SVG fixes for consistency */
.nav-icon {
  width: 20px;
  height: 20px;
}

.kc-cat-icon {
  width: 1.1em;
  height: 1.1em;
  max-width: 24px;
  max-height: 24px;
}

/* Ensure parents can contain the button nicely */
.kc-wrong,
.kc-right,
.kc-practice-word,
.kc-compare-text,
.kc-sound-symbol {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.kc-practice-word {
  display: inline-flex !important;
}

/* ---- Rule / Emphasized text ---- */
.kc-rule {
  border-right: 4px solid var(--kc-grammar);
  padding: 1rem 1.25rem;
  background: #f8fafc;
  border-radius: 0 8px 8px 0;
  margin: 1.5rem 0;
}

/* ========================================================
   MOBILE RESPONSIVENESS, OVERFLOW & AD LAYOUT CORRECTIONS
   ======================================================== */

/* --- 1. Prevent Dynamic Google Adsense Overflow --- */
.kc-ad-container,
.kc-bottom-ad-container,
.adsbygoogle,
ins.adsbygoogle,
.google-ads-container {
  max-width: 100% !important;
  width: 100% !important;
  overflow: hidden !important;
  display: flow-root !important;
}

/* --- 2. Mobile Padding Optimization for Article Container --- */
@media (max-width: 640px) {
  .kc-article-outer {
    padding: 0 0.75rem 4rem !important;
  }
}

/* --- 3. Premium Responsive Stacked Vocabulary Tables for Mobile --- */
@media (max-width: 600px) {
  .vocab-category .vocab-table tr {
    display: flex !important;
    flex-direction: column !important;
    padding: 10px 14px !important;
    gap: 2px !important;
  }
  
  .vocab-category .vocab-table td {
    display: flow-root !important;
    width: 100% !important;
    padding: 0 !important;
    box-sizing: border-box !important;
  }
  
  .vocab-category .vocab-eng {
    font-size: 1.05rem !important;
  }
  
  .vocab-category .vocab-heb {
    text-align: right !important;
    color: #64748b !important;
    font-size: 0.92rem !important;
    margin-top: 2px !important;
  }
  
  .vocab-category .kc-speak-btn {
    width: 28px !important;
    height: 28px !important;
  }
  
  .vocab-category .kc-speak-btn::after,
  .vocab-category .kc-speak-btn .kc-icon-speaker {
    width: 14px !important;
    height: 14px !important;
  }
}

/* Fix for vocab-eng table cells alignment without flex */
.vocab-eng, .v-word, .v-word-col {
  display: table-cell !important; /* For desktop, keep table structure */
  vertical-align: middle;
  position: relative;
  padding-right: 45px !important; /* Make room for the absolute button */
}

/* Absolute positioning for desktop keeps the cell behaving perfectly */
.vocab-eng .kc-speak-btn, .v-word .kc-speak-btn, .v-word-col .kc-speak-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0 !important;
  float: none !important;
}

/* Ensure mobile layout for vocab-eng is flex and 100% width */
@media (max-width: 600px) {
  .vocab-category .vocab-eng,
  .vocab-table-container .v-word,
  .vocab-table-full-container .v-word-col {
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding-right: 14px !important; /* Restore normal padding */
  }
  
  .vocab-category .vocab-eng .kc-speak-btn,
  .vocab-table-container .v-word .kc-speak-btn,
  .vocab-table-full-container .v-word-col .kc-speak-btn {
    position: static !important;
    transform: none !important;
  }
}
