/* =============================================================================
   PAGONI — DEMOS
   The five mini tutorial clips. All motion is CSS keyframes on a loop, so none
   of this costs a frame of JavaScript.

   Everything is sized in cqw against the clip's own container, so one component
   renders correctly at 640px wide in the showcase and at 320px on a phone.
   ============================================================================= */

.demo {
  --cycle: 9s;
  position: relative;
  container-type: inline-size;
  container-name: demo;
  aspect-ratio: 16 / 10;
  width: 100%;
  border-radius: var(--rounding-panel);
  overflow: hidden;
  isolation: isolate;
  background:
    radial-gradient(120% 90% at 10% 0%, rgb(63 179 146 / 0.10) 0%, transparent 58%),
    linear-gradient(160deg, var(--raw-void-850) 0%, var(--raw-void-950) 100%);
  box-shadow:
    inset 0 0 0 1px rgb(234 244 240 / 0.09),
    0 2.5rem 5rem -2rem rgb(2 8 7 / 0.8);
}

/* Off screen, the loops stop. Fifteen animated clips all running behind a page
   nobody is looking at is pure waste; the section modules toggle this. */
.demo:not(.is-playing) *,
.demo:not(.is-playing) { animation-play-state: paused !important; }

/* -----------------------------------------------------------------------------
   SHARED FURNITURE
   ----------------------------------------------------------------------------- */
.demo__chrome {
  display: flex;
  align-items: center;
  gap: 1.2cqw;
  padding: 2.4cqw 3cqw;
  border-bottom: 1px solid rgb(234 244 240 / 0.07);
  background: rgb(4 16 13 / 0.5);
}
.demo__dot {
  width: 1.4cqw;
  height: 1.4cqw;
  border-radius: 50%;
  background: rgb(234 244 240 / 0.18);
}
.demo__dot:nth-child(1) { background: rgb(255 102 93 / 0.55); }
.demo__dot:nth-child(2) { background: rgb(242 189 63 / 0.55); }
.demo__dot:nth-child(3) { background: rgb(37 201 138 / 0.55); }
.demo__chromeTitle {
  margin-left: 1.6cqw;
  font-size: 2.2cqw;
  letter-spacing: 0.04em;
  color: var(--foreground-faint);
}

.demo__body {
  position: relative;
  height: calc(100% - 7.4cqw);
  padding: 3.4cqw;
  display: flex;
  flex-direction: column;
  gap: 2.6cqw;
}

.demo__line {
  display: block;
  width: var(--w, 100%);
  height: 1.1cqw;
  min-height: 1px;
  border-radius: 1px;
  background: var(--foreground);
  opacity: 0.2;
}

/* =============================================================================
   01 — DESCRIBE
   ============================================================================= */
.demo--describe { --cycle: 10s; }

.demo--describe .demo__prompt {
  display: flex;
  align-items: center;
  gap: 2cqw;
  padding: 2.4cqw 2.4cqw 2.4cqw 3cqw;
  border-radius: 2cqw;
  border: 1px solid rgb(234 244 240 / 0.12);
  background: rgb(4 16 13 / 0.55);
}
.demo__promptLabel {
  font-size: 2cqw;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--foreground-faint);
  flex: none;
}
.demo__typed {
  flex: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  font-size: 2.6cqw;
  color: var(--foreground-strong);
  white-space: nowrap;
  overflow: hidden;
}
/* The type-on. A width animation with steps() is the one way to reveal text a
   character at a time without measuring anything. */
.demo__typedText {
  display: inline-block;
  overflow: hidden;
  white-space: nowrap;
  width: 0;
  animation: demoType var(--cycle) steps(44, end) infinite;
}
@keyframes demoType {
  0%   { width: 0; }
  38%  { width: 100%; }
  92%  { width: 100%; }
  100% { width: 0; }
}
.demo__caret {
  flex: none;
  width: 1px;
  height: 3cqw;
  margin-left: 0.4cqw;
  background: var(--foreground-signal);
  animation: demoCaret 1.05s steps(1) infinite;
}
@keyframes demoCaret { 0%, 55% { opacity: 1; } 56%, 100% { opacity: 0; } }

