/*
 * Workflows section (#demos): the copy on the left makes three promises; the bento on the right
 * proves each one with a coded tile that shares the bullet's number. Hovering either side lights
 * its pair. Scenes: workflows, build-fix and find-file in ./crux-demos.js.
 */
#demos {
  --cw-surface: #09090b;
  --cw-line: #ffffff14;
  --cw-line-linked: #ffffff3d;
  --cw-fg: #f6f8ff;
  --cw-fg-2: #c5cfde;
  --cw-fg-3: #8d97a8;
  --cw-detail: #a1acbd;
  --cw-sky: #a5d8ff;
  --cw-ease: cubic-bezier(.22, 1, .36, 1);
}

/* ---------- copy ---------- */
/* The desktop column is 400px wide: 48px wraps the heading to three lines, 38px keeps it to two. */
@media (min-width: 1200px) {
  #demos h2.framer-styles-preset-1uurn3n { --framer-font-size: 38px; --framer-letter-spacing: -1.6px; text-wrap: balance; }
}
#demos li[data-cw] { gap: 16px; }
#demos .cw-index {
  flex: none; width: 20px; padding-top: 4px;
  color: var(--cw-fg-3); font: 500 12px/1.4 'Geist Mono', ui-monospace, monospace; letter-spacing: .04em;
  transition: color 240ms var(--cw-ease);
}
#demos .cw-detail {
  margin: 6px 0 0; color: var(--cw-detail);
  font: 400 14px/1.55 Geist, -apple-system, BlinkMacSystemFont, sans-serif; text-wrap: pretty;
}
#demos .cw-detail code { color: var(--cw-fg-2); font: 500 .9em/1 'Geist Mono', ui-monospace, monospace; }

/* ---------- bento ---------- */
#demos .cw-bento {
  display: grid !important; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  align-items: stretch; overflow: visible; min-width: 0;
}
#demos .cw-tile {
  position: relative; display: flex; flex-direction: column; min-width: 0; margin: 0; overflow: hidden;
  border: 1px solid var(--cw-line); border-radius: 16px; background: var(--cw-surface);
  transition: border-color 240ms var(--cw-ease);
}
#demos .cw-tile--find { grid-column: 1 / -1; }
/* Own this layout directly; the old template class sets width:1px and padding:36px. */
#demos .cw-tile--find { flex: none; width: 100%; height: auto; padding: 0; place-content: stretch; align-items: stretch; }
#demos .cw-tile-head {
  position: relative; z-index: 2; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 16px;
  border-bottom: 1px solid var(--cw-line); color: var(--cw-fg-2);
  font: 500 11px/1 'Geist Mono', ui-monospace, monospace; letter-spacing: .04em; white-space: nowrap;
}
#demos .cw-tile--find .cw-tile-head { border-bottom: 0; background: var(--cw-surface); }
#demos .cw-tile-index { color: var(--cw-sky); }
#demos .cw-tile-name { color: var(--cw-fg); }
#demos .cw-tile-meta { margin-left: auto; overflow: hidden; color: var(--cw-fg-3); text-overflow: ellipsis; }
#demos .cw-tile-body { position: relative; z-index: 1; flex: none; height: 280px; }
#demos .cw-tile--find .cw-tile-body { height: 340px; }
#demos .cw-tile-body > [data-crux-demo] { position: absolute; inset: 0; width: 100%; height: 100%; }
/* Tile surfaces show through to the shared ASCII artwork. */
#demos .cw-bento .cd-host,
#demos .cw-bento .cd-stage { background: transparent; }

/* A bullet and its tile light up together. */
#demos .cw-tile:hover,
#demos:has(li[data-cw="1"]:hover) .cw-tile[data-cw="1"],
#demos:has(li[data-cw="2"]:hover) .cw-tile[data-cw="2"],
#demos:has(li[data-cw="3"]:hover) .cw-tile[data-cw="3"] { border-color: var(--cw-line-linked); }
#demos li[data-cw]:hover .cw-index,
#demos:has(.cw-tile[data-cw="1"]:hover) li[data-cw="1"] .cw-index,
#demos:has(.cw-tile[data-cw="2"]:hover) li[data-cw="2"] .cw-index,
#demos:has(.cw-tile[data-cw="3"]:hover) li[data-cw="3"] .cw-index { color: var(--cw-sky); }

