/* ============================================================================
   jobs-experience.css — /jobs redesign (Material 3 inspired, calm + dense)
   Loaded AFTER modern-theme/modern-design/components on the jobs page only.
   CSS-only over the existing Vue-rendered markup — no DOM restructuring here.
   Sections: 1 Tokens · 2 Navbar fix · 3 Sticky toolbar · 4 Filter chips ·
             5 Active-filter pills · 6 Result header · 7 Job card · 8 States ·
             9 FAB · 10 Responsive · 11 A11y/reduced-motion
   ============================================================================ */

/* ── 1. DESIGN TOKENS ────────────────────────────────────────────────────── */
:root {
  --jx-gold: #C9952B;         /* decorative only */
  --jx-gold-600: #B07F1C;     /* icons, borders */
  --jx-gold-700: #8A6410;     /* ALL gold TEXT (WCAG AA on white) */
  --jx-gold-050: #FDF8EC;
  --jx-gold-100: #F7EBCF;
  --jx-ink: #101418;
  --jx-ink-2: #39424E;
  --jx-ink-3: #5B6675;
  --jx-ink-4: #7C8695;
  --jx-line: #E4E8EE;
  --jx-line-2: #EFF2F6;
  --jx-canvas: #F7F8FA;
  --jx-success: #0F7A47;  --jx-success-bg: #E8F6EE;
  --jx-danger: #B4231B;   --jx-danger-bg: #FDECEA;
  --jx-warning: #8A5A00;  --jx-warning-bg: #FFF4DE;
  --jx-indigo: #3B3A99;   --jx-indigo-bg: #ECECFB;
  --jx-r-8: 8px; --jx-r-12: 12px; --jx-r-16: 16px; --jx-r-22: 22px; --jx-pill: 999px;
  --jx-e1: 0 1px 2px rgba(16,20,24,.06), 0 1px 3px rgba(16,20,24,.04);
  --jx-e2: 0 2px 4px rgba(16,20,24,.05), 0 6px 16px -4px rgba(16,20,24,.10);
  --jx-motion: 180ms cubic-bezier(.2,0,0,1);
  --jx-max: 1180px;
  --jx-pad: clamp(16px, 3vw, 28px);
}

/* ── 2. NAVBAR OVERFLOW FIX (bug 1) ──────────────────────────────────────── */
.jk-nav-menu { min-width: 0; overflow-x: auto; scrollbar-width: none; }
.jk-nav-menu::-webkit-scrollbar { display: none; }
.nav-actions-wrap { flex: 0 0 auto; }
@media (max-width: 1180px) { .streak-counter { display: none !important; } }

/* ── 3. STICKY TOOLBAR (bug 6: was transparent, no elevation) ────────────── */
.lp-filter-bar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255,255,255,.97);
  backdrop-filter: saturate(1.1) blur(6px);
  border-bottom: 1px solid transparent;
  transition: box-shadow var(--jx-motion), border-color var(--jx-motion), background var(--jx-motion);
}
.lp-filter-bar.jx-scrolled {
  box-shadow: var(--jx-e1);
  border-bottom-color: var(--jx-line);
  background: #fff;
}
.lp-filter-inner { max-width: var(--jx-max); margin: 0 auto; padding: 14px var(--jx-pad); }
.lp-filter-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0;
}

/* Search field: large pill, 52px, gold focus ring (bug 3: kill 280px cap) */
.lp-filter-search {
  position: relative; flex: 1 1 340px; min-width: 240px; max-width: none;
}
.lp-filter-search i.fa-search {
  position: absolute; left: 18px; top: 50%; transform: translateY(-50%);
  color: var(--jx-ink-4); font-size: 15px; pointer-events: none;
}
#job-keyword-search {
  width: 100%; height: 52px; padding: 0 18px 0 46px;
  border: 1px solid var(--jx-line); border-radius: var(--jx-pill);
  background: #fff; color: var(--jx-ink); font-weight: 500;
  box-shadow: var(--jx-e1); transition: border-color var(--jx-motion), box-shadow var(--jx-motion);
}
#job-keyword-search::placeholder { color: var(--jx-ink-4); }
#job-keyword-search:focus, #job-keyword-search:focus-visible {
  outline: none; border-color: var(--jx-gold-600);
  box-shadow: 0 0 0 4px var(--jx-gold-050), var(--jx-e1);
}

