/* Copyright 2026 BareProxy.com */
/* SPDX-License-Identifier: Apache-2.0 */

/* BareProxy live demo. Colours and fonts follow bareproxy.com. Light theme only. */

:root {
  --brand: #1F3A5F;
  --accent: #0E7C86;
  --accent-strong: #0A646C;
  --accent-soft: #E7F3F4;
  --ink: #17212E;
  --text: #2A3544;
  --muted: #5F6B7A;
  --line: #DCE3EA;
  --line-soft: #EAEFF3;
  --soft: #F4F7FA;
  --white: #FFFFFF;
  --ok: #17653B;
  --ok-soft: #E6F4EC;
  --err: #B42318;
  --err-soft: #FDECEA;
  --warn: #8A5A00;
  --warn-soft: #FFF4DB;
  --radius: 12px;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --line-px: 20px; /* editor line height: keep in step with LINE_PX in demo.js */
  color-scheme: light;
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--white);
  color: var(--text);
  font: 16px/1.55 var(--sans);
}

.demo {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 16px 24px;
}

code { font-family: var(--mono); font-size: 0.92em; background: var(--soft); padding: 1px 5px; border-radius: 5px; }

.sr {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Header and status */

.top { margin-bottom: 16px; }
.top h1 { margin: 0 0 4px; font-size: 1.35rem; line-height: 1.25; color: var(--ink); letter-spacing: -0.01em; }
.intro { margin: 0 0 10px; color: var(--text); }

.status {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--soft); font-size: 0.9rem; color: var(--muted);
}
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); flex: none; }
.status[data-state="loading"] .dot { animation: pulse 1.1s ease-in-out infinite; }
.status[data-state="ready"] { background: var(--ok-soft); border-color: #BFE0CC; color: var(--ok); }
.status[data-state="ready"] .dot { background: var(--ok); }
.status[data-state="error"] { background: var(--err-soft); border-color: #F3C3BD; color: var(--err); }
.status[data-state="error"] .dot { background: var(--err); }
.status .bar { flex: 1 1 120px; min-width: 80px; height: 4px; border-radius: 4px; background: var(--line); overflow: hidden; position: relative; }
.status .bar span { position: absolute; inset: 0 auto 0 0; width: 35%; background: var(--accent); border-radius: 4px; animation: slide 1.2s ease-in-out infinite; }
.status:not([data-state="loading"]) .bar { display: none; }

@keyframes pulse { 50% { opacity: 0.3; } }
@keyframes slide { 0% { left: -35%; } 100% { left: 100%; } }

@media (prefers-reduced-motion: reduce) {
  .status[data-state="loading"] .dot, .status .bar span { animation: none; }
  .status .bar span { width: 100%; opacity: 0.4; }
}

/* Panels */

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
  background: var(--white);
}
.panel h2 {
  display: flex; align-items: center; gap: 10px;
  margin: 0 0 6px; font-size: 1.1rem; line-height: 1.3; color: var(--ink);
}
.panel .num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent-strong);
  font-size: 0.85rem; font-weight: 700; flex: none;
}
.help { margin: 0 0 12px; color: var(--muted); font-size: 0.94rem; }
.help code { white-space: nowrap; }
.note { margin: 10px 0 0; color: var(--muted); font-size: 0.86rem; }

/* Editors with line numbers */

.editor {
  display: flex; border: 1px solid var(--line); border-radius: 8px;
  overflow: hidden; background: var(--white);
}
.editor:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.gutter {
  flex: none; min-width: 2.7em; padding: 10px 8px 26px 10px;
  text-align: right; color: var(--muted); background: var(--soft);
  border-right: 1px solid var(--line-soft);
  font: 13px/var(--line-px) var(--mono);
  user-select: none; -webkit-user-select: none; overflow: hidden;
}
.gutter div { height: var(--line-px); }
.gutter .err { color: var(--err); background: var(--err-soft); font-weight: 700; }
.gutter .warn { color: var(--warn); background: var(--warn-soft); font-weight: 700; }
.gutter .pick { box-shadow: inset 3px 0 0 var(--accent); }

textarea.code {
  flex: 1 1 auto; min-width: 0; width: 100%; margin: 0; border: 0; outline: 0; resize: none;
  padding: 10px 12px 26px;
  font: 13px/var(--line-px) var(--mono); color: var(--ink); background: var(--white);
  white-space: pre; overflow: auto; tab-size: 2; -moz-tab-size: 2;
}

