/* ===================================================================
   Case studies + field notes — long-form pages (loaded after style.css,
   which provides the tokens, nav, buttons, cards and the Ask widget)
   =================================================================== */
body.page { min-height: 100vh; }
.page .nav { border-bottom-color: var(--border); }
.page .aurora span { opacity: .3; }
:root[data-theme="light"] .page .aurora span { opacity: .16; }

.article {
  max-width: 820px; margin: 0 auto;
  padding: 128px clamp(18px, 5vw, 40px) 40px;
}
@media (max-width: 680px) { .article { padding-top: 110px; padding-bottom: 96px; } }
.article--list { max-width: 1080px; }

.crumbs { display: flex; flex-wrap: wrap; gap: 9px; font-size: .84rem; color: var(--muted); margin-bottom: 26px; }
.crumbs a { color: var(--muted); transition: color .2s; }
.crumbs a:hover { color: var(--accent); }
.crumbs span { opacity: .6; }

.article__eyebrow {
  font: 600 .8rem "Space Grotesk", sans-serif; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--accent); margin-bottom: 12px;
}
.article__head h1 {
  font-size: clamp(2rem, 5.6vw, 3.1rem); font-weight: 700; letter-spacing: -1px; line-height: 1.08;
  margin-bottom: 18px; text-wrap: balance;
}
.article__lede { font-size: clamp(1.05rem, 2.4vw, 1.22rem); line-height: 1.6; color: color-mix(in srgb, var(--text) 72%, var(--muted)); }
.article__meta { margin: 20px 0 16px; font-size: .88rem; color: var(--muted); }
.article__meta a { color: var(--text); font-weight: 600; }
.article__head .tags { margin-bottom: 8px; }

.article__cover {
  margin: 30px 0 8px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border);
  aspect-ratio: 2 / 1; background: var(--bg-soft);
}
.article__cover img { width: 100%; height: 100%; object-fit: cover; }

.article__facts {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(min(170px, 100%), 1fr)); gap: 1px;
  margin: 30px 0 0; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
  background: var(--border);
}
.article__facts div { background: var(--card); padding: 16px 18px; }
.article__facts dt { font-size: .72rem; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.article__facts dd { font-size: .93rem; font-weight: 500; line-height: 1.45; }

.article__toc {
  margin: 30px 0 0; padding: 18px 22px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: color-mix(in srgb, var(--card) 70%, transparent);
  font-size: .92rem;
}
.article__toc strong { display: block; font: 600 .78rem "Space Grotesk", sans-serif; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); margin-bottom: 10px; }
.article__toc ol { margin: 0; padding-inline-start: 20px; display: grid; gap: 5px; color: var(--muted); }
.article__toc a { color: var(--text); }
.article__toc a:hover { color: var(--accent); }

