/* ==========================================================================
   Article CSS
   Single article page, scoped rich text, and related sidebar layout.
   ========================================================================== */

main.article-page {
  padding-block: clamp(2rem, 5vw, 4rem) clamp(3.5rem, 7vw, 6rem);
  background: var(--color-white);
}

.article-layout {
  display: grid;
  grid-template-columns: minmax(0, 760px) minmax(270px, 320px);
  align-items: start;
  justify-content: center;
  gap: clamp(2.5rem, 5vw, 4.5rem);
  overflow: visible;
}

.single-article,
.article-sidebar {
  min-width: 0;
  align-self: start;
}

.single-article__title {
  max-width: 760px;
  margin: 0;
  color: var(--color-text-heading);
  font-size: clamp(1.875rem, 3vw, 2.75rem);
  line-height: 1.15;
  letter-spacing: var(--tracking-tight);
}

.single-article__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.single-article__meta-separator {
  color: var(--color-border);
}

.single-article__cover {
  margin: clamp(1.75rem, 4vw, 2.5rem) 0 0;
  overflow: hidden;
}

.single-article__cover-image {
  display: block;
  width: 100%;
  max-height: 470px;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
}

.entry-content,
.article-content {
  max-width: var(--container-reading);
  margin-top: clamp(2.25rem, 5vw, 3.25rem);
  color: var(--color-neutral-700);
  font-size: clamp(1rem, 1.2vw, 1.125rem);
  line-height: var(--line-height-relaxed);
  overflow-wrap: anywhere;
}

.entry-content::after,
.article-content::after {
  display: table;
  clear: both;
  content: "";
}

.entry-content > :first-child,
.article-content > :first-child {
  margin-top: 0;
}

.entry-content > :last-child,
.article-content > :last-child {
  margin-bottom: 0;
}

:where(.entry-content, .article-content) p {
  margin: 0 0 1.35em;
}

:where(.entry-content, .article-content) strong {
  font-weight: var(--font-weight-bold);
}

:where(.entry-content, .article-content) h2 {
  margin: 2em 0 0.7em;
  color: var(--color-text-heading);
  font-size: clamp(1.75rem, 3vw, 2.4rem);
  line-height: 1.2;
}

:where(.entry-content, .article-content) h3 {
  margin: 1.7em 0 0.6em;
  color: var(--color-text-heading);
  font-size: clamp(1.4rem, 2.2vw, 1.8rem);
  line-height: 1.3;
}

:where(.entry-content, .article-content) h4 {
  margin: 1.6em 0 0.55em;
  color: var(--color-text-heading);
  font-size: 1.2rem;
  line-height: 1.35;
}

:where(.entry-content, .article-content) a {
  color: var(--color-primary);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.2em;
}

:where(.entry-content, .article-content) a:hover {
  color: var(--color-primary-hover);
  text-decoration-thickness: 2px;
}

:where(.entry-content, .article-content) ul,
:where(.entry-content, .article-content) ol {
  padding-inline-start: 1.5em;
  margin-block: 1.25em 1.5em;
  list-style: revert;
}

:where(.entry-content, .article-content) ul ul,
:where(.entry-content, .article-content) ul ol,
:where(.entry-content, .article-content) ol ul,
:where(.entry-content, .article-content) ol ol {
  margin-block: 0.6em;
}

:where(.entry-content, .article-content) li + li {
  margin-top: 0.5em;
}

:where(.entry-content, .article-content) li::marker {
  color: var(--color-primary);
  font-weight: var(--font-weight-bold);
}

:where(.entry-content, .article-content) blockquote,
:where(.entry-content, .article-content) .wp-block-quote,
:where(.entry-content, .article-content) .wp-block-pullquote {
  margin-block: 1.75em;
  padding: var(--space-5) var(--space-6);
  color: var(--color-text-heading);
  background: var(--color-surface);
  border-inline-start: 4px solid var(--color-primary);
}

:where(.entry-content, .article-content) blockquote p {
  margin-bottom: var(--space-3);
  font-size: 1.12em;
  line-height: 1.65;
}

:where(.entry-content, .article-content) blockquote cite {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  font-style: normal;
}

:where(.entry-content, .article-content) img {
  max-width: 100%;
  height: auto;
}

:where(.entry-content, .article-content) figure,
:where(.entry-content, .article-content) .wp-block-image,
:where(.entry-content, .article-content) .wp-caption {
  max-width: 100%;
  margin-block: 1.75em;
}

:where(.entry-content, .article-content) figcaption,
:where(.entry-content, .article-content) .wp-caption-text {
  margin-top: var(--space-3);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.5;
}

:where(.entry-content, .article-content) .aligncenter {
  display: block;
  margin-inline: auto;
}

:where(.entry-content, .article-content) .alignleft {
  float: left;
  max-width: 45%;
  margin: 0.4em 1.5em 1em 0;
}

:where(.entry-content, .article-content) .alignright {
  float: right;
  max-width: 45%;
  margin: 0.4em 0 1em 1.5em;
}

:where(.entry-content, .article-content) .alignwide,
:where(.entry-content, .article-content) .alignfull {
  width: 100%;
  max-width: 100%;
}

:where(.entry-content, .article-content) .wp-block-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
  padding: 0;
  list-style: none;
}

:where(.entry-content, .article-content) .wp-block-gallery figure {
  margin: 0;
}

:where(.entry-content, .article-content) table {
  display: block;
  width: 100%;
  margin-block: 1.75em;
  overflow-x: auto;
  border-collapse: collapse;
}

