/* assets/styles.css */
:root { 
  --font-sans: 'Heebo','Rubik','system-ui','Segoe UI','Arial';
  --primary: #6aa9e8;
  --primary-50: #f0f7fe;
  --primary-100: #dcedfb;
  --primary-200: #bedcf8;
  --primary-300: #98c8f3;
  --primary-400: #6aa9e8;
  --primary-500: #458bd2;
  --primary-600: #3570b0;
  --primary-700: #2d5a8d;
  --primary-800: #274b73;
  --primary-900: #203d5e;
}

html, body { height: 100%; }
body { font-family: var(--font-sans); }

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

.sr-only:focus {
  position: static;
  width: auto;
  height: auto;
  padding: inherit;
  margin: inherit;
  overflow: visible;
  clip: auto;
  white-space: normal;
}

/* Focus Management */
*:focus {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

*:focus:not(:focus-visible) {
  outline: none;
}

*:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  :root {
    --primary: #0066cc;
    --primary-600: #004499;
  }
  
  .bg-primary {
    background-color: #0066cc !important;
  }
  
  .text-primary-600 {
    color: #004499 !important;
  }
}

/* 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;
  }
}

/* Primary color utility classes */
.bg-primary { background-color: var(--primary); }
.text-primary { color: var(--primary); }
.text-primary-600 { color: var(--primary-600); }
.hover\:text-primary-600:hover { color: var(--primary-600); }

/* RTL/LTR helpers */
[dir="ltr"] .rtl-hidden { display:none }
[dir="rtl"] .ltr-hidden { display:none }

/* Language-specific font optimization */
[lang="he"] body { font-family: 'Heebo','system-ui','Segoe UI','Arial', sans-serif; }
[lang="en"] body { font-family: 'Rubik','system-ui','Segoe UI','Arial', sans-serif; }

/* Smooth gradients */
.bg-hero {
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(160,231,229,.35), transparent 60%),
    linear-gradient(180deg, #f7fbff 0%, #eaf4ff 100%);
}

/* Form message styling */
.bg-green-100 { background-color: #dcfce7; }
.border-green-400 { border-color: #4ade80; }
.text-green-700 { color: #15803d; }
.bg-red-100 { background-color: #fee2e2; }
.border-red-400 { border-color: #f87171; }
.text-red-700 { color: #b91c1c; }

/* Navigation button colors */
.bg-blue-500 { background-color: #3b82f6; }
.bg-blue-600 { background-color: #2563eb; }
.bg-red-500 { background-color: #ef4444; }
.bg-red-600 { background-color: #dc2626; }

/* Hidden utility */
.hidden { display: none !important; }

/* Honeypot fields - Bot protection */
.honeypot-container {
  position: absolute;
  left: -9999px;
  opacity: 0;
  pointer-events: none;
}

.honeypot-field {
  display: none !important;
}

/* Pinterest-style Masonry Gallery */
.masonry-gallery {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  padding: 1rem 0;
}

/* Mobile: Show only 6 images (3 per row, 2 rows) */
@media (max-width: 639px) {
  .masonry-gallery {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(2, auto);
  }
  
  /* Hide images beyond the first 6 on mobile */
  .gallery-item:nth-child(n+7) {
    display: none;
  }
}

@media (min-width: 640px) {
  .masonry-gallery {
    columns: 2;
    display: block;
  }
  
  /* Show all images on larger screens */
  .gallery-item:nth-child(n+7) {
    display: block;
  }
}

@media (min-width: 768px) {
  .masonry-gallery {
    columns: 3;
    display: block;
  }
}

@media (min-width: 1024px) {
  .masonry-gallery {
    columns: 4;
    display: block;
  }
}

.gallery-item {
  break-inside: avoid;
  margin-bottom: 1rem;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  cursor: pointer;
  position: relative;
  display: flex;
  flex-direction: column;
  height: fit-content;
}

/* Mobile grid layout adjustments */
@media (max-width: 639px) {
  .gallery-item {
    margin-bottom: 0;
    width: 100%;
  }
}

.gallery-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

.gallery-item img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 1rem;
  transition: opacity 0.3s ease;
}

.gallery-item.loaded {
  height: auto;
}

.gallery-item.loaded img {
  opacity: 1;
  width: 100%;
  height: auto;
  display: block;
}

/* Image placeholder and loading states */
.image-placeholder {
  width: 100%;
  min-height: 150px;
  aspect-ratio: 4/3; /* Default aspect ratio, will be overridden by actual image */
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 1rem;
  position: relative;
}

.gallery-item.loaded .image-placeholder {
  display: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f3f3;
  border-top: 3px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes loading {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error state */
.gallery-item.error .image-placeholder {
  background: #fee2e2;
  color: #dc2626;
  font-size: 0.875rem;
  text-align: center;
  padding: 1rem;
}

.gallery-item.error .loading-spinner {
  display: none;
}

/* Modal/Lightbox styles */
.gallery-modal {
  animation: fadeIn 0.3s ease-out;
}

.gallery-modal img {
  animation: zoomIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes zoomIn {
  from { 
    opacity: 0;
    transform: scale(0.8);
  }
  to { 
    opacity: 1;
    transform: scale(1);
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .gallery-item {
    transition: none;
  }
  
  .gallery-item:hover {
    transform: none;
  }
  
  .image-placeholder {
    animation: none;
  }
  
  .loading-spinner {
    animation: none;
  }
  
  .gallery-modal {
    animation: none;
  }
  
  .gallery-modal img {
    animation: none;
  }
}
