/* ===================================
   RESPONSIVE BREAKPOINTS AND CONTENT FLOW
   Task 8.2: Optimize responsive breakpoints and content flow
   ===================================
   
   This file implements proper responsive breakpoints and ensures
   content maintains readability across all screen sizes with
   proper device rotation handling.
   ================================= */

/* ===================================
   BREAKPOINT DEFINITIONS
   ===================================
   320px  - Small mobile devices
   768px  - Tablets and large mobile
   1024px - Small desktops and tablets
   1440px - Standard desktops
   1920px - Large desktops
   ================================= */

:root {
  /* Responsive breakpoint variables */
  --breakpoint-xs: 320px;
  --breakpoint-sm: 768px;
  --breakpoint-md: 1024px;
  --breakpoint-lg: 1440px;
  --breakpoint-xl: 1920px;
  
  /* Fluid typography scale */
  --font-size-xs: clamp(0.75rem, 0.7rem + 0.25vw, 0.875rem);
  --font-size-sm: clamp(0.875rem, 0.8rem + 0.375vw, 1rem);
  --font-size-base: clamp(1rem, 0.9rem + 0.5vw, 1.125rem);
  --font-size-lg: clamp(1.125rem, 1rem + 0.625vw, 1.25rem);
  --font-size-xl: clamp(1.25rem, 1.1rem + 0.75vw, 1.5rem);
  --font-size-2xl: clamp(1.5rem, 1.3rem + 1vw, 2rem);
  --font-size-3xl: clamp(2rem, 1.7rem + 1.5vw, 3rem);
  
  /* Responsive spacing */
  --container-padding-xs: 1rem;
  --container-padding-sm: 2rem;
  --container-padding-md: 3rem;
  --container-padding-lg: 4rem;
  --container-padding-xl: 6rem;
}

/* ===================================
   CONTAINER AND LAYOUT SYSTEM
   ================================= */

.container-responsive {
  width: 100%;
  margin: 0 auto;
  padding: 0 var(--container-padding-xs);
}

/* 320px - Extra Small Devices */
@media (min-width: 320px) {
  .container-responsive {
    max-width: 100%;
    padding: 0 var(--container-padding-xs);
  }
  
  body {
    font-size: var(--font-size-sm);
    line-height: 1.6;
  }
  
  /* Ensure minimum touch targets */
  button, a, input, textarea, select {
    min-height: 44px;
  }
  
  /* Stack all grid items on extra small screens */
  .grid-responsive {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* 768px - Small Devices (Tablets) */
@media (min-width: 768px) {
  .container-responsive {
    max-width: 750px;
    padding: 0 var(--container-padding-sm);
  }
  
  body {
    font-size: var(--font-size-base);
  }
  
  /* Two column layout for tablets */
  .grid-responsive {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
  }
  
  /* Enhanced navigation for tablets */
  .navbar {
    padding: 0 var(--container-padding-sm);
  }
  
  .navbar .nav-link {
    font-size: 1.1rem;
    padding: 0.75rem 1rem;
  }
  
  /* Tablet-optimized sections */
  section {
    padding: 4rem var(--container-padding-sm);
  }
  
  .section-heading {
    margin-bottom: 3rem;
  }
  
  .section-heading h1 {
    font-size: var(--font-size-3xl);
  }
  
  .section-heading p {
    font-size: var(--font-size-lg);
    max-width: 600px;
    margin: 0 auto;
  }
}

/* 1024px - Medium Devices (Small Desktops) */
@media (min-width: 1024px) {
  .container-responsive {
    max-width: 970px;
    padding: 0 var(--container-padding-md);
  }
  
  body {
    font-size: var(--font-size-base);
  }
  
  /* Three column layout for small desktops */
  .grid-responsive {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
  }
  
  /* Desktop navigation */
  .navbar {
    padding: 0 var(--container-padding-md);
  }
  
  .navbar .nav-item:not(:last-child) {
    margin-right: 2rem;
  }
  
  .navbar .nav-link {
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
  }
  
  /* Desktop sections */
  section {
    padding: 5rem var(--container-padding-md);
  }
  
  .section-heading {
    margin-bottom: 4rem;
  }
  
  /* Enhanced content layouts */
  .contact-grid {
    grid-template-columns: 1fr 1fr;
    gap: 3rem;
    align-items: start;
  }
  
  .about-metrics {
    grid-template-columns: repeat(3, 1fr);
    gap: 2rem;
  }
  
  .events-grid,
  .updates-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 2rem;
  }
}

/* 1440px - Large Devices (Standard Desktops) */
@media (min-width: 1440px) {
  .container-responsive {
    max-width: 1200px;
    padding: 0 var(--container-padding-lg);
  }
  
  /* Four column layout for large desktops */
  .grid-responsive {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
  }
  
  /* Large desktop navigation */
  .navbar {
    padding: 0 var(--container-padding-lg);
  }
  
  .navbar .nav-item:not(:last-child) {
    margin-right: 2.5rem;
  }
  
  .navbar .nav-link {
    font-size: 1.2rem;
  }
  
  /* Large desktop sections */
  section {
    padding: 6rem var(--container-padding-lg);
  }
  
  .section-heading {
    margin-bottom: 5rem;
  }
  
  .section-heading h1 {
    font-size: var(--font-size-3xl);
  }
  
  .section-heading p {
    font-size: var(--font-size-xl);
    max-width: 800px;
  }
  
  /* Enhanced layouts for large screens */
  .about-metrics {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
  }
  
  .events-grid,
  .updates-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 2.5rem;
  }
}

