/* ═══════════════════════════════════════════════════════════════════════════
   pdf-inject — self-contained styles.

   The palette and the frame component are duplicated from the site's style.css
   rather than imported. That is deliberate: this tool is meant to be liftable
   into its own public repository, and a shared stylesheet would be the one
   thread holding it here. Nothing in this file leaks out, because nothing else
   loads it — and when the site's palette changes, this block changes with it
   by hand.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-deep:       #0f1319;
  --bg-main:       #151a22;
  --bg-surface:    #1b222c;
  --bg-elevated:   #242e3a;

  --border:        #2a3540;
  --border-soft:   #202932;
  --border-focus:  #455565;

  --text-primary:  #ccd5df;
  --text-dim:      #93a1ae;
  --text-faint:    #6e7d8b;

  --accent:        #56b8e0;
  --accent-bright: #8ad9f5;
  --accent-deep:   #173f4e;

  --amber:         #d7b070;
  --amber-dim:     #a68a56;
  --red:           #dd8079;
  --red-bright:    #f09b94;
  --blue:          #9aa8e8;

  /* Legacy hue names, so the rules further down keep resolving. */
  --green:         var(--accent);
  --green-bright:  var(--accent-bright);

  --font-mono:     'IBM Plex Mono', 'Menlo', 'Consolas', monospace;
  --font-display:  var(--font-mono);
  --wide:          1240px;
  --statusbar-h:   2.1rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

* { scrollbar-width: thin; scrollbar-color: var(--border) transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: var(--bg-deep); }
::-webkit-scrollbar-thumb { background: var(--border); border: 2px solid var(--bg-deep); }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

body {
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 14.5px;
  line-height: 1.6;
  /* The status bar is fixed to the viewport, so the page reserves its height. */
  padding-bottom: var(--statusbar-h);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--bg-deep); }

code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  color: var(--amber);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  padding: 0.05em 0.32em;
  word-break: break-all;
}

a { color: var(--green); text-decoration: none; }
a:hover { color: var(--green-bright); text-decoration: underline; }

.pdfi-wrap {
  max-width: var(--wide);
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
}

/* ── Topbar ──────────────────────────────────────────────────────────────
   The site's, minus the nav — this page is a one-way door, so the only route
   out of it is back the way you came. */

.pdfi-header {
  border-bottom: 1px solid var(--border);
  background: var(--bg-main);
  padding: 0;
  margin-bottom: 1.6rem;
}

.pdfi-topbar {
  display: flex;
  align-items: center;
  gap: 0.6rem 1.5rem;
  flex-wrap: wrap;
  padding: 0.4rem 0;
}

.pdfi-brand {
  font-size: 0.95rem;
  color: var(--accent);
  letter-spacing: 0.06em;
}

.pdfi-brand a { color: var(--accent); }
.pdfi-brand a:hover { color: var(--accent-bright); text-decoration: none; }

.pdfi-subtitle {
  font-size: 0.72rem;
  color: var(--text-faint);
  letter-spacing: 0.04em;
}

.pdfi-subtitle::before { content: '· '; }

/* Mirrors .site-nav in style.css — see the note in the template. */
.pdfi-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem 1.1rem;
  margin-left: auto;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
}

.pdfi-nav a { color: var(--text-faint); }
.pdfi-nav a .k { color: var(--amber); }
.pdfi-nav a:hover { color: var(--text-primary); text-decoration: none; }

.pdfi-nav a[aria-current="page"],
.pdfi-nav a[aria-current="page"] .k { color: var(--accent-bright); }

.pdfi-cursor {
  color: var(--amber);
  animation: pdfi-blink 1.2s step-end infinite;
}

@keyframes pdfi-blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .pdfi-cursor { animation: none; } }

.pdfi-tagline {
  font-size: 0.82rem;
  color: var(--text-dim);
  max-width: 84ch;
}

/* ── Frame ────────────────────────────────────────────────────────────────
   The site's panel: a border with the title notched into its top edge. The
   legend needs the page colour behind it, so a frame only works directly
   against --bg-deep and never nests. */

