/* ==========================================================================
   Audio & Signal Processing Notes — global stylesheet
   Loaded by every page. Keep component classes stable; tools and articles
   rely on .prose, .tool and .card.
   ========================================================================== */

:root {
  --bg: #ffffff;
  --surface: #f6f8fa;
  --surface-2: #eceff4;
  --text: #16181d;
  --text-soft: #3c4552;
  --muted: #5f6976;
  --border: #e2e6eb;
  --border-strong: #cdd4dd;
  --accent: #0b63ce;
  --accent-hover: #08499b;
  --accent-soft: #e9f1fd;
  --ok: #0f7b4f;
  --warn: #92590a;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --scrollbar-thumb: #c7cfda;
  --scrollbar-thumb-hover: #a3aeba;
  --scrollbar-track: transparent;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1216;
    --surface: #171b21;
    --surface-2: #1e242c;
    --text: #e9ecf1;
    --text-soft: #c6cdd7;
    --muted: #98a2b0;
    --border: #262c35;
    --border-strong: #3a424e;
    --accent: #6aa9ff;
    --accent-hover: #93c0ff;
    --accent-soft: #16233a;
    --ok: #4ec38a;
    --warn: #e0b062;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 28px rgba(0, 0, 0, .34);
    --scrollbar-thumb: #39424e;
    --scrollbar-thumb-hover: #55606e;
  }
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; }

[hidden] { display: none !important; }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); text-decoration: underline; }

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

/* ---------- scrollbars ---------------------------------------------------- */

/* WebKit / Blink (Chrome, Edge, Safari) — covers the page and every inner
   scroll area such as .tool__mono, .prose pre and .formula. */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--scrollbar-track); }
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border: 3px solid transparent;
  background-clip: padding-box;
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover); background-clip: padding-box; }
::-webkit-scrollbar-thumb:active { background: var(--accent); background-clip: padding-box; }
::-webkit-scrollbar-corner { background: transparent; }

/* Firefox only. Scoped with @supports so newer Chromium never sees
   scrollbar-color/width, which would otherwise disable the ::-webkit-* rules. */
@supports (-moz-appearance: none) {
  html { scrollbar-width: thin; scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-track); }
}

/* ---------- layout -------------------------------------------------------- */

.container {
  width: 100%;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 20px;
}

.container--narrow { max-width: 820px; }

main { display: block; }

.section { padding: 44px 0; }
.section--tight { padding: 28px 0; }

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: #fff;
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 100;
}
.skip-link:focus { left: 0; color: #fff; }

/* ---------- header / nav -------------------------------------------------- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(180%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.site-header__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 62px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 650;
  font-size: 16px;
  color: var(--text);
  letter-spacing: -.01em;
}
.brand:hover { color: var(--text); text-decoration: none; }
.brand__mark { flex: 0 0 auto; width: 26px; height: 26px; }
.brand__name { white-space: nowrap; }
.brand__name span { color: var(--muted); font-weight: 500; }

.site-nav ul {
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav a {
  display: block;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 15px;
  font-weight: 500;
}
.site-nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.site-nav a[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }

.nav-toggle {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  cursor: pointer;
}
.nav-toggle span,
.nav-toggle span::before,
.nav-toggle span::after {
  display: block;
  width: 18px;
  height: 2px;
  margin: 0 auto;
  background: currentColor;
  border-radius: 2px;
}
.nav-toggle span::before { content: ""; transform: translateY(-6px); }
.nav-toggle span::after { content: ""; transform: translateY(4px); }

@media (max-width: 760px) {
  .nav-toggle { display: block; }
  .site-nav {
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .site-nav.is-open { display: block; }
  .site-nav ul { flex-direction: column; align-items: stretch; padding: 8px; gap: 0; }
  .site-nav a { padding: 12px; font-size: 16px; }
}

/* ---------- hero ---------------------------------------------------------- */

.hero {
  position: relative;
  overflow: hidden;
  padding: 56px 0 40px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), var(--bg));
}
.hero h1 {
  margin: 0 0 14px;
  font-size: clamp(30px, 5vw, 44px);
  line-height: 1.15;
  letter-spacing: -.02em;
}
.hero p {
  margin: 0 0 22px;
  max-width: 66ch;
  font-size: 19px;
  color: var(--text-soft);
}
.hero__actions { display: flex; flex-wrap: wrap; gap: 12px; }
.hero__inner { display: block; }
.hero__copy { position: relative; z-index: 1; }

