/* scenes/assistant.css (W12, spec 2.15; D2 and D4 of addendum v1.3): the context packet as a dark mono screen.
   Left: why the page exists (the explainer, larger than anything else under the H1), then the route a packet travels (copy, open,
   paste). Right: the packet on a screen panel (ink-2, bone text, a vermilion scan line) and the closing actions. No paper here:
   no torn edge, no slot, no stamp, no scraps. Geometry shared with fx/stages/packet.mjs (SLIP): right column = the stage box
   `right`, panel width min(560px, 54vw - 4rem), panel top 120px, bottom 162px (the actions, the status line and the quiet link).
   `--pk-nav` is the one number for the fixed nav pill (its height plus 16px above and below): the section padding and the sticky
   top both read it, and the panel top = --pk-nav + the heading row. Phones: the intro, then a 12-line preview of the packet in a
   scroll box with the two actions under it, then the steps. Default (no JS, reduced motion, fx-fail): the packet is fully shown and nothing moves. Every
   animation and pre-state lives under html.js:not(.static):not(.fx-fail). */

#assistant { --pk-nav: calc(var(--pill-h) + 32px); --pk-fs: 14px; --pk-lh: 22px; --pk-pad: 44px; --pk-rows: 13; --pk-travel: 160px; padding-top: clamp(88px, 8vw, 120px); padding-bottom: clamp(56px, 6vw, 96px); }
/* Whatever scrolls up under the fixed pill (the headline, the pinned packet as the section ends) fades into the page there, instead of being cut
   off by the pill's edge. Fixed, above the swarm canvas (3) and the copy (2), below the pill (50). */
#assistant::before { content: ""; position: fixed; left: 0; right: 0; top: 0; z-index: 4; height: calc(var(--pk-nav) + 4px); pointer-events: none; background: linear-gradient(to bottom, var(--bg) 0, var(--bg) 60%, transparent); }
#assistant h1 { font-size: clamp(2rem, 3.3vw, 3.6rem); font-weight: 760; margin-bottom: 1.4rem; scroll-margin-top: 7rem; }
#assistant .label { margin-bottom: 1.2rem; }
.pk__w { display: inline-block; white-space: nowrap; }

.pk { display: grid; gap: 2.4rem; align-items: start; }
.pk__side { min-width: 0; max-width: 40rem; }

/* D4: the reason the page exists. Set larger than the steps, so it is the first thing read after the H1. */
.pk__why { max-width: 33rem; margin: 0; font-size: clamp(1.2rem, 1.5vw, 1.4rem); font-weight: 500; line-height: 1.4; text-wrap: pretty; }
.pk__steps-h { margin: 2rem 0 .4rem; font-family: var(--font-mono); font-size: var(--t-data); font-weight: 500; letter-spacing: .12em; line-height: 1.2; text-transform: uppercase; color: color-mix(in srgb, var(--fg) 80%, var(--bg)); }
.pk__intro { max-width: 34rem; margin: 0; color: color-mix(in srgb, var(--fg) 86%, var(--bg)); font-size: .95rem; }

/* ---- the route: three stops on one lane, a packet that keeps travelling ---- */
.pk__routewrap { position: relative; margin-block: 1.2rem 1.8rem; }
.pk__lane { position: absolute; left: 14px; top: var(--lane-top, 24px); bottom: var(--lane-bottom, 24px); width: 0; border-left: 1.5px dashed var(--line); pointer-events: none; }
.pk__packet { position: absolute; left: 6px; top: 0; z-index: 2; width: 16px; height: 16px; display: none; pointer-events: none;
  margin-top: -8px; transform: translate3d(0, var(--pk-y, 24px), 0);
  background: radial-gradient(circle, var(--fg) 1.2px, transparent 1.7px) 0 0 / 4px 4px; }
