/* /demo/: test emocji z kamery na pełnej szerokości.
   UI jest kopią logiki z hero w landing/index.html (tam zostaje inline, żeby nie ruszać strony głównej);
   silnik ten sam: /assets/emotion/emotion.js + /assets/models/emotion-web-v1.bin. */
@property --dc { syntax: "<color>"; inherits: true; initial-value: #4a3550; }
body { transition: --dc 1.2s ease; }

.fwdemo {
  --w: min(1120px, calc(100vw - 32px));
  position: relative; z-index: 1;
  width: var(--w); margin: 36px 0 8px calc(50% - var(--w) / 2);
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 20px;
  padding: 20px; border-radius: 28px;
  background: rgba(16, 14, 21, 0.72); box-shadow: inset 0 0 0 1px var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 15px; line-height: 1.45; color: var(--ink);
}
.prose > .fwdemo + * { margin-top: 28px; }

/* kamera */
.fd-cam { position: relative; aspect-ratio: 4 / 3; border-radius: 20px; overflow: hidden; background: radial-gradient(circle at 50% 35%, #221c28, #120f16); }
.fd-cam video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); opacity: 0; transition: opacity 0.6s; display: block; }
.fwdemo.live .fd-cam video { opacity: 1; }
.fd-gate { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 14px; padding: 28px; text-align: center; }
.fd-gate small { color: var(--mut); font-size: 13px; line-height: 1.45; max-width: 300px; }
.fd-gate .st-load, .fd-gate .st-err { display: none; }
.fwdemo.loading .fd-gate .st-idle, .fwdemo.error .fd-gate .st-idle { display: none; }
.fwdemo.loading .fd-gate .st-load, .fwdemo.error .fd-gate .st-err { display: grid; justify-items: center; gap: 12px; }
.fd-gate .st-idle { display: grid; justify-items: center; gap: 14px; }
.fwdemo.live .fd-gate { display: none; }
.fd-spin { width: 22px; height: 22px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.2); border-top-color: var(--ink); animation: fd-spin 0.9s linear infinite; }
@keyframes fd-spin { to { transform: rotate(360deg); } }
.fd-noface { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); font-size: 13px; padding: 7px 12px; border-radius: 99px; background: rgba(9, 8, 13, 0.72); backdrop-filter: blur(10px); white-space: nowrap; opacity: 0; transition: opacity 0.3s; pointer-events: none; }
.fwdemo.live.nf .fd-noface { opacity: 1; }

/* panel z wynikiem */
.fd-panel { display: flex; flex-direction: column; gap: 14px; padding: 8px 6px 4px; min-width: 0; }
.fd-k { font-size: 12.5px; color: var(--mut); letter-spacing: 0.02em; }
.fd-top { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; min-height: 72px; }
.fd-top b { font-family: var(--serif); font-weight: 400; font-size: clamp(44px, 5vw, 64px); line-height: 1; letter-spacing: -0.02em; color: var(--tc, var(--ink)); transition: color 0.35s; }
.fd-top span { font-family: var(--serif); font-size: clamp(28px, 3vw, 38px); color: var(--mut); line-height: 1; }
.fwdemo:not(.live) .fd-top b { color: var(--mut2); }
.fd-bars { list-style: none; display: grid; gap: 9px; margin: 0; padding: 0; }
.prose .fd-bars > li { padding-left: 0; }
.prose .fd-bars > li::before { content: none; }
.fd-bars li { display: grid; grid-template-columns: 112px 1fr 44px; align-items: center; gap: 12px; font-size: 14px; color: var(--ink2); transition: opacity 0.3s; }
.fd-bars .lb { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.fd-bars .lb i { width: 8px; height: 8px; border-radius: 50%; background: var(--c); flex: none; }
.fd-bars .tr { height: 10px; border-radius: 99px; background: rgba(255, 255, 255, 0.06); overflow: hidden; }
.fd-bars .tr i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c); opacity: 0.55; transition: width 0.25s ease-out, opacity 0.3s; }
.fd-bars .v { text-align: right; font-variant-numeric: tabular-nums; color: var(--mut); }
.fd-bars li.on { color: var(--ink); }
.fd-bars li.on .tr i { opacity: 1; }
.fd-bars li.on .v { color: var(--ink); }
.fwdemo:not(.live) .fd-bars { opacity: 0.35; }

/* strumień w czasie */
.fd-stream { grid-column: 1 / -1; display: grid; gap: 8px; }
.fd-stream .hd { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.fd-stream canvas { display: block; width: 100%; height: 120px; border-radius: 14px; background: rgba(255, 255, 255, 0.025); }
.fwdemo:not(.live) .fd-stream canvas { opacity: 0.35; }
.fd-tools { display: flex; gap: 8px; flex-wrap: wrap; }
.fd-tools .btn { height: 34px; padding: 0 14px; font-size: 13.5px; }
.fwdemo:not(.live) #fdStop { display: none; }

/* pełny ekran: Fullscreen API albo zapasowa klasa .max (iPhone nie ma requestFullscreen na elemencie) */
.fwdemo:fullscreen, .fwdemo.max {
  width: 100vw; height: 100vh; height: 100dvh; margin: 0; border-radius: 0; padding: 24px;
  background: var(--bg); grid-template-rows: minmax(0, 1fr) auto; overflow: auto;
}
.fwdemo.max { position: fixed; inset: 0; z-index: 100; }
.fwdemo:fullscreen .fd-cam, .fwdemo.max .fd-cam { aspect-ratio: auto; min-height: 0; height: 100%; }
.fwdemo:fullscreen .fd-panel, .fwdemo.max .fd-panel { justify-content: center; }
.fwdemo:fullscreen .fd-stream canvas, .fwdemo.max .fd-stream canvas { height: 150px; }
html.fd-lock, html.fd-lock body { overflow: hidden; }

.fd-note { font-size: 14px; color: var(--mut); }

@media (max-width: 860px) {
  .fwdemo { grid-template-columns: 1fr; padding: 14px; gap: 16px; border-radius: 22px; }
  .fd-panel { padding: 0 2px; }
  .fd-top { min-height: 0; }
  .fd-bars li { grid-template-columns: 100px 1fr 40px; gap: 10px; font-size: 13.5px; }
  .fd-stream canvas { height: 96px; }
  .fwdemo:fullscreen, .fwdemo.max { padding: 14px; grid-template-rows: minmax(0, 1fr) auto auto; }
  .fwdemo:fullscreen .fd-stream canvas, .fwdemo.max .fd-stream canvas { height: 80px; }
  .fwdemo:fullscreen .fd-bars, .fwdemo.max .fd-bars { gap: 6px; }
}
@media (prefers-reduced-motion: reduce) {
  body, .fd-top b, .fd-bars .tr i, .fd-cam video { transition: none; }
}
