/* The generator's API playground: the request sheet beside the response sheet.
   Tokens and components (sheet, key, chip, code) come from assets/style.css. */

.pg { padding-bottom: 72px; }
.pg .doc-title { padding: 48px 0 36px; }

.pg-grid {
  display: grid;
  grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
  gap: clamp(20px, 3vw, 36px);
  align-items: start;
}
@media (max-width: 960px) {
  .pg-grid { grid-template-columns: minmax(0, 1fr); }
}

.pg-form { display: grid; gap: 16px; }
.pg-form h2, .pg-out h2 { margin-bottom: 4px; }
/* `.key` and the fields set a display; `hidden` must still win. */
.pg [hidden] { display: none !important; }
.pg-form .actions { margin-top: 8px; }

.pg-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 520px) {
  .pg-row { grid-template-columns: minmax(0, 1fr); }
}

.pg-field, .pg-check {
  display: grid;
  gap: 6px;
  font: 600 13px/1.3 var(--mono);
  font-variation-settings: 'wdth' 87.5;
  color: var(--ink);
}
.pg-field small, .pg-check small { font: 400 12px/1.3 var(--sans); color: var(--fade); }
.pg-check { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.pg-field input,
.pg-field select {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  font: 400 14px/1.3 var(--mono);
  color: var(--ink);
  background: var(--key-face);
  border: 1px solid var(--paper-rule);
  border-radius: 8px;
}
.pg-field input:focus-visible,
.pg-field select:focus-visible,
.pg-check input:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
.pg-check input { width: 18px; height: 18px; accent-color: var(--key-confirm); }

.pg-line { margin: 0 0 10px; }
.pg-line code { font-size: 14px; }
.pg-status { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 0 0 12px; }
.pg-body pre { max-height: 70vh; overflow: auto; }

/* ───────── Keypad choices ─────────
   A short list is a row of keypad keys. The chosen key sits pressed in, with
   its LED lit: the card machine's own way of showing a selected function. */

.pg-keys { border: 0; margin: 0; padding: 0; min-width: 0; }
.pg-keys legend {
  padding: 0;
  margin-bottom: 8px;
  font: 600 13px/1.3 var(--mono);
  font-variation-settings: 'wdth' 87.5;
  color: var(--ink);
}
.pg-keys legend small { font: 400 12px/1.3 var(--sans); color: var(--fade); margin-left: 6px; }
.pg-keyrow { display: flex; flex-wrap: wrap; gap: 8px 8px; }
.pg-keyrow label { position: relative; display: inline-flex; }
.pg-keyrow input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.pg-keyrow span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 8px 13px 7px 11px;
  font: 600 13px/1 var(--mono);
  font-variation-settings: 'wdth' 87.5;
  color: var(--ink);
  background: var(--key-face);
  border-radius: 8px;
  box-shadow: 0 3px 0 #b9bab3, 0 5px 10px -6px color-mix(in srgb, var(--ink) 40%, transparent);
  transition: transform 60ms steps(2), box-shadow 60ms steps(2);
  pointer-events: none;
}
.pg-keyrow span::before {
  content: '';
  width: 7px;
  height: 7px;
  flex: none;
  border-radius: 50%;
  background: var(--paper-rule);
  box-shadow: inset 0 1px 1px color-mix(in srgb, var(--ink) 25%, transparent);
}
.pg-keyrow input:hover + span { filter: brightness(1.03); }
.pg-keyrow input:checked + span {
  transform: translateY(3px);
  box-shadow: 0 0 0 #b9bab3, inset 0 1px 3px color-mix(in srgb, var(--ink) 18%, transparent);
  background: var(--paper-band);
}
.pg-keyrow input:checked + span::before {
  background: var(--key-confirm);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--key-confirm) 20%, transparent), 0 0 6px 1px color-mix(in srgb, var(--key-confirm) 60%, transparent);
}
.pg-keyrow input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: 3px; }

/* ───────── The picker and the calendar ───────── */

.pg-native {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip-path: inset(50%);
  white-space: nowrap; border: 0; padding: 0; margin: -1px;
}
.pg-pick, .pg-date { position: relative; }

