/* The Gaussian sweep: styles for <div class="sw"> (see README.md).
 * The colours are those of the companion site's dark theme. The stage stays dark on a light
 * page too, like a video. sweep.js sets --sw-s, a scale for the text that follows the size of
 * the stage, and the classes sw--wide (a landscape stage), is-playing and is-idle. */
.sw {
  --sw-bg: #0d121a;
  --sw-text: #e9e6df;
  --sw-muted: #b9b4aa;
  --sw-primary: #e0a83c;
  --sw-link: #f2be5c;
  --sw-s: 1;
  position: relative;
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: calc(100vh - 4rem);
  max-height: calc(100svh - 4rem);
  overflow: hidden;
  isolation: isolate;
  background: var(--sw-bg);
  color: var(--sw-text);
  border-radius: 6px;
  line-height: 1.45;
  text-align: left;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  outline: none;
}
.sw:focus-visible { outline: 2px solid var(--sw-primary); outline-offset: 3px; }
@media (max-width: 759.98px) { .sw { aspect-ratio: 4 / 5; } }
@media (max-width: 480px) { .sw { aspect-ratio: 9 / 16; } }
.sw:fullscreen { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; }
.sw:-webkit-full-screen { width: 100%; height: 100%; max-height: none; aspect-ratio: auto; border-radius: 0; }

.sw .sw-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.sw p { margin: 0; }

/* the chapter, top left */
.sw .sw-kicker {
  position: absolute;
  z-index: 2;
  font-size: max(10.5px, calc(11px * var(--sw-s)));
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--sw-muted);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
}
.sw .sw-kicker b { color: var(--sw-primary); font-weight: 700; margin-right: 0.6em; letter-spacing: 0.08em; }

/* the title card */
.sw .sw-title {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5% 7%;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
}
.sw .sw-title__box {
  max-width: 33em;
  padding: 1.6em 2em;
  text-align: center;
  background: radial-gradient(closest-side, rgba(7, 10, 15, 0.78), rgba(7, 10, 15, 0.5) 60%, rgba(7, 10, 15, 0));
}
.sw .sw-title__kicker {
  font-size: max(11px, calc(12.5px * var(--sw-s)));
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--sw-primary);
}
.sw .sw-title__head {
  margin-top: 0.3em;
  font-size: max(30px, calc(48px * var(--sw-s)));
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
  color: #f6f2ea;
  text-shadow: 0 2px 30px rgba(0, 0, 0, 0.7);
}
.sw:not(.sw--wide) .sw-title__head { font-size: max(28px, calc(40px * var(--sw-s))); }
.sw:not(.sw--wide) .sw-title__box { padding: 1.2em 0.6em; }
.sw .sw-title__body {
  margin-top: 0.75em;
  font-size: max(14px, calc(17.5px * var(--sw-s)));
  line-height: 1.5;
  color: var(--sw-text);
  text-wrap: balance;
}
.sw .sw-title__note { margin-top: 1em; font-size: max(12px, calc(13.5px * var(--sw-s))); color: var(--sw-muted); }

