/* Merlin Public — La Forge Design System
   Shared CSS for both login page (standalone) and app pages (via base.html).
   When used with base.html, Tailwind CDN handles layout utilities. */

@font-face {
  font-family: 'Geist';
  src: url('/static/fonts/Geist-Variable.woff2') format('woff2');
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #041014;
  --bg-card: #082028;
  --bg-hover: #0c2e38;
  --bg-input: #0a1a22;
  --fg: #f9fafb;
  --fg-muted: #9ca3af;
  --fg-dim: #64748b;
  --primary: #ecc234;
  --primary-hover: #f0d060;
  --primary-dark: #d4aa2d;
  --primary-glow: rgba(236, 194, 52, 0.15);
  --secondary: #295EE6;
  --secondary-hover: #3d72f5;
  --tertiary: #0e9195;
  --destructive: #ef4444;
  --success: #22c55e;
  --warning: #f59e0b;
  --border: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.2);
  --glass-bg: rgba(8, 32, 40, 0.4);
  --glass-bg-strong: rgba(8, 32, 40, 0.6);
  --glass-blur: blur(16px);
  --glass-blur-mobile: blur(8px);
  --radius: 1rem;
  --radius-lg: 1.5rem;
  --radius-sm: 0.5rem;
  --radius-btn: 0.75rem;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
  --transition: 200ms ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  color-scheme: dark;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Geist', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Animated Background (login page) ─── */
