/* ============================================================
   Shelter Source Portal — Design System
   Theme: Dark hacker aesthetic matching digitalnomad.sh
   Colors: Slate #0f172a, Teal #2dd4bf, Purple #a855f7
   Font: Inter
   ============================================================ */

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

/* ---------- CSS Custom Properties ---------- */
:root {
  /* Core palette */
  --color-bg-primary: #0f172a;
  --color-bg-secondary: #1e293b;
  --color-bg-card: rgba(30, 41, 59, 0.6);
  --color-bg-glass: rgba(15, 23, 42, 0.8);

  /* Accent gradients */
  --color-teal: #2dd4bf;
  --color-teal-dark: #14b8a6;
  --color-purple: #a855f7;
  --color-purple-dark: #9333ea;
  --gradient-accent: linear-gradient(135deg, var(--color-purple), var(--color-teal));
  --gradient-accent-reverse: linear-gradient(135deg, var(--color-teal), var(--color-purple));

  /* Text */
  --color-text-primary: #e2e8f0;
  --color-text-secondary: #94a3b8;
  --color-text-muted: #64748b;

  /* Borders */
  --color-border: rgba(148, 163, 184, 0.15);
  --color-border-hover: rgba(45, 212, 191, 0.5);

  /* Shadows */
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --shadow-glow-teal: 0 0 20px rgba(45, 212, 191, 0.25);
  --shadow-glow-purple: 0 0 20px rgba(168, 85, 247, 0.25);

  /* Layout */
  --header-height: 64px;
  --sidebar-width: 300px;
  --max-width: 1400px;

  /* Transitions */
  --transition-fast: 0.2s ease;
  --transition-smooth: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html {
  height: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Carbon fiber texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(168, 85, 247, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(45, 212, 191, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

a {
  color: var(--color-teal);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-purple);
}

img {
  max-width: 100%;
  display: block;
}

/* ---------- Utilities ---------- */
.gradient-text {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ---------- Header / Navigation ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  height: var(--header-height);
  background: var(--color-bg-glass);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--color-border);
  transition: box-shadow var(--transition-smooth);
}

.site-header.scrolled {
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

.header-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.logo-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: white;
}

.logo-text {
  background: var(--gradient-accent);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Desktop nav */
.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
  list-style: none;
}

.nav-links a {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 8px;
  transition: all var(--transition-smooth);
  position: relative;
}

.nav-links a:hover {
  color: var(--color-teal);
  background: rgba(45, 212, 191, 0.08);
}

.nav-links a.active {
  color: var(--color-teal);
}

.nav-links .btn-nav {
  background: var(--gradient-accent);
  color: white !important;
  -webkit-text-fill-color: white;
  font-weight: 600;
  padding: 8px 20px;
  border-radius: 8px;
  transition: all var(--transition-smooth);
}

.nav-links .btn-nav:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-purple);
  background: var(--gradient-accent);
}

/* Mobile hamburger */
.nav-toggle {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  color: var(--color-text-primary);
}

.nav-toggle span {
  display: block;
  width: 24px;
  height: 2px;
  background: var(--color-text-primary);
  margin: 5px 0;
  border-radius: 2px;
  transition: all var(--transition-smooth);
}

.nav-toggle.open span:nth-child(1) {
  transform: rotate(45deg) translate(5px, 5px);
}
.nav-toggle.open span:nth-child(2) {
  opacity: 0;
}
.nav-toggle.open span:nth-child(3) {
  transform: rotate(-45deg) translate(5px, -5px);
}

/* ---------- Main Content Layout ---------- */
.main-content {
  flex: 1;
  position: relative;
  z-index: 1;
}

/* Landing page: map + sidebar ads */
.map-layout {
  display: grid;
  grid-template-columns: 1fr; /* Default to full width */
  gap: 0;
  height: calc(100vh - var(--header-height)); /* Default to full height below header */
  max-width: 100%;
}

.map-layout.has-sidebar {
  grid-template-columns: 1fr var(--sidebar-width);
}

body.has-top-banner .map-layout {
  height: calc(100vh - var(--header-height) - 60px); /* Adjust height if top banner is visible */
}

.map-viewport {
  position: relative;
  overflow: hidden;
  border-right: 1px solid var(--color-border);
}

.map-viewport iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.map-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg-primary);
  z-index: 5;
  transition: opacity 0.5s ease;
}

