/* ============================================================
   mez.sh — "Scratchpad"
   Palette sampled from matplotlib's magma colormap, the one
   every spectrogram on this site is already plotted in.
   ============================================================ */

:root {
  /* light */
  --paper:      #F7F6F9;
  --surface:    #FFFFFF;
  --surface-2:  #F1EEF5;
  --ink:        #171021;
  --ink-2:      #4B4159;
  --ink-3:      #7C7289;
  --rule:       #E5E0EC;
  --rule-soft:  #EFEBF3;

  /* magma stops */
  --m-deep:     #221030;
  --m-plum:     #6A1F6E;
  --m-magenta:  #B6367A;
  --m-coral:    #F1605D;
  --m-amber:    #FEB77E;

  --accent:     var(--m-magenta);
  --accent-ink: #8E1F5E;

  /* code surface stays dark in both themes */
  --code-bg:    #1A1024;
  --code-fg:    #E9DFF2;
  --code-rule:  #33203F;

  --measure: 68ch;
  --rail: 15rem;
  --gap: clamp(1.5rem, 4vw, 3rem);

  --f-display: "Bricolage Grotesque", "Helvetica Neue", Arial, sans-serif;
  --f-body: "Newsreader", Georgia, "Times New Roman", serif;
  --f-mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  --ease: cubic-bezier(.2, .7, .3, 1);
  color-scheme: light;
}

[data-theme="dark"] {
  --paper:      #110B18;
  --surface:    #191122;
  --surface-2:  #201630;
  --ink:        #F0EAF6;
  --ink-2:      #B6AAC4;
  --ink-3:      #857A94;
  --rule:       #2C2138;
  --rule-soft:  #241A30;
  --accent:     #E85AA0;
  --accent-ink: #FB86BE;
  --code-bg:    #0C0712;
  --code-rule:  #291B36;
  color-scheme: dark;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body, h1, h2, h3, h4, p, figure, blockquote, ul, ol, dl, dd { margin: 0; }
ul[class], ol[class] { list-style: none; padding: 0; }
img, svg, video { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }

html { scroll-behavior: smooth; scroll-padding-top: 6rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-variant-numeric: oldstyle-nums;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- shared bits ---------- */
.wrap {
  width: min(100% - 2.5rem, 76rem);
  margin-inline: auto;
}

.eyebrow {
  font-family: var(--f-mono);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--paper);
  padding: .75rem 1rem;
  z-index: 99;
}
.skip:focus { left: 0; }

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

a { color: inherit; }

/* ---------- masthead ---------- */
.masthead {
  position: sticky;
  top: 0;
  z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(14px) saturate(1.4);
  border-bottom: 1px solid var(--rule-soft);
}

.masthead__inner {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  height: 3.75rem;
}

.wordmark {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: -.02em;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: .55rem;
  margin-right: auto;
}

/* the dot is a live signal indicator, not decoration */
.wordmark__dot {
  width: .5rem;
  height: .5rem;
  border-radius: 50%;
  background: var(--m-coral);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--m-coral) 60%, transparent);
  animation: ping 3.2s var(--ease) infinite;
  flex: none;
}
@keyframes ping {
  0%, 70%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--m-coral) 55%, transparent); }
  35%           { box-shadow: 0 0 0 .4rem color-mix(in srgb, var(--m-coral) 0%, transparent); }
}

.nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  font-family: var(--f-mono);
  font-size: .8125rem;
}
.nav a {
  text-decoration: none;
  color: var(--ink-2);
  padding-bottom: 2px;
  border-bottom: 1px solid transparent;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.nav a:hover { color: var(--ink); border-bottom-color: var(--accent); }
.nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }

.theme-toggle {
  background: none;
  border: 1px solid var(--rule);
  border-radius: 999px;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--ink-2);
  transition: border-color .18s var(--ease), color .18s var(--ease);
  flex: none;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-3); }
.theme-toggle svg { width: 1rem; height: 1rem; }
[data-theme="dark"] .theme-toggle .i-sun { display: none; }
.theme-toggle .i-moon { display: none; }
[data-theme="dark"] .theme-toggle .i-moon { display: block; }

@media (max-width: 34rem) {
  .nav .nav--optional { display: none; }
}

/* ---------- hero ---------- */
.hero {
  padding: clamp(3.5rem, 11vw, 7.5rem) 0 clamp(2rem, 5vw, 3.5rem);
}