/* The line art is an ambient background layer, not a framed picture. */
.hero__media {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  pointer-events: none;
}
.hero__media img {
  position: absolute;
  top: 50%;
  right: -4%;
  height: min(360px, 52vh);
  width: auto;
  transform: translateY(-50%);
  opacity: .55;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 40%);
  mask-image: linear-gradient(90deg, transparent, #000 40%);
}

/* ---------- buttons ------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { background: var(--accent-hover); color: #fff; text-decoration: none; }

.btn--ghost {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--ghost:hover { background: var(--surface-2); color: var(--text); }

/* ---------- headings / prose --------------------------------------------- */

h2, h3, h4 { line-height: 1.25; letter-spacing: -.01em; }

.section-title {
  margin: 0 0 6px;
  font-size: 26px;
}
.section-lead {
  margin: 0 0 26px;
  color: var(--muted);
  max-width: 70ch;
}

.prose {
  max-width: 74ch;
  color: var(--text-soft);
}
.prose h2 {
  margin: 40px 0 12px;
  padding-top: 8px;
  font-size: 25px;
  color: var(--text);
}
.prose h3 { margin: 28px 0 10px; font-size: 20px; color: var(--text); }
.prose p { margin: 0 0 16px; }
.prose ul, .prose ol { margin: 0 0 16px; padding-left: 22px; }
.prose li { margin-bottom: 7px; }
.prose li::marker { color: var(--muted); }
.prose strong { color: var(--text); }
.prose hr { margin: 36px 0; border: 0; border-top: 1px solid var(--border); }
.prose blockquote {
  margin: 0 0 18px;
  padding: 4px 0 4px 18px;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}
.prose code {
  padding: 2px 6px;
  background: var(--surface-2);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: .89em;
  color: var(--text);
}
.prose pre {
  margin: 0 0 20px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 14px;
  line-height: 1.55;
}
.prose pre code { padding: 0; background: none; font-size: inherit; }
.prose table {
  width: 100%;
  margin: 0 0 20px;
  border-collapse: collapse;
  font-size: 15px;
}
.prose th, .prose td {
  padding: 9px 12px;
  border: 1px solid var(--border);
  text-align: left;
}
.prose th { background: var(--surface); color: var(--text); font-weight: 600; }

.formula {
  margin: 0 0 20px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 15px;
  color: var(--text);
  overflow-x: auto;
}

/* ---------- cards / lists ------------------------------------------------- */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(272px, 1fr));
  gap: 18px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card h3 { margin: 0; font-size: 18px; }
.card p { margin: 0; color: var(--muted); font-size: 15px; }
.card a { font-weight: 600; }

