/* ==========================================================================
   Apoxy — Demo request modal
   Left flare streams a real-time edge-trace log (visitor IP, ASN, ISP,
   country, negotiated TLS params). Right side is the demo-request form.
   Mounted by apx-demo.js. Sharp corners, brand palette.
   ========================================================================== */

.apx-demo-backdrop {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(20, 19, 18, 0.62);
  -webkit-backdrop-filter: blur(6px) saturate(110%);
  backdrop-filter: blur(6px) saturate(110%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  opacity: 0; pointer-events: none;
  transition: opacity var(--d-base) var(--ease-out);
}
.apx-demo-backdrop.open { opacity: 1; pointer-events: auto; }

.apx-demo {
  width: 100%; max-width: 960px; max-height: calc(100vh - 48px);
  background: var(--apx-paper); color: var(--apx-ink);
  border: 1px solid var(--apx-ink);
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.32);
  display: grid; grid-template-columns: 1.05fr 1fr;
  grid-template-rows: minmax(0, 1fr);
  position: relative; overflow: hidden;
  transform: translateY(8px) scale(0.98);
  transition: transform var(--d-base) var(--ease-out);
}
.apx-demo-backdrop.open .apx-demo { transform: translateY(0) scale(1); }

.apx-demo .close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; padding: 0;
  border: 1px solid var(--border-default);
  background: var(--apx-paper); color: var(--apx-ink); cursor: pointer;
  font-family: var(--font-mono); font-size: 18px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all var(--d-fast) var(--ease-out);
  z-index: 2;
}
.apx-demo .close:hover { border-color: var(--apx-ink); background: var(--apx-ink); color: var(--apx-bone); }