.demo__go {
  flex: none;
  padding: 1.4cqw 2.4cqw;
  border-radius: 100cqw;
  background: var(--foreground-signal);
  color: var(--raw-void-950);
  font-size: 2.1cqw;
  font-weight: var(--weight-medium);
  animation: demoGo var(--cycle) ease infinite;
}
@keyframes demoGo {
  0%, 36%  { transform: scale(1);    box-shadow: 0 0 0 0 rgb(191 203 69 / 0); }
  42%      { transform: scale(0.94); box-shadow: 0 0 0 2cqw rgb(191 203 69 / 0.18); }
  48%, 100%{ transform: scale(1);    box-shadow: 0 0 0 0 rgb(191 203 69 / 0); }
}

.demo--describe .demo__outline { display: flex; flex-direction: column; gap: 1.6cqw; }
.demo__outlineRow {
  display: flex;
  align-items: center;
  gap: 1.6cqw;
  opacity: 0;
  transform: translateY(1.2cqw);
  animation: demoRow var(--cycle) ease infinite;
  animation-delay: calc(var(--i) * 0.22s);
}
@keyframes demoRow {
  0%, 42%   { opacity: 0; transform: translateY(1.2cqw); }
  52%, 88%  { opacity: 1; transform: translateY(0); }
  96%, 100% { opacity: 0; transform: translateY(0); }
}
.demo__bullet {
  width: 1.4cqw; height: 1.4cqw; border-radius: 50%;
  background: var(--foreground-accent); flex: none;
}
.demo__outlineText { font-size: 2.2cqw; color: var(--foreground-muted); }

.demo--describe .demo__slides { display: flex; gap: 2cqw; margin-top: auto; }
.demo__slide {
  flex: 1;
  aspect-ratio: 16 / 9;
  border-radius: 1.2cqw;
  padding: 2cqw;
  display: flex;
  flex-direction: column;
  gap: 1.2cqw;
  background: linear-gradient(150deg, var(--raw-teal-900), var(--raw-void-900));
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.08);
  opacity: 0;
  transform: translateY(2.4cqw) scale(0.94);
  animation: demoSlideIn var(--cycle) var(--raw-ease-entrance) infinite;
  animation-delay: calc(0.34s + var(--i) * 0.16s);
}
@keyframes demoSlideIn {
  0%, 56%   { opacity: 0; transform: translateY(2.4cqw) scale(0.94); }
  66%, 90%  { opacity: 1; transform: translateY(0) scale(1); }
  97%, 100% { opacity: 0; transform: translateY(0) scale(1); }
}
.demo__slideBar { display: block; width: 42%; height: 1.6cqw; border-radius: 1px; background: var(--foreground-signal); }

/* =============================================================================
   02 — LAYOUT
   Four arrangements of the same four blocks. Nothing is added or removed.
   ============================================================================= */
.demo--layout { --cycle: 8s; }

.demo--layout .demo__canvas {
  position: relative;
  flex: 1;
  border-radius: 1.6cqw;
  background: rgb(4 16 13 / 0.4);
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.07);
}
.demo__blk {
  position: absolute;
  border-radius: 1.2cqw;
  animation: var(--cycle) var(--raw-ease-entrance) infinite;
}
.demo__blk--a { background: linear-gradient(150deg, var(--raw-jade-700), var(--raw-teal-900)); animation-name: demoBlkA; }
.demo__blk--b { background: var(--raw-royal-800); opacity: 0.85; animation-name: demoBlkB; }
.demo__blk--c { background: var(--raw-chart-400); opacity: 0.8;  animation-name: demoBlkC; }
.demo__blk--d { background: var(--raw-mint-500);  opacity: 0.7;  animation-name: demoBlkD; }