/* 1920px - Extra Large Devices */
@media (min-width: 1920px) {
  .container-responsive {
    max-width: 1400px;
    padding: 0 var(--container-padding-xl);
  }
  
  /* Ultra-wide layouts */
  .grid-responsive {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 3rem;
  }
  
  .navbar {
    padding: 0 var(--container-padding-xl);
  }
  
  section {
    padding: 8rem var(--container-padding-xl);
  }
  
  .section-heading {
    margin-bottom: 6rem;
  }
  
  .about-metrics {
    grid-template-columns: repeat(3, 1fr);
    gap: 4rem;
  }
  
  .events-grid,
  .updates-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem;
  }
}

/* ===================================
   DEVICE ROTATION HANDLING
   ================================= */

/* Portrait orientation optimizations */
@media (orientation: portrait) {
  .hero {
    height: 100vh;
    min-height: 600px;
  }
  
  .img-container {
    height: 30%;
  }
  
  /* Stack content vertically in portrait */
  .content-row-responsive {
    flex-direction: column;
  }
  
  .swiper-container {
    height: 70vh;
    min-height: 500px;
  }
}

/* Landscape orientation optimizations */
@media (orientation: landscape) {
  .hero {
    height: 100vh;
    min-height: 500px;
  }
  
  .img-container {
    height: 25%;
  }
  
  /* Horizontal layout in landscape */
  .content-row-responsive {
    flex-direction: row;
  }
  
  .swiper-container {
    height: 60vh;
    min-height: 400px;
  }
}

/* Mobile landscape specific adjustments */
@media (max-width: 768px) and (orientation: landscape) {
  .hero {
    height: 100vh;
  }
  
  .navbar-collapse {
    height: calc(100vh - 4.5rem);
    overflow-y: auto;
  }
  
  .navbar-nav {
    padding: 1rem;
    gap: 0.75rem;
  }
  
  .navbar .nav-link {
    font-size: 1rem;
    padding: 0.5rem 1rem;
  }
  
  section {
    padding: 2rem 1rem;
  }
}

/* ===================================
   CONTENT READABILITY OPTIMIZATIONS
   ================================= */

/* Ensure optimal line lengths for readability */
.text-content {
  max-width: 65ch; /* Optimal reading width */
  margin: 0 auto;
}

.text-content p {
  line-height: 1.6;
  margin-bottom: 1.5rem;
}

/* Responsive typography scale */
@media (max-width: 320px) {
  body { font-size: 14px; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.5rem; }
  h3 { font-size: 1.25rem; }
}

