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