/* ========== PORTFOLIO PAGE SPECIFIC STYLES ========== */
:root {
  /* Color Palette from main CSS */
  --primary: #191970; /* Midnight Blue */
  --primary-light: #2a2a9a;
  --primary-dark: #0f0f45;
  --accent: #ffd700; /* Gold */
  --accent-light: #ffe347;
  --accent-dark: #e6c200;
  --text: #333333;
  --text-light: #666666;
  --text-dark: #111111;
  --background: #ffffff;
  --background-alt: #f8f9fa;
  --border-color: #e9ecef;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --shadow-color-hover: rgba(0, 0, 0, 0.2);
  --overlay-gradient: linear-gradient(135deg, rgba(25, 25, 112, 0.8), rgba(25, 25, 112, 0.6));
  --arrow-icon-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23191970' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17l9.2-9.2M17 17V7H7'/%3E%3C/svg%3E");
  --arrow-icon-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffd700' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17l9.2-9.2M17 17V7H7'/%3E%3C/svg%3E");
  --transition-normal: 0.3s ease;
  --transition-bounce: cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Dark mode variables with enhanced deep gold */
@media (prefers-color-scheme: dark) {
  :root {
    /* Deep, luxurious gold palette */
    --primary: #a67c00; /* Deeper, richer gold base color */
    --primary-light: #d4af37; /* Rich gold */
    --primary-dark: #704700; /* Dark amber gold */
    --primary-highlight: #f9df85; /* Light gold for accents */
    --accent: #191970; /* Midnight Blue in dark mode (swapped with primary) */
    --accent-light: #2a2a9a;
    --accent-dark: #0f0f45;
    --text: #e0e0e0;
    --text-light: #b0b0b0;
    --text-dark: #ffffff;
    --background: #121212;
    --background-alt: #1e1e1e;
    --border-color: #333333;
    --shadow-color: rgba(0, 0, 0, 0.3);
    --shadow-color-hover: rgba(0, 0, 0, 0.4);
    /* Enhanced gold overlay gradient */
    --overlay-gradient: linear-gradient(135deg, rgba(166, 124, 0, 0.8), rgba(212, 175, 55, 0.6));
    /* Arrow icons for dark mode */
    --arrow-icon-light: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a67c00' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17l9.2-9.2M17 17V7H7'/%3E%3C/svg%3E");
    --arrow-icon-dark: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23191970' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17l9.2-9.2M17 17V7H7'/%3E%3C/svg%3E");
    /* Gold gradients for effects */
    --gold-gradient: linear-gradient(
      135deg,
      #704700 0%,
      #a67c00 20%,
      #d4af37 40%,
      #f9df85 50%,
      #d4af37 60%,
      #a67c00 80%,
      #704700 100%
    );
    --gold-gradient-simple: linear-gradient(135deg, #704700, #a67c00, #d4af37, #f9df85);
  }
}

/* Portfolio Page Header */
.portfolio-header {
  text-align: center;
  margin: 120px auto 40px;
  max-width: 800px;
  padding: 0 20px;
}

.portfolio-header h1 {
  color: var(--primary);
  font-size: 2.5rem;
  margin-bottom: 15px;
  position: relative;
  display: inline-block;
  transition: color var(--transition-normal);
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.portfolio-header h1::after {
  content: "";
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 4px;
  background: linear-gradient(to right, var(--primary), var(--accent));
  border-radius: 2px;
  transition: background var(--transition-normal);
}

.portfolio-header p {
  color: var(--text-light);
  font-size: 1.1rem;
  line-height: 1.6;
  transition: color var(--transition-normal);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Enhanced Portfolio Grid - Optimized for 6 blocks */
.portfolio-grid {
  display: grid;
  /* Explicitly set to 3 columns for desktop, overriding any auto-fit rules */
  grid-template-columns: repeat(3, 1fr);
  gap: 30px;
  padding: 20px;
  /* Increased max-width for a more "full screen" feel on large desktops */
  max-width: 1600px;
  margin: 80px auto 60px;
  /* Ensure items stretch to fill the row height */
  align-items: stretch;
}

.portfolio-item {
  background-color: var(--background-alt);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 30px var(--shadow-color);
  transition: all 0.4s var(--transition-bounce), background-color var(--transition-normal);
  position: relative;
  cursor: pointer;
  /* Adjusted min-height for a more rectangular, less tall look on desktop */
  min-height: 200px; /* Further reduced for a less tall appearance */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 30px;
  text-align: center;
  border: 1px solid var(--border-color);
}

.portfolio-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-gradient);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 1;
  border-radius: inherit;
}

.portfolio-item:hover {
  transform: translateY(-15px);
  box-shadow: 0 15px 35px var(--shadow-color-hover);
}

.portfolio-item:hover::before {
  opacity: 1;
}

.portfolio-item h2 {
  color: var(--primary);
  font-size: 1.8rem;
  margin-bottom: 15px;
  position: relative;
  z-index: 2;
  transition: color 0.4s ease, transform 0.4s ease;
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.portfolio-item p {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.6;
  z-index: 2;
  position: relative;
  transition: color 0.4s ease, transform 0.4s ease;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* CHANGED: Text color to gold instead of white on hover for better readability */
.portfolio-item:hover h2,
.portfolio-item:hover p {
  color: var(--accent); /* Gold color instead of white */
  transform: translateY(-5px);
}

/* Portfolio Item Icon */
.portfolio-item::after {
  content: "";
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 40px;
  height: 40px;
  background-image: var(--arrow-icon-light);
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease, background-image var(--transition-normal);
  z-index: 2;
}

.portfolio-item:hover::after {
  opacity: 1;
  transform: translateY(0);
  background-image: var(--arrow-icon-dark);
}

/* Portfolio Item Unique Styling - Extended for 6 items */
.portfolio-item:nth-child(1) {
  background-color: var(--background-alt);
  border-top: 4px solid var(--primary);
}

.portfolio-item:nth-child(2) {
  background-color: var(--background);
  border-top: 4px solid var(--accent);
}

.portfolio-item:nth-child(3) {
  background-color: var(--background-alt);
  border-top: 4px solid var(--primary-light);
}

.portfolio-item:nth-child(4) {
  background-color: var(--background);
  border-top: 4px solid var(--accent-light);
}

.portfolio-item:nth-child(5) {
  background-color: var(--background-alt);
  border-top: 4px solid var(--primary-dark);
}

.portfolio-item:nth-child(6) {
  background-color: var(--background); /* Alternating background */
  border-top: 4px solid var(--accent-dark); /* New border color for 6th item */
}

/* Animated Background */
.portfolio {
  position: relative;
  overflow: hidden;
  background-color: var(--background);
  transition: background-color var(--transition-normal);
}

.portfolio::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 10% 10%, rgba(25, 25, 112, 0.03) 0%, transparent 60%),
    radial-gradient(circle at 90% 90%, rgba(255, 215, 0, 0.03) 0%, transparent 60%);
  z-index: -1;
  transition: background var(--transition-normal);
}

/* Dark mode background adjustment */
@media (prefers-color-scheme: dark) {
  .portfolio::before {
    background: radial-gradient(circle at 10% 10%, rgba(166, 124, 0, 0.05) 0%, transparent 60%),
      radial-gradient(circle at 90% 90%, rgba(25, 25, 112, 0.03) 0%, transparent 60%);
  }

  /* Enhanced gold styling for portfolio header */
  .portfolio-header h1 {
    background: var(--gold-gradient-simple);
    background-size: 200% auto;
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent !important;
    animation: portfolioGoldShimmer 8s linear infinite;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    position: relative;
  }

  /* Add subtle glitter effect to header */
  .portfolio-header h1::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(circle at 20% 30%, rgba(249, 223, 133, 0.7) 0.1%, transparent 0.5%),
      radial-gradient(circle at 50% 70%, rgba(249, 223, 133, 0.5) 0.1%, transparent 0.5%),
      radial-gradient(circle at 80% 10%, rgba(249, 223, 133, 0.7) 0.1%, transparent 0.5%),
      radial-gradient(circle at 10% 90%, rgba(249, 223, 133, 0.5) 0.1%, transparent 0.5%);
    background-size: 150% 150%;
    mix-blend-mode: overlay;
    animation: glitterEffect 6s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
  }

  /* Enhanced gold gradient for header underline */
  .portfolio-header h1::after {
    background: var(--gold-gradient-simple);
    background-size: 200% 200%;
    animation: portfolioGoldShimmer 8s linear infinite;
  }

  /* Add gold glow to portfolio items on hover */
  .portfolio-item:hover {
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.3), 0 0 20px rgba(166, 124, 0, 0.15);
  }

  /* Enhance portfolio item borders with gold */
  /* Adjusted for 6 items to maintain the alternating pattern */
  .portfolio-item:nth-child(3n + 1) {
    border-top: 4px solid var(--primary);
  }
  .portfolio-item:nth-child(3n + 2) {
    border-top: 4px solid var(--accent);
  }
  .portfolio-item:nth-child(3n) {
    border-top: 4px solid var(--primary-light); /* Using primary-light for the third column item */
  }
  /* Specific overrides for the 4th, 5th, 6th items to match original intent if needed,
     otherwise the 3n+1, 3n+2, 3n pattern will cycle */
  .portfolio-item:nth-child(4) {
    border-top: 4px solid var(--accent-light);
  }
  .portfolio-item:nth-child(5) {
    border-top: 4px solid var(--primary-dark);
  }
  .portfolio-item:nth-child(6) {
    border-top: 4px solid var(--accent-dark);
  }
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columns for medium screens */
    gap: 25px;
  }
  .portfolio-item {
    min-height: 180px; /* Adjusted min-height for 2-column layout */
  }
}

