/**
 * MX Blog Stylesheet — mx.allabout.network
 * @description Dark-themed blog styles adapted from shared-mx.css.
 *              Preserves the author card, collapsible TOC, and article
 *              layout patterns, restyled to match the bookshop dark theme.
 * @version 1.0
 * @author Tom Cranstoun
 * @mx:status active
 * @mx:contentType stylesheet
 */

/* ══════════════════════════════════════════════
   Blog-specific layout
   ══════════════════════════════════════════════ */

.blog-page {
  max-width: 960px;
  margin: 0 auto;
  padding: 6rem 2rem 2rem;
}

/* ── Blog Introduction / Author Card ── */
.blog-introduction {
  background-color: var(--mx-surface);
  border-left: 4px solid var(--mx-gold);
  padding: 1.5rem;
  margin-bottom: 2rem;
  border-radius: 4px;
}

.introduction-content {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
}

.author-image {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  transition: opacity 0.2s, transform 0.2s;
}

.introduction-content a:focus {
  outline: 2px solid var(--mx-gold);
  outline-offset: 2px;
  border-radius: 50%;
}

.introduction-content a:hover .author-image {
  opacity: 0.85;
  transform: scale(1.05);
}

.introduction-text {
  flex: 1;
}

.introduction-message {
  font-size: 1.1rem;
  line-height: 1.5;
  margin-bottom: 0.5rem;
  color: var(--mx-white);
}

.author-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--mx-text-muted);
}

.author-contact {
  font-size: 0.9rem;
  color: var(--mx-text-muted);
  margin-top: 0.5rem;
}

.author-contact a {
  color: var(--mx-blue-light);
  text-decoration: none;
}

.author-contact a:hover {
  text-decoration: underline;
  color: var(--mx-gold);
}

/* ── Table of Contents (Collapsible Index) ── */
.table-of-contents {
  background-color: var(--mx-surface);
  border: 1px solid var(--mx-border);
  border-radius: 4px;
  padding: 1rem;
  margin-bottom: 2rem;
}

.table-of-contents summary {
  font-size: 1.25rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.5rem;
  list-style-position: outside;
  color: var(--mx-gold);
  -webkit-user-select: none;
  user-select: none;
}

.table-of-contents summary:focus {
  outline: 2px solid var(--mx-gold);
  outline-offset: 2px;
}

.table-of-contents summary:hover {
  color: var(--mx-blue-light);
}

.table-of-contents summary::marker {
  content: '▶ ';
}

.table-of-contents[open] summary::marker {
  content: '▼ ';
}

.table-of-contents nav {
  margin-top: 1rem;
  padding-left: 1rem;
}

.table-of-contents ul {
  list-style: none;
  padding-left: 0;
}

.table-of-contents li {
  margin-bottom: 0.5rem;
}

.table-of-contents a {
  color: var(--mx-blue-light);
  text-decoration: none;
  transition: color 0.2s;
}

.table-of-contents a:hover {
  color: var(--mx-gold);
  text-decoration: underline;
}

.table-of-contents a:focus {
  outline: 2px solid var(--mx-gold);
  outline-offset: 2px;
}

/* ── Article Header ── */
article header h1 {
  font-size: 2.5rem;
  line-height: 1.2;
  margin-bottom: 1rem;
  color: var(--mx-white);
}