textarea.plain {
  display: block; width: 100%; margin: 8px 0 0; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; resize: vertical;
  font: 13px/1.5 var(--mono); color: var(--ink); background: var(--white);
}
textarea.plain:focus, input[type="text"]:focus, select:focus {
  outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Buttons and result chips */

.bar-row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; margin-top: 12px; }

.btn {
  appearance: none; -webkit-appearance: none;
  min-height: 40px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--white); color: var(--ink); font: 600 0.95rem/1 var(--sans); cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:focus-visible, .chip:focus-visible, summary:focus-visible, .lineref:focus-visible, .out:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--white); }
.btn.primary:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.btn.quiet { color: var(--muted); font-weight: 500; }
.btn:disabled { opacity: 0.5; cursor: default; }

.chip-result {
  display: inline-flex; align-items: center; min-height: 28px; padding: 0 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 600;
}
.chip-result[data-kind="none"] { display: none; }
.chip-result[data-kind="ok"] { background: var(--ok-soft); color: var(--ok); }
.chip-result[data-kind="warn"] { background: var(--warn-soft); color: var(--warn); }
.chip-result[data-kind="err"] { background: var(--err-soft); color: var(--err); }

/* Check result */

.result { margin-top: 12px; }
.cmd { margin: 0 0 6px; font: 12.5px/1.5 var(--mono); color: var(--muted); overflow-wrap: anywhere; }
.summary { margin: 0 0 6px; font: 13px/1.5 var(--mono); color: var(--ink); overflow-wrap: anywhere; }
.summary[data-kind="err"] { color: var(--err); }
.problems { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.problems li {
  display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px;
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  font-size: 0.92rem; line-height: 1.45;
}
.problems li.err { background: var(--err-soft); border-color: #F3C3BD; }
.problems li.warn { background: var(--warn-soft); border-color: #F0DAA6; }
.problems .kind { font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.problems .err .kind { color: var(--err); }
.problems .warn .kind { color: var(--warn); }
.problems .msg { flex: 1 1 220px; min-width: 0; color: var(--ink); overflow-wrap: anywhere; }
.lineref {
  appearance: none; -webkit-appearance: none; border: 0; background: none; padding: 0;
  font: 600 0.9rem/1.4 var(--mono); color: var(--accent-strong); text-decoration: underline; cursor: pointer;
}

/* Request form */

.presets { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip {
  appearance: none; -webkit-appearance: none;
  min-height: 32px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--soft); color: var(--ink); font: 12.5px/1.3 var(--mono); cursor: pointer; text-align: left;
  overflow-wrap: anywhere;
}
.chip:hover { border-color: var(--accent); background: var(--accent-soft); }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; }

.request { display: grid; grid-template-columns: 7.5em minmax(0, 1fr) auto; gap: 8px; }
.request select, .request input[type="text"] {
  min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); color: var(--ink); font: 14px/1.2 var(--mono); min-width: 0; width: 100%;
}

.headers { margin-top: 10px; }
.headers summary { cursor: pointer; color: var(--muted); font-size: 0.9rem; width: fit-content; }

/* Output */

.out {
  margin: 0; padding: 10px 0; background: var(--soft); border: 1px solid var(--line-soft); border-radius: 8px;
  font: 13px/1.6 var(--mono); color: var(--ink); overflow-x: auto; white-space: pre;
  tab-size: 4; -moz-tab-size: 4; min-height: 3em;
}
.out .ln { display: block; padding: 0 12px; min-width: max-content; }
.out .miss { color: var(--muted); }
.out .hit { background: var(--accent-soft); color: var(--accent-strong); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.out .act { font-weight: 700; color: var(--brand); background: #E9EEF5; margin-top: 4px; }
.out .gap { color: var(--warn); background: var(--warn-soft); }
.out .bad { color: var(--err); }
.out .sec { font-weight: 700; color: var(--ink); margin-top: 4px; }
.out .chg { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; box-shadow: inset 3px 0 0 var(--accent); }

/* Footer */

.foot { margin-top: 20px; color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.foot a { color: var(--accent-strong); }

/* Narrow screens */

@media (max-width: 600px) {
  .demo { padding: 12px 12px 20px; }
  .panel { padding: 12px; margin-top: 12px; }
  .request { grid-template-columns: 6.5em minmax(0, 1fr); }
  .request .btn { grid-column: 1 / -1; width: 100%; }
  .request select, .request input[type="text"] { font-size: 16px; }
  .bar-row .btn { flex: 1 1 auto; }
  .chip { font-size: 12px; }
}
