/* Article page styles (individual essays, rebuttals, explanations) */

/* Sticky TOC */
.toc {
  position: sticky;
  top: 0;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 0.75rem 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 10;
}


.toc::-webkit-scrollbar {
  display: none;
}

/* Remove fade when scrolled to the end */
.toc.toc-end::after {
  opacity: 0;
}

.toc-label {
  flex-shrink: 0;
  margin-right: auto;
  font-size: 1.1rem;
  color: var(--text-faint);
  opacity: 0.5;
}

.toc::after {
  content: '';
  position: sticky;
  right: 0;
  flex-shrink: 0;
  min-width: 3rem;
  margin-left: -3rem;
  align-self: stretch;
  background: linear-gradient(to right, transparent, var(--bg));
  pointer-events: none;
  z-index: 1;
  transition: opacity 0.15s;
}

.toc a {
  font-size: 0.8rem;
  color: var(--text-faint);
  white-space: nowrap;
  border-bottom: none;
}

.toc a:hover,
.toc a.active {
  color: var(--text);
}

.toc a.h3 {
  padding-left: 0.75rem;
}

header {
  margin-bottom: 1.5rem;
}

.kicker {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 0.5rem;
}

.header-row {
  display: flex;
  align-items: baseline;
}

.header-row h1 {
  flex: 1;
}

.byline {
  position: relative;
  flex-shrink: 0;
  font-size: 0.75rem;
  color: var(--text-faint);
}

.byline summary {
  display: flex;
  align-items: center;
  cursor: pointer;
  list-style: none;
}

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

.byline summary::marker {
  content: '';
}

.byline-icon {
  font-size: 18px;
  color: var(--text-faint);
  transition: color 0.15s;
}

.byline summary:hover .byline-icon {
  color: var(--text);
}

.byline-detail {
  position: absolute;
  top: calc(100% + 0.4rem);
  right: 0;
  z-index: 20;
  padding: 0.6rem 0.75rem;
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--text-faint);
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 0.5rem;
  max-width: 320px;
  min-width: 240px;
  box-shadow: var(--glass-shadow);
  animation: byline-in 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.byline-date {
  margin: 0 0 0.4rem;
  font-weight: 600;
  color: var(--text-muted);
}

.byline-label {
  margin: 0 0 0.5rem;
}

.byline-checks {
  margin: 0;
  padding: 0;
  list-style: none;
}

.byline-checks li {
  padding: 0.25rem 0;
  margin: 0;
  color: var(--text-muted);
}

.byline-checks li::before {
  content: '✓ ';
  color: var(--text-faint);
}

.byline-prompt {
  margin: 0.5rem 0 0;
  padding: 0.45rem 0.6rem;
  font-size: 0.7rem;
  font-style: italic;
  color: var(--text-faint);
  background: var(--border);
  border-radius: 0.25rem;
}

