/* ═══════════════════════════════════════════════════════
   FML Case Search Engine — Global Styles
   Design: Apple × Linear × Vercel · Dark Mode
   ═══════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Reset & Base ────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg:         #06080f;
  --bg-2:       #0b0f1a;
  --surface:    rgba(255,255,255,0.032);
  --surface-2:  rgba(255,255,255,0.06);
  --border:     rgba(255,255,255,0.07);
  --border-2:   rgba(255,255,255,0.12);
  --primary:    #4f8ef7;
  --primary-glow: rgba(79,142,247,0.25);
  --accent:     #a78bfa;
  --accent-glow: rgba(167,139,250,0.2);
  --text-1:     #f1f5f9;
  --text-2:     #94a3b8;
  --text-3:     #475569;
  --danger:     #f87171;
  --success:    #34d399;
  --radius:     14px;
  --radius-sm:  8px;
  --radius-lg:  20px;
  --blur:       blur(20px) saturate(180%);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.4), 0 1px 0 rgba(255,255,255,0.05) inset;
  --shadow-glow: 0 0 40px rgba(79,142,247,0.15);
  --transition:  cubic-bezier(0.4, 0, 0.2, 1);
  --spring:      cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text-1);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Canvas particle background ──────────────────────── */
#particle-canvas {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.6;
}

/* ── Animated gradient mesh background ───────────────── */
.gradient-mesh {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.gradient-mesh::before {
  content: '';
  position: absolute;
  width: 900px;
  height: 900px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,142,247,0.08) 0%, transparent 70%);
  top: -300px;
  left: -200px;
  animation: meshDrift1 18s ease-in-out infinite alternate;
  will-change: transform;
}

.gradient-mesh::after {
  content: '';
  position: absolute;
  width: 700px;
  height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(167,139,250,0.07) 0%, transparent 70%);
  bottom: -200px;
  right: -100px;
  animation: meshDrift2 22s ease-in-out infinite alternate;
  will-change: transform;
}

@keyframes meshDrift1 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(120px, 80px) scale(1.15); }
}

@keyframes meshDrift2 {
  0%   { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-80px, -60px) scale(1.1); }
}

/* ── Navigation ──────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 28px;
  justify-content: space-between;
  background: rgba(6,8,15,0.7);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
  animation: navSlideDown 0.5s var(--transition) both;
}

@keyframes navSlideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text-1);
}

.nav-brand-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, #4f8ef7, #7c6af0);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.nav-brand-icon svg { width: 16px; height: 16px; }

.nav-brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.nav-brand-sub {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-pill {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 12px;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.nav-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.8); }
}

/* ── Glass Card ──────────────────────────────────────── */
.glass-card {
  background: var(--surface);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
}

.glass-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255,255,255,0.04) 0%, transparent 60%);
  pointer-events: none;
}

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  outline: none;
  transition: transform 0.15s var(--transition), box-shadow 0.15s var(--transition),
              background 0.2s var(--transition), opacity 0.15s;
  will-change: transform;
  position: relative;
  overflow: hidden;
  text-decoration: none;
  white-space: nowrap;
}

.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

/* Ripple */
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at var(--mx,50%) var(--my,50%), rgba(255,255,255,0.15) 0%, transparent 60%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.btn:hover::after { opacity: 1; }

.btn-primary {
  background: linear-gradient(135deg, #4f8ef7 0%, #7c6af0 100%);
  color: #fff;
  box-shadow: 0 4px 20px rgba(79,142,247,0.35), 0 1px 0 rgba(255,255,255,0.15) inset;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(79,142,247,0.5), 0 1px 0 rgba(255,255,255,0.15) inset;
}

.btn-primary:active { transform: translateY(0) scale(0.98); }

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-ghost {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--border-2);
  transform: translateY(-1px);
}

.btn-icon {
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--border);
  padding: 8px;
  border-radius: 8px;
}

.btn-icon:hover {
  background: rgba(79,142,247,0.15);
  color: var(--primary);
  border-color: rgba(79,142,247,0.3);
}

/* ── Inputs ──────────────────────────────────────────── */
.input-wrap {
  position: relative;
}

.input-wrap .input-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
  transition: color 0.15s;
  width: 16px; height: 16px;
}

.field-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-1);
  outline: none;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  caret-color: var(--primary);
}

.field-input.has-icon { padding-left: 42px; }

.field-input::placeholder { color: var(--text-3); }

.field-input:focus {
  border-color: var(--primary);
  background: rgba(79,142,247,0.05);
  box-shadow: 0 0 0 3px rgba(79,142,247,0.12);
}

.input-wrap:focus-within .input-icon { color: var(--primary); }

