/* ============================================
   BLOG STYLES - Minimalista e Clean
   Mantém consistência visual com o site principal
   ============================================ */

/* BLOG SECTION LAYOUT */

#blog {
  padding-top: 4vh;
  min-height: 100vh;
  /* limitar largura para leitura em monitores muito largos */
  width: clamp(320px, 90vw, 1100px);
  margin: 0 auto;
  box-sizing: border-box;
}

#post {
  padding-top: 4vh;
  min-height: 100vh;
  margin: 0 10rem;
  box-sizing: border-box;
}

/* BLOG HEADER WITH SEARCH */

.blog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4rem;
  flex-wrap: wrap;
  gap: 2rem;
}

.blog-header .title {
  flex: 1;
  min-width: 200px;
  margin: 0;
}

.search-container {
  /* expand to fill available space but center child */
  flex: 1;
  min-width: 250px;
  display: flex;
  justify-content: center; /* centraliza o campo de busca */
}

.search-input {
  padding: 0.75rem 1rem;
  border: 1px solid var(--container-border);
  border-radius: 0.5rem;
  background-color: var(--primary-color);
  color: var(--secondary-color);
  font-family: "Poppins", sans-serif;
  font-size: 1rem;
  width: 100%;
  max-width: 400px; /* aumentamos para dar mais espaço ao usuário */
  transition: all 0.3s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--secondary-color);
  background-color: var(--primary-color-2);
}

.search-input::placeholder {
  color: var(--secondary-color-2);
}

/* LOADING, ERROR, EMPTY STATES */

.loading-state,
.error-state,
.empty-state {
  text-align: center;
  padding: 3rem 2rem;
  background-color: var(--primary-color-2);
  border-radius: 1rem;
  border: 1px solid var(--container-border);
  margin: 2rem 0;
}

.loading-state p,
.error-state p,
.empty-state p {
  font-size: 1.1rem;
  color: var(--secondary-color-2);
}

.error-state {
  border-color: #d32f2f;
}

/* POSTS CONTAINER - Agrupamento por Mês/Ano */

.posts-container {
  display: flex;
  flex-direction: column;
  gap: 4rem;
}

.month-group {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.month-heading {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--secondary-color);
  border-bottom: 2px solid var(--container-border);
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
  letter-spacing: 0.5px;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
}

.post-item {
  padding: 0.5rem 0;
  transition: all 0.2s ease;
  /* start hidden for animation */
  opacity: 0;
  transform: translateY(5px);
}

.post-item.visible {
  opacity: 1;
  transform: translateY(0);
}

.post-item:hover {
  padding-left: 0.25rem;
  /* sem borda de separação entre posts; hover apenas desloca levemente */
  background-color: var(--primary-color-2);
  /* escala e sombra sutis para efeito de card */
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.post-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  text-decoration: none;
  color: var(--secondary-color);
  font-weight: 500;
  transition: all 0.3s ease;
}

.post-link:hover {
  color: var(--secondary-color-2);
  /* evitar sublinhado duplo: remover decoração do link pai quando sobreposto */
  text-decoration: none;
}

.post-title-link {
  flex: 1;
  color: #1e6aff; /* azul para títulos dos artigos */
  text-decoration: none;
  font-weight: 500;
  transition: color 0.3s ease;
  word-break: break-word;
}

.post-title-link:hover {
  text-decoration: underline;
  text-underline-offset: 0.5rem;
}

.post-date-inline {
  font-size: 0.9rem;
  color: var(--secondary-color-2);
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

/* POST PAGE STYLES */

.post-content-wrapper {
  /* Use largura responsiva: ocupa até 1100px ou 80vw, conforme disponível */
  max-width: 1100px;
  width: clamp(320px, 80vw, 1100px);
  margin: 0 auto;
  padding: 1.5rem 1rem;

  /* animação de entrada */
  opacity: 0;
  transform: translateY(10px);
  transition: all 0.4s ease;
}

.post-content-wrapper.visible {
  opacity: 1;
  transform: translateY(0);
}

.post-article {
  display: flex;
  flex-direction: column;  width: 100%;}

.post-header {
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--container-border);
}

.post-title {
  font-size: 2.5rem;
  font-weight: 600;
  color: var(--secondary-color);
  margin-bottom: 1rem;
  line-height: 1.3;
}

