/* PowerGridTools website: the live demo (tasks demo-hosting and site-live-demo-and-electra, docs/saas/demo-hosting.md,
   docs/site/live-demo-and-electra.md). Loaded by every page's head; /site/base/live-demo.js toggles the hidden
   attributes. Consumes the concept's --pgt-* tokens. */

.pgt-demo__note { color: var(--pgt-color-muted); max-width: 46rem; }

.pgt-demo__bar {
  display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
  gap: calc(var(--pgt-space-unit) * 2); margin-bottom: calc(var(--pgt-space-unit) * 2);
}
.pgt-demo__tabs { display: flex; flex-wrap: wrap; gap: var(--pgt-space-unit); }
.pgt-demo__tab {
  display: grid; gap: calc(var(--pgt-space-unit) * 0.25); min-width: 12rem; max-width: 22rem;
  padding: var(--pgt-space-unit) calc(var(--pgt-space-unit) * 2);
  border: 1px solid var(--pgt-color-border); border-bottom-width: 3px; border-radius: var(--pgt-radius-s);
  background: var(--pgt-color-bg); color: var(--pgt-color-text); text-decoration: none;
}
.pgt-demo__tab:hover { background: var(--pgt-color-surface); }
.pgt-demo__tab[aria-selected="true"] { border-color: var(--pgt-color-primary); background: var(--pgt-color-surface); }
.pgt-demo__tab-title { font-weight: 700; color: var(--pgt-color-primary); }
.pgt-demo__tab-text { font-size: 0.875rem; color: var(--pgt-color-muted); }

/* The frame fills the content area: the container width and the viewport height below the header. */
.pgt-demo__stage { position: relative; background: var(--pgt-color-bg); }
.pgt-demo__frame {
  display: block; width: 100%; height: calc(100vh - 14rem); min-height: 36rem;
  border: 1px solid var(--pgt-color-border); border-radius: var(--pgt-radius-s); background: var(--pgt-color-bg);
}
.pgt-demo__stage:fullscreen { padding: 0; }
.pgt-demo__stage:fullscreen .pgt-demo__frame { height: 100vh; min-height: 0; border: 0; border-radius: 0; }

.pgt-demo__unsupported {
  padding: calc(var(--pgt-space-unit) * 3); border: 1px solid var(--pgt-color-border);
  border-left: 4px solid var(--pgt-color-primary); border-radius: var(--pgt-radius-s);
  background: var(--pgt-color-surface);
}
.pgt-demo__unsupported > :last-child, .pgt-demo__noscript { margin-bottom: 0; }

/* Devices without the demo: the example's image, its "Open live demo" button, and the notice it reveals below. */
.pgt-demo__poster .pgt-figure { margin: 0; }
.pgt-demo__poster .pgt-demo__unsupported { margin-top: calc(var(--pgt-space-unit) * 2); }
.pgt-demo__poster .pgt-demo__unsupported:focus { outline: none; }

/* Live-demo entry points elsewhere on the site stay hidden until live-demo.js allows them. */
[data-pgt-live-demo][hidden], [data-pgt-live-demo-unsupported][hidden], [data-pgt-live-demo-embed][hidden],
.pgt-demo [hidden], .pgt-figure__demo [hidden] { display: none !important; }

/* Product images of the demo examples (site/fragments/ui :: figure with demoExample, task site-live-demo-and-electra):
   the overlay sits in the image's top right corner. */
.pgt-figure__media { position: relative; }
.pgt-figure__media > img { display: block; }
.pgt-figure__demo {
  position: absolute; top: calc(var(--pgt-space-unit) * 1.5); right: calc(var(--pgt-space-unit) * 1.5); z-index: 2;
  display: flex; flex-wrap: wrap; justify-content: flex-end; gap: var(--pgt-space-unit); margin: 0;
}
.pgt-figure__demo .pgt-btn { box-shadow: 0 0 0 3px var(--pgt-color-bg); }

/* The embedded demo (demoEmbed): the frame covers the image, which stays visible as the poster until the demo is
   ready; until then the frame takes no clicks. */
.pgt-figure__embed { position: absolute; inset: 0; z-index: 1; pointer-events: none; }
.pgt-figure__frame {
  display: block; width: 100%; height: 100%; border: 1px solid var(--pgt-color-border); background: transparent;
  opacity: 0; transition: opacity 0.3s ease;
}
.pgt-figure.is-ready .pgt-figure__embed { pointer-events: auto; }
.pgt-figure.is-ready .pgt-figure__frame { opacity: 1; background: var(--pgt-color-bg); }
.pgt-figure.is-loading .pgt-figure__media::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; z-index: 2;
  background: linear-gradient(90deg, transparent, var(--pgt-color-primary), transparent);
  background-size: 40% 100%; background-repeat: no-repeat; animation: pgt-demo-loading 1.4s linear infinite;
}
@keyframes pgt-demo-loading { from { background-position: -40% 0; } to { background-position: 140% 0; } }

/* "Full screen": the whole figure; the frame fills the screen and the overlay moves to the bottom right corner. */
.pgt-figure:fullscreen { margin: 0; background: var(--pgt-color-bg); }
.pgt-figure:fullscreen .pgt-figure__media { width: 100vw; height: 100vh; }
.pgt-figure:fullscreen .pgt-figure__media > img, .pgt-figure:fullscreen figcaption { display: none; }
.pgt-figure:fullscreen .pgt-figure__frame { border: 0; }
.pgt-figure:fullscreen .pgt-figure__demo { top: auto; bottom: calc(var(--pgt-space-unit) * 1.5); }

@media (prefers-reduced-motion: reduce) {
  .pgt-figure__frame { transition: none; }
  .pgt-figure.is-loading .pgt-figure__media::after { animation: none; background-position: 50% 0; }
}
@media print {
  .pgt-figure__demo, .pgt-figure__embed { display: none !important; }
}

@media (max-width: 47.99rem) {
  .pgt-demo__tab { min-width: 0; flex: 1 1 100%; }
}
