/*
 * dept-picker.css — Post-login department selector
 *
 * Lives on top of the auth Three.js canvas (still running in the background,
 * dimmed via vignette). Three cards spring-stagger in. Each card has its own
 * cyan-primary + secondary tint, glass surface, animated specular drift,
 * cursor-following glow, magnetic tilt on hover.
 *
 * Easing: enter = cubic-bezier(.2,.8,.2,1), exit = cubic-bezier(.4,0,.6,1).
 * Durations: micro 120ms, standard 240ms, expressive 400ms, scene 600ms.
 * Mobile: Three.js canvas killed <1194px (existing rule). Picker stays.
 */

/* ── Root overlay ────────────────────────────────────────────────────────── */
.dept-picker {
  position: fixed; inset: 0;
  z-index: 9000;
  display: flex; align-items: stretch; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, rgba(56,189,248,0.06) 0%, transparent 55%),
              radial-gradient(ellipse at 50% 110%, rgba(129,140,248,0.05) 0%, transparent 60%),
              rgba(4, 5, 15, 0.78);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 320ms cubic-bezier(.2,.8,.2,1);
}
.dept-picker.visible {
  opacity: 1;
  pointer-events: auto;
}
.dept-picker.committing { /* don't lock pointer during exit but stop new clicks */
  pointer-events: none;
}

/* ── Soft vignette + drifting ambient gradient mesh ──────────────────────── */
.dp-vignette {
  position: absolute; inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 22%, rgba(56,189,248,0.10) 0%, transparent 38%),
    radial-gradient(circle at 82% 78%, rgba(167,139,250,0.08) 0%, transparent 42%),
    radial-gradient(circle at 50% 50%, transparent 0%, rgba(2,3,8,0.42) 100%);
  animation: dpMeshDrift 22s ease-in-out infinite alternate;
}
@keyframes dpMeshDrift {
  0%   { transform: translate3d(0, 0, 0)   scale(1.00); }
  100% { transform: translate3d(-2%, 1%, 0) scale(1.04); }
}

/* ── Inner content (centred column) ──────────────────────────────────────── */
.dp-content {
  position: relative;
  width: min(1180px, 100% - 64px);
  margin: auto;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 44px;
  padding: 48px 0;
}

/* ── Header block ────────────────────────────────────────────────────────── */
.dp-header {
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  animation: dpHeaderIn 540ms cubic-bezier(.2,.8,.2,1) 80ms forwards;
}
@keyframes dpHeaderIn {
  to { opacity: 1; transform: translateY(0); }
}

.dp-eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 11px; font-weight: 600;
  letter-spacing: 0.18em;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
}
.dp-eyebrow-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 8px rgba(52,211,153,0.7);
  animation: dpDotPulse 2.4s ease-in-out infinite;
}
@keyframes dpDotPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.55; transform: scale(0.85); }
}

.dp-title {
  margin: 16px 0 8px;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: clamp(34px, 6vw, 64px);
  letter-spacing: -0.02em;
  line-height: 1;
  color: #ffffff;
}
.dp-title span {
  background: linear-gradient(90deg, #38bdf8 0%, #818cf8 60%, #2dd4bf 100%);
  -webkit-background-clip: text;
          background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% auto;
  animation: dpTitleShift 6s ease-in-out infinite alternate;
}
@keyframes dpTitleShift {
  0%   { background-position:   0% 50%; }
  100% { background-position: 100% 50%; }
}

.dp-sub {
  margin: 0;
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 14px;
  color: rgba(255,255,255,0.58);
  letter-spacing: 0.01em;
}

/* ── Card grid ───────────────────────────────────────────────────────────── */
.dp-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  width: 100%;
  perspective: 1400px;
}

/* ── Card ────────────────────────────────────────────────────────────────── */
.dp-card {
  --dept-accent: #38bdf8;
  --dept-tint:   #2dd4bf;
  --tilt-x: 0deg;
  --tilt-y: 0deg;
  --mx: 50%;
  --my: 50%;

  position: relative;
  display: flex; flex-direction: column;
  gap: 18px;
  text-align: left;
  padding: 28px 26px 22px;
  min-height: 320px;
  border-radius: 22px;
  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(22px) saturate(130%);
  -webkit-backdrop-filter: blur(22px) saturate(130%);
  box-shadow:
    0 1px 0  rgba(255,255,255,0.06) inset,
    0 -1px 0 rgba(255,255,255,0.02) inset,
    0 14px 40px -16px rgba(0,0,0,0.7);
  color: #ffffff;
  cursor: pointer;
  transform: translateY(28px) scale(0.96);
  opacity: 0;
  will-change: transform, opacity, filter;
  transition:
    transform 540ms cubic-bezier(.2,.8,.2,1),
    opacity   540ms cubic-bezier(.2,.8,.2,1),
    box-shadow 320ms cubic-bezier(.2,.8,.2,1),
    border-color 240ms ease,
    filter 420ms cubic-bezier(.2,.8,.2,1);
  overflow: hidden;
  isolation: isolate; /* contain blend modes / glow inside the card */
}
.dp-card.in {
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Animated specular drift across the glass surface */
.dp-card-bg {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background:
    linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0) 32%),
    radial-gradient(circle at 12% 8%, color-mix(in oklab, var(--dept-accent) 22%, transparent) 0%, transparent 38%),
    radial-gradient(circle at 88% 92%, color-mix(in oklab, var(--dept-tint) 18%, transparent) 0%, transparent 42%);
  opacity: 0.85;
}
/* Cursor-tracked glow — magnetic spotlight */
.dp-card-glow {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(circle at var(--mx) var(--my),
    color-mix(in oklab, var(--dept-accent) 28%, transparent) 0%,
    transparent 50%);
  opacity: 0;
  transition: opacity 280ms cubic-bezier(.2,.8,.2,1);
  mix-blend-mode: screen;
}
.dp-card:hover .dp-card-glow { opacity: 1; }

