/* ==========================================================================
   shell-features.css — pieces of the shell added in the website feature
   round (Oct 2026). app.js links this file on every page (the new pages
   link it in their <head>); everything here opens after the first paint
   (popover, sheets, dialogs), so the late link never flashes. Tokens only:
   colours, radii, type and motion come from style.css.

     1. Keyboard keys (<kbd>)
     2. Global search: topbar field, results popover, phone sheet rows
     3. Password meter, form-level alert
     4. "Forgot password?" sheet
     5. Set-password dialog
     6. Keyboard-shortcuts sheet
     7. Print: the shell chrome stays off paper
   ========================================================================== */

/* ---- 1. Keys ----------------------------------------------------------------- */
:where(kbd) {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 6px;
  border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 6px;
  background: var(--surface-2); color: var(--text);
  font: 600 var(--fs-xs)/1 ui-monospace, "SF Mono", Consolas, monospace;
  white-space: nowrap;
}

/* ---- 2. Global search ------------------------------------------------------------
   The field shows a "/" key while idle; focused, it opens .gs-pop under it. */
.topbar-search input { padding-right: 40px; }
.gs-slash {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--text-muted);
}
.topbar-search:focus-within .gs-slash,
.topbar-search input:not(:placeholder-shown) ~ .gs-slash { display: none; }
.topbar-search.is-open input { border-color: var(--brand); box-shadow: var(--ring); }

.gs-pop {
  position: absolute; top: calc(100% + 8px); left: 0;
  z-index: var(--z-menu);
  width: min(560px, calc(100vw - 32px));
  max-height: min(70vh, 560px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--elev-3);
  animation: rps-pop-in var(--dur-2) var(--ease-out);
}
.gs-pop[hidden] { display: none; }
/* style.css pins ".topbar-search svg" (the field's magnifier) absolutely;
   the icons inside the results flow with their rows. */
.topbar-search .gs-pop svg { position: static; top: auto; left: auto; transform: none; width: auto; height: auto; color: inherit; }

.gs-group {
  display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2);
  padding: 12px 10px 4px;
  font-size: var(--fs-xs); font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-muted);
}
.gs-group:first-child { padding-top: 6px; }
.gs-clear {
  border: 0; border-radius: var(--r-sm); background: none; cursor: pointer;
  padding: 6px 8px; margin: -6px -4px -6px 0;
  color: var(--text-muted); font: 600 var(--fs-xs)/1 var(--font); letter-spacing: 0; text-transform: none;
  text-decoration: underline; text-underline-offset: 2px;
}
@media (hover: hover) and (pointer: fine) { .gs-clear:hover { color: var(--text); } }
.gs-clear:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.gs-row {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  width: 100%; min-height: 44px; padding: 6px 10px;
  border: 0; border-radius: var(--r-sm);
  background: transparent; color: var(--text);
  font: 500 var(--fs-md)/1.3 var(--font); text-align: left; text-decoration: none;
  cursor: pointer;
}
.gs-row > .icon { flex: none; color: var(--text-muted); }
@media (hover: hover) and (pointer: fine) { .gs-row:hover { background: var(--surface-muted); } }
/* The keyboard's row: a tint plus the crimson focus bar. */
.gs-row.is-active { background: var(--surface-muted); }
.gs-row.is-active::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px;
  border-radius: 0 3px 3px 0; background: var(--brand);
}
.gs-ico {
  flex: none; width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: var(--r-sm); background: var(--surface-muted); color: var(--text-muted);
}
.gs-row.is-active .gs-ico { background: var(--surface); color: var(--text); }
.gs-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.gs-title, .gs-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gs-title { font-weight: 600; }
.gs-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.gs-primary .gs-title { font-weight: 700; }
.gs-primary > .icon { color: var(--text); }
.gs-row .pill, .gs-kbd { flex: none; }
.gs-hint {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: 12px 10px; color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.45;
}
.gs-spin {
  flex: none; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border-strong); border-top-color: var(--text);
  animation: gs-spin .7s linear infinite;
}
@keyframes gs-spin { to { transform: rotate(360deg); } }
.gs-foot {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  margin-top: 6px; padding: 10px 10px 6px;
  border-top: 1px solid var(--border);
  color: var(--text-muted); font-size: var(--fs-xs);
}
.gs-foot kbd { min-width: 20px; height: 20px; margin-right: 2px; }

/* Phone sheet: the same rows, a size up for thumbs. */
.search-sheet .gs-list { padding: 4px 8px 24px; }
.search-sheet .gs-row { min-height: 52px; font-size: 15px; }
.search-sheet .gs-group { padding: 16px 12px 6px; }
.search-sheet .gs-clear { min-height: 44px; }
.search-sheet .gs-kbd { display: none; }
/* The field draws the focus ring; the input inside it does not add a second. */
.search-field input:focus { box-shadow: none; }

