/* ============================================================================
   MEI-WEST ENTERPRISES - Main Stylesheet
   Production-ready professional agricultural services website
   ============================================================================ */

/* ============================================================================
   CSS CUSTOM PROPERTIES (Design System)
   ============================================================================ */

:root {
  /* Brand Colors */
  --color-dark-purple: #3B1E43;
  --color-deep-green: #1E3F20;
  --color-charcoal: #2B2C2C;
  --color-white: #FFFFFF;
  --color-light-grey: #F7F8F8;
  --color-border: #E0E0E0;
  --color-divider: rgba(43, 44, 44, 0.07);
  
  /* Semantic Colors */
  --color-primary: var(--color-dark-purple);
  --color-accent: var(--color-deep-green);
  --color-text: var(--color-charcoal);
  --color-text-light: #666666;
  --color-bg: var(--color-white);
  --color-bg-alt: var(--color-light-grey);
  
  /* Typography */
  --font-family-base: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", sans-serif;
  --font-size-base: 16px;
  --line-height-base: 1.6;
  --font-weight-normal: 400;
  --font-weight-medium: 500;
  --font-weight-semibold: 600;
  --font-weight-bold: 700;
  
  /* Spacing Scale */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;
  --spacing-2xl: 4rem;
  --spacing-3xl: 5rem;
  --spacing-4xl: 6rem;
  
  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.03);
  --shadow-md: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 8px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 8px 12px rgba(0, 0, 0, 0.06);
  
  /* Border Radius */
  --radius-sm: 2px;
  --radius-md: 4px;
  --radius-lg: 6px;
  
  /* Transitions */
  --transition-fast: 150ms ease-in-out;
  --transition-base: 250ms ease-in-out;
  --transition-slow: 350ms ease-in-out;
  
  /* Layout */
  --max-width-container: 1200px;
  --max-width-wide: 1400px;
  --breakpoint-sm: 640px;
  --breakpoint-md: 768px;
  --breakpoint-lg: 1024px;
  --breakpoint-xl: 1280px;
}

/* ============================================================================
   RESET & NORMALIZATION
   ============================================================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: var(--font-size-base);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background-color: var(--color-bg);
  overflow-x: hidden;
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */

h1, h2, h3, h4, h5, h6 {
  font-weight: var(--font-weight-bold);
  line-height: 1.2;
  margin-bottom: var(--spacing-md);
  color: var(--color-text);
}

h1 {
  font-size: 3.5rem;
  letter-spacing: -0.02em;
}

h2 {
  font-size: 2.5rem;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.875rem;
  letter-spacing: -0.01em;
}

h4 {
  font-size: 1.5rem;
}

h5 {
  font-size: 1.25rem;
}

h6 {
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: var(--font-weight-semibold);
  color: var(--color-primary);
}

p {
  margin-bottom: var(--spacing-md);
  color: var(--color-text-light);
}

p:last-child {
  margin-bottom: 0;
}

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

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

strong {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
}

/* ============================================================================
   LISTS
   ============================================================================ */

ul, ol {
  margin-bottom: var(--spacing-md);
  padding-left: 1.5rem;
}

li {
  margin-bottom: var(--spacing-sm);
}

/* ============================================================================
   IMAGES & MEDIA
   ============================================================================ */

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

video {
  max-width: 100%;
  height: auto;
  display: block;
}

/* ============================================================================
   FORMS
   ============================================================================ */

input, textarea, select {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  color: var(--color-text);
}

