/* The preview under the headline: a sketch of the app in HTML and CSS (the
   Engineer's Pipeline: a row per ticket, a cell per stage), not a video or a screenshot. preview.js
   plays one ticket through the loop while it is on screen. The handwritten notes
   sit in the margins with arrows pointing in on wide screens, and stack under the
   preview (numbered, no arrows) below 1360px.
   Every rule is scoped under .stage, so a class the page uses elsewhere (.body,
   .card, .item, ...) never picks one up from here. Keep it that way. */
.stage { position: relative; max-width: 1360px; margin: 0 auto; padding: 0 var(--gutter) clamp(48px, 7vw, 80px); }
.stage-inner { position: relative; max-width: 880px; margin: 0 auto; }
.stage .note { font-family: var(--hand); color: var(--ink); transition: opacity .6s ease, transform .6s ease; }
.stage .note b { display: block; font-weight: 700; font-size: 27px; line-height: 1.05; }
.stage .note span { display: block; font-weight: 500; font-size: 21px; line-height: 1.15; margin-top: 4px; color: var(--text-2); }
.stage .note svg { display: none; color: var(--ink); overflow: visible; }
.stage .notes { display: grid; gap: 18px; margin-top: 28px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .stage .notes { grid-template-columns: 1fr 1fr; } }
.stage .notes .note { display: flex; gap: 10px; }
.stage .notes .note i { font-style: normal; flex: none; display: grid; place-items: center; width: 24px; height: 24px; margin-top: 2px; border-radius: 50%; border: 1.5px solid currentColor; font: 700 15px var(--hand); }
@media (min-width: 1360px) {
  .stage .notes { display: block; margin: 0; }
  .stage .notes .note { position: absolute; width: 210px; display: block; }
  .stage .notes .note i { display: none; }
  .stage .note svg { display: block; }
  /* While the loop plays, the side notes start hidden and come in one at a
     time as the preview shows each beat. Paused, or without the script, every
     note shows. The numbered list on smaller screens always shows. */
  .stage.playing .note { opacity: 0; transform: translateY(6px); }
  .stage.playing .note.shown { opacity: 1; transform: none; }
  .stage .n-build { top: 96px; left: -240px; }
  .stage .n-ask { top: 360px; left: -240px; }
  .stage .n-review { top: -10px; right: -240px; text-align: right; }
  .stage .n-fix { top: 238px; right: -240px; text-align: right; }
}
.stage .draw { stroke-dasharray: 600; stroke-dashoffset: 0; }
.stage.playing .note.shown .draw { animation: preview-draw 1s ease both; }
@keyframes preview-draw { from { stroke-dashoffset: 600; } to { stroke-dashoffset: 0; } }

