/*
 * departments.css — multi-department architecture
 *
 * Covers:
 *   1. Nav dept badge + switcher dropdown (lives in every dashboard's nav)
 *   2. Analytics / Sales placeholder shells (`#dashboard-analytics`, `#dashboard-sales`)
 *   3. Subtle per-dept accent overrides on the cultivation shell (so the
 *      identity changes when a multi-dept user switches into Cultivation)
 *
 * Motion: stagger-in cards (CSS-only via data-stagger + JS adds .mount-in),
 * shared easings with the rest of the system.
 */

/* ════════════════════════════════════════════════════════════════════════
   1) Nav dept badge + dropdown
   ════════════════════════════════════════════════════════════════════════ */
.nav-dept-wrap {
  --dept-tint: var(--accent-cyan, #38bdf8);
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-left: 14px;
  z-index: 30;
}
.nav-dept-wrap:empty { display: none; }

.nav-dept-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 11px 6px 9px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.85);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 200ms ease, border-color 200ms ease, transform 160ms cubic-bezier(.2,.8,.2,1);
}
.nav-dept-wrap.single .nav-dept-badge {
  cursor: default;
  pointer-events: none;
}
.nav-dept-badge:hover {
  background: color-mix(in oklab, var(--dept-tint) 12%, rgba(255,255,255,0.04));
  border-color: color-mix(in oklab, var(--dept-tint) 36%, rgba(255,255,255,0.10));
}
.nav-dept-badge:active { transform: scale(0.97); }
.nav-dept-wrap.open .nav-dept-badge {
  background: color-mix(in oklab, var(--dept-tint) 16%, rgba(255,255,255,0.06));
  border-color: color-mix(in oklab, var(--dept-tint) 50%, rgba(255,255,255,0.10));
}
.nav-dept-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--dept-tint);
  box-shadow: 0 0 6px color-mix(in oklab, var(--dept-tint) 70%, transparent);
  animation: navDeptDot 2.4s ease-in-out infinite;
}
@keyframes navDeptDot {
  0%, 100% { transform: scale(1);    opacity: 1; }
  50%      { transform: scale(0.78); opacity: 0.6; }
}
.nav-dept-name {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}
.nav-dept-chev {
  margin-left: 1px;
  color: rgba(255,255,255,0.45);
  transition: transform 200ms cubic-bezier(.2,.8,.2,1);
}
.nav-dept-wrap.open .nav-dept-chev { transform: rotate(180deg); }

/* Dropdown */
.nav-dept-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 240px;
  padding: 6px;
  border-radius: 14px;
  background: rgba(10, 13, 22, 0.92);
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(22px) saturate(140%);
  -webkit-backdrop-filter: blur(22px) saturate(140%);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.06) inset,
    0 22px 50px -22px rgba(0,0,0,0.7);
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  transform-origin: top left;
  pointer-events: none;
  transition: opacity 200ms cubic-bezier(.2,.8,.2,1), transform 220ms cubic-bezier(.2,.8,.2,1);
}
.nav-dept-wrap.open .nav-dept-dropdown {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.nav-dept-dd-label {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.40);
  padding: 8px 10px 6px;
}
.nav-dept-item {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  align-items: center;
  column-gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #ffffff;
  text-align: left;
  cursor: pointer;
  transition: background 180ms ease, transform 160ms cubic-bezier(.2,.8,.2,1);
}
.nav-dept-item .nav-dept-dot { width: 8px; height: 8px; }
.nav-dept-item-name {
  display: block;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0;
}
.nav-dept-item-sub {
  display: block;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45);
  margin-top: 2px;
  grid-column: 2;
}
.nav-dept-check {
  font-size: 11px;
  color: var(--dept-tint);
  filter: drop-shadow(0 0 6px color-mix(in oklab, var(--dept-tint) 60%, transparent));
}
.nav-dept-item:hover { background: rgba(255,255,255,0.06); }
.nav-dept-item:active { transform: scale(0.98); }
.nav-dept-item.current {
  background: color-mix(in oklab, var(--dept-tint) 12%, transparent);
}
.nav-dept-item.locked {
  opacity: 0.42;
  cursor: not-allowed;
  filter: saturate(0.55);
}
.nav-dept-item.locked:hover { background: transparent; }