input, textarea, select {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--spacing-sm) var(--spacing-md);
  width: 100%;
  transition: all var(--transition-fast);
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(59, 30, 67, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

/* ============================================================================
   BUTTONS
   ============================================================================ */

.btn {
  display: inline-block;
  padding: var(--spacing-sm) var(--spacing-lg);
  font-size: 1rem;
  font-weight: var(--font-weight-semibold);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base);
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:focus {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

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

.btn-secondary {
  background-color: transparent;
  color: var(--color-primary);
  border-color: var(--color-primary);
}

.btn-secondary:hover {
  background-color: var(--color-primary);
  color: var(--color-white);
}

.btn-large {
  padding: var(--spacing-md) var(--spacing-2xl);
  font-size: 1.125rem;
}

/* ============================================================================
   LAYOUT: Container
   ============================================================================ */

.container {
  width: 100%;
  max-width: var(--max-width-container);
  margin: 0 auto;
  padding: 0 var(--spacing-lg);
}

.container-wide {
  max-width: var(--max-width-wide);
}

@media (max-width: 768px) {
  .container {
    padding: 0 var(--spacing-md);
  }
}

/* ============================================================================
   LAYOUT: Grid System
   ============================================================================ */

.grid {
  display: grid;
  gap: var(--spacing-lg);
}

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

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

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

@media (max-width: 1024px) {
  .grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .grid-2, .grid-3, .grid-4 {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   LAYOUT: Flexbox Utilities
   ============================================================================ */

.flex {
  display: flex;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-column {
  flex-direction: column;
}

.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }

/* ============================================================================
   SPACING UTILITIES
   ============================================================================ */

.mt-sm { margin-top: var(--spacing-sm); }
.mt-md { margin-top: var(--spacing-md); }
.mt-lg { margin-top: var(--spacing-lg); }
.mt-xl { margin-top: var(--spacing-xl); }
.mt-2xl { margin-top: var(--spacing-2xl); }
.mt-3xl { margin-top: var(--spacing-3xl); }

.mb-sm { margin-bottom: var(--spacing-sm); }
.mb-md { margin-bottom: var(--spacing-md); }
.mb-lg { margin-bottom: var(--spacing-lg); }
.mb-xl { margin-bottom: var(--spacing-xl); }
.mb-2xl { margin-bottom: var(--spacing-2xl); }
.mb-3xl { margin-bottom: var(--spacing-3xl); }

.py-2xl { padding-top: var(--spacing-2xl); padding-bottom: var(--spacing-2xl); }
.py-3xl { padding-top: var(--spacing-3xl); padding-bottom: var(--spacing-3xl); }
.py-4xl { padding-top: var(--spacing-4xl); padding-bottom: var(--spacing-4xl); }

/* ============================================================================
   TEXT UTILITIES
   ============================================================================ */

.text-center { text-align: center; }
.text-right { text-align: right; }

.text-sm { font-size: 0.875rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.375rem; }

.text-primary { color: var(--color-primary); }
.text-accent { color: var(--color-accent); }
.text-light { color: var(--color-text-light); }
.text-white { color: var(--color-white); }

.font-semibold { font-weight: var(--font-weight-semibold); }
.font-bold { font-weight: var(--font-weight-bold); }

.uppercase { text-transform: uppercase; }
.lowercase { text-transform: lowercase; }

/* ============================================================================
   COMPONENTS: Header & Navigation
   ============================================================================ */

header {
  background-color: var(--color-white);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow-sm);
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--spacing-md) 0;
}

.logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  color: var(--color-text);
  transition: opacity var(--transition-fast);
}

.logo:hover {
  opacity: 0.8;
}

.logo-image {
  height: 50px;
  width: auto;
  margin-right: var(--spacing-md);
}

.logo-text {
  font-size: 1.25rem;
  font-weight: var(--font-weight-bold);
  letter-spacing: -0.01em;
}

nav {
  display: flex;
  gap: var(--spacing-2xl);
  align-items: center;
}

nav a {
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
  border-bottom: 2px solid transparent;
  padding-bottom: 4px;
  transition: all var(--transition-fast);
}

nav a:hover, nav a.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.mobile-menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--color-text);
  padding: 0;
}

.mobile-menu-toggle svg {
  stroke: currentColor;
  width: 24px;
  height: 24px;
}

@media (max-width: 768px) {
  .header-content {
    flex-wrap: wrap;
    padding: var(--spacing-md) 0;
  }

  nav {
    display: none;
    flex-direction: column;
    width: 100%;
    gap: var(--spacing-md);
    order: 3;
    margin-top: var(--spacing-md);
  }

  nav.active {
    display: flex;
  }

  .mobile-menu-toggle {
    display: block;
    order: 2;
  }

  nav a {
    padding-bottom: 8px;
    padding-top: 8px;
  }
}

/* ============================================================================
   COMPONENTS: Hero Section
   ============================================================================ */