/* Four keyframe stops = four layouts, held then moved. */
@keyframes demoBlkA {
  0%,20%   { left: 5%;  top: 8%;  width: 42%; height: 84%; }
  25%,45%  { left: 5%;  top: 8%;  width: 90%; height: 34%; }
  50%,70%  { left: 5%;  top: 8%;  width: 56%; height: 50%; }
  75%,95%  { left: 5%;  top: 8%;  width: 26%; height: 84%; }
  100%     { left: 5%;  top: 8%;  width: 42%; height: 84%; }
}
@keyframes demoBlkB {
  0%,20%   { left: 52%; top: 8%;  width: 43%; height: 38%; }
  25%,45%  { left: 5%;  top: 48%; width: 28%; height: 44%; }
  50%,70%  { left: 65%; top: 8%;  width: 30%; height: 50%; }
  75%,95%  { left: 35%; top: 8%;  width: 60%; height: 26%; }
  100%     { left: 52%; top: 8%;  width: 43%; height: 38%; }
}
@keyframes demoBlkC {
  0%,20%   { left: 52%; top: 52%; width: 20%; height: 40%; }
  25%,45%  { left: 36%; top: 48%; width: 28%; height: 44%; }
  50%,70%  { left: 5%;  top: 62%; width: 56%; height: 30%; }
  75%,95%  { left: 35%; top: 38%; width: 60%; height: 26%; }
  100%     { left: 52%; top: 52%; width: 20%; height: 40%; }
}
@keyframes demoBlkD {
  0%,20%   { left: 75%; top: 52%; width: 20%; height: 40%; }
  25%,45%  { left: 67%; top: 48%; width: 28%; height: 44%; }
  50%,70%  { left: 65%; top: 62%; width: 30%; height: 30%; }
  75%,95%  { left: 35%; top: 68%; width: 60%; height: 24%; }
  100%     { left: 75%; top: 52%; width: 20%; height: 40%; }
}

.demo__optionRow { display: flex; gap: 1.4cqw; justify-content: center; }
.demo__option {
  padding: 1.2cqw 2.2cqw;
  border-radius: 100cqw;
  border: 1px solid rgb(234 244 240 / 0.12);
  font-size: 2cqw;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--foreground-faint);
  animation: demoOption var(--cycle) steps(1) infinite;
  animation-delay: calc(var(--i) * (var(--cycle) / 4));
}
@keyframes demoOption {
  0%, 25%   { color: var(--raw-void-950); background: var(--foreground-signal); border-color: var(--foreground-signal); }
  26%, 100% { color: var(--foreground-faint); background: transparent; border-color: rgb(234 244 240 / 0.12); }
}

/* =============================================================================
   03 — BRAND
   ============================================================================= */
.demo--brand { --cycle: 8.5s; }

.demo--brand .demo__kit {
  display: flex;
  align-items: center;
  gap: 2.4cqw;
  padding: 2.2cqw 2.6cqw;
  border-radius: 1.6cqw;
  border: 1px solid rgb(234 244 240 / 0.12);
  background: rgb(4 16 13 / 0.5);
}
.demo__kitLabel, .demo__kitType {
  font-size: 2cqw;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--foreground-faint);
}
.demo__kitType { margin-left: auto; text-transform: none; letter-spacing: 0.02em; }
.demo__swatches { display: flex; gap: 1cqw; }
.demo__swatch {
  width: 3.2cqw; height: 3.2cqw; border-radius: 0.8cqw;
  transform: scale(0.6); opacity: 0.35;
  animation: demoSwatch var(--cycle) var(--raw-ease-entrance) infinite;
  animation-delay: calc(var(--i) * 0.1s);
}
@keyframes demoSwatch {
  0%, 8%    { transform: scale(0.6); opacity: 0.35; }
  18%, 92%  { transform: scale(1);   opacity: 1; }
  100%      { transform: scale(0.6); opacity: 0.35; }
}
.demo__swatch--teal  { background: var(--raw-teal-900); }
.demo__swatch--jade  { background: var(--raw-jade-700); }
.demo__swatch--mint  { background: var(--raw-mint-500); }
.demo__swatch--chart { background: var(--raw-chart-400); }
.demo__swatch--royal { background: var(--raw-royal-800); }

