/* ═══════════════════════════════════════════════════════════════════
   article.css — Individual article page styles
   jules.buddocloud.com/[category]/[slug].html
   Depends on: main.css (tokens, reset, shared components)
   Category badge styles live in articles.css (shared)
   ═══════════════════════════════════════════════════════════════════ */

/* ── READING PROGRESS BAR ────────────────────────────────────────── */

.reading-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: calc(var(--z-nav) + 1);
  background: transparent;
  pointer-events: none;
}

.reading-progress__bar {
  height: 100%;
  width: 0%;
  background: var(--red-primary);
  transform-origin: left;
  transition: width 0.1s linear;

  /* Chromium scroll-driven animation — progressive enhancement */
  @supports (animation-timeline: scroll()) {
    width: 100%;
    transform: scaleX(0);
    transition: none;
    animation: reading-progress-grow linear;
    animation-timeline: scroll(root block);
  }
}

@keyframes reading-progress-grow {
  from { transform: scaleX(0); }
  to   { transform: scaleX(1); }
}

@media (prefers-reduced-motion: reduce) {
  .reading-progress__bar {
    transition: none;
    animation: none;
  }
}

/* ── ARTICLE PAGE BODY ───────────────────────────────────────────── */

.article-page-body {
  /* Ensure nav doesn't cover progress bar */
}

/* ── ARTICLE HEADER ──────────────────────────────────────────────── */

.article-header {
  padding: clamp(3rem, 6vw, 5rem) 0 clamp(2rem, 4vw, 3rem);
  border-bottom: 1px solid var(--border);
}

.article-header__inner {
  /* prose-wrap constrains width — defined in main.css */
}

.article-breadcrumb {
  margin-bottom: var(--space-3);
}

.article-cat-badge {
  /* Inherits from .cat-badge in articles.css */
  font-size: var(--text-sm);
}

.article-headline {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: var(--weight-black);
  line-height: var(--leading-headline);
  letter-spacing: var(--tracking-display);
  color: var(--text-emphasis);
  margin: 0 0 var(--space-3);
  text-wrap: balance;
  text-shadow: var(--text-shadow-headline);
}

@media (min-width: 768px) {
  .article-headline {
    font-size: var(--text-3xl);
  }
}

.article-standfirst {
  font-family: var(--font-body);
  font-size: var(--text-md);
  font-style: italic;
  font-weight: var(--weight-medium);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
  margin: 0 0 var(--space-3);
  max-width: 36rem;
}

.article-byline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-faint);
}

.article-author { color: var(--text-secondary); font-weight: var(--weight-medium); }
.article-date   { color: var(--text-faint); }
.article-readtime { color: var(--text-faint); }
.meta-sep       { color: var(--border-2); }

/* ── HERO IMAGE ──────────────────────────────────────────────────── */

.article-hero {
  margin: 0 0 clamp(2rem, 4vw, 3.5rem);
}

.article-hero__img-wrap {
  width: 100%;
  aspect-ratio: 21 / 9;
  overflow: hidden;
  background: var(--bg-deepest);
  position: relative;
}

@media (max-width: 600px) {
  .article-hero__img-wrap { aspect-ratio: 16 / 9; }
}

.article-hero__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Category-tinted placeholder hero */
.article-hero__placeholder {
  width: 100%;
  height: 100%;
  position: relative;
}

