/*WCAG 2.1 AA Compliant Shared Styles for MX Blog Posts
 * @file shared-mx.css
 * @version 1.0
 * @author Tom Cranstoun
 *
 * @mx:category mx-tools
 * @mx:status active
 * @mx:contentType stylesheet
 * @mx:tags tool
 * @mx:partOf mx-os
 */
/* This stylesheet consolidates common styles across all MX blog posts */
/* with support for dark mode, high contrast mode, and modern CSS architecture*/

/*Root Variables - Light Mode Default */
:root {
  /* Colors - Light Mode*/
  --primary-bg: #ffffff;
  --primary-text: #1a1a1a;
  --secondary-text: #4a4a4a;
  --heading-color: #2d3748;
  --accent-color: #0066cc;
  --accent-hover: #004499;
  --border-color: #e1e4e8;
  --code-bg: #f6f8fa;
  --code-border: #e1e4e8;
  --table-header-bg: #f7fafc;
  --intro-bg: #f8f9fa;
  --skip-link-bg: #000000;
  --skip-link-text: #ffffff;

  /*Typography*/
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-mono: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /*Spacing*/
  --max-width: 800px;
  --spacing-unit: 1rem;

  /*Typography Scale*/
  --font-size-h1: 2.5rem;
  --font-size-h2: 1.875rem;
  --font-size-h3: 1.5rem;
  --font-size-h4: 1.25rem;
  --font-size-h5: 1.125rem;
  --font-size-h6: 1rem;
}

/*Dark Mode Support*/
@media (prefers-color-scheme: dark) {
  :root {
    --primary-bg: #1a1a1a;
    --primary-text: #e0e0e0;
    --secondary-text: #b0b0b0;
    --heading-color: #e0e0e0;
    --accent-color: #66a3ff;
    --accent-hover: #99c2ff;
    --border-color: #404040;
    --code-bg: #2a2a2a;
    --code-border: #404040;
    --table-header-bg: #2a2a2a;
    --intro-bg: #2a2a2a;
    --skip-link-bg: #ffffff;
    --skip-link-text: #000000;
  }
}

/*High Contrast Mode Support*/
@media (prefers-contrast: high) {
  :root {
    --primary-text: #000000;
    --secondary-text: #000000;
    --heading-color: #000000;
    --accent-color: #0000ff;
    --accent-hover: #000080;
    --border-color: #000000;
  }
}

/*Reset and Base Styles*/

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-body);
  line-height: 1.6;
  color: var(--primary-text);
  background-color: var(--primary-bg);
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 2rem 1rem;
}

/*Skip to Content Link (WCAG Accessibility)*/
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--skip-link-bg);
  color: var(--skip-link-text);
  padding: 0.5rem 1rem;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
  outline: 2px solid var(--skip-link-text);
  outline-offset: 2px;
}

/*Blog Introduction*/
.blog-introduction {
  background-color: var(--intro-bg);
  border-left: 4px solid var(--accent-color);
  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(--accent-color);
  outline-offset: 2px;
  border-radius: 50%;
}

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

.introduction-content a:focus .author-image {
  opacity: 0.85;
}

.introduction-text {
  flex: 1;
}

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

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

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

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

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

/*Table of Contents (Index)*/
.table-of-contents {
  background-color: var(--intro-bg);
  border: 1px solid var(--border-color);
  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(--accent-color);
  -webkit-user-select: none;
  user-select: none;
}

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

.table-of-contents summary:hover {
  color: var(--accent-hover);
}

.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(--accent-color);
  text-decoration: none;
  transition: color 0.2s;
}

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

.table-of-contents a:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  text-decoration: underline;
}

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

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

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

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

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

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

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

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

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

article li {
  margin-bottom: 0.5rem;
}

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

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

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

/*Links*/
a {
  color: var(--accent-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  color: var(--accent-hover);
}

a:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
  text-decoration: underline;
}

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

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

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

th {
  background-color: var(--table-header-bg);
  font-weight: 600;
  color: var(--heading-color);
}

/*Images and Figures*/
img {
  max-width: 100%;
  height: auto;
  display: block;
}

figure {
  margin: 2rem 0;
}

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

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

/*Footnotes*/
.footnotes {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 2px solid var(--border-color);
  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;
}

/*Nested lists inside footnotes (for reference lists)*/
.footnotes ul {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
  padding-left: 1.5rem;
  list-style-type: disc;
}

.footnotes ul li {
  margin-bottom: 0.5rem;
}

/*Paragraphs inside footnotes*/
.footnotes p {
  margin-bottom: 0.75rem;
}

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

sup a {
  text-decoration: none;
  font-weight: 600;
}

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

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

.author-bio-link hr {
  display: none;
}

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

.author-bio-link a {
  color: var(--accent-color);
  text-decoration: none;
  font-weight: 600;
}

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

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

.back-to-top:hover {
  background-color: var(--accent-hover);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  text-decoration: none;
}

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

/*Footer*/
footer {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  text-align: center;
  color: var(--secondary-text);
  font-size: 0.9rem;
}

/*Reduced Motion Support (WCAG 2.3.3)*/
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

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

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    color: var(--secondary-text);
  }

  body {
    max-width: 100%;
    padding: 0;
  }

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

  a {
    text-decoration: none;
    color: var(--primary-text);
  }
}

/*Responsive Design*/
@media (max-width: 768px) {
  body {
    padding: 1rem;
  }

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

  article h2 {
    font-size: 1.5rem;
  }

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

  .author-bio-link {
    margin-top: 2rem;
    padding-top: 1.5rem;
  }

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