/* Jusa for Developers: where the scenes sit on the portal's pages (scenes/README.md).
 *
 * The home page's power row, the board under its first sample, the flow
 * grid and the power-line dividers, and the trace down the docs sidebar.
 * Clay is current; green paints only .is-live and .is-delivered. */

/* ---- a scene's plate: wider than its column, it scrolls sideways ------------------------
   scenes.css keeps every scene at least --sc-floor tall, so its labels stay
   legible. Where the column is narrower the plate scrolls inside itself, the
   caption stays put, and a shade on either edge says there is more. */
.scene.is-plate {
  --sc-plate: var(--surface-2, #FAFBF9);
  overflow-x: auto; overscroll-behavior-x: contain;
  background: linear-gradient(90deg, var(--sc-plate) 40%, transparent) left / 32px 100% no-repeat local,
    linear-gradient(270deg, var(--sc-plate) 40%, transparent) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(42, 50, 59, .16), transparent) left / 12px 100% no-repeat,
    radial-gradient(farthest-side at 100% 50%, rgba(42, 50, 59, .16), transparent) right / 12px 100% no-repeat,
    var(--sc-plate);
}
.scene.is-plate figcaption { position: sticky; left: 0; }
@media (max-width: 600px) { .scene.is-plate { padding-left: 10px; padding-right: 10px; } }
.scene.is-plate:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---- the home hero ---------------------------------------------------------------- */
.dvp-hero { max-width: 60rem; margin-bottom: var(--s-7); }
.dvp-hero h1 { font-size: var(--t-display-1); max-width: 18ch; }
.dvp-hero .lede { max-width: 58ch; }

/* The power row: generator, pylon, a span that stretches, pylon, then the
   two buttons the line feeds. Every piece is a fixed-height box, so the row
   never moves as it plays. */
.sc-power { display: flex; align-items: flex-end; margin-top: var(--s-6); max-width: 56rem; }
.sc-power > svg { display: block; height: 120px; overflow: visible; }
.sc-power-gen { flex: 0 0 150px; width: 150px; }
.sc-power-span { flex: 1 1 48px; min-width: 48px; }
.sc-power-drop { flex: 0 0 64px; width: 64px; }
.sc-power > .btn { flex: 0 0 auto; position: relative; }
.sc-jumper { flex: 0 0 28px; height: 52px; }
.sc-jumper svg { display: block; width: 100%; height: 100%; overflow: visible; }
.sc-narrow-only, .sc-jumper svg.sc-narrow-only { display: none; }

/* The terminal where the line meets a button, and the ring that flashes
   when current arrives. Unlit (armed, before the current) the primary
   button is drawn, not filled. */
.sc-feed::before {
  content: ""; position: absolute; left: -4px; top: 50%; width: 7px; height: 7px; margin-top: -3.5px;
  border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px var(--ground);
}
.sc-feed::after {
  content: ""; position: absolute; inset: -6px; border-radius: calc(var(--r-ctl) + 6px);
  border: 1.5px solid var(--accent); opacity: 0; pointer-events: none;
}
.is-armed .sc-feed { transition: background-color 280ms var(--ease), color 280ms var(--ease),
                                 border-color 280ms var(--ease); }
.is-armed .sc-feed:not(.is-on)::before { background: var(--line-strong); }
.is-armed .btn.primary.sc-feed:not(.is-on) { background: transparent; color: var(--accent); border-color: var(--accent-line); }
.is-armed .btn.secondary.sc-feed:not(.is-on) { color: var(--muted); border-color: var(--line); }
@media (prefers-reduced-motion: no-preference) {
  .is-armed .sc-feed.is-on::after, .sc-feed.is-flash::after { animation: sc-light 760ms var(--ease) both; }
  .is-armed.is-surge .sc-line.is-surgeable .sc-run { animation: sc-surge var(--dur, 600ms) linear var(--surge-at, 0ms) both; }
}
@keyframes sc-light { 0% { opacity: 0; transform: scale(.94); } 30% { opacity: .85; } 100% { opacity: 0; transform: scale(1.05); } }
@keyframes sc-surge { from { stroke-dashoffset: 14; } to { stroke-dashoffset: -101; } }

