/* ============================================================================
   HireIQ — reset, primitives, and the shared component layer
   ============================================================================ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: var(--fs-14);
  line-height: var(--lh-body);
  font-synthesis-weight: none;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg, video { max-width: 100%; display: block; }
[hidden] { display: none !important; }

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: var(--lh-snug); }
p { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }

/* Display face — used for page titles, big numerals, report headings */
.display {
  font-family: var(--font-display);
  font-weight: 600;
  line-height: var(--lh-tight);
  letter-spacing: -0.01em;
}

.mono {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Every numeric data context gets tabular figures — no column jitter */
.num, table, .stat, .metric { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------- focus ring */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

.skip-link {
  position: absolute; left: var(--s4); top: -100px;
  z-index: var(--z-toast);
  padding: var(--s3) var(--s5);
  background: var(--accent); color: var(--accent-ink);
  border-radius: var(--r-md); font-weight: 600;
  transition: top var(--dur) var(--ease-out);
}
.skip-link:focus-visible { top: var(--s4); }

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ------------------------------------------------------------------ buttons */
.btn {
  --btn-bg: transparent;
  --btn-fg: var(--text);
  --btn-line: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--s2);
  min-height: 40px;
  padding: 0 var(--s4);
  font: inherit; font-size: var(--fs-13); font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-line);
  border-radius: var(--r-full);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              opacity var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}
.btn:hover:not(:disabled) { background: var(--surface-3); }
.btn:active:not(:disabled) { transform: scale(.985); }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary {
  --btn-bg: var(--accent); --btn-fg: var(--accent-ink); --btn-line: var(--accent);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { --btn-line: transparent; --btn-fg: var(--text-2); }
.btn-ghost:hover:not(:disabled) { --btn-fg: var(--text); background: var(--surface-2); }

/* Destructive is visually and spatially separated from primary */
.btn-danger { --btn-fg: var(--danger); --btn-line: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-soft); }

.btn-sm { min-height: 32px; padding: 0 var(--s3); font-size: var(--fs-12); }
.btn-lg { min-height: 46px; padding: 0 var(--s6); font-size: var(--fs-14); }
.btn-block { width: 100%; }

.btn .spin {
  width: 14px; height: 14px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Icon-only controls still meet the 44px touch floor via padding */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  color: var(--text-2); background: transparent;
  border: 1px solid transparent; border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.icon-btn:hover { color: var(--text); background: var(--surface-2); }

/* ------------------------------------------------------------------- fields */
.field { display: flex; flex-direction: column; gap: var(--s2); }
.field + .field { margin-top: var(--s5); }

.label {
  font-size: var(--fs-12); font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-2);
}
.label .req { color: var(--danger); margin-left: 2px; }

.input, .textarea, .select {
  width: 100%;
  min-height: 44px;
  padding: var(--s3) var(--s4);
  font: inherit; font-size: var(--fs-14);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  transition: border-color var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .textarea:hover, .select:hover { border-color: var(--text-3); }
.input:focus-visible, .textarea:focus-visible, .select:focus-visible {
  border-color: var(--focus); outline-offset: 0;
}
.textarea { min-height: 168px; resize: vertical; line-height: var(--lh-body); }
.select { appearance: none; padding-right: var(--s8); cursor: pointer; }

.hint { font-size: var(--fs-12); color: var(--text-3); line-height: var(--lh-dense); }

/* Errors sit below the field they belong to, and say how to fix */
.err {
  display: flex; align-items: flex-start; gap: var(--s2);
  font-size: var(--fs-12); color: var(--danger); line-height: var(--lh-dense);
}
.err svg { flex: none; margin-top: 1px; }
.input.invalid, .textarea.invalid { border-color: var(--danger); }

/* -------------------------------------------------------------------- cards */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.card-pad { padding: var(--s6); }

.card-link {
  display: block; text-decoration: none; color: inherit;
  transition: border-color var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out),
              background var(--dur-fast) var(--ease-out);
}
.card-link:hover { border-color: var(--line-strong); background: var(--surface-2); }
.card-link:active { transform: scale(.995); }

/* -------------------------------------------------------------- chips/badges */
.chip {
  display: inline-flex; align-items: center; gap: var(--s1);
  height: 24px; padding: 0 var(--s2);
  font-size: var(--fs-12); font-weight: 500;
  color: var(--text-2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-full);
  white-space: nowrap;
}
.chip-mono { font-family: var(--font-mono); font-size: var(--fs-11); }

/* Status always pairs a dot with a text label — never colour alone */
.status {
  display: inline-flex; align-items: center; gap: var(--s2);
  font-size: var(--fs-12); font-weight: 600; letter-spacing: .02em;
}
.status::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; flex: none;
}
.status-open { color: var(--success); }
.status-draft { color: var(--text-3); }
.status-paused { color: var(--warn); }
.status-closed { color: var(--text-3); }
.status-applied { color: var(--info); }
.status-in_progress { color: var(--warn); }
.status-shortlisted { color: var(--success); }
.status-offer { color: var(--success); }
.status-rejected { color: var(--danger); }

/* ------------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; max-width: 100%; border-radius: var(--r-lg); border: 1px solid var(--line); }
table { width: 100%; border-collapse: collapse; font-size: var(--fs-13); }
thead th {
  position: sticky; top: 0; z-index: var(--z-sticky);
  padding: var(--s3) var(--s4);
  text-align: left; white-space: nowrap;
  font-size: var(--fs-11); font-weight: 600;
  letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
tbody td { padding: var(--s4); border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr { transition: background var(--dur-fast) var(--ease-out); }
tbody tr:hover { background: var(--surface-2); }

/* ------------------------------------------------------ skeleton / empty / toast */
.skel {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 37%, var(--surface-2) 63%);
  background-size: 400% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }

