/**
 * KE Leaders — course description typography (free, child-theme CSS).
 *
 * Normalises pasted Word / Google Docs / ChatGPT markup inside the
 * single-product description tabs only. Does not restyle the hero,
 * tabs chrome, forms, dates table, or WhatsApp buttons.
 *
 * Palette (matches the live aubergine homepage):
 *   plum #3D2438, deep plum #24141E, text #1F161A,
 *   muted #5A3A48, text-safe gold #7A5420, ivory #FBF7F0.
 *
 * Fonts: Montserrat is already loaded by Astra on product pages, so
 * descriptions stay consistent with the course chrome. Arabic pages
 * fall back to Cairo (enqueued by ke-course-typography.php when RTL).
 *
 * Rollback: remove this file (or stop enqueueing it) and purge LiteSpeed.
 * No other theme file needs restoring if the helpers file was not edited.
 */

body.single-product .ke-prose,
body.single-product #tab-description,
body.single-product .woocommerce-Tabs-panel--description,
body.single-product .woocommerce-product-details__short-description {
  --ke-type-text: #1F161A;
  --ke-type-muted: #5A3A48;
  --ke-type-heading: #3D2438;
  --ke-type-deep: #24141E;
  --ke-type-accent: #7A5420;
  --ke-type-ivory: #FBF7F0;
  --ke-type-line: #E8D9C8;
  font-family: Montserrat, "Segoe UI", Tahoma, sans-serif !important;
  font-size: 16px;
  line-height: 1.7;
  color: #1F161A;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Arabic / RTL: Cairo is an Arabic-friendly companion already in the child theme. */
html[lang^="ar"] body.single-product .ke-prose,
html[lang^="ar"] body.single-product #tab-description,
html[lang^="ar"] body.single-product .woocommerce-Tabs-panel--description,
html[lang^="ar"] body.single-product .woocommerce-product-details__short-description,
body.rtl.single-product .ke-prose,
body.rtl.single-product #tab-description,
body[class*="translatepress-ar"].single-product .ke-prose,
body[class*="translatepress-ar"].single-product #tab-description {
  font-family: Cairo, Tahoma, "Segoe UI", sans-serif;
}

/* Tight, professional heading scale — overrides Astra's 48/40/32/24/20/17px
   so a pasted H6 subtitle and a pasted H2 section title sit in one family. */
body.single-product .ke-prose :is(h1, h2, h3, h4, h5, h6),
body.single-product #tab-description :is(h1, h2, h3, h4, h5, h6),
body.single-product .woocommerce-Tabs-panel--description :is(h1, h2, h3, h4, h5, h6) {
  font-family: inherit !important;
  color: #3D2438 !important;
  letter-spacing: -0.02em;
  line-height: 1.35;
  text-transform: none;
  background: none !important;
  border: 0;
  padding: 0;
}

body.single-product .ke-prose h1,
body.single-product #tab-description h1,
body.single-product .woocommerce-Tabs-panel--description h1 {
  font-size: 24px !important;
  font-weight: 700 !important;
  margin: 0 0 0.75rem !important;
}

body.single-product .ke-prose h2,
body.single-product #tab-description h2,
body.single-product .woocommerce-Tabs-panel--description h2 {
  font-size: 22px !important;
  font-weight: 700 !important;
  margin: 1.75rem 0 0.55rem !important;
}

body.single-product .ke-prose h3,
body.single-product #tab-description h3,
body.single-product .woocommerce-Tabs-panel--description h3 {
  font-size: 19px !important;
  font-weight: 600 !important;
  margin: 1.45rem 0 0.45rem !important;
}

body.single-product .ke-prose :is(h4, h5, h6),
body.single-product #tab-description :is(h4, h5, h6),
body.single-product .woocommerce-Tabs-panel--description :is(h4, h5, h6) {
  font-size: 17px !important;
  font-weight: 600 !important;
  letter-spacing: -0.01em;
  color: #24141E !important;
  margin: 1.2rem 0 0.4rem !important;
}

/* Common paste pattern: H2 title, then one or two H5/H6 deck lines. */
body.single-product .ke-prose h2 + :is(h5, h6),
body.single-product .ke-prose h2 + :is(h5, h6) + :is(h5, h6) {
  font-size: 17px !important;
  font-weight: 600 !important;
  color: #5A3A48 !important;
  letter-spacing: 0;
  margin-top: 0.15rem !important;
  margin-bottom: 0.2rem !important;
  line-height: 1.5;
}

body.single-product .ke-prose > :is(h1, h2, h3, h4, h5, h6):first-child {
  margin-top: 0 !important;
}

/* Hide empty heading tags left by paste artefacts. */
body.single-product .ke-prose :is(h1, h2, h3, h4, h5, h6):empty,
body.single-product #tab-description :is(h1, h2, h3, h4, h5, h6):empty {
  display: none !important;
  margin: 0 !important;
}

