/* ── Google Fonts ────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;800;900&family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* ── CSS Variables ───────────────────────────────────────────────────────────── */
:root {
  --bg:       #06000f;
  --bg2:      #0c0118;
  --surface:  #110820;
  --surface2: #1a0f2e;
  --primary:  #7B2FBE;
  --primary-dark: #5a1f96;
  --primary-light: #9b4fd8;
  --accent:   #E056FD;
  --accent2:  #c930f0;
  --text:     #E8E0F0;
  --muted:    #8878a0;
  --subtle:   #4a3a60;
  --card:     rgba(123, 47, 190, 0.10);
  --card-border: rgba(123, 47, 190, 0.25);
  --glow:     rgba(224, 86, 253, 0.35);
  --glow-primary: rgba(123, 47, 190, 0.4);
  --danger:   #f04060;
  --success:  #34d399;
  --warning:  #fbbf24;

  --radius-sm:  6px;
  --radius:     12px;
  --radius-lg:  20px;
  --radius-xl:  32px;

  --font-heading: 'Orbitron', 'Space Grotesk', sans-serif;
  --font-body:    'Space Grotesk', sans-serif;

  --transition: 200ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);

  --z-nav:    100;
  --z-modal:  200;
  --z-toast:  300;
}

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

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  font-size: 16px;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

img, video { max-width: 100%; display: block; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
ul, ol { list-style: none; }

/* ── Typography ──────────────────────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
}

h1 { font-size: clamp(2rem, 5vw, 3.5rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.5rem); }
h3 { font-size: clamp(1.15rem, 2.5vw, 1.5rem); }
h4 { font-size: 1.125rem; }

p { max-width: 68ch; line-height: 1.7; }

.font-mono { font-family: 'JetBrains Mono', 'Courier New', monospace; }
.text-muted { color: var(--muted); }
.text-accent { color: var(--accent); }
.text-primary { color: var(--primary-light); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.uppercase { text-transform: uppercase; letter-spacing: 0.1em; }

/* ── Scrollbar ───────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ── Starfield Canvas (global bg) ────────────────────────────────────────────── */
#starfield-canvas {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  width: 100%;
  height: 100%;
}

/* ── Navigation ──────────────────────────────────────────────────────────────── */
.nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: var(--z-nav);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(1rem, 4vw, 3rem);
  height: 68px;
  background: rgba(6, 0, 15, 0.7);
  backdrop-filter: blur(20px) saturate(1.5);
  -webkit-backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid rgba(123, 47, 190, 0.2);
  transition: background var(--transition);
}

.nav-logo {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  white-space: nowrap;
}

.nav-logo-img {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex-shrink: 0;
  /* img doesn't inherit text-fill, so reset */
  -webkit-text-fill-color: initial;
}

.nav-logo:hover { opacity: 0.85; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-link {
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
  transition: color var(--transition), background var(--transition);
  cursor: pointer;
}

.nav-link:hover { color: var(--text); background: rgba(123, 47, 190, 0.15); }
.nav-link.active { color: var(--accent); }

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #fff;
  font-family: var(--font-heading);
}