/* the captions: one at a time, at the bottom of the column that sweep.js places */
.sw .sw-caps { position: absolute; z-index: 2; pointer-events: none; }
.sw .sw-cap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  visibility: hidden;
  opacity: 0;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.sw .sw-cap__head {
  margin-bottom: 0.4em;
  font-size: max(15px, calc(19px * var(--sw-s)));
  font-weight: 700;
  line-height: 1.25;
  color: #f6f2ea;
  text-wrap: balance;
}
.sw .sw-cap__body {
  font-size: max(13px, calc(15px * var(--sw-s)));
  line-height: 1.5;
  color: #d8d3c9;
  text-wrap: pretty;
}
/* the theorem at the end, in the style of the site's statements */
.sw .sw-cap--end { pointer-events: auto; }
.sw .sw-cap--end .sw-cap__head { font-size: max(14px, calc(16px * var(--sw-s))); font-weight: 400; color: var(--sw-text); }
.sw .sw-cap--end .sw-cap__head b { color: #f6f2ea; }
.sw .sw-cap--end .sw-cap__body {
  padding: 0.55em 0.85em;
  border-left: 3px solid var(--sw-primary);
  border-radius: 0 4px 4px 0;
  background: rgba(127, 127, 127, 0.1);
  color: var(--sw-text);
}
.sw .sw-cap__note { margin-top: 0.6em; font-size: max(12px, calc(13px * var(--sw-s))); color: var(--sw-muted); }
.sw .sw-cap__actions { display: flex; flex-wrap: wrap; gap: 0.6em; margin-top: 0.9em; }
.sw .sw-act {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  padding: 0.6em 1.05em;
  border: 1px solid var(--sw-primary);
  border-radius: 999px;
  background: var(--sw-primary);
  color: #181c23;
  font: inherit;
  font-size: max(13px, calc(14px * var(--sw-s)));
  font-weight: 700;
  line-height: 1;
  text-decoration: none;
  text-shadow: none;
  cursor: pointer;
}
.sw .sw-act:hover, .sw .sw-act:focus-visible { background: var(--sw-link); border-color: var(--sw-link); color: #181c23; }
.sw .sw-act:focus-visible { outline: 2px solid var(--sw-text); outline-offset: 2px; }
.sw .sw-act--ghost { background: rgba(13, 18, 26, 0.5); border-color: rgba(233, 230, 223, 0.4); color: var(--sw-text); }
.sw .sw-act--ghost:hover, .sw .sw-act--ghost:focus-visible { background: rgba(233, 230, 223, 0.12); border-color: rgba(233, 230, 223, 0.7); color: #fff; }
.sw .sw-act svg { width: 1.1em; height: 1.1em; flex: none; }

/* formulas: MathJax typesets them when the page loads it; until then, and without it, this */
.sw .sw-m { font-family: "STIX Two Math", "Cambria Math", "Latin Modern Math", "Times New Roman", serif; font-size: 1.06em; white-space: nowrap; }
.sw .sw-m sub, .sw .sw-m sup { font-size: 0.72em; line-height: 0; }
.sw mjx-container { color: inherit; }

/* the controls */
.sw .sw-ctrl {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 10px 0 6px;
  background: linear-gradient(to top, rgba(6, 8, 12, 0.8), rgba(6, 8, 12, 0));
  color: var(--sw-text);
  font-size: 12px;
  line-height: 1;
  transition: opacity 0.4s ease;
}
.sw.is-idle .sw-ctrl { opacity: 0; }
.sw.is-idle { cursor: none; }
.sw .sw-btn {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.sw .sw-btn:hover { background: rgba(255, 255, 255, 0.1); }
.sw .sw-btn:focus-visible { outline: 2px solid var(--sw-primary); outline-offset: 0; }
.sw .sw-btn[hidden] { display: none; }
.sw .sw-btn svg { width: 20px; height: 20px; }
.sw .sw-chap { flex: none; min-width: 7.6em; color: var(--sw-muted); white-space: nowrap; }
.sw:not(.sw--wide) .sw-chap { display: none; }
.sw .sw-bar { position: relative; flex: 1; height: 28px; cursor: pointer; touch-action: none; outline: none; }
.sw .sw-bar__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  margin-top: -1.5px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(233, 230, 223, 0.22);
  transition: height 0.15s, margin-top 0.15s;
}
.sw .sw-bar:hover .sw-bar__track, .sw .sw-bar:focus-visible .sw-bar__track { height: 5px; margin-top: -2.5px; }
.sw .sw-bar:focus-visible { outline: 2px solid var(--sw-primary); outline-offset: 2px; border-radius: 3px; }
.sw .sw-bar__fill { width: 0; height: 100%; background: var(--sw-primary); }
.sw .sw-bar__tick {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  margin: -8px 0 0 -8px;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}
.sw .sw-bar__tick::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 4px;
  width: 2px;
  height: 8px;
  border-radius: 1px;
  background: rgba(233, 230, 223, 0.6);
}
.sw .sw-bar__tick:first-of-type::after { display: none; }
.sw .sw-time { flex: none; color: var(--sw-muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
/* the switch between the 2D and the 3D view */
.sw .sw-view { flex: none; display: inline-flex; padding: 2px; border-radius: 999px; background: rgba(233, 230, 223, 0.12); }
.sw .sw-view[hidden] { display: none; }
.sw .sw-view__btn {
  min-width: 28px;
  height: 22px;
  padding: 0 7px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--sw-muted);
  font: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  cursor: pointer;
}
.sw .sw-view__btn:hover { color: var(--sw-text); }
.sw .sw-view__btn[aria-pressed="true"] { background: var(--sw-primary); color: #181c23; }
.sw .sw-view__btn:focus-visible { outline: 2px solid var(--sw-primary); outline-offset: 1px; }

/* the play button over the still, when the animation does not start by itself */
.sw .sw-bigplay {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 5;
  transform: translate(-50%, -50%);
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.8em 1.4em 0.8em 1.1em;
  border: 1px solid rgba(224, 168, 60, 0.65);
  border-radius: 999px;
  background: rgba(13, 18, 26, 0.78);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 34px rgba(0, 0, 0, 0.55);
  color: var(--sw-text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}
.sw .sw-bigplay:hover, .sw .sw-bigplay:focus-visible { border-color: var(--sw-primary); background: rgba(24, 28, 35, 0.9); }
.sw .sw-bigplay svg { width: 26px; height: 26px; color: var(--sw-primary); }
.sw .sw-bigplay[hidden] { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sw .sw-ctrl, .sw .sw-bar__track { transition: none; }
}
@media print {
  .sw .sw-ctrl, .sw .sw-bigplay { display: none; }
}