@keyframes byline-in {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Article metadata footer */
.article-footer {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.article-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  transition: opacity 0.15s;
}

.article-footer:hover .article-footer-row:not(:hover) {
  opacity: 0.7;
}

.article-footer-row:last-child {
  border-bottom: none;
}

.article-footer-label {
  font-size: 0.75rem;
  color: var(--text-faint);
}

.article-footer-value {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.tldr {
  padding: 1.5rem 0;
  margin-bottom: 2.5rem;
  border-top: 1px solid var(--border-muted);
  border-bottom: 1px solid var(--border-muted);
  counter-reset: overview;
}

.tldr h2 {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 0 0 1rem;
}

.tldr ul {
  list-style: none;
  margin: 0;
}

section.tldr ul li {
  display: grid;
  grid-template-columns: 1.5rem 1fr;
  gap: 0.75rem;
  align-items: baseline;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text);
  padding: 0.6rem 0;
  margin: 0;
  border-bottom: 1px solid var(--border);
  counter-increment: overview;
  transition: opacity 0.15s;
}

.tldr li:last-child {
  border-bottom: none;
}

section.tldr ul li::before {
  content: counter(overview);
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.15;
  color: var(--border-muted);
  transition: color 0.15s;
}

.tldr ul:hover li:not(:hover) {
  opacity: 0.5;
}

.tldr ul li:hover::before {
  color: var(--text);
}

/* Long-form content */
article p {
  hyphens: auto;
}

article h2 {
  font-size: 1rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: normal;
  color: var(--text);
  margin-top: 2.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: 4.5rem;
}

article h3 {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 2rem;
  margin-bottom: 0.75rem;
}

article ul,
article ol {
  margin-left: 1.5rem;
  margin-bottom: 1.5rem;
  list-style: disc;
}

article ol {
  list-style: decimal;
}

article li {
  margin-bottom: 0.5rem;
}

article li::marker {
  color: var(--text-faint);
}

/* Blockquotes for claims being addressed */
blockquote {
  border-left: 2px solid var(--border-muted);
  padding-left: 1rem;
  margin: 1.5rem 0;
  font-style: italic;
  color: var(--text-muted);
}

blockquote cite {
  display: block;
  font-style: normal;
  font-size: 0.85rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
}

/* Key points / summary boxes */
.summary {
  background: var(--border);
  padding: 1.25rem;
  margin: 2rem 0;
}

.summary h4 {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin-bottom: 0.75rem;
}

.summary p {
  margin-bottom: 0;
  color: var(--text);
}

.summary ul {
  margin-bottom: 0;
}

/* Figures and captions */
figure {
  margin: 2rem 0;
}

figure img {
  max-width: 100%;
  height: auto;
  border-radius: 0.5rem 0.5rem 0 0;
  cursor: pointer;
  display: block;
}

figcaption {
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 0.75rem 1rem;
  background: var(--border);
  border-radius: 0 0 0.5rem 0.5rem;
}

figcaption .source {
  color: var(--text-faint);
  font-size: 0.75rem;
}

figcaption .source a {
  color: var(--text-faint);
  border-bottom: none;
}

figcaption .source a:hover {
  color: var(--text-muted);
}

/* Full-screen image viewer (stage 1) */
.img-viewer {
  display: none;
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 101;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.img-viewer.open {
  display: flex;
  align-items: center;
  justify-content: center;
}

.img-viewer img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
  transition: transform 0.15s ease;
}

.img-viewer.dragging img {
  transition: none;
}

.img-viewer-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 102;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
  width: 2.5rem;
  height: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  transition: background 0.15s;
}

.img-viewer-close .material-symbols-outlined {
  font-size: 20px;
  color: rgba(255, 255, 255, 0.8);
}

.img-viewer-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.img-viewer-close:hover .material-symbols-outlined {
  color: #fff;
}


.img-viewer-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 102;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 3rem 1.5rem 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.5));
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.img-viewer.zoomed .img-viewer-bottom,
.img-viewer.panel-open .img-viewer-bottom {
  opacity: 0;
  pointer-events: none !important;
}

.img-viewer-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.5rem 0.5rem 1rem;
  pointer-events: auto;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 2rem;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  margin-bottom: 1.5rem;
  max-width: 500px;
  transition: background 0.15s;
}

.img-viewer-bar:hover {
  background: rgba(255, 255, 255, 0.14);
}

.img-viewer-bar .chevron-icon {
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 50%;
}

.img-viewer-bar .chevron-icon .material-symbols-outlined {
  font-size: 18px;
  color: rgba(255, 255, 255, 0.8);
}

.img-viewer-caption {
  font-size: 0.8rem;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}

.img-viewer-caption .source {
  display: none;
}

.img-viewer.cursor-grab { cursor: grab; }
.img-viewer.cursor-grabbing { cursor: grabbing; }
.img-viewer.cursor-zoom-in { cursor: zoom-in; }
.img-viewer.cursor-zoom-out { cursor: zoom-out; }

/* Image modal with explanation (stage 2, card over viewer) */
.img-modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1rem 2.5vh;
  visibility: hidden;
  pointer-events: none;
  transition: visibility 0.35s;
}

.img-modal.open {
  visibility: visible;
  pointer-events: auto;
}

