/* ===== REFERENCE ARCHITECTURES =====
   Shared component kit for sub-pages — /reference-architectures/* and /skills/.
   Loaded on top of styles.css. Adding a new architecture should never
   require touching this file — see reference-architectures/_template.html. */

:root {
  --ra-border:   #e5e7eb;
  --ra-border-2: #d1d5db;
  --ra-code-bg:  #f6f7f9;
  --ra-mono:     ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

/* ===== BREADCRUMB ===== */
.ra-crumbs {
  padding-top: var(--space-md);
  font-size: 0.85rem;
  color: var(--color-muted);
}

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

.ra-crumbs a:hover { color: var(--color-text); }

.ra-crumbs span { margin: 0 6px; }

/* ===== PAGE HEADER ===== */
.ra-hero {
  padding: var(--space-md) 0 var(--space-lg);
  border-bottom: 1px solid var(--ra-border);
}

.ra-hero__eyebrow {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-accent);
  margin-bottom: var(--space-xs);
}

.ra-hero__title {
  font-size: clamp(2rem, 4.5vw, 3rem);
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.12;
  margin-bottom: var(--space-sm);
}

.ra-hero__lead {
  font-size: 1.15rem;
  color: var(--color-muted);
  max-width: 680px;
}

.ra-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs);
  margin-top: var(--space-md);
}

.ra-tag {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--color-muted);
  background: var(--color-surface);
  border: 1px solid var(--ra-border);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
}

.ra-meta__updated {
  font-size: 0.8rem;
  color: var(--color-muted);
  margin-left: auto;
}

/* ===== LAYOUT: STICKY TOC + CONTENT ===== */
.ra-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-lg);
  padding: var(--space-lg) 0 var(--space-xl);
  align-items: start;
}

.ra-toc {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.ra-toc__label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-bottom: var(--space-sm);
}

/* The <details> wrapper is only interactive below 900px — see reference.js. */
.ra-toc summary { display: none; }

.ra-toc ol {
  list-style: none;
  border-left: 2px solid var(--ra-border);
}

.ra-toc li a {
  display: block;
  padding: 5px 0 5px 14px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  font-size: 0.85rem;
  line-height: 1.4;
  color: var(--color-muted);
  text-decoration: none;
  transition: color 0.15s, border-color 0.15s;
}

.ra-toc li a:hover { color: var(--color-text); }

.ra-toc li a.is-active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
  font-weight: 500;
}

/* ===== PROSE ===== */
.ra-prose { max-width: 760px; }

/* Full-width prose, for the index page where there is no sticky TOC
   taking up the left column. */
.ra-prose--wide {
  max-width: none;
  padding-bottom: var(--space-lg);
}

.ra-prose > * + * { margin-top: var(--space-sm); }

.ra-prose h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.25;
  margin-top: var(--space-lg);
  scroll-margin-top: 88px;
}

.ra-prose h3 {
  font-size: 1.075rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: var(--space-md);
  scroll-margin-top: 88px;
}

.ra-prose > h2:first-child { margin-top: 0; }

.ra-prose p {
  color: #374151;
  line-height: 1.7;
}

.ra-prose strong { color: var(--color-text); font-weight: 600; }

.ra-prose a {
  color: var(--color-accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(37, 99, 235, 0.3);
}

.ra-prose a:hover { border-bottom-color: var(--color-accent); }

.ra-prose ul,
.ra-prose ol {
  padding-left: 22px;
  color: #374151;
  line-height: 1.7;
}

.ra-prose li + li { margin-top: 6px; }

.ra-prose li::marker { color: var(--color-muted); }

.ra-prose code {
  font-family: var(--ra-mono);
  font-size: 0.855em;
  background: var(--ra-code-bg);
  border: 1px solid var(--ra-border);
  border-radius: 5px;
  padding: 1px 5px;
  white-space: nowrap;
}

.ra-prose pre {
  background: var(--ra-code-bg);
  border: 1px solid var(--ra-border);
  border-radius: var(--radius);
  padding: var(--space-sm);
  overflow-x: auto;
}

.ra-prose pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.82rem;
  line-height: 1.65;
  white-space: pre;
  color: #1f2937;
}

.ra-prose figcaption,
.ra-caption {
  font-size: 0.82rem;
  color: var(--color-muted);
  line-height: 1.55;
}

/* ===== DIAGRAM ===== */
.ra-figure {
  margin-top: var(--space-md);
  margin-bottom: var(--space-md);
}

.ra-figure__scroll {
  overflow-x: auto;
  background: var(--color-surface);
  border: 1px solid var(--ra-border);
  border-radius: var(--radius);
  padding: var(--space-sm);
}

.ra-figure__scroll svg {
  display: block;
  width: 100%;
  min-width: 660px;
  height: auto;
}

.ra-figure figcaption { margin-top: var(--space-xs); }

/* Diagram primitives — used by the inline SVGs so every diagram
   on the site shares one visual language. */
.d-band {
  font: 600 11px var(--font-sans);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  fill: var(--color-muted);
}

.d-box {
  fill: #ffffff;
  stroke: var(--ra-border-2);
  stroke-width: 1;
  rx: 10;
}

.d-box--accent {
  fill: rgba(37, 99, 235, 0.05);
  stroke: rgba(37, 99, 235, 0.45);
}

