/* Prime Torus – dunkle 3D-Szene (übernommen und behutsam angepasst) */

:root {
  --inner-diameter: min(50vmin, 400px);
  --inner-radian: calc(var(--inner-diameter) / 2);
  --circle-diameter: calc(var(--inner-diameter) * 0.45);
  --circle-radian: calc(var(--circle-diameter) / 2);
  --circle-count: 30;
  --circle-rotate: calc(360deg / var(--circle-count));
  --scene-size: calc(var(--inner-diameter) + var(--circle-diameter) * 1.5);
  --bg-color: #07060e;
  --fg-color: #0ff;
}

* {
  box-sizing: border-box;
}

body {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  margin: 0;
  overflow: hidden;
  background: radial-gradient(ellipse at center, #14102a 0%, var(--bg-color) 75%);
  color: var(--fg-color);
  font-family: "Segoe UI", system-ui, sans-serif;
  padding: 12px;
  user-select: none;
  -webkit-user-select: none;
}

header {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative;
  z-index: 20;
}

.header-top {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: rgba(13, 11, 30, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 255, 255, 0.14);
  border-radius: 12px;
  padding: 8px 14px;
}

.lang-btn {
  margin-left: auto;
  font-weight: 700;
  letter-spacing: 0.05em;
  min-width: 46px;
}

.info-btn {
  font-size: 1rem;
  min-width: 38px;
}

h1 {
  margin: 0;
  font-size: 1.4rem;
  color: #8cf;
}

.back-link {
  color: #8cf;
  text-decoration: none;
  border: 1px solid #334;
  border-radius: 8px;
  padding: 7px 13px;
  background: rgba(20, 16, 42, 0.8);
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.back-link:hover {
  background: rgba(102, 126, 234, 0.3);
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  background: rgba(13, 11, 30, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 255, 255, 0.14);
  border-radius: 12px;
  padding: 8px 14px;
}

label {
  display: flex;
  gap: 6px;
  align-items: center;
  color: #cce;
  font-size: 0.9rem;
}

input[type="number"] {
  width: 84px;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #334;
  background: #111;
  color: var(--fg-color);
}

button {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid #334;
  background: #1a1640;
  color: var(--fg-color);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, box-shadow 0.2s, border-color 0.2s;
}

button:hover {
  background: #2a2360;
  border-color: rgba(0, 255, 255, 0.45);
  box-shadow: 0 0 14px rgba(0, 255, 255, 0.22);
}

figure {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(var(--zoom, 1));
  width: var(--scene-size);
  aspect-ratio: 1;
  perspective: 2000px;
  transition: transform 0.1s ease;
  margin: 0;
}

.torus {
  --rot-x: 0;
  --rot-y: 0;
  display: grid;
  place-items: center;
  width: var(--scene-size);
  aspect-ratio: 1;
  transform-style: preserve-3d;
  transform: rotateX(var(--rot-x)) rotateY(var(--rot-y));
  cursor: grab;
}

.torus:active {
  cursor: grabbing;
}

.torus>.circle,
.torus>.ring {
  grid-area: 1/1;
  aspect-ratio: 1;
  border: solid 1px currentColor;
  border-radius: 50%;
}

.circle {
  width: var(--circle-diameter);
  transform: rotateY(calc(var(--circle-rotate) * var(--circle-index))) translateX(var(--inner-radian));
  color: rgba(255, 0, 0, 0.5);
}

.ring {
  --rot: 90deg;
  --z: 0;
  --scale: 1;
  width: var(--inner-diameter);
  transform: rotateX(var(--rot)) scale(var(--scale)) translateZ(calc(var(--circle-radian) * var(--z)));
}

.segment {
  position: absolute;
  width: 1%;
  height: 1%;
  background: var(--fg-color);
  box-shadow: 0 0 2% var(--fg-color);
  border-radius: 50%;
  left: 50%;
  top: 50%;
}

#status {
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100vw - 24px);
  color: #9fd4ff;
  font-family: 'Cascadia Code', Consolas, monospace;
  display: grid;
  gap: 3px;
  background: rgba(13, 11, 30, 0.62);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(0, 255, 255, 0.14);
  border-radius: 12px;
  padding: 10px 18px;
  font-size: 0.82rem;
  z-index: 20;
}

#status .ico {
  display: inline-block;
  width: 1.4em;
  color: rgba(0, 255, 255, 0.75);
}

/* ---------- Hover-Tooltips (dunkler Glas-Stil) ---------- */

[data-tip] {
  position: relative;
}

