/**
 * G1-Style Single Post Layout
 * FIESC Child Theme
 *
 * Inspired by g1.globo.com article pages:
 * - Centered narrow content (~680px)
 * - Generous line-height and font sizes
 * - Category badge, metadata, featured image, share buttons
 * - Related news grid
 */

/* ============================================================
   VARIABLES
   ============================================================ */
.fiesc-single-post {
  --post-max-width: 680px;
  --post-wide-width: 1100px;
  --post-color-primary: #003087;
  --post-color-accent: #e8271e;
  --post-color-text: #1a1a2e;
  --post-color-muted: #6b7280;
  --post-color-border: #e5e7eb;
  --post-color-bg-light: #f8fafc;
  --post-radius: 8px;
}

/* ============================================================
   ARTICLE CONTAINER
   ============================================================ */
.fiesc-single-post {
  padding: 0;
  margin: 0 auto;
}

/* ============================================================
   HEADER: CATEGORY, TITLE, LEAD, META
   ============================================================ */
.fiesc-post-header {
  padding: 2.5rem 1rem 1.5rem;
  border-bottom: 1px solid var(--post-color-border);
}

.fiesc-post-header__inner {
  max-width: var(--post-max-width);
  margin: 0 auto;
}

/* Category badge */
.fiesc-post-category {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  background-color: var(--post-color-primary);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: var(--post-radius);
  text-decoration: none;
  margin-bottom: 1rem;
  transition: background-color 0.2s ease;
}

.fiesc-post-category:hover {
  background-color: #002368;
  text-decoration: underline;
  color: #fff;
}

/* Title */
.fiesc-post-title {
  font-size: clamp(1.75rem, 4vw, 2.5rem);
  font-weight: 700;
  line-height: 1.2;
  color: var(--post-color-text);
  margin: 0 0 1rem;
}

/* Lead / subtitle */
.fiesc-post-lead {
  font-size: 1.25rem;
  line-height: 1.5;
  color: var(--post-color-muted);
  font-weight: 400;
  margin: 0 0 1.25rem;
}

/* Author & Date metadata */
.fiesc-post-meta {
  font-size: 0.875rem;
  color: var(--post-color-muted);
  line-height: 1.5;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem;
}

.fiesc-post-meta__author {
  font-weight: 500;
}

.fiesc-post-meta__separator {
  color: var(--post-color-border);
}

.fiesc-post-meta__updated {
  color: var(--post-color-muted);
}

/* ============================================================
   FEATURED IMAGE
   ============================================================ */
.fiesc-post-featured-image {
  max-width: var(--post-max-width);
  margin: 2rem auto;
  padding: 0 1rem;
}

.fiesc-post-featured-image__img {
  width: 100%;
  height: auto;
  border-radius: var(--post-radius);
  display: block;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.fiesc-post-featured-image__caption {
  font-size: 0.8125rem;
  color: var(--post-color-muted);
  margin-top: 0.5rem;
  line-height: 1.4;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--post-color-border);
}

/* ============================================================
   ARTICLE BODY
   ============================================================ */
.fiesc-post-body {
  max-width: var(--post-max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem 2rem;
  font-size: 1.125rem;
  line-height: 1.8;
  color: var(--post-color-text);
}

.fiesc-post-body p {
  margin-bottom: 1.5rem;
}

.fiesc-post-body h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 2.5rem 0 1rem;
  color: var(--post-color-text);
  line-height: 1.3;
}

.fiesc-post-body h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 2rem 0 0.75rem;
  color: var(--post-color-text);
  line-height: 1.3;
}

/* Clearfix — contain floated images pasted from Joomla/legacy content */
.fiesc-post-body::after {
  content: "";
  display: table;
  clear: both;
}

.fiesc-post-body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--post-radius);
  margin: 1.5rem 0;
}

/* Floated images (e.g. legacy inline photo galleries) */
.fiesc-post-body img[style*="float: left"],
.fiesc-post-body img[style*="float:left"] {
  margin-right: 1rem;
  margin-bottom: 1rem;
  margin-top: 0;
}

.fiesc-post-body img[style*="float: right"],
.fiesc-post-body img[style*="float:right"] {
  margin-left: 1rem;
  margin-bottom: 1rem;
  margin-top: 0;
}

/* Prevent arbitrary external div structures (e.g. content copied from React/ChatGPT interfaces)
   from breaking the post body flow */
.fiesc-post-body > div {
  overflow: visible !important;
  height: auto !important;
  max-width: 100% !important;
}

.fiesc-post-body blockquote {
  border-left: 4px solid var(--post-color-primary);
  margin: 2rem 0;
  padding: 1rem 1.5rem;
  background: var(--post-color-bg-light);
  border-radius: 0 var(--post-radius) var(--post-radius) 0;
  font-style: italic;
  color: var(--post-color-muted);
}

.fiesc-post-body blockquote p:last-child {
  margin-bottom: 0;
}

