/* ============================================
   FLASHR SHARED LAYOUT
   Navigation, Header, Footer
   ============================================ */

/* === NAVIGATION BAR === */
/* Prevent layout "chunking": hide until shared-layout.js finishes injecting nav/footer/wrapper */
html.flashr-preload body {
  visibility: hidden;
}

.flashr-nav {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  /* Keep nav above page-level fixed/sticky headers, but below full-screen modals (usually 10000+) */
  z-index: 9000;
  /* Nav background is rendered via ::before so we can fully block "bleed through" artifacts */
  background: transparent;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-color);
  height: calc(70px + env(safe-area-inset-top));
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  isolation: isolate; /* ensure the overlay paints above page content */
  overflow: hidden; /* prevent active-link glows/underlines from bleeding outside the nav */
}

/* Opaque overlay to prevent underlying headers/highlights from bleeding through */
.flashr-nav::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 10, 0.985);
  pointer-events: none;
  z-index: -1;
}

.flashr-nav-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-6);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

/* Logo */
.flashr-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  transition: all var(--transition-base);
  flex: 0 0 auto;
}

.flashr-logo:hover {
  transform: scale(1.05);
}

.flashr-logo-image {
  width: 34px;
  height: 34px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 8px 22px rgba(251, 191, 36, 0.28));
}

.flashr-logo-text {
  background: linear-gradient(135deg, #fbbf24, #fcd34d, #6b7280);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Navigation Links */
.flashr-nav-links {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1 1 auto;
  min-width: 0;
  /* Keep links safely separated from the logo (prevents "Dashboard" sliding under FLASHR) */
  justify-content: flex-start;
  margin-left: var(--space-6);
  margin-right: var(--space-6);
}

.flashr-nav-link {
  /* Slightly tighter so all tabs fit on common desktop widths (1366px) */
  padding: 10px 10px;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: var(--font-weight-medium);
  border-radius: var(--border-radius-md);
  transition: all var(--transition-base);
  position: relative;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  line-height: 1.5;
  white-space: nowrap;
}

.flashr-nav-link:hover {
  color: var(--color-text-primary);
  background: rgba(255, 255, 255, 0.05);
}

.flashr-nav-link.active {
  color: var(--color-yellow-bright);
  background: rgba(251, 191, 36, 0.1);
}

.flashr-nav-link.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 30px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--color-yellow-bright), transparent);
}

/* Wallet Connection */
.flashr-wallet-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-5);
  background: linear-gradient(135deg, var(--color-yellow-bright), var(--color-yellow-mid));
  color: #000;
  font-weight: var(--font-weight-semibold);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: all var(--transition-base);
  box-shadow: var(--elevation-2);
}

.flashr-wallet-btn:hover {
  box-shadow: var(--elevation-3), var(--glow-yellow);
  transform: translateY(-2px);
}

.flashr-wallet-connected {
  background: rgba(16, 185, 129, 0.2);
  border: 1px solid var(--color-success);
  color: var(--color-success);
}

.flashr-wallet-connected:hover {
  background: rgba(16, 185, 129, 0.3);
  box-shadow: var(--elevation-2), var(--glow-success);
}

/* Show full "Connect Wallet" on wider screens, just "Connect" on phones. */
.wallet-btn-label-short { display: none; }
@media (max-width: 640px) {
  .wallet-btn-label-full { display: none; }
  .wallet-btn-label-short { display: inline; }
}

/* Mobile Menu Toggle */
.flashr-mobile-toggle {
  display: none;
  background: none;
  border: none;
  color: var(--color-text-primary);
  font-size: 1.5rem;
  cursor: pointer;
  padding: var(--space-2);
}

/* === PAGE CONTENT === */
.flashr-page {
  min-height: 100vh;
  padding-top: calc(70px + env(safe-area-inset-top)); /* Nav height + iOS status bar */
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--color-bg-primary);
}

.flashr-page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: var(--space-5) var(--space-6) var(--space-8);
}

/* Reduce wrapper side padding on mobile so cards aren't squeezed
   into a narrow column with empty bands left and right. */
@media (max-width: 720px) {
  .flashr-page-content {
    padding: var(--space-3) var(--space-3) var(--space-6);
  }
}
@media (max-width: 420px) {
  .flashr-page-content {
    padding: var(--space-3) var(--space-2) var(--space-5);
  }
}

/* Hero Section */
.flashr-hero {
  padding: var(--space-16) 0;
  text-align: center;
}