.post-meta {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.post-date {
  font-size: 0.95rem;
  color: var(--secondary-color-2);
  font-weight: 500;
}

.post-body {
  font-size: 1.05rem;
  line-height: 1.85;
  color: var(--secondary-color-2);
  margin-bottom: 2rem;
  word-break: normal;
  overflow-wrap: normal;
  text-align: left;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  hyphens: none;
}

.post-body p {
  margin: 0 0 1rem 0;
  color: var(--secondary-color-2);
}

.post-body h1,
.post-body h2,
.post-body h3,
.post-body h4,
.post-body h5,
.post-body h6 {
  color: var(--secondary-color);
  margin: 1.5rem 0 1rem 0;
  font-weight: 600;
}

.post-body h1 {
  font-size: 1.8rem;
}

.post-body h2 {
  font-size: 1.6rem;
}

.post-body h3 {
  font-size: 1.4rem;
}

.post-body a {
  color: var(--secondary-color);
  text-decoration: underline;
  text-underline-offset: 0.3rem;
}

.post-body a:hover {
  opacity: 0.7;
}

.post-body ul,
.post-body ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
  color: var(--secondary-color-2);
}

.post-body li {
  margin-bottom: 0.75rem;
  line-height: 1.8;
}

.post-body code {
  background-color: var(--primary-color-2);
  padding: 0.2rem 0.4rem;
  border-radius: 0.3rem;
  font-family: "Courier New", monospace;
  font-size: 0.95rem;
  color: var(--secondary-color);
}

.post-body pre {
  background-color: var(--primary-color-2);
  padding: 1rem;
  border-radius: 0.5rem;
  overflow-x: auto;
  margin: 1.5rem 0;
  font-family: "Courier New", monospace;
  line-height: 1.5;
}

.post-body pre code {
  background-color: transparent;
  padding: 0;
  color: var(--secondary-color);
}

.post-body blockquote {
  border-left: 3px solid var(--container-border);
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--secondary-color-2);
}

.post-body img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem;
  margin: 1rem auto;
  display: block;
}

/* Responsividade para conteúdos incorporados (iframe, video) */
.post-body iframe,
.post-body video {
  max-width: 100%;
  width: 100%;
  display: block;
  margin: 1rem 0;
}

.post-footer {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--container-border);
}

.back-link {
  display: inline-block;
  color: var(--secondary-color);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border: 1px solid var(--container-border);
  border-radius: 0.5rem;
}

.back-link:hover {
  background-color: var(--primary-color-2);
  border-color: var(--secondary-color);
  text-decoration: none; /* não mostrar linha debaixo durante hover */
}

/* RESPONSIVE - TABLET */

@media screen and (max-width: 1200px) {
  #blog,
  #post {
    margin: 0 5rem;
  }

  .blog-header {
    flex-direction: column;
    align-items: stretch;
  }

  .blog-header .title {
    min-width: auto;
  }

  .search-container {
    justify-content: stretch;
  }

  .search-input {
    max-width: none;
  }

  .post-content-wrapper {
    max-width: 100%;
    padding: 0 1rem;
  }

  .post-title {
    font-size: 2rem;
  }

  .month-heading {
    font-size: 1.5rem;
  }
}

/* RESPONSIVE - MOBILE */

@media screen and (max-width: 600px) {
  #blog,
  #post {
    margin: 0 1rem;
    padding-top: 2vh;
  }

  .blog-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .blog-header .title {
    font-size: 2rem;
    text-align: center;
  }

  .search-container {
    justify-content: stretch;
  }

  .search-input {
    max-width: none;
  }

  .post-item:hover {
    padding-left: 0;
  }

  .post-link {
    flex-direction: column;
    align-items: flex-start;
  }

  .post-date-inline {
    margin-left: 0;
  }

  .month-heading {
    font-size: 1.3rem;
  }

  .post-content-wrapper {
    padding: 0;
  }

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

  .post-body h1 {
    font-size: 1.4rem;
  }

  .post-body h2 {
    font-size: 1.2rem;
  }

  .post-body h3 {
    font-size: 1.1rem;
  }

  .loading-state,
  .error-state,
  .empty-state {
    padding: 2rem 1rem;
  }
}
