/* css/stage.css - Modul C: Main Stage (Keynote-Stil).
 * Nur Design-Tokens aus dem :root-Block in index.html, keine eigenen Hex-Werte. */

.main-stage {
  display: block;
  position: relative;
  width: 100%;
  color: var(--text-primary);
  font-family: var(--font-body);
}

.stage-frame {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(20px, 4vh, 56px) clamp(16px, 4vw, 48px) 28px;
  min-height: 78vh;
}

/* ---- Folie ------------------------------------------------------------- */

.stage-deck { flex: 1 1 auto; display: flex; }

.slide {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr;
  /* "safe" verhindert, dass eine ueberhohe Folie nach oben aus dem Kasten
   * laeuft und der untere Teil nicht mehr erreichbar ist. */
  align-content: center;
  align-content: safe center;
  gap: clamp(20px, 3vw, 40px);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 240ms cubic-bezier(0.22, 0.61, 0.36, 1),
              transform 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

.slide.is-in { opacity: 1; transform: none; }

.slide.is-split {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: center;
  align-items: safe center;
}

.slide-text { min-width: 0; }

.slide-kicker {
  margin: 0 0 14px;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brand-color);
}

.slide-title {
  margin: 0;
  font-family: var(--font-headline);
  font-size: clamp(32px, 4.4vw, 64px);
  font-weight: 700;
  line-height: 1.04;
  letter-spacing: var(--headline-spacing);
  text-transform: var(--headline-transform);
  text-wrap: balance;
}

.slide-body {
  margin-top: clamp(16px, 2.4vh, 28px);
  max-width: 62ch;
  font-size: clamp(15px, 1.15vw, 19px);
  line-height: 1.6;
  color: var(--text-muted);
}

.slide-body .md-heading {
  margin: 0 0 10px;
  font-family: var(--font-headline);
  font-size: 1em;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-caption);
}

.slide-body .md-p { margin: 0 0 12px; }
.slide-body .md-p:last-child { margin-bottom: 0; }
.slide-body strong { color: var(--text-primary); font-weight: 700; }
.slide-body em { font-style: italic; }

.md-code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 0.88em;
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--brand-color);
}

.md-list { margin: 0 0 12px; padding-left: 1.2em; }
.md-list li { margin-bottom: 6px; }

.slide-bullets {
  margin: clamp(16px, 2.4vh, 26px) 0 0;
  padding: 0;
  list-style: none;
  max-width: 62ch;
  display: grid;
  gap: 10px;
}

.slide-bullets li {
  position: relative;
  padding-left: 22px;
  font-size: clamp(14px, 1.05vw, 17px);
  line-height: 1.5;
  color: var(--text-muted);
}

.slide-bullets li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.62em;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand-color);
}

.slide-commit { margin: clamp(18px, 2.6vh, 30px) 0 0; }

.commit-chip {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  padding: 5px 10px;
  border-radius: var(--radius-field);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-ghost);
  color: var(--text-caption);
}

.commit-chip::before { content: "commit "; color: var(--text-caption); opacity: 0.6; }

/* ---- Mockup und Code --------------------------------------------------- */

.slide-visual { min-width: 0; display: grid; gap: 16px; align-content: safe center; }
.slide-visual.is-inline { margin-top: clamp(18px, 2.6vh, 30px); max-width: 720px; }

.mockup-pane, .code-pane {
  margin: 0;
  background: var(--surface-1);
  border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 1px var(--border-ghost);
  overflow: hidden;
}

.mockup-img { display: block; width: 100%; height: auto; }

.mockup-frame {
  display: block;
  width: 100%;
  height: clamp(220px, 34vh, 420px);
  border: 0;
  background: var(--surface-0);
}

.mockup-caption, .code-head {
  font-size: 12px;
  color: var(--text-caption);
  padding: 10px 16px;
}

.code-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-ghost);
}

.code-title { font-weight: 600; color: var(--text-muted); }

.code-lang {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand-color);
}

.code-body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  max-height: clamp(220px, 40vh, 460px);
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.65;
}

.code-gutter {
  display: flex;
  flex-direction: column;
  padding: 14px 10px 14px 16px;
  text-align: right;
  color: var(--text-caption);
  opacity: 0.45;
  user-select: none;
  background: color-mix(in srgb, var(--surface-2) 60%, transparent);
}

.code-source { margin: 0; padding: 14px 16px 14px 12px; }
.code-source code { display: block; white-space: pre; }
.code-line { display: block; }

.tok-str { color: var(--brand-secondary); }
.tok-com { color: var(--text-caption); font-style: italic; opacity: 0.8; }
.tok-key { color: var(--brand-color); }
.tok-num { color: color-mix(in srgb, var(--brand-secondary) 65%, var(--text-primary)); }
.tok-var { color: var(--brand-color); }
.tok-prop { color: var(--text-primary); }

