/* Promptly primitives (DESIGN-SYSTEM.md §7), the classes behind FD.ui.* (ui/primitives.js).
 * Lane L0, DECK-202. Values come only from ui/tokens.css (--p-*), copied from the mock's Stack
 * helpers (B, PILL, TAG, C, F, CK, G, N, DLG, …). Every selector starts with a .p- class (or
 * FD.ui.el's [data-p-el] marker), so linking this file changes nothing on a screen until a node
 * carries one.
 */

/* ---- base: a primitive root sets its own family and ink, whatever the page body says ---- */
.p-root, .p-btn, .p-pill, .p-tag, .p-card, .p-field, .p-dialog, .p-notice, .p-toast, .p-sheet,
.p-drawer, .p-menu, .p-sysbar, .p-check, .p-kv {
  font-family: var(--p-font);
  -webkit-font-smoothing: antialiased;
  box-sizing: border-box;
}
.p-root *, .p-root *::before, .p-root *::after { box-sizing: border-box; }
.p-mono { font-family: var(--p-mono); }

/* D-04: visible focus ring on every interactive element, following its radius. */
.p-i:focus { outline: none; }
.p-i:focus-visible {
  outline: var(--p-focus-width) solid var(--p-focus-color);
  outline-offset: var(--p-focus-offset);
}
/* IM-A11Y-001: keyboard-only ring on FD.ui.el nodes; :focus-visible never matches a mouse/touch press on these tags. */
[data-p-el]:focus-visible {
  outline: var(--p-focus-width) solid var(--p-focus-color);
  outline-offset: var(--p-focus-offset);
}

