/* ════════════════════════════════════════════════
   Article reader
   Full-viewport modal with markdown-rendered article body.
════════════════════════════════════════════════ */

.article-modal {
  position: fixed;
  inset: 0;
  z-index: 8000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: article-modal-fade 180ms ease;
}

@keyframes article-modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.article-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 37, 48, 0.55);
  cursor: pointer;
}

.article-modal__panel {
  position: relative;
  background: var(--card);
  border-radius: var(--radius);
  width: 100%;
  max-width: 760px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(26, 37, 48, 0.25);
  overflow: hidden;
}

/* ── Header ───────────────────────────────── */
.article-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}

.article-modal__close {
  background: none;
  border: none;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text2);
  cursor: pointer;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.article-modal__close:hover {
  background: var(--bg3);
  color: var(--green);
}

.article-modal__cat {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-bdr);
  padding: 4px 10px;
  border-radius: 2px;
}

/* ── Body (scrollable) ──────────────────── */
.article-modal__body {
  flex: 1;
  overflow-y: auto;
  padding: 36px 48px 48px;
}

/* Loading state */
.article-modal__loading {
  text-align: center;
  padding: 80px 20px;
  color: var(--text3);
}
.article-modal__spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--bg3);
  border-top-color: var(--green);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: article-spin 0.8s linear infinite;
}
@keyframes article-spin {
  to { transform: rotate(360deg); }
}

/* Placeholder for unwritten articles */
.article-modal__placeholder {
  margin-top: 32px;
  padding: 24px;
  background: var(--bg2);
  border: 1px dashed var(--border2);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text2);
  line-height: 1.7;
}
.article-modal__placeholder p { margin-bottom: 10px; }
.article-modal__placeholder p:last-child { margin-bottom: 0; }

/* Raw fallback if marked fails to load */
.article-modal__raw {
  white-space: pre-wrap;
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
}

/* ── Article content typography ─────────── */
.article-content {
  font-family: 'Barlow', sans-serif;
  font-size: 16px;
  line-height: 1.75;
  color: var(--text);
  max-width: 640px;
  margin: 0 auto;
}

.article-content h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 32px;
  font-weight: 900;
  line-height: 1.15;
  color: var(--silver-dk);
  margin-bottom: 16px;
}

.article-content > p:first-of-type {
  font-size: 13px;
  color: var(--text3);
  margin-bottom: 24px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.article-content__lead,
.article-content > p:nth-of-type(2) {
  font-size: 18px;
  line-height: 1.65;
  color: var(--text2);
  margin-bottom: 24px;
}

.article-content h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--silver-dk);
  margin-top: 36px;
  margin-bottom: 12px;
  padding-top: 8px;
}

.article-content h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  margin-top: 24px;
  margin-bottom: 8px;
}

.article-content p {
  margin-bottom: 16px;
}

.article-content strong {
  color: var(--silver-dk);
  font-weight: 600;
}

.article-content em { color: var(--text2); }

.article-content ul,
.article-content ol {
  margin: 0 0 18px 0;
  padding-left: 22px;
}

.article-content li {
  margin-bottom: 8px;
  line-height: 1.7;
}

.article-content blockquote {
  margin: 20px 0;
  padding: 12px 18px;
  border-left: 3px solid var(--green);
  background: var(--green-bg);
  font-size: 15px;
  color: var(--text2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.article-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 32px 0;
}

.article-content code {
  background: var(--bg2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 2px;
  font-family: monospace;
  font-size: 13px;
  color: var(--silver-dk);
}

.article-content a {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid var(--green-bdr);
  transition: border-color var(--transition);
}
.article-content a:hover {
  border-bottom-color: var(--green);
}

/* References section — last h2 in the article */
.article-content h2:last-of-type + ul,
.article-content h2:last-of-type ~ ul {
  font-size: 13px;
  color: var(--text3);
  line-height: 1.6;
}
.article-content h2:last-of-type + ul li,
.article-content h2:last-of-type ~ ul li {
  margin-bottom: 8px;
}

/* ── Footer ───────────────────────────────── */
.article-modal__footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  font-size: 11px;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 700;
}

.article-modal__brand { color: var(--green); }

/* ── Mobile ──────────────────────────────── */
@media (max-width: 600px) {
  .article-modal { padding: 0; }
  .article-modal__panel {
    max-width: none;
    max-height: none;
    height: 100vh;
    border-radius: 0;
  }
  .article-modal__body { padding: 24px 20px 32px; }
  .article-content h1 { font-size: 26px; }
  .article-content { font-size: 15px; }
  .article-content > p:nth-of-type(2) { font-size: 16px; }
}
