/* Responsive CSS for ABMMS Website */

/* Base Responsive Settings */
:root {
  --container-padding-mobile: 1rem;
  --container-padding-tablet: 1.5rem;
  --section-spacing-mobile: 2rem;
  --section-spacing-tablet: 3rem;
  --section-spacing-desktop: 4rem;
  --card-gap-mobile: 0.75rem;
  --card-gap-tablet: 1rem;
  --card-gap-desktop: 1.5rem;
}

/* Global Responsive Adjustments */
html {
  font-size: 16px;
}

body {
  overflow-x: hidden;
  width: 100%;
  max-width: 100vw;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}

.container {
  width: 100%;
  max-width: 100%;
  padding-left: var(--container-padding-tablet);
  padding-right: var(--container-padding-tablet);
}

/* Responsive Grid System */
.row {
  margin-left: calc(-1 * var(--card-gap-desktop) / 2);
  margin-right: calc(-1 * var(--card-gap-desktop) / 2);
}

.row > [class*="col-"] {
  padding-left: calc(var(--card-gap-desktop) / 2);
  padding-right: calc(var(--card-gap-desktop) / 2);
  margin-bottom: var(--card-gap-desktop);
}

/* Responsive Spacing */
section {
  padding: var(--section-spacing-desktop) 0;
}