.pk__packet::before { content: ''; position: absolute; left: 7px; bottom: 16px; width: 2px; height: 44px; background: linear-gradient(to top, var(--fg), transparent); opacity: .5; }
.pk__packet.is-hot { background-image: radial-gradient(circle, var(--signal) 1.4px, transparent 1.9px); }
.pk__route { position: relative; display: grid; gap: 1rem; }
.pk__route li { display: grid; grid-template-columns: 28px 40px minmax(0, 1fr); grid-template-rows: auto auto; align-items: center; column-gap: .9rem; min-height: 48px; }
.pk__node { grid-row: 1 / span 2; justify-self: center; position: relative; z-index: 1; width: 11px; height: 11px; border: 1.5px solid var(--fg); border-radius: 50%; background: var(--bg); }
.pk__glyph { grid-row: 1 / span 2; width: 40px; height: 40px; color: var(--fg); opacity: .6; }
.pk__g-core { color: var(--signal); opacity: .22; }
.pk__n { align-self: end; font-family: var(--font-mono); font-size: var(--t-data); letter-spacing: .12em; color: color-mix(in srgb, var(--fg) 75%, var(--bg)); }
.pk__t { align-self: start; font-weight: 500; font-size: clamp(.95rem, 1.05vw, 1.05rem); line-height: 1.25; text-wrap: balance; }
.pk__route li.is-at .pk__node { background: var(--fg); }
.pk__route li.is-at .pk__glyph { opacity: 1; }
.pk__route li.is-at .pk__n { color: var(--fg); }
.pk__route li.is-at .pk__g-core { opacity: 1; }
.pk__not { margin-top: 0; }

/* ---- the screen ---- */
.pk__print { position: relative; display: flex; flex-direction: column; min-width: 0; }
.pk__heading { margin: 0 0 1.1rem; font-family: var(--font-mono); font-size: var(--t-data); font-weight: 500; letter-spacing: .12em; line-height: 1.2; text-transform: uppercase; color: var(--mut); }
.pk__slip { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; transform-origin: 50% 35%; }
.pk__screen { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; background: var(--ink-2); color: var(--on-ink); border: 1px solid var(--line-ink); border-top-color: var(--signal); }
.pk__bar { display: flex; justify-content: space-between; align-items: center; margin: 0; padding: .55rem 1rem; border-bottom: 1px solid var(--line-ink);
  font-family: var(--font-mono); font-size: var(--t-data); letter-spacing: .12em; line-height: 1.2; text-transform: uppercase; color: var(--on-ink-dim); }
.pk__ok { color: var(--signal); font-weight: 600; visibility: hidden; }
.pk__slip[data-copy-state='copied'] .pk__ok { visibility: visible; }
.pk__slip[data-copy-state='copied'] .pk__screen { border-color: var(--signal); }
.pk__scroll { flex: 1; min-width: 0; overflow: auto; padding: 20px 16px 24px 0; scrollbar-width: thin; scrollbar-color: color-mix(in srgb, var(--on-ink) 35%, transparent) transparent; overscroll-behavior: contain; }
.pk__scroll:focus-visible { outline: 2px solid var(--signal); outline-offset: -4px; }
.pk__doc { position: relative; padding-left: var(--pk-pad); }
.pk__ruler { position: absolute; left: 20px; top: 0; bottom: 0; width: 6px; pointer-events: none;
  background: repeating-linear-gradient(to bottom, color-mix(in srgb, var(--on-ink) 28%, transparent) 0 1px, transparent 1px var(--pk-lh)); }
.pk__band { position: absolute; left: 34px; right: 0; top: 0; height: var(--pk-lh); transform: translateY(var(--read-y, 0px)); background: rgb(58 77 255 / .12); pointer-events: none; }
.pk__tick { position: absolute; left: 10px; top: 0; width: 3px; height: var(--pk-lh); transform: translateY(var(--read-y, 0px)); background: var(--signal); pointer-events: none; }
.pk__caret { position: absolute; left: 0; top: 0; display: none; width: .62em; height: calc(var(--pk-lh) - 5px); margin-top: 2px; font-size: var(--pk-fs); background: var(--on-ink); pointer-events: none;
  transform: translate(var(--hx, 0px), var(--hy, 0px)); }
