/* The minimal surfaces page (/research/minimal-surfaces/). */

.ms-page .lede { font-size: var(--text-lg); }


/* ------------------ hero ------------------ */
.ms-hero {
  position: relative;
  margin: 0 0 var(--space-l);
  view-transition-name: ms-hero;
}
.ms-hero::before {
  content: "";
  position: absolute;
  inset: 8% 12%;
  background: radial-gradient(closest-side, var(--wash-strong), transparent);
  z-index: -1;
}
.ms-hero img { display: block; width: 100%; height: auto; }
.ms-hero figcaption,
.ms-knots figcaption {
  font-size: var(--text-sm);
  color: var(--text-muted);
  text-align: center;
  margin-top: var(--space-2xs);
}

/* ------------------ the proliferation map ------------------ */
.ms-map {
  position: relative;
  aspect-ratio: 1;
  max-width: 640px;
  margin: var(--space-l) auto 0;
  padding: 0;
}
.ms-edges { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.ms-edges path { fill: none; stroke: var(--text-faint); stroke-width: .32; stroke-linecap: round; }
.ms-edges path.tail { stroke-dasharray: .9 1.4; opacity: .7; }
.ms-edges marker path { fill: var(--text-faint); stroke: none; }

.ms-node {
  position: absolute;
  left: var(--x);
  top: var(--y);
  width: 12.5%;
  aspect-ratio: 1;
  translate: -50% -50%;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bg-raised) 80%, transparent);
  box-shadow: inset 0 0 0 var(--hairline) var(--line-strong), var(--shadow-1);
  cursor: pointer;
  transition: scale var(--dur-med) var(--ease-out), box-shadow var(--dur-med) var(--ease-out);
}
.ms-node.seed { width: 16%; box-shadow: inset 0 0 0 1.5px var(--accent-2), var(--shadow-1); }
.ms-node.new { box-shadow: inset 0 0 0 var(--hairline) var(--accent), var(--shadow-1); }
.ms-node img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
  padding: 6%;
}
.ms-node-label {
  position: absolute;
  left: 50%;
  top: 100%;
  translate: -50% 2px;
  font-size: var(--text-sm);
  color: var(--text-muted);
  white-space: nowrap;
  pointer-events: none;
}
.ms-node.label-top .ms-node-label { top: auto; bottom: 100%; translate: -50% -2px; }
.ms-node.seed .ms-node-label { top: 50%; left: 100%; translate: 8px -50%; }
.ms-node:focus-visible { outline-offset: 4px; border-radius: 50%; }
@media (hover: hover) and (pointer: fine) {
  .ms-node:hover { scale: 1.12; box-shadow: inset 0 0 0 1.5px var(--accent), var(--shadow-2); z-index: 1; }
  .ms-node:hover .ms-node-label { color: var(--text); }
}
@media (prefers-reduced-motion: reduce) {
  .ms-node:hover { scale: none; }
}

.ms-edge-label,
.ms-ellipsis {
  position: absolute;
  left: var(--x);
  top: var(--y);
  translate: -50% -50%;
  font-size: var(--text-sm);
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
}
.ms-edge-label.r { color: var(--label); }
.ms-ellipsis { font-size: var(--text-xs); letter-spacing: var(--tracking-wide); color: var(--text-faint); }

@media (max-width: 560px) {
  .ms-node { width: 14%; }
  .ms-node.seed { width: 17%; }
  .ms-node-label { font-size: var(--text-2xs); }
  .ms-edge-label { font-size: var(--text-2xs); }
  .ms-ellipsis { display: none; }
}

/* ------------------ the explorer and the knot panel ------------------ */
.ms-explorer-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3xs) var(--space-s);
  min-height: 2.6rem;
}
.ms-name { display: flex; align-items: baseline; gap: var(--space-xs); font-size: var(--text-lg); }
.ms-name .katex-display { margin: 0; }
.ms-nick { font-size: var(--text-sm); color: var(--text-muted); letter-spacing: var(--tracking-wide); }
.ms-rel { font-size: var(--text-sm); color: var(--text-muted); }
.ms-rel .katex-display { margin: 0; }

.ms-stage {
  position: relative;
  aspect-ratio: 4 / 3;
  margin: var(--space-2xs) calc(-1 * clamp(14px, 3vw, 26px));
  overflow: hidden;
}
.ms-stage > canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: pan-y;
  opacity: 0;
  transition: opacity var(--dur-slow) var(--ease-out);
}
.ms-stage > canvas.grabbing { cursor: grabbing; }
.live .ms-stage > canvas { opacity: 1; }
.ms-stage > canvas:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -4px; }

