/* Zero-Dependency Accessible Engineering Publication Stylesheet */
:root {
  color-scheme: light dark;
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-subtle: #f1f5f9;
  --border: #cbd5e1;
  --text: #0f172a;
  --text-muted: #334155;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-contrast: #ffffff;
  --accent-soft: #ccfbf1;
  --badge-ok-bg: #dcfce7;
  --badge-ok-fg: #14532d;
  --badge-warn-bg: #fef3c7;
  --badge-warn-fg: #78350f;
  --code-bg: #0f172a;
  --code-fg: #f8fafc;
  --focus-ring: #0284c7;
  --max-prose: 76ch;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b1120;
    --surface: #111827;
    --surface-subtle: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-muted: #cbd5e1;
    --accent: #2dd4bf;
    --accent-strong: #5eead4;
    --accent-contrast: #042f2e;
    --accent-soft: #134e4a;
    --badge-ok-bg: #052e16;
    --badge-ok-fg: #86efac;
    --badge-warn-bg: #451a03;
    --badge-warn-fg: #fde68a;
    --code-bg: #020617;
    --code-fg: #e2e8f0;
    --focus-ring: #38bdf8;
  }
}

:root[data-theme="dark"] {
  --bg: #0b1120;
  --surface: #111827;
  --surface-subtle: #1e293b;
  --border: #334155;
  --text: #f8fafc;
  --text-muted: #cbd5e1;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-contrast: #042f2e;
  --accent-soft: #134e4a;
  --badge-ok-bg: #052e16;
  --badge-ok-fg: #86efac;
  --badge-warn-bg: #451a03;
  --badge-warn-fg: #fde68a;
  --code-bg: #020617;
  --code-fg: #e2e8f0;
  --focus-ring: #38bdf8;
}

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

html {
  font-size: 100%;
  -webkit-text-size-adjust: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.65;
  max-width: 100%;
  overflow-x: clip;
}

main, section, article, header, footer, div, p, li, h1, h2, h3, h4 {
  min-width: 0;
  max-width: 100%;
}

:not(pre) > code, p, li, h1, h2, h3, h4, td, th, .tabular {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tabular, time, table, code, .stat-value, .badge {
  font-variant-numeric: tabular-nums;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0.5rem;
  z-index: 1000;
  padding: 0.75rem 1.25rem;
  min-height: 44px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 700;
  border-radius: 0.5rem;
  text-decoration: none;
}

.skip-link:focus {
  left: 0.75rem;
}

:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 1rem;
}

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0;
}

.brand-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.nav-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  margin: 0;
  padding: 0;
  max-width: 100%;
}

.nav-list > li {
  min-width: 0;
  max-width: 100%;
}

.nav-link, .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  padding: 0.5rem 0.9rem;
  border-radius: 0.5rem;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: normal;
  text-align: center;
  overflow-wrap: anywhere;
  word-break: break-word;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-subtle);
  color: var(--text);
}

.nav-link:hover, .btn:hover {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

.btn-primary:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.hero {
  padding: 2.25rem 0 1.75rem;
  border-bottom: 1px solid var(--border);
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.65rem, 3.5vw, 2.35rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.hero p {
  margin: 0 0 1.25rem;
  max-width: 68ch;
  color: var(--text-muted);
  font-size: 1.05rem;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-block {
  padding: 2rem 0;
}

.section-title {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  letter-spacing: -0.01em;
}

.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 300px), 1fr));
  gap: 1.25rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.card h3 {
  margin: 0.35rem 0 0.5rem;
  font-size: 1.15rem;
  line-height: 1.35;
}

.card h3 a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  padding: 0.35rem 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.84rem;
  color: var(--text-muted);
  min-width: 0;
  max-width: 100%;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: var(--surface-subtle);
  color: var(--text);
  border: 1px solid var(--border);
}

.badge-verified {
  background: var(--badge-ok-bg);
  color: var(--badge-ok-fg);
  border-color: transparent;
}

.badge-warn {
  background: var(--badge-warn-bg);
  color: var(--badge-warn-fg);
  border-color: transparent;
}

.meter-track {
  width: 100%;
  height: 0.75rem;
  border-radius: 999px;
  background: var(--surface-subtle);
  border: 1px solid var(--border);
  overflow: hidden;
  margin: 0.5rem 0;
}

.meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
}

.pin-thumb-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
}

.pin-thumb {
  display: block;
  width: 100%;
  max-width: 180px;
  height: auto;
  aspect-ratio: 2 / 3;
  border-radius: 0.5rem;
  border: 1px solid var(--border);
}

/* Article h-entry layout */
.article-shell {
  max-width: 820px;
  margin: 0 auto;
  padding: 2rem 0 3rem;
}

.article-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
}

.article-header h1 {
  margin: 0.6rem 0 0.75rem;
  font-size: clamp(1.6rem, 3.4vw, 2.25rem);
  line-height: 1.22;
}

.article-subtitle {
  margin: 0 0 1rem;
  font-size: 1.08rem;
  color: var(--text-muted);
}

.e-content {
  overflow-wrap: break-word;
}

.e-content h2 {
  margin: 2rem 0 0.75rem;
  font-size: 1.4rem;
  line-height: 1.3;
}

.e-content h3 {
  margin: 1.5rem 0 0.6rem;
  font-size: 1.18rem;
}

.e-content p, .e-content li {
  max-width: var(--max-prose);
}

.e-content a, .p-author, .site-footer a {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  min-height: 44px;
  min-width: 44px;
  max-width: 100%;
  padding: 0.25rem 0.15rem;
  color: var(--accent);
  text-underline-offset: 3px;
  font-weight: 600;
  overflow-wrap: anywhere;
  word-break: break-word;
}

:not(pre) > code, .e-content code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: var(--surface-subtle);
  padding: 0.12rem 0.35rem;
  border-radius: 0.3rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.code-frame {
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: 0.65rem;
  overflow: hidden;
  background: var(--code-bg);
}

.code-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.75rem;
  background: #1e293b;
  color: #e2e8f0;
  font-size: 0.8rem;
}

.copy-code-btn {
  min-height: 44px;
  min-width: 88px;
  padding: 0.35rem 0.75rem;
  border-radius: 0.4rem;
  border: 1px solid #475569;
  background: #0f172a;
  color: #f8fafc;
  font-weight: 600;
  cursor: pointer;
}

.copy-code-btn:hover {
  border-color: #38bdf8;
}

.code-frame pre {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  max-width: 100%;
  color: var(--code-fg);
  font-size: 0.86rem;
  line-height: 1.55;
}

.code-frame pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  margin: 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

th, td {
  text-align: left;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-subtle);
  font-weight: 700;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 1.75rem 0;
  margin-top: 2rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