/* AI Search button: gradient */
.lp-ai-search-btn {
  flex: 0 0 auto; height: 52px; padding: 0 20px;
  background: linear-gradient(135deg, #D2A03A, #B07F1C) !important;
  color: #fff !important; border: none !important; border-radius: var(--jx-pill) !important;
  font-weight: 700; display: inline-flex; align-items: center; gap: 8px;
  box-shadow: var(--jx-e1); transition: transform var(--jx-motion), box-shadow var(--jx-motion);
}
.lp-ai-search-btn:hover { transform: translateY(-1px); box-shadow: var(--jx-e2); }

/* Push Clear + Alert to the right end of the row */
.lp-filter-clear:first-of-type { margin-left: auto; }

/* ── 4. FILTER SELECTS AS MATERIAL CHIPS (bug: plain bootstrap selects) ──── */
.lp-filter-select {
  appearance: none; -webkit-appearance: none;
  height: 38px; padding: 0 34px 0 14px; min-width: 150px !important; max-width: none !important;
  border: 1px solid var(--jx-line); border-radius: var(--jx-pill);
  background-color: #fff; color: var(--jx-ink-2); font-weight: 600; font-size: 13px;
  box-shadow: var(--jx-e1); cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B6675' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center;
  transition: border-color var(--jx-motion), background-color var(--jx-motion), box-shadow var(--jx-motion);
}
#filter-sort { min-width: 160px !important; }
.lp-filter-select:hover { border-color: var(--jx-ink-4); }
.lp-filter-select:focus-visible {
  outline: none; border-color: var(--jx-gold-600);
  box-shadow: 0 0 0 4px var(--jx-gold-050), var(--jx-e1);
}
/* Active state: a non-default value is selected (CSS :has, no JS/Vue change) */
#filter-org:has(option:checked:not([value=""])),
#filter-level:has(option:checked:not([value=""])),
#filter-salary:has(option:checked:not([value=""])) {
  background-color: var(--jx-gold-050);
  border-color: var(--jx-gold-600);
  color: var(--jx-gold-700);
}

/* Clear + Alert buttons */
.lp-filter-clear {
  height: 38px; border-radius: var(--jx-pill); font-weight: 600; font-size: 13px;
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--jx-line); background: #fff; color: var(--jx-ink-2);
  transition: background var(--jx-motion), color var(--jx-motion), border-color var(--jx-motion);
}
.lp-filter-clear:hover { background: var(--jx-danger-bg); color: var(--jx-danger); border-color: var(--jx-danger); }
.lp-filter-badge, .lp-filter-clear .lp-filter-badge {
  background: var(--jx-ink); color: #fff; border-radius: var(--jx-pill);
  font-size: 11px; font-weight: 700; padding: 1px 7px; margin-left: 2px;
}
/* Alert (create-alert) — retention feature, gold-050 promote */
.lp-filter-clear[style*="C9952B"], .lp-filter-clear[style*="BAE6FD"] {
  background: var(--jx-gold-050) !important; border-color: var(--jx-gold-600) !important;
  color: var(--jx-gold-700) !important;
}
.lp-filter-clear[style*="C9952B"]:hover { background: var(--jx-gold-100) !important; }

/* ── 5. ACTIVE-FILTER PILLS (bug 4: long strings overflow) ───────────────── */
.lp-active-filters { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; min-width: 0; }
.lp-filter-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 260px; min-width: 0;
  background: var(--jx-gold-050); border: 1px solid var(--jx-gold-100);
  color: var(--jx-gold-700); border-radius: var(--jx-pill);
  padding: 5px 8px 5px 12px; font-size: 12.5px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lp-filter-chip .lp-filter-chip-label { color: var(--jx-ink-3); font-weight: 600; flex: 0 0 auto; }