.demo--brand .demo__deck {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 2cqw;
}
.demo__deckSlide {
  border-radius: 1.2cqw;
  padding: 1.8cqw;
  display: flex;
  flex-direction: column;
  gap: 1cqw;
  /* Starts grey; the kit lands and the whole deck repaints AT ONCE, which is
     the claim being made. The stagger is small on purpose — a slow cascade
     would say "slide by slide", which is the opposite. */
  background: var(--raw-void-850);
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.07);
  animation: demoRepaint var(--cycle) var(--raw-ease-entrance) infinite;
  animation-delay: calc(var(--i) * 0.035s);
}
@keyframes demoRepaint {
  0%, 20%   { background: var(--raw-void-850); }
  30%, 90%  { background: linear-gradient(150deg, var(--raw-teal-900), var(--raw-void-900)); }
  100%      { background: var(--raw-void-850); }
}
.demo__deckBar {
  display: block; width: 46%; height: 1.4cqw; border-radius: 1px;
  background: var(--foreground-faint);
  animation: demoRepaintBar var(--cycle) var(--raw-ease-entrance) infinite;
  animation-delay: calc(var(--i) * 0.035s);
}
@keyframes demoRepaintBar {
  0%, 20%   { background: var(--foreground-faint); width: 46%; }
  30%, 90%  { background: var(--foreground-signal); width: 60%; }
  100%      { background: var(--foreground-faint); width: 46%; }
}

/* =============================================================================
   04 — CHART
   ============================================================================= */
.demo--chart { --cycle: 8s; }

.demo--chart .demo__body { flex-direction: row; gap: 3cqw; }

.demo--chart .demo__table {
  flex: 0 0 32%;
  display: flex;
  flex-direction: column;
  gap: 1.4cqw;
  padding: 2cqw;
  border-radius: 1.4cqw;
  background: rgb(4 16 13 / 0.45);
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.07);
}
.demo__tableRow {
  display: flex; align-items: center; justify-content: space-between; gap: 1.4cqw;
  opacity: 0;
  animation: demoTableRow var(--cycle) ease infinite;
  animation-delay: calc(var(--i) * 0.07s);
}
@keyframes demoTableRow {
  0%, 4%    { opacity: 0; transform: translateX(-1.4cqw); }
  14%, 92%  { opacity: 1; transform: none; }
  100%      { opacity: 0; transform: translateX(-1.4cqw); }
}
.demo__cell {
  font-size: 2cqw;
  color: var(--foreground-muted);
  font-variant-numeric: tabular-nums;
}

.demo--chart .demo__chart {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.8cqw;
  padding: 2.4cqw;
  border-radius: 1.4cqw;
  background: rgb(4 16 13 / 0.45);
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.07);
  min-width: 0;
}
.demo__bars { flex: 1; display: flex; align-items: flex-end; gap: 2cqw; min-height: 0; }
.demo__bar {
  flex: 1;
  height: 0;
  border-radius: 0.6cqw 0.6cqw 0 0;
  background: linear-gradient(to top, var(--raw-teal-900), var(--raw-mint-500));
  animation: demoBar var(--cycle) var(--raw-ease-entrance) infinite;
  animation-delay: calc(0.3s + var(--i) * 0.06s);
}
@keyframes demoBar {
  0%, 22%   { height: 0; }
  40%, 90%  { height: var(--h); }
  100%      { height: 0; }
}
.demo__bar:last-child { background: linear-gradient(to top, var(--raw-olive-600), var(--raw-chart-400)); }
.demo__chartLabel { font-size: 2cqw; letter-spacing: 0.1em; text-transform: uppercase; color: var(--foreground-faint); }