/* Empty ChatGPT / editor wrappers (the real content sits as siblings). */
body.single-product .ke-prose section[data-testid^="conversation-turn"]:empty,
body.single-product .ke-prose [data-turn-id]:empty,
body.single-product .ke-prose [class*="text-token-text-primary"]:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  min-height: 0 !important;
}

body.single-product .ke-prose p,
body.single-product #tab-description p,
body.single-product .woocommerce-Tabs-panel--description p {
  font-family: inherit !important;
  font-size: 16px !important;
  line-height: 1.7 !important;
  color: #1F161A !important;
  font-weight: 400 !important;
  margin: 0 0 0.85rem !important;
}

/* A paragraph that is only a bold run is almost always a pasted sub-heading. */
body.single-product .ke-prose p:has(> strong:only-child),
body.single-product .ke-prose p:has(> b:only-child) {
  font-size: 17px !important;
  line-height: 1.4 !important;
  margin: 1.2rem 0 0.4rem !important;
  color: #3D2438 !important;
}

body.single-product .ke-prose p:has(> strong:only-child) :is(strong, b),
body.single-product .ke-prose p:has(> b:only-child) :is(strong, b) {
  font-weight: 600 !important;
  color: #3D2438 !important;
}

body.single-product .ke-prose :is(ul, ol),
body.single-product #tab-description :is(ul, ol) {
  margin: 0.35rem 0 1.15rem 1.2rem !important;
  padding: 0;
}

body.single-product .ke-prose li,
body.single-product #tab-description li {
  font-family: inherit !important;
  font-size: 16px !important;
  line-height: 1.65 !important;
  color: #1F161A !important;
  font-weight: 400 !important;
  margin: 0 0 0.4rem !important;
  padding-inline-start: 0.2rem;
}

body.single-product .ke-prose ul {
  list-style: disc;
}

body.single-product .ke-prose ul > li::marker {
  color: #7A5420;
}

body.single-product .ke-prose li > :is(ul, ol) {
  margin: 0.35rem 0 0.35rem 1.1rem !important;
}

body.single-product .ke-prose :is(strong, b) {
  font-weight: 600;
  color: #24141E;
}

body.single-product .ke-prose :is(em, i) {
  font-style: italic;
}

body.single-product .ke-prose a {
  color: #7A5420;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

body.single-product .ke-prose a:hover,
body.single-product .ke-prose a:focus {
  color: #24141E;
}

/* Kill pasted typography on spans / <font> / residual [style] — typography
   properties only. Layout styles (grid, margin, max-width, display) stay. */
body.single-product .ke-prose :is(span, font, p, li, td, th, a, strong, b, em, i, label),
body.single-product #tab-description :is(span, font, p, li, td, th, a) {
  font-family: inherit !important;
}

body.single-product .ke-prose :is(span, font),
body.single-product #tab-description :is(span, font) {
  font-size: inherit !important;
  line-height: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  background: transparent !important;
  letter-spacing: inherit;
}

/* Do not let a pasted 12pt / Arial / #000 on a heading span shrink the heading. */
body.single-product .ke-prose :is(h1, h2, h3, h4, h5, h6) :is(span, font) {
  font-size: inherit !important;
  font-weight: inherit !important;
  color: inherit !important;
  line-height: inherit !important;
  font-family: inherit !important;
}

body.single-product .ke-prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  margin: 0.75rem 0 1.25rem;
}

body.single-product .ke-prose :is(th, td) {
  font-family: inherit !important;
  color: #1F161A !important;
  text-align: start;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid #E8D9C8;
  vertical-align: top;
}

body.single-product .ke-prose th {
  font-weight: 600;
  color: #3D2438 !important;
  background: #FBF7F0;
}

body.single-product .ke-prose blockquote {
  margin: 1rem 0;
  padding: 0.75rem 1rem;
  border-inline-start: 3px solid #7A5420;
  background: #FBF7F0;
  color: #1F161A;
  font-size: 1rem;
  line-height: 1.7;
}

body.single-product .ke-prose hr {
  border: 0;
  border-top: 1px solid #E8D9C8;
  margin: 1.5rem 0;
}

body.single-product .ke-prose img {
  max-width: 100%;
  height: auto;
}

@media (max-width: 767px) {
  body.single-product .ke-prose h1,
  body.single-product #tab-description h1 {
    font-size: 22px !important;
  }
  body.single-product .ke-prose h2,
  body.single-product #tab-description h2 {
    font-size: 20px !important;
  }
  body.single-product .ke-prose h3,
  body.single-product #tab-description h3 {
    font-size: 18px !important;
  }
  body.single-product .ke-prose :is(ul, ol),
  body.single-product #tab-description :is(ul, ol) {
    margin-inline-start: 1.1rem !important;
  }
}
