/* Einthemige dunkle Gestaltung: die Simulation braucht einen schwarzen Grund,
   der Rest der Seite liest sich als Konsole einer Sternwarte. */

:root {
  color-scheme: dark;

  --void:      #04050a;
  --ground:    #07080f;
  --panel:     #0c0f18;
  --panel-hi:  #121725;
  --rule:      #1b2130;
  --text:      #dfe4ee;
  --muted:     #7d8799;
  --ember:     #ff8a3d;
  --ember-dim: #7d3f1a;
  --cold:      #6ba8ff;

  --font-display: "Fraunces", "Iowan Old Style", Georgia, serif;
  --font-body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --gutter: clamp(1rem, 4vw, 3rem);
}

*, *::before, *::after { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--void);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--ember);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

.label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Kopfzeile -------------------------------------------------------- */

.masthead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.5rem;
  padding-inline: var(--gutter);
  padding-block: 1.4rem 1.1rem;
  border-bottom: 1px solid var(--rule);
}

.masthead h1 {
  font-family: var(--font-display);
  font-optical-sizing: auto;
  font-weight: 500;
  font-size: clamp(1.4rem, 3.2vw, 2rem);
  line-height: 1.1;
  margin: 0;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

.masthead p {
  margin: 0;
  max-width: 46ch;
  color: var(--muted);
  font-size: 0.9rem;
}

.masthead .label { margin-inline-start: auto; }

/* ---- Bühne ------------------------------------------------------------ */

.stage {
  position: relative;
  height: clamp(24rem, 76vh, 54rem);
  background: #000;
  overflow: hidden;
  touch-action: none;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}

.stage canvas:active { cursor: grabbing; }

.notice {
  position: absolute;
  inset-inline: var(--gutter);
  top: var(--gutter);
  z-index: 5;
  padding: 0.9rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--ember-dim);
  color: var(--text);
  font-size: 0.9rem;
  max-width: 52ch;
}

.hint {
  position: absolute;
  bottom: 0.9rem;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 0.3rem 0.8rem;
  background: rgba(4, 5, 10, 0.7);
  border: 1px solid var(--rule);
  white-space: nowrap;
  pointer-events: none;
}

/* ---- Bedienfeld ------------------------------------------------------- */

.panel-toggle {
  position: absolute;
  top: 1rem;
  left: 1rem;
  z-index: 4;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text);
  background: rgba(12, 15, 24, 0.82);
  border: 1px solid var(--rule);
  padding: 0.5rem 0.85rem;
  cursor: pointer;
  backdrop-filter: blur(8px);
}

.panel-toggle:hover { border-color: var(--ember-dim); }

.panel {
  position: absolute;
  top: 3.9rem;
  left: 1rem;
  bottom: 1rem;
  z-index: 3;
  width: min(19rem, calc(100% - 2rem));
  display: none;
  flex-direction: column;
  gap: 1.1rem;
  padding: 1.1rem 1.15rem 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(12, 15, 24, 0.86);
  border: 1px solid var(--rule);
  backdrop-filter: blur(14px);
}

.panel.is-open { display: flex; }

.panel fieldset {
  margin: 0;
  padding: 0;
  border: 0;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.panel legend {
  padding: 0 0 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ember);
}

.field { display: grid; gap: 0.3rem; }

.field__head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
  font-size: 0.82rem;
}

.field__head output {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 1rem;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--rule);
}

input[type="range"]::-moz-range-track {
  height: 2px;
  background: var(--rule);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 13px;
  height: 13px;
  margin-top: -5.5px;
  border-radius: 50%;
  background: var(--ember);
  border: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--ember);
  border: 0;
}

.switch {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
}

.switch input {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 2.1rem;
  height: 1.05rem;
  margin: 0;
  background: var(--panel-hi);
  border: 1px solid var(--rule);
  position: relative;
  cursor: pointer;
}

.switch input::after {
  content: "";
  position: absolute;
  top: 1px;
  left: 1px;
  width: calc(1.05rem - 4px);
  height: calc(1.05rem - 4px);
  background: var(--muted);
  transition: transform 0.15s ease, background 0.15s ease;
}

.switch input:checked { border-color: var(--ember-dim); }
.switch input:checked::after {
  background: var(--ember);
  transform: translateX(1.05rem);
}

.switch input:disabled { opacity: 0.4; cursor: not-allowed; }
.switch:has(input:disabled) { color: var(--muted); cursor: not-allowed; }

