/* Schema Scribe — component primitives.
   All classes prefixed `scribe-*` to avoid collision with legacy app.css.
   Depends on tokens.css for variables. */

/* ============================================================ Button */
.scribe-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: var(--hit);
  padding: 0 16px;
  font-family: inherit;
  font-size: var(--t-13); font-weight: 500;
  line-height: 1;
  letter-spacing: var(--tr-tight);
  border-radius: var(--r-1);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background var(--d-fast) var(--ease),
    border-color var(--d-fast) var(--ease),
    color var(--d-fast) var(--ease);
}
.scribe-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.scribe-btn--sm { height: 32px; padding: 0 12px; font-size: var(--t-12); }
.scribe-btn--icon-only { width: var(--hit); padding: 0; }
.scribe-btn--sm.scribe-btn--icon-only { width: 32px; }

.scribe-btn--primary {
  background: var(--ink); color: var(--ink-inv); border-color: var(--ink);
}
.scribe-btn--primary:hover { background: #0e0c08; border-color: #0e0c08; }
[data-theme="dark"] .scribe-btn--primary:hover { background: #f5f1e9; border-color: #f5f1e9; }

.scribe-btn--secondary {
  background: var(--surface); color: var(--ink); border-color: var(--line-strong);
}
.scribe-btn--secondary:hover { background: var(--surface-sink); }

.scribe-btn--ghost {
  background: transparent; color: var(--ink); border-color: transparent;
}
.scribe-btn--ghost:hover { background: var(--surface-sink); }

.scribe-btn--destructive {
  background: var(--surface); color: var(--overdue); border-color: var(--overdue);
}
.scribe-btn--destructive:hover { background: var(--overdue-tint); }

.scribe-btn--accent {
  background: var(--signal); color: var(--ink-inv); border-color: var(--signal);
}
.scribe-btn--accent:hover { background: var(--signal-2); border-color: var(--signal-2); }

.scribe-btn--ink-inverse {
  background: transparent; color: var(--ink-inv); border-color: rgba(246,244,238,.3);
}
.scribe-btn--ink-inverse:hover { background: rgba(246,244,238,.08); }

/* ============================================================ Eyebrow */
.scribe-eyebrow {
  font-size: var(--t-10); font-weight: 500; color: var(--ink-3);
  text-transform: uppercase; letter-spacing: var(--tr-cap);
  line-height: 1;
}

/* ============================================================ Field */
.scribe-field { display: block; }
.scribe-field__label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
  font-size: var(--t-11); font-weight: 500; color: var(--ink-2);
}
.scribe-field__required { color: var(--overdue); }
.scribe-field__hint { color: var(--ink-3); font-weight: 400; }
.scribe-field__error { font-size: var(--t-11); color: var(--overdue); margin-top: 6px; }

/* ============================================================ Input */
.scribe-input {
  display: flex; align-items: center;
  height: var(--hit);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.scribe-input:focus-within {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-tint);
}
.scribe-input__icon, .scribe-input__icon-right {
  display: inline-flex; color: var(--ink-3);
  padding: 0 10px;
  flex: 0 0 auto;
}
.scribe-input__el {
  flex: 1; height: 100%; padding: 0 12px;
  background: transparent; border: 0; outline: none;
  color: var(--ink); font-size: var(--t-13); font-family: inherit;
  width: 100%; min-width: 0;
}
.scribe-input__el::placeholder { color: var(--ink-4); }
.scribe-input--has-icon .scribe-input__el { padding-left: 0; }
.scribe-input--has-icon-right .scribe-input__el { padding-right: 0; }

/* ============================================================ Textarea */
.scribe-textarea {
  width: 100%; padding: 12px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  font-family: inherit;
  font-size: var(--t-13); line-height: var(--lh-body);
  color: var(--ink); outline: none;
  resize: vertical;
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.scribe-textarea:focus {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-tint);
}

/* ============================================================ Select */
.scribe-select {
  position: relative; display: inline-flex; align-items: center;
  height: var(--hit);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  transition: border-color var(--d-fast) var(--ease), box-shadow var(--d-fast) var(--ease);
}
.scribe-select:focus-within {
  border-color: var(--signal);
  box-shadow: 0 0 0 3px var(--signal-tint);
}
.scribe-select__el {
  appearance: none; -webkit-appearance: none;
  border: 0; outline: none; background: transparent;
  height: 100%; padding: 0 32px 0 12px;
  font-family: inherit;
  font-size: var(--t-13); color: var(--ink);
  cursor: pointer; width: 100%;
}
.scribe-select__chevron {
  position: absolute; right: 10px;
  color: var(--ink-3); pointer-events: none;
  display: flex;
}

/* ============================================================ Checkbox */
.scribe-checkbox {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;
  cursor: pointer; flex: 0 0 auto;
  position: relative;
}
.scribe-checkbox__box {
  width: 16px; height: 16px;
  background: var(--surface);
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-1);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--ink-inv);
  transition: background var(--d-fast) var(--ease), border-color var(--d-fast) var(--ease);
}
.scribe-checkbox--checked .scribe-checkbox__box,
.scribe-checkbox--indeterminate .scribe-checkbox__box {
  background: var(--ink); border-color: var(--ink);
}
.scribe-checkbox__native {
  position: absolute; opacity: 0; pointer-events: none;
  width: 0; height: 0;
}