.fiesc-post-body a {
  color: var(--post-color-primary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.fiesc-post-body a:hover {
  color: #002368;
}

.fiesc-post-body ul,
.fiesc-post-body ol {
  margin: 1rem 0 1.5rem 1.5rem;
}

.fiesc-post-body li {
  margin-bottom: 0.5rem;
}

.fiesc-post-body figure {
  margin: 2rem 0;
}

.fiesc-post-body figcaption {
  font-size: 0.8125rem;
  color: var(--post-color-muted);
  margin-top: 0.5rem;
}

/* Embedded video */
.fiesc-post-body iframe,
.fiesc-post-body .wp-block-embed {
  max-width: 100%;
  margin: 2rem 0;
}

/* ============================================================
   TAGS
   ============================================================ */
.fiesc-post-tags {
  max-width: var(--post-max-width);
  margin: 0 auto;
  padding: 1.5rem 1rem;
  border-top: 1px solid var(--post-color-border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.fiesc-post-tag {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--post-color-border);
  border-radius: 100px;
  font-size: 0.8125rem;
  color: var(--post-color-primary);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.2s ease;
}

.fiesc-post-tag:hover {
  background-color: var(--post-color-primary);
  color: #fff;
  border-color: var(--post-color-primary);
  text-decoration: underline;
}

/* ============================================================
   SHARE BUTTONS
   ============================================================ */
.fiesc-post-share {
  max-width: var(--post-max-width);
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.fiesc-post-share__label {
  font-size: 0.875rem;
  color: var(--post-color-muted);
  font-weight: 500;
}

.fiesc-post-share__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: #fff;
  text-decoration: none;
  transition:
    transform 0.2s ease,
    opacity 0.2s ease;
}

.fiesc-post-share__btn:hover {
  transform: scale(1.1);
  opacity: 0.9;
}

.fiesc-post-share__btn--facebook {
  background-color: #1877f2;
}

.fiesc-post-share__btn--whatsapp {
  background-color: #25d366;
}

.fiesc-post-share__btn--twitter {
  background-color: #000;
}

.fiesc-post-share__btn--email {
  background-color: var(--post-color-muted);
}

/* ============================================================
   RELATED NEWS
   ============================================================ */
.fiesc-related-news {
  background-color: var(--post-color-bg-light);
  padding: 3rem 1rem;
  margin-top: 1rem;
}

.fiesc-related-news__inner {
  max-width: 900px; /* var(--post-wide-width) não resolve aqui pois está fora de .fiesc-single-post */
  margin: 0 auto;
  padding: 0 1rem;
}

.fiesc-related-news__title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--post-color-text);
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--post-color-primary);
  display: inline-block;
}

.fiesc-related-news__grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
}

.fiesc-related-news__card {
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  border-radius: var(--post-radius);
  overflow: hidden;
  transition:
    transform 0.25s ease,
    box-shadow 0.25s ease;
  background: #fff;
}

.fiesc-related-news__card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.fiesc-related-news__card-image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
}

.fiesc-related-news__card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.3s ease;
}

.fiesc-related-news__card:hover .fiesc-related-news__card-image img {
  transform: scale(1.05);
}

.fiesc-related-news__card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  padding: 0.75rem;
  margin: 0;
  color: var(--post-color-text);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* Tablet — 2 colunas a partir de 900px (igual ao max-width do inner) */
@media (max-width: 900px) {
  .fiesc-related-news__grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile */
@media (max-width: 680px) {
  /* Force floated images to stack vertically on small screens */
  .fiesc-post-body img[style*="float: left"],
  .fiesc-post-body img[style*="float:left"],
  .fiesc-post-body img[style*="float: right"],
  .fiesc-post-body img[style*="float:right"] {
    float: none !important;
    display: block !important;
    margin: 1rem auto !important;
    max-width: 100% !important;
    width: auto !important;
  }

  .fiesc-post-header {
    padding: 1.5rem 1rem 1.25rem;
  }

  .fiesc-post-title {
    font-size: 1.5rem;
  }

  .fiesc-post-lead {
    font-size: 1.0625rem;
  }

  .fiesc-post-meta {
    font-size: 0.8125rem;
  }

  .fiesc-post-body {
    font-size: 1rem;
    line-height: 1.75;
    padding: 1rem;
  }

  .fiesc-post-featured-image {
    padding: 0;
    margin: 1.5rem 0;
  }

  .fiesc-post-featured-image__img {
    border-radius: 0;
  }

  .fiesc-related-news__grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .fiesc-related-news__card {
    flex-direction: row;
  }

  .fiesc-related-news__card-image {
    width: 120px;
    min-width: 120px;
    aspect-ratio: 1 / 1;
  }

  .fiesc-related-news__card-title {
    font-size: 0.875rem;
  }

  .fiesc-post-share {
    flex-wrap: wrap;
  }

  .fiesc-post-share__btn {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 480px) {
  .fiesc-post-title {
    font-size: 1.3rem;
  }
}