.lp-filter-chip-remove {
  flex: 0 0 auto; width: 18px; height: 18px; line-height: 16px; border-radius: 50%;
  border: none; background: var(--jx-gold-100); color: var(--jx-gold-700);
  font-size: 13px; cursor: pointer;
}
.lp-filter-chip-remove:hover { background: var(--jx-danger); color: #fff; }

/* ── 11. A11Y + reduced motion ───────────────────────────────────────────── */
.jobs-list a:focus-visible, .lp-filter-bar :focus-visible, .job-card :focus-visible,
.lp-load-more-btn:focus-visible, .favorite-btn:focus-visible {
  outline: 3px solid var(--jx-gold-600); outline-offset: 2px; border-radius: 6px;
}
/* ── 6. RESULT HEADER ────────────────────────────────────────────────────── */
.lp-results-count { display: none !important; }   /* replaced by jx-resulthead */
.jx-resulthead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin: 8px 0 16px;
}
.jx-resulthead h2 {
  font-size: clamp(19px, 2.2vw, 24px); font-weight: 800; color: var(--jx-ink);
  margin: 0; line-height: 1.2;
}
.jx-resulthead .jx-sub { font-size: 12.5px; font-weight: 600; color: var(--jx-ink-3); margin-top: 3px; }
.jx-resulthead .jx-sub b { color: var(--jx-gold-700); }
.jx-viewtoggle { display: inline-flex; background: var(--jx-line-2); border-radius: var(--jx-pill); padding: 3px; }
.jx-viewtoggle button {
  border: none; background: transparent; color: var(--jx-ink-3); font-size: 13px; font-weight: 600;
  padding: 6px 14px; border-radius: var(--jx-pill); cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
.jx-viewtoggle button[aria-pressed="true"] { background: #fff; color: var(--jx-ink); box-shadow: var(--jx-e1); }

/* ── 7. JOB CARD ─────────────────────────────────────────────────────────── */
.jobs-list { display: flex; flex-direction: column; gap: 12px; }
.jobs-list.jx-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(370px, 1fr)); gap: 14px; align-items: stretch;
}
.job-card {
  position: relative; background: #fff; border: 1px solid var(--jx-line); border-radius: var(--jx-r-16);
  box-shadow: var(--jx-e1); overflow: hidden;
  transition: transform var(--jx-motion), box-shadow var(--jx-motion), border-color var(--jx-motion);
}
.job-card::before {   /* gold accent rail, fades in on hover */
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--jx-gold-600); opacity: 0; transition: opacity var(--jx-motion);
}
.job-card:hover { transform: translateY(-2px); box-shadow: var(--jx-e2); border-color: var(--jx-line); cursor: pointer; }
.job-card:hover::before { opacity: 1; }
.job-card-inner { display: flex; gap: 14px; padding: 16px 18px; align-items: flex-start; height: 100%; }
.jobs-list.jx-grid .job-card-inner { flex-direction: column; }
.jobs-list.jx-grid .job-card-body { width: 100%; }
.org-logo, .org-avatar {
  width: 46px; height: 46px; border-radius: var(--jx-r-12); flex: 0 0 auto; object-fit: contain;
  background: #fff; border: 1px solid var(--jx-line-2); padding: 4px;
}
.org-avatar {
  display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: 18px;
  color: var(--jx-gold-700); background: var(--jx-gold-050); border-color: var(--jx-gold-100);
}
.job-card-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.job-header { display: flex; align-items: flex-start; gap: 10px; }
.job-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 16px; line-height: 1.38; font-weight: 700; }
.job-title a {
  color: var(--jx-ink); text-decoration: none;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  transition: color var(--jx-motion);
}
.job-card:hover .job-title a { color: var(--jx-gold-700); }

/* Quick actions — circular icon buttons top-right */
.job-header .compare-check, .job-header .favorite-btn {
  flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--jx-line); background: #fff; color: var(--jx-ink-3);
  transition: background var(--jx-motion), color var(--jx-motion), border-color var(--jx-motion);
}
.job-header .favorite-btn:hover { background: var(--jx-gold-050); color: var(--jx-gold-700); border-color: var(--jx-gold-100); }
.job-header .favorite-btn.active { color: var(--jx-danger); border-color: var(--jx-danger-bg); }