.hero__title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(3.1rem, 12vw, 7.5rem);
  line-height: .88;
  letter-spacing: -.045em;
  font-variant-numeric: lining-nums;
  max-width: 12ch;
}
.hero__title em {
  font-style: normal;
  color: var(--accent);
}

.hero__lede {
  margin-top: 1.75rem;
  max-width: 46ch;
  font-size: clamp(1.125rem, 2.2vw, 1.375rem);
  line-height: 1.55;
  color: var(--ink-2);
}

.hero__links {
  margin-top: 1.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 1.25rem;
  font-family: var(--f-mono);
  font-size: .8125rem;
}
.hero__links a {
  text-decoration: none;
  color: var(--ink-2);
  border-bottom: 1px solid var(--rule);
  padding-bottom: 2px;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.hero__links a:hover { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------- signature: the signal strip ---------- */
.signal {
  margin: clamp(2.5rem, 6vw, 4.5rem) 0 clamp(3rem, 7vw, 5rem);
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  padding: 1.25rem 0 1rem;
}

.signal__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: .9rem;
}
.signal__caption {
  font-family: var(--f-mono);
  font-size: .6875rem;
  color: var(--ink-3);
  letter-spacing: .02em;
}

.signal__plot {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 74px;
  position: relative;
}

.signal__col {
  flex: 1 1 0;
  min-width: 2px;
  height: 100%;
  display: flex;
  align-items: flex-end;
  background: none;
  border: 0;
  padding: 0;
  cursor: default;
}
.signal__col[data-count]:not([data-count="0"]) { cursor: pointer; }

.signal__bar {
  width: 100%;
  border-radius: 1px;
  background: var(--rule);
  transform-origin: bottom;
  transition: filter .18s var(--ease), opacity .18s var(--ease);
}
.signal__col:hover .signal__bar,
.signal__col:focus-visible .signal__bar { filter: brightness(1.18); }

.signal__axis {
  display: flex;
  justify-content: space-between;
  margin-top: .6rem;
  font-family: var(--f-mono);
  font-size: .6875rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.signal__axis span:nth-child(2) {
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--ink-3);
  opacity: .75;
}

.signal__tip {
  position: absolute;
  bottom: calc(100% + .55rem);
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--paper);
  font-family: var(--f-mono);
  font-size: .6875rem;
  line-height: 1.4;
  padding: .4rem .6rem;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity .14s var(--ease);
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
}
.signal__tip[data-show="1"] { opacity: 1; }

@media (prefers-reduced-motion: no-preference) {
  .signal__bar { animation: rise .5s var(--ease) both; }
  @keyframes rise { from { transform: scaleY(0); opacity: 0; } to { transform: scaleY(1); opacity: 1; } }
}

/* ---------- section headers ---------- */
.section {
  padding-bottom: clamp(2.5rem, 6vw, 4rem);
}
.section__head {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding-bottom: 1.25rem;
}
.section__head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule);
}

/* ---------- featured post ---------- */
.featured {
  display: block;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: clamp(1.5rem, 4vw, 2.75rem);
  position: relative;
  overflow: hidden;
  transition: border-color .2s var(--ease), transform .2s var(--ease);
}
.featured::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: linear-gradient(180deg, var(--m-plum), var(--m-magenta) 45%, var(--m-coral) 78%, var(--m-amber));
}
.featured:hover { border-color: var(--ink-3); transform: translateY(-2px); }

.featured__meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem;
  align-items: center;
  margin-bottom: .9rem;
}

.featured__title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 4vw, 2.5rem);
  line-height: 1.05;
  letter-spacing: -.025em;
  max-width: 22ch;
}
.featured:hover .featured__title { color: var(--accent); }

.featured__excerpt {
  margin-top: .9rem;
  color: var(--ink-2);
  max-width: 60ch;
}

.featured__cta {
  margin-top: 1.4rem;
  font-family: var(--f-mono);
  font-size: .8125rem;
  color: var(--accent);
  display: inline-flex;
  gap: .4rem;
}
.featured:hover .featured__cta span { transform: translateX(3px); }
.featured__cta span { transition: transform .2s var(--ease); display: inline-block; }

/* ---------- archive list ---------- */
.year {
  display: flex;
  align-items: baseline;
  gap: 1rem;
  padding: 1.75rem 0 .5rem;
}
.year__label {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: -.01em;
  font-variant-numeric: lining-nums;
}
.year::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--rule-soft);
}
.year__count {
  font-family: var(--f-mono);
  font-size: .6875rem;
  color: var(--ink-3);
}

