/**
 * Strategic Content Engine — Front-end styles.
 *
 * Table styling + image layout + FAQ section styling.
 * All other content elements (headings, paragraphs, blockquotes,
 * lists) are handled by the active WordPress theme.
 *
 * @package StrategicContentEngine
 * @since   1.2.0
 */

/* ---- Tables ----------------------------------------------------------- */
.sce-table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 1.5em 0;
}

/*
 * When a table lives inside the scroll wrapper, give it back auto width so it
 * can exceed the container width (enabling horizontal scroll). min-width: 100%
 * keeps narrow tables filling the container. These selectors are more specific
 * than ".entry-content table" below, so they win the cascade.
 */
.entry-content .sce-table-responsive table,
.wp-block-post-content .sce-table-responsive table {
  margin: 0;
  width: auto;
  min-width: 100%;
}

.entry-content table,
.wp-block-post-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5em 0;
  font-size: 0.95em;
}

.entry-content table th,
.wp-block-post-content table th {
  background-color: #f1f5f9;
  font-weight: 600;
  text-align: left;
  padding: 0.75em 1em;
  border-bottom: 2px solid #cbd5e1;
}

.entry-content table td,
.wp-block-post-content table td {
  padding: 0.75em 1.25em;
  border-bottom: 1px solid #e2e8f0;
  border-right: 1px solid #e2e8f0;
}

.entry-content table td:last-child,
.wp-block-post-content table td:last-child {
  border-right: none;
}

.entry-content table th,
.wp-block-post-content table th {
  border-right: 1px solid #cbd5e1;
}

.entry-content table th:last-child,
.wp-block-post-content table th:last-child {
  border-right: none;
}

.entry-content table tbody tr:nth-child(even),
.wp-block-post-content table tbody tr:nth-child(even) {
  background-color: #f8fafc;
}

/* ---- Featured image --------------------------------------------------- */
/*
 * Images are server-side cropped to 16:9 during upload, so no CSS
 * aspect-ratio forcing is needed. This prevents the browser from
 * cutting off parts of the image.
 */
.post-thumbnail img,
.wp-post-image,
img.wp-post-image {
  width: 100%;
  height: auto;
}

/* ---- In-content images ------------------------------------------------ */
.entry-content .wp-block-image,
.wp-block-post-content .wp-block-image {
  margin: 1.5em 0;
  clear: both;
}

.entry-content .wp-block-image img,
.wp-block-post-content .wp-block-image img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
  display: block;
}

.entry-content .wp-block-image figcaption,
.wp-block-post-content .wp-block-image figcaption {
  font-size: 0.85em;
  color: #64748b;
  margin-top: 0.5em;
  text-align: center;
  font-style: italic;
}

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

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

/* Clearfix for float containers */
.entry-content::after,
.wp-block-post-content::after {
  content: "";
  display: table;
  clear: both;
}

/* ---- FAQ section ------------------------------------------------------ */
.entry-content .sce-faq-section,
.wp-block-post-content .sce-faq-section {
  background-color: #f8fafc;
  border-left: 4px solid #3b82f6;
  padding: 1.5em 2em;
  margin: 2em 0;
  border-radius: 0 6px 6px 0;
}

.entry-content .sce-faq-section h2,
.wp-block-post-content .sce-faq-section h2 {
  margin-top: 0;
}

.entry-content .sce-faq-section .sce-faq-list,
.wp-block-post-content .sce-faq-section .sce-faq-list {
  padding-left: 1.5em;
  margin: 0.75em 0 0;
}

.entry-content .sce-faq-section .sce-faq-list li,
.wp-block-post-content .sce-faq-section .sce-faq-list li {
  margin-bottom: 1.25em;
}

.entry-content .sce-faq-section .sce-faq-list li p:first-child,
.wp-block-post-content .sce-faq-section .sce-faq-list li p:first-child {
  margin-bottom: 0.25em;
}

.entry-content .sce-faq-section .sce-faq-list li p:last-child,
.wp-block-post-content .sce-faq-section .sce-faq-list li p:last-child {
  margin-top: 0;
}

/* ---- Mobile responsive ------------------------------------------------ */
@media (max-width: 768px) {
  /* Reinforce table scroll on small screens — prevents theme overrides */
  .sce-table-responsive {
    overflow-x: auto;
  }

  .sce-table-responsive table {
    min-width: 500px;
  }

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

  /* Reduce FAQ padding on mobile */
  .entry-content .sce-faq-section,
  .wp-block-post-content .sce-faq-section {
    padding: 1em 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;
  }
}