.flashr-hero-title {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-6);
  color: var(--color-text-primary);
  text-shadow: 0 0 24px rgba(96, 165, 250, 0.25);
  line-height: 1.2;
}

.flashr-hero-subtitle {
  font-size: var(--font-size-lg);
  color: var(--color-text-secondary);
  max-width: 600px;
  margin: 0 auto var(--space-8);
  line-height: 1.6;
}

/* === FOOTER === */
.flashr-footer {
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-color);
  padding: calc(var(--space-12) + var(--space-6)) 0 calc(var(--space-6) + var(--space-1));
  margin-top: calc(var(--space-16) + var(--space-6));
}

.flashr-footer-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.flashr-footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: var(--space-8);
  margin-top: var(--space-4);
  margin-bottom: var(--space-8);
}

.flashr-footer-brand {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.flashr-footer-logo {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  margin-bottom: var(--space-2);
}

.flashr-footer-logo-image {
  width: 34px;
  height: 34px;
  display: block;
  flex-shrink: 0;
  object-fit: contain;
  filter: drop-shadow(0 8px 22px rgba(251, 191, 36, 0.28));
}

.flashr-footer-description {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  line-height: 1.6;
  max-width: 320px;
}

.flashr-footer-section h4 {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-4);
  color: var(--color-text-primary);
}

.flashr-footer-links {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.flashr-footer-link {
  color: var(--color-text-muted);
  text-decoration: none;
  font-size: var(--font-size-sm);
  transition: color var(--transition-base);
}

.flashr-footer-link:hover {
  color: var(--color-yellow-bright);
}

.flashr-footer-bottom {
  padding-top: var(--space-8);
  padding-bottom: var(--space-4);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  flex-wrap: wrap;
  align-items: center;
  text-align: center;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

.flashr-footer-meta {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

.flashr-footer-legal {
  display: flex;
  gap: var(--space-4);
  flex-wrap: wrap;
  justify-content: center;
}

.flashr-footer-legal-link {
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  text-decoration: none;
  transition: all var(--transition-base);
}

.flashr-footer-legal-link:hover {
  color: var(--color-yellow-bright);
}

/* === RESPONSIVE === */
/* Mid breakpoint: tighten nav so links don't collide with the logo */
@media (max-width: 1280px) {
  .flashr-nav-container {
    padding: 0 var(--space-4);
  }
  .flashr-nav-links {
    gap: var(--space-1);
  }
  .flashr-nav-link {
    font-size: 0.92rem;
    padding: 10px 10px;
  }
  .flashr-wallet-btn {
    padding: 10px 12px;
    font-size: 0.9rem;
  }
}

/* If the window is still too tight, switch to mobile menu earlier (prevents overlap) */
@media (max-width: 1120px) {
  .flashr-nav-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: rgba(9, 9, 11, 0.97);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
    justify-content: flex-start;
  }

  .flashr-nav-links.mobile-open {
    display: flex;
  }

  .flashr-mobile-toggle {
    display: block;
  }
}

@media (max-width: 1024px) {
  .flashr-nav-links {
    display: none;
    position: absolute;
    top: 70px;
    left: 0;
    right: 0;
    background: rgba(9, 9, 11, 0.97);
    backdrop-filter: blur(20px);
    flex-direction: column;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-color);
  }
  
  .flashr-nav-links.mobile-open {
    display: flex;
  }
  
  .flashr-mobile-toggle {
    display: block;
  }
  
  .flashr-footer-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .flashr-nav-container {
    padding: 0 var(--space-3);
    gap: var(--space-2);
  }

  .flashr-logo {
    font-size: var(--font-size-lg);
    gap: var(--space-2);
    min-width: 0;
  }

  .flashr-logo-image,
  .flashr-footer-logo-image {
    width: 30px;
    height: 30px;
  }

  /* Shrink the theme toggle so it stops crowding the wallet button. */
  .theme-toggle {
    padding: 3px !important;
  }
  .theme-toggle-option {
    padding: 4px 8px !important;
    font-size: 0.72rem !important;
  }

  .flashr-wallet-btn {
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-sm);
    white-space: nowrap;
    flex-shrink: 0;
  }

  .flashr-hero {
    padding: var(--space-12) 0;
  }

  .flashr-hero-title {
    font-size: var(--font-size-2xl);
  }

  .flashr-hero-subtitle {
    font-size: var(--font-size-base);
  }

  /* === Compact mobile footer ===
     Centered, smaller, dense. Brand on top, two link columns below
     centered as a pair, then meta + legal as inline wrapped rows. */
  .flashr-footer {
    padding: var(--space-6) 0 var(--space-3);
    margin-top: var(--space-6);
    text-align: center;
  }
  .flashr-footer-container {
    padding: 0 var(--space-3);
  }
  .flashr-footer-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3) var(--space-2);
    margin-top: 0;
    margin-bottom: var(--space-3);
    justify-items: center;
  }
  .flashr-footer-brand {
    grid-column: 1 / -1;
    order: 2;
    align-items: center;
    text-align: center;
    gap: var(--space-1);
    margin-top: var(--space-1);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-color);
  }
  .flashr-footer-logo {
    justify-content: center;
    margin-bottom: 0;
    font-size: var(--font-size-base);
    gap: var(--space-2);
  }
  .flashr-footer-logo-image {
    width: 24px;
    height: 24px;
  }
  .flashr-footer-description {
    font-size: 0.74rem;
    line-height: 1.45;
    max-width: 280px;
    margin: 0 auto;
  }
  .flashr-footer-section {
    text-align: center;
  }
  .flashr-footer-section h4 {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: var(--space-2);
    color: var(--color-text-muted);
  }
  .flashr-footer-links {
    gap: 6px;
    align-items: center;
  }
  .flashr-footer-link,
  .flashr-footer-legal-link {
    font-size: 0.78rem;
  }

  .flashr-footer-bottom {
    flex-direction: column;
    gap: var(--space-2);
    padding-top: var(--space-3);
    padding-bottom: 0;
    text-align: center;
    font-size: 0.72rem;
  }

  /* Meta + legal as centered inline wrapped rows, not stacked column. */
  .flashr-footer-meta,
  .flashr-footer-legal {
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-2) var(--space-3);
    justify-content: center;
  }
  .flashr-footer-meta { font-size: 0.7rem; }
}

