/* ==========================================================================
   Design System: Ryan Rix
   ========================================================================== */

:root {
  /* Brand Colors - Deep Crimson + Slate Blue */
  --color-primary: #2C3E50;        /* Deep Slate */
  --color-primary-dark: #1A252F;   /* Darker Slate */
  --color-action: #8B1A1A;         /* Deep Crimson */
  --color-action-light: #B22222;   /* Brighter Crimson for hover */
  --color-emphasis: #B22222;       /* Emphasis Red */

  /* Background and Text Colors */
  --color-bg-main: #FFFFFF;
  --color-bg-secondary: #F4F5F7;   /* Neutral gray tint */
  --color-text-main: #1A1A1A;
  --color-text-muted: #4A4A4A;
  --color-border: #D5D8DC;        /* Neutral gray border */

  /* Typography */
  --font-primary: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --base-font-size: 20px;
  --line-height-body: 1.6;

  /* Spacing & Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 3px rgba(44, 62, 80, 0.08);
  --shadow-md: 0 4px 12px rgba(44, 62, 80, 0.1);
}

/* ==========================================================================
   Base Styles
   ========================================================================== */

html {
  font-size: var(--base-font-size);
  box-sizing: border-box;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

*, *:before, *:after {
  box-sizing: inherit;
}

body {
  font-family: var(--font-primary);
  color: var(--color-text-main);
  background-color: var(--color-bg-main);
  line-height: var(--line-height-body);
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

main {
  flex: 1;
  width: 100%;
}

/* ==========================================================================
   Typography Rules
   ========================================================================== */

h1, h2, h3, h4, h5, h6 {
  color: var(--color-primary);
  margin-top: 2rem;
  margin-bottom: 1rem;
  line-height: 1.2;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }

p {
  margin-bottom: 1.5rem;
}

/* ==========================================================================
   Links and Buttons (High Affordance)
   ========================================================================== */

a {
  color: #0056b3;
  text-decoration: underline;
  text-underline-offset: 4px;
}

a:hover {
  color: #003d82;
  text-decoration-thickness: 2px;
}

:is(h1, h2, h3, h4) a {
  color: var(--color-primary);
}

.button, button, input[type="submit"] {
  display: inline-block;
  background-color: var(--color-action);
  color: #1A1A1A;
  font-weight: 700;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid #6B1414;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.button:hover, button:hover, input[type="submit"]:hover {
  background-color: var(--color-action-light);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.button:active, button:active, input[type="submit"]:active {
  transform: translateY(0px);
  box-shadow: var(--shadow-sm);
}

/* ==========================================================================
   Header - Grid aligning with three-column layout below
   ========================================================================== */

header.site-header {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: white;
  padding: 0;
  width: 100%;
  box-shadow: 0 2px 8px rgba(44, 62, 80, 0.15);
}

.header-overlay {
  padding: 1rem 0;
}

.site-header--home .header-overlay {
  padding: 1.5rem 0;
}

.header-grid {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 2.5rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: 0 1rem;
  align-items: center;
}

.header-logo {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-logo img {
  max-width: 140px;
  height: auto;
}

/* Reversed logo on the right side of the header */
.header-logo-reverse {
  display: flex;
  justify-content: center;
  align-items: center;
}

.header-logo-reverse img {
  max-width: 140px;
  height: auto;
}

.header-title {
  text-align: center;
}

.header-title a {
  color: white;
  text-decoration: none;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Slightly larger on homepage */
header.site-header--home .header-logo img,
header.site-header--home .header-logo-reverse img {
  max-width: 160px;
}

header.site-header--home .header-title a {
  font-size: 1.8rem;
}

/* Crimson section bar below the slate header */
.section-bar {
  width: 100%;
  padding: 0.75rem 1rem;
  background: #6B1414;
  color: white;
  text-align: center;
  font-weight: 700;
  font-size: 1.2rem;
  letter-spacing: 0.03em;
}

.section-bar a.section-bar-link {
  color: white;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

.section-bar a.section-bar-link:hover {
  text-decoration-thickness: 2px;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer.site-footer {
  background-color: var(--color-bg-secondary);
  border-top: 2px solid var(--color-border);
  padding: 2rem 1rem;
  text-align: center;
  margin-top: 4rem;
}

.affiliate-disclosure {
  font-size: 0.85rem;
  color: var(--color-text-secondary, #666);
  margin-top: 0.5rem;
}

.affiliate-disclosure a {
  color: var(--color-text-secondary, #666);
  text-decoration: underline;
}

/* ==========================================================================
   Three-Column Layout, Sidebars & Accordion
   ========================================================================== */

.site-container {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 2.5rem;
  max-width: 1600px;
  margin: 0 auto;
  padding: 2rem 1rem;
  align-items: start;
}

main#main-content {
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  padding: 0;
}

.sidebar-box {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
}

.sidebar-title {
  margin-top: 0;
  margin-bottom: 1.25rem;
  font-size: 1.25rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-primary);
  padding-bottom: 0.5rem;
}

/* Left Sidebar Accordion */
.sidebar-left {
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-action);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.accordion-nav {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.accordion-item {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
}

.accordion-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.accordion-item summary {
  list-style: none;
  cursor: pointer;
  padding: 0.5rem 0;
}

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

.accordion-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
  user-select: none;
}

.accordion-header a.header-text {
  color: inherit;
  text-decoration: none;
  flex: 1;
}

.accordion-header::after {
  content: '▼';
  font-size: 0.7rem;
  color: var(--color-action);
  transition: transform 0.2s ease;
}

details[open] .accordion-header::after {
  transform: rotate(180deg);
}

.accordion-content {
  list-style: none;
  padding: 0.5rem 0 0 1rem;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accordion-content a {
  color: var(--color-text-main);
  text-decoration: none;
  font-weight: 500;
  display: block;
  padding: 0.25rem 0;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.accordion-content a:hover {
  color: var(--color-action);
  text-decoration: underline;
}

/* Section overview link at top of accordion */
.accordion-section-link {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

.accordion-section-overview {
  font-weight: 700;
  color: var(--color-primary) !important;
}

.accordion-item.single-link {
  padding: 0.5rem 0;
}

.accordion-header-link {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
  text-decoration: none;
  display: block;
}

.accordion-header-link:hover {
  color: var(--color-action);
  text-decoration: underline;
}

.accordion-nav .active-link {
  color: var(--color-action) !important;
  font-weight: 800;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

/* Sub-category topic groups (e.g., Technology > Home Networking) */
.topic-group {
  margin: 0.5rem 0;
}

.topic-label {
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-primary);
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
}

.topic-count {
  font-size: 0.8rem;
  color: var(--color-action);
  font-weight: 600;
  padding: 0 0 0.35rem 0;
}

.topic-label-link {
  display: block;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--color-primary);
  text-decoration: none;
  padding: 0.25rem 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 0.25rem;
  transition: all 0.15s ease;
}

.topic-label-link:hover {
  color: var(--color-action);
}

.topic-label-link--muted {
  color: var(--color-text-muted);
  font-weight: 600;
}

.topic-label--muted {
  color: var(--color-text-muted);
  font-weight: 600;
}

.topic-link {
  display: block;
  padding: 0.25rem 0 0.25rem 0.75rem;
  color: var(--color-text-main);
  text-decoration: none;
  font-size: 0.9rem;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.topic-link:hover {
  color: var(--color-action);
  text-decoration: underline;
}

.topic-placeholder {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  font-style: italic;
  padding: 0.15rem 0 0.25rem 0.75rem;
}

/* Right Sidebar & Widgets */
.widget-title {
  margin-top: 0;
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--color-primary);
  border-bottom: 2px solid var(--color-action);
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.featured-widget {
  background: linear-gradient(135deg, #F5F5F5 0%, #FAFAFA 100%);
  border: 1px solid #E0E0E0;
  border-top: 4px solid var(--color-action);
  border-radius: var(--radius-md);
}

.featured-badge {
  display: inline-block;
  background-color: var(--color-emphasis);
  color: white;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  margin-bottom: 0.5rem;
}

.featured-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-primary);
}

.widget-text {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.button-emphasis {
  background-color: var(--color-emphasis);
  color: white;
  border: 1px solid #8B1A1A;
  text-align: center;
}

.button-emphasis:hover {
  background-color: #B22222;
}

.button-fullwidth {
  display: block;
  width: 100%;
  box-sizing: border-box;
}

.recommendation-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.rec-link {
  text-decoration: none;
  color: inherit;
  display: block;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  background-color: var(--color-bg-main);
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.rec-link:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

.rec-name {
  display: block;
  font-weight: 700;
  color: var(--color-primary);
  margin-bottom: 0.25rem;
  font-size: 1rem;
}

.rec-desc {
  display: block;
  font-size: 0.85rem;
  color: var(--color-text-muted);
  line-height: 1.4;
}

.affiliate-disclaimer {
  font-size: 0.8rem;
  font-style: italic;
  color: var(--color-text-muted);
  margin-top: 1.5rem;
  margin-bottom: 0;
  line-height: 1.4;
}

/* ==========================================================================
   Newsletter Component
   ========================================================================== */

.newsletter-capture {
  background: linear-gradient(135deg, #EEF0F2 0%, #F8F9FA 100%);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 3rem 0;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.newsletter-inner h2 {
  margin-top: 0;
  color: var(--color-primary);
}

.newsletter-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  max-width: 400px;
  margin: 2rem auto 1rem;
}

.newsletter-form .form-group {
  width: 100%;
  text-align: left;
}

.newsletter-form label {
  display: block;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

/* ==========================================================================
   Hero Section (Homepage)
   ========================================================================== */

.hero {
  text-align: center;
  margin-bottom: 3rem;
  padding: 4rem 3rem;
  background: linear-gradient(135deg, #F0F1F3 0%, #FCFCFC 100%);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  position: relative;
  overflow: hidden;
}

.hero h1 {
  margin-top: 0;
  font-size: 2.5rem;
}

.hero p {
  font-size: 1.25rem;
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* ==========================================================================
   Article List
   ========================================================================== */

article {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

article:not(.single-article):hover h3 a {
  color: var(--color-action);
  text-decoration: underline;
}

article h3 {
  margin-bottom: 0.5rem;
  margin-top: 0;
}

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

article h3 a:hover {
  color: var(--color-action);
  text-decoration: underline;
}

/* ==========================================================================
   Content Pages
   ========================================================================== */

.content {
  line-height: 1.8;
}

main img,
.content img,
.article-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}

.content blockquote {
  border-left: 4px solid var(--color-action);
  margin: 1.5rem 0;
  padding: 0.5rem 1.5rem;
  background-color: var(--color-bg-secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.content code {
  background-color: #F4F5F7;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

.content pre {
  background-color: #1A1A2E;
  color: #E4E0EC;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
}

/* ==========================================================================
   Tags & Metadata
   ========================================================================== */

.tag-badge {
  display: inline-block;
  background-color: #F4F5F7;
  color: var(--color-primary);
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.2rem 0.6rem;
  border-radius: 20px;
  border: 1px solid var(--color-border);
  text-decoration: none;
  transition: all 0.15s ease;
}

.tag-badge:hover {
  background-color: var(--color-action);
  color: #1A1A1A;
  border-color: var(--color-action);
}

.level-badge {
  display: inline-block;
  background-color: var(--color-primary);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
}

/* ==========================================================================
   Tables
   ========================================================================== */

.article-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.5rem 0;
  font-size: 0.95rem;
}

.article-content th,
.article-content td {
  border: 1px solid var(--color-border);
  padding: 0.6rem 0.8rem;
  text-align: left;
  vertical-align: top;
}

.article-content th {
  background-color: var(--color-primary);
  color: white;
  font-weight: 700;
}

.article-content tr:nth-child(even) {
  background-color: var(--color-bg-secondary);
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 1100px) {
  .site-container {
    grid-template-columns: 240px 1fr;
    gap: 1.5rem;
  }
  .sidebar-right {
    display: none;
  }
}

/* ==========================================================================
   Homepage Card Grid
   ========================================================================== */

.site-container--home {
  max-width: 1600px;
  margin: 3rem auto;
  padding: 0 1.5rem;
  display: block;
}

.home-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.5rem;
}

.home-card {
  display: flex;
  flex-direction: column;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-action);
  border-radius: var(--radius-md);
  padding: 1.75rem;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.home-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-primary);
}

.home-card-title {
  margin: 0 0 0.75rem 0;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--color-primary);
}

.home-card-desc {
  margin: 0 0 1rem 0;
  font-size: 1rem;
  color: var(--color-text-muted);
  line-height: 1.5;
  flex: 1;
}

.home-card-count {
  font-size: 0.85rem;
  color: var(--color-action);
  font-weight: 700;
}

/* ==========================================================================
   Article Diagrams & Images
   ========================================================================== */

.article-diagram {
  margin: 2rem 0;
  padding: 0;
  text-align: center;
}

.article-diagram svg {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

main#main-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin: 1.5rem 0;
}

/* ==========================================================================
   Author Byline (on article pages)
   ========================================================================== */

.author-byline {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
}

.author-byline-avatar {
  width: 36px !important;
  height: 36px !important;
  border-radius: 50% !important;
  margin: 0 !important;
  box-shadow: none !important;
  border: 2px solid var(--color-action);
}

.author-byline a {
  color: var(--color-primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.author-byline a:hover {
  color: var(--color-action);
}

/* ==========================================================================
   Author Footer Card (at bottom of articles)
   ========================================================================== */

.author-footer-card {
  display: flex;
  gap: 1.25rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-action);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 2.5rem 0;
  box-shadow: var(--shadow-sm);
}

.author-footer-avatar {
  flex-shrink: 0;
}

.author-footer-avatar img {
  width: 80px !important;
  height: 80px !important;
  border-radius: 50% !important;
  margin: 0 !important;
  box-shadow: none !important;
  border: 3px solid var(--color-primary);
}

.author-footer-name {
  margin: 0 0 0.35rem 0;
  font-size: 1.2rem;
  font-weight: 800;
}

.author-footer-name a {
  color: var(--color-primary);
  text-decoration: none;
}

.author-footer-name a:hover {
  color: var(--color-action);
  text-decoration: underline;
}

.author-footer-bio {
  margin: 0 0 0.35rem 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
  line-height: 1.5;
}

.author-footer-email {
  margin: 0;
  font-size: 0.9rem;
}

.author-footer-email a {
  color: var(--color-action);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* ==========================================================================
   Author Profile Page
   ========================================================================== */

.author-profile {
  max-width: 700px;
}

.author-header {
  display: flex;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 2rem;
  padding-bottom: 2rem;
  border-bottom: 2px solid var(--color-primary);
}

.author-avatar-img {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 3px solid var(--color-action);
}

.author-info h1 {
  margin: 0 0 0.25rem 0;
  font-size: 2.2rem;
}

.author-email {
  margin: 0 0 0.25rem 0;
  font-weight: 600;
}

.author-email a {
  color: var(--color-action);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.author-role {
  margin: 0;
  font-size: 1rem;
  color: var(--color-text-muted);
  font-style: italic;
}

.author-bio {
  margin-bottom: 2rem;
  line-height: 1.7;
}

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

.author-articles {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 2px solid var(--color-border);
}

.author-articles h2 {
  font-size: 1.5rem;
  margin-bottom: 1.25rem;
}

.author-article-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.author-article-list li {
  background: var(--color-bg-secondary);
  padding: 1rem 1.25rem;
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--color-action);
  transition: all 0.15s ease;
}

.author-article-list li:hover {
  border-left-color: var(--color-primary);
}

.author-article-list li a {
  display: block;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
  text-decoration: none;
  margin-bottom: 0.25rem;
}

.author-article-list li a:hover {
  color: var(--color-action);
  text-decoration: underline;
}

.author-article-list .article-date {
  font-size: 0.85rem;
  color: var(--color-text-muted);
  display: block;
  margin-bottom: 0.25rem;
}

.author-article-list .article-desc {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Contribute Page
   ========================================================================== */

.contribute-intro {
  font-size: 1.2rem;
  line-height: 1.7;
  color: var(--color-text-muted);
  margin-bottom: 2rem;
}

.contribute-perks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 2rem 0;
}

.perk-card {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-action);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.perk-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.1rem;
  color: var(--color-primary);
}

.perk-card p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--color-text-muted);
}

/* ==========================================================================
   Tooltip Shortcode
   ========================================================================== */

.tooltip {
  position: relative;
  cursor: help;
  color: var(--color-action);
  border-bottom: 1px dotted var(--color-action);
  font-weight: 600;
  display: inline;
}

.tooltip-text {
  visibility: hidden;
  opacity: 0;
  position: absolute;
  z-index: 100;
  bottom: 140%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  max-width: 320px;
  padding: 0.6rem 0.8rem;
  background-color: var(--color-primary-dark);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 400;
  line-height: 1.5;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  pointer-events: none;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  text-align: center;
}

/* Arrow pointing down from the tooltip box */
.tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  margin-left: -6px;
  border-width: 6px;
  border-style: solid;
  border-color: var(--color-primary-dark) transparent transparent transparent;
}

/* Show on hover (desktop) and on focus (tab navigation / mobile tap) */
.tooltip:hover .tooltip-text,
.tooltip:focus .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* ==========================================================================
   Share Bar
   ========================================================================== */

.share-bar {
  margin: 3rem 0;
  padding: 1.5rem;
  background: var(--color-bg-secondary);
  border-radius: var(--radius-md);
  text-align: center;
  border: 1px solid var(--color-border);
}

.share-bar-heading {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-primary);
}

.share-bar-subtext {
  margin: 0 0 1.25rem;
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.share-buttons {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.share-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: #fff;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-main);
  text-decoration: none;
  transition: all 0.15s ease;
  position: relative;
}

.share-btn:hover {
  border-color: var(--color-action);
  color: var(--color-action);
  background: #FDF5F5;
}

.share-icon {
  flex-shrink: 0;
}

/* Copy button — swap label on click */
.share-btn--copy .share-btn-label--copied {
  display: none;
}

.share-btn--copied .share-btn-label--default {
  display: none;
}

.share-btn--copied .share-btn-label--copied {
  display: inline;
  color: #2E7D32;
}

.share-btn--copied {
  border-color: #2E7D32;
  background: #E8F5E9;
}

/* ==========================================================================
   Mobile Responsive — Consolidated (single breakpoint at end so it can
   properly override all desktop rules)
   ========================================================================== */

@media (max-width: 768px) {
  /* --- Viewport-level containment --- */
  html, body {
    overflow-x: hidden;
    width: 100%;
  }

  /* --- Universal container clamp --- */
  .site-container,
  .site-footer,
  .site-header {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* --- Header --- */
  .header-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    padding: 0 0.5rem;
  }

  .header-logo-reverse {
    display: none;
  }

  .header-logo img {
    max-width: 80px;
  }

  header.site-header--home .header-logo img {
    max-width: 100px;
  }

  .header-title a {
    font-size: 1.2rem;
  }

  /* --- Section bar --- */
  .section-bar {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
    overflow-wrap: break-word;
    word-break: break-word;
  }

  /* --- Three-column layout → single column, sidebars hidden --- */
  .site-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 1rem;
  }

  .sidebar-left,
  .sidebar-right {
    display: none;
  }

  /* --- Main content fills full width --- */
  main#main-content {
    max-width: 100%;
    width: 100%;
  }

  .single-article {
    max-width: 100%;
    width: 100%;
  }

  /* --- Article content: scrollable wrapper for wide children (tables, SVGs, code) --- */
  .article-content {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    word-wrap: break-word;
  }

  .article-content pre,
  .article-content code {
    white-space: pre-wrap;
    word-break: break-word;
    max-width: 100%;
  }

  .article-content img {
    max-width: 100% !important;
    height: auto;
  }

  /* Tables inside article-content: keep their native display:table layout.
     max-width: none lets them be their natural width (several columns of text
     at mobile). The parent .article-content has overflow-x: auto and handles
     the horizontal scrollbar. We undo the desktop width:100% constraint here
     so the table can expand beyond the viewport when it needs to. */
  .article-content table {
    width: auto;
    max-width: none;
    overflow: visible;
  }

  .article-content .callout {
    padding: 0.5rem 0.75rem !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  /* Tables OUTSIDE article-content (standalone): use same scroll-wrapper pattern */
  table:not(.article-content table) {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  table td,
  table th {
    white-space: normal;
    min-width: auto;
  }

  /* --- SVG diagrams --- */
  .article-diagram {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .article-diagram svg {
    max-width: 100%;
    height: auto;
  }

  /* --- Tags wrap instead of overflowing --- */
  .article-meta .tags {
    flex-wrap: wrap;
  }

  .article-meta {
    flex-direction: column;
    gap: 0.5rem !important;
  }

  /* --- Typography --- */
  h1 {
    font-size: 1.8rem !important;
  }

  h2 {
    font-size: 1.4rem;
  }

  .single-article header h1 {
    font-size: 2rem !important;
  }

  /* --- Author components --- */
  .author-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .author-footer-card {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  /* --- Homepage --- */
  .site-container--home {
    margin: 2rem auto;
    padding: 0 1rem;
  }

  .home-cards {
    grid-template-columns: 1fr;
  }

  /* --- Contribute page --- */
  .contribute-perks {
    grid-template-columns: 1fr;
  }

  /* --- Newsletter --- */
  .newsletter-box {
    padding: 1rem;
  }

  .newsletter-capture {
    padding: 1rem;
  }

  /* --- Related articles --- */
  .related-articles ul {
    grid-template-columns: 1fr;
  }

  /* --- Tooltip --- */
  .tooltip-text {
    min-width: 160px;
    max-width: 260px;
    left: auto;
    right: -20px;
    transform: none;
  }

  .tooltip-text::after {
    left: auto;
    right: 24px;
  }

  /* --- Share Bar --- */
  .share-bar {
    padding: 1rem;
    margin: 2rem 0;
  }

  .share-buttons {
    gap: 0.5rem;
  }

  .share-btn {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
  }
}
