/* ALIAS SHIM. The DS in web/static/web/ds/styles.css now owns the real token
   vocabulary + component library. This file no longer defines its own palette:
   every OLD custom property below is re-pointed at the nearest DS token so the
   deferred app screens (dashboard + ~40 partials, rebuilt in Wave 2) inherit
   the new palette/fonts and keep working. Pixel-parity is NOT a goal here.
   The legacy component classes further down still resolve through these
   aliases, so they render unchanged; leave them until Wave 2 replaces them.

   TWO SECTIONS:
     1. GLOBALS — app-wide primitives every page needs (the `hidden` channel,
        scrollbar-gutter, .visually-hidden, the :root alias vars, box-sizing,
        body). A second globals cluster (focus ring, reduced-motion, flash
        messages) sits at the very TAIL, after the legacy block, so it wins on
        source order — moving it up would change the cascade, so it stays put.
     2. LEGACY — the component classes the not-yet-reskinned pages still use;
        clearly banner-marked below and retired in the shim-retirement wave. */

/* ============================ GLOBALS ============================ */

/* The `hidden` attribute is the controller's visibility channel; it must beat
   any component class that sets `display` (e.g. .overlay{display:flex}). */
[hidden] { display: none !important; }

/* Reserve the scrollbar track always, so the modal scroll lock (overflow:
   hidden on <body>) doesn't shift the centred shell sideways on open/close. */
html { scrollbar-gutter: stable; }

/* Off-screen but focusable — for controls a visible <label> stands in for. */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

:root {
  /* Surfaces & ink */
  --paper: var(--paper-100);
  --card: var(--paper-0);
  --white: #fff;
  --ink: var(--slate-900);
  --soft: var(--slate-500);
  --faint: var(--slate-600);
  --mono-muted: var(--slate-600);
  --line: var(--border-subtle);
  --hairline-dark: var(--border-subtle);
  --chip: var(--paper-200);
  --btn-soft: var(--paper-200);
  --card-muted: var(--paper-200);
  --dashed: var(--slate-300);
  --dark-border: var(--slate-700);
  /* Primary accent: blue → orange */
  --blue: var(--orange-500);
  --blue-hover: var(--orange-600);
  --blue-06: rgba(255, 122, 61, .06);
  --blue-09: rgba(255, 122, 61, .09);
  --blue-10: rgba(255, 122, 61, .10);
  --blue-22: rgba(255, 122, 61, .22);
  --blue-30: rgba(255, 122, 61, .30);
  --blue-32: rgba(255, 122, 61, .32);
  /* Semantic hues */
  --green: var(--green-600);
  --green-tint: var(--green-50);
  --green-border: var(--green-100);
  --green-18: rgba(46, 125, 91, .18);
  --amber: var(--amber-600);
  --amber-tint: var(--amber-50);
  --amber-fg: var(--amber-600);
  --danger: var(--red-600);
  /* Fonts */
  --sans: var(--font-sans);
  --mono: var(--font-mono);
  /* Radii */
  --r-chip: var(--radius-sm);
  --r-control: var(--radius-md);
  --r-card: var(--radius-lg);
  --r-shell: var(--radius-xl);
  /* Type scale */
  --fs-mono: var(--text-2xs);
  --fs-body-s: var(--text-sm);
  --fs-body: var(--text-md);
  --fs-section: var(--text-lg);
  --fs-page: var(--text-xl);
  --fs-title: var(--text-2xl);
  --fs-display: var(--text-display-m);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

/* ============================================================================
   LEGACY — non-dashboard pages (auth/allauth, recruiter, messages, billing_*)
   plus the not-yet-reskinned dashboard partials. These component classes still
   render through the aliases above; retire them in the shim-retirement wave,
   once every page moves to the DS. Do NOT delete a rule still referenced — the
   a11y tests assert .drawer-input, the .toggle -webkit-appearance reset, and the
   palette contrast vars live in THIS file.
   ============================================================================ */

/* ---- Buttons & links ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--card);
  font-family: var(--sans);
  font-size: var(--fs-body-s);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease;
}
/* color too: DS base.css sets a:hover{color:--text-link-hover}, which would
   otherwise leave <a class="btn-primary"> orange-on-orange (~1.6:1) on hover. */
.btn-primary:hover { background: var(--blue); color: var(--card); }

.btn-soft {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: none;
  border-radius: var(--r-control);
  background: var(--btn-soft);
  color: var(--soft);
  font-family: var(--sans);
  font-size: var(--fs-body-s);
  font-weight: 500;
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.btn-soft:hover { background: var(--blue); color: var(--white); }
.dark-block .btn-soft:hover { background: var(--blue-hover); }

.link-blue {
  color: var(--blue);
  text-decoration: none;
  /* DS base.css underlines every <a> with a hairline border-bottom; .link-blue
     gets its affordance from colour alone, so drop it. */
  border-bottom: 0;
  transition: color .15s ease;
}
.link-blue:hover { color: var(--blue-hover); }

/* ---- Labels ---- */
.mono-label {
  font-family: var(--mono);
  font-weight: 500;
  font-size: var(--fs-mono);
  letter-spacing: .12em;
  color: var(--soft);
  text-transform: none;
}

.status-mono {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 10.5px;
  letter-spacing: .05em;
  color: var(--soft);
  font-variant-numeric: tabular-nums;
}

/* ---- Foldable sections ---- */
summary.fold-head {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
summary.fold-head::-webkit-details-marker { display: none; }
summary.fold-head::before {
  content: "";
  flex: none;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--soft);
  border-bottom: 1.5px solid var(--soft);
  transform: rotate(-45deg);
  transition: transform .15s ease;
}
details[open] > summary.fold-head::before { transform: rotate(45deg); }
details.fold > summary.fold-head + * { margin-top: 11px; }

/* ---- Panels & rows ---- */
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  overflow: hidden;
}

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  transition: background .15s ease;
}
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--chip); }