.panel__note {
  margin: 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.45;
}

select {
  width: 100%;
  font: inherit;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--panel-hi);
  border: 1px solid var(--rule);
  padding: 0.35rem 0.5rem;
}

.panel__actions { display: flex; gap: 0.5rem; }

.btn {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  background: var(--panel-hi);
  border: 1px solid var(--rule);
  padding: 0.5rem 0.4rem;
  cursor: pointer;
}

.btn:hover { border-color: var(--ember-dim); color: var(--ember); }

/* ---- Telemetrie ------------------------------------------------------- */

.telemetry {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 3;
  margin: 0;
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.18rem 0.9rem;
  padding: 0.8rem 0.95rem;
  background: rgba(4, 5, 10, 0.62);
  border: 1px solid var(--rule);
  backdrop-filter: blur(8px);
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
}

.telemetry dt { color: var(--muted); letter-spacing: 0.06em; }
.telemetry dd { margin: 0; text-align: right; }
.telemetry .u { color: var(--muted); }

/* ---- Fliesstext ------------------------------------------------------- */

.doc {
  padding-inline: var(--gutter);
  padding-block: clamp(2.5rem, 7vw, 4.5rem);
  max-width: 74ch;
  margin-inline: auto;
}

.doc > * + * { margin-top: 1.1rem; }

.doc section > * + * { margin-top: 1.1rem; }

.doc section { margin-top: clamp(2.5rem, 6vw, 4rem); }

.doc h2 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.3rem, 2.8vw, 1.75rem);
  line-height: 1.2;
  margin: 0 0 0.2rem;
  text-wrap: balance;
}

.doc h3 {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 1rem;
  margin: 1.8rem 0 0.3rem;
}

.doc p { margin: 0; }

.doc .lede {
  font-size: 1.05rem;
  color: var(--text);
}

.doc .aside {
  border-left: 2px solid var(--ember-dim);
  padding-left: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.doc .aside b { color: var(--text); font-weight: 600; }

code, .mono { font-family: var(--font-mono); font-size: 0.88em; }

.figure {
  margin: 2rem 0 0;
  padding: 1.2rem 0 0;
  border-top: 1px solid var(--rule);
}

.figure svg { display: block; width: 100%; height: auto; max-width: 100%; }

.figure figcaption {
  margin-top: 0.8rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.radii {
  margin: 1.2rem 0 0;
  display: grid;
  gap: 0.55rem 1.1rem;
  grid-template-columns: max-content 1fr;
  font-size: 0.92rem;
}

.radii dt {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--ember);
  padding-top: 0.15rem;
  white-space: nowrap;
}

.radii dd { margin: 0; color: var(--muted); }
.radii dd b { color: var(--text); font-weight: 600; }

.limits {
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.8rem;
}

.limits li {
  padding-left: 1.1rem;
  position: relative;
  color: var(--muted);
  font-size: 0.95rem;
}

.limits li::before {
  content: "–";
  position: absolute;
  left: 0;
  color: var(--ember-dim);
}

.limits b { color: var(--text); font-weight: 600; }

.keys {
  margin: 1rem 0 0;
  display: grid;
  gap: 0.4rem 1rem;
  grid-template-columns: max-content 1fr;
  font-size: 0.92rem;
}

.keys dt {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text);
  border: 1px solid var(--rule);
  padding: 0.05rem 0.45rem;
  justify-self: start;
}

.keys dd { margin: 0; color: var(--muted); }

.colophon {
  border-top: 1px solid var(--rule);
  padding-inline: var(--gutter);
  padding-block: 1.6rem 2.4rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.colophon p { margin: 0; max-width: 74ch; margin-inline: auto; }
.colophon .colophon__legal { margin-top: 0.9rem; font-family: var(--font-mono); font-size: 0.74rem; letter-spacing: 0.04em; }
.colophon__legal a { color: var(--muted); text-decoration: none; border-bottom: 1px solid var(--rule); }
.colophon__legal a:hover { color: var(--text); border-bottom-color: var(--ember-dim); }

/* ---- Schmale Schirme -------------------------------------------------- */

@media (max-width: 860px) {
  .panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 62%;
    border-inline: 0;
    border-bottom: 0;
  }
  .telemetry {
    grid-template-columns: auto auto;
    font-size: 0.62rem;
    padding: 0.55rem 0.65rem;
  }
  .hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .switch input::after { transition: none; }
}