.badge {
  align-self: flex-start;
  padding: 3px 9px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.badge--live { background: var(--accent-soft); border-color: transparent; color: var(--accent); }

/* ---------- embedded tool shell (used by articles) ------------------------ */

.tool {
  margin: 28px 0 32px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.tool__head { margin-bottom: 18px; }
.tool__title { margin: 0 0 4px; font-size: 18px; }
.tool__hint { margin: 0; color: var(--muted); font-size: 14px; }

.tool__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px 18px;
  margin-bottom: 18px;
}

.tool__field { display: flex; flex-direction: column; gap: 6px; }
.tool__field > label,
.tool__label {
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .01em;
}

.tool input[type="number"],
.tool input[type="text"],
.tool select {
  width: 100%;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
}
.tool input:focus, .tool select:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.tool input[aria-invalid="true"] { border-color: #c0392b; }

.tool__actions { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 18px; }

.tool__out {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  padding: 16px;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
}
.tool__row { display: flex; flex-direction: column; gap: 2px; }
.tool__row dt, .tool__row span:first-child {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .03em;
}
.tool__row dd { margin: 0; }
.tool__value {
  font-family: var(--mono);
  font-size: 17px;
  color: var(--text);
  word-break: break-all;
}

.tool__error {
  margin: 0 0 14px;
  padding: 10px 14px;
  background: #fdf3f2;
  border: 1px solid #f3c9c4;
  border-radius: var(--radius-sm);
  color: #9b2c20;
  font-size: 14px;
}
@media (prefers-color-scheme: dark) {
  .tool__error { background: #2a1614; border-color: #5c2b24; color: #f1a99e; }
}

.tool__note { margin: 14px 0 0; color: var(--muted); font-size: 13px; }

/* ---------- tool plots, previews and inline controls ---------------------- */

.tool__plots { display: grid; gap: 16px; margin: 0 0 18px; }

.tool__plot-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 6px;
}
.tool__plot-head h4 { margin: 0; font-size: 14px; }
.tool__plot-head span { color: var(--muted); font-size: 12.5px; }

.tool__plot {
  display: block;
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.tool__mono {
  margin: 0 0 12px;
  padding: 12px 14px;
  max-height: 168px;
  overflow: auto;
  background: var(--bg);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.tool input[type="file"] {
  padding: 6px 0;
  color: var(--text-soft);
  font-size: 14px;
}

.tool textarea {
  width: 100%;
  min-height: 84px;
  padding: 9px 11px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.5;
  resize: vertical;
}
.tool textarea:focus { border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }

.tool__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text-soft);
}
.tool__check input { width: auto; margin: 0; }

.tool__status { color: var(--muted); font-size: 13px; }

/* ---------- notices ------------------------------------------------------- */

.notice {
  margin: 0 0 22px;
  padding: 14px 18px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 15px;
}
.notice--warn { background: #fdf6e6; color: #6b4708; }
@media (prefers-color-scheme: dark) { .notice--warn { background: #2a2113; color: #e6c68a; } }

.meta {
  margin: 0 0 26px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 14px;
}

/* ---------- breadcrumbs --------------------------------------------------- */

.breadcrumbs {
  margin: 0 0 18px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}
.breadcrumbs li + li::before { content: "/"; margin-right: 8px; color: var(--border-strong); }

/* ---------- footer -------------------------------------------------------- */

.site-footer {
  margin-top: 56px;
  padding: 34px 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-size: 15px;
  color: var(--muted);
}
.site-footer__grid {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 22px;
}
.site-footer__brand { max-width: 34ch; }
.site-footer__brand p { margin: 8px 0 0; }
.site-footer nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.site-footer nav a { color: var(--text-soft); }
.site-footer__legal {
  margin: 24px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13.5px;
}

/* ---------- related reading ----------------------------------------------- */

.related {
  margin: 40px 0 0;
  padding: 22px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.related__title { margin: 0 0 4px; font-size: 17px; }

.related__note {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 14px;
}

.related__list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.related__list li {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.related__list a { font-weight: 600; }

.related__list code {
  padding: 1px 5px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 13px;
}

/* Two stacked blocks at the foot of an article read as separate panels. */
.related + .related { margin-top: 16px; }

.related--refs { background: var(--bg); }

.figure { margin: 0 0 30px; }
.figure img {
  display: block;
  width: 100%;
  height: auto;
  max-height: 320px;
  object-fit: contain;
  opacity: .9;
}
.figure figcaption { margin-top: 10px; color: var(--muted); font-size: 13.5px; }
@media (max-width:880px) {
  .hero__media img {
    top: 0;
    right: -28%;
    width: 150%;
    transform: none;
    opacity: .22;
    -webkit-mask-image: linear-gradient(180deg, transparent, #000 55%);
    mask-image: linear-gradient(180deg, transparent, #000 55%);
  }
}

