/* LocalEye v8: Kameraszene mit Prüfrahmen und Prüfhinweis-Toast (Agent E). Gehört zu js/stage.js.
   Markup und Verträge: BRIEFING.md. Farben über die Tokens aus css/v8.css, mit Rückfallwerten.
   Anpassbar für den Seitenbau: --stage-radius, --stage-toast-w, --stage-toast-overlap. */

.stage {
  --stage-radius: 20px;
  --stage-toast-w: min(380px, 56%);
  --stage-toast-overlap: 44px;
  position: relative;
  min-width: 0;
  margin: 0;
}

/* Videofläche: 16:9 wie das Video, enthalten statt beschnitten (Koordinaten gelten direkt) */
.stage__media {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: var(--stage-radius);
  background: #0F172A;
  isolation: isolate;
}
.stage__media > video,
.stage__still {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
/* Standbild des letzten Bildes für die Überblendung beim Neustart */
.stage__still {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.7s ease;
}
.stage__still.is-on {
  opacity: 1;
  transition: none;
}

.stage__overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

/* Kamera-Chip oben links im Video */
.stage__cam {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 4px 9px;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.62);
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  white-space: nowrap;
}

/* Prüfrahmen: 2 px Grün, Radius 6 px, keine Pulsation, kein Fadenkreuz */
.stage__box {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--green, #22C55E);
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.22s ease-out;
}
.stage__box.is-on {
  opacity: 1;
}
/* Hinweis-Chip: #15803D mit weißer Schrift (Weiß auf #22C55E ist verboten) */
.stage__tag {
  position: absolute;
  left: -2px;
  bottom: calc(100% + 6px);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--green-text, #15803D);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
}
.stage__box.is-rechts .stage__tag {
  left: auto;
  right: -2px;
}
.stage__box.is-innen .stage__tag {
  top: 6px;
  bottom: auto;
  left: 6px;
}
.stage__box.is-innen.is-rechts .stage__tag {
  left: auto;
  right: 6px;
}

/* Kennzeichnung der inszenierten Szene: bleibt immer sichtbar */
.stage__label {
  margin: 12px 0 0;
  color: var(--muted, #64748B);
  font-size: 13px;
  line-height: 1.45;
}

/* Pause und Abspielen, oben rechts im Video */
.stage__ctl {
  position: absolute;
  z-index: 3;
  top: calc(var(--stage-mt, 0px) + 12px);
  right: calc(var(--stage-mr, 0px) + 12px);
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.62);
  color: #fff;
  cursor: pointer;
}
.stage__ctl:hover {
  background: rgba(15, 23, 42, 0.8);
}
.stage__ctl:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--blue, #2563EB);
}
.stage__ctl:empty,
.stage__ctl[hidden] {
  display: none;
}
.stage__icon {
  display: block;
  width: 14px;
  height: 14px;
  fill: currentColor;
}
.stage__icon--play,
.stage__ctl.is-paused .stage__icon--pause {
  display: none;
}
.stage__ctl.is-paused .stage__icon--play {
  display: block;
}

/* Prüfhinweis-Toast: schmal unter dem Video, breit überlappend an der unteren Kartenkante */
.stage__toast {
  position: relative;
  z-index: 4;
  margin-top: 12px;
}
.stage__toast[hidden] {
  display: none;
}
.stage__card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  padding: 12px;
  border: 1px solid var(--line, #E2E8F0);
  border-radius: 14px;
  background: #fff;
  color: var(--ink, #0F172A);
  box-shadow: 0 18px 40px -18px rgba(15, 23, 42, 0.35), 0 2px 6px rgba(15, 23, 42, 0.06);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
}
.stage__card.is-wartend {
  visibility: hidden;
}
.stage__card.is-on {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.stage__thumb {
  flex: none;
  width: 56px;
  height: 42px;
  border-radius: 8px;
  background-color: #0F172A;
  background-repeat: no-repeat;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.08);
}
.stage__text {
  flex: 1 1 140px;
  min-width: 0;
}
.stage__title {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}
.stage__dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green, #22C55E);
}
.stage__meta {
  margin: 2px 0 0;
  color: var(--muted, #64748B);
  font-size: 13px;
  line-height: 1.35;
}
.stage__action {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--blue, #2563EB);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
}
.stage__action:hover {
  background: #1D4ED8;
}
.stage__action:focus-visible {
  outline: 2px solid var(--blue, #2563EB);
  outline-offset: 2px;
}

/* Breite Szene (Desktop): Toast überlappt die untere Kante der Videokarte */
.stage.is-wide .stage__toast {
  position: absolute;
  top: calc(var(--stage-mt, 0px) + var(--stage-mh, 0px) - var(--stage-toast-overlap));
  right: calc(var(--stage-mr, 0px) + 16px);
  width: var(--stage-toast-w);
  margin: 0;
}
.stage.is-wide.has-toast .stage__label {
  min-height: 30px;
  padding-right: calc(var(--stage-toast-w) + 32px);
}

/* Schmale Szene (mobil): kleinere Chips, Toast unter dem Video */
.stage:not(.is-wide) .stage__cam {
  left: 8px;
  top: 8px;
  padding: 3px 7px;
  font-size: 11px;
}
.stage:not(.is-wide) .stage__tag {
  padding: 3px 7px;
  font-size: 11px;
}
.stage:not(.is-wide) .stage__ctl {
  top: calc(var(--stage-mt, 0px) + 8px);
  right: calc(var(--stage-mr, 0px) + 8px);
  width: 32px;
  height: 32px;
}
.stage:not(.is-wide) .stage__card {
  gap: 8px 10px;
  padding: 10px;
}
.stage:not(.is-wide) .stage__thumb {
  width: 48px;
  height: 36px;
}
.stage:not(.is-wide) .stage__text {
  flex-basis: 120px;
}

@media (max-width: 640px) {
  .stage {
    --stage-radius: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage__box,
  .stage__card,
  .stage__still {
    transition: none;
  }
  .stage__card {
    transform: none;
  }
}

@media (forced-colors: active) {
  .stage__box {
    border-color: Highlight;
  }
}

/* v9: erkannte Ware (blau), Personenrahmen vor dem Hinweis grün, mit Prüfhinweis rot */
.stage__box--obj { border-color: #3B82F6; border-radius: 5px; }
.stage__box--obj .stage__tag { background: #1D4ED8; }
.stage__box.is-alarm { border-color: #EF4444; box-shadow: 0 0 0 3px rgba(239, 68, 68, .28); }
.stage__box.is-alarm .stage__tag { background: #DC2626; }
.stage__dot { background: #EF4444; box-shadow: 0 0 0 0 rgba(239, 68, 68, .55); }
@media (prefers-reduced-motion: no-preference) {
  .stage__card.is-on .stage__dot { animation: stageAlarm 1.6s ease-out infinite; }
}
@keyframes stageAlarm { 0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .6); } 70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); } 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); } }
@media (forced-colors: active) { .stage__box.is-alarm { border-color: Mark; } }
/* v9: Farben wie überall (css/live.css): Ware gelb */
.stage__box--obj { border-color: var(--mk-ware, #FACC15); }
.stage__box--obj .stage__tag { background: var(--mk-ware, #FACC15); color: var(--mk-ware-ink, #3F2D00); }
