/* Ambient Sound Online — /insights
   Shares the main app's design tokens exactly: same monochrome palette,
   same monospace type, same button/panel language. No framework. */

:root {
  --bg: #05070a;
  --panel-bg: rgba(10, 14, 18, 0.74);
  --border: rgba(255, 255, 255, 0.09);
  --text: rgba(255, 255, 255, 0.82);
  --text-body: rgba(255, 255, 255, 0.70); /* running text: softer than headings, easier on the eyes */
  --text-dim: rgba(235, 238, 240, 0.42);
  --text-faint: rgba(235, 238, 240, 0.28);
  --accent: #e9edee;
  --max-width: 640px;
}

* { box-sizing: border-box; }

html { background: var(--bg); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "IBM Plex Mono", "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--text); text-underline-offset: 2px; }
a:hover { color: var(--accent); }

button, .btn {
  display: inline-block;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.15s ease;
  text-decoration: none;
}
button:hover, .btn:hover { background: rgba(255, 255, 255, 0.12); color: var(--text); }

.btn.primary {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.9);
  color: #05070a;
  font-weight: 700;
}
.btn.primary:hover { background: #ffffff; }

.filter-btn.active {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.9);
  color: #05070a;
}

/* ---- Top bar ---- */

.topbar {
  border-bottom: 1px solid var(--border);
  background: var(--panel-bg);
  backdrop-filter: blur(6px);
}

.topbar-inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar-inner { flex-wrap: nowrap; gap: 12px; }
.brand {
  color: var(--accent);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  white-space: nowrap;
}
.brand svg { flex: none; display: block; }
.brand-text { overflow: hidden; text-overflow: ellipsis; text-transform: uppercase; letter-spacing: -0.06em; }
.topbar a, .topbar a:hover, .topbar a:focus, .topbar a:focus-visible { text-decoration: none; }
.topbar a:focus-visible { outline: 1px solid rgba(255,255,255,0.6); outline-offset: 4px; border-radius: 2px; }
.topbar nav { flex: none; display: flex; align-items: center; gap: 18px; }