.article-hero__placeholder--empire-resistance  { background: linear-gradient(160deg, #2A0808 0%, #0D0D0F 60%); }
.article-hero__placeholder--us-politics        { background: linear-gradient(160deg, #0A1520 0%, #0D0D0F 60%); }
.article-hero__placeholder--borders-migration  { background: linear-gradient(160deg, #2A1000 0%, #0D0D0F 60%); }
.article-hero__placeholder--class-labor        { background: linear-gradient(160deg, #260808 0%, #0D0D0F 60%); }
.article-hero__placeholder--animal-liberation  { background: linear-gradient(160deg, #061A0C 0%, #0D0D0F 60%); }
.article-hero__placeholder--ecology-capital    { background: linear-gradient(160deg, #041818 0%, #0D0D0F 60%); }
.article-hero__placeholder--culture-commodity  { background: linear-gradient(160deg, #160820 0%, #0D0D0F 60%); }
.article-hero__placeholder--theory-method      { background: linear-gradient(160deg, #0C1018 0%, #0D0D0F 60%); }

/* Subtle red edge glow */
.article-hero__placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at top left, rgba(224, 51, 51, 0.08) 0%, transparent 60%);
  pointer-events: none;
}

.article-hero__caption {
  padding: var(--space-1) 0;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-style: italic;
  line-height: 1.4;
  max-width: var(--prose-width);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ── ARTICLE LAYOUT (prose + ToC) ────────────────────────────────── */

.article-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-8);
  padding-bottom: clamp(3rem, 6vw, 5rem);
}

@media (min-width: 1100px) {
  .article-layout {
    grid-template-columns: 1fr 220px;
    align-items: start;
  }

  /* Body first in markup = first visually on mobile, left on desktop */
  .article-body { order: 1; }
  .article-toc  { order: 2; }
}

/* ── PROSE-WRAP UTILITY ──────────────────────────────────────────── */
/* Applied to header, body, footer, bio sections */

.prose-wrap {
  max-width: var(--prose-width);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ── ARTICLE BODY / PROSE ────────────────────────────────────────── */

.article-body {
  max-width: var(--prose-width);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--text-primary);
  letter-spacing: var(--tracking-body);
}

/* Paragraph spacing */
.article-body p {
  margin: 0;
}

.article-body p + p,
.article-body p + h2,
.article-body p + h3,
.article-body blockquote + p,
.article-body .pull-quote + p {
  margin-top: 1.4em;
}

.article-body h2 + p,
.article-body h3 + p {
  margin-top: 0.85em;
}

/* Drop cap on first paragraph */
.article-body > p:first-of-type::first-letter {
  font-family: var(--font-display);
  font-size: 4.25rem;
  font-weight: var(--weight-black);
  float: left;
  line-height: 0.78;
  margin: 0.1em 0.1em 0 0;
  color: var(--red-primary);
  text-shadow: none;
}

/* Headings */
.article-body h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-headline);
  letter-spacing: var(--tracking-display);
  color: var(--text-emphasis);
  margin: clamp(2.5rem, 5vw, 3.5rem) 0 0.85rem;
  padding-left: 1.1rem;
  border-left: 4px solid var(--red-primary);
  text-wrap: balance;
}

.article-body h3 {
  font-family: var(--font-ui);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-headline);
  color: var(--text-emphasis);
  margin: clamp(2rem, 4vw, 3rem) 0 0.65rem;
}

/* Links */
.article-body a {
  color: var(--red-primary);
  text-decoration: underline;
  text-decoration-color: rgba(224, 51, 51, 0.4);
  text-underline-offset: 3px;
  transition: text-decoration-color var(--anim-hover), color var(--anim-hover);
}

.article-body a:hover {
  color: var(--red-bright);
  text-decoration-color: var(--red-bright);
}

/* Blockquote */
.article-body blockquote {
  margin: 2.5rem 0;
  padding: 1.25rem 1.5rem;
  border-left: 4px solid var(--red-primary);
  background: var(--bg-elevated);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-primary);
  position: relative;
}

.article-body blockquote::before {
  content: '\201C';
  font-family: var(--font-display);
  font-size: 3.5rem;
  color: var(--red-dimmed);
  line-height: 0;
  vertical-align: -0.6em;
  margin-right: 0.1em;
  font-style: normal;
}

.article-body blockquote p { margin: 0; }

/* Quote attribution */
.article-body .article-quote-attr {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-faint);
  margin-top: -1rem;
  padding-left: 1.5rem;
  font-style: normal;
}

/* Pull quote */
.article-body .pull-quote {
  max-width: 100%;
  margin: clamp(2rem, 4vw, 3rem) 0;
  padding: 1.75rem 2rem;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-style: italic;
  font-weight: var(--weight-medium);
  line-height: 1.35;
  color: var(--text-emphasis);
  border-top: 2px solid var(--red-primary);
  border-bottom: 2px solid var(--red-primary);
  background: linear-gradient(to bottom, rgba(224, 51, 51, 0.04), transparent);
}

/* Inline images */
.article-body .article-image {
  margin: 2rem 0;
}

.article-body .article-image img {
  width: 100%;
  border-radius: var(--radius-sm);
  display: block;
}

.article-body .article-image figcaption {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-faint);
  font-style: italic;
  margin-top: var(--space-1);
  padding-left: var(--space-1);
  border-left: 2px solid var(--border);
}

/* Strong, em */
.article-body strong { color: var(--text-emphasis); font-weight: var(--weight-semibold); }
.article-body em     { font-style: italic; }

/* Lists — restore list-style nullified by reset.css */
.article-body ul {
  list-style: disc;
  padding-left: 1.5rem;
  margin: 1.2em 0;
}

.article-body ol {
  list-style: decimal;
  padding-left: 1.5rem;
  margin: 1.2em 0;
}

.article-body li {
  margin-bottom: 0.5em;
  line-height: var(--leading-body);
}

/* ── TABLE OF CONTENTS ───────────────────────────────────────────── */

.article-toc {
  display: none; /* Hidden on mobile/tablet — shown via media query below */
}

@media (min-width: 1100px) {
  .article-toc {
    display: block;
    position: sticky;
    top: calc(var(--nav-height) + var(--space-4));
    max-height: calc(100vh - var(--nav-height) - var(--space-8));
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
  }
}

.toc-title {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 var(--space-2);
}

.toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-left: 2px solid var(--border);
}

.toc-list li {
  margin-bottom: 0;
}

.toc-list a {
  display: block;
  padding: 0.4rem 0 0.4rem 1rem;
  font-family: var(--font-ui);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  line-height: 1.4;
  border-left: 2px solid transparent;
  margin-left: -2px;
  transition: color var(--anim-hover), border-color var(--anim-hover);
}

.toc-list a:hover { color: var(--text-primary); }

.toc-list a.toc-active {
  color: var(--red-primary);
  border-left-color: var(--red-primary);
  font-weight: var(--weight-medium);
}

/* ── ARTICLE FOOTER (tags + share) ───────────────────────────────── */

.article-footer {
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .article-footer {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
  }
}

/* Tags */
.article-tags {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.article-tags__label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-faint);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tag-chip {
  display: inline-flex;
  padding: 0.2rem 0.65rem;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  text-decoration: none;
  transition: color var(--anim-hover), border-color var(--anim-hover), background var(--anim-hover);
}

.tag-chip:hover {
  color: var(--red-primary);
  border-color: var(--red-primary);
  background: var(--red-faint);
}

/* Share buttons */
.share-buttons {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.share-buttons__label {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--text-faint);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}

.share-buttons__group {
  display: flex;
  gap: 0.4rem;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
  color: var(--text-secondary);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  text-decoration: none;
  cursor: pointer;
  transition:
    color var(--anim-hover),
    border-color var(--anim-hover),
    background var(--anim-hover),
    transform var(--anim-hover);
  white-space: nowrap;
}

.share-btn:hover {
  color: var(--red-primary);
  border-color: var(--red-primary);
  background: var(--red-faint);
  transform: translateY(-1px);
}

.share-btn:focus-visible {
  outline: 2px solid var(--red-primary);
  outline-offset: 2px;
}

/* Copy confirmation state */
.share-btn--copy.copied {
  color: #3DAA6A;
  border-color: #196F3D;
  background: rgba(25, 111, 61, 0.12);
}

/* ── AUTHOR BIO ──────────────────────────────────────────────────── */

.author-bio {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: clamp(2rem, 4vw, 3rem) 0;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 480px) {
  .author-bio { flex-direction: column; }
}

.author-bio__avatar {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-highlight);
  border: 2px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
}

.author-bio__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author-bio__initials {
  font-family: var(--font-display);
  font-size: 1.5rem;
  font-weight: var(--weight-bold);
  color: var(--red-primary);
  line-height: 1;
}

.author-bio__content {
  flex: 1;
}

.author-bio__name {
  font-family: var(--font-ui);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--text-emphasis);
  margin: 0 0 0.15rem;
}

.author-bio__affiliation {
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-faint);
  letter-spacing: var(--tracking-ui);
  margin: 0 0 var(--space-2);
}

.author-bio__bio {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  color: var(--text-secondary);
  margin: 0 0 var(--space-2);
}

.author-bio__links {
  display: flex;
  gap: var(--space-2);
}

.author-bio__link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  color: var(--text-faint);
  text-decoration: none;
  transition: color var(--anim-hover);
}

.author-bio__link:hover { color: var(--red-primary); }

/* ── RELATED ARTICLES ────────────────────────────────────────────── */

.related-articles {
  background: var(--bg-elevated);
  border-top: 3px solid var(--border);
  padding: clamp(3rem, 6vw, 5rem) 0;
  margin-top: clamp(3rem, 6vw, 5rem);
  position: relative;
}

.related-articles::before {
  content: '';
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--red-primary), var(--red-dimmed), transparent);
}

.related-articles__inner { /* wrap utility applied in HTML */ }

.related-articles__title {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--text-emphasis);
  margin: 0 0 var(--space-5);
  letter-spacing: var(--tracking-display);
}

.related-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-3);
}

@media (min-width: 640px) {
  .related-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 900px) {
  .related-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ── SCROLL REVEAL on article page ──────────────────────────────── */

.js-enabled [data-reveal="fade-up"] {
  opacity: 0;
  transform: translateY(28px);
}

.js-enabled [data-reveal="fade-in"] {
  opacity: 0;
}

.js-enabled [data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0);
  transition:
    opacity 0.6s var(--ease-out-expo),
    transform 0.6s var(--ease-out-expo);
}

.js-enabled [data-reveal-delay="100"].is-visible { transition-delay: 0.1s; }
.js-enabled [data-reveal-delay="200"].is-visible { transition-delay: 0.2s; }
.js-enabled [data-reveal-delay="300"].is-visible { transition-delay: 0.3s; }

@media (prefers-reduced-motion: reduce) {
  .js-enabled [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
  }
}