.empty {
  display: flex; flex-direction: column; align-items: center;
  gap: var(--s4); padding: var(--s18) var(--s6); text-align: center;
}
.empty-icon {
  display: grid; place-items: center;
  width: 48px; height: 48px;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.empty h3 { font-size: var(--fs-16); }
.empty p { max-width: 44ch; color: var(--text-2); font-size: var(--fs-13); }

#toasts {
  position: fixed; right: var(--s5); bottom: var(--s5);
  z-index: var(--z-toast);
  display: flex; flex-direction: column; gap: var(--s2);
  pointer-events: none;
}
.toast {
  display: flex; align-items: flex-start; gap: var(--s3);
  max-width: 380px; padding: var(--s3) var(--s4);
  font-size: var(--fs-13);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-2);
  pointer-events: auto;
  animation: toast-in var(--dur) var(--ease-out);
}
.toast svg { flex: none; margin-top: 2px; }
.toast-ok svg { color: var(--success); }
.toast-err svg { color: var(--danger); }
.toast.out { animation: toast-out var(--dur-fast) var(--ease-in) forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px) scale(.97); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(4px) scale(.98); } }

/* -------------------------------------------------------------------- modal */
.modal-scrim {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: grid; place-items: center; padding: var(--s5);
  background: var(--scrim);
  backdrop-filter: blur(3px);
  animation: fade var(--dur-fast) var(--ease-out);
}
.modal {
  width: min(520px, 100%);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-3);
  animation: modal-in var(--dur) var(--ease-out);
}
@keyframes fade { from { opacity: 0; } }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } }

/* ------------------------------------------------------------------ helpers */
.row { display: flex; align-items: center; gap: var(--s3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); }
.col { display: flex; flex-direction: column; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap1 { gap: var(--s1); } .gap2 { gap: var(--s2); } .gap3 { gap: var(--s3); } .gap4 { gap: var(--s4); }
.gap5 { gap: var(--s5); } .gap6 { gap: var(--s6); } .gap8 { gap: var(--s8); }
.t2 { color: var(--text-2); } .t3 { color: var(--text-3); }
.fs11 { font-size: var(--fs-11); } .fs12 { font-size: var(--fs-12); } .fs13 { font-size: var(--fs-13); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hr { height: 1px; background: var(--line); border: 0; margin: 0; }

/* Staggered list reveal, capped at 6 so long lists don't crawl in */
.stagger > * { animation: rise var(--dur-slow) var(--ease-out) backwards; }
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 40ms; }
.stagger > *:nth-child(3) { animation-delay: 80ms; }
.stagger > *:nth-child(4) { animation-delay: 120ms; }
.stagger > *:nth-child(5) { animation-delay: 160ms; }
.stagger > *:nth-child(n+6) { animation-delay: 200ms; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }

/* --------------------------------------------------------- reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
    scroll-behavior: auto !important;
  }
}

/* Back links: inline in flow, but padded to a 44px hit area. */
.backlink {
  display: inline-flex; align-items: center; gap: var(--s2);
  padding: var(--s3) var(--s2); margin-left: calc(var(--s2) * -1);
  font-size: var(--fs-13); color: var(--text-3); text-decoration: none;
  border-radius: var(--r-md);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.backlink:hover { color: var(--text); background: var(--surface-2); }

/* ---- password reveal ---- */
.input-wrap { position: relative; display: flex; }
.input-wrap .input { padding-right: 46px; }
.reveal {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  color: var(--text-3); background: transparent;
  border: 0; border-radius: var(--r-sm); cursor: pointer;
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.reveal:hover { color: var(--text); background: var(--surface-2); }
.reveal[aria-pressed='true'] { color: var(--text); }

/* ---- cross-portal hint: shown on any failed sign-in, so it confirms nothing ---- */
.cross-hint {
  display: flex; align-items: flex-start; gap: var(--s2);
  margin-top: var(--s5); padding: var(--s3) var(--s4);
  font-size: var(--fs-12); line-height: var(--lh-dense);
  color: var(--text-2);
  background: var(--warn-soft);
  border: 1px solid color-mix(in srgb, var(--warn) 30%, transparent);
  border-radius: var(--r-md);
}
.cross-hint svg { flex: none; margin-top: 1px; color: var(--warn); }
.cross-hint a { color: var(--text); font-weight: 600; }

/* ------------------------------------------------------- view transition
   One motion, on the thing that actually changed: the view. A route change should
   read as navigation, not as a repaint. Transform and opacity only, so it never
   triggers layout. */
.view-enter { animation: view-in var(--dur-slow) var(--ease-out); }
@keyframes view-in {
  from { opacity: 0; transform: translateY(8px); }
}

/* The theme control sits in chrome, so it stays quiet until reached. */
.theme-toggle { color: var(--text-3); }
.theme-toggle:hover { color: var(--text); }

/* Switching theme should feel deliberate rather than instantaneous, but only the
   ground and hairlines animate — animating every colour on the page is expensive and
   reads as a smear. */
body,
.card,
.sidebar,
.topbar,
.portal-bar,
.mon-col {
  transition: background-color var(--dur) var(--ease-out),
              border-color var(--dur) var(--ease-out);
}