.entry {
  display: grid;
  grid-template-columns: 4.5rem 1fr auto;
  gap: 1.25rem;
  align-items: baseline;
  padding: .85rem 0;
  border-bottom: 1px solid var(--rule-soft);
  text-decoration: none;
  transition: background .18s var(--ease);
}
.entry:hover { background: var(--surface-2); }
.entry__date {
  font-family: var(--f-mono);
  font-size: .75rem;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}
.entry__title {
  font-size: 1.0625rem;
  line-height: 1.4;
  transition: color .18s var(--ease);
}
.entry:hover .entry__title { color: var(--accent); }
.entry__tags {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

@media (max-width: 40rem) {
  .entry { grid-template-columns: 3.75rem 1fr; }
  .entry__tags { display: none; }
}

.tag {
  font-family: var(--f-mono);
  font-size: .6875rem;
  letter-spacing: .02em;
  color: var(--ink-3);
  border: 1px solid var(--rule);
  border-radius: 999px;
  padding: .1rem .5rem;
  white-space: nowrap;
}

/* ---------- post page ---------- */
.post-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--gap);
  padding-bottom: 4rem;
}
@media (min-width: 62rem) {
  .post-shell { grid-template-columns: minmax(0, 1fr) var(--rail); }
}

.post-head {
  padding: clamp(2.5rem, 7vw, 4.5rem) 0 clamp(1.5rem, 3vw, 2.25rem);
  border-bottom: 1px solid var(--rule);
  margin-bottom: clamp(2rem, 4vw, 3rem);
}
.post-head__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.1rem;
}
.post-head__title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.1rem, 6vw, 3.75rem);
  line-height: 1.02;
  letter-spacing: -.035em;
  max-width: 20ch;
}
.post-head__sub {
  margin-top: 1.1rem;
  font-size: 1.1875rem;
  color: var(--ink-2);
  max-width: 52ch;
}

.prose { max-width: var(--measure); }

.prose > * + * { margin-top: 1.25em; }
.prose p { color: var(--ink); }

.prose h2, .prose h3, .prose h4 {
  font-family: var(--f-display);
  letter-spacing: -.02em;
  line-height: 1.15;
  scroll-margin-top: 6rem;
}
.prose h2 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-top: 2.75em;
  padding-top: .9rem;
  border-top: 1px solid var(--rule-soft);
}
.prose h3 { font-size: 1.3125rem; font-weight: 600; margin-top: 2.1em; }
.prose h4 { font-size: 1.0625rem; font-weight: 600; margin-top: 1.8em; }

.prose a {
  color: var(--accent-ink);
  text-decoration: none;
  background-image: linear-gradient(var(--accent), var(--accent));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  padding-bottom: 1px;
  transition: background-size .2s var(--ease);
}
.prose a:hover { background-size: 100% 2px; }

.prose ul, .prose ol { padding-left: 1.35em; }
.prose li + li { margin-top: .4em; }
.prose li::marker { color: var(--ink-3); }

.prose strong { font-weight: 600; }
.prose hr {
  border: 0;
  height: 1px;
  background: var(--rule);
  margin: 2.75em 0;
}

.prose blockquote {
  border-left: 2px solid var(--accent);
  background: var(--surface-2);
  padding: 1rem 1.25rem;
  border-radius: 0 6px 6px 0;
  color: var(--ink-2);
}
.prose blockquote > * + * { margin-top: .75em; }

.prose img { border-radius: 8px; border: 1px solid var(--rule); }

.prose figcaption,
.prose img + em {
  font-family: var(--f-mono);
  font-size: .75rem;
  color: var(--ink-3);
}

/* code */
.prose code {
  font-family: var(--f-mono);
  font-size: .875em;
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: .1em .35em;
  font-variant-numeric: normal;
}

.prose pre,
.prose div.highlight,
.prose figure.highlight {
  background: var(--code-bg);
  border: 1px solid var(--code-rule);
  border-radius: 8px;
  overflow-x: auto;
  font-variant-numeric: normal;
}
.prose div.highlight, .prose figure.highlight { padding: 0; }
.prose pre {
  padding: 1.1rem 1.25rem;
  margin: 0;
  line-height: 1.6;
}
.prose div.highlight pre, .prose figure.highlight pre { border: 0; border-radius: 0; }