/* Metadata as chips */
.job-meta { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 0; font-size: 12.5px; }
.job-meta > span {
  display: inline-flex; align-items: center; gap: 5px; max-width: 100%; min-width: 0;
  padding: 3px 9px; border-radius: var(--jx-pill); font-weight: 600;
  background: var(--jx-line-2); color: var(--jx-ink-2);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.job-meta > span:first-child { background: var(--jx-gold-050); color: var(--jx-gold-700); }  /* employer */
.job-meta .job-meta-posted { background: transparent !important; color: var(--jx-ink-3) !important; padding-left: 0; }
.job-meta i { color: var(--jx-ink-4); }
.job-meta > span:first-child i { color: var(--jx-gold-600); }

/* Badges */
.job-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; align-items: center; }
.fomo-badge-new { background: var(--jx-success-bg) !important; color: var(--jx-success) !important; border: none !important;
  font-size: 11px; font-weight: 800; padding: 3px 9px; border-radius: var(--jx-pill); letter-spacing: .5px; }
.grade-badge { background: var(--jx-indigo-bg) !important; color: var(--jx-indigo) !important;
  font-size: 11.5px; font-weight: 700; padding: 3px 9px; border-radius: var(--jx-pill); }
.salary-badge {
  background: var(--jx-success-bg) !important; color: var(--jx-success) !important; border: none !important;
  font-size: 12.5px; font-weight: 800; padding: 4px 11px; border-radius: var(--jx-pill);
  display: inline-flex; align-items: center; gap: 5px;
}
.salary-badge i { color: var(--jx-success) !important; }
.fomo-card-countdown, .job-tag.closing-soon {
  font-size: 11.5px; font-weight: 800; padding: 3px 9px; border-radius: var(--jx-pill);
  background: var(--jx-warning-bg) !important; color: var(--jx-warning) !important; border: none !important;
}
.fomo-card-countdown.urgency-high, .fomo-card-countdown.urgency-final,
.fomo-card-countdown.urgency-critical, .fomo-card-countdown.urgency-alert,
.job-tag.closing-soon { background: var(--jx-danger-bg) !important; color: var(--jx-danger) !important; }

/* Footer CTA (added in markup) */
.jx-cardfoot {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--jx-line-2);
}
.jx-cardfoot .jx-foot-hint { font-size: 12.5px; font-weight: 700; color: var(--jx-ink-3); }
.jx-cardfoot .jx-foot-hint.danger { color: var(--jx-danger); }
.jx-cta {
  display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
  background: var(--jx-ink); color: #fff; font-weight: 700; font-size: 13px;
  padding: 8px 16px; border-radius: var(--jx-pill); transition: background var(--jx-motion);
}
.jx-cta i { transition: transform var(--jx-motion); }
.job-card:hover .jx-cta { background: var(--jx-gold-700); }
.job-card:hover .jx-cta i { transform: translateX(3px); }

/* ── 8. STATES ───────────────────────────────────────────────────────────── */
.lp-load-more-btn {
  height: 48px; padding: 0 26px; border-radius: var(--jx-pill) !important;
  background: #fff !important; color: var(--jx-ink) !important;
  border: 1.5px solid var(--jx-line) !important; font-weight: 700 !important;
  transition: border-color var(--jx-motion), background var(--jx-motion) !important;
}
.lp-load-more-btn:hover { border-color: var(--jx-gold-600) !important; background: var(--jx-gold-050) !important; color: var(--jx-gold-700) !important; }
.jx-backtotop {
  position: fixed; left: 20px; bottom: 20px; z-index: 45;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--jx-line);
  background: #fff; color: var(--jx-ink-2); box-shadow: var(--jx-e2); cursor: pointer;
  display: none; align-items: center; justify-content: center; font-size: 15px;
}
.jx-backtotop.show { display: inline-flex; }

/* In-flight filter request: dim the stale list + inline status note */
.jobs-list.jx-busy { position: relative; }
.jobs-list.jx-busy .job-card { opacity: .45; pointer-events: none; transition: opacity var(--jx-motion); }
.jx-busy-note {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  font-size: 13px; font-weight: 700; color: var(--jx-ink-3); padding: 6px 0 2px;
}
.jx-spin {
  width: 14px; height: 14px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid var(--jx-line); border-top-color: var(--jx-gold-600);
  animation: jxspin .7s linear infinite;
}
@keyframes jxspin { to { transform: rotate(360deg); } }

