/* ===================================================================
   UXUARIA — blog.css
   Figma: uxuaria-Web, "Blog" (64:1030) and "Artículo" (69:1088).
   Spec: 12-blog-redesign.
   =================================================================== */

/* ===== LISTING ===== */
.blog-listing {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding-block: 64px 96px;
}

.blog-listing__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

/* ===== POST CARD ===== */
.post-card {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 16px;
  overflow: hidden;
  border: 1px solid var(--ux-color-border-soft);
  border-radius: var(--ux-radius-card);
  background: var(--ux-color-surface);
  color: var(--ux-color-text);
  text-decoration: none;
  transition: transform .25s ease, box-shadow .25s ease;
}

.post-card:hover,
.post-card:focus-visible {
  position: relative;
  z-index: 2;
  transform: scale(1.02);
  box-shadow: var(--ux-shadow-card-hover);
}

.post-card:hover .arrow-link { text-decoration: underline; }

.post-card__image {
  flex: none;
  height: 226px;
  overflow: hidden;
  border-radius: var(--ux-radius-frame);
  background: var(--ux-color-surface-soft);
}

.post-card__image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.post-card__content {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  align-items: flex-start;
  padding: 0 4px 8px;
}

.post-card__date {
  color: var(--ux-color-text-muted);
  font-family: var(--ux-font-mono);
  font-size: var(--ux-size-label);
  font-weight: 700;
  line-height: 17.6px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.post-card__title {
  min-height: 5em;
  font-size: var(--ux-size-subtitle);
  font-weight: 500;
  line-height: var(--ux-leading-subtitle);
  letter-spacing: var(--ux-track-heading);
}

.post-card__excerpt {
  display: -webkit-box;
  overflow: hidden;
  min-height: 76.8px;
  color: var(--ux-color-text-muted);
  font-size: var(--ux-size-small);
  line-height: 25.6px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.post-card .arrow-link { margin-top: auto; }

.post-card--featured {
  display: grid;
  grid-template-columns: 550fr 500fr;
  gap: 32px;
  align-items: center;
}

.post-card--featured .post-card__image { height: 430px; }

.post-card--featured .post-card__content {
  gap: 20px;
  padding: 0 16px 0 0;
}

.post-card--featured .post-card__title { min-height: 0; }

.post-card--featured .post-card__excerpt {
  display: block;
  font-size: var(--ux-size-body);
  line-height: 28.8px;
}

.post-card--related .post-card__image { height: 280px; }
.post-card--related .post-card__content { padding-inline: 8px; }
.post-card--related .post-card__title { min-height: 3em; }

.post-card--related .post-card__excerpt {
  min-height: 51.2px;
  -webkit-line-clamp: 2;
}

.post-card__meta {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

/* ===== ARTICLE HEADER ===== */
.post-header {
  display: flex;
  flex-direction: column;
  gap: 40px;
  padding-block: 56px 64px;
}

.post-header__heading {
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: flex-start;
}

.post-header__title {
  color: var(--ux-color-text);
  font-size: var(--ux-size-display);
  font-weight: 700;
  line-height: var(--ux-leading-display);
  letter-spacing: var(--ux-track-display);
}

.post-header__date {
  color: var(--ux-color-text-muted);
  font-family: var(--ux-font-mono);
  font-size: var(--ux-size-label);
  font-weight: 700;
  line-height: 17.6px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.post-header__cover {
  height: 500px;
  overflow: hidden;
  border-radius: var(--ux-radius-frame);
  background: var(--ux-color-surface-soft);
}

.post-header__cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== ARTICLE BODY ===== */
.post-body {
  display: flex;
  flex-direction: column;
  gap: 24px;
  max-width: 792px;
  margin: 0 auto;
  padding: 0 16px 48px;
  color: var(--ux-color-text);
  font-size: var(--ux-size-body);
  line-height: 28.8px;
}

.post-body h2 {
  margin-top: 24px;
  font-size: var(--ux-size-subtitle);
  font-weight: 500;
  line-height: var(--ux-leading-subtitle);
  letter-spacing: var(--ux-track-heading);
}

.post-body h3 {
  margin-top: 8px;
  font-size: var(--ux-size-heading);
  font-weight: 700;
  line-height: var(--ux-leading-heading);
}

.post-body a { color: inherit; text-decoration: underline; }
.post-body ul, .post-body ol { display: flex; flex-direction: column; gap: 12px; padding-left: 24px; }
.post-body ul { list-style: disc; }
.post-body ol { list-style: decimal; }

.post-body blockquote {
  padding-left: 24px;
  border-left: 2px solid var(--ux-color-ink);
  font-size: var(--ux-size-lead);
}

.post-body hr { border: 0; border-top: 1px solid var(--ux-color-border-soft); }

/* Sources: the closing heading and list */
.post-body h3:has(+ ul:last-child) { font-weight: 400; }

.post-body > ul:last-child {
  gap: 20px;
  padding-left: 18px;
  font-size: var(--ux-size-small);
  line-height: 25.6px;
}

.article-figure { margin: 8px 0; }

.article-figure__img {
  width: 100%;
  height: auto;
  border: 1px solid var(--ux-color-border-soft);
  border-radius: var(--ux-radius-frame);
}

.article-figure figcaption {
  margin-top: 8px;
  color: var(--ux-color-text-muted);
  font-size: var(--ux-size-small);
  line-height: 25.6px;
}

/* The article's Markdown links this button with its Retro 3.1 class names */
.post-body .btn {
  align-self: flex-start;
  padding: 9px 20px;
  border: 1px solid var(--ux-color-ink);
  border-radius: var(--ux-radius-pill);
  box-shadow: var(--ux-shadow-button);
  font-size: var(--ux-size-small);
  text-decoration: none;
  transition: background-color .2s ease, color .2s ease;
}

.post-body .btn:hover,
.post-body .btn:focus-visible {
  background: var(--ux-color-ink);
  color: var(--ux-color-text-inverse);
}

/* Responsive YouTube embed inside an article (16:9) */
.article-video {
  margin: 8px 0;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  border-radius: var(--ux-radius-frame);
  background: var(--ux-color-surface-soft);
}

.article-video__frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

/* Callout cards between paragraphs: lead to a service page (spec 17) */
.article-callout {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  margin: 8px 0;
  padding: 24px;
  border: 1px solid var(--ux-color-ink);
  border-radius: var(--ux-radius-card);
  background: var(--ux-color-surface-soft);
}

.article-callout__title {
  margin-top: 4px;
  font-size: var(--ux-size-heading);
  font-weight: 700;
  line-height: var(--ux-leading-heading);
  letter-spacing: -.04em;
}

.article-callout__text { font-size: var(--ux-size-small); line-height: 25.6px; }

.post-body .article-callout__link {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  margin-top: 4px;
  font-size: var(--ux-size-small);
  font-weight: 500;
}

/* ===== GUIDE =====
   The side index is compact so a long guide fits without its own scroll;
   overflow-y stays only as a fallback for very short screens
   Long how-to articles: index, summary and numbered sections (spec 18-blog-guias) */
.post-guide {
  display: grid;
  grid-template-columns: 264px minmax(0, 792px);
  gap: 40px;
  justify-content: center;
  align-items: start;
}

/* A guide without h2 has no index: the text keeps the single reading column */
.post-guide--no-toc { grid-template-columns: minmax(0, 792px); }

.post-guide__main {
  display: flex;
  flex-direction: column;
  gap: 40px;
  min-width: 0;
}

.post-guide .post-body {
  max-width: none;
  margin: 0;
  padding-inline: 0;
}

/* Section numbers, matching the index */
.post-body--guide { counter-reset: guide-section; }

.post-body--guide h2 {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 40px;
  scroll-margin-top: calc(var(--ux-header-height) + 24px);
  counter-increment: guide-section;
}

.post-body--guide h2::before {
  content: counter(guide-section, decimal-leading-zero);
  color: var(--ux-color-text-muted);
  font-family: var(--ux-font-mono);
  font-size: var(--ux-size-small);
  letter-spacing: .3px;
}

/* Index */
.guide-toc__title {
  color: var(--ux-color-text-muted);
  font-family: var(--ux-font-mono);
  font-size: var(--ux-size-label);
  font-weight: 700;
  line-height: 17.6px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.guide-toc__list {
  display: flex;
  flex-direction: column;
  margin-top: 12px;
}

.guide-toc__link {
  display: flex;
  gap: 10px;
  padding: 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 var(--ux-radius-frame) var(--ux-radius-frame) 0;
  color: var(--ux-color-text-muted);
  font-size: var(--ux-size-meta);
  line-height: 1.3;
  text-decoration: none;
  transition: color .2s ease, background-color .2s ease, border-color .2s ease;
}

.guide-toc__number {
  flex: none;
  font-family: var(--ux-font-mono);
  font-size: var(--ux-size-label);
  line-height: 18.2px;
}

.guide-toc__link:hover,
.guide-toc__link:focus-visible {
  color: var(--ux-color-text);
  background: var(--ux-color-surface-soft);
}

.guide-toc__link[aria-current] {
  border-left-color: var(--ux-color-ink);
  color: var(--ux-color-text);
  font-weight: 500;
}

.guide-toc--aside {
  position: sticky;
  top: calc(var(--ux-header-height) + 24px);
  max-height: calc(100vh - var(--ux-header-height) - 48px);
  overflow-y: auto;
}

.guide-toc--details {
  display: none;
  padding: 16px 20px;
  border: 1px solid var(--ux-color-border-soft);
  border-radius: var(--ux-radius-card);
}

.guide-toc--details summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

.guide-toc--details summary::-webkit-details-marker { display: none; }

.guide-toc--details summary::after {
  content: '+';
  color: var(--ux-color-text);
  font-family: var(--ux-font-mono);
  font-size: var(--ux-size-lead);
  line-height: 1;
}

.guide-toc--details[open] summary::after { content: '–'; }

/* Opening summary */
.guide-summary {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 28px 32px;
  border-radius: var(--ux-radius-card);
  background: var(--ux-color-surface-soft);
}

.guide-summary__title {
  color: var(--ux-color-text);
  font-size: var(--ux-size-heading);
  font-weight: 700;
  line-height: var(--ux-leading-heading);
  letter-spacing: -.04em;
}

.guide-summary__list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--ux-color-text);
  font-size: var(--ux-size-small);
  line-height: 25.6px;
}

.guide-summary__list li {
  position: relative;
  padding-left: 24px;
}

.guide-summary__list li::before {
  content: '→';
  position: absolute;
  left: 0;
}

/* ===== AUTHOR ===== */
.post-author {
  display: flex;
  flex-direction: column;
  gap: 20px;
  align-items: flex-start;
  max-width: 760px;
  /* The newsletter block follows it: same 40px gap as in guides */
  margin: 0 auto 40px;
  padding: 32px;
  border: 1px solid var(--ux-color-border-soft);
  border-radius: var(--ux-radius-card);
}

/* Guides: in the reading column, next to the index; the column gap spaces it */
.post-guide__main .post-author {
  max-width: none;
  margin: 0;
}

.post-author__name {
  color: var(--ux-color-text);
  font-size: var(--ux-size-heading);
  font-weight: 700;
  line-height: var(--ux-leading-heading);
  letter-spacing: var(--ux-track-heading);
}

.post-author__bio {
  color: var(--ux-color-text-muted);
  font-size: var(--ux-size-small);
  line-height: 25.6px;
}

/* ===== NEWSLETTER (spec 20-boletin) ===== */
.blog-listing > .newsletter { margin-top: 40px; }

/* Same width, padding and outer margins as .post-author, which sits above it */
.post-newsletter .newsletter {
  max-width: 760px;
  margin: 0 auto 80px;
}

.post-newsletter .newsletter,
.post-guide__main .newsletter { padding: 32px; }

/* Guides: in the reading column, under the author */
.post-guide__main .newsletter { margin-bottom: 80px; }

/* ===== RELATED ===== */
.post-related {
  padding-block: 80px;
  border-top: 1px solid var(--ux-color-border-soft);
  background: var(--ux-color-surface-soft);
}

.post-related__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 24px;
  margin-top: 32px;
}

/* ===== TABLES, CHECKLISTS AND NOTES =====
   Markdown content of long guides (guia-diagnostico-ux-app-lista-usuarios-reales) */
.post-header__subtitle {
  max-width: 792px;
  color: var(--ux-color-text-muted);
  font-size: var(--ux-size-lead);
  line-height: var(--ux-leading-heading);
}

/* Tables scroll sideways inside their frame instead of widening the page */
.post-table {
  overflow-x: auto;
  border: 1px solid var(--ux-color-border-soft);
  border-radius: var(--ux-radius-frame);
}

.post-table table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--ux-size-small);
  line-height: 25.6px;
}