.prose pre code {
  background: none;
  border: 0;
  padding: 0;
  color: var(--code-fg);
  font-size: .8125rem;
}

/* rouge tokens, magma-tinted */
.highlight .c, .highlight .c1, .highlight .cm, .highlight .cs { color: #7B6B8C; font-style: italic; }
.highlight .k, .highlight .kd, .highlight .kn, .highlight .kp, .highlight .kr, .highlight .kt { color: #F1605D; }
.highlight .s, .highlight .s1, .highlight .s2, .highlight .sb, .highlight .sd, .highlight .se { color: #FEB77E; }
.highlight .m, .highlight .mi, .highlight .mf, .highlight .mh, .highlight .il { color: #E9A0D2; }
.highlight .nf, .highlight .nd { color: #B6D6F5; }
.highlight .nc, .highlight .nn { color: #F5D9A8; }
.highlight .o, .highlight .ow { color: #C6B3D6; }
.highlight .nb { color: #E85AA0; }
.highlight .err { color: #FF8A8A; }

/* tables — his results tables are the centrepiece */
.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9375rem;
  display: block;
  overflow-x: auto;
}
.prose thead th {
  font-family: var(--f-mono);
  font-size: .6875rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--ink-3);
  font-weight: 500;
  text-align: left;
  padding: .5rem .75rem;
  border-bottom: 1px solid var(--ink-3);
  white-space: nowrap;
}
.prose tbody td {
  padding: .6rem .75rem;
  border-bottom: 1px solid var(--rule-soft);
  vertical-align: top;
}
.prose tbody tr:hover { background: var(--surface-2); }
.prose td.is-num {
  font-family: var(--f-mono);
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.prose tbody tr:first-child td.is-num { color: var(--accent-ink); font-weight: 600; }

/* ---------- table of contents rail ---------- */
.toc {
  display: none;
  font-family: var(--f-mono);
  font-size: .75rem;
  line-height: 1.5;
}
@media (min-width: 62rem) {
  .toc { display: block; position: sticky; top: 5.5rem; align-self: start; max-height: 80vh; overflow-y: auto; }
}
.toc__label { margin-bottom: .85rem; }
.toc ol { list-style: none; padding: 0; margin: 0; border-left: 1px solid var(--rule); }
.toc a {
  display: block;
  padding: .3rem 0 .3rem .85rem;
  margin-left: -1px;
  border-left: 1px solid transparent;
  color: var(--ink-3);
  text-decoration: none;
  transition: color .18s var(--ease), border-color .18s var(--ease);
}
.toc a:hover { color: var(--ink); }
.toc li.is-sub a { padding-left: 1.6rem; font-size: .7rem; }
.toc a.is-active { color: var(--accent); border-left-color: var(--accent); }

/* ---------- post footer / pager ---------- */
.post-nav {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--rule);
  display: grid;
  gap: 1rem;
  max-width: var(--measure);
}
@media (min-width: 40rem) { .post-nav { grid-template-columns: 1fr 1fr; } }
.post-nav a {
  text-decoration: none;
  border: 1px solid var(--rule);
  border-radius: 8px;
  padding: 1rem 1.15rem;
  transition: border-color .18s var(--ease);
}
.post-nav a:hover { border-color: var(--ink-3); }
.post-nav a:hover .post-nav__title { color: var(--accent); }
.post-nav__dir { font-family: var(--f-mono); font-size: .6875rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.post-nav__title { display: block; margin-top: .3rem; line-height: 1.35; }
.post-nav a:last-child:nth-child(even) { text-align: right; }

/* ---------- page layout (about etc.) ---------- */
.page-head {
  padding: clamp(2.5rem, 7vw, 4.5rem) 0 1.5rem;
}
.page-head__title {
  font-family: var(--f-display);
  font-weight: 800;
  font-size: clamp(2.25rem, 6vw, 3.5rem);
  letter-spacing: -.035em;
  line-height: 1.03;
}

/* ---------- colophon ---------- */
.colophon {
  border-top: 1px solid var(--rule);
  padding: 2.25rem 0 3rem;
  font-family: var(--f-mono);
  font-size: .75rem;
  color: var(--ink-3);
}
.colophon__inner {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: center;
  justify-content: space-between;
}
.colophon a { color: var(--ink-2); text-decoration: none; border-bottom: 1px solid var(--rule); }
.colophon a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.colophon__links { display: flex; gap: 1.25rem; flex-wrap: wrap; }