.img-modal-content {
  width: 100%;
  max-width: 600px;
  max-height: 50vh;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
  padding: 1.25rem 1.75rem 1.75rem;
  border-radius: 1rem;
  background: rgba(30, 30, 30, 0.45);
  backdrop-filter: blur(48px) saturate(1.6);
  -webkit-backdrop-filter: blur(48px) saturate(1.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.9);
  transform: translateY(1.5rem);
  opacity: 0;
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
              opacity 0.3s ease;
}

.img-modal-content::before {
  content: '';
  display: block;
  width: 2rem;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 3px;
  margin: 0 auto 1.25rem;
}

.img-modal.open .img-modal-content {
  transform: translateY(0);
  opacity: 1;
}

.img-modal-content::-webkit-scrollbar {
  width: 4px;
}

.img-modal-content::-webkit-scrollbar-track {
  background: transparent;
}

.img-modal-content::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

.img-modal h3 {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.95);
  margin-bottom: 1rem;
}

.img-modal p {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.6;
  margin-bottom: 1rem;
}

.img-modal .source {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.35);
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Citations and references */
.references {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.references h2 {
  scroll-margin-top: 4.5rem;
}

.ref-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  scroll-margin-top: 4.5rem;
  transition: background 0.6s ease, opacity 0.15s, border-color 0.15s;
  position: relative;
  cursor: pointer;
}

.ref-card:hover {
  border-color: var(--text-faint);
}

.ref-card.highlight {
  background: var(--border);
  transition: background 0s;
}

.ref-num {
  font-size: 0.7rem;
  color: var(--text-faint);
  flex-shrink: 0;
  min-width: 1.25rem;
  text-align: right;
}

.ref-body {
  flex: 1;
  min-width: 0;
}

.ref-title {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 0.15rem;
  line-height: 1.4;
}

.ref-meta {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin: 0;
  line-height: 1.4;
}

.ref-link {
  flex-shrink: 0;
  color: var(--text-faint);
  border-bottom: none;
}

.ref-link::after {
  content: '';
  position: absolute;
  inset: 0;
}

.ref-card:hover .ref-link {
  color: var(--text);
}

.ref-link .material-symbols-outlined {
  font-size: 16px;
}

/* Inline footnote markers */
sup a {
  font-size: 0.75rem;
  border-bottom: none;
  color: var(--text-faint);
}

sup a:hover {
  color: var(--text);
}

/* Related articles carousel */
.related {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border);
}

.related li {
  margin-bottom: 0.5rem;
  transition: opacity 0.15s;
}

.related ul:hover li:not(:hover) {
  opacity: 0.7;
}

.related li a {
  color: var(--text-muted);
  border-bottom: none;
}

.related li a:hover {
  color: var(--text);
}

.claim-num {
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-right: 0.15rem;
}

/* Mobile adjustments */
@media (max-width: 480px) {
  .toc {
    position: static;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    margin-bottom: 1.5rem;
    margin-left: -1rem;
    margin-right: -1rem;
  }

  .toc-label {
    display: none;
  }

  .toc a {
    font-size: 0.75rem;
  }

  .back {
    font-size: 0.8rem;
    margin-bottom: 1.5rem;
  }

  article h2 {
    margin-top: 2rem;
  }

  article ul,
  article ol {
    margin-left: 1rem;
  }

  .summary {
    margin-left: -1rem;
    margin-right: -1rem;
    padding: 1rem;
  }

  figure {
    margin-left: -1rem;
    margin-right: -1rem;
  }

  figure img {
    border-radius: 0;
  }

  figcaption {
    padding: 0.75rem 1rem;
    border-radius: 0;
  }

  .img-modal-content {
    padding: 1.5rem 1rem;
  }

  .references,
  .related {
    margin-top: 2rem;
    padding-top: 1.5rem;
  }

  .ref-card {
    gap: 0.5rem;
    padding: 0.65rem 0.75rem;
  }

  .ref-title {
    font-size: 0.8rem;
  }

  .ref-meta {
    font-size: 0.7rem;
  }
}
