/* House pop-ups — "Quiet" (user, 2026-10-15; drafts in static/proto/popup-styles.html). Spec: docs/features/popups.md.

   One look for every dialog, popover and menu: no rules inside, whitespace separates title / body / buttons,
   ghost × to close, buttons on the right (Cancel, then primary), destructive text button far left, light dim
   behind dialogs (no blur), fade + 6px rise. No drawers: anything that used to slide in from a side is a
   centred dialog. Pages restyle nothing here; they set a size (.sm/.lg/.xl) and lay out their own body.

   Markup:
     dialog   <div class="aiq-dlg [sm|lg|xl]" role="dialog" aria-modal="true" hidden>
                <header class="aiq-dlg-h"><h2 class="aiq-dlg-t">Title <span class="ctx">· context</span></h2>
                  <button class="aiq-x" aria-label="Close"><i class="ph-bold ph-x"></i></button></header>
                <div class="aiq-dlg-b">…</div>
                <footer class="aiq-dlg-f"><button class="aiq-btn txt">Clear</button><span class="sp"></span>
                  <button class="aiq-btn">Cancel</button><button class="aiq-btn pri">Save</button></footer></div>
              opened with aiqDialog.open(el) (scrim, Esc, focus) — static/js/aiq-pop.js
     popover  <div class="aiq-pop"><div class="aiq-pop-h">Title</div><div class="aiq-pop-b">…</div><div class="aiq-pop-f">…</div></div>
              (no ×: outside click / Esc closes it; the page positions it)
     menu     <div class="aiq-menu"><button class="aiq-mi"><i class="ph ph-pencil-simple"></i>Rename</button>
                <div class="aiq-menu-hr"></div><button class="aiq-mi red">Delete…</button></div>
     confirm  aiqConfirm({title, message, ok: 'Delete', danger: true}) → Promise<boolean>; hx-confirm uses it too. */

:root {
  --pop-bg: #292929;
  --pop-ink: rgba(255,255,255,0.95);
  --pop-sub: rgba(203,213,225,0.72);
  --pop-faint: rgba(148,163,184,0.62);
  --pop-line: rgba(255,255,255,0.08);
  --pop-line2: rgba(255,255,255,0.14);
  --pop-hover: rgba(255,255,255,0.05);
  --pop-input: #1F1F1F;
  --pop-blue: #455DDC;
  --pop-blue-h: #3a50c4;
  --pop-blue-ink: #9AA9F5;
  --pop-red: #F73463;
  --pop-scrim: rgba(0,0,0,0.5);
  --pop-shadow: 0 12px 32px rgba(0,0,0,0.5);
  /* One z-index scale for everything that floats (app chrome tops out at 210; the sidebar is 200). */
  --z-pop: 1000;      /* popovers, menus, hover cards */
  --z-scrim: 1090;    /* dim behind a dialog */
  --z-dlg: 1100;      /* dialogs */
  --z-dlg-top: 1200;  /* a confirm opened from inside a dialog */
}
html[data-theme="light"] {
  --pop-bg: #ffffff;
  --pop-ink: #0f172a;
  --pop-sub: #64748b;
  --pop-faint: #94a3b8;
  --pop-line: rgba(15,23,42,0.08);
  --pop-line2: rgba(15,23,42,0.14);
  --pop-hover: rgba(15,23,42,0.04);
  --pop-input: #ffffff;
  --pop-blue-ink: #3347C8;
  --pop-red: #c8203f;
  --pop-scrim: rgba(15,17,21,0.32);
  --pop-shadow: 0 12px 32px rgba(15,23,42,0.14);
}

@keyframes aiqPopRise { from { opacity: 0; translate: 0 6px; } to { opacity: 1; translate: 0 0; } }
@keyframes aiqPopFade { from { opacity: 0; } to { opacity: 1; } }

/* ── scrim ── */
.aiq-scrim { position: fixed; inset: 0; z-index: var(--z-scrim); background: var(--pop-scrim); animation: aiqPopFade .16s ease-out; }
.aiq-scrim.top { z-index: calc(var(--z-dlg-top) - 1); }

/* ── dialog ── */
.aiq-dlg { position: fixed; z-index: var(--z-dlg); left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(var(--dlg-w, 500px), calc(100vw - 32px)); max-height: calc(100vh - 64px);
  display: flex; flex-direction: column; background: var(--pop-bg); color: var(--pop-ink);
  border: 1px solid var(--pop-line); border-radius: 4px; box-shadow: var(--pop-shadow);
  font-family: 'Inter', sans-serif; font-size: 13px; line-height: 1.45; text-align: left;
  animation: aiqPopRise .16s ease-out; }
.aiq-dlg.sm { --dlg-w: 380px; }
.aiq-dlg.lg { --dlg-w: 760px; }
.aiq-dlg.xl { --dlg-w: 1100px; }
.aiq-dlg.tall { height: calc(100vh - 96px); }
.aiq-dlg.top { z-index: var(--z-dlg-top); }
.aiq-dlg[hidden], .aiq-scrim[hidden], .aiq-pop[hidden], .aiq-menu[hidden] { display: none !important; }

