/* Interactive tools: Rechnen im Kreis, Caesar & Vigenère, Diffie-Hellman */

/* Shared controls */

.wz {
  margin: 1rem 0 2rem;
}

.wz p {
  margin: 0.5rem 0;
}

.wz-zeile {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
  margin: 0.8rem 0;
}

.wz .wz-titel {
  font-weight: bold;
}

.wz-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.wz button {
  padding: 0.3rem 0.9rem;
  border: 1px solid var(--global-theme-color);
  border-radius: 6px;
  background: transparent;
  color: var(--global-theme-color);
  font: inherit;
  cursor: pointer;
}

.wz button:hover,
.wz button.wz-haupt {
  background: var(--global-theme-color);
  color: var(--global-hover-text-color);
}

.wz button:disabled {
  opacity: 0.4;
  cursor: default;
}

.wz .wz-chip {
  padding: 0.25rem 0.8rem;
  border-color: var(--global-divider-color);
  border-radius: 999px;
  color: var(--global-text-color);
}

.wz .wz-chip:hover {
  border-color: var(--global-theme-color);
  background: transparent;
  color: var(--global-text-color);
}

.wz .wz-chip[aria-pressed="true"] {
  border-color: var(--global-theme-color);
  background: var(--global-theme-color);
  color: var(--global-hover-text-color);
}

.wz input[type="number"],
.wz input[type="text"],
.wz textarea {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 4px;
  background: var(--global-bg-color);
  color: var(--global-text-color);
  font: inherit;
}

.wz input[type="number"] {
  width: 5.5em;
}

.wz textarea {
  box-sizing: border-box;
  width: 100%;
}

.wz input[type="range"] {
  vertical-align: middle;
  accent-color: var(--global-theme-color);
}

.wz-mono,
.wz textarea.wz-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  letter-spacing: 0.04em;
}

.wz .wz-klein {
  color: var(--global-text-color-light);
  font-size: 0.85rem;
}

.wz .wz-ergebnis {
  font-size: 1.15rem;
  font-weight: bold;
}

.wz-kasten {
  margin: 1rem 0;
  padding: 0.6rem 1rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 8px;
}

.wz .wz-richtig {
  color: #2e7d32;
}

.wz .wz-falsch {
  color: #c8602a;
}

/* Rechnen im Kreis */

.mod-kreis {
  display: block;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  touch-action: manipulation;
}

.mod-kreis text {
  fill: var(--global-text-color);
  font-family: inherit;
  text-anchor: middle;
  dominant-baseline: central;
}

.mod-platz circle {
  fill: var(--global-bg-color);
  stroke: var(--global-divider-color);
  stroke-width: 0.6;
}

.mod-platz {
  cursor: pointer;
}

.mod-platz.mod-start circle {
  fill: #1b7f86;
  stroke: #1b7f86;
}

.mod-platz.mod-ziel circle {
  fill: #c8602a;
  stroke: #c8602a;
}

.mod-platz.mod-sprung circle {
  stroke: #c8602a;
  stroke-width: 1.2;
}

.mod-platz.mod-start text,
.mod-platz.mod-ziel text {
  fill: #fff;
  font-weight: bold;
}

.mod-kreis .mod-weg {
  fill: none;
  stroke: var(--global-theme-color);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.8;
}

.mod-kreis .mod-anlauf {
  fill: none;
  stroke: #1b7f86;
  stroke-width: 1;
  stroke-dasharray: 2 2;
}

.mod-kreis .mod-figur {
  fill: var(--global-theme-color);
}

.mod-kreis .mod-mitte {
  font-weight: bold;
}

/* Caesar & Vigenère: disc in the colours of the paper Caesar-Scheibe, which
   stays light in dark mode like the paper one */

