/*===============================================================
  MAI CUBE — Laborgerät-Seite (mai-cube.html)
  Eine einzige Bühne: Hero-Animation -> dasselbe Objekt bleibt beim
  Scrollen stehen -> Bauteil-Explorer mit seitlichem Teile-Scroller.
  Die Bühne bleibt wie die Spark-Bühne in beiden Themes dunkel
  (#0a0a0f, Violett #7c3aed, Pink #ec4899). Präfix: .mai-
  --p (0..1) = Scrollfortschritt der Bühne, gesetzt von js/mai-cube.js
================================================================*/

.mai-page {
  --mai-stage: #0a0a0f;
  --mai-violet: 124, 58, 237;
  --mai-pink: 236, 72, 153;
  --mai-mono: 'JetBrains Mono', ui-monospace, Menlo, monospace;
  --mai-card-w: min(400px, 34vw);
  --mai-gut: clamp(18px, 6vw, 92px);
}

/* overflow:hidden auf .main würde position:sticky abschalten */
.mai-page .main { overflow: clip; }
@supports not (overflow: clip) { .mai-page .main { overflow: visible; } }
.mai-page *, .mai-page *::before, .mai-page *::after { box-sizing: border-box; }

/* ---------- Gemeinsame Bausteine ---------- */
.mai-eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  font-family: var(--font-photyra, 'Arkitech', 'Kiona', sans-serif);
  font-size: 0.8rem; letter-spacing: 0.24em; text-transform: uppercase; font-weight: 500;
  color: hsl(355, 88%, 74%);
  margin-bottom: 16px;
}
.mai-eyebrow__dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 10px currentColor; }

.mai-reveal { opacity: 0; transform: translateY(26px); transition: opacity 0.8s var(--ease-out), transform 0.8s var(--ease-out); }
.mai-reveal.in-view { opacity: 1; transform: none; }

/* ===============================================================
   BÜHNE
================================================================*/
.mai-stage {
  --p: 0;
  position: relative;
  height: 200vh;                 /* 100vh Scrollweg = Übergang Hero -> Explorer */
  background: var(--mai-stage);
}
.mai-stage__sticky {
  position: sticky; top: 0;
  height: 100vh; height: 100svh;
  min-height: 600px;
  overflow: hidden;
  isolation: isolate;
  background: var(--mai-stage);
}
.mai-stage__canvas {
  position: absolute; inset: 0; z-index: 1;
  display: block; width: 100%; height: 100%;
  pointer-events: none;           /* im Hero scrollt die Seite durch den Canvas */
}
.mai-stage.is-x .mai-stage__canvas { pointer-events: auto; cursor: grab; }
.mai-stage.is-x .mai-stage__canvas:active { cursor: grabbing; }
.mai-stage.is-x .mai-stage__canvas.is-hot { cursor: pointer; }

/* Aurora liegt über dem (opaken) Canvas und hellt per screen auf */
.mai-stage__aurora {
  position: absolute; inset: -20%; z-index: 2;
  pointer-events: none;
  filter: blur(90px);
  opacity: 0.5;
  mix-blend-mode: screen;
}
.mai-blob { position: absolute; border-radius: 50%; will-change: transform; }
.mai-blob--1 { width: 46vw; height: 46vw; left: 4%; top: 6%;
  background: radial-gradient(circle, rgba(var(--mai-violet), 0.62), rgba(var(--mai-violet), 0) 70%);
  animation: mai-drift-a 26s ease-in-out infinite alternate; }
.mai-blob--2 { width: 40vw; height: 40vw; right: 2%; top: 22%;
  background: radial-gradient(circle, rgba(var(--mai-pink), 0.42), rgba(var(--mai-pink), 0) 70%);
  animation: mai-drift-b 31s ease-in-out infinite alternate; }
.mai-blob--3 { width: 52vw; height: 52vw; left: 26%; bottom: -12%;
  background: radial-gradient(circle, rgba(58, 84, 186, 0.45), rgba(58, 84, 186, 0) 70%);
  animation: mai-drift-c 37s ease-in-out infinite alternate; }
@keyframes mai-drift-a { to { transform: translate3d(6vw, 4vh, 0) scale(1.12); } }
@keyframes mai-drift-b { to { transform: translate3d(-5vw, 6vh, 0) scale(1.08); } }
@keyframes mai-drift-c { to { transform: translate3d(4vw, -5vh, 0) scale(1.14); } }
.mai-stage__shade { display: none; }