/* Empty state — exactly one, with a way out */
.jx-empty { text-align: center; padding: 56px 16px 64px; }
.jx-empty i { font-size: 34px; color: var(--jx-ink-4); }
.jx-empty h3 { font-size: 18px; font-weight: 800; color: var(--jx-ink); margin: 14px 0 6px; }
.jx-empty p { font-size: 13.5px; color: var(--jx-ink-3); margin: 0 0 18px; }
.jx-empty-clear {
  height: 42px; padding: 0 22px; border-radius: var(--jx-pill); cursor: pointer;
  border: 1.5px solid var(--jx-gold-600); background: var(--jx-gold-050);
  color: var(--jx-gold-700); font-weight: 700; font-size: 13.5px;
  transition: background var(--jx-motion);
}
.jx-empty-clear:hover { background: var(--jx-gold-100); }

/* ── 9. FAB (bug 5: consolidate — hide redundant AI FAB; AI Search is in toolbar) ── */
.lp-ai-fab { display: none !important; }

/* ── 10. RESPONSIVE ──────────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .lp-filter-search { flex: 1 1 100%; }
  .lp-ai-search-btn { flex: 1 1 100%; justify-content: center; }
  .job-card-inner { padding: 14px; gap: 10px; }
  .jx-cta { padding: 9px 14px; }
  .jobs-list.jx-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .lp-filter-bar, .lp-ai-search-btn, .job-card, .job-card-inner, .jx-cta, .jx-cta i, * {
    transition: none !important; animation: none !important;
  }
}

/* ── 12. CLS HARDENING (Lighthouse CLS 0.38 fix) ─────────────────────────── */
/* Pre-hydration reserve: [v-cloak]{display:none} hides #app until Vue mounts,
   so without this the footer paints near the top and is pushed a full screen
   down at hydration. The wrapper div (plain markup, not Vue-owned) holds the
   space from first paint. */
.jx-app-reserve { min-height: 100vh; }

/* Toolbar region: controls already have fixed heights (search 52px, chips 38px);
   a floor on the inner wrapper stops web-font swap from reflowing the bar. */
.lp-filter-inner { min-height: 80px; } /* 52px row + 14px padding top and bottom */
.lp-filter-row { min-height: 52px; }

/* Results region floor so the skeleton-to-cards swap happens inside space that
   is already reserved. */
.jx-results { min-height: 60vh; }

/* Skeleton cards mirror real card geometry so hydration swaps in place.
   Real list card (this stylesheet): 1px borders (2) + 16px padding x2 (32)
   + body [header 44 + meta 8+25 + tags 10+27 + footer 12+12+36 = 174] = 208px. */
.lp-skeleton-list { padding: 0; gap: 12px; }
.lp-skeleton-card {
  box-sizing: border-box; height: 208px; padding: 16px 18px; gap: 14px;
  align-items: flex-start; overflow: hidden;
  border: 1px solid var(--jx-line); border-radius: var(--jx-r-16); box-shadow: var(--jx-e1);
}
.lp-skel-logo { width: 46px; height: 46px; border-radius: var(--jx-r-12); }
.lp-skel-title { height: 22px; width: 70%; margin-bottom: 10px; }
.lp-skel-meta { height: 25px; width: 55%; margin-bottom: 12px; }
.lp-skel-tags { height: 27px; width: 40%; }

/* Below-fold cards: skip offscreen render work. The `auto` keyword makes the
   browser remember each card's real height once rendered, so the Load More
   button's getBoundingClientRect() (used by the auto-load scroll listener in
   mounted()) stays accurate; 208px is only the first-pass estimate. */
.jobs-list > .job-card { content-visibility: auto; contain-intrinsic-size: auto 208px; }

@media (max-width: 640px) {
  /* Mobile card: 14px padding x2 (28) + borders (2) + taller wrapped body */
  .lp-skeleton-card { height: 236px; padding: 14px; gap: 10px; }
  .jobs-list > .job-card { contain-intrinsic-size: auto 236px; }
}
