/* Quiet Circuit — core stylesheet.
   Authoritative design reference: doc/design-system.md
   Order: fonts, structural tokens, theme tokens, base, shell, index,
   article, markdown content, plain code. Component files
   (code-blocks.css, diagrams.css) consume the tokens defined here. */

@font-face {
  font-family: "IBM Plex Sans";
  font-display: swap;
  font-style: normal;
  font-weight: 400;
  src: url("fonts/ibm-plex-sans-latin.woff2") format("woff2");
}

@font-face {
  font-family: "IBM Plex Sans";
  font-display: swap;
  font-style: normal;
  font-weight: 700;
  src: url("fonts/ibm-plex-sans-latin.woff2") format("woff2");
}

@font-face {
  font-family: "Noto Sans Mono";
  font-display: swap;
  font-style: normal;
  font-weight: 400;
  src: url("fonts/noto-sans-mono-latin.woff2") format("woff2");
}

/* Structural tokens — shared by every theme. */
:root {
  color-scheme: dark;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-code: "Noto Sans Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --page-max: 42rem;
  --page-pad-x: clamp(1.2rem, 3vw, 2rem);
  --nav-pad-y: 18px;

  --type-label: 0.72rem;
  --type-list-title: 1.06rem;
  --type-page-title: 2rem;
  --type-section-title: 1.2rem;
  --type-subsection-title: 1rem;

  --radius-s: 0.25rem;
  --radius-m: 0.35rem;
  --radius-l: 0.45rem;

  /* Via nodes: outer diameter of the small ring that terminates a trace. */
  --node-size: 7px;
}

/* Theme tokens — quiet-circuit is the site default. */
:root,
html[data-theme="quiet-circuit"] {
  --bg: #0e1418;
  --bg-code: #0a0f13;
  --text: #e7edec;
  --muted: #96a4a3;
  --quiet: #5d6b6c;
  --line: #1e282c;
  --accent: #6fd9c8;
  --accent-soft: rgba(111, 217, 200, 0.22);
  --copper: #d9a06c;
  --error: #ff8a7a;

  /* Circuit ornaments: decorative traces sit a step above --line,
     quiet via rings a step above that. */
  --trace: #24313a;
  --node: #3b4c50;

  --bg-code-inline: rgba(10, 15, 19, 0.72);
  --line-code-inline: rgba(111, 217, 200, 0.14);
  --text-code-inline: #cfdedb;

  /* Raised surfaces: code blocks, diagrams, floating controls. */
  --surface-border: rgba(148, 196, 205, 0.09);
  --surface-divider: rgba(148, 196, 205, 0.08);
  --control-border: rgba(148, 196, 205, 0.14);
  --shadow-raised: 0 0.4rem 0.75rem rgba(2, 6, 8, 0.34);
  --shadow-control: 0 0.35rem 1rem rgba(2, 6, 8, 0.34);
}

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

html {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font-body);
  letter-spacing: 0.04em;
  scroll-behavior: smooth;
}

body {
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  margin: 0;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration-color: var(--accent);
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.16em;
}

a:hover,
a:focus-visible {
  color: var(--accent);
}

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