/* ----- LEFT: live edge trace log ----- */
.apx-demo .flare {
  background: #0F0E0D; color: var(--apx-bone);
  padding: 30px 24px 22px; position: relative; overflow: hidden;
  display: flex; flex-direction: column; gap: 14px;
  min-height: 0;
}
.apx-demo .flare::before {
  content: ""; position: absolute; inset: 0;
  background-image:
    linear-gradient(#8E8B86 1px, transparent 1px),
    linear-gradient(90deg, #8E8B86 1px, transparent 1px);
  background-size: 24px 24px; opacity: 0.05; pointer-events: none;
}

.apx-demo .flare .crumb {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--apx-stone);
  position: relative; line-height: 1;
}

.apx-demo .trace {
  margin-top: 2px; flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 6px;
  position: relative;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #2A2826 transparent;
  padding-right: 2px;
}
.apx-demo .trace::-webkit-scrollbar { width: 6px; }
.apx-demo .trace::-webkit-scrollbar-track { background: transparent; }
.apx-demo .trace::-webkit-scrollbar-thumb { background: #2A2826; }
.apx-demo .ping {
  display: flex; flex-direction: column;
  border: 1px solid #2A2826;
  background: rgba(255,255,255,0.02);
  padding: 7px 11px 8px;
  opacity: 0; transform: translateY(4px);
  animation: apx-demo-fadein 0.36s var(--ease-out) forwards;
  flex-shrink: 0;
}
.apx-demo .ping .meta {
  font-family: var(--font-mono); font-size: 9.5px; line-height: 1;
  letter-spacing: 0.14em; color: #6b6967;
  display: flex; gap: 7px; align-items: center; margin-bottom: 5px;
  text-transform: uppercase;
}
.apx-demo .ping .line {
  font-family: var(--font-mono); font-size: 11.5px; line-height: 1.4;
  color: var(--apx-bone);
  word-break: break-word;
}
.apx-demo .ping .meta .ts   { color: #6b6967; }
.apx-demo .ping .meta .sep  { color: #3a3735; }
.apx-demo .ping .meta .type { text-transform: uppercase; letter-spacing: 0.14em; }
.apx-demo .ping .meta .type.ok   { color: #8AB97A; }
.apx-demo .ping .meta .type.geo  { color: #e6c875; }
.apx-demo .ping .meta .type.tls  { color: #a6c8e6; }
.apx-demo .ping .meta .type.fwd  { color: #d9b380; }

.apx-demo .ping .line .k   { color: #6b6967; }
.apx-demo .ping .line .s   { color: #e6db74; }
.apx-demo .ping .line .em  { color: #f5f3ee; font-weight: 500; }
.apx-demo .ping .line .ip  { color: #f5f3ee; font-weight: 500; }
.apx-demo .ping .line .cursor {
  display: inline-block; width: 7px; height: 11px;
  background: var(--apx-leaf); margin-left: 4px; vertical-align: -1px;
  animation: apx-demo-blink 0.9s infinite step-end;
}

@keyframes apx-demo-fadein {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes apx-demo-blink {
  0%, 50% { opacity: 1; }
  50.01%, 100% { opacity: 0; }
}

.apx-demo .stats {
  display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0;
  border-top: 1px solid #2A2826; padding-top: 14px; margin-top: 2px;
}
.apx-demo .stats .cell { padding: 0 14px; border-left: 1px solid #2A2826; }
.apx-demo .stats .cell:first-child { border-left: 0; padding-left: 0; }
.apx-demo .stats .k {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: #6b6967; margin-bottom: 4px;
}
.apx-demo .stats .v {
  font-family: var(--font-display); font-size: 20px; line-height: 1;
  letter-spacing: -0.012em; font-weight: 500; color: var(--apx-bone);
  font-variant-numeric: tabular-nums;
}
.apx-demo .stats .v .unit { font-family: var(--font-body); font-size: 11px; color: #8E8B86; margin-left: 3px; }

/* ----- RIGHT: form ----- */
.apx-demo .form {
  padding: 30px 32px 24px; background: var(--apx-paper);
  display: flex; flex-direction: column; gap: 0;
  overflow-y: auto;
}
.apx-demo .form .head { margin-bottom: 18px; }
.apx-demo .form .crumb {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.16em;
  color: var(--text-muted); text-transform: uppercase; margin-bottom: 14px;
  line-height: 1;
}
.apx-demo .form h2 {
  font-family: var(--font-display); font-size: 26px; line-height: 1.05;
  letter-spacing: -0.012em; font-weight: 500; margin: 0 0 8px; max-width: 18ch;
}
.apx-demo .form .lede {
  font-size: 13px; line-height: 1.55; color: var(--text-secondary); margin: 0;
}

.apx-demo .form form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
.apx-demo .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.apx-demo .field { display: flex; flex-direction: column; gap: 6px; }
.apx-demo .field label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--text-muted);
}
.apx-demo .field label .req { color: var(--apx-coral); margin-left: 4px; }
.apx-demo .field input,
.apx-demo .field select,
.apx-demo .field textarea {
  font-family: var(--font-body); font-size: 14px; line-height: 1.4;
  background: var(--apx-bone); color: var(--apx-ink);
  border: 1px solid var(--border-default); border-radius: 0;
  padding: 10px 12px; outline: none;
  transition: border-color var(--d-fast) var(--ease-out);
}
.apx-demo .field input:focus,
.apx-demo .field select:focus,
.apx-demo .field textarea:focus { border-color: var(--apx-ink); }
.apx-demo .field textarea { resize: vertical; min-height: 80px; font-family: var(--font-body); }
.apx-demo .field select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%236B6967' stroke-width='1.4' fill='none'/></svg>"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 28px; }

.apx-demo .actions { display: flex; gap: 12px; align-items: center; margin-top: 10px; }
.apx-demo .actions .btn-fill { background: var(--apx-ink); color: var(--apx-bone); border: 1px solid var(--apx-ink); padding: 12px 18px; font-family: var(--font-body); font-size: 14px; font-weight: 500; cursor: pointer; }
.apx-demo .actions .btn-fill:hover { background: #2A2826; }
.apx-demo .actions .btn-fill[disabled] { opacity: 0.6; cursor: progress; }

/* ----- Success state ----- */
.apx-demo .submitted {
  display: none;
  flex: 1; min-height: 0;
  padding: 24px 32px;
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 18px;
}
.apx-demo.is-submitted .form form,
.apx-demo.is-submitted .form .head { display: none; }
.apx-demo.is-submitted .submitted { display: flex; }

.apx-demo .stamp {
  display: inline-flex; flex-direction: column; align-items: stretch;
  border: 1px solid var(--apx-ink);
  background: var(--apx-paper);
  min-width: 160px;
}
.apx-demo .stamp .code {
  font-family: var(--font-display); font-size: 44px; line-height: 1;
  letter-spacing: -0.02em; font-weight: 500; color: var(--apx-ink);
  font-variant-numeric: tabular-nums;
  text-align: center;
  padding: 18px 24px 14px;
}
.apx-demo .stamp .label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.24em;
  text-transform: uppercase; color: var(--apx-ink);
  text-align: center;
  padding: 10px 24px;
  border-top: 1px solid var(--apx-ink);
}

.apx-demo .submitted h2 {
  font-family: var(--font-display); font-size: 26px; letter-spacing: -0.012em; font-weight: 500; margin: 4px 0 0;
}
.apx-demo .submitted p {
  font-size: 13px; color: var(--text-secondary); margin: 0; line-height: 1.55; max-width: 34ch;
}
.apx-demo .submitted .receipt {
  margin-top: 4px;
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em;
  color: var(--text-muted);
  display: inline-flex; gap: 8px; align-items: center;
  border-top: 1px solid var(--border-default);
  padding-top: 12px;
}
.apx-demo .submitted .receipt .sep { color: var(--apx-fog); }
.apx-demo .submitted .receipt .em { color: var(--apx-ink); }

/* Inline error surface for client-side validation / network failures */
.apx-demo .form-error {
  display: none;
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid var(--apx-coral);
  background: var(--apx-coral-tint);
  color: var(--apx-ink);
  font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  letter-spacing: 0.02em;
}
.apx-demo.has-error .form-error { display: block; }

@media (max-width: 760px) {
  .apx-demo { grid-template-columns: 1fr; max-height: calc(100vh - 32px); }
  .apx-demo .flare { padding: 22px 18px; min-height: 0; }
  .apx-demo .trace { min-height: 0; }
  .apx-demo .ping .line { font-size: 11px; }
  .apx-demo .form { padding: 22px 20px; }
  .apx-demo .row-2 { grid-template-columns: 1fr; }
  .apx-demo .stats .v { font-size: 17px; }
}
