/**
 * Strategic Content Engine — Front-end styles.
 *
 * Reading layout, tables, featured image, in-content images and the FAQ
 * section, plus the E-E-A-T byline and author card.
 *
 * Everything is scoped to .sce-article, the wrapper SCE_Post_Display puts
 * around a generated post. Until 2.13.0 these rules hung off .entry-content
 * and .wp-block-post-content, which Hello Elementor (.page-content) and
 * Elementor's Post Content widget never output — so on most sites none of
 * it applied and tables fell back to the theme's reset.
 *
 * Colours are translucent black so they sit on any brand palette.
 *
 * @package StrategicContentEngine
 * @since   1.2.0
 */

/* ---- Reading layout (2.14.0) ------------------------------------------ */
/*
 * Switched on by the body class `sce-layout` (Settings → Article layout).
 * Fonts and colours stay the theme's; only --sce-accent adds brand colour.
 * Prose rules use child selectors: article text sits directly in
 * .sce-article, while the byline, FAQ and author card bring their own
 * headings and lists that must keep the styles further down.
 * The Elementor kit colours are not used: on most sites they were never
 * set and are still Elementor's default blue and green.
 */
.sce-layout .sce-article {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
  font-size: 1.0625rem;
  line-height: 1.75;
}

.sce-layout .sce-article > p {
  margin: 0 0 1.2em;
}

.sce-layout .sce-article > h2 {
  margin: 2.1em 0 0.6em;
  font-size: clamp(1.5rem, 2.2vw, 1.875rem);
  font-weight: 600;
  line-height: 1.3;
}

.sce-layout .sce-article > h3 {
  margin: 1.7em 0 0.5em;
  font-size: 1.3125rem;
  font-weight: 600;
  line-height: 1.4;
}

.sce-layout .sce-article > h2 + h3 {
  margin-top: 0.8em;
}

.sce-layout .sce-article > :is(p, ul, ol, blockquote) strong {
  font-weight: 600;
}