@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr; /* Force 1 column for tablets and smaller */
    gap: 20px;
    padding: 15px;
  }

  .portfolio-header h1 {
    font-size: 2rem;
  }

  .portfolio-item {
    min-height: 160px; /* Adjusted min-height for smaller screens */
    padding: 20px;
  }

  .portfolio-item h2 {
    font-size: 1.5rem;
  }
}

@media (max-width: 480px) {
  .portfolio-grid {
    grid-template-columns: 1fr; /* Single column for small mobile screens */
    padding: 10px; /* Reduced padding for full width feel */
    gap: 15px; /* Reduced gap for mobile */
  }

  .portfolio-header h1 {
    font-size: 1.8rem;
  }
  .portfolio-item {
    min-height: 140px; /* Adjusted min-height for single column on mobile */
    padding: 15px; /* Adjusted padding for mobile */
  }
}

/* Animation Classes */
.fade-in {
  animation: fadeIn 0.8s ease forwards;
}

.slide-up {
  animation: slideUp 0.8s ease forwards;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

/* Gold effect animations */
@keyframes portfolioGoldShimmer {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

@keyframes portfolioGlitterEffect {
  0% {
    background-position: 0% 0%;
  }
  25% {
    background-position: 100% 0%;
  }
  50% {
    background-position: 100% 100%;
  }
  75% {
    background-position: 0% 100%;
  }
  100% {
    background-position: 0% 0%;
  }
}

/* Staggered Animation Delays */
.delay-1 {
  animation-delay: 0.1s;
}

.delay-2 {
  animation-delay: 0.2s;
}

.delay-3 {
  animation-delay: 0.3s;
}

.delay-4 {
  animation-delay: 0.4s;
}

.delay-5 {
  animation-delay: 0.5s;
}

.delay-6 {
  animation-delay: 0.6s; /* Added delay for the 6th item */
}

/* ========== PORTFOLIO ITEM FIXES ========== */
/* Make sure portfolio items are clearly interactive */
.portfolio-item {
  cursor: pointer !important;
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease !important;
  position: relative;
  z-index: 1;
}

/* Add a subtle indicator that items are clickable */
.portfolio-item::after {
  content: "";
  position: absolute;
  bottom: 15px;
  right: 15px;
  width: 30px;
  height: 30px;
  background-image: var(--arrow-icon-light);
  background-size: contain;
  background-repeat: no-repeat;
  opacity: 0.7;
  transition: opacity 0.3s ease, transform 0.3s ease, background-image var(--transition-normal);
  z-index: 2;
}

.portfolio-item:hover::after {
  opacity: 1;
  transform: translateY(-5px);
  background-image: var(--arrow-icon-dark);
}

/* Ensure text remains readable on hover */
.portfolio-item:hover h2,
.portfolio-item:hover p {
  color: var(--accent) !important; /* Force accent color for better visibility */
}

/* Add a subtle overlay on hover */
.portfolio-item::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--overlay-gradient);
  opacity: 0;
  transition: opacity 0.3s ease, background var(--transition-normal);
  z-index: 1;
  border-radius: inherit;
}

