/* Playground — builds on the tokens and components in style.css */

.pg-page { padding-block: var(--gap-lg) 0; }

.pg-hero { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 20px; }

/* One-click example requests */
.pg-presets { display: flex; align-items: center; gap: 10px; margin-top: var(--gap-lg); }
.pg-presets-label { flex: none; font-size: 0.85rem; font-weight: 600; color: var(--ink-2); }
.pg-preset-row { display: flex; gap: 6px; overflow-x: auto; padding: 2px 2px 6px; scrollbar-width: none; }
.pg-preset-row::-webkit-scrollbar { display: none; }
.pg-preset-row .chip { flex: none; padding: 7px 12px; border: 1px solid var(--glass-edge); background: var(--card); font-size: 0.84rem; font-weight: 600; cursor: pointer; transition: background 0.15s, color 0.15s; }
.pg-preset-row .chip:hover { background: rgba(255, 255, 255, 0.9); color: var(--ink); }
.pg-preset-row .chip.active { background: var(--ink); border-color: var(--ink); color: #fff; }

.pg-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--gap-lg); margin-top: 8px; align-items: start; }

/* ---------- Request ---------- */
.pg-field { display: grid; gap: 6px; margin-bottom: 14px; }
.pg-field > span:first-child, .pg-field > label:first-child, .pg-param > span { font-size: 0.82rem; font-weight: 600; color: var(--ink-2); }
.pg-hint { font-size: 0.78rem; color: var(--ink-3); }
.pg-request .input { padding: 11px 14px; font-size: 0.92rem; }
#apiKey, .pg-param input { font-family: var(--mono); font-size: 0.86rem; }
select.input { appearance: none; -webkit-appearance: none; padding-right: 38px; font-family: var(--mono); font-size: 0.88rem; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8e9c' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }

.pg-key { position: relative; display: block; }
.pg-key .input { padding-right: 46px; }
.pg-icon-btn { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--ink-3); }
.pg-icon-btn:hover, .pg-icon-btn.on { color: var(--blue); background: var(--blue-wash); }
.pg-icon-btn svg { width: 18px; height: 18px; }
.pg-remember { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.pg-remember input { accent-color: var(--blue); }

.pg-params { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; margin-bottom: 14px; padding: 14px; border-radius: var(--r-sm); background: rgba(232, 237, 252, 0.5); }
.pg-params[hidden] { display: none; }
.pg-param { display: grid; gap: 4px; min-width: 0; }
.pg-param.is-path > span { color: var(--blue); }
.pg-param small { font-size: 0.74rem; color: var(--ink-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pg-param .input { padding: 9px 12px; background: rgba(255, 255, 255, 0.8); }

.pg-url { display: flex; align-items: baseline; gap: 10px; margin-bottom: 12px; padding: 10px 14px; border-radius: var(--r-sm); background: var(--code-bg); color: #d6d8e1; font-family: var(--mono); font-size: 0.8rem; }
.pg-url i { flex: none; font-style: normal; font-weight: 600; color: #8ab4ff; }
.pg-url code { min-width: 0; overflow-wrap: anywhere; }

#send { gap: 10px; }
#send svg { width: 16px; height: 16px; }
#send:disabled { opacity: 0.55; cursor: not-allowed; }
#send.is-loading svg { animation: pg-spin 0.8s linear infinite; }
@keyframes pg-spin { to { transform: rotate(360deg); } }

.pg-cost-high { background: #fff3e0; color: var(--warn); }

.pg-shake { animation: pg-shake 0.4s ease; border-color: var(--err); }
@keyframes pg-shake { 20%, 60% { transform: translateX(-5px); } 40%, 80% { transform: translateX(5px); } }

/* ---------- Response ---------- */
.pg-response { margin-top: 16px; }
.pg-response-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; font-size: 0.82rem; }
.pg-status { padding: 3px 10px; border-radius: var(--pill); font-weight: 700; font-family: var(--mono); font-size: 0.78rem; }
.pg-status.ok { background: rgba(22, 163, 74, 0.12); color: var(--ok); }
.pg-status.err { background: rgba(220, 38, 38, 0.1); color: var(--err); }
.pg-meta { color: var(--ink-3); font-variant-numeric: tabular-nums; }
.pg-copy { margin-left: auto; padding: 5px 12px; border-radius: 8px; background: var(--card-2); font-size: 0.78rem; font-weight: 600; color: var(--ink-2); }
.pg-copy:hover { color: var(--ink); background: #fff; }
.pg-json { margin: 0; max-height: 520px; overflow: auto; font-size: 0.8rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; }
.pg-json .k, .pg-snippet .k { color: #8ab4ff; }
.pg-json .s { color: #a5e3a1; }
.pg-json .n { color: #f7c47a; }

/* ---------- Code ---------- */
.pg-code { position: sticky; top: 92px; }
.pg-snippet { position: relative; }
.pg-snippet pre { margin: 0; min-height: 150px; font-size: 0.82rem; }
.pg-snippet .pg-copy { position: absolute; top: 10px; right: 10px; z-index: 1; background: rgba(255, 255, 255, 0.08); color: #b7bac6; }
.pg-snippet .pg-copy:hover { color: #fff; background: rgba(255, 255, 255, 0.16); }
.pg-code-note { margin-top: 10px; }
.pg-hint code, .pg-notes code { font-size: 0.85em; padding: 1px 5px; border-radius: 5px; background: var(--card-2); color: var(--ink); }

.pg-notes { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.pg-notes h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 8px; }
.pg-notes ul { margin-left: 1.1rem; display: grid; gap: 6px; font-size: 0.88rem; color: var(--ink-2); }
.pg-notes a { color: var(--blue); font-weight: 600; }

@media (max-width: 900px) {
    .pg-grid { grid-template-columns: minmax(0, 1fr); }
    .pg-code { position: static; }
}
@media (max-width: 640px) {
    .pg-presets { flex-direction: column; align-items: stretch; gap: 6px; }
    .pg-preset-row { margin-inline: calc(-1 * var(--gutter)); padding-inline: var(--gutter); }
    .pg-params { grid-template-columns: minmax(0, 1fr); }
    .pg-code .tile-head { flex-wrap: wrap; }
}