/* ---- keyframes (§5) ---- */
@keyframes p-pop-in { from { opacity: 0; transform: scale(.965) translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes p-sheet-up { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes p-drawer-in { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: none; } }
@keyframes p-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes p-run-dot { 0%, 100% { opacity: .35; transform: scale(.85); } 50% { opacity: 1; transform: scale(1); } }
@keyframes p-spin { to { transform: rotate(360deg); } }

/* ---- text roles (§3) ---- */
.p-t-display-xl { font: var(--p-fw-display-xl) var(--p-fs-display-xl)/var(--p-lh-display-xl) var(--p-font); letter-spacing: var(--p-ls-display-xl); text-wrap: balance; }
.p-t-display-l { font: var(--p-fw-display-l) var(--p-fs-display-l)/var(--p-lh-display-l) var(--p-font); letter-spacing: var(--p-ls-display-l); text-wrap: balance; }
.p-t-display-m { font: var(--p-fw-display-m) var(--p-fs-display-m)/var(--p-lh-display-m) var(--p-font); letter-spacing: var(--p-ls-display-m); text-wrap: balance; }
.p-t-display-s { font: var(--p-fw-display-s) var(--p-fs-display-s)/var(--p-lh-display-s) var(--p-font); letter-spacing: var(--p-ls-display-s); text-wrap: balance; }
.p-t-display-s-setup { font: var(--p-fw-display-s-setup) var(--p-fs-display-s-setup)/var(--p-lh-display-s-setup) var(--p-font); letter-spacing: var(--p-ls-display-s-setup); text-wrap: balance; }
.p-t-title-caption { font: var(--p-fw-title-caption) var(--p-fs-title-caption)/var(--p-lh-title-caption) var(--p-font); letter-spacing: var(--p-ls-title-caption); text-wrap: balance; }
.p-t-title-l { font: var(--p-fw-title-l) var(--p-fs-title-l)/var(--p-lh-title-l) var(--p-font); letter-spacing: var(--p-ls-title-l); text-wrap: balance; }
.p-t-title-dialog { font: var(--p-fw-title-dialog) var(--p-fs-title-dialog)/var(--p-lh-title-dialog) var(--p-font); letter-spacing: var(--p-ls-title-dialog); text-wrap: balance; }
.p-t-title-m { font: var(--p-fw-title-m) var(--p-fs-title-m)/var(--p-lh-title-m) var(--p-font); text-wrap: balance; }
.p-t-title-s { font: var(--p-fw-title-s) var(--p-fs-title-s)/var(--p-lh-title-s) var(--p-font); text-wrap: balance; }
.p-t-lede { font: 400 var(--p-fs-lede)/var(--p-lh-lede) var(--p-font); color: var(--p-muted); text-wrap: pretty; margin: 0; }
.p-t-body { font: 400 var(--p-fs-body)/var(--p-lh-body) var(--p-font); color: var(--p-ink); text-wrap: pretty; margin: 0; }
.p-t-body-s { font: 400 var(--p-fs-body-s)/var(--p-lh-body-s) var(--p-font); color: var(--p-muted); text-wrap: pretty; margin: 0; }
.p-t-caption { font: 400 var(--p-fs-caption)/var(--p-lh-caption) var(--p-font); color: var(--p-muted); text-wrap: pretty; }
.p-t-kicker { font-family: var(--p-mono); font-size: var(--p-fs-kicker); letter-spacing: var(--p-ls-kicker); text-transform: uppercase; color: var(--p-muted); }
.p-t-kicker-s { font-family: var(--p-mono); font-size: var(--p-fs-kicker-s); letter-spacing: var(--p-ls-kicker-s); text-transform: uppercase; color: var(--p-muted); }
.p-t-meta { font-family: var(--p-mono); font-size: 11.5px; color: var(--p-muted); }
.p-t-mono { font-family: var(--p-mono); font-size: 13px; color: var(--p-ink); overflow-wrap: anywhere; }

/* ---- Button [B, fBtn] (§7) ---- */
.p-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  height: var(--p-h-btn); min-width: 0; padding: 0 18px; border-radius: var(--p-r-pill);
  border: 1px solid var(--p-line); background: var(--p-card); color: var(--p-ink);
  font-size: var(--p-fs-button); font-weight: var(--p-fw-button); line-height: 1;
  white-space: nowrap; flex: 0 0 auto; cursor: pointer; text-decoration: none;
  position: relative;
}
/* 44 px minimum hit target, 48 dp on Android, without changing the visual (§4.3). */
.p-hit { position: relative; }
/* Read by screen readers, not drawn (e.g. the static sentence beside an aria-hidden countdown). */
.p-sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.p-btn::after, .p-hit::after {
  content: ''; position: absolute; left: 50%; top: 50%;
  width: max(100%, var(--p-hit)); height: max(100%, var(--p-hit)); transform: translate(-50%, -50%);
}
.p-btn--cta, .p-btn--out {
  height: var(--p-h-cta); padding: 0 32px; min-width: var(--p-w-cta-min);
  font-size: var(--p-fs-button-cta); font-weight: var(--p-fw-button-cta);
}
.p-btn--cta, .p-btn--pri { background: var(--p-ink); border-color: var(--p-ink); color: var(--p-on-ink); }
.p-btn--out { border-color: var(--p-ink); }
.p-btn--ghost { border: none; background: transparent; padding: 0 4px; font-size: var(--p-fs-body); }
.p-btn--danger { background: var(--p-bad); border-color: var(--p-bad); color: var(--p-danger-ink); }
.p-btn--bad { border-color: var(--p-bad); color: var(--p-bad); }
.p-btn--sm { height: var(--p-h-btn-sm); padding: 0 14px; font-size: var(--p-fs-button-sm); }
.p-btn--sm.p-btn--ghost { padding: 0 4px; }
.p-btn--foot { font-size: var(--p-fs-button-cta-foot); }
.p-btn--full { width: 100%; min-width: 0; }
.p-btn:disabled, .p-btn[aria-disabled="true"] { opacity: .38; cursor: not-allowed; }
.p-btn .p-spin { width: 14px; height: 14px; }
.p-btn--cta .p-spin, .p-btn--out .p-spin { width: 18px; height: 18px; }
.p-btn--cta .p-spin, .p-btn--pri .p-spin, .p-btn--danger .p-spin { border-color: currentColor; border-right-color: transparent; }
.p-btn .p-icon { flex: 0 0 auto; }

/* Text link [LK] */
.p-link {
  border: none; background: transparent; padding: 0; color: var(--p-ink); font: inherit;
  text-decoration: underline; text-underline-offset: 2px; cursor: pointer;
}

/* ---- Spinner [SP] and check glyph [G] ---- */
.p-spin {
  display: inline-block; flex: 0 0 auto; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--p-ink); border-right-color: transparent;
  animation: p-spin var(--p-dur-spin) linear infinite;
}
.p-glyph {
  width: 22px; height: 22px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 12px/1 var(--p-font); color: var(--g); background: color-mix(in oklch, var(--g) var(--p-tint-glyph), transparent);
}
.p-glyph--pass { --g: var(--p-good); }
.p-glyph--warn { --g: var(--p-warn); }
.p-glyph--fail { --g: var(--p-bad); }
.p-glyph--info { --g: var(--p-info); }
.p-glyph--skip, .p-glyph--wait { --g: var(--p-muted); background: transparent; border: 1.5px solid var(--p-glyph-ring); }
.p-glyph--skip { border-style: dashed; }
.p-glyph--run { background: transparent; }
.p-glyph--run .p-spin { width: 14px; height: 14px; }

