/* ==========================================================================
   DEMOS — the live product section
   --------------------------------------------------------------------------
   Three real applications embedded in the page and driveable from it. The
   page's job is to get out of the way: a switcher, a frame, and a row of
   questions you can fire into whichever app is loaded.

   Loads AFTER style.css / motion.css / search.css and BEFORE mobile.css and
   center.css, so the mobile layer and the site-wide centring still win.
   ========================================================================== */

/* The lede needs air under a two-line headline; the site's base .lead has no
   top margin because it usually follows an eyebrow, not an h2. */
#demos .section-head .lead { margin-top: 20px; }

/* ---- Switcher -------------------------------------------------------------
   Three buttons that look like the products they load. Each carries its own
   accent so the choice is made on colour before it is made on the label. */
.demo-switch {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.demo-tab {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px 18px 22px;
  text-align: left;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface-canvas);
  color: var(--mist);
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
              border-color 0.3s ease, background 0.3s ease, color 0.3s ease;
}
.demo-tab:hover { transform: translateY(-3px); color: var(--ink); }

/* The accent lives on a left edge rather than on the whole panel, so three
   different-coloured tabs sitting side by side never fight each other. */
.demo-tab::before {
  content: "";
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--demo-accent, var(--accent-fill));
  opacity: 0;
  transition: opacity 0.3s ease;
}
.demo-tab[aria-selected="true"]::before { opacity: 1; }
.demo-tab[aria-selected="true"] {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--demo-accent) 45%, transparent);
  background:
    linear-gradient(100deg,
      color-mix(in srgb, var(--demo-accent) 12%, transparent),
      transparent 62%),
    var(--surface-canvas);
}

.demo-tab-top { display: flex; align-items: center; gap: 10px; }
.demo-tab-dot {
  width: 26px; height: 26px;
  border-radius: 8px;
  flex: none;
  background: var(--demo-grad);
}
.demo-tab-name {
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.12rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}
.demo-tab-for {
  margin-left: auto;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mist-dim);
}
.demo-tab-desc { font-size: 0.88rem; line-height: 1.5; }

/* ---- The frame ------------------------------------------------------------
   A window chrome around the iframe. It reads as "this is a real running
   application", which a bare rectangle does not. */
.demo-window {
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  box-shadow: none;
  transition: box-shadow 0.5s ease;
}

.demo-chrome {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-canvas);
}
.demo-lights { display: flex; gap: 7px; flex: none; }
.demo-lights i {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--surface-pebble);
}
.demo-lights i:first-child { background: rgba(255, 95, 87, 0.75); }
.demo-lights i:nth-child(2) { background: rgba(255, 189, 46, 0.7); }
.demo-lights i:nth-child(3) { background: rgba(40, 200, 64, 0.65); }

.demo-url {
  flex: 1;
  min-width: 0;
  max-width: 420px;
  margin: 0 auto;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--surface-canvas);
  border: 1px solid var(--line);
  font-size: 0.76rem;
  color: var(--mist-dim);
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.demo-live {
  flex: none;
  display: flex; align-items: center; gap: 7px;
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--mist-dim);
}
.demo-live i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--demo-accent);
  box-shadow: none;
  animation: demoPulse 2.4s ease-in-out infinite;
}
@keyframes demoPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.demo-viewport { position: relative; aspect-ratio: 16 / 9; background: var(--void-2); }
.demo-viewport iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  opacity: 0;
  transition: opacity 0.55s ease;
}
.demo-viewport iframe.is-ready { opacity: 1; }

/* ---- Loading skeleton -------------------------------------------------
   Held until the embedded app posts back that it has booted. A static
   impression of the product's own topbar/sidebar/KPI layout — the same
   shell every one of the three apps actually has — rather than a spinner,
   so the page reads as "your dashboard is arriving" instead of "please
   wait". Each embedded app also skeletons its own content the same way on
   first load (see js/app.js in demos/); this is the outer shell for the
   moment before that app has even painted. */
.demo-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 18px;
  gap: 12px;
  transition: opacity 0.4s ease;
  pointer-events: none;
}
.demo-loading.is-gone { opacity: 0; }

.demo-skel-top { display: flex; align-items: center; gap: 10px; flex: none; }
.demo-skel-top .skel:nth-child(1) { width: 90px; height: 12px; }
.demo-skel-top .skel:nth-child(2) { flex: 1; max-width: 280px; height: 12px; }
.demo-skel-top .skel:nth-child(3) { margin-left: auto; width: 30px; height: 30px; border-radius: 50%; }