/* ============================================================ Card */
.scribe-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: var(--s-4);
}
.scribe-card--flush { padding: 0; }
.scribe-card--sink { background: var(--surface-sink); }

/* ============================================================ Section header */
.scribe-section-header {
  display: flex; align-items: baseline; justify-content: space-between;
  padding: var(--s-4) 0 var(--s-2);
  border-bottom: 1px solid var(--line-strong);
}
.scribe-section-header__left { display: flex; align-items: baseline; gap: 10px; }
.scribe-section-header__count {
  font-size: var(--t-10); color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* ============================================================ Row */
.scribe-row {
  padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--line-faint);
  transition: background var(--d-fast) var(--ease);
}
.scribe-row--clickable { cursor: pointer; }
.scribe-row--clickable:hover { background: var(--surface-sink); }
.scribe-row--selected { background: var(--signal-tint); }
.scribe-row-wrap { position: relative; padding-left: var(--s-4); }
.scribe-row__bar {
  position: absolute; left: 0; top: 8px; bottom: 8px;
  width: var(--bar-w);
}
.scribe-row__bar--current     { background: var(--ok); }
.scribe-row__bar--needsReview { background: var(--caution); }
.scribe-row__bar--approaching { background: var(--caution); }
.scribe-row__bar--overdue     { background: var(--overdue); }
.scribe-row__bar--failed      { background: var(--overdue); }
.scribe-row__bar--critical    { background: var(--critical-bg); }
.scribe-row__bar--pending     { background: var(--ink-4); }
.scribe-row__bar--classifying { background: var(--ink-3); }
.scribe-row__bar--classified  { background: var(--ok); }

/* ============================================================ StatusTag */
.scribe-status-tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px 4px;
  border-radius: var(--r-1);
  font-size: var(--t-11); font-weight: 500;
  line-height: 1.2; white-space: nowrap;
}
.scribe-status-tag__glyph {
  font-size: 11px; line-height: 1; position: relative; top: -1px;
}
.scribe-status-tag--dense {
  padding: 1px 6px 2px;
  font-size: var(--t-10);
}
.scribe-status-tag--dense .scribe-status-tag__glyph { font-size: 9px; }

.scribe-status-tag--current     { background: var(--ok-tint);       color: var(--ok); }
.scribe-status-tag--classified  { background: var(--ok-tint);       color: var(--ok); }
.scribe-status-tag--approaching { background: var(--caution-tint);  color: var(--caution); }
.scribe-status-tag--needsReview { background: var(--caution-tint);  color: var(--caution); }
.scribe-status-tag--overdue     { background: var(--overdue-tint);  color: var(--overdue); }
.scribe-status-tag--failed      { background: var(--overdue-tint);  color: var(--overdue); }
.scribe-status-tag--critical    { background: var(--critical-bg);   color: var(--critical-fg); }
.scribe-status-tag--pending     { background: var(--surface-sink);  color: var(--ink-3); }
.scribe-status-tag--classifying { background: var(--surface-sink);  color: var(--ink-2); }
.scribe-status-tag--unmanaged   { background: var(--signal-tint);   color: var(--signal); }

