/* Base Layout Styles and Container Classes */

/* Smooth Scrolling - Requirement 1.5, 9.1 */
html {
  scroll-behavior: smooth;
}

/* Body Styles */
body {
  font-family: var(--font-family-base);
  font-size: var(--font-size-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden; /* Prevent horizontal scrolling - Requirement 8.6 */
  width: 100%;
  max-width: 100vw;
  box-sizing: border-box;
}

/* Ensure all elements respect box-sizing */
*, *::before, *::after {
  box-sizing: border-box;
}

/* Prevent images and media from causing overflow - but allow specific heights */
img, video, iframe, embed, object {
  max-width: 100%;
}

/* Only apply height: auto to images that don't have explicit height set */
img:not([style*="height"]) {
  height: auto;
}

/* Container Classes */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.container-wide {
  width: 100%;
  max-width: var(--max-width-wide);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.container-narrow {
  width: 100%;
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 var(--spacing-md);
}

.container-fluid {
  width: 100%;
  padding: 0 var(--spacing-md);
}

/* Section Spacing */
.section {
  padding: var(--spacing-3xl) 0;
}

.section-sm {
  padding: var(--spacing-2xl) 0;
}

.section-lg {
  padding: var(--spacing-4xl) 0;
}

/* Typography Utilities */
.text-center {
  text-align: center;
}

.text-left {
  text-align: left;
}

.text-right {
  text-align: right;
}

/* Heading Styles */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  margin-bottom: var(--spacing-md);
}

h1 {
  font-size: var(--font-size-5xl);
}

h2 {
  font-size: var(--font-size-4xl);
}

h3 {
  font-size: var(--font-size-3xl);
}

h4 {
  font-size: var(--font-size-2xl);
}

h5 {
  font-size: var(--font-size-xl);
}

h6 {
  font-size: var(--font-size-lg);
}

/* Paragraph Styles */
p {
  margin-bottom: var(--spacing-md);
  line-height: var(--line-height-normal);
}

/* 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);
}

/* Flexbox Utilities */
.flex {
  display: flex;
}

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flex-column {
  display: flex;
  flex-direction: column;
}

.flex-wrap {
  flex-wrap: wrap;
}

/* 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); }

.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); }

.pt-sm { padding-top: var(--spacing-sm); }
.pt-md { padding-top: var(--spacing-md); }
.pt-lg { padding-top: var(--spacing-lg); }
.pt-xl { padding-top: var(--spacing-xl); }

.pb-sm { padding-bottom: var(--spacing-sm); }
.pb-md { padding-bottom: var(--spacing-md); }
.pb-lg { padding-bottom: var(--spacing-lg); }
.pb-xl { padding-bottom: var(--spacing-xl); }

/* Visibility Utilities */
.hidden {
  display: none !important;
}

.visible {
  display: block !important;
}

/* Screen reader only content */
.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;
}

/* Focus visible styles for keyboard navigation */
*:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* Fade-in Animation for Scroll Effects - Requirement 9.4 */
.fade-in {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}

.fade-in.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Hover Transition Effects for Interactive Elements - Requirements 9.2, 9.3 */
/* All interactive elements should have hover effects with 0.2s-0.4s duration */
a,
button,
.card,
.feature-card,
.service-card,
.source-card,
input[type="button"],
input[type="submit"],
.interactive {
  transition: all 0.3s ease;
}

/* Specific hover effects for links */
a:hover {
  opacity: 0.8;
}

/* Specific hover effects for buttons */
button:hover,
input[type="button"]:hover,
input[type="submit"]:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

/* Specific hover effects for cards */
.card:hover,
.feature-card:hover,
.service-card:hover,
.source-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}

/* Responsive Breakpoints - Requirement 8.3 */

/* Tablet (768px - 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .container {
    padding: 0 var(--spacing-lg);
  }
  
  .section {
    padding: var(--spacing-2xl) 0;
  }
  
  h1 {
    font-size: var(--font-size-4xl);
  }
  
  h2 {
    font-size: var(--font-size-3xl);
  }
  
  h3 {
    font-size: var(--font-size-2xl);
  }
}

/* Mobile (max-width: 767px) */
@media (max-width: 767px) {
  .container,
  .container-wide,
  .container-narrow {
    padding: 0 var(--spacing-md);
  }
  
  .section {
    padding: var(--spacing-xl) 0;
  }
  
  .section-lg {
    padding: var(--spacing-2xl) 0;
  }
  
  /* Stack grids on mobile */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }
  
  /* Adjust typography for mobile */
  h1 {
    font-size: var(--font-size-3xl);
  }
  
  h2 {
    font-size: var(--font-size-2xl);
  }
  
  h3 {
    font-size: var(--font-size-xl);
  }
  
  h4 {
    font-size: var(--font-size-lg);
  }
  
  h5, h6 {
    font-size: var(--font-size-base);
  }
}

/* Ensure viewport adaptation from 320px to 1920px - Requirement 8.1 */
@media (min-width: 320px) and (max-width: 1920px) {
  body {
    width: 100%;
    max-width: 100vw;
  }
  
  /* Ensure all containers respect viewport width */
  .container,
  .container-wide,
  .container-narrow,
  .container-fluid {
    max-width: 100%;
  }
}

/* Extra Small Mobile (320px-479px) */
@media (min-width: 320px) and (max-width: 479px) {
  .container,
  .container-wide,
  .container-narrow {
    padding: 0 var(--spacing-sm);
  }
  
  h1 {
    font-size: var(--font-size-2xl);
  }
  
  h2 {
    font-size: var(--font-size-xl);
  }
}

/* Large Desktop (1440px+) */
@media (min-width: 1440px) {
  .container {
    max-width: var(--max-width-wide);
  }
}

/* Extra Large Desktop (1920px+) */
@media (min-width: 1920px) {
  .container {
    max-width: 1600px;
  }
}