.demo-skel-body { flex: 1; min-height: 0; display: flex; gap: 16px; }
.demo-skel-side { flex: none; width: 14%; min-width: 60px; display: flex; flex-direction: column; gap: 12px; padding-top: 6px; }
.demo-skel-side .skel { height: 10px; width: 100%; }
.demo-skel-side .skel:first-child { width: 65%; }

.demo-skel-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 10px; }
.demo-skel-kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; flex: none; }
.demo-skel-kpis .skel { height: 15%; min-height: 40px; }
.demo-skel-block { flex: 1; min-height: 30px; }
.demo-skel-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; flex: none; height: 32%; min-height: 50px; }

.skel {
  display: block;
  border-radius: 6px;
  background: linear-gradient(100deg, var(--fill-subtle) 30%, var(--fill-hover) 50%, var(--fill-subtle) 70%);
  background-size: 250% 100%;
  animation: demo-skel-shimmer 1.6s ease-in-out infinite;
}
@keyframes demo-skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
  .skel { animation: none; background: var(--fill-hover); }
}

/* ---- Screenshot shimmer -------------------------------------------------
   The still fallbacks (mobile embed swap, no-hover row thumbnails) are real
   photographs, not generated UI, so they get the plainer "shimmer until
   loaded" treatment: the gradient sits on the <img> itself as a background,
   which shows through until the image has something to paint over it, then
   fades out once the real photo has decoded. */
.demo-row-thumb,
.demo-still img {
  background: linear-gradient(100deg, var(--fill-subtle) 30%, var(--fill-hover) 50%, var(--fill-subtle) 70%);
  background-size: 250% 100%;
  animation: demo-skel-shimmer 1.6s ease-in-out infinite;
  opacity: 0;
  transition: opacity 0.4s ease;
}
.demo-row-thumb.is-loaded,
.demo-still img.is-loaded {
  animation: none;
  background: none;
  opacity: 1;
}
@media (prefers-reduced-motion: reduce) {
  .demo-row-thumb, .demo-still img { animation: none; background: var(--fill-hover); }
}

/* ---- Try-this row ---------------------------------------------------------
   The point of the whole page. Clicking one of these posts the question into
   the running app, which then answers it for real. */
.demo-try {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}
.demo-try-label {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mist-dim);
  margin-right: 4px;
}
.demo-chip {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: var(--surface-canvas);
  color: var(--mist);
  font-size: 0.88rem;
  cursor: pointer;
  transition: color 0.25s ease, border-color 0.25s ease, background 0.25s ease,
              transform 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}
.demo-chip:hover {
  color: var(--ink);
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--demo-accent) 55%, transparent);
  background: color-mix(in srgb, var(--demo-accent) 10%, transparent);
}
.demo-open {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
  color: var(--accent);
  text-decoration: none;
  white-space: nowrap;
}
.demo-open svg { width: 15px; height: 15px; }
.demo-open:hover { text-decoration: underline; }

/* The still shown instead of the frame on phones. */
.demo-still { display: none; }

/* ---- Narrow screens -------------------------------------------------------
   A 1600px-wide application squeezed into a 360px column is not a demo, it is
   a smudge. Below the breakpoint the frame is replaced by a still and a link
   that opens the real thing full screen. */
@media (max-width: 900px) {
  .demo-switch { grid-template-columns: 1fr; gap: 10px; }
  .demo-tab { padding: 14px 16px 14px 18px; }
  .demo-tab-desc { display: none; }
  .demo-tab-for { display: none; }

  .demo-viewport { display: none; }
  .demo-still {
    display: block;
    position: relative;
    aspect-ratio: 16 / 9;
    background: var(--void-2);
  }
  .demo-still img {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: top left;
    display: block;
  }
  .demo-still::after {
    content: "";
    position: absolute; inset: 0;
    background: linear-gradient(180deg, transparent 45%, rgba(0, 0, 0, 0.55));
  }
  .demo-still-cta {
    position: absolute;
    left: 50%; bottom: 16px;
    transform: translateX(-50%);
    z-index: 2;
    white-space: nowrap;
  }

  .demo-try { margin-top: 16px; }
  .demo-try-label { width: 100%; margin-bottom: 2px; }
  .demo-chip { font-size: 0.84rem; padding: 8px 14px; }
  .demo-open { margin-left: 0; width: 100%; margin-top: 4px; }
}

@media (prefers-reduced-motion: reduce) {
  .demo-tab, .demo-chip { transition: none; }
  .demo-live i { animation: none; }
}

/* ---- Homepage teaser ------------------------------------------------------
   Three cards on index.html pointing here. They borrow the site's .card and
   only add the product swatch, so they sit inside the existing grid rhythm
   rather than introducing a fourth card style. */