.hero {
  position: relative;
  min-height: 600px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: var(--color-charcoal);
  color: var(--color-white);
}

.hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
}

.hero-image {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  object-fit: cover;
  z-index: 1;
  opacity: 0.6;
}

.hero-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(43, 44, 44, 0.5);
  z-index: 2;
}

.hero-content {
  position: relative;
  z-index: 3;
  text-align: center;
  max-width: 700px;
}

.hero h1 {
  font-size: 3.5rem;
  margin-bottom: var(--spacing-md);
  color: var(--color-white);
}

.hero .subtitle {
  font-size: 1.5rem;
  margin-bottom: var(--spacing-2xl);
  color: rgba(255, 255, 255, 0.9);
  font-weight: var(--font-weight-medium);
}

.hero-cta {
  display: flex;
  gap: var(--spacing-md);
  justify-content: center;
  flex-wrap: wrap;
}

.hero .btn-primary {
  background-color: var(--color-primary);
}

.hero .btn-primary:hover {
  background-color: var(--color-accent);
}

.hero .btn-secondary {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--color-white);
  border-color: var(--color-white);
}

.hero .btn-secondary:hover {
  background-color: var(--color-white);
  color: var(--color-charcoal);
}

@media (max-width: 768px) {
  .hero {
    min-height: 500px;
  }

  .hero h1 {
    font-size: 2.25rem;
  }

  .hero .subtitle {
    font-size: 1.125rem;
  }
}

/* ============================================================================
   COMPONENTS: Cards
   ============================================================================ */

.card {
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  border-top: 3px solid var(--color-primary);
  border-radius: var(--radius-lg);
  padding: var(--spacing-lg);
  transition: all var(--transition-base);
  display: flex;
  flex-direction: column;
}

.card:hover {
  border-top-width: 5px;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

.card-image {
  width: 100%;
  height: 250px;
  background-color: var(--color-bg-alt);
  border-radius: var(--radius-md);
  margin-bottom: var(--spacing-lg);
}

.card h3 {
  margin-bottom: var(--spacing-sm);
}

.card p {
  flex-grow: 1;
  margin-bottom: var(--spacing-md);
}

/* ============================================================================
   COMPONENTS: Section
   ============================================================================ */

section {
  padding: var(--spacing-4xl) 0;
}

section.alt-bg {
  background-color: var(--color-bg-alt);
}

/* Hairline rhythm divider reinforces each white/grey background shift
   without a visible border. Skipped after .hero, since the dark-to-light
   shift already reads clearly on its own. */
section + section {
  border-top: 1px solid var(--color-divider);
}

.hero + section {
  border-top: none;
}

section h2 {
  text-align: center;
  margin-bottom: var(--spacing-lg);
}

.section-intro {
  text-align: center;
  max-width: 600px;
  margin: 0 auto var(--spacing-3xl);
  color: var(--color-text-light);
  font-size: 1.125rem;
}

/* ============================================================================
   COMPONENTS: Feature Section
   ============================================================================ */

.features {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--spacing-2xl);
}

/* Shared by the "why us" feature grid and the About page value cards —
   same component, one definition. */
.feature,
.value-card {
  text-align: left;
  padding-top: var(--spacing-lg);
  border-top: 3px solid var(--color-primary);
  transition: all var(--transition-base);
}

.feature:hover,
.value-card:hover {
  padding-top: calc(var(--spacing-lg) - 2px);
  border-top-width: 5px;
}

.feature h3,
.value-card h3 {
  margin-bottom: var(--spacing-md);
  font-size: 1.375rem;
  font-weight: var(--font-weight-semibold);
}

.feature p,
.value-card p {
  margin-bottom: 0;
  line-height: 1.7;
}

@media (max-width: 768px) {
  .features {
    grid-template-columns: 1fr;
    gap: var(--spacing-xl);
  }
}

/* ============================================================================
   COMPONENTS: Media Placeholder
   Consistent stand-in for photography that hasn't been shot yet — an icon
   and a caption, styled as an intentional part of the system rather than a
   leftover debug box.
   ============================================================================ */

.media-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: var(--color-bg-alt);
  border-radius: var(--radius-lg);
}

