/* Mobile-first responsive styles */
@media screen and (max-width: 768px) {

  /* Increase base font size for better readability */
  html {
    font-size: 16px;
  }

  /* Header and Navigation */
  .navbar {
    padding: 15px 0;
  }

  .navbar-brand {
    font-size: 24px;
  }

  .navbar-nav .nav-link {
    font-size: 18px;
    padding: 12px 15px;
  }

  /* Enhanced navbar-header visibility */
  .navbar-header {
    padding: 10px 15px;
    background-color: rgba(255, 255, 255, 0);
    width: 100%;
    z-index: 1030;
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .navbar-header .navbar-brand {
    font-size: 24px !important;
    line-height: 1.2;
    padding: 10px 0;
    margin-left: 10px;
    white-space: nowrap; /* Prevent text wrapping */
    overflow: hidden;
    text-overflow: ellipsis; /* Show ... if text overflows */
    max-width: calc(100% - 70px); /* Leave space for toggle button */
  }

  .navbar-toggle {
    margin: 8px 15px;
    padding: 12px 10px;
    flex-shrink: 0; /* Prevent toggle button from shrinking */
  }

  /* Buttons and interactive elements */
  .btn {
    font-size: 16px;
    padding: 12px 24px;
    min-height: 44px; /* Minimum touch target size */
  }

  /* Sections padding */
  section {
    padding: 60px 0;
  }

  .container {
    padding-left: 20px;
    padding-right: 20px;
  }

  /* Portfolio items */
  .portfolio-item {
    margin-bottom: 30px;
  }

  /* Contact form elements */
  input[type="text"],
  input[type="email"],
  textarea {
    font-size: 16px;
    padding: 12px;
    margin-bottom: 20px;
  }

  /* Footer */
  footer {
    padding: 40px 0;
  }

  footer p {
    font-size: 14px !important;
  }

  /* Image scaling */
  img {
    max-width: 100%;
    height: auto;
  }

  /* Title-specific adjustments */
  .title,
  h1.title,
  .header-title {
    font-size: 28px !important;
    line-height: 1.2;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin: 10px 0;
  }

  /* Ensure container has proper padding */
  .container {
    padding-left: 20px;
    padding-right: 20px;
  }
}

/* Additional rules for very small devices */
@media screen and (max-width: 480px) {
  html {
    font-size: 18px;
  }

  /* Increase spacing for better touch targets */
  .navbar-nav .nav-link {
    padding: 15px;
    margin: 5px 0;
  }

  /* Enhanced navbar-header visibility for very small screens */
  .navbar-header {
    padding: 8px 10px;
  }

  .navbar-header .navbar-brand {
    font-size: 20px !important;
    margin-left: 5px;
    max-width: calc(100% - 60px); /* Slightly less space on very small screens */
  }

  .navbar-toggle {
    margin: 6px 10px;
    padding: 10px 8px;
  }

  /* Adjust grid items for single column */
  .col-sm-6,
  .col-md-4,
  .col-lg-3 {
    width: 100%;
    margin-bottom: 20px;
  }

  .title,
  h1.title,
  .header-title {
    font-size: 24px !important;
    line-height: 1.3;
    padding: 0 10px;
  }

  /* Adjust header spacing */
  header {
    padding: 15px 0;
  }
}

/* Ensure proper scaling on landscape orientation */
@media screen and (max-width: 768px) and (orientation: landscape) {
  .navbar-collapse {
    max-height: 80vh;
    overflow-y: auto;
  }
  .title,
  h1.title,
  .header-title {
    font-size: 26px !important;
    max-width: 100%;
    margin: 15px auto;
  }
}