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

/* Prevent horizontal scrolling */
html, body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
}

/* Ensure full height for html and body */
html, body {
  height: 100%;
}

body {
  font-family: "Arimo", sans-serif;
  line-height: 1.6;
  color: #333;
}

/* Main Section with Full Background Image & Dark Overlay */
#main-content {
  position: relative;
  background: url('photos/bg.jpg') no-repeat center center;
  background-size: cover;
  padding: 2rem 0;
  animation: fadeIn 1.5s ease-in-out;
}

/* Dark overlay to enhance text contrast */
#main-content::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 1;
}

/* Centered content: vertically & horizontally centered */
.centered-content {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
}

/* Top Content Styling with restricted width */
.top-content {
  max-width: 50%; /* Approximately spans the 2nd and 3rd column width */
  margin: 0 auto 2rem;
  padding: 0 1rem;
  animation: slideDown 1s ease-out 0.5s both;
}

.top-content h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  letter-spacing: 2px;
  color: #fff;
}

.top-content p {
  font-size: 1.2rem;
  color: #fff;
}

/* Photo Grid: use Grid with align-items: stretch to force equal card heights */
.photo-grid {
  width: 80%;
  margin: 0 auto;
  display: grid;
  grid-gap: 1.5rem;
  padding: 0 1rem;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch; /* Ensures each .company in the row is the same total height */
  perspective: 1000px; /* For 3D effects on children */
}

/* Each card is a flex container in column direction */
.company {
  display: flex;
  flex-direction: column;
  background: transparent; /* No background so the entire card can stretch */
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  border-radius: 8px;
  opacity: 0;
  animation: fadeIn 0.8s ease-out forwards;
  animation-delay: calc(var(--animation-order) * 0.2s);
}

/* Apply animation delays to each company */
.photo-grid .company:nth-child(1) {
  --animation-order: 1;
}
.photo-grid .company:nth-child(2) {
  --animation-order: 2;
}
.photo-grid .company:nth-child(3) {
  --animation-order: 3;
}
.photo-grid .company:nth-child(4) {
  --animation-order: 4;
}

.company:hover {
  transform: translateY(-10px);
  box-shadow: 0 15px 30px rgba(0, 0, 0, 0.2);
  z-index: 5;
}

/* The image sits at the top; the black text area can fill remaining space */
.company a {
  display: block;
  flex: 0 0 auto; /* Image doesn't stretch */
  overflow: hidden; /* Contain zoom effect */
  border-radius: 8px 8px 0 0;
}

.company img {
  width: 100%;
  height: auto;
  display: block;
  transition: transform 0.5s ease, filter 0.5s ease;
}

.company:hover img {
  transform: scale(1.05);
}

/* The black text area is a flex child that can stretch with the card height */
.company-text {
  background-color: rgba(0, 0, 0, 0.7);
  border-radius: 8px;
  margin-top: 50px;
  text-align: left;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  /* Let it fill up leftover space to match the tallest card */
  flex: 1;
  padding: 1rem; /* Increase padding for comfortable spacing */
  transition: background-color 0.4s ease;
}

.company:hover .company-text {
  background-color: rgba(0, 0, 0, 0.85);
}

.company-text h2 {
  color: #fff;
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
  transition: transform 0.3s ease, color 0.3s ease;
}

.company:hover .company-text h2 {
  color: #f8f8f8;
  transform: translateX(5px);
}

.company-text p {
  color: #fff;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: justify;
  margin: 0;
  transition: opacity 0.4s ease;
}

.company:hover .company-text p {
  opacity: 0.95;
}

/* Base transition for images */
.photo-grid .company img {
  transition: filter 0.5s ease, transform 0.5s ease;
}

/* On hover over the grid, all images become grayscale */
.photo-grid:hover .company img {
  filter: grayscale(100%);
}

/* Except the hovered image, which remains in full colour */
.photo-grid:hover .company:hover img {
  filter: none;
  transform: scale(1.05);
}

/* Footer Styling */
footer {
  background-color: #333;
  color: #fff;
  padding: 1rem 0;
  animation: slideUp 0.8s ease-out;
}

/* Footer Container: Flexbox to position text and image */
.footer-container {
  width: 90%;
  max-width: 1200px;
  margin: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  padding: 0 1rem;
}

.footer-container p {
  margin: 0.5rem 0;
}

/* Footer Logo: Adjust size as needed */
.footer-logo {
  max-width: 125px;
  height: auto;
  transition: transform 0.3s ease;
}

.footer-container a:hover .footer-logo {
  transform: scale(1.1);
}

/* Animation Keyframes */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

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

/* Smooth scroll behavior */
html {
  scroll-behavior: smooth;
}

/* Desktop: 4 columns */
.photo-grid {
  width: 80%;
  margin: 0 auto;
  display: grid;
  grid-gap: 1.5rem;
  padding: 0 1rem;
  grid-template-columns: repeat(4, 1fr);
  align-items: stretch;
}

/* Tablet: 2 columns (768px to 1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
  .photo-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Mobile: 1 column (below 768px) */
@media (max-width: 767px) {
  .photo-grid {
    grid-template-columns: 1fr;
    width: 90%;       /* Use more screen width */
    grid-gap: 1rem;   /* Slightly reduce gap between items */
    padding: 0;       /* Remove padding to use more space */
  }
  
  .top-content {
    max-width: 90%;   /* Use more of the screen width */
    margin: 0 auto 2rem;
    padding: 0;       /* Remove padding to use more space */
  }
  
  .top-content h1 {
    font-size: 1.8rem;  /* Smaller for mobile */
    /* Don't force nowrap as it may cause overflow */
    word-break: keep-all;
    hyphens: none;
  }
  
  .top-content p {
    font-size: 1.1rem; /* Slightly smaller for mobile */
  }
  
  .centered-content {
    padding: 1rem;    /* Reduce overall padding */
    width: 100%;      /* Full width */
    max-width: 100%;  /* Ensure no overflow */
  }
  
  .company-text {
    padding: 0.8rem;  /* Slightly less padding in company text boxes */
  }
  
  /* Fix for potential overflow issues */
  #main-content {
    width: 100%;
    max-width: 100%;
  }
  
  .footer-container {
    width: 100%;
    max-width: 100%;
    padding: 0 1rem;
  }
}

/* Optional: Parallax effect for background */
@media (min-width: 1024px) {
  #main-content {
    background-attachment: fixed;
  }
}