@media (min-width: 321px) and (max-width: 767px) {
  body { font-size: 15px; }
  h1 { font-size: 2rem; }
  h2 { font-size: 1.75rem; }
  h3 { font-size: 1.5rem; }
}

@media (min-width: 768px) and (max-width: 1023px) {
  body { font-size: 16px; }
  h1 { font-size: 2.5rem; }
  h2 { font-size: 2rem; }
  h3 { font-size: 1.75rem; }
}

@media (min-width: 1024px) {
  body { font-size: 16px; }
  h1 { font-size: 3rem; }
  h2 { font-size: 2.5rem; }
  h3 { font-size: 2rem; }
}

/* ===================================
   RESPONSIVE IMAGES AND MEDIA
   ================================= */

/* Responsive images */
img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive videos */
video {
  max-width: 100%;
  height: auto;
}

/* Responsive iframes */
iframe {
  max-width: 100%;
}

/* ===================================
   RESPONSIVE TABLES
   ================================= */

@media (max-width: 768px) {
  table {
    font-size: 0.875rem;
  }
  
  /* Stack table cells on mobile */
  .table-responsive-stack {
    display: block;
  }
  
  .table-responsive-stack thead,
  .table-responsive-stack tbody,
  .table-responsive-stack th,
  .table-responsive-stack td,
  .table-responsive-stack tr {
    display: block;
  }
  
  .table-responsive-stack thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }
  
  .table-responsive-stack tr {
    border: 1px solid #ccc;
    margin-bottom: 10px;
    padding: 10px;
  }
  
  .table-responsive-stack td {
    border: none;
    position: relative;
    padding-left: 50%;
  }
  
  .table-responsive-stack td:before {
    content: attr(data-label) ": ";
    position: absolute;
    left: 6px;
    width: 45%;
    padding-right: 10px;
    white-space: nowrap;
    font-weight: bold;
  }
}

/* ===================================
   RESPONSIVE UTILITIES
   ================================= */

/* Show/hide content based on screen size */
.show-xs { display: block; }
.show-sm, .show-md, .show-lg, .show-xl { display: none; }

@media (min-width: 768px) {
  .show-xs { display: none; }
  .show-sm { display: block; }
}

@media (min-width: 1024px) {
  .show-sm { display: none; }
  .show-md { display: block; }
}

@media (min-width: 1440px) {
  .show-md { display: none; }
  .show-lg { display: block; }
}

@media (min-width: 1920px) {
  .show-lg { display: none; }
  .show-xl { display: block; }
}

/* Responsive text alignment */
.text-center-xs { text-align: center; }
.text-left-sm { text-align: left; }

@media (min-width: 768px) {
  .text-center-xs { text-align: left; }
  .text-left-sm { text-align: left; }
}

/* Responsive margins and padding */
.p-responsive {
  padding: 1rem;
}

@media (min-width: 768px) {
  .p-responsive {
    padding: 2rem;
  }
}

@media (min-width: 1024px) {
  .p-responsive {
    padding: 3rem;
  }
}

@media (min-width: 1440px) {
  .p-responsive {
    padding: 4rem;
  }
}

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

@media print {
  * {
    background: transparent !important;
    color: black !important;
    box-shadow: none !important;
    text-shadow: none !important;
  }
  
  body {
    font-size: 12pt;
    line-height: 1.5;
  }
  
  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
  }
  
  .navbar,
  .footer,
  .btn,
  .swiper-container {
    display: none !important;
  }
  
  .container-responsive {
    max-width: none;
    padding: 0;
  }
  
  section {
    padding: 1rem 0;
  }
}

/* ===================================
   HIGH CONTRAST MODE SUPPORT
   ================================= */

@media (prefers-contrast: high) {
  :root {
    --text-primary: #ffffff;
    --text-secondary: #ffffff;
    --bg-dark: #000000;
    --accent: #ffff00;
    --border-soft: #ffffff;
  }
  
  .btn,
  .nav-link,
  .form-control {
    border: 2px solid currentColor;
  }
}

/* ===================================
   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;
  }
  
  .rellax {
    transform: none !important;
  }
  
  .parallax-element {
    transform: none !important;
  }
}