/* ---- Dots ---- */
.p-dot { display: inline-block; flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--d, var(--p-muted)); }
.p-dot--ring { background: transparent; border: 1.5px solid var(--d, var(--p-muted)); }
.p-dot--live { animation: p-run-dot var(--p-dur-run-dot) ease-in-out infinite; }

/* ---- Status pill [PILL, fPill] and agent status pill [statusPill] ---- */
.p-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px;
  border-radius: var(--p-r-pill); flex: 0 0 auto; white-space: nowrap;
  background: color-mix(in oklch, var(--c) var(--p-tint-pill), transparent); color: var(--ct, var(--c));
  font-family: var(--p-mono); font-size: var(--p-fs-status); letter-spacing: var(--p-ls-pill); text-transform: uppercase;
}
.p-pill .p-dot { width: 6px; height: 6px; --d: var(--c); }
.p-pill--agent {
  height: auto; padding: 4px 9px; font-weight: 700; letter-spacing: var(--p-ls-status);
  background: color-mix(in oklch, var(--c) var(--p-tint-agent), transparent);
}
.p-pill--agent .p-dot { width: 7px; height: 7px; }

/* ---- Tag [TAG, fTag] ---- */
.p-tag {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: var(--p-r-pill);
  flex: 0 0 auto; white-space: nowrap;
  background: color-mix(in oklch, var(--c) var(--p-tint-tag), transparent); color: var(--ct, var(--c));
  font-family: var(--p-mono); font-size: var(--p-fs-tag); letter-spacing: var(--p-ls-tag);
}

/* ---- Card [C, fCard] and section label [fSec, LAB] ---- */
.p-card {
  background: var(--p-card); border: 1px solid var(--p-line); border-radius: var(--p-r-card);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; color: var(--p-ink);
}
.p-sec { display: flex; align-items: baseline; gap: 10px; margin: 10px 4px 0; }
.p-sec--flush { margin: 0; }
.p-sec__label { font-family: var(--p-mono); font-size: var(--p-fs-kicker); letter-spacing: var(--p-ls-kicker); color: var(--p-muted); text-transform: uppercase; white-space: nowrap; }
.p-sec__right { margin-left: auto; font-family: var(--p-mono); font-size: 11px; color: var(--p-muted); white-space: nowrap; }
.p-intro { font-size: 14px; line-height: 1.5; color: var(--p-muted); text-wrap: pretty; padding: 0 4px; font-family: var(--p-font); }

/* ---- Text field [F] ---- */
.p-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; color: var(--p-ink); }
.p-field__label { padding-left: 12px; font-size: 14px; line-height: 20px; color: var(--p-muted); }
.p-field__opt { opacity: .8; }
.p-field__box {
  display: flex; align-items: center; gap: 10px; height: var(--p-h-field); padding: 0 22px 0 24px;
  border: 1px solid var(--p-field); border-radius: var(--p-r-field); background: var(--p-card);
}
.p-field__box:focus-within { outline: var(--p-focus-width) solid var(--p-focus-color); outline-offset: var(--p-focus-offset); }
.p-field--area .p-field__box { align-items: flex-start; height: auto; padding: 15px 22px; border-radius: var(--p-r-card); }
.p-field--ro .p-field__box, .p-field--dis .p-field__box { background: var(--p-soft); }
.p-field--err .p-field__box { border-color: var(--p-bad); box-shadow: 0 0 0 1px var(--p-bad); }
.p-field__input {
  flex: 1; min-width: 0; height: 100%; border: none; outline: none; background: transparent; padding: 0; margin: 0;
  color: var(--p-ink); font-family: var(--p-font); font-size: var(--p-fs-field);
}
.p-field__input::placeholder { color: var(--p-muted); opacity: 1; }
.p-field--area .p-field__input { resize: vertical; line-height: 22px; height: auto; }
.p-field--mono .p-field__input { font-family: var(--p-mono); font-size: var(--p-fs-field-mono); letter-spacing: var(--p-ls-field-mono); }
.p-field__pre { color: var(--p-muted); font-family: var(--p-mono); font-size: 14px; flex: 0 0 auto; }
.p-field__show {
  border: none; background: transparent; color: var(--p-ink); font-family: var(--p-font); font-size: 13px;
  cursor: pointer; padding: 0; flex: 0 0 auto; position: relative;
}
.p-field__msg { padding-left: 12px; font-size: 13px; line-height: 18px; color: var(--p-muted); text-wrap: pretty; }
.p-field__msg--err { color: var(--p-bad); }
.p-field__msg--ok { color: var(--p-good); }
.p-field__msg--warn { color: var(--p-warn); }

