/* ph-widgets.css — embeddable persistent-homology widgets.
   Extracted from the standalone "Shape of a Point Cloud" page (ph-explainer);
   token values and control metrics match the original exactly.

   The canvas code (js/ph/viz.js) reads its colors from CSS custom properties
   on :root at draw time. These token names are the ph-teach set and do not
   collide with the site's own tokens (--bg, --text, --accent, …). The blog
   is light-only, so only light values are defined. */

:root {
  --paper: #fcfcfd;        /* widget panel background                  */
  --ink: #1c2733;          /* points                                   */
  --ink-soft: #57687c;
  --ink-faint: #93a3b5;
  --hair: #e2e9f2;         /* hairlines, panel border                  */
  --h0: #2e7cd6;           /* components — cyan-leaning blue           */
  --h1: #2b52b5;           /* loops — royal blue                       */
  --wash: #e9f1fa;         /* union-of-disks fill                      */
  --wash-tri: #d3e2f5;     /* filled triangles                         */
  --sweep: #2e7cd6;
  --hi: #0f1b2d;           /* hover emphasis                           */
  --ph-mono: ui-monospace, 'SF Mono', 'Cascadia Mono', Menlo, Consolas, monospace;
}

figure.ph-fig {
  margin: 2.6rem 0;
}
.ph-fig .fig-panel {
  border: 1px solid var(--hair);
  border-radius: 3px;
  background: var(--paper);
  overflow: hidden;
}
.ph-fig canvas { display: block; width: 100%; touch-action: none; }
.ph-fig .plane { cursor: crosshair; }
.ph-fig figcaption {        /* reads like every other caption on the blog */
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--text-softer);
  text-align: center;
  text-wrap: balance;
  margin-top: 0.6rem;
}

.ph-fig .controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem 1rem;
  padding: 0.7rem 0.2rem 0.2rem;
  font-family: var(--sans);
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.ph-fig .controls label { display: flex; align-items: center; gap: 0.5rem; }

.ph-fig button.chip {
  font-family: var(--sans);
  font-size: 0.8rem;
  letter-spacing: 0.03em;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--hair);
  border-radius: 3px;
  padding: 0.34rem 0.7rem;
  cursor: pointer;
}
.ph-fig button.chip:hover { border-color: var(--h0); color: var(--h0); }
.ph-fig button.chip.active {
  border-color: var(--h0);
  color: var(--h0);
  font-weight: 600;
}
.ph-fig button.chip:focus-visible,
.ph-fig input[type="range"]:focus-visible {
  outline: 2px solid var(--h0);
  outline-offset: 2px;
}

.ph-fig input[type="range"] {
  accent-color: var(--h0);
  width: 11rem;
  max-width: 45vw;
}
.ph-fig .readout {
  font-family: var(--ph-mono);
  font-size: 0.82rem;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  min-width: 6.5ch;
}
.ph-fig .spacer { flex: 1; }
.ph-fig .counter { font-family: var(--ph-mono); font-size: 0.78rem; color: var(--ink-faint); }

/* --- Display equation (centred, serif, a little air) --- */
.post-body .ph-eq {
  margin: 1.6rem 0;
  text-align: center;
  font-size: 1.08rem;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
}
/* on the narrowest phones a long equation scrolls instead of widening the page */
.post-body .ph-eq .katex-display {
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.15rem 0;
}
@media (max-width: 400px) {
  .post-body .ph-eq { font-size: 0.9rem; }
}



/* --- KWIC concordance: node word aligned down the middle --- */
.post-body .kwic {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  column-gap: 0.5rem;
  row-gap: 0.4rem;
  align-items: baseline;
  margin: 1rem 0 0.6rem;
  font-family: var(--ph-mono);
  font-size: 0.78rem;
  line-height: 1.45;
  overflow-x: auto;
}
.post-body .kwic .kl { text-align: right; color: var(--ink-soft); }
.post-body .kwic .kr { text-align: left;  color: var(--ink-soft); }
.post-body .kwic .kn {
  text-align: center;
  white-space: nowrap;
  padding: 0.05rem 0.4rem;
  border-radius: 4px;
  background: #d94f36;
  color: #fff;
  font-weight: 600;
}
.post-body .kwic-note {
  font-family: var(--sans, system-ui), sans-serif;
  font-size: 0.82rem;
  color: var(--ink-faint);
  margin: 0 0 1.4rem;
}
@media (max-width: 560px) {
  .post-body .kwic { font-size: 0.7rem; column-gap: 0.3rem; }
}


/* --- Numbered linguistic examples, in the concordance face --- */
.post-body .examples {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 0.75rem;
  row-gap: 0.45rem;
  margin: 0.85rem 0 1.3rem;
  font-family: var(--ph-mono);
  font-size: 0.82rem;
  line-height: 1.5;
}
.post-body .examples .n { color: var(--ink-faint); white-space: nowrap; }
.post-body .examples .s { color: var(--ink-soft); }
.post-body .examples .mark {
  display: inline-block;
  width: 1ch;
  color: #d94f36;
  font-weight: 600;
}
.post-body .examples .key {
  padding: 0.05rem 0.34rem;
  border-radius: 4px;
  background: #d94f36;
  color: #fff;
  font-weight: 600;
}


/* --- Figure sizing for this post ---
   Tall figures (portrait photos, paper figures with small type) get more
   height than the blog's 440px cap, so their text stays legible. */
.post-body figure.fig-tall img { max-height: 640px; }

/* Side-by-side figures stack on phones; keep each one from towering over
   the text when it gets the full width. */
@media (max-width: 560px) {
  .post-body .post-figs figure img { max-height: 260px; width: auto; margin: 0 auto; }
}