/* Three and four columns keep a readable width on mobile and scroll */
.post-table table:has(th:nth-child(3)) { min-width: 600px; }
.post-table table:has(th:nth-child(4)) { min-width: 760px; }

.post-table th,
.post-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--ux-color-border-soft);
  text-align: left;
  vertical-align: top;
}

.post-table th {
  background: var(--ux-color-surface-soft);
  font-weight: 700;
}

.post-table tr:last-child td { border-bottom: 0; }

/* Checklists: visible boxes, read-only today, ready to be ticked later */
.post-body ul.contains-task-list {
  gap: 14px;
  padding-left: 0;
  list-style: none;
}

.task-list-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.task-list-item input[type="checkbox"] {
  flex: none;
  width: 22px;
  height: 22px;
  margin: 3px 0 0;
  border: 2px solid var(--ux-color-ink);
  border-radius: 4px;
  background: var(--ux-color-surface);
  appearance: none;
}

.task-list-item input[type="checkbox"]:checked {
  background: var(--ux-color-ink);
  box-shadow: inset 0 0 0 3px var(--ux-color-surface);
}

.task-list-item input[type="checkbox"]:not(:disabled) { cursor: pointer; }

/* Note before a checklist: distinct from a quote */
.post-note {
  padding: 24px;
  border-left: 4px solid var(--ux-color-ink);
  border-radius: var(--ux-radius-frame);
  background: var(--ux-color-surface-soft);
}

