/* ==========================================================================
   Welcome to Elderfield Help — Shared Stylesheet
   Version: 2026-09-20 / v2.24
   Tone: Cozy Horror / Atmospheric Eldritch Palette & High-legibility Layout
   ========================================================================== */

:root {
  /* Color Palette */
  --bg-primary: #0d0a14;
  --bg-surface: #151020;
  --bg-surface-raised: #1c152b;
  --bg-surface-alt: #241c36;
  --bg-card: #181226;
  
  --border-subtle: #2b1f40;
  --border-medium: #423060;
  --border-focus: #9333ea;
  --border-accent: #a855f7;

  --text-primary: #f5f2eb;
  --text-secondary: #c4b9d8;
  --text-muted: #8e80a6;
  --text-inverse: #0d0a14;

  --accent-purple: #9333ea;
  --accent-purple-light: #c084fc;
  --accent-amber: #f59e0b;
  --accent-amber-light: #fbbf24;
  --accent-cyan: #38bdf8;
  --accent-red: #ef4444;
  --accent-green: #10b981;

  /* Typography */
  --font-sans: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;

  /* Sizing & Layout */
  --container-max: 1140px;
  --article-max: 780px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px rgba(147, 51, 234, 0.2);
}

/* Global Reset & Base */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  scroll-behavior: smooth;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 0%, #1a122c 0%, var(--bg-primary) 65%);
  background-attachment: fixed;
}

/* Accessible focus styling */
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent-purple-light);
  outline-offset: 3px;
}

/* Anchor and article-link accessibility corrections */
[id] { scroll-margin-top: 90px; }
@media (max-width:640px) { [id] { scroll-margin-top: 195px; } }
.article-body a:not(.external-link) { color: var(--accent-purple-light); text-underline-offset: 3px; }
.table-wrapper:focus-visible { outline: 2px solid var(--accent-purple-light); }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

/* Container */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin-left: auto;
  margin-right: auto;
  padding-left: 1.25rem;
  padding-right: 1.25rem;
}

/* Site Header */
.site-header {
  height: var(--header-height);
  background-color: rgba(13, 10, 20, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: var(--text-primary);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: block;
}

.brand-text {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent-amber);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.site-nav a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.site-nav a:hover, .site-nav a.active {
  color: var(--accent-purple-light);
}

/* Main Content Wrapper */
.site-main {
  flex: 1 0 auto;
  padding-top: 2rem;
  padding-bottom: 4rem;
}

/* Typography Hierarchy */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
}

h1 {
  font-size: 2.15rem;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.5rem;
  margin-top: 2.25rem;
  margin-bottom: 0.85rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border-subtle);
}

h3 {
  font-size: 1.2rem;
  margin-top: 1.75rem;
  margin-bottom: 0.6rem;
}

p {
  margin-bottom: 1.15rem;
  color: var(--text-secondary);
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
  color: var(--text-secondary);
}

li {
  margin-bottom: 0.4rem;
}

strong {
  color: var(--text-primary);
}

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  background-color: var(--bg-surface-alt);
  color: var(--accent-purple-light);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

/* Hero Section (Homepage) */
.hero-banner-section {
  position: relative;
  background: linear-gradient(180deg, rgba(28, 21, 43, 0.7) 0%, rgba(13, 10, 20, 0.95) 100%),
              url('../images/hero-backdrop.jpg') center/cover no-repeat;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  margin-bottom: 2.5rem;
  overflow: hidden;
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.hero-content {
  position: relative;
  z-index: 2;
  max-width: 800px;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background-color: rgba(147, 51, 234, 0.2);
  border: 1px solid var(--accent-purple);
  color: var(--accent-purple-light);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  color: #ffffff;
  margin-bottom: 0.75rem;
}

.hero-lead {
  font-size: 1.15rem;
  line-height: 1.6;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  align-items: center;
}

/* Button & Action Styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.7rem 1.35rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  border: 1px solid transparent;
}

.btn-primary {
  background-color: var(--accent-purple);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(147, 51, 234, 0.4);
}

.btn-primary:hover {
  background-color: #7e22ce;
  transform: translateY(-1px);
}

.btn-secondary {
  background-color: var(--bg-surface-raised);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-alt);
  border-color: var(--accent-purple);
}

/* Meta / Status Badges */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.badge-verified {
  background-color: rgba(16, 185, 129, 0.15);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.4);
}

.badge-researching {
  background-color: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber-light);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.badge-fixed {
  background-color: rgba(56, 189, 248, 0.15);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* Callout / Alert Boxes */
.callout {
  padding: 1.15rem 1.35rem;
  border-radius: var(--radius-md);
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid;
  background-color: var(--bg-card);
}

.callout-info {
  border-left-color: var(--accent-purple);
  border-top: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
}

.callout-warning {
  border-left-color: var(--accent-amber);
  background-color: rgba(245, 158, 11, 0.06);
  border-top: 1px solid rgba(245, 158, 11, 0.2);
  border-right: 1px solid rgba(245, 158, 11, 0.2);
  border-bottom: 1px solid rgba(245, 158, 11, 0.2);
}

.callout-direct-answer {
  background: linear-gradient(135deg, rgba(28, 21, 43, 0.9) 0%, rgba(36, 28, 54, 0.9) 100%);
  border-left-color: var(--accent-cyan);
  border-top: 1px solid var(--border-medium);
  border-right: 1px solid var(--border-medium);
  border-bottom: 1px solid var(--border-medium);
  box-shadow: var(--shadow-sm);
}

.callout-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

/* Cards & Router Grid */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1.5rem;
  margin-top: 1.5rem;
  margin-bottom: 2.5rem;
}