/* =============================================================================
   05 — PRESENT
   ============================================================================= */
.demo--present { --cycle: 6s; }

.demo--present .demo__body { flex-direction: row; gap: 2.6cqw; }

.demo--present .demo__now {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1.6cqw;
  justify-content: center;
  padding: 3.4cqw;
  border-radius: 1.6cqw;
  background: linear-gradient(150deg, var(--raw-teal-900), var(--raw-void-900));
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.09);
  min-width: 0;
}
.demo__nowMark {
  width: 5cqw; height: 5cqw; border-radius: 50%;
  background: radial-gradient(circle,
    var(--raw-chart-400) 0 18%, var(--raw-royal-800) 18% 42%,
    var(--raw-mint-500) 42% 66%, var(--raw-teal-900) 66% 88%, transparent 88%);
}
.demo__nowTitle {
  font-size: 4.4cqw;
  font-weight: var(--weight-display);
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.demo--present .demo__side { flex: 0 0 32%; display: flex; flex-direction: column; gap: 2cqw; }
.demo__sideLabel {
  display: block;
  font-size: 1.9cqw; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--foreground-faint); margin-bottom: 1cqw;
}
.demo__nextSlide {
  aspect-ratio: 16 / 9;
  border-radius: 1cqw;
  padding: 1.6cqw;
  display: flex; flex-direction: column; gap: 1cqw;
  background: var(--raw-void-850);
  box-shadow: inset 0 0 0 1px rgb(234 244 240 / 0.07);
}
.demo__nextBar { display: block; width: 40%; height: 1.2cqw; border-radius: 1px; background: var(--foreground-accent); }

.demo__clock {
  display: flex; align-items: baseline;
  font-size: 5cqw;
  font-weight: var(--weight-display);
  font-variant-numeric: tabular-nums;
  color: var(--foreground-signal);
}
.demo__colon { animation: demoCaret 1s steps(1) infinite; }
/* Counting seconds without JavaScript: a strip of numbers stepped past a
   one-line window. */
.demo__seconds {
  display: inline-block;
  height: 1em;
  overflow: hidden;
  line-height: 1;
}
.demo__seconds::before {
  content: '18\A 19\A 20\A 21\A 22\A 23';
  white-space: pre;
  display: block;
  animation: demoSeconds var(--cycle) steps(6) infinite;
}
@keyframes demoSeconds { from { transform: translateY(0); } to { transform: translateY(-6em); } }

.demo__notes { display: flex; flex-direction: column; gap: 1.2cqw; margin-top: auto; }

/* =============================================================================
   REDUCED MOTION
   Hold on a composed state rather than an empty one: every clip's keyframes are
   authored so that "paused at the end" is a finished picture.
   ============================================================================= */
@media (prefers-reduced-motion: reduce) {
  .demo *, .demo { animation: none !important; }
  .demo__typedText { width: 100% !important; }
  .demo__outlineRow, .demo__slide, .demo__tableRow { opacity: 1 !important; transform: none !important; }
  .demo__swatch { transform: none !important; opacity: 1 !important; }
  .demo__bar { height: var(--h) !important; }
  .demo__blk--a { left: 5%;  top: 8%;  width: 42%; height: 84%; }
  .demo__blk--b { left: 52%; top: 8%;  width: 43%; height: 38%; }
  .demo__blk--c { left: 52%; top: 52%; width: 20%; height: 40%; }
  .demo__blk--d { left: 75%; top: 52%; width: 20%; height: 40%; }
  .demo__deckSlide { background: linear-gradient(150deg, var(--raw-teal-900), var(--raw-void-900)); }
  .demo__seconds::before { content: '18'; }
}