/* Tiles rise in as they scroll into view, where scroll-driven animation exists. */
@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    #demos .cw-tile { animation: cw-rise linear both; animation-timeline: view(); animation-range: entry 0% entry 55%; }
    #demos .cw-tile--steps { animation-range: entry 8% entry 63%; }
  }
}
@keyframes cw-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

@media (min-width: 1200px) {
  #demos .framer-zabbv { gap: 64px; align-items: center; }
  #demos .framer-1pl5b91 { flex: 0 1 400px; width: auto; min-width: 0; }
  #demos .cw-bento { flex: 1 1 0; width: auto; }
}
@media (min-width: 768px) and (max-width: 1199.98px) {
  #demos .cw-tile-body { height: 300px; }
  #demos .cw-tile--find .cw-tile-body { height: 400px; }
}
@media (max-width: 767.98px) {
  #demos .cw-bento { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  #demos .cw-tile--find .cw-tile-body { height: 350px; }
  #demos .cw-detail { font-size: 13.5px; }
}

/* ---------- 01 · .agents → runtimes ---------- */
.cw-shared {
  position: absolute; inset: 0; display: flex; flex-direction: column; padding: 22px 16px 20px;
  background: radial-gradient(120% 70% at 50% 0%, #0b1631, transparent 62%);
}
.cw-src {
  align-self: center; width: 268px; overflow: hidden;
  border: 1px solid var(--cd-border-strong); border-radius: 12px; background: var(--cd-chrome);
  box-shadow: 0 14px 32px -20px #000;
}
.cw-src-head {
  display: flex; align-items: center; gap: 9px; height: 34px; padding: 0 12px;
  border-bottom: 1px solid var(--cd-border); color: var(--cd-fg); font: 500 12.5px/1 var(--cd-code);
}
.cw-src-counts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 0; }
.cw-src-counts div { display: flex; flex-direction: column-reverse; gap: 4px; padding: 9px 12px 10px; }
.cw-src-counts div + div { border-left: 1px solid var(--cd-border); }
.cw-src-counts dd { margin: 0; color: var(--cd-fg); font: 500 17px/1 var(--cd-ui); letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.cw-src-counts dt { color: var(--cd-fg-3); font: 11px/1 var(--cd-ui); }
/* Spans the full design width so its 420-unit viewBox lines up with the runtime columns. */
.cw-wires { display: block; flex: 1; width: calc(100% + 32px); min-height: 36px; margin: 0 -16px; overflow: visible; }
.cw-wires path { fill: none; stroke: var(--cd-border-strong); stroke-width: 1.25; vector-effect: non-scaling-stroke; }
.cw-wires .cw-wire-live { stroke: var(--cd-accent-text); opacity: 0; transition: opacity 360ms var(--cd-ease); }
.cw-wires g.is-on .cw-wire-live { opacity: 1; }
.cw-rts { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cw-rt {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 12px 6px 11px;
  border: 1px solid var(--cd-border-strong); border-radius: 10px; background: var(--cd-chrome);
}
.cw-rt::after {
  content: ""; position: absolute; inset: -1px; border-radius: inherit; pointer-events: none;
  box-shadow: 0 0 0 1px var(--cd-accent), 0 0 22px rgba(0, 85, 255, .28); opacity: 0; transition: opacity 360ms var(--cd-ease);
}
.cw-rt.is-on::after { opacity: 1; }
.cw-rt b { color: var(--cd-fg); font: 500 12.5px/1.2 var(--cd-ui); white-space: nowrap; }
.cw-rt code { color: var(--cd-fg-3); font: 11px/1 var(--cd-code); white-space: nowrap; transition: color 360ms var(--cd-ease); }
.cw-rt.is-on code { color: var(--cd-accent-text); }
.cw-logo { width: 18px; height: 18px; flex: none; object-fit: contain; filter: brightness(0) invert(1); opacity: .9; }

/* ---------- 02 · /build-fix, same steps for every provider ---------- */
.cw-cmd { position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; padding: 20px 16px; }
.cw-composer {
  display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 8px 0 14px; flex: none;
  border: 1px solid var(--cd-border-strong); border-radius: 12px; background: var(--cd-chrome);
}
.cw-typed { display: flex; flex: 1; align-items: center; min-width: 0; color: var(--cd-fg); font: 13.5px/1 var(--cd-code); }
.cw-caret { width: 1.5px; height: 15px; margin-left: 1px; background: var(--cd-accent-text); animation: cd-blink 1s steps(1) infinite; }
.cw-provider { display: grid; height: 28px; border-radius: 8px; background: var(--cd-elevated); }
.cw-provider-item {
  grid-area: 1 / 1; display: flex; align-items: center; gap: 6px; padding: 0 10px 0 8px;
  color: var(--cd-fg-2); font: 500 12px/1 var(--cd-ui); white-space: nowrap; opacity: 0; transition: opacity 280ms var(--cd-ease);
}
.cw-provider-item.is-on { opacity: 1; }
.cw-provider-item .cw-logo { width: 14px; height: 14px; }
.cw-sent {
  position: relative; flex: 1; min-height: 0; overflow: hidden;
  border: 1px solid var(--cd-border); border-radius: 12px; background: var(--cd-bg);
  opacity: .42; transition: opacity 400ms var(--cd-ease);
}
.cw-sent.is-sent { opacity: 1; }
.cw-sent-head {
  display: flex; align-items: center; gap: 5px; height: 34px; padding: 0 14px;
  border-bottom: 1px solid var(--cd-border); color: var(--cd-fg-3); font: 12px/1 var(--cd-ui);
}
.cw-sent-to { display: grid; }
.cw-sent-to b { grid-area: 1 / 1; color: var(--cd-fg); font-weight: 500; opacity: 0; transition: opacity 280ms var(--cd-ease); }
.cw-sent-to b.is-on { opacity: 1; }
.cw-steps { margin: 0; padding: 8px 0; list-style: none; }
.cw-steps li { display: flex; align-items: center; gap: 12px; height: 27px; padding: 0 14px; color: var(--cd-fg-2); font: 12.5px/1 var(--cd-code); white-space: nowrap; }
.cw-steps li span { width: 10px; color: var(--cd-fg-4); text-align: right; }
.cw-sweep {
  position: absolute; top: 34px; right: 0; left: 0; height: 48px; pointer-events: none; opacity: 0;
  background: linear-gradient(transparent, rgba(0, 85, 255, .16), transparent);
}
.cw-sent.is-sweeping .cw-sweep { animation: cw-sweep 1000ms var(--cd-ease) both; }
@keyframes cw-sweep { 0% { opacity: 0; transform: translateY(-48px); } 20% { opacity: 1; } 100% { opacity: 0; transform: translateY(160px); } }

/* ---------- 03 · the everyday essential: find a file and open it ---------- */
.cw-find { position:absolute; inset:20px; overflow:hidden; border:1px solid var(--cd-border-strong); border-radius:12px; background:var(--cd-bg); box-shadow:0 16px 40px #0004; }
.cw-find-title { display:flex; align-items:center; gap:12px; height:32px; padding:0 14px; border-bottom:1px solid var(--cd-border); background:var(--cd-chrome); color:var(--cd-fg-3); font:11px/1 var(--cd-ui); }
.cw-find-title b { color:var(--cd-fg); font-weight:600; }
.cw-find-title kbd { margin-left:auto; font:10px/1 var(--cd-code); }
.cw-find-palette { position:absolute; top:52px; left:50%; width:calc(100% - 48px); max-width:600px; transform:translateX(-50%); border:1px solid var(--cd-border-strong); border-radius:10px; background:var(--cd-chrome); box-shadow:0 20px 50px #0008; transition:opacity .4s var(--cd-ease),transform .4s var(--cd-ease); }
.cw-find-query { display:flex; align-items:center; gap:10px; height:40px; padding:0 12px; border-bottom:1px solid var(--cd-border-strong); color:var(--cd-fg); font:14px/1 var(--cd-ui); }
.cw-find-query svg { width:16px; height:16px; fill:none; stroke:var(--cd-fg-3); stroke-width:1.75; }
.cw-find-query .cw-caret { margin-left:-8px; }
.cw-find-placeholder { color:var(--cd-fg-4); }
.cw-find.has-query .cw-find-placeholder { display:none; }
.cw-find-results { padding:4px; }
.cw-find-label { padding:8px 8px 4px; color:var(--cd-fg-3); font:11px/1 var(--cd-ui); }
.cw-find-row { display:flex; align-items:center; gap:10px; height:32px; padding:0 8px; border-radius:6px; color:var(--cd-fg-2); font:13px/1 var(--cd-ui); }
.cw-find-row.is-selected { background:var(--cd-selected,#242428); color:var(--cd-fg); }
.cw-find-row small { color:var(--cd-fg-3); font:11px/1 var(--cd-code); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cw-find.has-query .cw-find-row:not([data-find-target]) { display:none; }
.cw-find-footer { display:flex; gap:16px; height:32px; align-items:center; padding:0 12px; border-top:1px solid var(--cd-border-strong); color:var(--cd-fg-3); font:11px/1 var(--cd-ui); }
.cw-find-editor { position:absolute; inset:32px 0 0; opacity:0; transform:translateY(8px); transition:opacity .5s var(--cd-ease),transform .5s var(--cd-ease); }
.cw-find-tab { display:flex; align-items:center; gap:8px; width:156px; height:34px; padding:0 14px; border-right:1px solid var(--cd-border); border-top:1px solid var(--cd-accent); color:var(--cd-fg); font:12px/1 var(--cd-ui); }
.cw-find-editor .cd-code { padding-top:18px; font-size:14px; line-height:24px; }
.cw-find.is-open .cw-find-palette { opacity:0; transform:translate(-50%,-8px); pointer-events:none; }
.cw-find.is-open .cw-find-editor { opacity:1; transform:none; }
@media(max-width:767.98px) { .cw-find { inset:16px; } .cw-find-palette { width:calc(100% - 24px); } .cw-find-row small { max-width:130px; } .cw-find-editor .cd-code { font-size:13px; } }
@media(prefers-reduced-motion:reduce) { .cw-find * { transition:none!important; } }

/* Legacy handoff scene, retained for other demo consumers. */
.cw-desk { position: absolute; inset: 0; container-type: inline-size; color: #f5f5f7; font-family: -apple-system, BlinkMacSystemFont, Geist, sans-serif; }
.cw-menubar {
  position: absolute; inset: 0 0 auto; display: flex; align-items: center; justify-content: space-between; height: 32px; padding: 0 18px;
  border-bottom: 1px solid #ffffff12; background: rgba(9, 9, 11, .66); font-size: 12.5px; font-weight: 500;
}
.cw-menu-l, .cw-menu-r { display: flex; align-items: center; gap: 18px; }
.cw-menu-l span { color: #f5f5f7cc; }
.cw-menu-r { gap: 14px; }
.cw-menu-r svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.7; }
.cw-window {
  position: absolute; top: 124px; bottom: -24px; left: 50%; width: min(640px, 84%); overflow: hidden; transform: translateX(-50%);
  border: 1px solid var(--cd-border-strong); border-radius: 12px; background: rgba(12, 12, 14, .94); box-shadow: 0 30px 80px -30px #000;
}
.cw-window-bar { display: flex; align-items: center; gap: 7px; height: 30px; padding: 0 12px; border-bottom: 1px solid var(--cd-border); }
.cw-window-bar i { width: 10px; height: 10px; border-radius: 50%; background: var(--cd-border-strong); }
.cw-window-body { display: grid; grid-template-columns: 150px minmax(0, 1fr); height: 100%; }
.cw-window-side, .cw-window-main { display: flex; flex-direction: column; gap: 12px; padding: 18px 16px; }
.cw-window-side { border-right: 1px solid var(--cd-border); }
.cw-window-side i, .cw-window-main i { display: block; height: 8px; border-radius: 4px; background: #ffffff0d; }
.cw-window-side i:nth-child(odd) { width: 72%; }
.cw-window-main i:nth-child(1) { width: 46%; height: 12px; background: #ffffff14; }
.cw-window-main i:nth-child(3) { width: 88%; }
.cw-window-main i:nth-child(5) { width: 64%; }
@container (max-width: 640px) {
  .cw-menu-l span, .cw-menu-r .cd-native-battery { display: none; }
  .cw-window { top: 112px; width: 86%; }
  .cw-window-body { grid-template-columns: minmax(0, 1fr); }
  .cw-window-side { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #demos .cw-tile, #demos .cw-index { transition: none; }
  .cw-caret { animation: none; }
}