.pk__pre { margin: 0; font: 400 var(--pk-fs) / var(--pk-lh) var(--font-mono); font-variant-ligatures: none; letter-spacing: 0; white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 2; color: var(--on-ink); user-select: text; cursor: text; }
.pk__pre::selection { background: var(--signal); color: var(--on-signal); }
html:not(.js):not(.static) .pk__pre { user-select: all; }
::highlight(pk-unprinted) { color: transparent; }

/* the leading edge while the screen is still filling: one solid vermilion line riding the clip line */
.pk__lead { position: absolute; z-index: 3; left: 0; right: 0; top: var(--feed, 0px); height: 1px; display: none; pointer-events: none; background: var(--signal); }
.pk__scan { position: absolute; z-index: 3; left: 0; right: 0; top: 0; height: 1px; opacity: 0; background: var(--signal); pointer-events: none; }

/* ---- the ending: copy, then a conversation, then the quiet way out ---- */
.pk__foot { display: grid; gap: .5rem; padding-top: 1.1rem; }
.pk__acts { display: flex; flex-wrap: wrap; gap: .6rem; }
.pk__copy, .pk__talk { flex: none; min-height: 48px; }
.pk__copy[hidden] { display: none; }
.pk__copy.is-copied { background: var(--fg); border-color: var(--fg); color: var(--bg); }
.pk__status, .pk__hint { margin: 0; font-family: var(--font-mono); font-size: var(--t-data); letter-spacing: .08em; line-height: 1.5; color: var(--mut); }
.pk__status { min-height: 3em; }
.pk__alt { margin: .4rem 0 0; font-size: .9rem; }

/* the composed frame: in the no-JS flow an ordinary image after the copy; cinematic, a fixed poster behind everything */
#assistant > .composed { margin-top: 3rem; }