.article-meta {
  color: var(--mx-text-muted);
  font-size: 0.95rem;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* ── Article Content Typography ── */
article h2 {
  font-size: 1.875rem;
  margin-top: 3rem;
  margin-bottom: 1rem;
  color: var(--mx-white);
  border-bottom: 2px solid var(--mx-border);
  padding-bottom: 0.5rem;
}

article h3 {
  font-size: 1.5rem;
  margin-top: 2rem;
  margin-bottom: 1rem;
  color: var(--mx-white);
}

article h4 {
  font-size: 1.25rem;
  margin-top: 1.75rem;
  margin-bottom: 0.875rem;
  color: var(--mx-white);
  font-weight: 600;
}

article h5 {
  font-size: 1.125rem;
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  color: var(--mx-white);
  font-weight: 600;
}

article h6 {
  font-size: 1rem;
  margin-top: 1.25rem;
  margin-bottom: 0.625rem;
  color: var(--mx-white);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

article p {
  margin-bottom: 1.5rem;
  color: var(--mx-text);
}

article ul,
article ol {
  margin-bottom: 1.5rem;
  padding-left: 2rem;
}

article li {
  margin-bottom: 0.5rem;
  color: var(--mx-text);
}

/* ── Code Blocks ── */
pre {
  background-color: var(--mx-blue-dark);
  border: 1px solid var(--mx-border);
  border-radius: 4px;
  padding: 1rem;
  overflow-x: auto;
  margin-bottom: 1.5rem;
}

code {
  font-family: var(--mx-font-mono);
  font-size: 0.9em;
  color: var(--mx-blue-light);
}

p code,
li code {
  background-color: var(--mx-blue-dark);
  border: 1px solid var(--mx-border);
  border-radius: 3px;
  padding: 0.2em 0.4em;
}

/* ── Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5rem;
}

caption {
  font-weight: 600;
  text-align: left;
  margin-bottom: 0.5rem;
  color: var(--mx-white);
}

th,
td {
  border: 1px solid var(--mx-border);
  padding: 0.75rem;
  text-align: left;
}

th {
  background-color: var(--mx-blue-dark);
  font-weight: 600;
  color: var(--mx-white);
}

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

figcaption {
  font-size: 0.9rem;
  color: var(--mx-text-muted);
  text-align: center;
  margin-top: 0.5rem;
  font-style: italic;
}

/* ── Horizontal Rules ── */
hr {
  border: none;
  border-top: 1px solid var(--mx-border);
  margin: 3rem 0;
}

/* ── Footnotes ── */
.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--mx-border);
  font-size: 0.95rem;
}

.footnotes h2 {
  font-size: 1.5rem;
  margin-top: 0;
  border-bottom: none;
}

.footnotes ol {
  padding-left: 1.5rem;
}

.footnotes li {
  margin-bottom: 0.75rem;
}

.footnotes ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  list-style-type: disc;
}

.footnotes p {
  margin-bottom: 0.75rem;
}

.footnotes p:last-child {
  margin-bottom: 0;
}

sup a {
  text-decoration: none;
  font-weight: 600;
  color: var(--mx-gold);
}

sup a:hover {
  text-decoration: underline;
}

/* ── Author Bio Link ── */
.author-bio-link {
  margin-top: 3rem;
  padding-top: 2rem;
  border-top: 2px solid var(--mx-border);
}

.author-bio-link p {
  font-size: 0.95rem;
  color: var(--mx-text-muted);
}

.author-bio-link a {
  color: var(--mx-blue-light);
  font-weight: 600;
}

.author-bio-link a:hover {
  text-decoration: underline;
  color: var(--mx-gold);
}

/* ── Back to Top Button ── */
.back-to-top {
  position: fixed;
  bottom: 2rem;
  left: 2rem;
  background-color: var(--mx-gold);
  color: var(--mx-blue-deep);
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  text-decoration: none;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: background-color 0.2s, transform 0.2s;
  z-index: 1000;
}

.back-to-top:hover {
  background-color: #c49a3a;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  text-decoration: none;
  color: var(--mx-blue-deep);
}

.back-to-top:focus {
  outline: 2px solid var(--mx-white);
  outline-offset: 2px;
}

/* ── Blog Footer ── */
.blog-page footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--mx-border);
  text-align: center;
  color: var(--mx-text-muted);
  font-size: 0.9rem;
}

/* ── Cross-links Navigation ── */
.cross-links {
  margin-top: 3rem;
  padding: 2rem;
  background: var(--mx-surface);
  border-radius: 8px;
  border: 1px solid var(--mx-border);
}

.cross-links h2 {
  font-size: 1.25rem;
  color: var(--mx-white);
  margin-bottom: 1rem;
  border-bottom: none;
}

.cross-links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.75rem;
}

.cross-links-grid a {
  display: block;
  padding: 0.75rem 1rem;
  background: var(--mx-blue-dark);
  border: 1px solid var(--mx-border);
  border-radius: 4px;
  color: var(--mx-blue-light);
  transition: background 0.2s, color 0.2s;
}

.cross-links-grid a:hover {
  background: var(--mx-blue-mid);
  color: var(--mx-gold);
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .blog-page {
    padding: 5rem 1rem 1rem;
  }

  article header h1 {
    font-size: 2rem;
  }

  article h2 {
    font-size: 1.5rem;
  }

  .introduction-content {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .back-to-top {
    bottom: 1rem;
    left: 1rem;
    padding: 0.75rem 1rem;
    min-width: 44px;
    min-height: 44px;
  }
}

/* ── Print ── */
@media print {
  .skip-link,
  .back-to-top,
  .table-of-contents,
  .cross-links {
    display: none;
  }

  .blog-page {
    max-width: 100%;
    padding: 0;
  }

  article h2 {
    page-break-after: avoid;
  }
}
