/* ==========================================================================
   CoreAxis global search — command palette (assets/js/cax-search.js)
   Standalone: used by the staff shell (style.css tokens, dark + light) and by
   the student portal (light, .cxs-light). Never widens the page.
   ========================================================================== */

/* ---- top-bar trigger (staff) ---- */
.cxs-trigger{
  display:flex; align-items:center; gap:9px; flex:0 1 340px; min-width:0; max-width:340px; height:36px;
  padding:0 8px 0 12px; margin:0; border-radius:9px; cursor:pointer;
  background:var(--card2,rgba(255,255,255,.08)); border:1px solid var(--border,rgba(255,255,255,.1));
  color:var(--text2,#94a3b8); font:inherit; font-size:13px; text-align:left; transition:border-color .15s,color .15s,background .15s;
}
.cxs-trigger:hover,.cxs-trigger:focus-visible{ border-color:var(--saffron,#f59e0b); color:var(--text,#e2e8f0); outline:none; }
.cxs-trigger > i{ font-size:13px; flex-shrink:0; }
.cxs-trigger-txt{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cxs-kbd,.cxs-overlay kbd{
  font:600 11px/1 ui-monospace,SFMono-Regular,Consolas,monospace; padding:4px 6px; border-radius:5px; white-space:nowrap;
  background:rgba(148,163,184,.14); border:1px solid rgba(148,163,184,.28); color:inherit;
}
.cxs-kbd{ flex-shrink:0; }
/* portal variant (light app bar) */
.cxs-trigger.cxs-portal{ background:#f1f5f9; border-color:#e2e8f0; color:#5b6b82; flex-basis:300px; }
.cxs-trigger.cxs-portal:hover,.cxs-trigger.cxs-portal:focus-visible{ border-color:#f0a830; color:#0a2342; }
@media (max-width:860px){ .cxs-trigger.cxs-portal{ margin-left:auto; } }

@media (max-width:1100px){ .cxs-trigger{ flex-basis:250px; } }
@media (max-width:900px){ .cxs-trigger .cxs-kbd{ display:none; } .cxs-trigger{ flex-basis:200px; } }
@media (max-width:768px){
  /* phones/tablets: icon button like its neighbours */
  .cxs-trigger,.cxs-trigger.cxs-portal{ flex:0 0 auto; width:32px; height:31px; padding:0; justify-content:center; }
  .cxs-trigger .cxs-trigger-txt{ display:none; }
}

/* ---- overlay + dialog ---- */
html.cxs-lock,html.cxs-lock body{ overflow:hidden; }
.cxs-overlay{
  --cxs-bg:#122040; --cxs-bg2:#0f1b36; --cxs-text:#e2e8f0; --cxs-mut:#94a3b8; --cxs-line:rgba(255,255,255,.09);
  --cxs-on:rgba(245,158,11,.14); --cxs-acc:#f59e0b; --cxs-ico:rgba(255,255,255,.06); --cxs-hl:rgba(245,158,11,.3);
  position:fixed; inset:0; z-index:100500; background:rgba(3,8,20,.62); backdrop-filter:blur(3px);
  display:flex; align-items:flex-start; justify-content:center; padding:10vh 16px 16px; box-sizing:border-box;
  font-family:'Inter','Segoe UI',system-ui,-apple-system,sans-serif;
}
.cxs-overlay[hidden]{ display:none; }
html[data-theme="light"] .cxs-overlay,.cxs-overlay.cxs-light{
  --cxs-bg:#ffffff; --cxs-bg2:#f8fafc; --cxs-text:#1e293b; --cxs-mut:#64748b; --cxs-line:rgba(15,23,42,.1);
  --cxs-on:rgba(245,158,11,.14); --cxs-acc:#d97706; --cxs-ico:#f1f5f9; --cxs-hl:rgba(245,158,11,.32);
  background:rgba(15,23,42,.42);
}
.cxs-dialog{
  width:100%; max-width:640px; max-height:76vh; display:flex; flex-direction:column; overflow:hidden; box-sizing:border-box;
  background:var(--cxs-bg); color:var(--cxs-text); border:1px solid var(--cxs-line); border-radius:16px;
  box-shadow:0 30px 70px rgba(0,0,0,.45); animation:cxsIn .14s ease-out;
}
@keyframes cxsIn{ from{ opacity:0; transform:translateY(-8px) scale(.985); } to{ opacity:1; transform:none; } }
.cxs-head{ display:flex; align-items:center; gap:10px; padding:12px 14px; border-bottom:1px solid var(--cxs-line); }
.cxs-head > i{ color:var(--cxs-acc); font-size:16px; flex-shrink:0; }
.cxs-input{
  flex:1; min-width:0; background:transparent !important; border:0 !important; outline:none !important; box-shadow:none !important;
  color:var(--cxs-text) !important; font:inherit; font-size:16px !important; padding:6px 0 !important; margin:0; height:auto;
}
.cxs-input::placeholder{ color:var(--cxs-mut); }
.cxs-input::-webkit-search-cancel-button{ display:none; }
.cxs-spin{ color:var(--cxs-mut); font-size:14px; }
.cxs-spin i,.cxs-loading i{ animation:cxsSpin .8s linear infinite; }
@keyframes cxsSpin{ to{ transform:rotate(360deg); } }
.cxs-close{
  flex-shrink:0; background:var(--cxs-ico); border:1px solid var(--cxs-line); color:var(--cxs-mut); border-radius:7px;
  padding:5px 8px; font:600 11px/1 ui-monospace,Consolas,monospace; cursor:pointer;
}
.cxs-close:hover{ color:var(--cxs-text); }
.cxs-close-txt{ display:none; }

.cxs-body{ flex:1; overflow-y:auto; overscroll-behavior:contain; padding:6px 8px 10px; }
.cxs-grp{
  display:flex; align-items:center; gap:7px; padding:10px 8px 5px; font-size:11px; font-weight:700; letter-spacing:.06em;
  text-transform:uppercase; color:var(--cxs-mut);
}
.cxs-grp i{ font-size:11px; }
.cxs-grp span{ flex:1; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cxs-clear{ background:none; border:0; color:var(--cxs-acc); font:inherit; font-size:11px; cursor:pointer; text-transform:none; letter-spacing:0; padding:2px 4px; }
.cxs-clear:hover{ text-decoration:underline; }
.cxs-item{
  display:flex; align-items:center; gap:11px; padding:8px 10px; border-radius:10px; cursor:pointer;
  color:var(--cxs-text) !important; text-decoration:none !important; min-width:0; border:1px solid transparent;
}
.cxs-item.on{ background:var(--cxs-on); border-color:rgba(245,158,11,.35); }
.cxs-ico{
  width:32px; height:32px; flex-shrink:0; border-radius:9px; display:flex; align-items:center; justify-content:center;
  background:var(--cxs-ico); color:var(--cxs-acc); font-size:13px;
}
.cxs-txt{ flex:1; min-width:0; display:flex; flex-direction:column; gap:1px; }
.cxs-t{ font-size:14px; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cxs-s{ font-size:12px; color:var(--cxs-mut); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.cxs-badge{
  flex-shrink:0; font-size:10.5px; font-weight:700; color:var(--cxs-mut); border:1px solid var(--cxs-line);
  border-radius:20px; padding:2px 8px; white-space:nowrap;
}
.cxs-item.on .cxs-badge{ color:var(--cxs-acc); border-color:rgba(245,158,11,.4); }
mark.cxs-hl{ background:var(--cxs-hl); color:inherit; border-radius:3px; padding:0 1px; }
.cxs-note{ display:flex; align-items:flex-start; gap:8px; padding:10px 10px; font-size:12.5px; color:var(--cxs-mut); line-height:1.45; }
.cxs-note i{ margin-top:2px; }
.cxs-err{ color:#f87171; }
.cxs-light .cxs-err,html[data-theme="light"] .cxs-err{ color:#dc2626; }
.cxs-empty{ text-align:center; padding:28px 16px 22px; color:var(--cxs-mut); }
.cxs-empty > i{ font-size:26px; opacity:.6; margin-bottom:10px; display:block; }
.cxs-empty-t{ font-size:14px; color:var(--cxs-text); word-break:break-word; }
.cxs-empty-s{ font-size:12.5px; margin-top:5px; }
.cxs-foot{
  display:flex; align-items:center; gap:14px; flex-wrap:wrap; padding:9px 14px; border-top:1px solid var(--cxs-line);
  background:var(--cxs-bg2); font-size:11.5px; color:var(--cxs-mut);
}
.cxs-foot-r{ margin-left:auto; }

/* ---- phones: full-screen palette ---- */
@media (max-width:640px){
  .cxs-overlay{ padding:0; align-items:stretch; }
  .cxs-dialog{ max-width:none; max-height:none; height:100%; border-radius:0; border:0; }
  .cxs-head{ padding:10px 12px; }
  .cxs-close-esc{ display:none; }
  .cxs-close-txt{ display:inline; }
  .cxs-close{ font-family:inherit; font-size:13px; padding:7px 10px; color:var(--cxs-acc); }
  .cxs-foot{ display:none; }
  .cxs-item{ padding:10px 8px; }
  .cxs-badge{ display:none; }
}

/* ---- target highlight after a jump (#cxs-find / portal records) ---- */
@keyframes cxsFlash{ 0%,40%{ box-shadow:0 0 0 3px rgba(245,158,11,.75); background-color:rgba(245,158,11,.16); } 100%{ box-shadow:0 0 0 3px rgba(245,158,11,0); } }
.cxs-flash{ animation:cxsFlash 2.4s ease-out; border-radius:6px; }
@media (prefers-reduced-motion:reduce){ .cxs-dialog,.cxs-spin i,.cxs-loading i{ animation:none; } }
@media print{ .cxs-trigger,.cxs-overlay{ display:none !important; } }