.post-note blockquote {
  padding-left: 0;
  border-left: 0;
  font-size: var(--ux-size-small);
  line-height: 25.6px;
}

.post-body--guide h3 { scroll-margin-top: calc(var(--ux-header-height) + 24px); }

/* ===== RESPONSIVE =====
   Provisional until the mobile frames exist (spec 12-blog-redesign) */
@media (max-width: 1100px) {
  .blog-listing__grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .post-card--featured { grid-template-columns: minmax(0, 1fr); }
  .post-card--featured .post-card__image { height: 300px; }
  .post-header__cover { height: clamp(220px, 40vw, 500px); }
  .post-guide { grid-template-columns: minmax(0, 792px); }
  .guide-toc--aside { display: none; }
  .guide-toc--details { display: block; }
}

@media (max-width: 768px) {
  .blog-listing__grid, .post-related__grid { grid-template-columns: minmax(0, 1fr); }
  .post-card__title, .post-card--related .post-card__title { min-height: 0; }
  .post-card__excerpt, .post-card--related .post-card__excerpt { min-height: 0; }
  .post-card--featured .post-card__content { padding: 0 4px 8px; }
  .post-author { margin-inline: 16px; padding: 24px; }
  .post-guide__main .post-author { margin-inline: 0; }
  .post-newsletter .newsletter { margin-inline: 16px; }
  .post-newsletter .newsletter,
  .post-guide__main .newsletter { padding: 24px; }
  .post-related { padding-block: 56px; }
  /* Same reading width as a regular article; site.css loads after this file */
  .post-guide.page-container { padding-inline: 16px; }
  .post-guide__main { gap: 32px; }
  .guide-summary { padding: 24px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .post-card:hover, .post-card:focus-visible { transform: none; }
}