.cv-scheibe {
  display: block;
  width: 100%;
  max-width: 340px;
  margin: 0.5rem auto;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.cv-scheibe.cv-ziehen {
  cursor: grabbing;
}

.cv-scheibe:focus-visible {
  border-radius: 50%;
  outline: 2px solid var(--global-theme-color);
}

.cv-scheibe text {
  font-family: inherit;
  font-weight: bold;
  text-anchor: middle;
  dominant-baseline: central;
}

.cv-aussen {
  fill: #e3e9f2;
  stroke: #1f3a5f;
  stroke-width: 0.6;
}

.cv-aussen-text {
  fill: #1f3a5f;
  font-size: 13px;
}

.cv-innen {
  fill: #f8e6dc;
  stroke: #c8602a;
  stroke-width: 0.6;
}

.cv-innen-text {
  fill: #c8602a;
  font-size: 12px;
}

.cv-markierung {
  fill: #f5e86e;
  opacity: 0.7;
}

.cv-mitte {
  fill: #fffdf6;
  stroke: #1f3a5f;
  stroke-width: 0.8;
}

.cv-scheibe .cv-mitte-schluessel {
  fill: #c8602a;
  font-size: 30px;
}

.cv-scheibe .cv-mitte-text {
  fill: #1f3a5f;
  font-size: 10px;
  font-weight: normal;
}

.cv-drehen {
  transition: transform 0.25s ease;
}

.cv-ziehen .cv-drehen {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .cv-drehen {
    transition: none;
  }
}

/* the disc beside its controls, below them on a phone */
.cs {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr);
  gap: 0.5rem 1.5rem;
  align-items: center;
}

.cs .cv-scheibe {
  margin: 0 auto;
}