/* ---- Prose ---- */
.prose { margin-top: 38px; font-size: 1.04rem; line-height: 1.78; color: color-mix(in srgb, var(--text) 88%, var(--muted)); }
.prose > * + * { margin-top: 1.15em; }
.prose h2 {
  font-size: clamp(1.45rem, 3.6vw, 1.85rem); letter-spacing: -.4px; line-height: 1.2; color: var(--text);
  margin-top: 2.3em; padding-top: .2em;
}
.prose h2::before { content: ""; display: block; width: 44px; height: 4px; border-radius: 4px; background: var(--grad); margin-bottom: 16px; }
.prose h3 { font-size: 1.18rem; line-height: 1.3; color: var(--text); margin-top: 1.9em; }
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.prose a:hover { text-decoration-thickness: 2px; }
.prose ul, .prose ol { padding-inline-start: 1.35em; }
.prose li + li { margin-top: .45em; }
.prose li::marker { color: var(--accent); }
.prose blockquote {
  border-inline-start: 3px solid var(--accent); padding: 4px 0 4px 18px; color: var(--muted); font-style: italic;
}
.prose hr { border: 0; height: 1px; background: var(--border); margin: 2.4em 0; }
.prose code {
  font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em;
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-soft)); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere;
}
.prose pre {
  position: relative; overflow-x: auto; padding: 18px 20px; border-radius: var(--radius-sm);
  background: #0a0f1c; border: 1px solid #1d2740; color: #dbe4f7; font-size: .86rem; line-height: 1.65;
  -webkit-overflow-scrolling: touch;
}
.prose pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; overflow-wrap: normal; white-space: pre; }
.code-copy {
  position: absolute; top: 8px; inset-inline-end: 8px; font: 600 .7rem "Inter", sans-serif; cursor: pointer;
  color: #93a0bd; background: #131e33; border: 1px solid #1d2740; border-radius: 7px; padding: 5px 9px;
  opacity: 0; transition: opacity .2s, color .2s;
}
.prose pre:hover .code-copy, .code-copy:focus-visible { opacity: 1; }
.code-copy:hover { color: #fff; }
@media (hover: none) { .code-copy { opacity: 1; } }

.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.prose table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.prose th, .prose td { text-align: start; padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { font: 600 .76rem "Space Grotesk", sans-serif; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); background: var(--bg-soft); }
.prose tr:last-child td { border-bottom: 0; }

.prose .note {
  padding: 16px 18px; border-radius: var(--radius-sm); font-size: .96rem;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  background: color-mix(in srgb, var(--accent) 8%, var(--card));
}
.prose .note > :first-child { margin-top: 0; }

/* ---- Layered architecture diagram (```flow blocks) ---- */
.flow {
  margin: 1.8em 0; padding: clamp(14px, 3vw, 24px); border-radius: var(--radius);
  border: 1px solid var(--border); background: color-mix(in srgb, var(--card) 72%, transparent);
  display: grid; gap: 0; font-size: .86rem; line-height: 1.35;
}
.flow__row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.flow__box {
  flex: 1 1 130px; max-width: 260px; text-align: center; padding: 12px 12px; border-radius: 12px;
  background: var(--bg-soft); border: 1px solid color-mix(in srgb, var(--accent) 38%, var(--border));
}
.flow__box strong { display: block; font: 600 .9rem "Space Grotesk", sans-serif; color: var(--text); }
.flow__box small { display: block; margin-top: 4px; font-size: .76rem; color: var(--muted); }
.flow__arrow { position: relative; height: 40px; display: grid; place-items: center; }
.flow__arrow::before {
  content: ""; position: absolute; left: 50%; top: 4px; bottom: 10px; width: 2px; margin-left: -1px;
  background: linear-gradient(var(--accent), var(--accent-2));
}
.flow__arrow::after {
  content: ""; position: absolute; left: 50%; bottom: 5px; width: 8px; height: 8px; margin-left: -4px;
  border-right: 2px solid var(--accent-2); border-bottom: 2px solid var(--accent-2); transform: rotate(45deg);
}
.flow__arrow span {
  position: relative; z-index: 1; font-size: .72rem; font-weight: 600; color: var(--muted);
  background: var(--card); border: 1px solid var(--border); border-radius: 100px; padding: 2px 10px;
}

/* ---- CTA + related ---- */
.article__cta {
  margin: 64px 0 0; padding: clamp(26px, 5vw, 40px); border-radius: 22px; text-align: center;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, var(--border));
  background:
    radial-gradient(120% 130% at 12% -10%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 55%),
    radial-gradient(130% 130% at 90% 120%, color-mix(in srgb, var(--accent-2) 16%, transparent), transparent 58%),
    var(--card);
}
.article__cta h2 { font-size: clamp(1.4rem, 4vw, 1.9rem); letter-spacing: -.5px; margin-bottom: 10px; }
.article__cta p { color: var(--muted); max-width: 520px; margin: 0 auto 22px; }
.article__cta-row { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; align-items: center; }
.article__related { margin-top: 64px; }
.article__related h2 { font-size: 1.3rem; margin-bottom: 20px; }
.posts--list { margin-top: 40px; grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr)); }
.page .post-card :is(h2, h3) { font-size: 1.12rem; }

@media print {
  .article { padding-top: 20px; }
  .article__cta, .article__related, .code-copy { display: none !important; }
  .prose pre { background: #fff; color: #000; border-color: #ccc; white-space: pre-wrap; }
}

/* Touch targets: breadcrumbs, byline, contents and footer links reach 24px+ on touch screens
   (html scroll-padding-top already clears the fixed nav for #anchors, so headings need no scroll-margin) */
@media (pointer: coarse) {
  .crumbs a, .article__meta a, .footer p a { display: inline-block; padding: 8px 4px; margin: -8px -4px; }
  .article__toc ol { gap: 0; }
  .article__toc a { display: inline-block; padding: 5px 0; }
}
