/* Shared styles for architecture docs — matches index.html aesthetic */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #F3ECE0;
  --bg-deep: #EBE2D3;
  --bg-card: #FBF7EF;
  --bg-card-hover: #FFFBF3;
  --text: #1E1A16;
  --text-secondary: #6A615A;
  --text-muted: #A49B90;
  --accent: #C2613A;
  --accent-deep: #8B3F21;
  --accent-wash: rgba(194, 97, 58, 0.08);
  --rule: #D9CFC1;
  --rule-soft: #E6DED0;
  --live: #4A7C59;
  --serif: 'Instrument Serif', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

/* Grain overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
}

/* Ambient */
.ambient {
  position: fixed;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.45;
}
.ambient::before, .ambient::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
}
.ambient::before {
  width: 55vw; height: 55vw; top: -10%; left: -5%;
  background: radial-gradient(circle, rgba(194, 97, 58, 0.18), transparent 70%);
  animation: drift1 28s ease-in-out infinite alternate;
}
.ambient::after {
  width: 45vw; height: 45vw; bottom: -10%; right: -10%;
  background: radial-gradient(circle, rgba(139, 63, 33, 0.14), transparent 70%);
  animation: drift2 36s ease-in-out infinite alternate;
}
@keyframes drift1 { 0%{transform:translate(0,0) scale(1);} 100%{transform:translate(8vw,6vh) scale(1.15);} }
@keyframes drift2 { 0%{transform:translate(0,0) scale(1);} 100%{transform:translate(-6vw,-8vh) scale(1.1);} }

main, header, footer, .masthead { position: relative; z-index: 1; }

/* Masthead */
.masthead {
  max-width: 860px;
  margin: 0 auto;
  padding: 28px 40px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.25s ease;
}
.back-link:hover { color: var(--accent); }
.back-link svg { width: 12px; height: 12px; }

.masthead-right { display: flex; gap: 18px; }

/* Hero */
header.doc-hero {
  max-width: 860px;
  margin: 0 auto;
  padding: 64px 40px 48px;
}

.doc-kicker {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 18px;
}

.doc-title {
  font-family: var(--serif);
  font-weight: 400;
  font-size: clamp(2.6rem, 6vw, 4.4rem);
  letter-spacing: -0.02em;
  line-height: 1;
  color: var(--text);
  margin-bottom: 20px;
}

.doc-title em { color: var(--accent); font-style: italic; }

.doc-lede {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.3rem;
  color: var(--text-secondary);
  line-height: 1.5;
  max-width: 620px;
}

.doc-rule {
  height: 1px;
  background: var(--rule);
  margin: 48px auto 0;
  max-width: 860px;
  width: calc(100% - 80px);
}

/* Article body */
article.doc {
  max-width: 860px;
  margin: 0 auto;
  padding: 56px 40px 96px;
}

article.doc section + section { margin-top: 56px; }

.section-label {
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.section-label::before {
  content: '';
  width: 24px;
  height: 1px;
  background: var(--accent);
}

/* Jargon info — hover/focus tooltip on tech-jargon sections */
.jargon-info {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  margin-left: 4px;
  padding: 0;
  border: 1px solid rgba(194, 97, 58, 0.45);
  border-radius: 50%;
  background: transparent;
  color: var(--accent);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.72rem;
  line-height: 1;
  cursor: help;
  transition: background 0.25s ease, color 0.25s ease, border-color 0.25s ease, transform 0.25s ease;
  -webkit-tap-highlight-color: transparent;
}
.jargon-info:hover,
.jargon-info:focus-visible {
  background: var(--accent);
  color: var(--bg-card);
  border-color: var(--accent);
  transform: translateY(-1px);
  outline: none;
}

.jargon-tip {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  z-index: 20;
  width: max-content;
  max-width: 320px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-left: 2px solid var(--accent);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(30, 26, 22, 0.08);
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--text);
  text-transform: none;
  letter-spacing: 0;
  opacity: 0;
  transform: translateY(-4px);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.jargon-tip::before {
  content: '';
  position: absolute;
  top: -6px;
  left: 14px;
  width: 10px;
  height: 10px;
  background: var(--bg-card);
  border-top: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  transform: rotate(45deg);
}
.jargon-info:hover .jargon-tip,
.jargon-info:focus-visible .jargon-tip,
.jargon-info:focus-within .jargon-tip {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

@media (max-width: 860px) {
  .jargon-tip { max-width: 260px; font-size: 0.92rem; padding: 12px 14px; }
}

.section-head {
  font-family: var(--serif);
  font-weight: 400;
  font-size: 2.1rem;
  letter-spacing: -0.015em;
  line-height: 1.1;
  margin-bottom: 20px;
  color: var(--text);
}

.section-head em { color: var(--accent); font-style: italic; }

article.doc p {
  font-size: 1.05rem;
  color: var(--text);
  margin-bottom: 18px;
  max-width: 680px;
}

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

.pull {
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.45rem;
  color: var(--text);
  line-height: 1.45;
  border-left: 2px solid var(--accent);
  padding: 6px 0 6px 22px;
  margin: 32px 0;
  max-width: 640px;
}

/* Flow diagram: input → transform → output */
.flow {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto 1fr;
  gap: 18px;
  align-items: stretch;
  margin: 32px 0 12px;
  counter-reset: flow-step;
}

.flow-step {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--rule-soft);
  border-radius: 16px;
  padding: 26px 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  counter-increment: flow-step;
  transition: border-color 0.3s ease, background 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}
.flow-step::before {
  content: counter(flow-step, decimal-leading-zero);
  position: absolute;
  top: 18px;
  right: 22px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  opacity: 0.7;
}
.flow-step:hover {
  border-color: var(--rule);
  background: var(--bg-card-hover);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(30, 26, 22, 0.05);
}

.flow-step .flow-kicker {
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.flow-step .flow-title {
  font-family: var(--serif);
  font-size: 1.3rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
  color: var(--text);
  margin-top: 2px;
}

.flow-step .flow-body {
  font-size: 0.92rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 4px;
}

.flow-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-family: var(--serif);
  font-size: 1.4rem;
  font-style: italic;
  opacity: 0.6;
}

/* Tech list — spec sheet */
.tech-grid {
  display: flex;
  flex-direction: column;
  margin-top: 20px;
  border-top: 1px solid var(--rule);
}

.tech-row {
  display: grid;
  grid-template-columns: 120px 190px 1fr;
  gap: 28px;
  align-items: baseline;
  padding: 22px 0;
  border-bottom: 1px solid var(--rule-soft);
  transition: background 0.25s ease, padding 0.25s ease;
}
.tech-row:hover {
  background: linear-gradient(90deg, var(--accent-wash), transparent 70%);
  padding-left: 12px;
}

.tech-row .tech-label {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--accent);
  padding-top: 4px;
}

