/**
 * City Template - Main Stylesheet
 * 
 * Mobile-first, performance-optimized CSS for city landing pages
 * 
 * @package HelpBix
 * @subpackage CityTemplate
 * @version 1.0.0
 */

/* ==========================================================================
   CSS Custom Properties (CSS Variables)
   ========================================================================== */

:root {
  /* Color system - can be overridden by theme-specific variables */
  --city-primary-color: #667eea;
  --city-secondary-color: #764ba2;
  --city-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --city-accent-color: #f8f9fa;
  --city-text-overlay: #ffffff;
  --city-trust-score-bg: #667eea;
  
  /* Semantic colors */
  --color-success: #27AE60;
  --color-warning: #F39C12;
  --color-danger: #E74C3C;
  --color-info: #3498DB;
  
  /* Typography */
  --font-family-base: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  --font-family-heading: var(--font-family-base);
  --font-size-base: 1rem;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  --line-height-base: 1.5;
  --line-height-tight: 1.25;
  
  /* Spacing system (8px grid) */
  --space-1: 0.25rem;  /* 4px */
  --space-2: 0.5rem;   /* 8px */
  --space-3: 0.75rem;  /* 12px */
  --space-4: 1rem;     /* 16px */
  --space-5: 1.25rem;  /* 20px */
  --space-6: 1.5rem;   /* 24px */
  --space-8: 2rem;     /* 32px */
  --space-10: 2.5rem;  /* 40px */
  --space-12: 3rem;    /* 48px */
  --space-16: 4rem;    /* 64px */
  
  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-full: 50px;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
  --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
  --shadow-xl: 0 20px 25px rgba(0, 0, 0, 0.1);
  
  /* Transitions */
  --transition-fast: 0.15s ease-out;
  --transition-base: 0.2s ease-out;
  --transition-slow: 0.3s ease-out;
  
  /* Z-index scale */
  --z-dropdown: 1000;
  --z-sticky: 1020;
  --z-fixed: 1030;
  --z-modal-backdrop: 1040;
  --z-modal: 1050;
  --z-popover: 1060;
  --z-tooltip: 1070;
  
  /* Breakpoints (for use in calc() functions) */
  --breakpoint-sm: 480px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1200px;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

/* City template specific container reset */
.city-template-main {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: #212529;
  background: #ffffff;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

.city-template-main * {
  margin: 0;
  padding: 0;
}

.city-template-main img {
  max-width: 100%;
  height: auto;
}

.city-template-main a {
  color: inherit;
  text-decoration: none;
}

.city-template-main button {
  border: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

.city-template-main ul,
.city-template-main ol {
  list-style: none;
}

/* ==========================================================================
   Typography Scale
   ========================================================================== */

.city-template-main h1,
.city-template-main h2,
.city-template-main h3,
.city-template-main h4,
.city-template-main h5,
.city-template-main h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  color: #212529;
  margin: 0;
}

.city-template-main h1 { font-size: 2.5rem; }
.city-template-main h2 { font-size: 2rem; }
.city-template-main h3 { font-size: 1.5rem; }
.city-template-main h4 { font-size: 1.25rem; }
.city-template-main h5 { font-size: 1.125rem; }
.city-template-main h6 { font-size: 1rem; }

.city-template-main p {
  margin: 0;
  line-height: var(--line-height-base);
}

.city-template-main small {
  font-size: 0.875rem;
}

/* ==========================================================================
   Layout Utilities
   ========================================================================== */

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.section {
  padding: var(--space-12) 0;
}

.section--sm {
  padding: var(--space-8) 0;
}

.section--lg {
  padding: var(--space-16) 0;
}

/* Flex utilities */
.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-2 {
  gap: var(--space-2);
}

.gap-4 {
  gap: var(--space-4);
}

/* ==========================================================================
   Component Base Classes
   ========================================================================== */

/* Button base */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
  text-align: center;
  text-decoration: none;
  transition: all var(--transition-base);
  border: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  min-height: 44px; /* Minimum touch target */
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--city-primary-color);
  color: white;
  border-color: var(--city-primary-color);
}

.btn--primary:hover,
.btn--primary:focus {
  background: var(--city-secondary-color);
  border-color: var(--city-secondary-color);
  color: white;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.btn--secondary {
  background: transparent;
  color: var(--city-primary-color);
  border-color: var(--city-primary-color);
}

.btn--secondary:hover,
.btn--secondary:focus {
  background: var(--city-primary-color);
  color: white;
  transform: translateY(-1px);
}

.btn--sm {
  padding: var(--space-2) var(--space-4);
  font-size: 0.8125rem;
  min-height: 36px;
}

.btn--lg {
  padding: var(--space-4) var(--space-8);
  font-size: 1rem;
  min-height: 52px;
}

/* Card base */
.card {
  background: white;
  border: 2px solid #e9ecef;
  border-radius: var(--radius-xl);
  padding: var(--space-6);
  transition: all var(--transition-slow);
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--city-gradient);
  opacity: 0;
  transition: opacity var(--transition-slow);
  z-index: 1;
}

.card:hover::before {
  opacity: 0.03;
}

.card:hover {
  border-color: var(--city-primary-color);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.12);
}

.card__content {
  position: relative;
  z-index: 2;
}

/* Badge component */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: 0.75rem;
  font-weight: var(--font-weight-semibold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.025em;
  border: 1px solid;
}