.media-placeholder-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  padding: var(--spacing-lg);
  color: var(--color-text-light);
  text-align: center;
}

.media-placeholder-inner svg {
  width: 28px;
  height: 28px;
  stroke: currentColor;
  opacity: 0.5;
}

.media-placeholder-inner span {
  font-size: 0.75rem;
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* ============================================================================
   COMPONENTS: Gallery Grid
   ============================================================================ */

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--spacing-lg);
}

.gallery-item {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  aspect-ratio: 1;
  background-color: var(--color-bg-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-light);
  font-size: 0.875rem;
  text-align: center;
  padding: var(--spacing-md);
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md);
}

/* ============================================================================
   COMPONENTS: Contact Form
   ============================================================================ */

.form-group {
  margin-bottom: var(--spacing-lg);
}

.form-group label {
  display: block;
  margin-bottom: var(--spacing-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-md);
}

@media (max-width: 768px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

.form-message {
  padding: var(--spacing-md);
  border-radius: var(--radius-md);
  margin-top: var(--spacing-md);
  display: none;
}

.form-message.success {
  background-color: #E8F5E9;
  color: #2E7D32;
  display: block;
}

.form-message.error {
  background-color: #FFEBEE;
  color: #C62828;
  display: block;
}

/* ============================================================================
   COMPONENTS: Footer
   ============================================================================ */

footer {
  background-color: var(--color-charcoal);
  color: rgba(255, 255, 255, 0.8);
  padding: var(--spacing-3xl) 0 var(--spacing-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.footer-content {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--spacing-2xl);
  margin-bottom: var(--spacing-3xl);
}

.footer-section h4 {
  color: var(--color-white);
  margin-bottom: var(--spacing-md);
}

.footer-section ul {
  list-style: none;
  padding-left: 0;
}

.footer-section li {
  margin-bottom: var(--spacing-sm);
}

.footer-section a {
  color: rgba(255, 255, 255, 0.7);
  transition: color var(--transition-fast);
}

.footer-section a:hover {
  color: var(--color-white);
}

.footer-logo {
  display: flex;
  align-items: center;
  margin-bottom: var(--spacing-md);
}

.footer-logo img {
  height: 40px;
  width: auto;
  margin-right: var(--spacing-md);
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--spacing-lg);
  text-align: center;
  font-size: 0.875rem;
}

.footer-credit {
  margin-top: var(--spacing-sm);
}

.footer-credit a {
  color: rgba(255, 255, 255, 0.7);
  text-decoration: underline;
}

.footer-credit a:hover {
  color: var(--color-white);
}

@media (max-width: 1024px) {
  .footer-content {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .footer-content {
    grid-template-columns: 1fr;
  }
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

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

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

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

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

.fade-in {
  animation: fadeIn 0.6s ease-out;
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out;
}

.fade-in-down {
  animation: fadeInDown 0.6s ease-out;
}

.slide-in-left {
  animation: slideInLeft 0.6s ease-out;
}

.slide-in-right {
  animation: slideInRight 0.6s ease-out;
}

/* Intersection Observer for on-scroll animations */
.fade-in-on-scroll {
  opacity: 0;
  animation: fadeInUp 0.6s ease-out forwards;
}

/* ============================================================================
   ACCESSIBILITY
   ============================================================================ */

@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;
  }
}

/* Skip to main content link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--color-primary);
  color: var(--color-white);
  padding: 8px 16px;
  text-decoration: none;
  z-index: 100;
}

.skip-link:focus {
  top: 0;
}

/* Focus visible styling for better accessibility */
:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* ============================================================================
   PRINT STYLES
   ============================================================================ */

@media print {
  body {
    background-color: var(--color-white);
  }

  header, footer, nav {
    display: none;
  }

  section {
    page-break-inside: avoid;
  }
}

/* ============================================================================
   PERFORMANCE: Critical CSS Optimization
   ============================================================================ */

/* Reduce paint areas */
.no-scroll {
  overflow: hidden;
}

/* Improve font loading performance */
@font-feature-settings "kern" 1;
text-rendering: optimizeLegibility;

/* Optimize image loading */
img[loading="lazy"] {
  background: var(--color-bg-alt);
}