/* Subtle noise to kill banding (procedural via SVG data URL) */
.dp-card-noise {
  position: absolute; inset: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.45'/></svg>");
}

/* Hover / focus state — lift, tilt, glow strengthens, border picks up tint */
.dp-card:hover,
.dp-card:focus-visible {
  outline: none;
  transform: translateY(-6px) rotateX(var(--tilt-x)) rotateY(var(--tilt-y));
  border-color: color-mix(in oklab, var(--dept-accent) 40%, rgba(255,255,255,0.10));
  box-shadow:
    0 1px 0  rgba(255,255,255,0.08) inset,
    0 -1px 0 rgba(255,255,255,0.02) inset,
    0 28px 60px -22px color-mix(in oklab, var(--dept-accent) 50%, rgba(0,0,0,0.8)),
    0 0 0 1px color-mix(in oklab, var(--dept-accent) 22%, transparent);
}
.dp-card:active { transform: translateY(-2px) scale(0.985); }

/* ── Glyph (top-left art) ────────────────────────────────────────────────── */
.dp-card-glyph {
  width: 56px; height: 56px;
  color: var(--dept-tint);
  filter: drop-shadow(0 0 14px color-mix(in oklab, var(--dept-tint) 35%, transparent));
  transition: transform 380ms cubic-bezier(.2,.8,.2,1);
}
.dp-card:hover .dp-card-glyph {
  transform: translate3d(calc((var(--mx, 50%) - 50%) * 0.06), calc((var(--my, 50%) - 50%) * 0.06), 0) scale(1.04);
}
.dp-card-glyph svg { width: 100%; height: 100%; }

/* ── Body text ───────────────────────────────────────────────────────────── */
.dp-card-body { display: flex; flex-direction: column; gap: 4px; margin-top: auto; }

.dp-card-title {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-weight: 700;
  font-size: 30px;
  line-height: 1.05;
  letter-spacing: -0.015em;
  color: #ffffff;
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

.dp-card-sub {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 13px;
  color: rgba(255,255,255,0.62);
  letter-spacing: 0.005em;
}

/* ── Foot row (Enter affordance) ─────────────────────────────────────────── */
.dp-card-foot {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px;
}
.dp-card-enter {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.03);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em;
  color: rgba(255,255,255,0.82);
  text-transform: uppercase;
  transition: background 220ms, border-color 220ms, color 220ms, transform 220ms cubic-bezier(.2,.8,.2,1);
}
.dp-card:hover .dp-card-enter {
  background: color-mix(in oklab, var(--dept-accent) 14%, rgba(255,255,255,0.04));
  border-color: color-mix(in oklab, var(--dept-accent) 45%, rgba(255,255,255,0.12));
  color: #ffffff;
}
.dp-card-enter svg {
  transition: transform 240ms cubic-bezier(.2,.8,.2,1);
}
.dp-card:hover .dp-card-enter svg { transform: translateX(3px); }

/* ── Commit animation (chosen card expands, others fade) ─────────────────── */
.dp-card.faded {
  transform: translateY(8px) scale(0.96);
  opacity: 0.2;
  filter: blur(2px) saturate(0.6);
  transition:
    transform 380ms cubic-bezier(.4,0,.6,1),
    opacity   380ms cubic-bezier(.4,0,.6,1),
    filter    380ms cubic-bezier(.4,0,.6,1);
}
.dp-card.chosen {
  transform: scale(1.03);
  box-shadow:
    0 0 0 1px color-mix(in oklab, var(--dept-accent) 60%, transparent),
    0 0 40px color-mix(in oklab, var(--dept-accent) 55%, transparent),
    0 30px 80px -20px color-mix(in oklab, var(--dept-accent) 40%, rgba(0,0,0,0.8));
  animation: dpCardCommit 520ms cubic-bezier(.4,0,.6,1) forwards;
}
@keyframes dpCardCommit {
  0%   { transform: scale(1.03); }
  35%  { transform: scale(1.05); }
  100% { transform: scale(1.5);  opacity: 0; }
}