.topbar nav a {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.topbar nav a:hover { color: var(--text); }

.breadcrumbs {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 18px 20px 0;
  font-size: 11px;
  letter-spacing: 0.02em;
  color: var(--text-faint);
}
.breadcrumbs a { color: var(--text-faint); }
.breadcrumbs a:hover { color: var(--text-dim); }

/* ---- Article ---- */

main.article {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 20px 20px 90px;
}

.kicker {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 16px;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.005em;
  margin: 0 0 12px;
  color: var(--accent);
}

.dek {
  color: var(--text-dim);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 20px;
}

.meta-line {
  color: var(--text-faint);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 40px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.prose p, .prose li {
  font-size: 15px;
  line-height: 1.7;
  color: var(--text-body);
}

.prose h2 {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 2.4em 0 0.9em;
  font-weight: 600;
}

.prose ul, .prose ol { padding-left: 1.3em; }

.callout {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px 22px;
  margin: 2.2em 0;
}
.callout p { margin: 0; font-size: 14px; color: var(--text-dim); line-height: 1.65; }
.callout p + p { margin-top: 0.8em; }
.callout .btn { margin-top: 14px; }

.faq dt {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-top: 1.5em;
}
.faq dd {
  margin: 0.4em 0 0;
  font-size: 14px;
  color: var(--text-dim);
}

.related {
  margin-top: 3em;
  padding-top: 1.8em;
  border-top: 1px solid var(--border);
}
.related h2 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  font-weight: 600;
  margin: 0 0 1em;
}
.related-list { list-style: none; padding: 0; margin: 0; }
.related-list li { margin-bottom: 0.7em; font-size: 14px; }
.related-list a { color: var(--text-dim); }
.related-list a:hover { color: var(--accent); }

footer.site-footer {
  max-width: 880px;
  margin: 0 auto;
  padding: 30px 20px 60px;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.02em;
}
footer.site-footer a { color: var(--text-dim); }

/* ---- Catalog ---- */

.catalog-hero {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 36px 20px 0;
}
.catalog-hero h1 { margin-bottom: 8px; }
.catalog-hero p { color: var(--text-dim); font-size: 14px; }

.filters {
  max-width: 880px;
  margin: 28px auto 0;
  padding: 0 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-grid {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 90px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 20px;
  display: flex;
  flex-direction: column;
}
.card { position: relative; transition: border-color 200ms ease, background-color 200ms ease; }
.card:hover, .card:focus-within { border-color: rgba(255,255,255,0.28); background: rgba(27,31,37,0.78); }
.card:active { background: rgba(34,38,45,0.82); }

.card .tag {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin-bottom: 10px;
}

.card h2 {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 8px;
}
.card h2 a, .card h2 a:hover, .card h2 a:focus { color: var(--text); text-decoration: none; }
.card h2 a::after { content: ""; position: absolute; inset: 0; border-radius: 6px; }
.card h2 a:focus-visible { outline: none; }

.card p {
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.6;
  margin: 0 0 14px;
  flex-grow: 1;
}

.card .read-more { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.card .read-more { display: inline-block; text-decoration: none; transition: transform 200ms ease, color 200ms ease; }
.card:hover .read-more, .card:focus-within .read-more { transform: translateX(4px); color: var(--text-dim); }
@media (hover: none) { .card:hover, .card:focus-within { border-color: var(--border); background: var(--panel-bg); } .card:hover .read-more, .card:focus-within .read-more { transform: none; color: var(--text-faint); } }
@media (prefers-reduced-motion: reduce) { .card, .card .read-more { transition: none; } .card:hover .read-more, .card:focus-within .read-more { transform: none; } }

.card[hidden] { display: none; }

/* ---- Article v2: language row, listen button, short answer, tables, code ---- */

h1 { overflow-wrap: anywhere; }
.prose { overflow-wrap: break-word; }

/* The language row sits under the headline, the way Wikipedia lists a page's
   other languages. Only languages the page exists in are shown. */
.langs {
  display: flex;
  flex-wrap: wrap;
  gap: 0 18px;
  margin: -2px 0 12px;
  font-size: 12px;
  letter-spacing: 0.02em;
}
/* padding makes each language a comfortable target for a thumb */
.langs a, .langs span { display: inline-block; padding: 7px 0; }
.langs a { color: var(--text-dim); text-decoration: none; }
.langs a:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 5px; }
.langs [aria-current] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 5px;
}
.catalog-hero .langs { margin: 10px 0 0; }
.more-english { margin: 12px 0 0; font-size: 12px; }
.more-english a { color: var(--text-dim); }

.meta-line { margin-bottom: 24px; }

.listen {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 30px;
}
.listen .btn { font-size: 12px; padding: 10px 16px; }
.listen-note { color: var(--text-dim); font-size: 12px; line-height: 1.5; }

.short-answer {
  border-left: 2px solid var(--accent);
  padding: 2px 0 2px 16px;
  margin: 0 0 2.2em;
}
.short-answer p { margin: 0; }
.short-answer strong { color: var(--text); }

.prose h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin: 2em 0 0.6em;
}
.prose strong { color: var(--text); font-weight: 600; }
.prose a { color: var(--text-body); text-decoration-color: rgba(255,255,255,0.35); }
.prose a:hover { color: var(--text); }
.prose li { margin-bottom: 0.45em; }
.prose p.note { color: var(--text-dim); font-size: 13px; font-style: italic; }