.aiq-dlg-h { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; flex: none; min-width: 0; }
.aiq-dlg-t { margin: 0; font-size: 15px; font-weight: 600; color: var(--pop-ink); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.aiq-dlg-t .ctx { color: var(--pop-sub); font-weight: 500; }
.aiq-dlg-b { padding: 6px 18px 14px; overflow: auto; flex: 1 1 auto; min-height: 0; }
.aiq-dlg-f { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 6px 18px 16px; flex: none; flex-wrap: wrap; }
.aiq-dlg-f .sp { flex: 1; }
.aiq-dlg-msg { margin: 0; color: var(--pop-sub); }

/* close: ghost × */
.aiq-x { margin-left: auto; margin-right: -6px; flex: none; width: 28px; height: 28px; display: grid; place-items: center;
  border: 0; border-radius: 4px; background: transparent; color: var(--pop-sub); cursor: pointer; font-size: 16px; line-height: 1; padding: 0; }
.aiq-x:hover { background: var(--pop-hover); color: var(--pop-ink); }
.aiq-x i { font-size: 15px; }

/* buttons */
.aiq-btn { height: 30px; padding: 0 12px; border-radius: 4px; border: 1px solid var(--pop-line2); background: transparent;
  color: var(--pop-ink); font: inherit; font-size: 13px; font-weight: 550; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; }
.aiq-btn:hover { background: var(--pop-hover); }
.aiq-btn.pri { background: var(--pop-blue); border-color: var(--pop-blue); color: #fff; }
.aiq-btn.pri:hover { background: var(--pop-blue-h); border-color: var(--pop-blue-h); }
.aiq-btn.danger { background: var(--pop-red); border-color: var(--pop-red); color: #fff; }
.aiq-btn.danger:hover { filter: brightness(0.94); }
.aiq-btn.txt { border-color: transparent; color: var(--pop-sub); padding: 0 6px; }
.aiq-btn.txt:hover { color: var(--pop-ink); background: transparent; }
.aiq-btn.txt.red { color: var(--pop-red); }
.aiq-btn:disabled { opacity: .5; cursor: default; }

/* inputs inside any pop-up */
.aiq-dlg .aiq-in, .aiq-pop .aiq-in { height: 30px; width: 100%; border: 1px solid var(--pop-line2); border-radius: 4px;
  background: var(--pop-input); color: var(--pop-ink); padding: 0 9px; font: inherit; font-size: 13px; }
.aiq-dlg .aiq-in:focus, .aiq-pop .aiq-in:focus { outline: none; border-color: var(--pop-blue); }
.aiq-fld { display: block; margin-bottom: 12px; }
.aiq-fld > span { display: block; font-size: 12px; font-weight: 550; color: var(--pop-sub); margin-bottom: 4px; }

/* ── popover (anchored, no scrim, no ×) ── */
.aiq-pop { position: fixed; z-index: var(--z-pop); background: var(--pop-bg); color: var(--pop-ink);
  border: 1px solid var(--pop-line); border-radius: 4px; box-shadow: var(--pop-shadow);
  font-family: 'Inter', sans-serif; font-size: 13px; line-height: 1.45; animation: aiqPopRise .14s ease-out; }
.aiq-pop-h { padding: 12px 14px 2px; font-size: 13px; font-weight: 600; color: var(--pop-ink); display: flex; align-items: center; gap: 8px; }
.aiq-pop-h .ctx { color: var(--pop-sub); font-weight: 500; }
.aiq-pop-b { padding: 4px 14px 8px; }
.aiq-pop-f { display: flex; align-items: center; justify-content: flex-end; gap: 8px; padding: 4px 14px 12px; }
.aiq-pop-f .sp { flex: 1; }

/* ── menu ── */
.aiq-menu { position: fixed; z-index: var(--z-pop); min-width: 190px; padding: 5px; background: var(--pop-bg); color: var(--pop-ink);
  border: 1px solid var(--pop-line); border-radius: 4px; box-shadow: var(--pop-shadow);
  font-family: 'Inter', sans-serif; font-size: 13px; animation: aiqPopRise .14s ease-out; }
.aiq-mi { display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 10px; border: 0; border-radius: 3px;
  background: transparent; color: var(--pop-ink); font: inherit; text-align: left; cursor: pointer; white-space: nowrap; text-decoration: none; }
.aiq-mi:hover, .aiq-mi.hv { background: var(--pop-hover); }
.aiq-mi > i, .aiq-mi > svg { font-size: 15px; width: 15px; color: var(--pop-sub); flex: none; }
.aiq-mi.on { color: var(--pop-blue-ink); font-weight: 600; }
.aiq-mi.red, .aiq-mi.red > i { color: var(--pop-red); }
.aiq-menu-hr { height: 1px; background: var(--pop-line); margin: 4px 0; }
.aiq-menu-lbl { padding: 6px 10px 3px; font-size: 11px; font-weight: 600; color: var(--pop-sub); }

@media (prefers-reduced-motion: reduce) {
  .aiq-dlg, .aiq-pop, .aiq-menu, .aiq-scrim { animation: none; }
}

/* base.html forces light-mode inputs to a #c0c0bc border with !important; inside pop-ups use the kit's border + blue focus. */
html[data-theme="light"] :is(.aiq-dlg, .aiq-pop, .aiq-menu) :is(input[type], select, textarea):not(.bg-transparent) { border-color: var(--pop-line2) !important; }
html[data-theme="light"] :is(.aiq-dlg, .aiq-pop, .aiq-menu) :is(input[type], select, textarea):not(.bg-transparent):focus { border-color: var(--pop-blue) !important; }