.badge--success {
  background: #d4edda;
  color: #155724;
  border-color: #c3e6cb;
}

.badge--warning {
  background: #fff3cd;
  color: #856404;
  border-color: #ffeaa7;
}

.badge--danger {
  background: #f8d7da;
  color: #721c24;
  border-color: #f5c6cb;
}

.badge--info {
  background: #d1ecf1;
  color: #0c5460;
  border-color: #bee5eb;
}

/* ==========================================================================
   Trust Score Component
   ========================================================================== */

.trust-score {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: rgba(39, 174, 96, 0.1);
  border: 1px solid rgba(39, 174, 96, 0.2);
  border-radius: var(--radius-lg);
  font-size: 0.875rem;
  font-weight: var(--font-weight-semibold);
}

.trust-score--excellent {
  background: rgba(39, 174, 96, 0.1);
  border-color: rgba(39, 174, 96, 0.2);
  color: #27AE60;
}

.trust-score--good {
  background: rgba(243, 156, 18, 0.1);
  border-color: rgba(243, 156, 18, 0.2);
  color: #F39C12;
}

.trust-score--average {
  background: rgba(230, 126, 34, 0.1);
  border-color: rgba(230, 126, 34, 0.2);
  color: #E67E22;
}

.trust-score--poor {
  background: rgba(231, 76, 60, 0.1);
  border-color: rgba(231, 76, 60, 0.2);
  color: #E74C3C;
}

.trust-score__value {
  font-size: 1rem;
  font-weight: var(--font-weight-bold);
}

.trust-score__icon {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Scroll Container Component
   ========================================================================== */

.scroll-container {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  scroll-behavior: smooth;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
}

.scroll-container::-webkit-scrollbar {
  display: none;
}

.scroll-grid {
  display: flex;
  gap: var(--space-4);
  padding: var(--space-2);
  min-width: min-content;
}

.scroll-item {
  flex-shrink: 0;
  scroll-snap-align: start;
}

/* ==========================================================================
   Loading States
   ========================================================================== */

.loading-skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--city-primary-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   Animation Utilities
   ========================================================================== */

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

.slide-up {
  animation: slideUp 0.6s ease-out;
}

.slide-in-left {
  animation: slideInLeft 0.5s ease-out;
}

.stagger-children > * {
  animation-delay: calc(var(--stagger-delay, 0.1s) * var(--index, 0));
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ==========================================================================
   Responsive Design - Mobile First
   ========================================================================== */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
  .container {
    padding: 0 var(--space-6);
  }
  
  .city-template-main h1 { font-size: 3rem; }
  .city-template-main h2 { font-size: 2.25rem; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
  .container {
    padding: 0 var(--space-8);
  }
  
  .section {
    padding: var(--space-16) 0;
  }
  
  /* Desktop-specific styles */
  .scroll-container {
    padding-bottom: 0;
  }
  
  .btn {
    min-height: 40px;
  }
  
  .btn--sm {
    min-height: 32px;
  }
  
  .btn--lg {
    min-height: 48px;
  }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
  .city-template-main h1 { font-size: 3.5rem; }
  .city-template-main h2 { font-size: 2.5rem; }
  
  .scroll-grid {
    gap: var(--space-6);
  }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
  .container {
    padding: 0 var(--space-4);
  }
}

/* ==========================================================================
   Accessibility
   ========================================================================== */

/* Focus styles */
.city-template-main *:focus {
  outline: 2px solid var(--city-primary-color);
  outline-offset: 2px;
}

.city-template-main *:focus:not(:focus-visible) {
  outline: none;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .card {
    border-width: 3px;
  }
  
  .btn {
    border-width: 3px;
  }
  
  .badge {
    border-width: 2px;
  }
  
  .trust-score {
    border-width: 2px;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  
  .scroll-container {
    scroll-behavior: auto;
  }
  
  .card:hover,
  .btn:hover,
  .btn:focus {
    transform: none;
  }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
  .city-template-main {
    background: white !important;
    color: black !important;
  }
  
  .btn,
  .scroll-indicator,
  .badge--new {
    display: none !important;
  }
  
  .card {
    border: 1px solid #ccc !important;
    box-shadow: none !important;
    break-inside: avoid;
  }
  
  .scroll-container {
    overflow: visible !important;
  }
  
  .scroll-grid {
    flex-wrap: wrap;
  }
}

/* ==========================================================================
   Performance Optimizations
   ========================================================================== */

/* GPU acceleration for animations */
.card,
.btn,
.scroll-container {
  will-change: transform;
}

/* Contain layout for better performance */
.city-template-main {
  contain: layout style paint;
}

.card {
  contain: layout paint;
}

/* Content visibility for off-screen content */
.scroll-item:not(.visible) {
  content-visibility: auto;
  contain-intrinsic-size: 300px;
}

/* ==========================================================================
   Dark Mode Support (Optional)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .city-template-main {
    --color-bg: #1a1a1a;
    --color-text: #ffffff;
    --color-border: #333333;
  }
  
  /* Only apply if explicitly enabled */
  .city-template-main.dark-mode {
    background: var(--color-bg);
    color: var(--color-text);
  }
  
  .city-template-main.dark-mode .card {
    background: #2a2a2a;
    border-color: var(--color-border);
  }
}