[data-tip]:hover::after {
  content: attr(data-tip);
  position: absolute;
  top: calc(100% + 9px);
  left: 50%;
  transform: translateX(-50%);
  background: rgba(16, 13, 36, 0.96);
  border: 1px solid rgba(0, 255, 255, 0.3);
  color: #cfe6ff;
  padding: 8px 12px;
  border-radius: 8px;
  width: max-content;
  max-width: 270px;
  font-size: 0.78rem;
  font-weight: 500;
  line-height: 1.55;
  text-align: left;
  white-space: normal;
  z-index: 600;
  pointer-events: none;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.55), 0 0 18px rgba(0, 255, 255, 0.08);
  opacity: 0;
  animation: tipIn 0.18s ease 0.25s forwards;
}

[data-tip]:hover::before {
  content: '';
  position: absolute;
  top: calc(100% + 3px);
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-bottom-color: rgba(0, 255, 255, 0.3);
  z-index: 600;
  pointer-events: none;
  opacity: 0;
  animation: tipIn 0.18s ease 0.25s forwards;
}

@keyframes tipIn {
  to {
    opacity: 1;
  }
}

/* ---------- Sternenhimmel + Vignette ---------- */

#stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

body.hq::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(ellipse at center,
      transparent 52%,
      rgba(2, 2, 10, 0.38) 86%,
      rgba(1, 1, 6, 0.62) 100%);
}

/* ---------- Material statt Drahtgitter (Qualitätsmodus) ---------- */

body.hq .circle {
  border: 1px solid rgba(255, 95, 115, 0.55);
  box-shadow:
    0 0 14px rgba(255, 60, 95, 0.16),
    inset 0 0 22px rgba(255, 60, 95, 0.13);
  color: transparent;
}

body.hq .segment {
  width: 1.6%;
  height: 1.6%;
  margin-left: -0.8%;
  margin-top: -0.8%;
  background: radial-gradient(circle,
      rgba(255, 255, 255, 0.98) 0%,
      rgba(150, 255, 255, 0.85) 38%,
      rgba(0, 230, 255, 0.25) 70%,
      transparent 100%);
  box-shadow: 0 0 7px rgba(0, 240, 255, 0.55);
}

body.hq .ring {
  border-color: rgba(0, 255, 255, 0.30);
  box-shadow: 0 0 18px rgba(0, 255, 255, 0.10), inset 0 0 18px rgba(0, 255, 255, 0.08);
}

/* ---------- Info-Popup im dunklen Torus-Stil ---------- */

.torus-popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 2, 8, 0.78);
  backdrop-filter: blur(6px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.torus-popup-overlay.hidden {
  display: none;
}

.torus-popup {
  background: linear-gradient(160deg, #181430 0%, #0d0b1c 100%);
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: 16px;
  box-shadow: 0 0 60px rgba(0, 255, 255, 0.12), 0 18px 60px rgba(0, 0, 0, 0.6);
  max-width: 720px;
  width: 92%;
  max-height: 88vh;
  overflow-y: auto;
  animation: torusPopupIn 0.28s ease-out;
}

@keyframes torusPopupIn {
  from {
    transform: translateY(-30px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.torus-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-bottom: 1px solid rgba(0, 255, 255, 0.2);
  position: sticky;
  top: 0;
  background: rgba(24, 20, 48, 0.96);
  border-radius: 16px 16px 0 0;
}

.torus-popup-header h2 {
  margin: 0;
  font-size: 1.15rem;
  color: #8cf;
}

.torus-popup-close {
  background: rgba(0, 255, 255, 0.1);
  border: 1px solid rgba(0, 255, 255, 0.3);
  color: var(--fg-color);
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.torus-popup-close:hover {
  background: rgba(0, 255, 255, 0.25);
}

.torus-popup-body {
  padding: 18px 24px 24px 24px;
  color: #cfd3ee;
  line-height: 1.8;
  font-size: 0.95rem;
}

.torus-popup-body p {
  margin: 0 0 14px 0;
}

.torus-popup-body strong {
  color: #fff;
}

.torus-popup-body .hl-red {
  color: #ff7b7b;
  font-weight: 600;
}

.torus-popup-body .hl-cyan {
  color: #4ff5f5;
  font-weight: 600;
}

.torus-popup-body .hl-yellow {
  color: #ffe96a;
  font-weight: 600;
}

.torus-popup-body .mono {
  font-family: monospace;
  color: #9fe8ff;
  white-space: nowrap;
}

.torus-popup-body h3 {
  color: #8cf;
  font-size: 1rem;
  margin: 4px 0 10px 0;
}

.torus-popup-body .var-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 7px 16px;
  margin: 0;
  align-items: baseline;
}

.torus-popup-body .var-list dt {
  font-family: monospace;
  font-weight: 700;
  color: #4ff5f5;
  background: rgba(0, 255, 255, 0.08);
  border: 1px solid rgba(0, 255, 255, 0.25);
  border-radius: 6px;
  padding: 2px 9px;
  text-align: center;
  white-space: nowrap;
}

.torus-popup-body .var-list dd {
  margin: 0;
  line-height: 1.6;
}
