/* Page head */
.page {
  padding: 42px 0 22px;
}
#blog-list.page,
#blog-post.page {
  min-height: calc(100vh - 145px);
}
h1 {
  margin: 0 0 10px;
  font-size: clamp(28px, 3.6vw, 44px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.sub {
  margin: 0;
  font-size: 16px;
  line-height: 1.7;
  color: var(--muted);
  max-width: 70ch;
}

/* Posts stack */
.posts-grid {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 28px;
  padding-bottom: 42px;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}

/* Post card */
.post-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--card-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition:
    transform 0.15s ease,
    box-shadow 0.15s ease;
}
.post-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--elev-shadow);
}

.post-card-link {
  display: flex;
  flex-direction: column;
  flex: 1;
  text-decoration: none;
  color: inherit;
}

.post-card-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(180deg, var(--surface-2), var(--surface-3));
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.post-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-card-body {
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.post-date {
  font-size: 12px;
  color: var(--muted);
}

.post-card-date {
  display: block;
  text-align: right;
  margin-top: auto;
  padding-top: 2px;
}

.post-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.3;
}

.post-card-summary {
  margin: 0;
  font-size: 14px;
  color: var(--muted);
  line-height: 1.6;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  padding-left: 14px;
  transition:
    max-height 0.45s ease,
    opacity 0.2s ease 0.12s;
}

.post-card:hover .post-card-summary {
  max-height: 200px;
  opacity: 1;
}

/* Reading progress bar */
.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 3px;
  background: var(--text);
  z-index: 55;
  opacity: 0;
  pointer-events: none;
  transition:
    width 0.1s linear,
    opacity 0.15s ease;
}
.reading-progress.is-visible {
  opacity: 1;
}

/* Post detail */
.post-container {
  max-width: 1076px;
  padding-bottom: 64px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0;
  margin-bottom: 28px;
  transition: color 0.15s ease;
}
.back-link:hover {
  color: var(--text);
}

.post-content {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.post-header {
  margin-bottom: 36px;
}

.post-header-date {
  display: block;
  margin-bottom: 20px;
  text-align: center;
}

.post-header-title {
  margin: 0 0 12px;
  font-size: clamp(26px, 3.2vw, 38px);
  line-height: 1.15;
  letter-spacing: -0.03em;
  text-align: center;
}

.post-header-summary {
  margin: 0 0 24px;
  font-size: 18px;
  color: var(--muted);
  line-height: 1.65;
  text-align: center;
}

.post-header-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  display: block;
}

/* Corpo do post (markdown renderizado) */
.post-body {
  font-size: 18px;
  line-height: 1.75;
  color: var(--text);
}
.post-body p {
  margin: 0 auto;
  max-width: 65ch;
  text-align: justify;
  hyphens: auto;
}
.post-body li {
  max-width: 65ch;
  margin: 0 auto;
  text-align: justify;
  text-align-last: left;
  hyphens: auto;
}
.post-body > * + * {
  margin-top: 1.4em;
}
.post-body p + p {
  margin-top: 1.4em;
}
.post-body h2 {
  font-size: clamp(20px, 2.4vw, 26px);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 2em 0 0.6em;
}
.post-body h3 {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 1.6em 0 0.5em;
}
.post-body a {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.post-body a:hover {
  color: var(--muted);
}
.post-body strong {
  font-weight: 650;
}
.post-body img {
  max-width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  display: block;
  margin: 0 auto;
}
.post-body blockquote {
  border-left: 3px solid var(--line);
  padding: 4px 0 4px 18px;
  margin: 0;
  color: var(--muted);
  font-style: italic;
}
.post-body pre {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 15px;
  line-height: 1.6;
}
.post-body code {
  font-family: 'SF Mono', 'Fira Mono', 'Cascadia Code', Menlo, Consolas, monospace;
}
.post-body :not(pre) > code {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 15px;
}
.post-body ul,
.post-body ol {
  padding-left: 1.5em;
}
.post-body li + li {
  margin-top: 0.4em;
}
.post-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 2em 0;
}

/* Responsive */
@media (max-width: 640px) {
  .post-body {
    font-size: 17px;
  }
  .post-header-summary {
    font-size: 16px;
  }
}

/* Layout duas colunas no desktop */
.blog-list-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
}
.blog-list-layout .archive-nav {
  order: -1;
  margin-bottom: 8px;
}

@media (min-width: 980px) {
  .blog-list-layout {
    grid-template-columns: 1fr 160px;
    gap: 20px;
    align-items: start;
  }
  .blog-list-layout .posts-grid {
    max-width: none;
    margin-left: 0;
    margin-right: 0;
  }
  .blog-list-layout .archive-nav {
    order: 0;
    position: sticky;
    top: 80px;
  }
}

/* Mobile: details colapsavel (comeca fechado) */
.archive-mobile-toggle {
  border: none;
  background: none;
  padding: 0;
}
.archive-mobile-toggle summary {
  cursor: pointer;
  font-weight: 650;
  font-size: 15px;
  color: var(--text);
  padding: 8px 0;
  list-style: none;
}
.archive-mobile-toggle summary::-webkit-details-marker {
  display: none;
}
.archive-mobile-toggle summary::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  margin-right: 8px;
  vertical-align: middle;
  transition: transform 0.2s ease;
}
.archive-mobile-toggle[open] summary::before {
  transform: rotate(45deg);
}

@media (min-width: 980px) {
  .archive-mobile-toggle summary {
    display: none;
  }
  .archive-mobile-toggle .archive-tree {
    display: block !important;
  }
}

/* Arvore ano > mes */
.archive-tree {
  padding: 4px 0;
}
.archive-year h3 {
  font-size: 13px;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--text);
  letter-spacing: 0.02em;
}
.archive-year:first-child h3 {
  margin-top: 0;
}
.archive-tree ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.archive-tree li a {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 4px 6px;
  font-size: 13px;
  color: var(--muted);
  border-radius: 6px;
  text-decoration: none;
  transition:
    color 0.15s ease,
    background 0.15s ease;
}
.archive-tree li a:hover {
  color: var(--text);
  background: var(--soft);
}
.archive-tree li a span {
  font-size: 12px;
  opacity: 0.6;
  font-weight: 400;
}
.archive-tree li.is-current a {
  color: var(--text);
  font-weight: 650;
  background: var(--soft);
}

/* Separador de mes/ano na lista de posts */
.archive-separator {
  margin: 32px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.archive-separator time {
  font-size: 14px;
  font-weight: 650;
  color: var(--muted);
  letter-spacing: 0.01em;
}
.archive-separator:first-child {
  margin-top: 0;
}

/* Skeleton post card sizing */
.post-card.skeleton {
  transition: none;
}
.post-card.skeleton:hover {
  transform: none;
  box-shadow: var(--card-shadow);
}
.post-card.skeleton .post-card-cover,
.card-ghost .post-card-cover {
  background: none;
  border-bottom: none;
}
.post-card.skeleton .skeleton-cover,
.card-ghost .skeleton-cover {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 0;
}
.post-card.skeleton .skeleton-title,
.card-ghost .skeleton-title {
  height: 15px;
  width: 75%;
}
.post-card.skeleton .skeleton-summary,
.card-ghost .skeleton-summary {
  display: none;
}
.post-card.skeleton .skeleton-date,
.card-ghost .skeleton-date {
  height: 12px;
  width: 100px;
  margin-top: auto;
}