/* Very small phones: hide the FLASHR wordmark next to the logo so the
   nav has room for the theme toggle + Connect button without clipping. */
@media (max-width: 420px) {
  .flashr-logo-text { display: none; }
  .flashr-nav-container { padding: 0 10px; gap: 8px; }
  .flashr-wallet-btn { padding: var(--space-2); font-size: 0.8rem; }
}

/* Keep the 3 sections side-by-side even on small phones —
   just tighten typography so they fit the narrow viewport. */
@media (max-width: 420px) {
  .flashr-footer-container { padding: 0 var(--space-2); }
  .flashr-footer-grid { gap: var(--space-3) 6px; }
  .flashr-footer-section h4 { font-size: 0.66rem; }
  .flashr-footer-link,
  .flashr-footer-legal-link { font-size: 0.72rem; }
}

/* === UTILITY CLASSES === */
.flashr-badge {
  display: inline-flex;
  align-items: center;
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--border-radius-full);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.flashr-badge-yellow {
  background: rgba(251, 191, 36, 0.2);
  color: var(--color-yellow-bright);
  border: 1px solid rgba(251, 191, 36, 0.3);
}

.flashr-badge-success {
  background: rgba(16, 185, 129, 0.2);
  color: var(--color-success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.flashr-badge-danger {
  background: rgba(239, 68, 68, 0.2);
  color: var(--color-danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Loading State */
.flashr-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-12);
  color: var(--color-text-muted);
}

.flashr-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(251, 191, 36, 0.2);
  border-top-color: var(--color-yellow-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* === THEME TOGGLE === */
.theme-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius-full);
  padding: 3px;
  cursor: pointer;
  gap: 2px;
  transition: border-color var(--transition-base);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: rgba(251, 191, 36, 0.4);
}

.theme-toggle-option {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 28px;
  border-radius: var(--border-radius-full);
  padding: 0 var(--space-2);
  font-size: 11px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  transition: background var(--transition-fast);
  color: var(--color-text-muted);
}

.theme-toggle-option.active {
  background: rgba(251, 191, 36, 0.15);
  color: var(--color-yellow-bright);
}

[data-theme="light"] .theme-toggle {
  background: rgba(244, 244, 245, 0.9);
  border-color: rgba(228, 228, 231, 0.9);
}

[data-theme="light"] .theme-toggle-option.active {
  background: rgba(251, 191, 36, 0.2);
}