.table-wrap { overflow-x: auto; margin: 1.6em 0; -webkit-overflow-scrolling: touch; }
.prose table { border-collapse: collapse; width: 100%; font-size: 13px; line-height: 1.5; }
.prose th, .prose td {
  text-align: left;
  vertical-align: top;
  padding: 9px 14px 9px 0;
  border-bottom: 1px solid var(--border);
}
.prose td { color: var(--text-body); }
.prose th:last-child, .prose td:last-child { padding-right: 0; }
.prose th {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.prose pre {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 1.6em 0;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
}
.prose code { font-family: inherit; }
.prose :not(pre) > code {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 0.92em;
  overflow-wrap: anywhere;
}

.prose .sources { padding-left: 1.1em; }
.prose .sources li { font-size: 13px; color: var(--text-dim); line-height: 1.6; }
.prose .sources a { color: var(--text-dim); }
.prose .sources a:hover { color: var(--accent); }

.prose .callout p { font-size: 14px; }
.prose .callout p.app-note { font-size: 12px; color: var(--text-faint); margin-top: 12px; }

/* marks a link that leaves the reader's language for the English page */
.lang-tag {
  display: inline-block;
  font-size: 9px;
  line-height: 1;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 2px 4px;
  vertical-align: 2px;
}

@media (max-width: 380px) {
  .brand-text { display: none; }
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  .prose p, .prose li { font-size: 14px; }
  .topbar nav { gap: 14px; }
  .prose pre { font-size: 11.5px; padding: 12px; }
  .listen { margin-bottom: 26px; }
  .langs { font-size: 13px; }
}

/* Wide tables on a phone: every row becomes a block, the first cell is its
   title and the other cells carry their column name as a small label. */
@media (max-width: 600px) {
  .prose table.stack,
  .prose table.stack tbody,
  .prose table.stack tr,
  .prose table.stack td { display: block; width: 100%; }
  .prose table.stack thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
  .prose table.stack tr { padding: 16px 0; border-bottom: 1px solid var(--border); }
  .prose table.stack tr:first-child { border-top: 1px solid var(--border); }
  .prose table.stack td { border: 0; padding: 0 0 10px; font-size: 14px; }
  .prose table.stack td:last-child { padding-bottom: 0; }
  .prose table.stack td:first-child {
    color: var(--accent);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
  }
  .prose table.stack td[data-label]::before {
    content: attr(data-label);
    display: block;
    color: var(--text-faint);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    margin-bottom: 2px;
  }
}

/* ---- Live demos (filled in by demos.js) ---- */

.demo {
  margin: 2.2em 0 2.6em;
  padding: 18px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.demo-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin-bottom: 14px;
}
.demo-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.demo-tab { flex: 1 1 auto; padding: 10px 12px; }
.demo-tab[aria-pressed="true"] {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.9);
  color: #05070a;
  font-weight: 700;
}
.demo-screens { display: grid; grid-template-columns: 1.55fr 1fr; gap: 12px; }
.demo-screen {
  min-width: 0;
  padding: 10px 12px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
}
.demo-label {
  display: block;
  margin-bottom: 8px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
}
.demo-canvas { display: block; width: 100%; height: 132px; }
.demo-screen-short .demo-canvas { height: 112px; }
.demo-screens.one { grid-template-columns: 1fr; }
.demo-screens.even { grid-template-columns: 1fr 1fr; }
.demo-screen-tall .demo-canvas { height: 170px; }

/* a row of switches and sliders above or below the pictures */
.demo-controls { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 12px 22px; margin: 14px 0 0; }
.demo-tabs + .demo-controls { margin-top: 0; margin-bottom: 14px; }

.demo .demo-switch {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
}
.demo .demo-switch:hover { background: none; color: var(--accent); }
.demo-switch-track {
  position: relative;
  flex: none;
  width: 36px;
  height: 20px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  transition: background 0.15s ease, border-color 0.15s ease;
}
.demo-switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.15s ease, background 0.15s ease;
}
.demo-switch[aria-checked="true"] .demo-switch-track { background: rgba(255, 255, 255, 0.9); border-color: rgba(255, 255, 255, 0.9); }
.demo-switch[aria-checked="true"] .demo-switch-track::after { transform: translateX(16px); background: #05070a; }

.demo-slider { display: block; flex: 1 1 220px; min-width: 0; }
.demo-slider-name {
  display: block;
  margin-bottom: 2px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
}
.demo-slider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 30px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
.demo-slider input[type="range"]::-webkit-slider-runnable-track { height: 2px; background: rgba(255, 255, 255, 0.25); }
.demo-slider input[type="range"]::-moz-range-track { height: 2px; background: rgba(255, 255, 255, 0.25); }
.demo-slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -9px;
  border: 0;
  border-radius: 50%;
  background: #e9edee;
}
.demo-slider input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border: 0; border-radius: 50%; background: #e9edee; }
.demo-slider-ends {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}