/* ── Buttons ─────────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1.4rem;
  border-radius: var(--radius);
  font-family: var(--font-heading);
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  box-shadow: 0 0 20px var(--glow-primary);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 0 32px var(--glow), 0 4px 16px rgba(0,0,0,0.3);
}

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

.btn-ghost {
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  backdrop-filter: blur(10px);
}

.btn-ghost:hover {
  background: rgba(123, 47, 190, 0.2);
  border-color: var(--primary);
  color: var(--accent);
}

.btn-danger {
  background: rgba(240, 64, 96, 0.15);
  border: 1px solid rgba(240, 64, 96, 0.4);
  color: var(--danger);
}

.btn-danger:hover {
  background: rgba(240, 64, 96, 0.25);
  border-color: var(--danger);
  box-shadow: 0 0 16px rgba(240, 64, 96, 0.3);
}

.btn-sm { padding: 0.35rem 0.85rem; font-size: 0.75rem; }
.btn-lg { padding: 0.85rem 2rem; font-size: 0.95rem; }
.btn-icon { padding: 0.5rem; border-radius: var(--radius-sm); }

/* ── Cards ───────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.card:hover {
  border-color: rgba(123, 47, 190, 0.5);
  box-shadow: 0 0 24px rgba(123, 47, 190, 0.15);
}

.card-glow {
  box-shadow: 0 0 30px rgba(224, 86, 253, 0.12), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* ── Forms ───────────────────────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}

.form-label .required { color: var(--accent); margin-left: 2px; }

.form-control {
  background: rgba(17, 8, 32, 0.8);
  border: 1px solid rgba(123, 47, 190, 0.3);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  color: var(--text);
  font-size: 1rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
  min-height: 48px;
}

.form-control::placeholder { color: var(--subtle); }

.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(123, 47, 190, 0.2);
}

.form-control:focus-visible { outline: none; }

textarea.form-control {
  resize: vertical;
  min-height: 80px;
  line-height: 1.6;
}

.form-helper { font-size: 0.8rem; color: var(--muted); }
.form-error  { font-size: 0.8rem; color: var(--danger); }

/* ── Flash Messages ──────────────────────────────────────────────────────────── */
.flash-container {
  position: fixed;
  top: 80px;
  right: 1.5rem;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 380px;
}

.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  font-size: 0.9rem;
  font-weight: 500;
  animation: flashIn 0.3s ease forwards;
  border: 1px solid;
}

.flash-error {
  background: rgba(240, 64, 96, 0.15);
  border-color: rgba(240, 64, 96, 0.4);
  color: #ff8fa0;
}

.flash-success {
  background: rgba(52, 211, 153, 0.12);
  border-color: rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}

.flash-info {
  background: rgba(123, 47, 190, 0.15);
  border-color: var(--card-border);
  color: var(--accent);
}

@keyframes flashIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Layout Utilities ────────────────────────────────────────────────────────── */
.page-wrapper {
  padding-top: 68px;
  min-height: 100dvh;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(1rem, 4vw, 2.5rem);
}

.container-sm { max-width: 640px; }
.container-md { max-width: 800px; }

.section { padding: clamp(3rem, 8vw, 6rem) 0; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.w-full { width: 100%; }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mb-8 { margin-bottom: 2rem; }

/* ── Divider ─────────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--card-border), transparent);
  margin: 2rem 0;
}

/* ── Badges ──────────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.badge-primary  { background: rgba(123,47,190,0.2);  color: var(--primary-light); border: 1px solid rgba(123,47,190,0.35); }
.badge-accent   { background: rgba(224,86,253,0.15); color: var(--accent);        border: 1px solid rgba(224,86,253,0.3); }
.badge-success  { background: rgba(52,211,153,0.12); color: var(--success);       border: 1px solid rgba(52,211,153,0.3); }
.badge-danger   { background: rgba(240,64,96,0.12);  color: var(--danger);        border: 1px solid rgba(240,64,96,0.3); }
.badge-muted    { background: rgba(136,120,160,0.15); color: var(--muted);        border: 1px solid rgba(136,120,160,0.25); }

/* ── Animations ──────────────────────────────────────────────────────────────── */
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px var(--glow-primary); }
  50%       { box-shadow: 0 0 40px var(--glow), 0 0 60px var(--glow-primary); }
}

@keyframes accent-pulse {
  0%, 100% { text-shadow: 0 0 10px var(--glow); }
  50%       { text-shadow: 0 0 25px var(--glow), 0 0 40px rgba(224,86,253,0.4); }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-8px); }
}

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

@keyframes nebula-rotate {
  to { transform: rotate(360deg) scale(1.1); }
}

@keyframes scan-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

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

.fade-in       { animation: fade-in 0.5s ease forwards; }
.float-anim    { animation: float 4s ease-in-out infinite; }
.glow-anim     { animation: glow-pulse 2.5s ease-in-out infinite; }
.accent-glow   { animation: accent-pulse 2s ease-in-out infinite; }

/* ── Nav: divider & dashboard button ─────────────────────────────────────────── */
.nav-divider {
  width: 1px;
  height: 20px;
  background: rgba(123, 47, 190, 0.3);
  flex-shrink: 0;
  margin: 0 0.35rem;
}