.pdfi-frame {
  position: relative;
  border: 1px solid var(--border);
  background: var(--bg-main);
  margin-bottom: 1.6rem;
}

/* Inside a column the flex gap does the spacing, so the frame's own margin
   would double it. Without a gap of some kind the next frame's legend lands on
   this one's bottom border. */
.pdfi-col > .pdfi-frame { margin-bottom: 0; }

.pdfi-legend {
  position: absolute;
  top: 0;
  left: 0.9rem;
  transform: translateY(-50%);
  background: var(--bg-deep);
  padding: 0 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  max-width: calc(100% - 3rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pdfi-legend .n { color: var(--accent); }

.pdfi-frame-body { padding: 1rem 1.1rem; }

/* ── The disclaimer ──────────────────────────────────────────────────────
   A frame like everything else, but red and never collapsible. It is the one
   thing on this page nobody gets to skip. */

.pdfi-warning {
  border-color: rgba(221, 128, 121, 0.5);
  background: rgba(221, 128, 121, 0.05);
}

.pdfi-warning > .pdfi-legend { color: var(--red-bright); }

.pdfi-warning p {
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 96ch;
}

.pdfi-warning p + p { margin-top: 0.6rem; }
.pdfi-warning strong { color: var(--text-primary); }
.pdfi-warning code { color: var(--red-bright); }

/* ── Layout ──────────────────────────────────────────────────────────── */

.pdfi-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
}

@media (max-width: 900px) {
  .pdfi-grid { grid-template-columns: minmax(0, 1fr); }
}

.pdfi-col { display: flex; flex-direction: column; gap: 1.25rem; min-width: 0; }

.pdfi-panel {
  position: relative;
  background: var(--bg-main);
  border: 1px solid var(--border);
  padding: 1rem 1.1rem 1.1rem;
}

/* The step you finish on: the accent marks it the way the selected row is
   marked on the index. */
.pdfi-panel--go {
  border-color: var(--border-focus);
  background: var(--bg-surface);
}

/* ── Fields ──────────────────────────────────────────────────────────── */

.pdfi-field {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  margin-bottom: 0.8rem;
}
.pdfi-field:last-child { margin-bottom: 0; }
.pdfi-field[hidden] { display: none; }
.pdfi-field--grow { flex: 1; min-width: 0; margin-bottom: 0; }

.pdfi-label {
  font-size: 0.65rem;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.pdfi-field input[type="text"],
.pdfi-field select,
#pdfi-payload {
  width: 100%;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  background: var(--bg-deep);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 0.4rem 0.55rem;
}

.pdfi-field input[type="text"]:focus,
.pdfi-field select:focus,
#pdfi-payload:focus {
  border-color: var(--green);
  outline: none;
}

/* pre-wrap, not pre: newlines in the payload are significant — a spoofed
   turn delimiter is nothing without them — but a long instruction should
   still be readable without scrolling sideways to find the end of it. */
#pdfi-payload {
  line-height: 1.55;
  resize: vertical;
  min-height: 12rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.pdfi-row {
  display: flex;
  align-items: flex-end;
  gap: 0.6rem;
  flex-wrap: wrap;
}
.pdfi-row--end { justify-content: flex-end; margin-top: 0.7rem; }

/* ── Notes and hints ─────────────────────────────────────────────────── */

.pdfi-note {
  font-size: 0.74rem;
  color: var(--text-faint);
  border-left: 2px solid var(--border);
  padding-left: 0.6rem;
  margin: -0.2rem 0 0.85rem;
}

.pdfi-note--block {
  font-family: var(--font-mono);
  white-space: pre-wrap;
  word-break: break-word;
  margin-top: 0.75rem;
  margin-bottom: 0;
  line-height: 1.5;
}

.pdfi-hint {
  font-size: 0.72rem;
  color: var(--text-faint);
  line-height: 1.5;
}
.pdfi-panel > .pdfi-hint { margin-bottom: 0.7rem; }
.pdfi-hint code { font-size: 0.95em; }