/* ---- Key/value row (label left, value right) ---- */
.kv-label {
  flex: 0 0 130px;
  font: 400 var(--fs-body-s)/1.4 var(--sans);
  color: var(--soft);
}
.kv-value {
  flex: 1;
  min-width: 0;
  font: 400 var(--fs-body)/1.4 var(--sans);
  color: var(--ink);
  text-align: right;
  word-break: break-word;
}

/* ---- Chips (skills, languages) — variable width, fit to text, wrap ---- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  background: var(--chip);
  border: 1px solid var(--line);
  border-radius: var(--r-chip);
  font: 400 var(--fs-body-s)/1 var(--sans);
  color: var(--ink);
}

/* ---- Layout & text utilities (the most-repeated former inline styles) ---- */
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.stack-12 { display: flex; flex-direction: column; gap: 12px; }
.stack-6 { display: flex; flex-direction: column; gap: 6px; }
.stack-5 { display: flex; flex-direction: column; gap: 5px; }
.hint { font: 400 var(--fs-body-s) var(--sans); color: var(--soft); }
/* Compact button — must stay after .btn-soft/.btn-primary to win on padding. */
.btn-xs { flex: none; padding: 6px 10px; }

/* ---- Drawer form fields (shared by the drawer + master-profile editors) ---- */
.drawer-input { padding: 9px 12px; border: 1px solid var(--line); border-radius: var(--r-control); background: var(--white); font: 400 14px var(--sans); width: 100%; box-sizing: border-box; }
.drawer-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 160px; }
.drawer-field > span { font: 400 12px var(--sans); color: var(--soft); }

/* ---- Unified master profile: one [data-profile-form] both shows & edits.
   .v-show is the read node, .v-edit the input beside it (same value, so they
   can't drift), .edit-only the add/remove + Save chrome, .v-empty a row/section
   with no value — hidden in view, revealed while editing so a premium user can
   fill it. The `editing` class on the form flips the whole tree. ---- */
[data-profile-form] .v-edit,
[data-profile-form] .edit-only,
[data-profile-form] .v-empty { display: none; }
[data-profile-form].editing .v-show { display: none; }
[data-profile-form].editing .v-edit { display: block; }
[data-profile-form].editing .edit-only,
[data-profile-form].editing .v-empty { display: flex; }
[data-profile-form].editing details.v-empty { display: block; }