.portfolio-item:hover::before {
  opacity: 1;
}

/* Make sure text is above the overlay */
.portfolio-item h2,
.portfolio-item p {
  position: relative;
  z-index: 2;
  transition: color 0.3s ease, transform 0.3s ease;
}

/* Add a subtle lift effect on hover */
.portfolio-item:hover {
  transform: translateY(-15px) !important;
  box-shadow: 0 15px 35px var(--shadow-color-hover) !important;
}

/* Ensure the portfolio grid has proper spacing */
.portfolio-grid {
  margin-top: 80px;
  padding: 2rem;
  display: grid;
  /* Explicitly set to 3 columns for larger screens */
  grid-template-columns: repeat(3, 1fr);
  gap: 2rem;
  position: relative;
  align-items: stretch;
}

/* Ensure portfolio items have consistent height */
.portfolio-item {
  min-height: 200px; /* Adjusted for consistent rectangular height on desktop */
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 2rem;
  text-align: center;
  background-color: var(--background-alt);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: background-color var(--transition-normal), border-color var(--transition-normal);
}

/* Active state for portfolio items */
.portfolio-item.active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(var(--primary), 0.3);
}

/* Responsive adjustments */
@media (max-width: 1200px) {
  .portfolio-grid {
    grid-template-columns: repeat(2, 1fr); /* 2 columns for medium screens */
  }
  .portfolio-item {
    min-height: 180px;
  }
}