.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.card-title {
  font-size: 1.2rem;
  color: var(--text-primary);
}

.card-body p {
  font-size: 0.95rem;
  margin-bottom: 1rem;
}

.card-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border-subtle);
}

/* Tables */
.table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
  text-align: left;
}

th, td {
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border-subtle);
}

th {
  background-color: var(--bg-surface-raised);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

tr:last-child td {
  border-bottom: none;
}

tr:nth-child(even) td {
  background-color: rgba(255, 255, 255, 0.015);
}

/* Article / Longform Layout */
.article-container {
  max-width: var(--article-max);
  margin-left: auto;
  margin-right: auto;
}

.article-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  list-style: none;
  padding-left: 0;
}

.breadcrumb a {
  color: var(--text-muted);
  text-decoration: none;
}

.breadcrumb a:hover {
  color: var(--accent-purple-light);
}

.breadcrumb-separator {
  color: var(--border-medium);
}

.article-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.75rem;
}

.article-meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

/* Article Body Typography & Components */
.article-body p {
  line-height: 1.7;
  margin-bottom: 1.35rem;
}

.article-body ul, .article-body ol {
  margin-bottom: 1.5rem;
  padding-left: 1.75rem;
}

.article-body li {
  margin-bottom: 0.5rem;
  line-height: 1.65;
}

/* Figures & Images */
figure.article-figure {
  margin: 2rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  background-color: var(--bg-surface);
}

figure.article-figure img {
  width: 100%;
  height: auto;
  display: block;
}

figcaption {
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  background-color: var(--bg-surface-raised);
  border-top: 1px solid var(--border-subtle);
  line-height: 1.5;
}

/* Step-by-step list */
.step-list {
  list-style: none;
  padding-left: 0;
  counter-reset: step-counter;
  margin: 1.75rem 0;
}

.step-item {
  position: relative;
  padding-left: 3rem;
  margin-bottom: 1.5rem;
}

.step-item::before {
  counter-increment: step-counter;
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 0;
  width: 2rem;
  height: 2rem;
  background-color: var(--bg-surface-raised);
  border: 2px solid var(--accent-purple);
  color: var(--accent-purple-light);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.step-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 0.35rem;
}

/* Citations & Sources (00B 4B.1) */
.citation-ref {
  font-size: 0.8em;
  vertical-align: super;
  line-height: 0;
  padding: 0 0.15em;
}

a.citation-ref {
  color: var(--accent-purple-light);
  text-decoration: none;
  font-weight: 600;
}

a.citation-ref:hover {
  text-decoration: underline;
}

.sources-section {
  margin-top: 3rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--border-subtle);
}

.sources-list {
  list-style: none;
  padding-left: 0;
}

.source-item {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.9rem;
  margin-bottom: 0.75rem;
  color: var(--text-muted);
}

.source-num {
  font-weight: 700;
  color: var(--accent-purple-light);
  min-width: 1.5rem;
}

/* External Link Component */
.external-link {
  color: var(--accent-purple-light);
  text-decoration: underline;
  text-underline-offset: 3px;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  word-break: break-word;
}

.external-link:hover {
  color: #d8b4fe;
}

.external-icon {
  font-size: 0.85em;
  display: inline-block;
  line-height: 1;
}

/* Site Footer */
.site-footer {
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  padding: 3rem 0 2rem 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
}

.footer-col h4 {
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.footer-nav {
  list-style: none;
  padding-left: 0;
}

.footer-nav li {
  margin-bottom: 0.5rem;
}

.footer-nav a {
  color: var(--text-muted);
  text-decoration: none;
  transition: color 0.15s ease;
}

.footer-nav a:hover {
  color: var(--accent-purple-light);
}

.footer-bottom {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  font-size: 0.8rem;
}

/* Responsive Media Queries */
@media (max-width: 860px) {
  .hero-title {
    font-size: 2rem;
  }
  .footer-grid {
    grid-template-columns: 1fr;
    gap: 2rem;
  }
}

@media (max-width: 640px) {
  :root {
    --header-height: auto;
  }
  .site-header {
    height: auto;
    padding: 0.65rem 0;
  }
  .site-header .container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  .brand-wrapper {
    gap: 0.6rem;
  }
  .brand-name {
    font-size: 0.95rem;
  }
  .brand-badge {
    font-size: 0.65rem;
  }
  .site-nav {
    width: 100%;
    gap: 0.75rem;
    flex-wrap: wrap;
    padding-top: 0.4rem;
    border-top: 1px solid var(--border-subtle);
  }
  .site-nav a {
    font-size: 0.82rem;
  }
  h1 {
    font-size: 1.75rem;
  }
  h2 {
    font-size: 1.3rem;
  }
  .hero-banner-section {
    padding: 1.75rem 1.25rem;
  }
  .hero-title {
    font-size: 1.6rem;
  }
  .hero-lead {
    font-size: 1rem;
  }
  .grid-cards {
    grid-template-columns: 1fr;
  }
  .table-wrapper {
    font-size: 0.88rem;
  }
  th, td {
    padding: 0.65rem 0.85rem;
  }
}

/* Local table-scroll guidance; preserve existing table layout. */
.table-hint { display: none; }
@media(max-width:640px) { .table-hint { display:block; font-size:0.85rem; color:var(--text-secondary); margin-bottom:0.5rem; } }