/* Light theme */
html[data-theme="light"] .nav-dept-badge {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.10);
  color: rgba(15,23,42,0.82);
}
html[data-theme="light"] .nav-dept-chev   { color: rgba(15,23,42,0.40); }
html[data-theme="light"] .nav-dept-dropdown {
  background: rgba(255,255,255,0.92);
  border-color: rgba(15,23,42,0.10);
}
html[data-theme="light"] .nav-dept-dd-label   { color: rgba(15,23,42,0.40); }
html[data-theme="light"] .nav-dept-item       { color: #0f172a; }
html[data-theme="light"] .nav-dept-item-sub   { color: rgba(15,23,42,0.45); }
html[data-theme="light"] .nav-dept-item:hover { background: rgba(15,23,42,0.05); }

/* ════════════════════════════════════════════════════════════════════════
   2) Placeholder department dashboards (Analytics, Sales)
   ════════════════════════════════════════════════════════════════════════ */
.dept-dashboard {
  min-height: 100vh;
  opacity: 0;
  transition: opacity 480ms cubic-bezier(.2,.8,.2,1);
}
.dept-dashboard.visible { opacity: 1; }
.dept-dashboard.hidden  { display: none; }

#dashboard-analytics, #dashboard-sales {
  position: relative;
  font-family: 'Space Grotesk', Inter, sans-serif;
  color: #ffffff;
}

.dept-shell {
  position: relative;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  isolation: isolate;
}

/* Ambient drifting mesh, scoped to each dept's tint */
.dept-shell-bg {
  position: fixed; inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 15% 18%, rgba(56,189,248,0.10) 0%, transparent 40%),
    radial-gradient(circle at 85% 82%, rgba(129,140,248,0.08) 0%, transparent 45%),
    radial-gradient(circle at 50% 110%, rgba(45,212,191,0.06) 0%, transparent 55%);
  animation: deptShellDrift 28s ease-in-out infinite alternate;
}
#dashboard-sales .dept-shell-bg {
  background:
    radial-gradient(circle at 18% 12%, rgba(251,191,36,0.09)  0%, transparent 40%),
    radial-gradient(circle at 82% 88%, rgba(167,139,250,0.07) 0%, transparent 45%),
    radial-gradient(circle at 50% 50%, rgba(56,189,248,0.05)  0%, transparent 55%);
}
@keyframes deptShellDrift {
  0%   { transform: translate3d(0, 0, 0)   scale(1.00); }
  100% { transform: translate3d(-2%, 1.5%, 0) scale(1.05); }
}

/* ── Top bar ──────────────────────────────────────────────────────────── */
.dept-shell-head {
  position: relative;
  z-index: 2;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 18px 32px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(10,13,22,0.72) 0%, rgba(10,13,22,0.42) 100%);
  backdrop-filter: blur(20px) saturate(140%);
  -webkit-backdrop-filter: blur(20px) saturate(140%);
}

.dept-shell-brand {
  display: inline-flex; align-items: center; gap: 12px;
}
.dept-shell-brand-mark {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: rgba(56,189,248,0.10);
  border: 1px solid rgba(56,189,248,0.22);
}
.dept-shell-brand-text {
  display: inline-flex; flex-direction: column; line-height: 1; gap: 4px;
}
.dept-shell-brand-name {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: #ffffff;
  text-transform: uppercase;
}
.dept-shell-brand-name span { color: var(--accent-cyan, #38bdf8); }
.dept-shell-brand-dept {
  --dept-tint: #38bdf8;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--dept-tint);
  text-transform: uppercase;
}

/* Switcher pills (inside placeholder shells) */
.dept-shell-switch {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  justify-self: center;
}
.dept-switch-pill {
  --dept-tint: #38bdf8;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 6px 13px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.65);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background 180ms ease, color 180ms ease, transform 160ms cubic-bezier(.2,.8,.2,1);
}
.dept-switch-pill .dept-switch-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--dept-tint);
  box-shadow: 0 0 6px color-mix(in oklab, var(--dept-tint) 70%, transparent);
}
.dept-switch-pill:hover {
  color: #ffffff;
  background: rgba(255,255,255,0.05);
}
.dept-switch-pill:active { transform: scale(0.97); }
.dept-switch-pill.current {
  color: #ffffff;
  background: color-mix(in oklab, var(--dept-tint) 18%, rgba(255,255,255,0.04));
}
.dept-switch-pill.locked {
  opacity: 0.36;
  cursor: not-allowed;
  filter: saturate(0.4);
}
.dept-switch-pill.locked:hover { background: transparent; color: rgba(255,255,255,0.65); }
.dept-switch-check {
  font-size: 8px;
  color: var(--dept-tint);
}