.merlin-background {
  position: fixed; inset: 0; overflow: hidden;
  pointer-events: none; z-index: 0; isolation: isolate;
  background: #031c25;
}
.merlin-background__image {
  position: absolute; inset: 0;
  background:
    radial-gradient(ellipse 140% 120% at 53% 135%, rgba(50, 165, 168, 0.6) 0%, transparent 70%),
    radial-gradient(ellipse 260% 180% at 27% -60%, rgba(50, 165, 168, 0.45) 0%, transparent 70%);
  opacity: 0.95;
}
.merlin-background__grid {
  position: absolute; inset: 0; opacity: 0.14;
  background-image:
    linear-gradient(rgba(50, 165, 168, 0.34) 1px, transparent 1px),
    linear-gradient(90deg, rgba(50, 165, 168, 0.34) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: radial-gradient(circle at 50% 42%, black 28%, transparent 92%);
  -webkit-mask-image: radial-gradient(circle at 50% 42%, black 28%, transparent 92%);
}

/* ─── Login Page ─── */
.login-container {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 1rem;
  position: relative; z-index: 1;
}
.login-card {
  backdrop-filter: var(--glass-blur-mobile); -webkit-backdrop-filter: var(--glass-blur-mobile);
  background: var(--glass-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 2.5rem;
  width: 100%; max-width: 420px;
  position: relative; z-index: 10;
  animation: fadeIn 0.6s ease-out forwards;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 40px rgba(236, 194, 52, 0.07),
    0 0 80px rgba(236, 194, 52, 0.03),
    0 24px 64px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
}
@media (min-width: 1024px) {
  .login-card {
    backdrop-filter: var(--glass-blur); -webkit-backdrop-filter: var(--glass-blur);
    background: rgba(8, 32, 40, 0.3);
  }
}
.login-forge-glow {
  position: relative; display: inline-flex;
  align-items: center; justify-content: center;
}
.login-forge-glow::before {
  content: ''; position: absolute; inset: -15%;
  border-radius: 40% 60% 55% 45% / 50% 45% 55% 50%;
  background: radial-gradient(ellipse 80% 60% at 58% 62%, rgba(236,194,52,0.32) 0%, rgba(210,90,10,0.12) 45%, transparent 70%);
  filter: blur(20px); animation: forge-pulse 3s ease-in-out infinite;
  pointer-events: none; z-index: 0;
}
.login-forge-glow img {
  position: relative; z-index: 1;
  width: auto; max-width: 70vw; height: 3.5rem; object-fit: contain;
  filter: drop-shadow(0 0 10px rgba(236,194,52,0.40)) drop-shadow(0 0 24px rgba(200,100,10,0.20));
}
@keyframes forge-pulse {
  0%, 100% { opacity: 0.60; transform: scale(0.96); }
  50%       { opacity: 1.00; transform: scale(1.05); }
}
.login-spark {
  position: absolute; width: 3px; height: 3px; border-radius: 50%;
  background: #ecc234;
  box-shadow: 0 0 5px rgba(236,194,52,0.9), 0 0 10px rgba(236,194,52,0.4);
  pointer-events: none; z-index: 2;
}
.login-spark-1 { bottom: 22%; left: 18%; animation: spark-1 2.1s ease-out 0.0s infinite; }
.login-spark-2 { bottom: 12%; left: 44%; animation: spark-2 1.8s ease-out 0.7s infinite; }
.login-spark-3 { bottom: 25%; left: 70%; animation: spark-3 2.4s ease-out 0.3s infinite; }
.login-spark-4 { bottom:  8%; left: 80%; animation: spark-4 1.6s ease-out 1.2s infinite; }
.login-spark-5 { bottom: 18%; left: 32%; animation: spark-5 2.0s ease-out 1.6s infinite; }
@keyframes spark-1 { 0% { transform: translate(0,0) scale(1); opacity: 0.9; } 100% { transform: translate(-8px,-55px) scale(0); opacity: 0; } }
@keyframes spark-2 { 0% { transform: translate(0,0) scale(1); opacity: 0.8; } 100% { transform: translate(6px,-65px) scale(0); opacity: 0; } }
@keyframes spark-3 { 0% { transform: translate(0,0) scale(1); opacity: 1; } 100% { transform: translate(-4px,-50px) scale(0); opacity: 0; } }
@keyframes spark-4 { 0% { transform: translate(0,0) scale(0.8); opacity: 0.7; } 100% { transform: translate(10px,-70px) scale(0); opacity: 0; } }
@keyframes spark-5 { 0% { transform: translate(0,0) scale(1.1); opacity: 0.9; } 100% { transform: translate(-12px,-45px) scale(0); opacity: 0; } }

.login-title { font-size: 1.5rem; font-weight: 700; text-align: center; margin-bottom: 0.25rem; color: #f5f0e8; }
.login-title-shimmer {
  background: linear-gradient(90deg, #ecc234 0%, #f0d060 50%, #ecc234 100%);
  background-size: 200% auto;
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: login-text-shimmer 0.8s ease-in-out;
}
@keyframes login-text-shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}
.login-subtitle { font-size: 0.8125rem; color: var(--fg-muted); text-align: center; margin-bottom: 1.5rem; }
.login-auth-button {
  display: flex; align-items: center; justify-content: center; gap: 0.75rem;
  width: 100%; padding: 0.75rem 1.25rem; min-height: 2.75rem;
  border-radius: 10px; font-size: 0.9375rem; font-weight: 500;
  cursor: pointer; transition: all 0.3s ease; font-family: inherit;
  color: var(--fg); border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
.login-auth-button:hover {
  transform: translateY(-1px);
  border-color: rgba(236,194,52,0.28); background: rgba(236,194,52,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08), 0 0 16px rgba(236,194,52,0.08);
}
.login-auth-button:focus-visible { outline: 2px solid rgba(236,194,52,0.35); outline-offset: 2px; }
.login-auth-button:active { transform: scale(0.98); }
.login-footer {
  border-top: 1px solid rgba(255,255,255,0.05); padding-top: 1.25rem;
  margin-top: 1.5rem; display: flex; align-items: center; justify-content: center; gap: 0.75rem;
}
.login-footer img { height: 1.75rem; width: auto; opacity: 0.8; }
.login-footer span { font-size: 0.75rem; color: rgba(255,255,255,0.5); }
.login-footer .powered-by { font-weight: 600; color: rgba(255,255,255,0.8); }

/* ─── Form Elements (shared) ─── */
.input, select, textarea {
  width: 100%; padding: 0.75rem 1rem;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius-btn); color: var(--fg);
  font-size: 1rem; font-family: inherit;
  transition: all 0.3s ease; min-height: 3rem; outline: none;
}
@media (min-width: 1024px) {
  .input, select, textarea { padding: 0.625rem 1rem; min-height: auto; background: rgba(8,32,40,0.5); }
}
.input:focus, select:focus, textarea:focus {
  border-color: rgba(236,194,52,0.6); background: rgba(8,32,40,0.7);
  box-shadow: 0 0 0 3px rgba(236,194,52,0.1), 0 0 20px rgba(236,194,52,0.1);
}
.input::placeholder { color: rgba(156,163,175,0.6); }
label { font-size: 0.75rem; font-weight: 600; color: var(--fg-muted); display: block; margin-bottom: 0.375rem; }

/* ─── Buttons (shared — used by login and base.html pages) ─── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.75rem 1.25rem; border-radius: var(--radius-btn);
  font-size: 0.9375rem; font-weight: 500; cursor: pointer; border: none;
  transition: all 0.3s ease; text-decoration: none;
  min-height: 2.75rem; white-space: nowrap;
  position: relative; overflow: hidden; font-family: inherit;
}
@media (min-width: 768px) { .btn { padding: 0.5rem 1rem; min-height: 2.5rem; font-size: 0.875rem; } }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--bg); border: 1px solid rgba(236,194,52,0.3);
  box-shadow: 0 4px 15px var(--primary-glow), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary::before {
  content: ''; position: absolute; top: 0; left: -100%; width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
  transition: left 0.5s ease;
}
.btn-primary:hover::before { left: 100%; }
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 25px rgba(236,194,52,0.35), inset 0 1px 0 rgba(255,255,255,0.3); }

.btn-glass {
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  background: var(--glass-bg-strong); border: 1px solid rgba(255,255,255,0.15); color: var(--fg);
}
.btn-glass:hover { border-color: rgba(236,194,52,0.5); background: rgba(8,32,40,0.7); box-shadow: 0 0 20px var(--primary-glow); }
.btn-glass:active { transform: scale(0.98); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.75rem; min-height: 36px; }

/* ─── Alert / Toast (shared) ─── */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius-btn);
  font-size: 0.8125rem; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem;
}
.alert-info { background: rgba(41,94,230,0.1); border: 1px solid rgba(41,94,230,0.2); color: var(--secondary); }
.alert-success { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.2); color: var(--success); }
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.2); color: var(--destructive); }
.alert-warning { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.2); color: var(--warning); }

/* ─── Minimal Utilities (for login page which doesn't have Tailwind) ─── */
.hidden { display: none !important; }
.w-full { width: 100%; }
.mt-4 { margin-top: 1rem; }

/* ─── Animations ─── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ─── Reduced Motion ─── */
@media (prefers-reduced-motion: reduce) {
  .login-forge-glow::before { animation: none !important; }
  .login-spark { animation: none !important; opacity: 0 !important; }
  .login-card { animation: none !important; }
}

/* ─── Scrollbar (shared) ─── */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(8,32,40,0.5); border-radius: 5px; }
::-webkit-scrollbar-thumb { background: rgba(14,145,149,0.3); border-radius: 5px; border: 2px solid rgba(8,32,40,0.5); }
::-webkit-scrollbar-thumb:hover { background: rgba(14,145,149,0.5); }
* { scrollbar-width: thin; scrollbar-color: rgba(14,145,149,0.3) rgba(8,32,40,0.5); }