@media (max-width: 640px) {
  .sc-power { flex-wrap: wrap; max-width: none; }
  .sc-power > .btn { flex: 1 0 100%; }
  .sc-jumper { flex: 1 0 100%; height: 12px; }
  .sc-wide-only, .sc-jumper svg.sc-wide-only { display: none; }
  g.sc-narrow-only { display: inline; }
  .sc-jumper svg.sc-narrow-only { display: block; }
  .sc-feed::before { left: auto; right: 14.5px; top: -4px; margin-top: 0; }
}

/* ---- the board: the hero's request and its answer, on traces ------------------------ */
.sc-board {
  position: relative; isolation: isolate; overflow: hidden;
  margin: 0 0 var(--s-4); padding: clamp(14px, 3vw, 32px);
  border-radius: calc(var(--r-card) + 6px); background: var(--ground-2);
}
.sc-board-traces { position: absolute; inset: 0; z-index: -1; width: 100%; height: 100%; }
.sc-board .sc-wire { stroke: rgba(42, 50, 59, .16); stroke-width: 1.5; }
.sc-board .sc-pad { stroke: rgba(42, 50, 59, .3); fill: var(--ground-2); }
.sc-board .sc-run { stroke-dasharray: 4 400; stroke-width: 2.25; }
.sc-board .sc-hot { opacity: .3; }
.sc-board-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(15rem, 19rem);
                 gap: clamp(20px, 4vw, 48px); align-items: center; }
.sc-board .code-block { margin: 0; }
.sc-board-event {
  display: flex; align-items: center; gap: 10px; margin: var(--s-3) 0 0; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-ctl);
  font-size: .9rem; line-height: 1.45; color: var(--ink-soft);
}
.sc-board-event code { font-family: var(--f-num); font-size: .84rem; color: var(--ink); }
.sc-board-lamp { flex: 0 0 auto; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); }
.sc-board-lamp.is-delivered { background: #37AC34; box-shadow: 0 0 0 4px rgba(55, 172, 52, .16); }
.is-armed .sc-board-lamp.is-delivered:not(.is-on) { background: var(--line-strong); box-shadow: none; }
.is-armed .sc-board-lamp { transition: background-color 300ms var(--ease), box-shadow 300ms var(--ease); }
@media (max-width: 900px) {
  .sc-board-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---- the flow grid: one small scene per thing people build -------------------------- */
/* Two across, so each drawing is big enough for its labels without scrolling
   (a 280-unit scene needs 385px); one across below that, never blown up. */
.sc-flow { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-4); margin: 0 0 var(--s-5); }
.sc-flow > .scene.is-wide { grid-column: 1 / -1; }
.sc-flow > .scene > svg { max-width: 30rem; margin: 0 auto; }
.sc-flow > .scene.is-wide > svg { max-width: none; }
.sc-flow figcaption { font-size: .92rem; }
@media (max-width: 900px) { .sc-flow { grid-template-columns: minmax(0, 1fr); } }

/* The home page uses the whole width the header does: no dead gutter on the right. */
.dev-body.is-full { max-width: none; }

/* ---- a power line between sections ------------------------------------------------- */
.sc-divider { display: flex; align-items: flex-end; height: 56px; margin: var(--s-8) 0 var(--s-4); }
.sc-divider > svg { display: block; height: 56px; overflow: visible; }
.sc-divider-end { flex: 0 0 40px; width: 40px; }
.sc-divider-span { flex: 1 1 auto; min-width: 0; }
.sc-divider .sc-run { stroke-dasharray: 3 400; }
.dev-body .sc-divider + h2 { margin-top: 0; }

/* A copy button carries its spark. */
.code-copy { position: relative; }

/* ---- the recipes page: each use case's scene, above its code --------------------------- */
.recipe-toc { columns: 2; padding-left: 1.2rem; }
@media (max-width: 600px) { .recipe-toc { columns: 1; } }
.recipe-scene { margin: var(--s-4) 0 var(--s-4); }
/* A band as wide as the text; the drawing keeps its proportions and stops
   growing at a readable height, centred in its plate. */
.recipe-scene .scene > svg { max-height: 184px; }
.recipe-scene .scene figcaption { font-size: .9rem; }
/* The recipe's own heading names it, so the caption keeps only its sentence. */
.recipe-scene .scene figcaption strong { display: none; }
/* On a phone the drawing takes the plate's whole width, so its labels stay legible. */
@media (max-width: 600px) {
  .recipe-scene .scene.is-plate { padding: 10px 4px 10px; }
  .recipe-scene .scene figcaption { padding: 0 10px; }
}