.map-loading.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-teal);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.loading-text {
  margin-top: 16px;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* ---------- Ad Slots ---------- */
.ad-banner-top {
  display: flex; /* Hidden by default; shown if ads are loaded */
  width: 100%;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
  align-items: center;
  justify-content: center;
  min-height: 60px;
  padding: 8px 24px;
  position: relative;
  z-index: 1;
}

.ad-sidebar {
  display: flex; /* Hidden by default; shown if ads are loaded */
  background: var(--color-bg-secondary);
  padding: 16px;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
}

.ad-sidebar .ad-slot {
  background: var(--color-bg-card);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  min-height: 250px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ad-placeholder {
  color: var(--color-text-muted);
  font-size: 0.75rem;
  text-align: center;
}

/* ---------- Page Container (for stub pages) ---------- */
.page-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 60px 24px 80px;
}

.page-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 8px;
  line-height: 1.1;
}

.page-subtitle {
  font-size: 1.125rem;
  color: var(--color-text-secondary);
  margin-bottom: 48px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--color-bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 32px;
  transition: all var(--transition-smooth);
}

.card:hover {
  transform: translateY(-4px);
  border-color: var(--color-border-hover);
  box-shadow: var(--shadow-card), var(--shadow-glow-teal);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--gradient-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 16px;
}

.card-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-description {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 24px;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--color-text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 0.9375rem;
  transition: all var(--transition-smooth);
  outline: none;
}

.form-input:focus {
  border-color: var(--color-teal);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.form-input::placeholder {
  color: var(--color-text-muted);
}

textarea.form-input {
  min-height: 140px;
  resize: vertical;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-smooth);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-accent);
  color: white;
}

.btn-primary:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: var(--shadow-glow-purple);
  color: white;
}

.btn-secondary {
  background: var(--color-bg-card);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
}

.btn-secondary:hover {
  border-color: var(--color-border-hover);
  color: var(--color-teal);
}

.btn-full {
  width: 100%;
}

/* ---------- Divider ---------- */
.divider {
  width: 100%;
  height: 1px;
  background: var(--color-border);
  margin: 24px 0;
}

.divider-text {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.divider-text::before,
.divider-text::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* ---------- Status Badge ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.badge-coming-soon {
  background: rgba(168, 85, 247, 0.15);
  color: var(--color-purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-active {
  background: rgba(45, 212, 191, 0.15);
  color: var(--color-teal);
  border: 1px solid rgba(45, 212, 191, 0.3);
}

/* ---------- Footer ---------- */
.site-footer {
  background: var(--color-bg-secondary);
  border-top: 1px solid var(--color-border);
  padding: 32px 24px;
  position: relative;
  z-index: 1;
}

.footer-inner {
  max-width: var(--max-width);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-text {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

.footer-links {
  display: flex;
  gap: 24px;
  list-style: none;
}

.footer-links a {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  transition: color var(--transition-fast);
}

.footer-links a:hover {
  color: var(--color-teal);
}

/* ---------- Animations ---------- */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-in {
  animation: fadeInUp 0.6s ease forwards;
}

.animate-in:nth-child(2) { animation-delay: 0.1s; }
.animate-in:nth-child(3) { animation-delay: 0.2s; }
.animate-in:nth-child(4) { animation-delay: 0.3s; }

/* ---------- Responsive ---------- */
@media (max-width: 1024px) {
  .map-layout,
  .map-layout.has-sidebar {
    grid-template-columns: 1fr;
  }

  body.has-top-banner .map-layout {
    height: calc(100vh - var(--header-height) - 50px);
  }

  .ad-sidebar {
    display: none !important;
  }

  .ad-banner-top {
    min-height: 50px;
  }

  .map-viewport {
    border-right: none;
  }
}

@media (max-width: 768px) {
  /* Mobile nav */
  .nav-links {
    display: none;
    position: fixed;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    flex-direction: column;
    align-items: stretch;
    padding: 24px;
    gap: 4px;
    z-index: 999;
  }

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

  .nav-links a {
    font-size: 1rem;
    padding: 14px 16px;
  }

  .nav-toggle {
    display: block;
  }

  .page-container {
    padding: 40px 16px 60px;
  }

  .page-title {
    font-size: 1.75rem;
  }

  .card {
    padding: 24px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    flex-direction: column;
    text-align: center;
  }
}

@media (max-width: 480px) {
  .header-inner {
    padding: 0 16px;
  }

  .logo {
    font-size: 1.1rem;
  }

  .ad-banner-top {
    display: none;
  }

  .map-layout {
    height: calc(100vh - var(--header-height));
  }
}