@media (max-width: 640px) {
  .cs {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* only with a mouse or touchpad, which suggests a keyboard */
.cs-tastatur {
  display: none;
}

@media (hover: hover) and (pointer: fine) {
  .cs-tastatur {
    display: block;
  }
}

.cv-ergebnis {
  min-height: 1.6em;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  background: var(--global-code-bg-color);
  font-size: 1.1rem;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* input and result side by side and equally tall, stacked on a phone */
.cv-texte {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin: 0.75rem 0;
}

.cv-texte > div {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.cv-texte textarea,
.cv-texte .cv-ergebnis {
  flex: 1;
  min-height: 6.5em;
}

.cv-texte .cv-ergebnis {
  padding: 0.2rem 0.4rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 4px;
  font-size: inherit;
  letter-spacing: 0.04em;
}

@media (max-width: 640px) {
  .cv-texte {
    grid-template-columns: minmax(0, 1fr);
  }
}

.cv-karten {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 0.3rem;
  margin: 0.8rem 0;
}

.cv-karte {
  display: grid;
  justify-items: center;
  gap: 0.15rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-weight: bold;
}

.cv-kw {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  border-radius: 50%;
  background: var(--team);
  color: #fff;
  font-size: 0.8rem;
}

.cv-ein,
.cv-aus {
  display: grid;
  width: 1.9rem;
  height: 1.9rem;
  place-items: center;
  border: 1px solid var(--global-text-color-light);
  border-radius: 3px;
}

.cv-aus {
  border-color: var(--team);
  color: var(--team);
}

.cv-plus {
  color: var(--team);
  font-size: 0.75rem;
}

.cv-luecke {
  width: 0.6rem;
}

/* Code breaker */

.ck-alle {
  max-height: 15rem;
  overflow-y: auto;
  border: 1px solid var(--global-divider-color);
  border-radius: 6px;
  font-size: 0.9rem;
}

.ck-zeile {
  display: flex;
  gap: 0.8rem;
  padding: 0.1rem 0.5rem;
  white-space: nowrap;
}

.ck-zeile:nth-child(odd) {
  background: var(--global-code-bg-color);
}

.ck-k {
  flex: none;
  width: 6.5rem;
  color: var(--global-text-color-light);
  font-family: inherit;
}

.ck-diagramm {
  max-width: 560px;
  margin: 0.4rem 0 0.8rem;
}

.ck-balken,
.ck-namen {
  display: grid;
  grid-template-columns: repeat(26, 1fr);
  gap: 2px;
}

/* Labels hang above the bars, out of the flow, so they take no height from
   them; the padding leaves room for a label above the tallest bar. */
.ck-balken {
  box-sizing: content-box;
  height: 90px;
  padding-top: 1.1rem;
}

.ck-saeule {
  position: relative;
}

.wz .ck-balken-wert {
  display: block;
  position: absolute;
  bottom: 0;
  width: 100%;
  height: var(--hoehe);
  min-height: 1px;
  padding: 0;
  border: 0;
  border-radius: 2px 2px 0 0;
  background: var(--farbe);
  opacity: 0.4;
}

.wz button.ck-balken-wert:hover {
  background: var(--farbe);
  opacity: 0.7;
}

.wz .ck-balken-wert.ck-markiert {
  opacity: 1;
}

.ck-marke,
.ck-anzahl {
  position: absolute;
  bottom: calc(var(--hoehe) + 2px);
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-weight: bold;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

/* at the ends of the chart, labels must not stick out of it */
.ck-links :is(.ck-marke, .ck-anzahl) {
  left: 0;
  transform: none;
}

.ck-rechts :is(.ck-marke, .ck-anzahl) {
  right: 0;
  left: auto;
  transform: none;
}

.ck-marke {
  color: #c8602a;
}

.ck-anzahl {
  display: none;
  z-index: 1;
  padding: 0 0.3rem;
  border-radius: 3px;
  background: var(--global-text-color);
  color: var(--global-bg-color);
}

.ck-saeule:hover .ck-anzahl,
.ck-saeule:focus-within .ck-anzahl {
  display: block;
}

.ck-namen span {
  font-size: 0.7rem;
  text-align: center;
}

.ck-namen .ck-markiert {
  font-weight: bold;
}

.ck-verteilung {
  overflow-wrap: anywhere;
  font-weight: bold;
}

/* Diffie-Hellman: public in teal, secret in magenta, as on the slides */

.dh {
  --dh-offen: #1b7f86;
  --dh-geheim: #c2185b;
}

html[data-theme="dark"] .dh {
  --dh-offen: #4fc3c9;
  --dh-geheim: #f06292;
}

/* a step not reached yet: invisible, but taking its space */
.dh .dh-spaeter {
  visibility: hidden;
}

.dh input[type="number"] {
  box-sizing: border-box;
  max-width: 100%;
}

.dh-oben {
  justify-content: flex-end;
}

/* one layer per step, one below the other */
.dh-schicht {
  margin-bottom: 0.5rem;
  scroll-margin-top: 4.5rem; /* below the fixed navbar */
  scroll-margin-bottom: 4rem; /* above the fixed footer */
}

.dh-schicht h3 {
  display: flex;
  gap: 0.6rem;
  align-items: baseline;
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
  line-height: 1.45;
}

.dh-schicht h3:focus {
  outline: none;
}

.dh-nr {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 1.7em;
  height: 1.7em;
  border-radius: 50%;
  background: var(--global-theme-color);
  color: #fff;
  font-size: 0.9em;
  font-weight: bold;
}

.wz .dh-begriff,
.wz .dh-begriff:hover {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-decoration: underline dotted;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.dh-erklaerung {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.8rem;
  border-radius: 6px;
  background: var(--global-code-bg-color);
  font-size: 0.95rem;
}

.dh-erklaerung p:last-child {
  margin-bottom: 0;
}

.dh-karte {
  min-width: 0;
  padding: 0.6rem 0.9rem;
  border: 1px solid var(--global-divider-color);
  border-radius: 8px;
  overflow-wrap: anywhere;
}

.dh-karte p:last-child {
  margin-bottom: 0;
}

.dh-oeffentlich {
  border-color: var(--dh-offen);
}

/* Alia left, Ben right; one below the other on a phone */
.dh-paar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

@media (max-width: 640px) {
  .dh-paar {
    grid-template-columns: minmax(0, 1fr);
  }
}

.dh-mitte {
  margin: 0.75rem 0;
  text-align: center;
}

.dh-weiter {
  margin: 1rem 0 0;
  text-align: center;
}

.dh-wie summary {
  cursor: pointer;
}

.dh .dh-offen {
  color: var(--dh-offen);
}

.dh .dh-geheim {
  color: var(--dh-geheim);
}

.dh .wz-ergebnis .dh-geheim {
  font-size: 1.5rem;
}

.dh-versuche {
  max-height: 12rem;
  overflow-y: auto;
  font-size: 0.9rem;
}

.dh-neu {
  animation: dh-auftauchen 0.5s ease;
}

@keyframes dh-auftauchen {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dh-neu {
    animation: none;
  }
}