@media (max-width: 768px) {
  .portfolio-grid {
    grid-template-columns: 1fr; /* Force 1 column for tablets and smaller */
    gap: 1.5rem;
    padding: 1.5rem;
  }

  .portfolio-item {
    min-height: 160px;
    padding: 1.5rem;
  }
}

@media (max-width: 480px) {
  .portfolio-grid {
    grid-template-columns: 1fr;
    padding: 10px; /* Reduced padding for full width feel */
    gap: 15px; /* Reduced gap for mobile */
  }
  .portfolio-item {
    min-height: 140px;
    padding: 15px;
  }
}

/* Manual dark mode class for JavaScript toggling */
.dark-mode .portfolio-header h1 {
  color: var(--primary);
}

.dark-mode .portfolio-header p {
  color: var(--text-light);
}

.dark-mode .portfolio {
  background-color: var(--background);
}

.dark-mode .portfolio::before {
  background: radial-gradient(circle at 10% 10%, rgba(166, 124, 0, 0.05) 0%, transparent 60%),
    radial-gradient(circle at 90% 90%, rgba(25, 25, 112, 0.03) 0%, transparent 60%);
}

.dark-mode .portfolio-item {
  background-color: var(--background-alt);
  border-color: var(--border-color);
  box-shadow: 0 10px 30px var(--shadow-color);
}

.dark-mode .portfolio-item:hover {
  box-shadow: 0 15px 35px var(--shadow-color-hover), 0 0 20px rgba(166, 124, 0, 0.15);
}

.dark-mode .portfolio-item h2 {
  color: var(--primary);
}

.dark-mode .portfolio-item p {
  color: var(--text);
}

.dark-mode .portfolio-item::after {
  background-image: var(--arrow-icon-light);
}

.dark-mode .portfolio-item:hover::after {
  background-image: var(--arrow-icon-dark);
}

.dark-mode .portfolio-item::before {
  background: var(--overlay-gradient);
}

.dark-mode .portfolio-item.active {
  border-color: var(--primary);
}

/* Fix for portfolio item hover text in dark mode */
@media (prefers-color-scheme: dark) {
  /* Make heading text gold on hover for better visibility */
  .portfolio-item:hover h2 {
    color: var(--primary) !important; /* Gold color in dark mode */
  }

  /* Make paragraph text white on hover for better readability */
  .portfolio-item:hover p {
    color: #ffffff !important; /* White color for better readability */
  }

  /* Ensure the overlay gradient works well with the new text colors */
  .portfolio-item::before {
    background: linear-gradient(135deg, rgba(25, 25, 112, 0.8), rgba(25, 25, 112, 0.6));
  }
}

/* For manually toggled dark mode */
.dark-mode .portfolio-item:hover h2 {
  color: var(--primary) !important; /* Gold color in dark mode */
}

.dark-mode .portfolio-item:hover p {
  color: #ffffff !important; /* White color for better readability */
}

.portfolio-item-tag {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page-title {
  font-family: "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.page-description,
.portfolio-item-description {
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