.d-title     { font: 600 13.5px var(--font-sans); fill: var(--color-text); }
.d-sub       { font: 400 11.5px var(--font-sans); fill: var(--color-muted); }
.d-mono      { font: 400 11px var(--ra-mono); fill: var(--color-muted); }
.d-chip-name { font: 600 11.5px var(--font-sans); fill: var(--color-text); }

.d-chip {
  fill: #ffffff;
  stroke: var(--ra-border-2);
  stroke-dasharray: 3 3;
  rx: 7;
}

.d-arrow {
  fill: none;
  stroke: #9ca3af;
  stroke-width: 1.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.d-dash {
  fill: none;
  stroke: var(--color-accent);
  stroke-width: 1.4;
  stroke-dasharray: 5 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.d-badge { fill: var(--color-accent); }
.d-badge-text { font: 600 11px var(--font-sans); fill: #ffffff; }
.d-note { font: 500 12px var(--font-sans); fill: var(--color-text); }

/* ===== CALLOUTS ===== */
.ra-callout {
  border: 1px solid var(--ra-border);
  border-left: 3px solid var(--color-accent);
  background: var(--color-surface);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-sm);
}

.ra-callout__label {
  display: block;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-accent);
  margin-bottom: 4px;
}

.ra-callout p { font-size: 0.93rem; margin: 0; }
.ra-callout p + p { margin-top: var(--space-xs); }

.ra-callout--warn { border-left-color: #d97706; }
.ra-callout--warn .ra-callout__label { color: #b45309; }

/* ===== TABLES ===== */
.ra-table {
  overflow-x: auto;
  border: 1px solid var(--ra-border);
  border-radius: var(--radius);
}

.ra-table table {
  border-collapse: collapse;
  width: 100%;
  min-width: 520px;
  font-size: 0.88rem;
}

.ra-table th,
.ra-table td {
  text-align: left;
  vertical-align: top;
  padding: 10px 14px;
  border-bottom: 1px solid var(--ra-border);
  line-height: 1.55;
}

.ra-table thead th {
  background: var(--color-surface);
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--color-text);
  white-space: nowrap;
}

.ra-table tbody tr:last-child td { border-bottom: none; }

.ra-table td code { white-space: nowrap; }

/* ===== TWO-COLUMN "FIT / MISFIT" ===== */
.ra-split {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--space-sm);
}

.ra-split__col {
  border: 1px solid var(--ra-border);
  border-radius: var(--radius);
  padding: var(--space-sm) var(--space-md) var(--space-md);
}

.ra-split__col h3 {
  margin-top: var(--space-sm);
  font-size: 0.95rem;
}

.ra-split__col ul {
  padding-left: 18px;
  margin-top: var(--space-xs);
  font-size: 0.9rem;
}

/* ===== FOOTER NAV ===== */
.ra-footnav {
  border-top: 1px solid var(--ra-border);
  padding: var(--space-md) 0 var(--space-lg);
}

.ra-backlink {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-accent);
  text-decoration: none;
}

.ra-backlink:hover { text-decoration: underline; }

/* ===== INDEX PAGE ===== */
.ra-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: var(--space-sm);
  padding-bottom: var(--space-lg);
}

.ra-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  border: 1px solid var(--ra-border);
  border-radius: var(--radius);
  padding: var(--space-md);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s, transform 0.15s, border-color 0.15s;
}

.ra-card:hover {
  transform: translateY(-2px);
  border-color: var(--ra-border-2);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.07);
}

.ra-card__icon {
  width: 36px;
  height: 36px;
  color: var(--color-accent);
  margin-bottom: var(--space-sm);
}

.ra-card__icon svg { width: 100%; height: 100%; }

.ra-card__title {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin-bottom: var(--space-xs);
}

.ra-card__desc {
  font-size: 0.92rem;
  color: var(--color-muted);
  line-height: 1.65;
  margin-bottom: var(--space-sm);
}

.ra-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
}

.ra-card__link {
  margin-top: var(--space-sm);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-accent);
}

/* Placeholder card for architectures that are still being written. */
.ra-card--soon {
  border-style: dashed;
  background: var(--color-surface);
  cursor: default;
}

.ra-card--soon:hover {
  transform: none;
  box-shadow: none;
  border-color: var(--ra-border);
}

.ra-card--soon .ra-card__icon,
.ra-card--soon .ra-card__link { color: var(--color-muted); }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .ra-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-md);
  }

  .ra-toc {
    position: static;
    max-height: none;
    border: 1px solid var(--ra-border);
    border-radius: var(--radius);
    padding: var(--space-sm);
    background: var(--color-surface);
  }

  .ra-toc__label { display: none; }

  .ra-toc summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-xs);
    list-style: none;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-muted);
  }

  .ra-toc summary::-webkit-details-marker { display: none; }

  .ra-toc summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
    transition: transform 0.15s;
  }

  .ra-toc details[open] summary::after {
    transform: translateY(2px) rotate(-135deg);
  }

  .ra-toc details[open] ol { margin-top: var(--space-sm); }

  /* No scrollspy highlight when the list is a menu rather than a rail. */
  .ra-toc li a.is-active { font-weight: 500; }
}

@media (max-width: 768px) {
  .ra-meta__updated { margin-left: 0; width: 100%; }
  .ra-prose pre code { font-size: 0.76rem; }
}
