/* === x402 Developer Playground Styles === */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --border: #30363d;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --accent: #f0883e;
  --accent-dim: #d18616;
  --green: #3fb950;
  --green-dim: #238636;
  --red: #f85149;
  --blue: #58a6ff;
  --purple: #bc8cff;
  --yellow: #d29922;
  --radius: 8px;
  --font-mono: "SF Mono", "Cascadia Code", "Fira Code", Consolas, monospace;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial,
    sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* === Header === */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.5rem 2rem;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
}

.header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.header-links {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.header-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.header-link:hover {
  color: var(--text);
  background: var(--surface-2);
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.accent {
  color: var(--accent);
}

.subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-family: var(--font-mono);
  margin-top: 0.25rem;
}

/* === Nav === */
nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 2rem;
  display: flex;
  gap: 0;
  max-width: 1100px;
  margin: 0 auto;
  overflow-x: auto;
}

.nav-link {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color 0.15s, border-color 0.15s;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

/* === Main === */
main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* === Landing === */
.landing-hero {
  text-align: center;
  padding: 2rem 0;
}

.landing-hero h2 {
  font-size: 1.8rem;
  margin-bottom: 0.5rem;
}

.landing-hero > p {
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.flow-diagram {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  margin: 2rem auto;
  max-width: 300px;
}

.flow-step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 1.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  width: 100%;
  text-align: center;
}

.flow-step.highlight {
  border-color: var(--accent);
  color: var(--accent);
}

.flow-step.success {
  border-color: var(--green);
  color: var(--green);
}

.flow-arrow {
  color: var(--text-muted);
  font-size: 1rem;
}

.examples-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 2.5rem;
}

.example-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.15s;
  text-align: left;
}

.example-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.example-card h3 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.example-card .price {
  display: inline-block;
  background: var(--accent-dim);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.example-card p {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* === Page Headers === */
.page-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.page-header h2 {
  font-size: 1.4rem;
}

.page-header code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  background: var(--surface-2);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
}

.badge {
  background: var(--accent);
  color: #000;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 700;
}

/* === Controls === */
.controls {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.controls label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex: 1;
  min-width: 180px;
}

.controls select,
.controls input,
.controls textarea {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0.6rem 0.75rem;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.controls textarea {
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 0.82rem;
}

.controls select:focus,
.controls input:focus,
.controls textarea:focus {
  border-color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  padding: 0.6rem 1.5rem;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-primary:hover {
  background: var(--accent-dim);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* === Payment Flow Inspector === */
.inspector {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.inspector:empty {
  display: none;
}

.inspector-title {
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.inspector-step {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(8px);
  animation: stepIn 0.3s ease forwards;
}

.inspector-step:last-child {
  border-bottom: none;
}

@keyframes stepIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
  margin-top: 2px;
}

.step-icon.pending {
  background: var(--border);
  color: var(--text-muted);
}

.step-icon.active {
  background: var(--blue);
  color: #fff;
  animation: pulse 1s infinite;
}

.step-icon.done {
  background: var(--green-dim);
  color: var(--green);
}

.step-icon.error {
  background: rgba(248, 81, 73, 0.2);
  color: var(--red);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.step-content {
  flex: 1;
  min-width: 0;
}

.step-label {
  font-weight: 600;
  font-size: 0.88rem;
}

.step-detail {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
  word-break: break-all;
}

.step-detail .kv {
  display: flex;
  gap: 0.5rem;
}

.step-detail .key {
  color: var(--purple);
}

.step-detail .val {
  color: var(--text);
}

/* === Raw HTTP Panel === */
.raw-http {
  margin-top: 0.5rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 150px;
  overflow-y: auto;
}

.raw-http .method {
  color: var(--green);
  font-weight: 700;
}

.raw-http .status-402 {
  color: var(--accent);
  font-weight: 700;
}

.raw-http .status-200 {
  color: var(--green);
  font-weight: 700;
}

.raw-http .header-name {
  color: var(--blue);
}

/* === Response Panel === */
.response-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.response-panel:empty {
  display: none;
}

.response-title {
  padding: 0.75rem 1rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--green);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.response-body {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
  color: var(--text);
}

/* === Code block === */
.code-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.code-block pre {
  margin: 0;
}

.code-block code {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text);
}

/* === Footer === */
footer {
  text-align: center;
  padding: 2rem;
  color: var(--text-muted);
  font-size: 0.82rem;
  border-top: 1px solid var(--border);
  margin-top: 3rem;
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

.footer-links {
  margin-top: 0.5rem;
}

.footer-links .sep {
  color: var(--border);
  margin: 0 0.25rem;
}

/* === Responsive === */
@media (max-width: 640px) {
  header { padding: 1rem; }
  main { padding: 1rem; }
  nav { padding: 0 1rem; }
  .examples-grid { grid-template-columns: 1fr; }
  .controls { flex-direction: column; }
  .page-header { flex-direction: column; align-items: flex-start; }
}