/* The window: the app's dark canvas, the side menu and the Pipeline. */
.stage .window { border: 1px solid rgba(227, 229, 232, 0.12); border-radius: 12px; background: var(--canvas); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); overflow: hidden; font-size: 12.5px; line-height: 1.45; }
.stage .titlebar { height: 30px; display: flex; align-items: center; gap: 7px; padding: 0 12px; background: #1b1b1b; border-bottom: 1px solid var(--hairline); }
.stage .titlebar i { width: 11px; height: 11px; border-radius: 50%; }
.stage .titlebar i:nth-child(1) { background: #ec6a5e; } .stage .titlebar i:nth-child(2) { background: #f4bf4f; } .stage .titlebar i:nth-child(3) { background: #61c554; }
.stage .app { display: grid; grid-template-columns: minmax(0, 1fr); height: 400px; }
@media (min-width: 520px) { .stage .app { height: 540px; } }
@media (min-width: 720px) { .stage .app { grid-template-columns: 164px minmax(0, 1fr); } }
.stage .ico { width: 14px; height: 14px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }

.stage .side { display: none; background: #1b1b1b; border-right: 1px solid var(--hairline); padding: 12px 8px; flex-direction: column; color: var(--text); }
@media (min-width: 720px) { .stage .side { display: flex; } }
.stage .side .logo-row { display: flex; align-items: center; justify-content: center; gap: 7px; padding: 0 0 12px; font: 600 13.5px var(--display); }
.stage .side .logo-row img { width: 18px; height: 18px; }
.stage .side .item { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-radius: 7px; white-space: nowrap; }
.stage .side .item.on { background: #262626; }
.stage .side .item .ico { color: var(--text-3); }
.stage .side .dot { margin-left: auto; width: 6px; height: 6px; border-radius: 50%; background: #5d5d5d; transition: background .3s; }
.stage .side .dot.live { background: var(--lime); }
.stage .side .dot.ask { background: var(--flame); }
.stage .side .group { padding: 9px 8px 2px; font-size: 11px; color: var(--text-3); }
.stage .side .grow { flex: 1; }
.stage .side .gear { align-self: flex-end; color: var(--text-3); padding: 4px 6px; }

.stage .main { display: flex; flex-direction: column; min-width: 0; padding: 10px 12px 12px; }
.stage .top { display: flex; align-items: center; gap: 10px; }
.stage .segs { display: flex; gap: 2px; padding: 3px; border-radius: 9px; background: #1f1f1f; border: 1px solid var(--hairline); color: var(--text-2); white-space: nowrap; overflow: hidden; }
.stage .segs span { padding: 2px 9px; border-radius: 6px; }
.stage .segs span.on { background: #303030; color: var(--text); }
.stage .repos { margin-left: auto; padding: 3px 9px; border-radius: 8px; border: 1px solid var(--hairline); color: var(--text-2); white-space: nowrap; }
.stage .head { display: flex; align-items: baseline; gap: 8px; margin: 10px 2px 8px; color: var(--text-3); font-size: 11.5px; white-space: nowrap; overflow: hidden; }
.stage .head b { font: 600 14px var(--display); color: var(--text); }
.stage .head .next { margin-left: auto; }
.stage .body { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; overflow: hidden; }

/* The Pipeline: a row per ticket and a cell per stage, joined by a track. A
   cell is a dot (waiting), a pulse (running or fixing) or a mark (done, failing,
   needs you), with its word under it from 640px. */
.stage .pipe { border-radius: 10px; background: #1a1a1a; border: 1px solid var(--hairline); padding: 2px 4px; overflow: hidden; }
.stage .prow { display: grid; grid-template-columns: minmax(0, 1fr) repeat(6, 33px); align-items: center; gap: 0; padding: 6px 4px; }
@media (min-width: 640px) { .stage .prow { grid-template-columns: minmax(0, 1fr) repeat(6, 58px); } }
@media (min-width: 900px) { .stage .prow { grid-template-columns: minmax(0, 1fr) repeat(6, 72px); } }
.stage .prow + .prow, .stage #rows .prow:first-child { border-top: 1px dashed rgba(227, 229, 232, 0.07); }
.stage .prow.hd { padding: 6px 4px 5px; color: var(--text-3); font-size: 9px; }
@media (min-width: 640px) { .stage .prow.hd { font-size: 10.5px; } }
.stage .prow.hd span + span { text-align: center; white-space: nowrap; }
.stage .prow.hd b { font-weight: 500; }
.stage .prow.hd b:first-child { display: none; }
@media (min-width: 900px) { .stage .prow.hd b:first-child { display: inline; } .stage .prow.hd b:last-child { display: none; } }
.stage .prow .t { min-width: 0; padding-right: 8px; }
.stage .prow .ref { display: block; font-size: 10.5px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stage .prow .t b { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; font-weight: 500; line-height: 1.3; overflow: hidden; }
.stage .c { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stage .c::before { content: ""; position: absolute; top: 9px; left: 0; right: 0; height: 1px; background: rgba(227, 229, 232, 0.1); }
.stage .t + .c::before { left: 50%; }
.stage .c:last-child::before { right: 50%; }
.stage .c i { position: relative; z-index: 1; display: grid; place-items: center; width: 19px; height: 19px; border-radius: 50%; font: 700 11px/1 var(--body); font-style: normal; color: var(--c); background: color-mix(in srgb, var(--c) 16%, #1a1a1a); border: 1px solid color-mix(in srgb, var(--c) 55%, transparent); transition: color .3s, background .3s, border-color .3s; }
.stage .c.live i::after { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--c); animation: preview-pulse 1.2s ease-in-out infinite; }
.stage .c em { display: none; font-style: normal; font-size: 10px; line-height: 1.2; color: var(--c); white-space: nowrap; }
@media (min-width: 640px) { .stage .c em { display: block; } }
.stage .c.s-wait em { color: var(--text-3); }
.stage .c.pop i { animation: preview-pop .45s cubic-bezier(.2, .8, .2, 1) both; }

/* Ticket states, in the app's colours: grey while waiting, lime while it is
   working, amber in review, orange while fixing, green once landed, red when it
   needs a person. */
.stage .st { display: inline-block; padding: 0 6px; border-radius: 4px; font-size: 10.5px; line-height: 17px; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); transition: color .3s, background .3s; }
.stage .s-wait { --c: #5d5d5d; }
.stage .s-ready { --c: #a3a3a3; }
.stage .s-work { --c: var(--lime); }
.stage .s-review { --c: #e8c547; }
.stage .s-fix { --c: #f0a340; }
.stage .s-done { --c: #5bc27a; }
.stage .s-ask { --c: var(--flame-text); }

/* The question a ticket stopped on, and your reply to it. Until one does, a
   quiet box holds its place. */
.stage .idle { display: none; flex: 1; align-items: center; justify-content: center; border-radius: 10px; border: 1px dashed rgba(227, 229, 232, 0.1); color: var(--text-3); font-size: 11.5px; }
.stage .ask:not(.on) + .idle { display: flex; }
.stage .ask { display: none; gap: 10px; padding: 10px 11px; border-radius: 10px; background: #1d1d1d; border: 1px solid color-mix(in srgb, var(--flame-text) 35%, transparent); }
.stage .ask.on { display: grid; animation: preview-slidein .35s ease both; }
@media (min-width: 520px) { .stage .ask.on { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); } }
.stage .ask .q p:first-child { display: flex; align-items: center; gap: 8px; }
.stage .ask .ref { font-size: 10.5px; color: var(--text-3); }
.stage .why { margin-top: 6px; color: var(--text-2); }
.stage .reply { padding: 8px 9px; border-radius: 8px; border: 1px solid rgba(227, 229, 232, 0.14); background: #181818; }
.stage .reply small { display: block; font-size: 10.5px; color: var(--text-3); }
.stage .reply p { min-height: 2.9em; margin-top: 3px; color: var(--text); }
.stage .reply p::after { content: ""; display: inline-block; width: 1px; height: 1.1em; margin-left: 1px; vertical-align: -2px; background: var(--text); animation: preview-pulse 1s steps(1) infinite; }
.stage .reply .send { display: flex; justify-content: flex-end; gap: 6px; margin-top: 4px; }
.stage .reply .send span { padding: 1px 8px; border-radius: 6px; border: 1px solid rgba(227, 229, 232, 0.16); color: var(--text-2); transition: background .3s, color .3s; }
.stage .reply .send span.press { background: #F4F5F7; color: #0b0b0c; }
@keyframes preview-pop { from { transform: scale(.6); } to { transform: none; } }
/* A phone has room for four tickets and no question box: there the red cell is the ask. */
@media (max-width: 519px) { .stage .ask.on, .stage .ask:not(.on) + .idle { display: none; } }
/* Below 1024px the question box and five tickets do not both fit, so show four. */
@media (max-width: 1023px) { .stage #rows .prow:nth-child(n+5) { display: none; } }
@keyframes preview-slidein { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes preview-pulse { 50% { opacity: .3; } }
@media (prefers-reduced-motion: reduce) {
  .stage *, .stage *::before, .stage *::after { animation: none !important; transition: none !important; }
}

/* The pause control: the loop starts by itself, so a visitor can stop it
   (WCAG 2.2.2). It is hidden until preview.js runs, and the script reveals it. */
.stage .pause { display: none; margin: 14px auto 0; align-items: center; gap: 8px; font: 600 13px var(--body); color: var(--text-2); background: transparent; border: 1px solid rgba(227, 229, 232, 0.16); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
.stage .pause:hover { background: var(--raised); color: var(--text); }
.stage .pause.ready { display: flex; }