.ms-fallback {
  position: absolute;
  inset: 0;
  margin: auto;
  width: min(60%, 26rem);
  max-height: 90%;
  height: auto;
  object-fit: contain;
  transition: opacity var(--dur-med) var(--ease-out);
}
.live .ms-fallback { opacity: 0; pointer-events: none; }

.ms-tilt {
  position: absolute;
  left: clamp(14px, 3vw, 26px);
  bottom: var(--space-xs);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3xs);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-med) var(--ease-out);
}
.live .ms-tilt { opacity: 1; pointer-events: auto; }
.ms-tilt canvas {
  width: clamp(84px, 16vw, 124px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 50%;
  box-shadow: 0 0 0 var(--hairline) var(--line-strong), var(--shadow-1);
  cursor: crosshair;
  touch-action: none;
}
.ms-tilt-out {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  background: color-mix(in srgb, var(--bg) 70%, transparent);
  padding: 1px var(--space-3xs);
  border-radius: var(--radius-s);
}

.ms-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: var(--space-xs); }
.ms-chips button {
  font-family: var(--font-body);
  font-size: var(--text-md);
  color: var(--text-muted);
  background: none;
  border: var(--hairline) solid var(--line);
  border-radius: var(--radius-pill);
  min-width: 52px;
  min-height: 40px;
  padding: 0 var(--space-2xs);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.ms-chips button[aria-pressed="true"] { border-color: var(--accent); color: var(--label); background: var(--wash); }
@media (hover: hover) and (pointer: fine) {
  .ms-chips button:hover { border-color: var(--control); color: var(--text); }
}

.ms-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-xs) var(--space-s);
  margin-top: var(--space-s);
}
.ms-controls .btn { min-height: 40px; padding: 6px var(--space-xs); }
.ms-controls .btn[aria-pressed="true"] { border-color: var(--accent); color: var(--label); }
.ms-controls .btn:disabled { opacity: .5; cursor: default; }
.ms-controls .seg button:disabled { opacity: .45; cursor: default; }
.ms-controls .seg button { padding: 0 var(--space-xs); }
.ms-slider {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2xs);
  font-size: var(--text-sm);
  color: var(--text-muted);
}
.ms-slider input { width: clamp(110px, 22vw, 180px); accent-color: var(--accent); }
.ms-slider output { min-width: 2.8em; font-variant-numeric: tabular-nums; color: var(--text); }

.ms-tex { overflow-x: auto; overflow-y: hidden; margin-top: var(--space-xs); font-size: var(--text-md); }
.ms-tex .katex-display { margin: var(--space-2xs) 0 0; text-align: left; }
.ms-tex .katex-display > .katex { text-align: left; }

.ms-knot .ms-stage { aspect-ratio: 16 / 10; }
.ms-knot-out, .ms-counters { margin: var(--space-xs) 0 0; font-size: var(--text-md); color: var(--text-muted); }
.ms-knot-out strong, .ms-counters strong { color: var(--label); font-weight: var(--weight-medium); }
.ms-counters:empty { display: none; }

@media (max-width: 560px) {
  .ms-stage { aspect-ratio: 1; }
  .ms-knot .ms-stage { aspect-ratio: 1; }
}

/* without WebGL the explorers show their pictures and nothing to press */
.ms-static .ms-controls,
.ms-static .ms-chips,
.ms-static .ms-explorer-head .ms-rel,
.ms-static .ms-knot-out,
.ms-static .ms-explorer + .instrument-caption { display: none; }

/* ------------------ knot diagrams ------------------ */
.ms-knots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-s);
  margin: var(--space-l) 0;
}
.ms-knot-svg {
  display: block;
  aspect-ratio: 1;
  background: var(--bg);
  border-radius: var(--radius-l);
  box-shadow: inset 0 0 0 var(--hairline) var(--line);
  padding: 8%;
}
.ms-knot-svg svg { display: block; width: 100%; height: 100%; overflow: visible; }
.ms-knot-svg .k { fill: none; stroke: var(--accent); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.ms-knot-svg .h { fill: none; stroke: var(--bg); stroke-width: 13; }
.ms-knot-svg circle { fill: var(--text-strong); }
@media (max-width: 560px) {
  .ms-knots { gap: var(--space-2xs); }
  .ms-knots figcaption { font-size: var(--text-xs); }
}