/* ── Labels ──────────────────────────────────────────── */
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 7px;
  letter-spacing: 0.2px;
}

/* ── Error ───────────────────────────────────────────── */
.error-box {
  display: none;
  align-items: center;
  gap: 8px;
  background: rgba(248,113,113,0.08);
  border: 1px solid rgba(248,113,113,0.2);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--danger);
  animation: shakeX 0.4s var(--transition);
}

.error-box.show { display: flex; }
.error-box svg { width: 14px; height: 14px; flex-shrink: 0; }

@keyframes shakeX {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

/* ── Spinner ─────────────────────────────────────────── */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  will-change: transform;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Entrance Animations ─────────────────────────────── */
.fade-up {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeUp 0.5s var(--spring) forwards;
}

@keyframes fadeUp {
  to { opacity: 1; transform: translateY(0); }
}

.fade-in {
  opacity: 0;
  animation: fadeIn 0.4s var(--transition) forwards;
}

@keyframes fadeIn { to { opacity: 1; } }

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.12s; }
.stagger-3 { animation-delay: 0.19s; }
.stagger-4 { animation-delay: 0.26s; }
.stagger-5 { animation-delay: 0.33s; }

/* ── Badge ───────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2px;
}

.badge-blue {
  background: rgba(79,142,247,0.12);
  color: #93c5fd;
  border: 1px solid rgba(79,142,247,0.2);
}

.badge-green {
  background: rgba(52,211,153,0.1);
  color: #34d399;
  border: 1px solid rgba(52,211,153,0.2);
}

.badge-purple {
  background: rgba(167,139,250,0.1);
  color: #c4b5fd;
  border: 1px solid rgba(167,139,250,0.2);
}

/* ── Tag ─────────────────────────────────────────────── */
.tag {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  color: var(--text-2);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  transition: background 0.15s, color 0.15s;
}

.tag:hover {
  background: rgba(79,142,247,0.1);
  color: var(--primary);
  border-color: rgba(79,142,247,0.2);
}

/* ── Page wrapper ────────────────────────────────────── */
.page-content {
  position: relative;
  z-index: 1;
}

/* ── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── Selection ───────────────────────────────────────── */
::selection {
  background: rgba(79,142,247,0.3);
  color: #fff;
}

/* ── Focus visible ───────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
  border-radius: 4px;
}

/* ── Tooltip ─────────────────────────────────────────── */
[data-tip] {
  position: relative;
}

[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%) scale(0.9);
  background: rgba(15,20,35,0.95);
  border: 1px solid var(--border-2);
  color: var(--text-1);
  font-size: 11px;
  padding: 5px 10px;
  border-radius: 6px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
  z-index: 9999;
  backdrop-filter: blur(8px);
}

[data-tip]:hover::after {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 640px) {
  .nav { padding: 0 16px; }
  .nav-brand-sub { display: none; }
}

/* ── Light theme ─────────────────────────────────────── */
html.light {
  --bg:         #f0f2f8;
  --bg-2:       #e8ebf4;
  --surface:    rgba(0,0,0,0.04);
  --surface-2:  rgba(0,0,0,0.07);
  --border:     rgba(0,0,0,0.09);
  --border-2:   rgba(0,0,0,0.15);
  --primary:    #2563eb;
  --primary-glow: rgba(37,99,235,0.2);
  --accent:     #7c3aed;
  --accent-glow: rgba(124,58,237,0.15);
  --text-1:     #0f172a;
  --text-2:     #475569;
  --text-3:     #94a3b8;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.1), 0 1px 0 rgba(255,255,255,0.8) inset;
}

html.light body { background: var(--bg); }

html.light .gradient-mesh::before,
html.light .gradient-mesh::after { opacity: 0.4; }

html.light .nav {
  background: rgba(240,242,248,0.85);
  border-bottom-color: rgba(0,0,0,0.09);
}

html.light .glass-card {
  background: rgba(255,255,255,0.7);
  border-color: rgba(0,0,0,0.08);
  box-shadow: 0 4px 24px rgba(0,0,0,0.08), 0 1px 0 rgba(255,255,255,0.9) inset;
}

html.light .nav-pill {
  background: rgba(0,0,0,0.05);
  border-color: rgba(0,0,0,0.1);
}

html.light ::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.15); }
html.light ::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.25); }

/* Theme toggle button */
.btn-theme {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.2s;
  flex-shrink: 0;
}

.btn-theme:hover {
  background: var(--surface-2);
  color: var(--text-1);
  border-color: var(--border-2);
  transform: rotate(18deg) scale(1.08);
}

.btn-theme svg { width: 15px; height: 15px; }