:where(h1, h2, h3, p) {
  margin: 0;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* Shell */
.site-header,
.site-main,
.site-footer {
  margin-inline: auto;
  max-width: var(--page-max);
  padding-inline: var(--page-pad-x);
  width: 100%;
}

.site-main {
  flex: 1;
  padding-bottom: 3.5rem;
}

.site-nav {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  min-height: 22px;
  padding-block: var(--nav-pad-y);
  position: relative;
}

/* Header trace: a hairline that starts at a via under the brand, runs to
   the right, then escapes upward through a 45° jog (.site-nav-trace) and
   fades out. */
.site-nav::before {
  background: var(--trace);
  bottom: 0;
  content: "";
  height: 1px;
  left: 0;
  position: absolute;
  right: 149px;
}

.site-nav-trace {
  bottom: 0;
  color: var(--trace);
  display: block;
  mask-image: linear-gradient(90deg, #000 0 40%, transparent 97%);
  position: absolute;
  right: 0;
}

.site-nav::after {
  background: var(--bg);
  border: 1px solid var(--accent);
  border-radius: 50%;
  bottom: calc(var(--node-size) / -2 + 0.5px);
  content: "";
  height: var(--node-size);
  left: 0;
  position: absolute;
  transition: background-color 140ms ease;
  width: var(--node-size);
}

.site-nav:has(.site-brand:hover)::after,
.site-nav:has(.site-brand:focus-visible)::after {
  background: var(--accent);
}

.site-brand,
.site-links a {
  text-decoration: none;
}

.site-brand {
  color: var(--text);
  font-size: 0.94rem;
  line-height: 1;
}

.site-links {
  align-items: center;
  display: inline-flex;
  gap: 0.9rem;
  line-height: 1;
}

.site-links a {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1;
}

.feed-link {
  align-items: center;
  display: inline-flex;
  flex: 0 0 22px;
  height: 22px;
  justify-content: center;
  width: 22px;
}

.feed-link svg {
  display: block;
  fill: none;
  height: 13px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  width: 13px;
}

.site-footer {
  color: var(--quiet);
  font-family: var(--font-code);
  font-size: var(--type-label);
  padding-block: 1.1rem 1.5rem;
  position: relative;
}

/* Footer trace mirrors the header: line fades in from the left and
   terminates at a quiet via on the right. */
.site-footer::before {
  background: linear-gradient(270deg, var(--trace) 0 70%, transparent 100%);
  content: "";
  height: 1px;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
}

.site-footer::after {
  background: var(--bg);
  border: 1px solid var(--node);
  border-radius: 50%;
  content: "";
  height: var(--node-size);
  position: absolute;
  right: 0;
  top: calc(var(--node-size) / -2 + 0.5px);
  width: var(--node-size);
}

/* 404: an interrupted trace between two open vias — the signal stops here. */
.open-circuit {
  color: var(--trace);
  display: block;
  margin-top: 2rem;
  mask-image: linear-gradient(90deg, #000 0 70%, transparent 100%);
}

.open-circuit circle {
  stroke: var(--node);
}

.open-circuit .open-circuit__live {
  stroke: var(--accent);
}

.sr-only {
  height: 1px;
  margin: -1px;
  overflow: hidden;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

/* Index */
.home-intro {
  color: var(--muted);
  padding-top: 3.1rem;
}

.home-intro h1 {
  color: var(--text);
  font-size: var(--type-page-title);
  line-height: 1.08;
  margin-bottom: 0.75rem;
}

.home-intro p {
  max-width: 33rem;
}

.post-list {
  padding-top: 1.7rem;
}

.home-intro+.post-list {
  padding-top: 2.4rem;
}

/* Heading and count sit on one schematic net: label, dashed trace, value. */
.index-heading-row {
  align-items: baseline;
  display: flex;
  gap: 0.8rem;
  margin-bottom: 0.7rem;
}

.index-heading-row::after {
  align-self: center;
  background: repeating-linear-gradient(90deg, var(--trace) 0 5px, transparent 5px 9px);
  content: "";
  flex: 1;
  height: 1px;
  order: 2;
}

.index-heading,
.index-count,
time {
  color: var(--quiet);
  font-family: var(--font-code);
  font-weight: 400;
  text-transform: uppercase;
}

.index-heading {
  font-size: var(--type-label);
  line-height: 1.55;
}

.index-count {
  font-size: 0.68rem;
  line-height: 1.55;
  order: 3;
}

time {
  display: block;
  font-size: 0.72rem;
  line-height: 1.4;
}

.post-summary {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 0.35rem;
  grid-template-columns: 1fr;
  padding: 1rem 0;
  position: relative;
}

/* Each entry hangs off the rail at a via; the via powers on under hover. */
.post-summary::before {
  background: var(--bg);
  border: 1px solid var(--node);
  border-radius: 50%;
  content: "";
  height: var(--node-size);
  left: 0;
  position: absolute;
  top: calc(var(--node-size) / -2 + 0.5px);
  transition: background-color 140ms ease, border-color 140ms ease;
  width: var(--node-size);
}

.post-summary:hover::before,
.post-summary:focus-within::before {
  background: var(--accent);
  border-color: var(--accent);
}

.post-summary h2 {
  font-size: var(--type-list-title);
  line-height: 1.2;
}

.post-summary h2 a {
  color: var(--text);
  text-decoration: none;
}

.post-summary p,
.post-list>p {
  color: var(--muted);
}

.post-summary p {
  margin-top: 0.35rem;
}

.post-list>p {
  margin-top: 1rem;
}

/* Article */
.page {
  margin-top: 2.5rem;
}

.page-header {
  margin-bottom: 1.6rem;
  padding-bottom: 1.15rem;
  position: relative;
}

.page-header::before {
  background: linear-gradient(90deg, var(--trace) 0 70%, transparent 100%);
  bottom: 0;
  content: "";
  height: 1px;
  left: 0;
  position: absolute;
  right: 0;
}

.page-header::after {
  background: var(--bg);
  border: 1px solid var(--node);
  border-radius: 50%;
  bottom: calc(var(--node-size) / -2 + 0.5px);
  content: "";
  height: var(--node-size);
  left: 0;
  position: absolute;
  width: var(--node-size);
}

.page-header time {
  margin-bottom: 0.7rem;
}

.page-header h1 {
  font-size: var(--type-page-title);
  line-height: 1.08;
}

.subtitle {
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.38;
  margin-top: 0.8rem;
}

/* Markdown */
.content {
  width: 100%;
}

.content :where(p, ul, ol) {
  margin: 0 0 1rem;
}

.content> :first-child {
  margin-top: 0;
}

.content h2,
.content h3 {
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 700;
  line-height: 1.22;
}

.content h2 {
  font-size: var(--type-section-title);
  margin: 2.25rem 0 0.7rem;
}

/* Section headings open at a small accent via; it powers on under hover. */
.content h2::before {
  border: 1px solid var(--accent);
  border-radius: 50%;
  content: "";
  display: inline-block;
  height: 0.36em;
  margin-right: 0.55rem;
  transition: background-color 140ms ease;
  vertical-align: 0.1em;
  width: 0.36em;
}

.content h2:hover::before {
  background: var(--accent);
}

.content h3 {
  color: var(--muted);
  font-size: var(--type-subsection-title);
  margin: 1.75rem 0 0.65rem;
}

.content :where(h2, h3) .zola-anchor {
  color: inherit;
  text-decoration: none;
}

.content :where(h2, h3) .zola-anchor:hover {
  color: var(--accent);
}

.content :where(ul, ol) {
  padding-left: 1.35rem;
}

.content li+li {
  margin-top: 0.35rem;
}

.content blockquote {
  border-left: 3px solid var(--line);
  color: var(--muted);
  margin: 1.5rem 0;
  padding-left: 1rem;
}

.content hr {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 2rem 0;
  overflow: visible;
  position: relative;
}

.content hr::after {
  background: var(--bg);
  border: 1px solid var(--node);
  border-radius: 50%;
  content: "";
  height: var(--node-size);
  left: 50%;
  position: absolute;
  top: calc(var(--node-size) / -2 - 0.5px);
  transform: translateX(-50%);
  width: var(--node-size);
}

.content table {
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
  width: 100%;
}

.content :where(th, td) {
  border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.65rem;
  text-align: left;
}

.content sup {
  line-height: 0;
}

.content .footnote-definition {
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.9rem;
  margin-top: 2rem;
  padding-top: 0.75rem;
}

.content .footnote-definition+.footnote-definition {
  border-top: 0;
  margin-top: 0.5rem;
  padding-top: 0;
}

.content .footnote-definition p {
  display: inline;
  margin: 0;
}

/* Code */
code {
  -webkit-box-decoration-break: clone;
  background: var(--bg-code-inline);
  border: 1px solid var(--line-code-inline);
  border-radius: var(--radius-s);
  box-decoration-break: clone;
  color: var(--text-code-inline);
  font-family: var(--font-code);
  font-size: 0.86em;
  padding: 0.08rem 0.28rem 0.1rem;
}

pre {
  background: var(--bg-code);
  border: 1px solid var(--line);
  border-radius: var(--radius-m);
  line-height: 1.55;
  margin: 1.5rem 0;
  overflow-x: auto;
  padding: 1rem;
}

pre code {
  background: transparent;
  border: 0;
  border-radius: 0;
  box-decoration-break: slice;
  color: inherit;
  padding: 0;
}