/* ---- Funnel-Widget ----------------------------------------------------- */

.funnel {
  margin: clamp(18px, 2.6vh, 30px) 0 0;
  padding: clamp(16px, 2vw, 24px);
  background: var(--surface-1);
  border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 1px var(--border-ghost);
}

.funnel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-bottom: 16px;
}

.funnel-title {
  margin: 0;
  font-family: var(--font-headline);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-caption);
}

.funnel-plot { position: relative; }
.funnel-svg { display: block; width: 100%; height: auto; overflow: visible; }

.funnel-label {
  font-family: var(--font-body);
  font-size: 13px;
  fill: var(--text-muted);
}

.funnel-value {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  fill: var(--text-caption);
}

.funnel-track { fill: var(--surface-3); }
.funnel-bar { fill: var(--brand-color); opacity: 0.85; }
.funnel-bar.is-drop { fill: var(--brand-secondary); opacity: 0.9; }

/* Drop-off-Bereich: liegt als Schaltflaeche ueber der Luecke zwischen den
 * beiden betroffenen Balken, damit er per Tab erreichbar bleibt. */
.funnel-drop {
  position: absolute;
  height: 16px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 6px;
  overflow: hidden;
  border: 0;
  border-radius: 8px;
  background: color-mix(in srgb, var(--brand-secondary) 12%, transparent);
  cursor: help;
  font: inherit;
}

.funnel-drop-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--brand-secondary);
}

.funnel-drop:hover, .funnel-drop:focus, .funnel-drop:focus-visible {
  outline: none;
  background: color-mix(in srgb, var(--brand-secondary) 22%, transparent);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand-secondary) 45%, transparent);
}

/* Bewusst im Fluss statt absolut: absolut positioniert wird das Panel am
 * unteren Rand der Buehne abgeschnitten. Es liegt ausserhalb von .funnel-plot,
 * weil es sonst dessen Hoehe aendert und die Prozent-Position des Drop-off-
 * Bandes verschiebt. Es schiebt beim Aufklappen die Marker nach unten. */
.funnel-tip {
  display: none;
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--surface-3);
  border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 1px var(--border-ghost);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
}

/* Fokus kommt ohne :has aus, Hover braucht es (Chrome/Safari seit 2022). */
.funnel-plot:focus-within + .funnel-tip,
.funnel-plot:has(.funnel-drop:hover) + .funnel-tip,
.funnel-tip:hover { display: block; }

.funnel-tip p { margin: 0 0 8px; }
.funnel-tip p:last-child { margin-bottom: 0; }

.funnel-tip-head {
  display: inline-block;
  margin-right: 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--brand-color);
}

.funnel-tip-excl { color: var(--text-caption); }

.funnel-markers {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.funnel-marker {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius-field);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border-ghost);
}

.funnel-marker-key {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-caption);
}

.funnel-marker-val {
  font-family: var(--font-headline);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-muted);
}

.funnel-marker.is-after .funnel-marker-val { color: var(--brand-color); }

/* ---- Notizen ----------------------------------------------------------- */

.stage-notes {
  padding: 14px 18px;
  background: var(--surface-2);
  border-radius: var(--radius-card);
  box-shadow: inset 0 0 0 1px var(--border-ghost);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted);
  max-height: 26vh;
  overflow: auto;
}

.stage-notes .notes-head {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-caption);
}

.stage-notes .md-p, .stage-notes .md-list { margin: 0 0 8px; }
.stage-notes .md-p:last-child { margin-bottom: 0; }

/* ---- Fuss: Punkte, Zaehler, Fortschritt -------------------------------- */

.stage-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.stage-dots { display: flex; flex-wrap: wrap; gap: 8px; }

.stage-dot {
  width: 9px;
  height: 9px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface-4);
  cursor: pointer;
  transition: background-color 160ms ease, transform 160ms ease;
}

.stage-dot:hover { background: var(--text-caption); }

.stage-dot.is-active {
  background: var(--brand-color);
  transform: scale(1.35);
}

.stage-dot:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--brand-soft);
}

.stage-counter {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text-caption);
}

.stage-progress {
  height: 2px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}

.stage-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--brand-color);
  transition: width 240ms cubic-bezier(0.22, 0.61, 0.36, 1);
}

/* ---- Schmale Fenster und Vollbild -------------------------------------- */

@media (max-width: 820px) {
  .slide.is-split { grid-template-columns: 1fr; }
  .stage-frame { min-height: 70vh; padding-left: 16px; padding-right: 16px; }
  .funnel-drop { justify-content: flex-start; }
  .funnel-drop-label { font-size: 11px; }
}

:fullscreen .stage-frame { min-height: 92vh; max-width: 1400px; }

@media (prefers-reduced-motion: reduce) {
  .slide { transition: none; opacity: 1; transform: none; }
  .stage-progress span { transition: none; }
  .stage-dot { transition: none; }
}