/* ---------- Phase 1: Hero (blendet mit --p aus) ---------- */
.mai-hero__copy, .mai-modes, .mai-hint { opacity: calc(1 - var(--p) * 2.8); }
.mai-stage.is-out .mai-hero__copy, .mai-stage.is-out .mai-modes, .mai-stage.is-out .mai-hint { visibility: hidden; pointer-events: none; }

.mai-hero__copy {
  position: absolute; z-index: 3;
  left: var(--mai-gut);
  top: 50%;
  transform: translateY(calc(-50% - var(--p) * 60px));
  max-width: min(46ch, 44vw);
}
.mai-hero__title {
  font-family: 'Kiona', sans-serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  line-height: 1.1; margin: 0 0 18px; font-weight: 400;
  background: linear-gradient(110deg, #fff 0%, #fff 24%, hsl(355, 72%, 64%) 42%, #fff 58%, #fff 100%);
  background-size: 260% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: mai-title-sweep 4.5s linear infinite;
  text-wrap: balance;
}
@keyframes mai-title-sweep { to { background-position: -260% center; } }
.mai-hero__sub { font-size: 1.02rem; color: hsl(228, 12%, 86%); line-height: 1.6; margin: 0 0 26px; text-shadow: 0 1px 14px rgba(0, 0, 0, 0.6); }

.mai-facts { display: grid; grid-template-columns: repeat(3, auto); justify-content: start; gap: clamp(14px, 2vw, 34px); }
.mai-fact b { display: block; font-family: 'Kiona', sans-serif; color: hsl(228, 8%, 98%); font-size: 1.5rem; font-weight: 400; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mai-fact span { display: block; margin-top: 0.2rem; font-size: 0.74rem; letter-spacing: 0.1em; text-transform: uppercase; color: hsl(228, 6%, 62%); }
.mai-fact + .mai-fact { border-left: 1px solid hsla(0, 0%, 100%, 0.08); padding-left: clamp(16px, 2.4vw, 40px); }

.mai-hero__btns { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 28px; }
.mai-page .mai-hero__btns > * { flex: 0 0 auto; width: auto; }
/* Bühne ist in beiden Themes dunkel: Pillen hier immer hell zeichnen */
.mai-stage .btn-secondary { border-color: #fff; color: #fff; }
.mai-stage .btn-secondary:hover { color: #fff; border-color: var(--first-color); }

.mai-modes {
  position: absolute; z-index: 3;
  right: var(--mai-gut);
  bottom: 112px;                 /* über dem Chat-Dock unten rechts */
  display: flex; align-items: center; gap: 6px;
  padding: 6px; border-radius: 999px;
  background: hsla(228, 24%, 6%, 0.62);
  border: 1px solid hsla(0, 0%, 100%, 0.12);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.mai-modes__label { padding: 0 8px 0 12px; font-family: var(--mai-mono); font-size: 0.66rem; letter-spacing: 0.14em; text-transform: uppercase; color: hsl(228, 6%, 62%); }
.mai-mode {
  appearance: none; border: 0; border-radius: 999px; padding: 8px 14px;
  background: transparent; color: hsl(228, 10%, 86%);
  font-family: 'Kiona', sans-serif; font-size: 0.7rem; letter-spacing: 0.12em; text-transform: uppercase;
  cursor: pointer; transition: background 0.25s ease, color 0.25s ease;
}
.mai-mode:hover { background: hsla(0, 0%, 100%, 0.08); }
.mai-mode.is-active { background: #fff; color: #0a0a0f; }
.mai-mode:focus-visible, .mai-chip:focus-visible, .mai-rail__nav:focus-visible { outline: 2px solid var(--first-color); outline-offset: 2px; }

.mai-hint {
  position: absolute; z-index: 3; left: 50%; bottom: 26px; transform: translateX(-50%);
  font-family: 'Kiona', sans-serif; font-size: 0.72rem; letter-spacing: 0.16em; text-transform: uppercase;
  color: hsl(228, 6%, 62%);
}

/* ---------- Phase 2: Explorer-Oberfläche (blendet mit --p ein) ---------- */
.mai-xui {
  position: absolute; inset: 0; z-index: 3;
  opacity: calc((var(--p) - 0.62) * 2.8);
  pointer-events: none;
}
.mai-stage:not(.is-out) .mai-xui { visibility: hidden; }
.mai-stage.is-x .mai-xui__card, .mai-stage.is-x .mai-rail, .mai-stage.is-x .mai-x__explode { pointer-events: auto; }

.mai-xui__head { position: absolute; left: var(--mai-gut); top: 118px; max-width: min(40ch, 36vw); }
.mai-xui__head .mai-eyebrow { margin-bottom: 10px; }
.mai-xui__head h2 { font-family: 'Kiona', sans-serif; font-weight: 400; font-size: clamp(1.4rem, 2.6vw, 2.1rem); line-height: 1.15; color: #fff; margin: 0 0 8px; }
.mai-xui__head p { margin: 0; font-size: 0.9rem; line-height: 1.55; color: hsl(228, 10%, 74%); }

.mai-x__loading {
  position: absolute; left: 0; right: var(--mai-card-w); top: 50%;
  text-align: center;
  font-family: var(--mai-mono); font-size: 0.78rem; letter-spacing: 0.1em; color: hsl(228, 6%, 62%);
  transition: opacity 0.4s ease;
}
.mai-x__loading.is-done { opacity: 0; }

.mai-x__mark {
  position: absolute; left: 0; top: 0;
  display: flex; align-items: center; gap: 8px;
  transform: translate(0, -50%);
  opacity: 0; transition: opacity 0.25s linear;
  font-family: 'Kiona', sans-serif; font-size: 0.68rem; letter-spacing: 0.1em; text-transform: uppercase; white-space: nowrap; color: #fff;
}
.mai-x__mark.is-on { opacity: 1; }
.mai-x__mark i { width: 7px; height: 7px; flex: 0 0 7px; border-radius: 50%; background: hsl(355, 82%, 64%);
  box-shadow: 0 0 0 4px hsla(355, 82%, 64%, 0.18), 0 0 14px hsla(355, 82%, 64%, 0.8); }
.mai-x__mark span { padding: 4px 10px; border-radius: 999px; background: hsla(228, 24%, 6%, 0.82); border: 1px solid hsla(0, 0%, 100%, 0.16);
  -webkit-backdrop-filter: blur(5px); backdrop-filter: blur(5px); }

.mai-x__explode {
  position: absolute; left: var(--mai-gut); bottom: 112px;
  display: inline-flex; align-items: center; gap: 10px;
  padding: 8px 14px; border-radius: 999px;
  background: hsla(228, 24%, 6%, 0.7); border: 1px solid hsla(0, 0%, 100%, 0.12);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  font-family: var(--mai-mono); font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: hsl(228, 8%, 78%);
  cursor: pointer;
}
.mai-x__explode input { width: clamp(90px, 14vw, 170px); accent-color: hsl(355, 78%, 62%); cursor: pointer; }

/* Detailkarte rechts — dunkles Glas, unabhängig vom Theme */
.mai-xui__card {
  position: absolute; right: var(--mai-gut); top: 118px; bottom: 112px;
  width: var(--mai-card-w);
  overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: hsla(0, 0%, 100%, 0.2) transparent;
  border-radius: var(--radius-lg);
  border: 1px solid hsla(0, 0%, 100%, 0.12);
  background: hsla(228, 22%, 7%, 0.66);
  -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  padding: clamp(18px, 2vw, 26px);
}
.mai-part { display: none; }
.mai-part.is-active { display: block; animation: mai-part-in 0.45s var(--ease-out); }
@keyframes mai-part-in { from { opacity: 0; transform: translateY(10px); } }
.mai-part__video {
  aspect-ratio: 1 / 1;
  margin-bottom: 18px;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: #000;
  border: 1px solid hsla(0, 0%, 100%, 0.12);
}
.mai-part__video video { width: 100%; height: 100%; object-fit: cover; object-position: 50% 38%; display: block; }
.mai-part__no { font-family: var(--mai-mono); font-size: 0.7rem; letter-spacing: 0.14em; color: hsl(355, 88%, 72%); }
.mai-part h3 { font-family: 'Kiona', sans-serif; font-weight: 400; font-size: clamp(1.2rem, 1.8vw, 1.5rem); color: #fff; margin: 8px 0 12px; }
.mai-part p { color: hsl(228, 10%, 80%); line-height: 1.65; margin: 0 0 18px; font-size: 0.95rem; }
.mai-specs { list-style: none; margin: 0; padding: 0; border-top: 1px solid hsla(0, 0%, 100%, 0.1); }
.mai-specs li { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 10px 0; border-bottom: 1px solid hsla(0, 0%, 100%, 0.1); }
.mai-specs span { font-size: 0.7rem; letter-spacing: 0.1em; text-transform: uppercase; color: hsl(228, 6%, 60%); }
.mai-specs b { font-family: var(--mai-mono); font-weight: 500; font-size: 0.82rem; color: #fff; text-align: right; font-variant-numeric: tabular-nums; }
.mai-x__note { margin: 16px 0 0; font-size: 0.74rem; line-height: 1.5; color: hsl(228, 6%, 56%); }

/* Teile-Scroller: seitlich scrollen, Auswahl rastet ein */
.mai-rail {
  position: absolute; left: var(--mai-gut); bottom: 26px;
  right: max(calc(var(--mai-gut) + var(--mai-card-w) + 24px), 560px);   /* frei für Chat-Dock */
  display: flex; align-items: center; gap: 8px;
}
.mai-rail__track {
  flex: 1 1 auto; min-width: 0;
  display: flex; gap: 8px;
  overflow-x: auto; overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  scrollbar-width: none;
  padding: 4px 2px;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 28px, #000 calc(100% - 28px), transparent);
}
.mai-rail__track::-webkit-scrollbar { display: none; }
.mai-rail__nav {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid hsla(0, 0%, 100%, 0.16);
  background: hsla(228, 24%, 6%, 0.7);
  color: #fff; font-size: 1.2rem; cursor: pointer;
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  transition: border-color 0.2s ease;
}
.mai-rail__nav:hover { border-color: var(--first-color); }
.mai-chip {
  appearance: none; flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 11px 16px;
  border-radius: 999px;
  border: 1px solid hsla(0, 0%, 100%, 0.14);
  background: hsla(228, 24%, 6%, 0.7);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  color: hsl(228, 10%, 82%);
  font-family: var(--body-font); font-size: 0.88rem; white-space: nowrap;
  cursor: pointer; scroll-snap-align: center;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
}
.mai-chip em { font-style: normal; font-family: var(--mai-mono); font-size: 0.7rem; color: hsl(228, 6%, 56%); font-variant-numeric: tabular-nums; }
.mai-chip:hover { border-color: hsla(355, 80%, 64%, 0.6); color: #fff; }
.mai-chip.is-active { border-color: hsl(355, 78%, 62%); background: hsla(355, 70%, 50%, 0.22); color: #fff; }
.mai-chip.is-active em { color: hsl(355, 88%, 74%); }

/* ===============================================================
   INTERESSE
================================================================*/
.mai-section { position: relative; padding: clamp(64px, 10vw, 120px) clamp(16px, 4vw, 40px); background: var(--body-color); }
.mai-interest { background: hsl(228, 4%, 7%); text-align: center; }
.mai-interest__card {
  max-width: 640px; margin: 0 auto;
  padding: clamp(32px, 5vw, 52px) clamp(20px, 4vw, 40px);
  border-radius: 24px;
  background: linear-gradient(160deg, hsla(355, 60%, 14%, 0.40), hsla(228, 14%, 8%, 0.34));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.mai-interest__card h2 { font-family: 'Kiona', sans-serif; font-weight: 400; font-size: clamp(1.6rem, 3.6vw, 2.4rem); line-height: 1.15; color: hsl(228, 8%, 97%); margin: 0 0 14px; text-wrap: balance; }
.mai-interest__desc { color: hsl(228, 8%, 70%); line-height: 1.7; margin: 0 auto 26px; max-width: 46ch; }
.mai-interest .btn-secondary { border-color: #fff; color: #fff; }
.mai-interest .btn-secondary:hover { color: #fff; border-color: var(--first-color); }
.mai-interest #mai-interest-open[aria-expanded="true"] { display: none; }

.mai-lead { max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; text-align: left; animation: mai-part-in 0.45s var(--ease-out); }
.mai-lead[hidden] { display: none; }
.mai-lead__row { display: flex; gap: 10px; flex-wrap: wrap; }
.mai-lead__input {
  flex: 1 1 170px; min-width: 0; padding: 12px 14px; border-radius: 12px;
  border: 1px solid hsla(0, 0%, 100%, 0.16);
  background: hsla(228, 20%, 6%, 0.6);
  color: #fff; font: inherit; font-size: 0.95rem;
}
.mai-lead__input::placeholder { color: hsl(228, 6%, 56%); }
.mai-lead__input:focus { outline: none; border-color: var(--first-color); box-shadow: 0 0 0 3px var(--accent-soft); }
.mai-lead__consent { display: flex; gap: 8px; align-items: flex-start; font-size: 0.82rem; line-height: 1.5; color: hsl(228, 8%, 70%); }
.mai-lead__consent input { margin-top: 3px; accent-color: var(--first-color); }
.mai-lead__consent a { color: hsl(355, 88%, 74%); text-decoration: underline; }
.mai-page .mai-lead button[type="submit"] { align-self: center; width: auto; }
.mai-lead button.is-loading { opacity: 0.6; pointer-events: none; }
.mai-lead__status { text-align: center; font-size: 0.9rem; margin: 2px 0 0; }
.mai-lead__status[data-kind="ok"] { color: hsl(140, 52%, 56%); }
.mai-lead__status[data-kind="error"] { color: hsl(355, 88%, 72%); }

.mai-github {
  display: inline-flex; align-items: center; gap: 8px;
  margin: 28px 0 0;
  font-family: var(--mai-mono); font-size: 0.74rem; letter-spacing: 0.08em;
  color: hsl(228, 6%, 58%);
}
.mai-github i { font-size: 1.05rem; }

/* ===============================================================
   Mobil
================================================================*/
@media (max-width: 960px) {
  .mai-page { --mai-gut: clamp(12px, 4vw, 28px); }
  .mai-stage__shade {
    display: block;
    position: absolute; left: 0; right: 0; bottom: 0; height: 66%;
    z-index: 2; pointer-events: none;
    background: linear-gradient(to bottom, rgba(10, 10, 15, 0) 0%, rgba(10, 10, 15, 0.84) 40%, rgba(10, 10, 15, 0.97) 100%);
    opacity: calc(1 - var(--p) * 2.2);
  }
  .mai-hero__copy {
    top: auto; bottom: calc(100px + env(safe-area-inset-bottom, 0px));
    transform: translateY(calc(var(--p) * -40px)); max-width: none;
    left: var(--mai-gut); right: var(--mai-gut);
  }
  .mai-hero__title { font-size: clamp(1.7rem, 8.4vw, 2.4rem); margin-bottom: 12px; }
  .mai-hero__sub { font-size: 0.94rem; margin-bottom: 18px; }
  .mai-facts { gap: 12px; }
  .mai-fact b { font-size: 1.1rem; }
  .mai-fact span { font-size: 0.62rem; letter-spacing: 0.08em; }
  .mai-fact + .mai-fact { padding-left: 12px; }
  .mai-hero__btns { margin-top: 18px; gap: 10px; }
  .mai-modes { left: 50%; right: auto; transform: translateX(-50%); top: 100px; bottom: auto; }
  .mai-modes__label, .mai-hint { display: none; }

  /* Explorer: Objekt oben, Teile-Scroller, darunter die Karte */
  .mai-xui__head { display: none; }
  .mai-x__loading { right: 0; top: 30%; }
  .mai-x__explode { left: auto; right: var(--mai-gut); top: 96px; bottom: auto; }
  .mai-xui__card {
    left: var(--mai-gut); right: var(--mai-gut); top: auto;
    bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    width: auto; height: 34vh; height: 34svh;
    border-radius: var(--radius-md);
  }
  .mai-rail {
    left: 0; right: 0;
    bottom: calc(96px + 34vh + 10px + env(safe-area-inset-bottom, 0px));
    bottom: calc(96px + 34svh + 10px + env(safe-area-inset-bottom, 0px));
  }
  .mai-rail__nav { display: none; }
  .mai-rail__track { padding: 4px var(--mai-gut); -webkit-mask-image: none; mask-image: none; scroll-padding: 0 var(--mai-gut); }
  .mai-part__video { max-width: 240px; }
}

@media (prefers-reduced-motion: reduce) {
  .mai-blob, .mai-hero__title, .mai-part.is-active, .mai-lead { animation: none; }
  .mai-reveal { opacity: 1; transform: none; transition: none; }
}