/* ---- Check list [CK] ---- */
.p-check { gap: 12px; }
.p-check__row { display: flex; gap: 12px; align-items: flex-start; }
.p-check__row + .p-check__row { padding-top: 12px; border-top: 1px solid var(--p-line); }
.p-check__main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.p-check__head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.p-check__name { font-size: var(--p-fs-body); font-weight: 500; line-height: 22px; color: var(--p-ink); }
.p-check__row--warn .p-check__name, .p-check__row--fail .p-check__name { font-weight: 600; }
.p-check__row--skip .p-check__name, .p-check__row--wait .p-check__name { color: var(--p-muted); }
.p-check__meta {
  margin-left: auto; font-family: var(--p-mono); font-size: 11.5px; line-height: 22px; color: var(--p-muted);
  text-align: right; min-width: 0; overflow-wrap: anywhere;
}
.p-check__row--fail .p-check__meta { color: var(--p-bad); }
.p-check__row--warn .p-check__meta { color: var(--p-warn); }
.p-check__desc { font-size: 14px; line-height: 20px; color: var(--p-muted); text-wrap: pretty; }
.p-check__acts { display: flex; gap: 8px; margin-top: 2px; flex-wrap: wrap; }

/* ---- Notice [N] ---- */
.p-notice {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--p-r-notice); align-items: flex-start;
  background: color-mix(in oklch, var(--c) var(--p-tint-notice), transparent); color: var(--p-ink);
}
.p-notice__main { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1; }
.p-notice__title { font-size: 15px; font-weight: 600; line-height: 21px; text-wrap: pretty; }
.p-notice__body { font-size: 14px; line-height: 20px; opacity: .8; text-wrap: pretty; }
.p-notice__acts { display: flex; gap: 8px; margin-top: 6px; flex-wrap: wrap; }

/* ---- Dialog [DLG] (§7): centred ≥ 560 px, bottom sheet below ---- */
.p-layer {
  position: fixed; inset: 0; z-index: var(--p-z-menu); display: flex; align-items: center; justify-content: center;
  padding: 24px; font-family: var(--p-font);
}
/* A dialog is modal over everything but a toast: a confirm opened from a sheet (55) or a drawer
   (60) must draw above it, as it sits above it in the Esc stack. */
.p-layer--dialog { z-index: calc(var(--p-z-drawer) + 5); }
.p-scrim { position: absolute; inset: 0; background: var(--p-scrim-dialog); backdrop-filter: var(--p-scrim-blur); -webkit-backdrop-filter: var(--p-scrim-blur); }
.p-dialog {
  position: relative; width: 100%; max-width: var(--p-max-dialog); background: var(--p-screen); color: var(--p-ink);
  border-radius: var(--p-r-dialog); padding: 26px 26px 22px; display: flex; flex-direction: column; gap: 16px;
  box-shadow: var(--p-shadow-dialog); max-height: calc(100% - 48px); overflow-y: auto;
  animation: p-pop-in var(--p-dur-pop-dialog) var(--p-ease);
}
.p-dialog__title { margin: 0; }
.p-dialog__acts { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; margin-top: 4px; }
@media (max-width: 559.98px) {
  .p-layer--dialog { align-items: flex-end; padding: 0; }
  .p-dialog {
    max-width: none; border-radius: var(--p-r-dialog) var(--p-r-dialog) 0 0; padding: 24px 22px 28px;
    max-height: 88%; animation: p-sheet-up var(--p-dur-sheet) var(--p-ease);
  }
  .p-dialog__acts { flex-direction: column-reverse; }
}

/* D-05: pop-in / sheet-up / drawer-in become fades; live dots stop pulsing. */
@media (prefers-reduced-motion: reduce) {
  .p-dialog, .p-sheet, .p-drawer, .p-menu { animation-name: p-fade-in !important; }
  .p-dot--live { animation: none; }
  /* IM-A11Y-002: the mock's inline motion collapses only under the OS setting; end states (and animationend) unchanged. */
  [data-p-el] { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