/* ── Checkboxes ──────────────────────────────────────────────────────── */

.pdfi-checks {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.3rem 0.9rem;
}

.pdfi-check {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-dim);
  cursor: pointer;
  padding: 0.15rem 0;
}
.pdfi-check:hover { color: var(--text-primary); }

.pdfi-check input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 0.95rem;
  height: 0.95rem;
  margin-top: 0.22rem;
  background: var(--bg-deep);
  border: 1px solid var(--border-focus);
  cursor: pointer;
  position: relative;
}

.pdfi-check input[type="checkbox"]:checked {
  background: var(--green);
  border-color: var(--green);
}
.pdfi-check input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 0.28rem;
  top: 0.06rem;
  width: 0.24rem;
  height: 0.5rem;
  border: solid var(--bg-deep);
  border-width: 0 2px 2px 0;
  transform: rotate(42deg);
}
.pdfi-check input[type="checkbox"]:focus-visible { outline: 1px solid var(--accent-bright); outline-offset: 1px; }

.pdfi-check--ack {
  border: 1px solid rgba(215, 176, 112, 0.4);
  background: rgba(215, 176, 112, 0.06);
  padding: 0.7rem 0.8rem;
  margin-bottom: 0.85rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

/* ── Buttons ─────────────────────────────────────────────────────────── */

.pdfi-btn {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0.4rem 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}

.pdfi-btn:hover { border-color: var(--border-focus); color: var(--text-primary); }
.pdfi-btn:focus-visible { outline: 1px solid var(--accent-bright); outline-offset: 1px; }

/* The rebuild button lights up once the textarea has been hand-edited, so it
   is obvious that the pickers and the payload have drifted apart. */
.pdfi-btn.is-stale { border-color: var(--amber-dim); color: var(--amber); }
.pdfi-btn.is-active { border-color: var(--green); color: var(--green-bright); }

.pdfi-btn--primary {
  display: block;
  width: 100%;
  font-size: 0.85rem;
  padding: 0.65rem 1rem;
  background: var(--bg-elevated);
  border-color: var(--green);
  color: var(--green-bright);
}
.pdfi-btn--primary:hover:not(:disabled) {
  background: var(--green);
  color: var(--bg-deep);
  border-color: var(--green);
}
.pdfi-btn--primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: var(--border);
  color: var(--text-faint);
}

/* ── Status ──────────────────────────────────────────────────────────── */

.pdfi-status {
  margin-top: 0.6rem;
  font-size: 0.73rem;
  color: var(--text-faint);
  min-height: 1.3em;
  word-break: break-word;
}
.pdfi-status.is-ok { color: var(--green-bright); }
.pdfi-status.is-bad { color: var(--red-bright); }

/* ── Outbound URL list ───────────────────────────────────────────────── */

.pdfi-url {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  padding: 0.35rem 0;
  border-bottom: 1px dashed var(--border);
  font-size: 0.74rem;
}
.pdfi-url:last-child { border-bottom: none; }

.pdfi-url-verb {
  flex: 0 0 auto;
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber);
  border: 1px solid rgba(215, 176, 112, 0.35);
  padding: 0.05rem 0.35rem;
}

.pdfi-url code {
  background: none;
  border: none;
  padding: 0;
  color: var(--blue);
  word-break: break-all;
}

/* Shown when an outbound channel has no listener URL yet. Amber rather than
   red: it is an unfinished setup, not a mistake — and it is the one place the
   tool asks for something instead of quietly substituting a default. */
.pdfi-hint--warn {
  color: var(--amber);
  border-left: 2px solid var(--amber-dim);
  background: rgba(215, 176, 112, 0.06);
  padding: 0.5rem 0.6rem;
}

/* ── Stage-two preview modal ──────────────────────────────────────────────
   Native <dialog>: Escape, focus trapping and the backdrop are the browser's
   job, so all that is left here is making it look like the rest of the page. */