.sce-layout .sce-article > :is(p, ul, ol, blockquote) a {
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.sce-layout .sce-article > :is(ul, ol) {
  margin: 0 0 1.4em;
  padding-left: 1.4em;
}

.sce-layout .sce-article > :is(ul, ol) > li {
  margin: 0.4em 0;
  padding-left: 0.2em;
}

.sce-layout .sce-article > :is(ul, ol) > li::marker {
  color: var(--sce-accent, currentColor);
  font-weight: 600;
}

.sce-layout .sce-article > blockquote {
  margin: 1.8em 0;
  padding: 1.1em 1.4em;
  background: rgba(0, 0, 0, 0.035);
  border: 0;
  border-left: 4px solid var(--sce-accent, rgba(0, 0, 0, 0.18));
  border-radius: 0 12px 12px 0;
  font-size: 1em;
  font-style: normal;
}

.sce-layout .sce-article > blockquote p:last-child {
  margin-bottom: 0;
}

/*
 * The post title sits outside .sce-article, so it is aligned with the
 * column separately: the plain Hello Elementor page header, and the
 * Post Title widget of an Elementor single template. The title element is
 * targeted, not the widget: Elementor's container rules win on the widget.
 */
.sce-layout .site-main > .page-header .entry-title,
.sce-layout .elementor-location-single .elementor-widget-theme-post-title .elementor-heading-title {
  max-width: 780px;
  margin-left: auto;
  margin-right: auto;
}

/* Accent title band, only on the plain page header (no single template). */
.sce-layout.sce-has-accent .site-main > .page-header {
  margin-bottom: 3.5rem;
  padding: 4rem 20px;
  background: var(--sce-accent);
  box-shadow: 0 0 0 100vmax var(--sce-accent);
  clip-path: inset(0 -100vmax);
  text-align: center;
}

.sce-layout.sce-has-accent .site-main > .page-header .entry-title {
  color: var(--sce-accent-text, #fff);
}

/* ---- Tables ----------------------------------------------------------- */
.sce-article .sce-table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.75em 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
}

/*
 * Themes style bare <table> elements (Hello Elementor: a 1px border on every
 * cell, 15px padding, a grey tint on odd rows and on hover). Each property
 * below is set explicitly so that reset never shows through.
 */
.sce-article .sce-table-responsive table {
  width: auto;
  min-width: 100%;
  margin: 0;
  border: 0;
  border-collapse: collapse;
  border-spacing: 0;
  background: transparent;
  font-size: 0.95em;
  line-height: 1.5;
}

.sce-article .sce-table-responsive th,
.sce-article .sce-table-responsive td {
  padding: 0.8em 1.1em;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  text-align: left;
  vertical-align: top;
  background: transparent;
}

.sce-article .sce-table-responsive thead th {
  background: rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  font-weight: 600;
  white-space: nowrap;
}

.sce-article .sce-table-responsive tbody tr:nth-child(odd) > td,
.sce-article .sce-table-responsive tbody tr:nth-child(odd) > th,
.sce-article .sce-table-responsive tbody tr:hover > td,
.sce-article .sce-table-responsive tbody tr:hover > th {
  background: transparent;
}

.sce-article .sce-table-responsive tbody tr:nth-child(even) > td,
.sce-article .sce-table-responsive tbody tr:nth-child(even) > th {
  background: rgba(0, 0, 0, 0.02);
}

.sce-article .sce-table-responsive tbody tr:last-child > td,
.sce-article .sce-table-responsive tbody tr:last-child > th {
  border-bottom: 0;
}

/*
 * Hand-written posts (2.14.1, "Apply layout to: All blog posts") use the
 * block editor's table block instead of .sce-table-responsive. Same look;
 * the border sits on the table so the figure's caption stays outside it.
 */
.sce-layout .sce-article > .wp-block-table {
  margin: 1.75em 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.sce-layout .sce-article > .wp-block-table table {
  width: 100%;
  margin: 0;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 10px;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  background: transparent;
  font-size: 0.95em;
  line-height: 1.5;
}

.sce-layout .sce-article > .wp-block-table :is(th, td) {
  padding: 0.8em 1.1em;
  border: 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  text-align: left;
  vertical-align: top;
  background: transparent;
}

.sce-layout .sce-article > .wp-block-table thead :is(th, td) {
  background: rgba(0, 0, 0, 0.04);
  border-bottom: 1px solid rgba(0, 0, 0, 0.12);
  font-weight: 600;
}

.sce-layout .sce-article > .wp-block-table tbody tr:nth-child(odd) > :is(th, td),
.sce-layout .sce-article > .wp-block-table tbody tr:hover > :is(th, td) {
  background: transparent;
}

.sce-layout .sce-article > .wp-block-table tbody tr:nth-child(even) > :is(th, td) {
  background: rgba(0, 0, 0, 0.02);
}

.sce-layout .sce-article > .wp-block-table tbody tr:last-child > :is(th, td) {
  border-bottom: 0;
}

.sce-layout .sce-article > .wp-block-table figcaption {
  margin-top: 0.5em;
  font-size: 0.85em;
  color: rgba(0, 0, 0, 0.55);
  text-align: center;
  font-style: italic;
}

@media (max-width: 768px) {
  .sce-layout .sce-article > .wp-block-table table {
    min-width: 500px;
  }
}

/* ---- Featured image --------------------------------------------------- */
/*
 * Images are server-side cropped to 16:9 during upload, so no CSS
 * aspect-ratio forcing is needed. .sce-featured-image is the copy
 * SCE_Post_Display adds when the theme leaves the image out.
 */
.post-thumbnail img,
.wp-post-image,
img.wp-post-image {
  width: 100%;
  height: auto;
}

.sce-article .sce-featured-image {
  margin: 0 0 2.25em;
}

.sce-article .sce-featured-image img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  margin: 0;
  border-radius: 10px;
}

/* ---- In-content images ------------------------------------------------ */
.sce-article .wp-block-image {
  margin: 1.75em 0;
  clear: both;
}

.sce-article .wp-block-image img {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.sce-article .wp-block-image figcaption {
  margin-top: 0.5em;
  font-size: 0.85em;
  color: rgba(0, 0, 0, 0.55);
  text-align: center;
  font-style: italic;
}

/* Center-aligned images: constrained width, centered */
.sce-article .wp-block-image.aligncenter {
  margin-left: auto;
  margin-right: auto;
  text-align: center;
  max-width: 100%;
}

/* Right-floated images: smaller, text wraps around them */
.sce-article .wp-block-image.alignright {
  float: right;
  max-width: 340px;
  margin: 0.25em 0 1em 1.5em;
  clear: right;
}

/* Clearfix for float containers */
.sce-article::after {
  content: "";
  display: table;
  clear: both;
}

/* ---- FAQ section ------------------------------------------------------ */
.sce-article .sce-faq-section {
  margin: 2.5em 0;
  padding: 1.75em 2em;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
}

.sce-article .sce-faq-section h2 {
  margin-top: 0;
}

.sce-article .sce-faq-section .sce-faq-list {
  margin: 1em 0 0;
  padding-left: 1.25em;
}

.sce-article .sce-faq-section .sce-faq-list li {
  margin-bottom: 1.25em;
  padding-bottom: 1.25em;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.sce-article .sce-faq-section .sce-faq-list li:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.sce-article .sce-faq-section .sce-faq-list li p {
  margin: 0;
}

.sce-article .sce-faq-section .sce-faq-list li p:first-child {
  margin-bottom: 0.35em;
}

/* ---- Mobile responsive ------------------------------------------------ */
@media (max-width: 768px) {
  .sce-article .sce-table-responsive table {
    min-width: 500px;
  }

  /* Stack floated images on small screens */
  .sce-article .wp-block-image.alignright {
    float: none;
    max-width: 100%;
    margin: 1em 0;
  }

  .sce-article .sce-faq-section {
    padding: 1.25em 1.25em;
  }
}

/* ---- E-E-A-T byline + author card ------------------------------------ */

.sce-byline {
  display: flex;
  align-items: center;
  gap: 1.1em;
  margin: 0 0 2.5em;
  padding: 1.1em 1.25em;
  background: rgba(0, 0, 0, 0.025);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 10px;
  font-size: 0.95em;
  line-height: 1.45;
}

.sce-byline__avatar img {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* The site-icon fallback is usually a logo on a coloured background.
   A square-ish badge looks better than a forced circle in that case. */
.sce-byline__avatar--fallback img {
  border-radius: 8px;
  object-fit: contain;
  background: #fff;
  padding: 4px;
}

.sce-byline__meta {
  display: flex;
  flex-direction: column;
  gap: 0.25em;
  min-width: 0;
}

.sce-byline__author {
  font-size: 1em;
}

.sce-byline__author a {
  font-weight: 600;
  text-decoration: none;
}

.sce-byline__author a:hover {
  text-decoration: underline;
}

.sce-byline__role {
  color: rgba(0, 0, 0, 0.65);
}

.sce-byline__dates {
  font-size: 0.85em;
  color: rgba(0, 0, 0, 0.55);
}

.sce-author-card {
  display: block;
  margin: 3.5em 0 1.5em;
  padding: 2em 2.25em;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 14px;
  font-size: 0.96em;
  line-height: 1.65;
}

.sce-author-card__head {
  display: flex;
  align-items: center;
  gap: 1.5em;
  margin: 0 0 1.25em;
}

.sce-author-card__photo {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* When the favicon is used as a fallback, a soft rounded square reads
   better than a forced circle (favicons are rarely round-safe). */
.sce-author-card__photo--fallback {
  border-radius: 16px;
  object-fit: contain;
  background: #fff;
  padding: 10px;
}

.sce-author-card__title {
  min-width: 0;
}

.sce-author-card__name {
  margin: 0;
  font-size: 1.3em;
  font-weight: 700;
  line-height: 1.25;
}

.sce-author-card__role {
  margin: 0.35em 0 0;
  color: rgba(0, 0, 0, 0.65);
  font-size: 0.95em;
}

.sce-author-card__bio {
  margin: 0.75em 0 1.5em;
  font-size: 1em;
}

.sce-author-card__facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.5em 1.25em;
  margin: 0 0 1.5em;
  padding: 1em 0;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
  font-size: 0.9em;
}

.sce-author-card__facts dt {
  font-weight: 600;
  color: rgba(0, 0, 0, 0.7);
  margin: 0;
  align-self: start;
}

.sce-author-card__facts dd {
  margin: 0;
}

.sce-author-card__facts ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sce-author-card__facts li {
  display: inline;
}

.sce-author-card__facts li + li::before {
  content: " · ";
  color: rgba(0, 0, 0, 0.35);
}

.sce-author-card__tags li {
  display: inline-block;
  margin: 0.15em 0.35em 0.15em 0;
  padding: 0.2em 0.7em;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  font-size: 0.9em;
}

.sce-author-card__tags li + li::before {
  content: none;
}

.sce-author-card__links {
  list-style: none;
  margin: 0 0 1.25em;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55em 0.75em;
}

.sce-author-card__links li {
  margin: 0;
}

.sce-author-card__links a {
  display: inline-block;
  font-size: 0.88em;
  font-weight: 500;
  text-decoration: none;
  padding: 0.35em 0.85em;
  border: 1px solid rgba(0, 0, 0, 0.18);
  border-radius: 999px;
  transition: background 120ms ease, border-color 120ms ease;
}

.sce-author-card__links a:hover {
  background: rgba(0, 0, 0, 0.05);
  border-color: rgba(0, 0, 0, 0.3);
}

.sce-author-card__publisher {
  margin: 0;
  padding-top: 1em;
  border-top: 1px solid rgba(0, 0, 0, 0.07);
  font-size: 0.88em;
  color: rgba(0, 0, 0, 0.6);
}

/* AI-transparency disclosure on Organization-authored articles. */
.sce-author-card__disclosure {
  margin: 1.25em 0 0;
  padding: 0.85em 1em;
  background: rgba(0, 102, 204, 0.05);
  border-left: 3px solid rgba(0, 102, 204, 0.4);
  border-radius: 4px;
  font-size: 0.85em;
  line-height: 1.55;
  color: rgba(0, 0, 0, 0.7);
}

.sce-byline__avatar--org img,
.sce-author-card__photo--org {
  border-radius: 12px;
  object-fit: contain;
  background: #fff;
  padding: 6px;
}

/* Mobile: stack the bio card head and reduce padding. */
@media (max-width: 600px) {
  .sce-byline {
    padding: 0.9em 1em;
    gap: 0.85em;
  }

  .sce-byline__avatar img {
    width: 48px;
    height: 48px;
  }

  .sce-author-card {
    padding: 1.5em 1.25em;
  }

  .sce-author-card__head {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.85em;
  }

  .sce-author-card__photo {
    width: 88px;
    height: 88px;
  }

  .sce-author-card__facts {
    grid-template-columns: 1fr;
    gap: 0.25em 0;
  }

  .sce-author-card__facts dt {
    margin-top: 0.5em;
  }

  .sce-author-card__facts dt:first-of-type {
    margin-top: 0;
  }
}