.nav-dashboard-btn {
  box-shadow: 0 0 16px rgba(123, 47, 190, 0.5);
  animation: nav-db-pulse 3s ease-in-out infinite;
}

.nav-dashboard-btn:hover {
  box-shadow: 0 0 28px var(--glow), 0 4px 14px rgba(0,0,0,0.3);
  animation: none;
}

@keyframes nav-db-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(123,47,190,0.45); }
  50%       { box-shadow: 0 0 26px rgba(224,86,253,0.6), 0 0 8px rgba(123,47,190,0.3); }
}

/* ── Skip Link ───────────────────────────────────────────────────────────────── */
.skip-link {
  position: fixed;
  top: -100%;
  left: 1rem;
  z-index: 9999;
  background: var(--primary);
  color: #fff;
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-weight: 600;
  transition: top 0.2s ease;
}
.skip-link:focus { top: 1rem; }

/* ── Nav: scroll depth ───────────────────────────────────────────────────────── */
.nav--scrolled {
  background: rgba(6, 0, 15, 0.92);
  border-bottom-color: rgba(123, 47, 190, 0.35);
  box-shadow: 0 4px 32px rgba(0, 0, 0, 0.4);
}

/* ── Nav: hamburger ──────────────────────────────────────────────────────────── */
.nav-hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 40px;
  height: 40px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}
.nav-hamburger span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all var(--transition);
  transform-origin: center;
}
.nav-hamburger--open span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-hamburger--open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.nav-hamburger--open span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

@media (max-width: 768px) {
  .nav-hamburger { display: flex; }

  .nav-links {
    display: none;
    position: fixed;
    top: 68px;
    left: 0;
    right: 0;
    background: rgba(6, 0, 15, 0.97);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-bottom: 1px solid rgba(123, 47, 190, 0.3);
    flex-direction: column;
    align-items: stretch;
    padding: 1rem;
    gap: 0.25rem;
    z-index: calc(var(--z-nav) - 1);
    animation: slideDown 0.2s ease forwards;
  }
  .nav-links--open { display: flex; }

  .nav-link {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
  }

  .nav-divider {
    width: 100%;
    height: 1px;
    margin: 0.25rem 0;
  }

  .nav-dashboard-btn {
    width: 100%;
    justify-content: center;
  }

  .nav-user {
    flex-direction: column;
    align-items: stretch;
    gap: 0.25rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(123, 47, 190, 0.2);
    margin-top: 0.25rem;
  }
  .nav-user .nav-link,
  .nav-user .btn { width: 100%; justify-content: flex-start; }

  .nav-avatar { display: none; }
  .hide-mobile { display: none !important; }
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Flash: close button + fade-out ─────────────────────────────────────────── */
.flash {
  position: relative;
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.flash--out { opacity: 0; transform: translateX(20px); pointer-events: none; }

.flash-close {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  padding: 0 0.2rem;
  flex-shrink: 0;
  transition: opacity var(--transition);
}
.flash-close:hover { opacity: 1; }

/* ── Back link ───────────────────────────────────────────────────────────────── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  transition: color var(--transition), gap var(--transition);
}
.back-link:hover { color: var(--accent); gap: 0.6rem; }
.back-link::before { content: '←'; }

/* ── Scroll-to-top button ────────────────────────────────────────────────────── */
.scroll-top-btn {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: var(--z-toast);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--accent);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease, background var(--transition);
}
.scroll-top-btn--visible { opacity: 1; transform: translateY(0); pointer-events: auto; }
.scroll-top-btn:hover { background: rgba(123,47,190,0.25); border-color: var(--primary); }

@media (max-width: 768px) {
  .scroll-top-btn { bottom: 1.25rem; right: 1.25rem; }
}

/* ── Button spinner ──────────────────────────────────────────────────────────── */
.btn-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin-slow 0.7s linear infinite;
}

/* ── Reduced Motion ──────────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hide-mobile { display: none !important; }
}

@media (max-width: 480px) {
  .btn-lg { padding: 0.75rem 1.4rem; font-size: 0.85rem; }
}