/* Responsive images */
img, svg, video, canvas, picture {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Responsive image containers */
.img-fluid {
  max-width: 100%;
  height: auto;
}

.img-container {
  position: relative;
  overflow: hidden;
  width: 100%;
}

/* Aspect ratio containers */
.ratio {
  position: relative;
  width: 100%;
}

.ratio::before {
  content: "";
  display: block;
  padding-top: var(--aspect-ratio, 56.25%); /* Default 16:9 ratio */
}

.ratio > * {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ratio-1x1::before {
  --aspect-ratio: 100%;
}

.ratio-4x3::before {
  --aspect-ratio: 75%;
}

.ratio-16x9::before {
  --aspect-ratio: 56.25%;
}

.ratio-21x9::before {
  --aspect-ratio: 42.85%;
}

/* Background images */
.bg-img {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Responsive image loading */
.lazy-load {
  opacity: 0;
  transition: opacity 0.3s ease-in-out;
}

.lazy-load.loaded {
  opacity: 1;
}

/* Image optimization for mobile */
@media (max-width: 767.98px) {
  .mobile-img-sm {
    max-width: 80%;
    margin-left: auto;
    margin-right: auto;
  }
  
  /* Reduce quality for performance on mobile */
  .bg-img {
    background-attachment: scroll !important;
  }
}

/* Touch-friendly Elements */
button, .btn, a, input, select, textarea {
  touch-action: manipulation;
}

.btn, button, [role="button"], 
input[type="button"], 
input[type="submit"] {
  min-height: 44px; /* Minimum touch target size */
}

/* Improve touch targets spacing */
.nav-link, .dropdown-item {
  padding: 0.75rem 1rem;
  min-height: 44px;
}

/* Add active state feedback for touch */
.btn:active, a:active, .nav-link:active, .dropdown-item:active {
  transform: scale(0.97);
  transition: transform 0.1s ease-in-out;
}

/* Disable hover effects on touch devices */
@media (hover: none) {
  .btn:hover, a:hover, .card:hover {
    transform: none !important;
  }
  
  /* Use active states instead for touch feedback */
  .btn:active, a:active, .card:active {
    transform: scale(0.97) !important;
  }
}

/* Enhanced Navbar Responsiveness */
@media (max-width: 991.98px) {
  /* Prevent body scrolling when menu is open */
  body.menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
  }
  
  /* Improve touch targets for mobile navbar */
  .navbar-nav .nav-item {
    margin-bottom: 0.5rem;
  }
  
  /* Navbar collapse styles are handled in modern-ui.css */
  
  /* Ensure navbar items are visible */
  .navbar-nav {
    margin-top: 3.5rem;
    width: 100%;
  }
  
  .navbar-nav .nav-link {
    color: white !important;
    opacity: 0.9;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.5rem;
    font-weight: 500;
    display: block;
  }
  
  /* Better spacing for dropdown menus */
  .dropdown-menu {
    border: none;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 10px;
    margin-top: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.5rem;
  }
  
  .dropdown-item {
    color: rgba(255, 255, 255, 0.9);
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    margin: 0.25rem;
  }
  
  .dropdown-item:hover, .dropdown-item:focus {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
  }
  
  /* Improve navbar brand display */
  .navbar-brand {
    display: flex;
    align-items: center;
    max-width: 70%;
  }
  
  /* Ensure navbar toggler is easily tappable */
  .navbar-toggler {
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1050; /* Ensure it's above the side menu */
  }
  
  /* Navbar collapse overlay is handled in modern-ui.css */
}

@media (max-width: 575.98px) {
  /* Optimize navbar for very small screens */
  .navbar-brand {
    max-width: 75%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  /* Ensure dropdown menus don't overflow screen */
  .dropdown-menu {
    max-height: 50vh;
    overflow-y: auto;
  }
  
  /* Navbar collapse spacing is handled in modern-ui.css */
  
  /* Make nav links more tappable on small screens */
  .nav-link {
    padding: 0.85rem 1rem;
    margin-bottom: 0.25rem;
  }
}

/* Navbar Brand & Logo Responsiveness */
.navbar-brand {
  display: flex;
  align-items: center;
  transition: all 0.3s ease;
}

.navbar-brand img {
  transition: all 0.3s ease;
}

/* Ensure navbar brand text doesn't wrap awkwardly */
.navbar-brand span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Responsive Typography */
:root {
  --base-font-size: 16px;
  --scale-ratio: 1.2;
  --h1-size: calc(var(--base-font-size) * var(--scale-ratio) * var(--scale-ratio) * var(--scale-ratio) * var(--scale-ratio));
  --h2-size: calc(var(--base-font-size) * var(--scale-ratio) * var(--scale-ratio) * var(--scale-ratio));
  --h3-size: calc(var(--base-font-size) * var(--scale-ratio) * var(--scale-ratio));
  --h4-size: calc(var(--base-font-size) * var(--scale-ratio));
  --h5-size: var(--base-font-size);
  --h6-size: calc(var(--base-font-size) / var(--scale-ratio));
  --body-font-size: var(--base-font-size);
  --small-font-size: calc(var(--base-font-size) * 0.875);
}

body {
  font-size: var(--body-font-size);
  line-height: 1.6;
}

h1, .h1 {
  font-size: var(--h1-size);
  line-height: 1.2;
}

h2, .h2 {
  font-size: var(--h2-size);
  line-height: 1.25;
}

h3, .h3 {
  font-size: var(--h3-size);
  line-height: 1.3;
}

h4, .h4 {
  font-size: var(--h4-size);
  line-height: 1.35;
}

h5, .h5 {
  font-size: var(--h5-size);
  line-height: 1.4;
}

h6, .h6 {
  font-size: var(--h6-size);
  line-height: 1.4;
}

.lead {
  font-size: calc(var(--body-font-size) * 1.15);
  line-height: 1.5;
}

small, .small {
  font-size: var(--small-font-size);
}

/* Responsive typography adjustments */
@media (max-width: 1199.98px) {
  :root {
    --scale-ratio: 1.18;
  }
}

@media (max-width: 991.98px) {
  :root {
    --base-font-size: 15px;
    --scale-ratio: 1.15;
  }
}

@media (max-width: 767.98px) {
  :root {
    --base-font-size: 14px;
    --scale-ratio: 1.12;
  }
  
  h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    margin-bottom: 0.75rem;
  }
  
  p {
    margin-bottom: 1rem;
  }
}

@media (max-width: 575.98px) {
  :root {
    --base-font-size: 14px;
    --scale-ratio: 1.1;
  }
  
  h1, .h1, h2, .h2, h3, .h3, h4, .h4, h5, .h5, h6, .h6 {
    margin-bottom: 0.5rem;
  }
  
  p {
    margin-bottom: 0.75rem;
  }
}

/* Large Desktop (1200px and up) */
@media (min-width: 1200px) {
  html {
    font-size: 18px;
  }
  
  .container {
    max-width: 1140px;
  }
}

/* Desktop (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199.98px) {
  html {
    font-size: 17px;
  }
  
  .container {
    max-width: 960px;
  }
  
  h1, .h1 {
    font-size: 2.25rem;
  }
}

/* Tablet (768px to 991px) */
@media (min-width: 768px) and (max-width: 991.98px) {
  html {
    font-size: 16px;
  }
  
  .container {
    max-width: 720px;
    padding-left: var(--container-padding-tablet);
    padding-right: var(--container-padding-tablet);
  }
  
  .row {
    margin-left: calc(-1 * var(--card-gap-tablet) / 2);
    margin-right: calc(-1 * var(--card-gap-tablet) / 2);
  }
  
  .row > [class*="col-"] {
    padding-left: calc(var(--card-gap-tablet) / 2);
    padding-right: calc(var(--card-gap-tablet) / 2);
    margin-bottom: var(--card-gap-tablet);
  }
  
  section {
    padding: var(--section-spacing-tablet) 0;
  }
  
  h1, .h1 {
    font-size: 2rem;
  }
  
  h2, .h2 {
    font-size: 1.75rem;
  }
  
  h3, .h3 {
    font-size: 1.5rem;
  }
}

/* Mobile Large (576px to 767px) */
@media (min-width: 576px) and (max-width: 767.98px) {
  html {
    font-size: 15px;
  }
  
  .container {
    max-width: 540px;
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }
  
  .row {
    margin-left: calc(-1 * var(--card-gap-mobile) / 2);
    margin-right: calc(-1 * var(--card-gap-mobile) / 2);
  }
  
  .row > [class*="col-"] {
    padding-left: calc(var(--card-gap-mobile) / 2);
    padding-right: calc(var(--card-gap-mobile) / 2);
    margin-bottom: var(--card-gap-mobile);
  }
  
  section {
    padding: var(--section-spacing-mobile) 0;
  }
  
  h1, .h1 {
    font-size: 1.85rem;
  }
  
  h2, .h2 {
    font-size: 1.6rem;
  }
  
  h3, .h3 {
    font-size: 1.4rem;
  }
  
  h4, .h4 {
    font-size: 1.25rem;
  }
}

/* Mobile Small (575px and down) */
@media (max-width: 575.98px) {
  html {
    font-size: 14px;
  }
  
  .container {
    padding-left: var(--container-padding-mobile);
    padding-right: var(--container-padding-mobile);
  }
  
  .row {
    margin-left: calc(-1 * var(--card-gap-mobile) / 2);
    margin-right: calc(-1 * var(--card-gap-mobile) / 2);
  }
  
  .row > [class*="col-"] {
    padding-left: calc(var(--card-gap-mobile) / 2);
    padding-right: calc(var(--card-gap-mobile) / 2);
    margin-bottom: var(--card-gap-mobile);
  }
  
  section {
    padding: var(--section-spacing-mobile) 0;
  }
  
  h1, .h1 {
    font-size: 1.75rem;
  }
  
  h2, .h2 {
    font-size: 1.5rem;
  }
  
  h3, .h3 {
    font-size: 1.3rem;
  }
  
  h4, .h4 {
    font-size: 1.2rem;
  }
  
  p, .p {
    font-size: 0.95rem;
  }
  
  /* Adjust column widths for mobile */
  .col-6 {
    width: 100%;
  }
  
  /* Stack buttons on mobile */
  .btn-group {
    flex-direction: column;
    width: 100%;
  }
  
  .btn-group .btn {
    margin-bottom: 0.5rem;
    width: 100%;
  }
  
  /* Adjust form elements */
  input, select, textarea {
    font-size: 16px; /* Prevents iOS zoom on focus */
  }
}

/* Landscape orientation adjustments */
@media (max-height: 500px) and (orientation: landscape) {
  .hero-section {
    min-height: 300px !important;
  }
  
  .navbar-modern {
    height: 56px !important;
  }
}

/* Print styles */
@media print {
  .navbar, .footer, .no-print {
    display: none !important;
  }
  
  body {
    font-size: 12pt;
  }
  
  a[href]:after {
    content: " (" attr(href) ")";
  }
}