.demo .demo-readout {
  margin: 12px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 12px;
  line-height: 1.5;
  color: var(--text);
  overflow-wrap: anywhere;
}
.demo-readout span { display: block; margin-bottom: 4px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--text-faint); }
.demo-axis {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 8px;
  font-size: 10px;
  line-height: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
}
/* labels that sit under particular bars: octave below, main note, the rest */
.demo-axis-slots { display: grid; grid-template-columns: 1fr 1fr 4fr; gap: 0; text-align: center; }
.demo-axis-slots span:last-child { text-align: left; padding-left: 8px; }
.demo-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px; margin-top: 14px; }
.demo .demo-play { font-size: 12px; padding: 10px 16px; min-width: 104px; text-align: center; }
.demo .demo-caption { flex: 1 1 240px; margin: 0; font-size: 13px; line-height: 1.55; color: var(--text-body); }
.demo .demo-hint { margin: 12px 0 0; font-size: 11px; line-height: 1.5; color: var(--text-faint); }
.demo.is-playing .demo-screen:first-child { border-color: rgba(255, 255, 255, 0.22); }

@media (max-width: 600px) {
  .demo { padding: 14px; }
  .demo-screens { grid-template-columns: 1fr; }
  .demo-canvas { height: 116px; }
  .demo-screen-short .demo-canvas { height: 84px; }
  .demo-screen-tall .demo-canvas { height: 150px; }
  .demo-screens.even { grid-template-columns: 1fr; }
  .demo-tab { flex: 1 1 40%; }
}

/* lanes: one row per part of a sound — its switch, and what that part is doing.
   Each lane is as wide as the picture below it, so a mark sits right above its trace. */
.demo-lanes { margin: 0 13px 4px; }
.demo-lane { position: relative; }
.demo-lane .demo-canvas { height: 44px; }
.demo .demo-lane .demo-switch { position: absolute; z-index: 1; left: 0; top: 0; height: 100%; max-width: 50%; padding: 0 10px 0 0; }

/* meters: a track with two marks, one for each sound being compared */
.demo-meter { margin-top: 14px; }
.demo-meter:first-of-type { margin-top: 6px; }
.demo-meter-name { display: block; font-size: 12px; color: var(--text); margin-bottom: 9px; }
.demo-meter-track { position: relative; height: 2px; margin: 0 8px; background: rgba(255, 255, 255, 0.22); }
.demo-meter-mark {
  position: absolute;
  top: 50%;
  left: 0;
  width: 14px;
  height: 14px;
  margin: -7px 0 0 -7px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: #05070a;
  opacity: 0;
  transition: left 0.5s ease, opacity 0.3s ease, transform 0.2s ease;
}
.demo-meter-mark.is-set { opacity: 0.55; }
.demo-meter-mark.sharp { background: var(--accent); }
.demo[data-chosen="soft"] .demo-meter-mark.soft.is-set,
.demo[data-chosen="sharp"] .demo-meter-mark.sharp.is-set { opacity: 1; transform: scale(1.25); z-index: 1; }
.demo-meter .demo-axis { margin-top: 10px; }
.demo .demo-meter-legend { margin: 16px 0 0; font-size: 11px; color: var(--text-dim); white-space: pre-wrap; }

/* the listen button waits (dimmed) until the sound is loaded in the background */
.listen .btn.is-loading { opacity: 0.55; }

/* pinned guide at the top of the list */
.card-pinned { grid-column: 1 / -1; border-color: rgba(255,255,255,0.22); }
.card-pinned h2 { font-size: 18px; }