.pg-pick-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  font: 400 14px/1.3 var(--mono);
  color: var(--ink);
  text-align: left;
  background: var(--key-face);
  border: 1px solid var(--paper-rule);
  border-radius: 8px;
  cursor: pointer;
}
.pg-pick-value { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.pg-pick-value .pg-opt-code { font-weight: 600; }
.pg-pick-value .pg-opt-name { margin-left: 8px; font: 400 14px/1.3 var(--sans); color: var(--ink-soft); }
.pg-pick-button svg { width: 16px; height: 16px; flex: none; color: var(--fade); transition: transform 120ms steps(3); }
.pg-pick-button[aria-expanded='true'] { border-color: var(--ink); }
.pg-pick-button[aria-expanded='true'] svg { transform: rotate(180deg); }
.pg-pick-button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.pg-date input { padding-right: 52px; }
.pg-date input[aria-invalid='true'] { border-color: var(--print-red); color: var(--print-red); }
.pg-date-toggle {
  position: absolute;
  top: 5px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 40px;
  height: 34px;
  color: var(--ink);
  background: var(--paper-band);
  border: 0;
  border-radius: 6px;
  box-shadow: 0 2px 0 var(--paper-rule);
  cursor: pointer;
}
.pg-date-toggle svg { width: 18px; height: 18px; }
.pg-date-toggle[aria-expanded='true'] { transform: translateY(2px); box-shadow: none; background: var(--paper-rule); }
.pg-date-toggle:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* The slip: printed down from its field, torn at the bottom like the receipt.
   It lives on <body> (controls.js places it), out of reach of the sheet's mask. */
.pg-slip[hidden] { display: none; }
.pg-slip {
  position: fixed;
  z-index: 60;
  filter: drop-shadow(0 14px 18px color-mix(in srgb, var(--ink) 28%, transparent)) drop-shadow(0 2px 2px color-mix(in srgb, var(--ink) 15%, transparent));
}
.pg-paper {
  --edge: 10px;
  margin: 0;
  padding: 6px 0 calc(var(--edge) + 8px);
  list-style: none;
  color: var(--ink);
  background: var(--paper);
  border-top: 3px solid var(--ink);
  -webkit-mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--edge) 51% repeat-x,
    linear-gradient(#000 0 0) top / 100% 50% no-repeat;
  mask: conic-gradient(from -45deg at bottom, #0000, #000 1deg 89deg, #0000 90deg) bottom / var(--edge) 51% repeat-x,
    linear-gradient(#000 0 0) top / 100% 50% no-repeat;
  animation: pg-print 200ms steps(5) both;
}
@keyframes pg-print {
  from { clip-path: inset(0 0 100% 0); }
  to { clip-path: inset(0 0 -20px 0); }
}
/* Opened above its field, the slip feeds upward. */
.pg-slip.is-up .pg-paper { animation-name: pg-print-up; }
@keyframes pg-print-up {
  from { clip-path: inset(100% 0 0 0); }
  to { clip-path: inset(-20px 0 0 0); }
}
@media (prefers-reduced-motion: reduce) {
  .pg-paper { animation: none; }
  .pg-keyrow span, .pg-pick-button svg { transition: none; }
}

.pg-list {
  max-height: min(320px, 50vh);
  overflow-y: auto;
  outline: none;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-rule) transparent;
}
.pg-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 9px 14px 9px 30px;
  position: relative;
  font: 600 13px/1.3 var(--mono);
  font-variation-settings: 'wdth' 87.5;
  cursor: pointer;
  border-bottom: 1px dotted var(--paper-rule);
}
.pg-list li:last-child { border-bottom: 0; }
.pg-list .pg-opt-name { font: 400 14px/1.3 var(--sans); color: var(--ink-soft); }
.pg-list li.is-active, .pg-list li:hover { background: var(--paper-band); }
.pg-list li[aria-selected='true']::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  margin-top: -3.5px;
  border-radius: 50%;
  background: var(--key-confirm);
  box-shadow: 0 0 6px 1px color-mix(in srgb, var(--key-confirm) 60%, transparent);
}
.pg-list:focus-visible li.is-active { outline: 2px solid var(--ink); outline-offset: -2px; }

.pg-cal { padding: 14px 14px calc(var(--edge) + 14px); }
.pg-cal-head { display: grid; grid-template-columns: 36px 1fr 36px; align-items: center; gap: 6px; margin-bottom: 10px; }
.pg-cal-title {
  margin: 0;
  text-align: center;
  font: 800 17px/1.1 var(--display);
  letter-spacing: 0.02em;
  text-transform: capitalize;
}
.pg-cal-nav {
  width: 36px;
  height: 34px;
  font: 700 18px/1 var(--mono);
  color: var(--ink);
  background: var(--key-face);
  border: 0;
  border-radius: 6px;
  box-shadow: 0 2px 0 #b9bab3;
  cursor: pointer;
}
.pg-cal-nav:active { transform: translateY(2px); box-shadow: none; }
.pg-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.pg-cal-dow {
  padding: 4px 0 6px;
  text-align: center;
  font: 600 11px/1 var(--mono);
  color: var(--fade);
  text-transform: uppercase;
}
.pg-cal-day {
  position: relative;
  aspect-ratio: 1;
  min-height: 34px;
  font: 500 13px/1 var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  background: none;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
}
.pg-cal-day:hover { background: var(--paper-band); }
.pg-cal-day.is-today::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 5px;
  width: 4px;
  height: 4px;
  margin-left: -2px;
  border-radius: 50%;
  background: var(--print-red);
}
.pg-cal-day[aria-pressed='true'] { color: #fff; background: var(--key-confirm); font-weight: 700; }
.pg-cal-day[aria-pressed='true'].is-today::after { background: #fff; }
.pg-cal-day:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.pg-cal-foot {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  padding-top: 12px;
  background: radial-gradient(circle, var(--paper-rule) 1.6px, #0000 2px) top left / 12px 4px repeat-x;
}

/* The labels over the link and the curl line. */
.pg-label { margin: 0 0 6px; font: 600 13px/1.3 var(--mono); font-variation-settings: 'wdth' 87.5; color: var(--ink); }
.pg-label small { display: block; margin-top: 2px; font: 400 12px/1.4 var(--mono); color: var(--fade); overflow-wrap: anywhere; }
.pg-out .code { margin-bottom: 18px; }
.pg-note { margin: 0; padding: 10px 12px; font: 400 13px/1.5 var(--sans); color: var(--ink-soft); background: var(--paper-band); border-radius: 6px; }