/* ============================================================ Tag (neutral, non-status) */
.scribe-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px 3px;
  border: 1px solid var(--line);
  border-radius: var(--r-1);
  font-size: var(--t-11); font-weight: 500;
  line-height: 1.2;
}
.scribe-tag--neutral { background: var(--surface-sink); color: var(--ink-2); border-color: var(--line); }
.scribe-tag--ink     { background: var(--ink); color: var(--ink-inv); border-color: var(--ink); }
.scribe-tag--outline { background: transparent; color: var(--ink-2); border-color: var(--line-strong); }

/* ============================================================ Modal */
.scribe-modal-scrim {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(20,19,16,0.36);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 10vh 16px;
}
/* Explicit display:none on [hidden] — required because display:flex above
   would otherwise defeat the HTML `hidden` attribute (default
   `[hidden] { display: none }` rule loses on specificity). */
.scribe-modal-scrim[hidden] { display: none; }
.scribe-modal {
  width: 100%; max-width: 520px;
  background: var(--surface-overlay);
  border: 1px solid var(--line);
  border-radius: var(--r-3);
  box-shadow: var(--shadow-pop);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: calc(100vh - 20vh);
}
.scribe-modal__head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
}
.scribe-modal__title {
  font-size: var(--t-17); font-weight: 500;
  letter-spacing: var(--tr-tight);
  margin-top: 4px;
}
.scribe-modal__title--no-eyebrow { margin-top: 0; }
.scribe-modal__body {
  padding: 20px;
  font-size: var(--t-13); color: var(--ink-2);
  line-height: var(--lh-body);
  overflow-y: auto;
}
.scribe-modal__foot {
  padding: 14px 20px;
  border-top: 1px solid var(--line);
  display: flex; justify-content: flex-end; gap: 8px;
  background: var(--surface-sink);
}

/* ============================================================ EmptyState */
.scribe-empty {
  text-align: center; padding: 48px 24px;
  color: var(--ink-3);
}
.scribe-empty__glyph {
  font-size: 36px; line-height: 1; margin-bottom: 16px;
  color: var(--ink-4); font-weight: 300;
}
.scribe-empty__title {
  font-size: var(--t-14); color: var(--ink-2); font-weight: 500;
}
.scribe-empty__body {
  font-size: var(--t-12); color: var(--ink-3); margin-top: 8px;
  max-width: 380px; margin-left: auto; margin-right: auto;
  line-height: var(--lh-body);
}
.scribe-empty__action { margin-top: 20px; }

/* ============================================================ Skeleton — inherits .skel from tokens.css */
.scribe-skel { /* alias */
  background: var(--surface-sink);
  border-radius: var(--r-1);
  animation: portcullis-skel-pulse 1.4s var(--ease) infinite;
}
@media (prefers-reduced-motion: reduce) { .scribe-skel { animation: none; opacity: 0.7; } }

/* ============================================================ Kpi */
.scribe-kpi { display: block; }
.scribe-kpi__label { margin-bottom: 6px; }
.scribe-kpi__value {
  font-size: var(--t-32); font-weight: 500; line-height: 1;
  letter-spacing: var(--tr-display);
  color: var(--ink);
  font-feature-settings: var(--num);
}
.scribe-kpi__value--ok      { color: var(--ok); }
.scribe-kpi__value--caution { color: var(--caution); }
.scribe-kpi__value--overdue { color: var(--overdue); }
.scribe-kpi__value--muted   { color: var(--ink-4); }
.scribe-kpi__sub {
  font-size: var(--t-12); color: var(--ink-3); margin-top: 8px;
  line-height: var(--lh-body);
}