:where(.entry-content, .article-content) .wp-block-table {
  max-width: 100%;
  margin-block: 1.75em;
  overflow-x: auto;
}

:where(.entry-content, .article-content) .wp-block-table table {
  display: table;
  min-width: 620px;
  margin: 0;
}

:where(.entry-content, .article-content) th,
:where(.entry-content, .article-content) td {
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-neutral-300);
  text-align: start;
  vertical-align: top;
}

:where(.entry-content, .article-content) th {
  color: var(--color-white);
  background: var(--color-text-heading);
}

:where(.entry-content, .article-content) tbody tr:nth-child(even) {
  background: var(--color-neutral-75);
}

:where(.entry-content, .article-content) iframe,
:where(.entry-content, .article-content) video {
  display: block;
  width: 100%;
  max-width: 100%;
  margin-block: 1.75em;
  border: 0;
}

:where(.entry-content, .article-content) iframe {
  aspect-ratio: 16 / 9;
  height: auto;
}

:where(.entry-content, .article-content) .wp-block-embed,
:where(.entry-content, .article-content) .wp-block-video {
  max-width: 100%;
  margin-block: 1.75em;
  overflow: hidden;
}

:where(.entry-content, .article-content) .wp-block-embed__wrapper {
  position: relative;
  aspect-ratio: 16 / 9;
}

:where(.entry-content, .article-content) .wp-block-embed__wrapper iframe {
  position: absolute;
  inset: 0;
  height: 100%;
  margin: 0;
}

:where(.entry-content, .article-content) code {
  padding: 0.12em 0.35em;
  background: var(--color-surface);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9em;
}

:where(.entry-content, .article-content) pre,
:where(.entry-content, .article-content) .wp-block-code,
:where(.entry-content, .article-content) .wp-block-preformatted {
  max-width: 100%;
  padding: var(--space-5);
  margin-block: 1.75em;
  overflow-x: auto;
  color: var(--color-cyan-50);
  background: var(--color-navy-deep);
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

:where(.entry-content, .article-content) pre code {
  padding: 0;
  color: inherit;
  background: transparent;
}

:where(.entry-content, .article-content) hr,
:where(.entry-content, .article-content) .wp-block-separator {
  margin-block: 2.5em;
  border: 0;
  border-top: 1px solid var(--color-border);
}

.post-page-links {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-8);
}

.post-page-links a,
.post-page-links > span {
  display: inline-flex;
  min-width: 40px;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  color: var(--color-navy);
  border: 1px solid var(--color-border);
  text-decoration: none;
}

.post-page-links a:hover {
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.article-sidebar__sticky {
  position: sticky;
  top: var(--space-5);
  padding: 22px;
  background: var(--color-white);
  border: 1px solid var(--color-border-muted);
}

.article-sidebar__title {
  margin: 0 0 18px;
  color: var(--color-text-heading);
  font-size: 1.25rem;
  line-height: 1.2;
}

.latest-articles {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.latest-article {
  padding-block: var(--space-4);
  border-top: 1px solid var(--color-neutral-225);
}

.latest-article:first-child {
  padding-top: 0;
  border-top: 0;
}

.latest-article:last-child {
  padding-bottom: 0;
}

.latest-article__link {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.latest-article__link--no-media {
  grid-template-columns: 1fr;
}

.latest-article__media {
  display: block;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background: var(--color-surface-subtle);
}

.latest-article__media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition:
    transform var(--transition-base),
    opacity var(--transition-base);
}

.latest-article__content {
  min-width: 0;
}

.latest-article__date {
  display: block;
  color: var(--color-text-muted);
  font-size: var(--font-size-xs);
}

.latest-article__title {
  display: block;
  margin: var(--space-1) 0 0;
  color: var(--color-text-heading);
  font-size: 0.95rem;
  font-weight: var(--font-weight-semibold);
  line-height: 1.4;
}

.latest-article__link:hover .latest-article__title {
  color: var(--color-primary);
}

.latest-article__link:hover img {
  opacity: 0.92;
  transform: scale(1.035);
}

.latest-article__link:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring-color);
  outline-offset: 3px;
}

@media (max-width: 1199px) {
  .article-layout {
    grid-template-columns: 1fr;
    gap: var(--space-10);
  }

  .single-article {
    max-width: 800px;
  }

  .article-sidebar__sticky {
    position: static;
  }

  .latest-articles {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 var(--space-6);
  }
}

@media (max-width: 767px) {
  main.article-page {
    padding-block: var(--space-8) var(--space-10);
  }

  .article-layout {
    gap: var(--space-9);
  }

  .entry-content,
  .article-content {
    font-size: 1.0625rem;
  }

  :where(.entry-content, .article-content) .alignleft,
  :where(.entry-content, .article-content) .alignright {
    float: none;
    width: 100%;
    max-width: 100%;
    margin: 1.75em 0;
  }

  :where(.entry-content, .article-content) .wp-block-gallery,
  .latest-articles {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 479px) {
  .single-article__title {
    font-size: clamp(1.875rem, 9vw, 2.125rem);
    line-height: 1.18;
  }

  .article-sidebar__sticky {
    padding: 19px;
  }

  .latest-article__link {
    grid-template-columns: 72px minmax(0, 1fr);
    gap: var(--space-3);
  }

  :where(.entry-content, .article-content) ul,
  :where(.entry-content, .article-content) ol {
    padding-inline-start: 1.25em;
  }

  :where(.entry-content, .article-content) th,
  :where(.entry-content, .article-content) td {
    padding: 0.65rem 0.75rem;
  }
}