.teaser-card { display: block; }
/* .teaser-dot retired with the card layout — see the row list below. */

.teaser-card:hover { border-color: color-mix(in srgb, var(--teaser) 45%, transparent); }
.teaser-card:hover .card-link { color: var(--teaser); }


/* ==========================================================================
   Live Demos — Hover Image Reveal (OriginKit)

   The card row is gone. Each demo is a full-width row: number, name,
   description, arrow, divided by hairlines. On a fine pointer the OriginKit
   component floats the app's real screenshot alongside the cursor; without
   one the same rows show an inline thumbnail instead, because hover cannot be
   the only way to see the product.

   The component's textColor/dimColor props are sourced from these two tokens
   so the section follows the theme — see deviation 3 in js/components/hover-image-reveal.js.
   ========================================================================== */
.demo-reveal {
  --hir-text: var(--ink);
  --hir-dim: var(--mist);

  position: relative;
  /* Wider than the 980px text measure: the extra room on the right is where
     the floating frame lives, so it never has to sit on the label. */
  max-width: 1080px;
  margin: 48px auto 0;
  border-top: 1px solid var(--line);
  text-align: left;
}

.demo-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(130px, 250px) minmax(0, 340px) 1fr 34px;
  align-items: center;
  gap: 24px;
  /* The 1fr is a deliberate empty column — the frame's parking space. */
  padding: 30px 8px 32px;
  border-bottom: 1px solid var(--line);
  color: var(--hir-text);
  text-decoration: none;
  transition: color 0.2s ease;   /* the component's own 0.2s colour ease */
}
.demo-row.is-dim { color: var(--hir-dim); }
.demo-row.is-dim .demo-row-desc,
.demo-row.is-dim .demo-row-num { color: inherit; }

.demo-row-num {
  font-family: var(--font-body);
  font-size: var(--text-caption);
  letter-spacing: 0.04em;
  color: var(--mist);
  transition: color 0.2s ease;
}

/* The roll: the label is rendered twice and the pair slides up 100%, so the
   duplicate lands exactly where the original was. The clip lives here. */
.demo-row-name {
  display: block;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: clamp(28px, 3.4vw, 44px);
  font-weight: var(--font-weight-semibold);
  line-height: 1.05;
  letter-spacing: -0.012em;
}
.demo-row-name .hir-roll { display: block; position: relative; will-change: transform; }
.demo-row-name .hir-copy { display: block; white-space: pre; }
.demo-row-name .hir-copy-ghost { position: absolute; top: 100%; left: 0; width: 100%; }

.demo-row-desc {
  font-size: var(--text-body-sm);
  line-height: var(--leading-body-sm);
  letter-spacing: var(--tracking-body-sm);
  color: var(--mist);
  max-width: 46ch;
  transition: color 0.2s ease;
}

.demo-row-go {
  grid-column: 5;
  justify-self: end;
  display: flex;
  color: var(--mist);
  transition: transform var(--transition), color var(--transition);
}
.demo-row-go svg { width: 22px; height: 22px; }
.demo-row.is-hovered .demo-row-go { color: var(--ink); transform: translateX(4px); }

/* The floating frame. Positioned by transform from js; nothing here animates. */
.hir-frame {
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  border: 1px solid var(--line);
  background: var(--surface-white);
}
.hir-layer { position: absolute; inset: 0; overflow: hidden; will-change: transform; }
.hir-layer img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hir-layer-empty { background: var(--surface-pebble); }

/* The inline thumbnail is the no-hover path only. */
.demo-row-thumb { display: none; }

/* ---- No fine pointer: no floating frame, so the screenshot comes inline ---- */
[data-hir-static] .demo-row {
  grid-template-columns: 40px minmax(0, 1fr) 104px;
  grid-template-areas:
    "num  name  thumb"
    "num  desc  thumb";
  gap: 6px 20px;
  align-items: start;
  padding: 22px 4px 24px;
}
[data-hir-static] .demo-row-num  { grid-area: num; padding-top: 6px; }
[data-hir-static] .demo-row-name { grid-area: name; font-size: clamp(22px, 6vw, 30px); }
[data-hir-static] .demo-row-desc { grid-area: desc; max-width: none; }
[data-hir-static] .demo-row-go   { display: none; }
[data-hir-static] .demo-row-thumb {
  display: block;
  grid-area: thumb;
  width: 104px;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  align-self: center;
}

@media (max-width: 860px) {
  .demo-reveal { margin-top: 32px; }
}