.tech-row .tech-value {
  font-family: var(--serif);
  font-size: 1.3rem;
  color: var(--text);
  letter-spacing: -0.005em;
  line-height: 1.25;
}

.tech-row .tech-plain {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
  max-width: 440px;
}

/* Callouts */
.callout {
  background: var(--accent-wash);
  border: 1px solid rgba(194, 97, 58, 0.2);
  border-radius: 14px;
  padding: 22px 24px;
  margin: 28px 0 0;
  max-width: 680px;
}
.callout .callout-label {
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 8px;
}
.callout p {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
}

/* Footer */
footer {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 40px 64px;
}
.footer-rule { width: 100%; height: 1px; background: var(--rule); margin-bottom: 28px; }
.footer-grid {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.footer-grid a { color: var(--text-muted); text-decoration: none; transition: color 0.25s ease; }
.footer-grid a:hover { color: var(--accent); }

/* Entrance animation */
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.masthead { animation: fadeIn 0.7s ease 0.05s both; }
header.doc-hero { animation: fadeUp 0.75s cubic-bezier(0.2, 0.8, 0.2, 1) 0.1s both; }
article.doc section:nth-child(1) { animation: fadeUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.35s both; }
article.doc section:nth-child(2) { animation: fadeUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.45s both; }
article.doc section:nth-child(3) { animation: fadeUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.55s both; }
article.doc section:nth-child(4) { animation: fadeUp 0.6s cubic-bezier(0.2, 0.8, 0.2, 1) 0.65s both; }

/* Responsive */
@media (max-width: 860px) {
  .masthead { padding: 20px 24px 0; font-size: 0.64rem; }
  header.doc-hero { padding: 40px 24px 32px; }
  .doc-title { font-size: clamp(2.2rem, 9vw, 3.2rem); }
  .doc-lede { font-size: 1.15rem; }
  .doc-rule { width: calc(100% - 48px); margin-top: 32px; }
  article.doc { padding: 40px 24px 72px; }
  article.doc section + section { margin-top: 40px; }
  .section-head { font-size: 1.7rem; }
  .flow {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .flow-arrow {
    transform: rotate(90deg);
    font-size: 1.4rem;
    padding: 2px 0;
  }
  .tech-row {
    grid-template-columns: 1fr;
    gap: 4px;
    padding: 18px 0;
  }
  .tech-row:hover { padding-left: 0; }
  .tech-row .tech-label { padding-top: 0; }
  .tech-row .tech-value { font-size: 1.2rem; }
  footer { padding: 0 24px 48px; }
  .footer-grid { flex-direction: column; gap: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .ambient { display: none; }
}

/* ============================================================
   UI EXTRAS — scroll rail · § anchors · toast
   Added 2026-04-21. Mirrors index.html patterns.
   ============================================================ */

/* Scroll-progress rail */
.scroll-rail {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 100vh;
  background: var(--rule-soft);
  z-index: 40;
  pointer-events: none;
}
.scroll-rail-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transform-origin: top;
  transform: scaleY(0);
  transition: transform 80ms linear;
  will-change: transform;
}
@media (max-width: 900px) { .scroll-rail { display: none; } }
@media (prefers-reduced-motion: reduce) { .scroll-rail { display: none; } }

/* § copy-link anchors */
.has-anchor { position: relative; }
.heading-anchor {
  position: absolute;
  left: -1.4em;
  top: 50%;
  transform: translateY(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  font-family: var(--serif);
  font-style: italic;
  font-size: 0.62em;
  line-height: 1;
  color: var(--accent);
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease;
  text-decoration: none;
}
.has-anchor:hover .heading-anchor,
.has-anchor:focus-within .heading-anchor { opacity: 0.55; }
.heading-anchor:hover { opacity: 1; }
.heading-anchor:focus-visible {
  opacity: 1;
  outline: 2px solid rgba(194, 97, 58, 0.28);
  outline-offset: 3px;
  border-radius: 3px;
}
@media (max-width: 820px) { .heading-anchor { display: none; } }
@media (prefers-reduced-motion: reduce) { .heading-anchor { transition: none; } }

/* Toast */
.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--rule);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(30, 26, 22, 0.10);
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}
.toast.open { opacity: 1; transform: translateY(0); }
@media (prefers-reduced-motion: reduce) {
  .toast { transition: opacity 120ms; transform: none; }
  .toast.open { transform: none; }
}