/* ---- 3. Password meter, form alert --------------------------------------------- */
.pw-meter { display: flex; align-items: center; gap: 10px; margin-top: 8px; min-height: 20px; }
.pw-bars { flex: none; display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; width: 112px; }
.pw-bars i { height: 4px; border-radius: var(--r-full); background: var(--border-strong); transition: background var(--dur-2) var(--ease-out); }
.pw-meter[data-score="1"] .pw-bars i:nth-child(-n+1) { background: var(--tone-danger-solid); }
.pw-meter[data-score="2"] .pw-bars i:nth-child(-n+2) { background: var(--tone-warning-solid); }
.pw-meter[data-score="3"] .pw-bars i:nth-child(-n+3) { background: var(--tone-success-solid); }
.pw-meter[data-score="4"] .pw-bars i { background: var(--tone-success-solid); }
.pw-label { font-size: var(--fs-xs); font-weight: 600; color: var(--text-muted); }

/* A refusal that belongs to the whole form (wrong sign-in, rate limit). */
.form-alert {
  display: flex; align-items: flex-start; gap: 10px;
  margin-top: var(--sp-3); padding: 10px 12px;
  border-radius: var(--r-sm);
  background: var(--tone-danger-bg); color: var(--tone-danger-fg);
  font-size: var(--fs-sm); font-weight: 600; line-height: 1.45;
}
.form-alert[hidden] { display: none; }
.form-alert > svg { flex: none; margin-top: 2px; }
.form-alert > span { min-width: 0; overflow-wrap: anywhere; }
.form-alert a, .form-alert .link-btn { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.form-alert--info { background: var(--tone-info-bg); color: var(--tone-info-fg); }
.form-alert--success { background: var(--tone-success-bg); color: var(--tone-success-fg); }
.form-alert--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.link-btn {
  display: inline; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--text); text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }

/* ---- 4. Forgot password -------------------------------------------------------------- */
.forgot-sheet .sheet-body { padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
.fp-lead { margin: 0 0 16px; color: var(--text-muted); line-height: 1.5; }
.fp-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: var(--sp-4); }
.fp-done { text-align: center; padding: 8px 4px 4px; }
.fp-done[hidden] { display: none; }
.fp-ico {
  width: 56px; height: 56px; margin: 0 auto 12px;
  display: grid; place-items: center; border-radius: 50%;
  background: var(--tone-success-bg); color: var(--tone-success-fg);
}
.fp-done-t { margin: 0 0 6px; font-size: var(--fs-xl); font-weight: 800; letter-spacing: -.01em; line-height: var(--lh-tight); }
.fp-done-b { margin: 0 auto 18px; max-width: 42ch; color: var(--text-muted); line-height: 1.5; overflow-wrap: anywhere; }
@media (max-width: 640px) { .fp-actions .btn { flex: 1 1 0; } }

/* ---- 5. Set-password dialog -------------------------------------------------------------- */
.modal.spw-modal { max-width: 480px; }
.spw-row { display: flex; gap: var(--sp-2); }
.spw-row input {
  flex: 1 1 auto; min-width: 0;
  font-family: ui-monospace, "SF Mono", Consolas, monospace; letter-spacing: .02em;
}
.spw-row .btn { flex: none; }
.spw-done { display: flex; gap: 12px; align-items: flex-start; }
.spw-ico {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--tone-success-bg); color: var(--tone-success-fg);
}
.spw-done-t { font-weight: 700; font-size: var(--fs-lg); line-height: 1.3; }
.spw-done-sub { font-size: var(--fs-sm); margin-top: 2px; line-height: 1.45; }
.spw-secret {
  display: flex; align-items: center; gap: 10px;
  margin-top: var(--sp-4); padding: 10px 12px;
  border: 1px dashed var(--border-strong); border-radius: var(--r-sm); background: var(--surface-2);
}
.spw-secret code {
  flex: 1 1 auto; min-width: 0;
  font: 700 var(--fs-lg)/1.3 ui-monospace, "SF Mono", Consolas, monospace;
  color: var(--text); overflow-wrap: anywhere;
}
@media (max-width: 480px) { .spw-row { flex-direction: column; } }

/* ---- 6. Keyboard shortcuts ------------------------------------------------------------------ */
.keys-sheet .sheet-body { padding: 6px 20px calc(20px + env(safe-area-inset-bottom, 0px)); }
.keys-row { display: flex; align-items: center; gap: var(--sp-4); min-height: 44px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.keys-row:last-child { border-bottom: 0; }
.keys-k { flex: 0 0 132px; display: flex; align-items: center; gap: 6px; }
.keys-then { font-size: var(--fs-xs); color: var(--text-muted); }
.keys-l { flex: 1 1 auto; min-width: 0; }
.keys-note { margin: 12px 0 0; font-size: var(--fs-sm); color: var(--text-muted); }

/* ---- 7. Print --------------------------------------------------------------------------------- */
@media print {
  .sidebar, .topbar, .tabbar, .drawer-backdrop, .toast-wrap, .notif-pop-wrap, .net-banner,
  .gs-pop, .sheet, .sheet-backdrop, .no-print { display: none !important; }
  .app { display: block !important; }
  .main { padding: 0 !important; }
}
@media (prefers-reduced-motion: reduce) { .gs-spin { animation-duration: 1.6s; } }
