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

   The palette is 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.
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-deep:       #141a18;
  --bg-main:       #1a211e;
  --bg-surface:    #222b27;
  --bg-elevated:   #2b3530;
  --border:        #384340;
  --border-focus:  #576660;

  --text-primary:  #c8d0c0;
  --text-dim:      #9aa595;
  --text-faint:    #7b8a82;
  --green:         #8fb87e;
  --green-bright:  #a8d498;
  --amber:         #d4bf72;
  --amber-dim:     #a89458;
  --red:           #c47a72;
  --red-bright:    #e0958c;
  --blue:          #7ea4c0;

  --font-mono:     'IBM Plex Mono', 'Menlo', 'Consolas', monospace;
  --font-display:  'Share Tech Mono', monospace;
  --wide:          1240px;
}

*, *::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: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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);
}

/* ── Header ──────────────────────────────────────────────────────────── */

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

.pdfi-back {
  font-size: 0.75rem;
  color: var(--text-faint);
  letter-spacing: 0.05em;
}
.pdfi-back:hover { color: var(--green); }

.pdfi-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  font-weight: 400;
  color: var(--green);
  letter-spacing: 0.02em;
  margin: 0.4rem 0 0.3rem;
}

.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.84rem;
  color: var(--text-dim);
  max-width: 68ch;
}

/* ── The disclaimer ──────────────────────────────────────────────────────
   Red, full width, above everything, and not collapsible. */

.pdfi-warning {
  border: 1px solid rgba(196, 122, 114, 0.5);
  border-left: 3px solid var(--red);
  background: rgba(196, 122, 114, 0.07);
  padding: 1rem 1.15rem;
  margin-bottom: 1.75rem;
}

.pdfi-warning h2 {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--red-bright);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 0.55rem;
}

.pdfi-warning p {
  font-size: 0.8rem;
  color: var(--text-dim);
  max-width: 92ch;
}
.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 {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-focus);
  padding: 0.95rem 1.1rem 1.1rem;
}

.pdfi-panel--go { border-left-color: var(--green); }

.pdfi-panel-title {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--green);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.85rem;
}

/* ── 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; 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%;
  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: 2px solid var(--green-bright); }

.pdfi-check--ack {
  border: 1px solid rgba(212, 191, 114, 0.4);
  background: rgba(212, 191, 114, 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: 2px solid var(--green); 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(212, 191, 114, 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(212, 191, 114, 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);
  border-left: 3px solid var(--amber-dim);
  color: var(--text-primary);
  font-family: var(--font-mono);
  overflow: auto;
}

.pdfi-modal::backdrop { background: rgba(10, 14, 12, 0.78); }

.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(212, 191, 114, 0.45);
  border-left: 3px solid var(--amber);
  background: rgba(212, 191, 114, 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;
}

/* ── Footer ──────────────────────────────────────────────────────────── */

.pdfi-footer {
  margin: 2.5rem 0 3rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-faint);
}
.pdfi-footer p { max-width: 80ch; }
.pdfi-footer p + p { margin-top: 0.5rem; }