/* ── Footer ──────────────────────────────────────────────────────────────── */
.dp-footer {
  display: flex; align-items: center; justify-content: space-between;
  width: 100%;
  margin-top: 12px;
  opacity: 0;
  animation: dpFooterIn 540ms cubic-bezier(.2,.8,.2,1) 460ms forwards;
}
@keyframes dpFooterIn { to { opacity: 1; } }

.dp-logout {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 14px;
  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.65);
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 12px; 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);
}
.dp-logout:hover {
  background: rgba(251,113,133,0.10);
  border-color: rgba(251,113,133,0.30);
  color: #fb7185;
}
.dp-logout:active { transform: scale(0.97); }

.dp-foot-meta {
  font-family: 'Space Grotesk', Inter, sans-serif;
  font-size: 10px;
  letter-spacing: 0.22em;
  color: rgba(255,255,255,0.30);
  text-transform: uppercase;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .dp-cards { gap: 18px; }
  .dp-card  { min-height: 280px; padding: 22px 22px 18px; }
  .dp-card-title { font-size: 26px; }
}

@media (max-width: 900px) {
  .dp-cards { grid-template-columns: 1fr; gap: 14px; }
  .dp-card  { min-height: auto; flex-direction: row; align-items: center; padding: 18px 20px; gap: 16px; }
  .dp-card-glyph { width: 48px; height: 48px; flex: 0 0 48px; }
  .dp-card-body  { flex: 1; margin-top: 0; }
  .dp-card-title { font-size: 22px; }
  .dp-card-sub   { font-size: 12px; }
  .dp-card-foot  { display: none; } /* affordance is the whole row at this width */
  .dp-content    { gap: 28px; padding: 32px 0; }
  .dp-header     { padding: 0 8px; }
}

@media (max-width: 640px) {
  .dp-content { width: calc(100% - 28px); gap: 22px; }
  .dp-card { padding: 16px; gap: 14px; min-height: 76px; }
  .dp-card-glyph { width: 40px; height: 40px; flex: 0 0 40px; }
  .dp-card-title { font-size: 20px; }
  .dp-title { font-size: clamp(28px, 9vw, 40px); }
  .dp-sub { font-size: 13px; }
  .dp-footer { flex-direction: column; gap: 12px; align-items: center; }
  .dp-foot-meta { font-size: 9px; }
}

@media (max-width: 400px) {
  .dp-content { width: calc(100% - 20px); }
  .dp-card-title { font-size: 18px; }
  .dp-eyebrow { font-size: 10px; padding: 5px 11px; }
}

/* ── Light theme ─────────────────────────────────────────────────────────── */
html[data-theme="light"] .dept-picker {
  background: radial-gradient(ellipse at 50% 30%, rgba(56,189,248,0.08) 0%, transparent 55%),
              radial-gradient(ellipse at 50% 110%, rgba(129,140,248,0.06) 0%, transparent 60%),
              rgba(240, 244, 255, 0.78);
}
html[data-theme="light"] .dp-title { color: #0f172a; }
html[data-theme="light"] .dp-sub   { color: rgba(15,23,42,0.62); }
html[data-theme="light"] .dp-eyebrow {
  background: rgba(15,23,42,0.04);
  border-color: rgba(15,23,42,0.08);
  color: rgba(15,23,42,0.62);
}
html[data-theme="light"] .dp-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);
  color: #0f172a;
  box-shadow: 0 10px 30px -14px rgba(15,23,42,0.18);
}
html[data-theme="light"] .dp-card-title  { color: #0f172a; }
html[data-theme="light"] .dp-card-sub    { color: rgba(15,23,42,0.58); }
html[data-theme="light"] .dp-card-enter  { color: rgba(15,23,42,0.7); border-color: rgba(15,23,42,0.12); background: rgba(15,23,42,0.04); }
html[data-theme="light"] .dp-foot-meta   { color: rgba(15,23,42,0.32); }
html[data-theme="light"] .dp-logout      { background: rgba(15,23,42,0.04); border-color: rgba(15,23,42,0.10); color: rgba(15,23,42,0.6); }

/* ── Reduced motion: fades only, no translate/scale/parallax ─────────────── */
@media (prefers-reduced-motion: reduce) {
  .dp-vignette { animation: none; }
  .dp-title span { animation: none; }
  .dp-eyebrow-dot { animation: none; }
  .dp-header { transform: none; animation-duration: 0.001ms; opacity: 1; }
  .dp-card {
    transform: none !important;
    transition: opacity 240ms ease, background 200ms ease, border-color 200ms ease;
  }
  .dp-card.in { opacity: 1; }
  .dp-card:hover { transform: none; }
  .dp-card-glyph { transition: none; }
  .dp-card.chosen { animation: dpFadeOnly 320ms ease forwards; }
  .dp-card.faded  { transform: none !important; filter: none; }
  @keyframes dpFadeOnly { to { opacity: 0; } }
}
