/* Reset and base styles */
html, body {
  min-height: 100%;   /* allow page to grow taller than screen */
  margin: 0;
  background: linear-gradient(to bottom right, #f9f9f9, #eaeef3);
  background-attachment: fixed; /* ensures gradient stays consistent as page grows */
}

/* Main content */
.main-content {
  display: block;
  padding: 5rem;
}

h1 {
  text-align: center;
  margin-bottom: 2rem;
  font-size: 2rem;
  opacity: 0;
  animation: fadeInUp 0.6s ease forwards;
  animation-delay: 0.2s;
}

.fade-in-up {
  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

#search {
  width: 100%;
  padding: 0.75rem;
  margin-bottom: 2rem;
  font-size: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  transition: border-color 0.3s ease;

  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

#search:focus {
  border-color: #4a90e2;
  outline: none;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.product {
  perspective: 1000px;
  font-family: Arial, Helvetica, sans-serif
}

.tilt-inner {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  transition: transform 0.3s ease, box-shadow 0.3s ease;

  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
}

.tilt-inner:hover {
  transform: scale(1.02);
  box-shadow: 0 6px 16px rgba(0,0,0,0.12);
}

.tilt-inner img {
  max-width: 100%;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.tilt-inner h2 {
  font-size: 1.2rem;
  margin: 0 0 0.5rem;
}

.tilt-inner p {
  font-size: 0.95rem;
  line-height: 1.4;
  margin-bottom: 1rem;
}

.tilt-inner a {
  text-decoration: none;
  color: white;
  background: #4a90e2;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  text-align: center;
  font-weight: bold;
  display: inline-block;
  transition: background 0.3s ease;
}

.tilt-inner a:hover {
  background: #357ab8;
}

/* Ad Modal Styles (Scoped) */
.ad-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.ad-modal-content {
  background: #fff;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: adPopIn 0.3s ease-out;
  position: relative;
}

.ad-modal-content img {
  width: 100%;
  border-radius: 6px;
  margin-bottom: 1rem;
}

.ad-modal-content h3 {
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
}

.ad-modal-content p {
  font-size: 0.95rem;
  margin-bottom: 1rem;
  color: #333;
}

.ad-modal-content a {
  display: inline-block;
  padding: 0.5rem 1rem;
  background: #0078D4;
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  font-weight: bold;
}

.ad-close {
  position: absolute;
  top: 0.5rem;
  right: 0.75rem;
  font-size: 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
}

@keyframes adPopIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}


.ad-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.6);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 1000;
}

.ad-grid {
  background: #fff;
  padding: 2rem;
  border-radius: 10px;
  max-width: 1000px;
  width: 95%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.5rem;
  position: relative;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  animation: adPopIn 0.3s ease-out;
}

.ad-card {
  background: #f9f9f9;
  border-radius: 6px;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.ad-card img {
  width: 100%;
  max-width: 120px;
  margin-bottom: 0.5rem;
  border-radius: 4px;
}

.ad-card h4 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #333;
}

.ad-card a {
  display: inline-block;
  padding: 0.4rem 0.8rem;
  background: #0078D4;
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 0.85rem;
  font-weight: bold;
}

.ad-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-size: 1.5rem;
  background: none;
  border: none;
  cursor: pointer;
  color: #333;
}

@keyframes adPopIn {
  from {
    transform: scale(0.9);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.ad-heading {
  position: fixed;
  top: 3%;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: #fff;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 1.5rem;
  font-weight: 600;
  color: #222;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  z-index: 1001; /* above modal backdrop */
}

.ad-heading.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Desktop Navbar */
header {
  background: #ffffff;
  border-bottom: 1px solid #ddd;
  padding: 1rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  margin: 0;
  font-size: 1.5rem;
}

nav {
  display: flex;
  gap: 1rem;
}

nav a {
  text-decoration: none;
  color: #4a90e2;
  font-weight: bold;
  position: relative;
  padding: 0.5rem 1rem;
}

nav a::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0%;
  height: 2px;
  background: #4a90e2;
  transition: width 0.3s ease;
}

nav a:hover::after {
  width: 100%;
}

.mobile-nav {
  display: none;
}

/* Mobile nav styles */
@media (max-width: 768px) {
  header {
    display: none;
  }

  .mobile-nav {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #fff;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  }

  .mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
  }

  .mobile-nav-header h1 {
    font-size: 1.2rem;
    margin: 0;
  }

  .hamburger {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #4a90e2;
  }

  .mobile-nav-links {
    display: none;
    flex-direction: column;
    padding: 0 1rem 1rem 1rem;
  }

  .mobile-nav-links a {
    text-decoration: none;
    color: #4a90e2;
    font-weight: bold;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
  }

  .hero {
    padding-top: 10rem;
  }
}

/* Mobile nav hidden by default */
.mobile-nav {
  display: none;
}

/* Mobile nav styles */
@media (max-width: 768px) {
  header {
    display: none;
  }

  .mobile-nav {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background: #fff;
    z-index: 1000;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
  }

  .mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
  }

  .mobile-nav-header h1 {
    font-size: 1.2rem;
    margin: 0;
  }

  .hamburger {
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
    color: #4a90e2;
  }

  .mobile-nav-links {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.4s ease;
    padding: 0 1rem;
  }

  .mobile-nav-links a {
    text-decoration: none;
    color: #4a90e2;
    font-weight: bold;
    padding: 0.75rem 0;
    border-bottom: 1px solid #eee;
  }

  .mobile-nav-links.open {
    max-height: 500px; /* Enough to show all links */
  }

  .hero {
    padding-top: 10rem;
  }
}

.seo-description {
  text-align: center;
  margin-left: 7%;
  margin-right: 7%;
  font-size: 1rem;
  color: #444;

  opacity: 0;
  transform: translateY(20px);
  animation: fadeInUp 0.6s ease forwards;
  animation-delay: 0.4s;
}

@media (max-width: 768px) {
  .main-content {
    padding: 2rem 1rem;
  }

  h1 {
    font-size: 1.4rem;
    margin-bottom: 1.5rem;
  }

  .seo-description {
    font-size: 0.95rem;
    margin-left: 5%;
    margin-right: 5%;
  }
}

@media screen and (max-width: 768px) {
  .main-content {
    padding-top: 120px; /* Adjust based on mobile navbar height */
  }
}

@media (max-width: 768px) {
  .ad-grid {
    grid-template-columns: repeat(2, 1fr); /* fewer columns */
    padding: 1rem;
    gap: 1rem;
    width: 90%;
    max-width: 100%;
    border-radius: 6px;
  }

  .ad-card img {
    max-width: 100px;
  }

  .ad-heading {
    font-size: 1.2rem;
    padding: 0.5rem;
    top: 1rem;
  }

  .ad-modal-content {
    width: 95%;
    max-width: 320px;
    padding: 1rem;
  }

  .ad-close {
    top: 0.25rem;
    right: 0.5rem;
    font-size: 1.2rem;
  }

    .ad-modal {
    align-items: flex-start;
    padding-top: 4rem;
    overflow-y: auto;
  }

  .ad-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    max-height: calc(100vh - 8rem);
    overflow-y: auto;
    padding: 1rem;
  }

  .ad-card {
    padding: 0.75rem;
  }

  .ad-card img {
    max-width: 80px;
  }

}

@media (max-width: 768px) {
  #search {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto 2rem auto;
    padding: 0.75rem;
    font-size: 1rem;
  }
}