/* ---- Segmented control ---- */
.seg {
  display: inline-flex;
  gap: 3px;
  padding: 3px;
  border-radius: var(--r-card);
  background: var(--chip);
}
.seg-btn {
  padding: 5px 11px;
  border: none;
  border-radius: var(--r-control);
  background: transparent;
  color: var(--soft);
  font-family: var(--sans);
  font-size: var(--fs-body-s);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active {
  background: var(--white);
  color: var(--ink);
  font-weight: 500;
}

/* ---- Sidebar nav ---- */
.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px;
  border-radius: var(--r-control);
  color: var(--soft);
  cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
a.nav-item { text-decoration: none; }
.nav-item:hover:not(.is-active) { background: var(--chip); }
.nav-item.is-active {
  background: var(--chip);
  color: var(--ink);
  font-weight: 500;
}

/* ---- Badges & pills ---- */
.badge {
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--blue);
  color: var(--white);
  font-family: var(--mono);
  font-size: 10px;
}
.nav-item.is-active .badge {
  background: var(--blue);
  color: var(--white);
}

.pill-premium {
  padding: 3px 9px;
  border-radius: 99px;
  background: var(--blue-10);
  color: var(--blue);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .05em;
}

/* ---- Toggle ---- */
.toggle {
  width: 36px;
  height: 20px;
  border-radius: 99px;
  border: none;
  appearance: none;
  -webkit-appearance: none;
  padding: 2px;
  display: flex;
  align-items: center;
  background: var(--dashed);
  cursor: pointer;
}
.toggle.on {
  background: var(--blue);
  justify-content: flex-end;
}
.knob {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--white);
}

/* ---- Kanban cards ---- */
.kcard {
  border: 1px solid var(--line);
  border-radius: var(--r-card);
  background: var(--white);
  padding: 12px;
  position: relative;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(27, 27, 31, .04);
  transition: border-color .15s ease, box-shadow .15s ease;
}
.kcard:hover {
  border-color: var(--hairline-dark);
  box-shadow: 0 3px 8px rgba(27, 27, 31, .07);
}
.kcard.tone-0 {
  background: var(--white);
  border-color: var(--line);
}
.kcard.tone-1 {
  background: var(--white);
  border-color: var(--line);
  border-left: 2px solid var(--blue);
}
.kcard.tone-2 {
  background: var(--white);
  border-color: var(--line);
}
.kcard.tone-2 .kcard-note { color: var(--blue); }
.kcard.tone-3 {
  background: var(--green-tint);
  border-color: var(--green-border);
}
.kcard.tone-3 .kcard-meta { color: var(--green); }
.kcard.tone-3 .kcard-tile { background: var(--green-tint); color: var(--green); }
.kcard.tone-3:hover {
  border-color: var(--green-border);
  box-shadow: 0 1px 4px var(--green-18);
}
.kcard.tone-4 {
  background: var(--card-muted);
  border-color: var(--chip);
  color: var(--soft);
}
.kcard.tone-5 {
  background: var(--card-muted);
  border: 1px dashed var(--dashed);
  color: var(--soft);
}
.kcard.tone-4 .kcard-role, .kcard.tone-5 .kcard-role,
.kcard.tone-4 .kcard-company, .kcard.tone-5 .kcard-company { color: var(--soft); }
.kcard.tone-4:hover,
.kcard.tone-5:hover {
  border-color: var(--dashed);
  box-shadow: none;
}

/* ---- Dark ground block ---- */
.dark-block {
  background: var(--chip);
  color: var(--soft);
  border: 1px solid var(--line);
}
.dark-block h1,
.dark-block h2,
.dark-block h3,
.dark-block h4 { color: var(--ink); }

/* ---- Overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  background: rgba(28, 26, 23, .3);
}

.modal {
  margin: auto;
  border-radius: var(--r-shell);
  background: var(--card);
}

/* ==================== GLOBALS (tail — see header) ====================
   App-wide, kept AFTER the legacy block so the focus ring and reduced-motion
   reset win on source order; the flash toaster is rendered by base.html. */
/* ---- Global quality primitives ---- */
:focus-visible,
.btn-primary:focus-within {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* ---- Flash messages (django.contrib.messages, rendered in base.html) ---- */
.flash {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 520px;
  width: calc(100% - 32px);
  animation: flash-out .3s ease 5s forwards;
}
@keyframes flash-out { to { opacity: 0; visibility: hidden; } }
.flash-msg {
  padding: 10px 14px;
  border-radius: var(--r-control);
  background: var(--ink);
  color: var(--card);
  font: 400 var(--fs-body-s) var(--sans);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
}
.flash-msg.error { background: var(--danger); color: var(--white); }