/* ============================================================ Toast */
.scribe-toast-host {
  position: fixed; right: 24px; bottom: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 60;
  pointer-events: none;
}
.scribe-toast {
  width: min(420px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-pop);
  display: flex; align-items: stretch;
  overflow: hidden;
  transform: translateY(8px); opacity: 0;
  transition: transform var(--d-med) var(--ease), opacity var(--d-med) var(--ease);
  pointer-events: auto;
}
.scribe-toast.is-open { transform: translateY(0); opacity: 1; }
.scribe-toast__bar { width: var(--bar-w); flex: 0 0 auto; }
.scribe-toast__body {
  padding: 12px 14px 14px;
  display: flex; gap: 12px; flex: 1; min-width: 0;
}
.scribe-toast__glyph {
  font-size: 14px; line-height: 1; margin-top: 2px; flex: 0 0 auto;
}
.scribe-toast__content { flex: 1; min-width: 0; }
.scribe-toast__title {
  font-size: var(--t-13); font-weight: 500; color: var(--ink);
  letter-spacing: var(--tr-tight);
}
.scribe-toast__text {
  font-size: var(--t-12); color: var(--ink-2);
  line-height: var(--lh-body); margin-top: 4px;
}
.scribe-toast__action {
  margin-top: 8px; padding: 0; background: transparent; border: 0;
  color: var(--signal); font-size: var(--t-12); font-weight: 500;
  font-family: inherit; cursor: pointer;
}
.scribe-toast__close {
  background: transparent; border: 0; color: var(--ink-3);
  padding: 6px; cursor: pointer;
  display: flex; align-items: flex-start; flex: 0 0 auto;
}
.scribe-toast--info    .scribe-toast__bar { background: var(--ink-2); }
.scribe-toast--info    .scribe-toast__glyph { color: var(--ink-2); }
.scribe-toast--ok      .scribe-toast__bar { background: var(--ok); }
.scribe-toast--ok      .scribe-toast__glyph { color: var(--ok); }
.scribe-toast--caution .scribe-toast__bar { background: var(--caution); }
.scribe-toast--caution .scribe-toast__glyph { color: var(--caution); }
.scribe-toast--overdue .scribe-toast__bar { background: var(--overdue); }
.scribe-toast--overdue .scribe-toast__glyph { color: var(--overdue); }

/* ============================================================ Divider */
.scribe-divider { height: 1px; background: var(--line); width: 100%; }
.scribe-divider--strong { background: var(--line-strong); }

/* ============================================================ Kbd */
.scribe-kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 20px; padding: 0 6px;
  background: var(--surface-sink);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  font-size: var(--t-10); font-weight: 500;
  color: var(--ink-2);
}

/* ============================================================ CodeBlock */
.scribe-code-block {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  padding: 14px 64px 14px 16px;
  font-size: var(--t-12);
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  color: var(--ink-2);
  white-space: pre-wrap;
  max-height: 360px;
  overflow: auto;
}
.scribe-code-block__copy {
  position: absolute; top: 8px; right: 8px;
  width: 32px; height: 32px;
  background: transparent;
  border: 0; border-radius: var(--r-1);
  color: var(--ink-3);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: color var(--d-fast) var(--ease);
}
.scribe-code-block__copy svg { width: 18px; height: 18px; }
.scribe-code-block__copy:hover { color: var(--ink); }
.scribe-code-block__copy.is-success { color: var(--ok); }

/* ============================================================ Icon (size + alignment) */
.scribe-icon {
  display: inline-block;
  flex: 0 0 auto;
  vertical-align: middle;
}

/* ============================================================ Menu (portal dropdown) */
/* Appended to document.body by Scribe.menu.open(); position set inline.
   z-index sits above the profile menu (40) and below modal scrim (50). */
.scribe-menu {
  position: fixed;
  min-width: 200px;
  padding: 4px;
  background: var(--surface-overlay);
  border: 1px solid var(--line);
  border-radius: var(--r-2);
  box-shadow: var(--shadow-pop);
  z-index: 45;
}
.scribe-menu__item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: var(--r-1);
  font-family: inherit;
  font-size: var(--t-12);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.scribe-menu__item:hover:not(:disabled) { background: var(--surface-sink); }
.scribe-menu__item:disabled { color: var(--ink-4); cursor: default; }

/* AUDIT SL4: logout is a POST form; keep the button inline with the header controls. */
.scribe-inline-form { display: inline; margin: 0; }