.dept-shell-logout {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.62);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 11px; font-weight: 500;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: background 200ms, color 200ms, border-color 200ms, transform 160ms cubic-bezier(.2,.8,.2,1);
}
.dept-shell-logout:hover {
  background: rgba(251,113,133,0.10);
  border-color: rgba(251,113,133,0.30);
  color: #fb7185;
}
.dept-shell-logout:active { transform: scale(0.97); }

/* ── Main column ─────────────────────────────────────────────────────── */
.dept-shell-main {
  position: relative;
  z-index: 1;
  max-width: 1180px;
  width: calc(100% - 64px);
  margin: 0 auto;
  padding: 64px 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Stagger entrance for any [data-stagger] child */
.dept-shell [data-stagger] {
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 540ms cubic-bezier(.2,.8,.2,1),
    transform 540ms cubic-bezier(.2,.8,.2,1);
  will-change: transform, opacity;
}
.dept-shell [data-stagger].mount-in {
  opacity: 1;
  transform: translateY(0);
}

.dept-shell-eyebrow {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.62);
  text-transform: uppercase;
  align-self: flex-start;
}
.dept-shell-dot {
  --dept-tint: #38bdf8;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--dept-tint);
  box-shadow: 0 0 8px color-mix(in oklab, var(--dept-tint) 65%, transparent);
  animation: navDeptDot 2.4s ease-in-out infinite;
}

.dept-shell-title {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: clamp(36px, 6.4vw, 64px);
  letter-spacing: -0.02em;
  line-height: 1.02;
  color: #ffffff;
}
.dept-shell-title span {
  background: linear-gradient(90deg, #38bdf8 0%, #818cf8 60%, #2dd4bf 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}
#dashboard-sales .dept-shell-title span {
  background: linear-gradient(90deg, #fbbf24 0%, #fb7185 50%, #a78bfa 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
}

.dept-shell-lede {
  max-width: 720px;
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: rgba(255,255,255,0.62);
}

/* ── Coming-soon cards ───────────────────────────────────────────────── */
.dept-shell-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 8px;
}

.dept-shell-card {
  --dept-tint: #38bdf8;
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px 22px 18px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.06);
  background: linear-gradient(180deg, rgba(255,255,255,0.05) 0%, rgba(255,255,255,0.02) 100%);
  backdrop-filter: blur(18px) saturate(130%);
  -webkit-backdrop-filter: blur(18px) saturate(130%);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px);
  transition:
    opacity 540ms cubic-bezier(.2,.8,.2,1),
    transform 540ms cubic-bezier(.2,.8,.2,1),
    border-color 220ms ease,
    background 220ms ease;
}
.dept-shell-card.mount-in {
  opacity: 1;
  transform: translateY(0);
}
.dept-shell-card::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(circle at 14% 8%, color-mix(in oklab, var(--dept-tint) 18%, transparent) 0%, transparent 42%);
  opacity: 0.7;
}
.dept-shell-card:hover {
  border-color: color-mix(in oklab, var(--dept-tint) 30%, rgba(255,255,255,0.10));
  background: linear-gradient(180deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.025) 100%);
}

.dept-shell-card-glyph {
  width: 38px; height: 38px;
  color: var(--dept-tint);
  filter: drop-shadow(0 0 10px color-mix(in oklab, var(--dept-tint) 40%, transparent));
}
.dept-shell-card-glyph svg { width: 100%; height: 100%; }

.dept-shell-card-title {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.005em;
  color: #ffffff;
}
.dept-shell-card-sub {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  color: rgba(255,255,255,0.58);
}
.dept-shell-card-status {
  align-self: flex-start;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: color-mix(in oklab, var(--dept-tint) 14%, rgba(255,255,255,0.04));
  border: 1px solid color-mix(in oklab, var(--dept-tint) 30%, rgba(255,255,255,0.08));
  color: var(--dept-tint);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 9px; font-weight: 700;
  letter-spacing: 0.20em;
  text-transform: uppercase;
}

/* ════════════════════════════════════════════════════════════════════════
   3) Light theme — placeholder shells
   ════════════════════════════════════════════════════════════════════════ */