/* A text scroll fades at its top edge, so lines slide under the bar instead of being cut off by it. A gradient, not a torn edge. */
.pk__scroll { -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 18px); mask-image: linear-gradient(to bottom, transparent 0, #000 18px); }

@media (min-width: 901px) {
  .pk { grid-template-columns: calc(46vw - var(--gutter)) 1fr; column-gap: 0; margin-right: calc(var(--gutter) * -1); }
  #assistant { padding-top: var(--pk-nav); }
  .pk__side { position: relative; padding: 3.4rem 2.2rem 1.5rem 0; isolation: isolate; }
  /* A solid ink panel under the whole left column (title, explainer, steps, boundary): the swarm never passes behind a word. It runs to the viewport's left edge and carries a hairline on its right. */
  .pk__side::before { content: ""; position: absolute; z-index: -1; inset: -1px 0 0 calc(var(--gutter) * -1); background: var(--bg); border-right: 1px solid var(--line); pointer-events: none; }
  /* The packet column gets a near-solid scrim too, so its heading, the buttons and the quiet link read without a star crossing them. */
  .pk__print { isolation: isolate; }
  .pk__print::before { content: ""; position: absolute; z-index: -1; inset: -1.4rem -1.6rem -.6rem; background: color-mix(in srgb, var(--bg) 94%, transparent); pointer-events: none; }
  .pk__print { position: sticky; top: var(--pk-nav); align-self: start; justify-self: center; width: min(560px, calc(54vw - 4rem)); height: calc(100svh - var(--pk-nav) - 1.25rem); min-height: 28rem; }
}
/* Windows tall enough for the whole left column: it pins under the pill with the packet for --pk-travel of extra scroll, so the title is
   never cut by the pill at the middle of the page. Shorter windows scroll normally (a pinned column taller than the window hides its end). */
@media (min-width: 901px) and (min-height: 860px) {
  .pk { min-height: calc(100svh - var(--pk-nav) - 1.25rem + var(--pk-travel)); }
  .pk__side { position: sticky; top: var(--pk-nav); }
}

@media (max-width: 900px) {
  #assistant { --pk-pad: 40px; padding-top: 6rem; }
  /* Order on a phone: the reason, then the packet itself (a 12-line preview; the whole packet scrolls inside the box) with the two
     actions under it, then the steps and the boundary. The side column dissolves into the grid so each piece can be placed. */
  .pk { gap: 0; position: relative; isolation: isolate; }
  /* On a phone the column is one stack: a solid ink sheet behind all of it, so every line reads on a flat surface. */
  .pk::before { content: ""; position: absolute; z-index: -1; inset: 0 calc(var(--gutter) * -1); background: var(--bg); pointer-events: none; }
  .pk__side { display: contents; }
  .pk__print { order: 1; margin-top: 1.4rem; }
  .pk__steps-h, .pk__intro, .pk__routewrap, .pk__not { order: 2; }
  .pk__why { font-size: 1.2rem; }
  .pk__steps-h { margin-top: 2.2rem; }
  .pk__route li { grid-template-columns: 28px 36px minmax(0, 1fr); column-gap: .8rem; }
  .pk__glyph { width: 36px; height: 36px; }
  .pk__scroll { flex: none; max-height: calc(var(--pk-lh) * var(--pk-rows) + 20px + 12px); }
  .pk__print { margin-inline: auto; width: 100%; max-width: 560px; }
  .pk__heading { margin-bottom: .7rem; }
  .pk__foot { padding-top: .9rem; }
  .pk__acts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .pk__acts .btn { justify-content: center; padding-inline: .6rem; text-align: center; line-height: 1.15; white-space: normal; }
  .pk__status { min-height: 0; }
  .pk__alt { margin-top: .2rem; }
  html.js:not(.fx-fail):not(.static) #assistant > .composed { opacity: .1; object-position: 72% 50%; }
}

@media (max-width: 900px) and (max-height: 760px) {
  #assistant { --pk-rows: 8; }
}

/* ---- cinematic only ---- */
html.js:not(.static):not(.fx-fail) #assistant > .composed { position: fixed; inset: 0; z-index: 0; margin: 0; height: 100%; }
html.js:not(.static):not(.fx-fail) .pk__packet { display: block; }

/* Pre-state of the screen until the scene starts the print; a CSS release means a scene that never loads cannot leave it blank. */
html.js:not(.static):not(.fx-fail) #assistant:not(.is-live):not([data-fx-fail]) .pk__screen { clip-path: inset(0 0 100% 0); animation: pk-release 0s linear 3.4s forwards; }
@keyframes pk-release { to { clip-path: inset(0); } }
html.js:not(.static):not(.fx-fail) #assistant.is-printing .pk__screen { clip-path: inset(0 0 calc(100% - var(--feed, 0px)) 0); }
html.js:not(.static):not(.fx-fail) #assistant.is-printing .pk__lead { display: block; }
html.js:not(.static):not(.fx-fail) #assistant.is-printing .pk__caret { display: block; animation: caret-blink 1s steps(1) infinite; }
html.js:not(.static):not(.fx-fail) .pk__g-caret { animation: caret-blink 1s steps(1) infinite; }
html.js:not(.static):not(.fx-fail) .pk__g-drop { animation: pk-drop 2.4s steps(6, end) infinite; }
@keyframes pk-drop { from { transform: translateY(-9px); } to { transform: translateY(0); } }
html.js:not(.static):not(.fx-fail) .pk__slip { transform: perspective(1600px) rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg)); }
html.js:not(.static):not(.fx-fail) .pk__slip.is-scanning .pk__scan { animation: pk-scan .62s cubic-bezier(.7, 0, .2, 1) forwards; }
@keyframes pk-scan { 0% { opacity: 1; transform: translateY(0); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(var(--screen-h, 600px)); } }

@media print { .pk__slip { transform: none !important; } .pk__scroll { overflow: visible; } .pk__print { position: static; height: auto; } .pk__foot, .pk__alt { display: none; } }

/* The footer is a solid plate above the swarm: no star drifts behind its line, its date or the page's last words. */
.site-footer { position: relative; z-index: 4; background: var(--ink); }
