/* A small, opt-in mathematical Easter egg. */
.twist-footer {
  position: relative;
  z-index: 101;
  padding: 0 max(12px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) 12px;
  text-align: right;
}
#twist-toggle {
  position: relative;
  min-width: 32px;
  min-height: 28px;
  padding: 6px;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  opacity: 0.16;
  font: 12px / 1 Georgia, "Times New Roman", serif;
  cursor: pointer;
  transition: opacity 160ms ease;
}
#twist-toggle:hover { opacity: 0.75; }
#twist-toggle:focus-visible {
  opacity: 1;
  outline: 1px solid currentColor;
  outline-offset: 2px;
}
body.twist-text-active #twist-toggle { opacity: 0.65; }
body.twist-neon #twist-toggle { color: #dcefff; opacity: 0.55; }
body.twist-truck #twist-toggle {
  opacity: 0.95;
  color: #345d76;
  background: rgb(217 232 239 / 70%);
  box-shadow: 0 0 0 1px rgb(52 93 118 / 30%), 0 0 14px rgb(114 171 203 / 22%);
}
body.twist-rescue #twist-toggle {
  visibility: hidden;
  pointer-events: none;
}
.truck-controls {
  position: fixed;
  z-index: 102;
  top: max(20px, env(safe-area-inset-top));
  left: 20px;
  max-width: calc(100vw - 40px);
  color: #4b6472;
  font: 13px / 1.5 var(--sans);
}
.truck-hint { margin: 0 0 8px; }
.truck-buttons { display: flex; flex-wrap: wrap; gap: 6px; }
.truck-buttons button {
  min-width: 54px;
  min-height: 38px;
  padding: 6px 12px;
  color: #345d76;
  background: rgb(245 247 246 / 80%);
  border: 1px solid rgb(52 93 118 / 25%);
  border-radius: 6px;
  font: inherit;
  touch-action: none;
  user-select: none;
  cursor: pointer;
}
.truck-buttons button:active,
.truck-buttons button[aria-pressed="true"] { background: #cddfe8; }
.truck-buttons button:focus-visible { outline: 2px solid #567e96; outline-offset: 2px; }
.truck-feedback { display: block; min-height: 1.5em; margin: 8px 0 0; }
#twist-status {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
#twist-canvas {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
body.twist-text-active #twist-canvas { display: block; }
body.twist-text-active header.page,
body.twist-text-active main.page { visibility: hidden; }

@media (prefers-reduced-motion: reduce) {
  #twist-toggle { transition: none; }
}

/* Original fixed neon background from commit 1674ed5.
   Intended for insertion in the page's inline stylesheet: image URLs are
   relative to seminars/intrinsic-moduli-theory/index.html. */
#twist-background {
  display: none;
}

body.twist-neon {
  background: #000;
  position: relative;
  isolation: isolate;
}

body.twist-neon::before {
  content: "";
  position: fixed;
  inset-block: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 1000px);
  background: var(--paper);
  box-shadow: 0 0 55px rgba(0, 0, 0, 0.65);
  z-index: -1;
  pointer-events: none;
}

body.twist-neon #twist-background {
  display: block;
  --gutter: max(0px, calc((100vw - 1000px) / 2));
  --stack-size: clamp(900px, 72vw, 1400px);
  --filt-size: clamp(1150px, 85vw, 1700px);
  --chain-size: clamp(1300px, 96vw, 1800px);
  position: fixed;
  inset: 0;
  overflow: hidden;
  z-index: -2;
  pointer-events: none;
  user-select: none;
  background: #000;
}

#twist-background .background-diagram {
  position: absolute;
  background-repeat: no-repeat;
  mix-blend-mode: screen;
  filter: contrast(1.14) brightness(0.9);
  opacity: 0.86;
}

#twist-background .background-theta,
#twist-background .background-s {
  width: var(--stack-size);
  aspect-ratio: 971 / 809;
  top: calc(34vh - var(--stack-size) * 0.443);
  background-image: url('test-stacks-neon-v2.png');
  background-size: 200% 100%;
}

#twist-background .background-theta {
  left: calc(var(--gutter) / 2 - var(--stack-size) / 2);
  background-position: left center;
}

#twist-background .background-s {
  right: calc(var(--gutter) / 2 - var(--stack-size) / 2);
  background-position: right center;
}

#twist-background .background-filt {
  width: var(--filt-size);
  aspect-ratio: 1842 / 854;
  left: calc(var(--gutter) / 2 - var(--filt-size) * 0.396);
  top: calc(76vh - var(--filt-size) * 0.218);
  background: url('filtration-neon.png') center / 100% 100% no-repeat;
}

#twist-background .background-chain {
  width: var(--chain-size);
  aspect-ratio: 1816 / 865;
  right: calc(var(--gutter) / 2 - var(--chain-size) * 0.2);
  top: calc(76vh - var(--chain-size) * 0.316);
  background: url('exceptional-chain-neon-v2.png') center / 100% 100% no-repeat;
}

@media (max-width: 1000px) {
  body.twist-neon #twist-background { display: none; }
}

@media print {
  body.twist-neon { background: var(--paper); }
  body.twist-neon::before,
  #twist-background { display: none; }
}

@media print {
  .twist-footer, #twist-toggle, #twist-canvas, #twist-status, #twist-background, .truck-controls { display: none !important; }
  body.twist-text-active header.page, body.twist-text-active main.page { visibility: visible; }
}