.pdfi-modal {
  /* Explicit, because the `* { margin: 0 }` reset above clobbers the auto
     margins a modal <dialog> centres itself with. */
  margin: auto;
  width: min(74ch, calc(100vw - 2rem));
  max-height: min(80vh, 52rem);
  padding: 1.1rem 1.25rem 1.25rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-mono);
  overflow: auto;
}

.pdfi-modal::backdrop { background: rgba(6, 9, 13, 0.8); }

.pdfi-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.8rem;
}

.pdfi-modal-head h2 {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.pdfi-modal-x { padding: 0.15rem 0.5rem; line-height: 1.4; }

.pdfi-modal .pdfi-url { margin: 0.6rem 0 0.8rem; border-bottom: none; }

.pdfi-modal-status {
  font-size: 0.72rem;
  color: var(--text-faint);
  margin: 0.2rem 0 0.6rem;
  word-break: break-all;
}
.pdfi-modal-status.is-ok   { color: var(--green-bright); }
.pdfi-modal-status.is-warn { color: var(--amber); }
.pdfi-modal-status.is-bad  { color: var(--red-bright); }

.pdfi-modal-alert {
  font-size: 0.75rem;
  line-height: 1.5;
  color: var(--amber);
  border: 1px solid rgba(215, 176, 112, 0.45);
  border-left: 2px solid var(--amber);
  background: rgba(215, 176, 112, 0.08);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.7rem;
}

/* Response headers, where the authorised-testing notice lives now. Dimmer
   than the body: it is provenance, not payload. */
.pdfi-modal-headers {
  font-size: 0.68rem;
  line-height: 1.55;
  color: var(--text-faint);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-left: 2px solid var(--blue);
  padding: 0.55rem 0.7rem;
  margin-bottom: 0.6rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: 11rem;
  overflow: auto;
}

/* This is a file, so it should read like one — wrapped, but preserving the
   line breaks that make the fake status header look like a real header. */
.pdfi-modal-body {
  font-size: 0.76rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-deep);
  border: 1px solid var(--border);
  padding: 0.8rem 0.9rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  max-height: 30rem;
  overflow: auto;
}

/* ── Notes under the tool ────────────────────────────────────────────── */

.pdfi-footer {
  margin: 2rem 0 2.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-faint);
}

.pdfi-footer p { max-width: 84ch; }
.pdfi-footer p + p { margin-top: 0.5rem; }

/* ── Status bar ───────────────────────────────────────────────────────────
   The site's, pinned to the viewport. Static text rather than live counters:
   the only state worth reporting here is that nothing leaves the browser. */

.pdfi-statusbar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: stretch;
  height: var(--statusbar-h);
  background: var(--bg-main);
  border-top: 1px solid var(--border);
  font-size: 0.7rem;
  color: var(--text-dim);
  overflow: hidden;
}

.pdfi-status-mode {
  display: flex;
  align-items: center;
  padding: 0 0.8rem;
  background: var(--accent);
  color: var(--bg-deep);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.pdfi-status-seg {
  display: flex;
  align-items: center;
  padding: 0 0.9rem;
  border-right: 1px solid var(--border-soft);
  white-space: nowrap;
}

.pdfi-status-seg b { color: var(--text-primary); font-weight: 400; }
.pdfi-status-push { margin-left: auto; }

.pdfi-status-keys {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  padding: 0 0.9rem;
  color: var(--text-faint);
  white-space: nowrap;
}

.pdfi-statusbar a { color: inherit; }
.pdfi-statusbar a:hover { color: var(--accent-bright); text-decoration: none; }

@media (max-width: 760px) {
  body { padding-bottom: 0; }

  .pdfi-statusbar {
    position: static;
    height: auto;
    flex-wrap: wrap;
    padding: 0.35rem 0;
  }

  .pdfi-status-seg { border-right: none; padding: 0.15rem 0.75rem; }
  .pdfi-status-push { margin-left: 0; }
}

@media (max-width: 600px) {
  .pdfi-subtitle { display: none; }
}