html[data-theme="light"] .dept-shell-head {
  background: linear-gradient(180deg, rgba(240,244,255,0.85) 0%, rgba(240,244,255,0.55) 100%);
  border-bottom-color: rgba(15,23,42,0.08);
}
html[data-theme="light"] .dept-shell-brand-name { color: #0f172a; }
html[data-theme="light"] .dept-shell-switch {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.08);
}
html[data-theme="light"] .dept-switch-pill { color: rgba(15,23,42,0.6); }
html[data-theme="light"] .dept-switch-pill:hover { color: #0f172a; background: rgba(15,23,42,0.05); }
html[data-theme="light"] .dept-switch-pill.current { color: #0f172a; }
html[data-theme="light"] .dept-shell-logout {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.10);
  color: rgba(15,23,42,0.6);
}
html[data-theme="light"] .dept-shell-eyebrow {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.08);
  color: rgba(15,23,42,0.6);
}
html[data-theme="light"] .dept-shell-title { color: #0f172a; }
html[data-theme="light"] .dept-shell-lede  { color: rgba(15,23,42,0.62); }
html[data-theme="light"] .dept-shell-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.85) 0%, rgba(255,255,255,0.72) 100%);
  border-color: rgba(15,23,42,0.08);
  box-shadow: 0 10px 28px -14px rgba(15,23,42,0.18);
}
html[data-theme="light"] .dept-shell-card-title { color: #0f172a; }
html[data-theme="light"] .dept-shell-card-sub   { color: rgba(15,23,42,0.6); }

/* ════════════════════════════════════════════════════════════════════════
   4) Responsive
   ════════════════════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .dept-shell-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 768px) {
  /* Match the system-wide rule — disable heavy ambient motion on phones.
     Was ≤1194px in the iPad-first era (relaxed 2026-05-22). */
  .dept-shell-bg { animation: none; }
  .dp-vignette  { animation: none; }
}
@media (max-width: 900px) {
  .dept-shell-head {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px 16px;
  }
  .dept-shell-switch { justify-self: stretch; flex-wrap: wrap; justify-content: center; }
  .dept-shell-logout { justify-self: end; }
  .dept-shell-main { padding: 36px 0; gap: 22px; width: calc(100% - 32px); }
  .dept-shell-grid { grid-template-columns: 1fr; gap: 12px; }
}
@media (max-width: 640px) {
  .dept-shell-brand-name { font-size: 13px; letter-spacing: 0.14em; }
  .dept-shell-brand-dept { font-size: 8px; letter-spacing: 0.28em; }
  .dept-switch-pill { padding: 6px 10px; font-size: 10px; min-height: 36px; }
  .dept-shell-title { font-size: clamp(28px, 9vw, 40px); }
  .dept-shell-lede  { font-size: 14px; }
  .dept-shell-card  { padding: 18px; }
  .dept-shell-card-title { font-size: 16px; }
}
@media (max-width: 400px) {
  .dept-shell-head { padding: 12px 12px; }
  .dept-shell-main { width: calc(100% - 20px); padding: 28px 0; }
  .dept-shell-brand-name { font-size: 12px; }
  .dept-shell-card { padding: 16px; }
}

/* ── Nav dept badge: small-screen pass ───────────────────────────────── */
@media (max-width: 640px) {
  .nav-dept-wrap { margin-left: 8px; }
  .nav-dept-badge { padding: 5px 9px 5px 8px; font-size: 10px; gap: 6px; }
  .nav-dept-name { font-size: 10px; }
  .nav-dept-dropdown { min-width: 220px; left: -8px; }
}
@media (max-width: 400px) {
  /* The dept badge is important enough to keep; hide only the dept sub-label */
  .nav-dept-item-sub { display: none; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .dept-shell-bg { animation: none; }
  .nav-dept-dot, .dept-shell-dot { animation: none; }
  .dept-shell [data-stagger] { transition: opacity 240ms ease; transform: none; }
  .dept-shell [data-stagger].mount-in { transform: none; }
  .dept-shell-card { transition: opacity 240ms ease, border-color 200ms ease; transform: none; }
  .dept-shell-card.mount-in { transform: none; }
  .nav-dept-dropdown { transition: opacity 180ms ease; transform: none; }
  .nav-dept-wrap.open .nav-dept-dropdown { transform: none; }
  .nav-dept-chev { transition: none; }
}
