/* Portfolio Flex Layout */
.rt-portfolio-flex {
  width: 100%;
}

.portfolio-flex-container {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: flex-start;
}

/* Each portfolio item - using proper gap-aware calculations */
.portfolio-flex-item {
  flex: 0 1 calc(33.333% - 14px); /* default 3 columns - accounts for gap */
  min-width: 0; /* prevents flex items from overflowing */
  box-sizing: border-box;
  display: flex;
}

/* Dynamic columns via data attribute */
.rt-portfolio-flex[data-columns="1"] .portfolio-flex-item {
  flex: 0 1 100%;
}

.rt-portfolio-flex[data-columns="2"] .portfolio-flex-item {
  flex: 0 1 calc(50% - 10px);
}

.rt-portfolio-flex[data-columns="3"] .portfolio-flex-item {
  flex: 0 1 calc(33.333% - 14px);
}

.rt-portfolio-flex[data-columns="4"] .portfolio-flex-item {
  flex: 0 1 calc(25% - 15px);
}

/* Responsive breakpoints */
@media (max-width: 1024px) {
  .rt-portfolio-flex[data-columns="4"] .portfolio-flex-item {
    flex: 0 1 calc(33.333% - 14px); /* fallback to 3 cols */
  }
}

@media (max-width: 768px) {
  .rt-portfolio-flex[data-columns] .portfolio-flex-item {
    flex: 0 1 calc(50% - 10px); /* 2 columns */
  }

  .portfolio-flex-container {
    gap: 15px; /* reduce gap on tablets */
  }
}

@media (max-width: 480px) {
  .rt-portfolio-flex[data-columns] .portfolio-flex-item {
    flex: 0 1 100%; /* 1 column on mobile */
  }

  .portfolio-flex-container {
    gap: 20px;
  }
}

/* Portfolio Item Styling */
.portfolio-item {
  position: relative;
  width: 100%;
  overflow: hidden;
  background: #fff;
  border-radius: 8px;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.portfolio-item:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

/* Focus state for accessibility */
.portfolio-item:focus-within {
  outline: 2px solid var(--e-global-color-primary, #222);
  outline-offset: 2px;
}

.portfolio-img {
  position: relative;
  overflow: hidden;
  background: #f5f5f5; /* placeholder color while loading */
  aspect-ratio: 16 / 9; /* maintain consistent aspect ratio */
}

.portfolio-img a {
  display: block;
  width: 100%;
  height: 100%;
}

.portfolio-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.4s ease;
}

.portfolio-item:hover .portfolio-img img {
  transform: scale(1.08);
}

/* Overlay content */
.portfolio-content {
  padding: 20px;
  text-align: left;
  flex: 1; /* allows content to grow and push button to bottom */
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.p-category {
  font-size: 13px;
  margin: 0;
  color: #777;
  line-height: 1.4;
}

.p-category a {
  color: inherit;
  text-decoration: none;
  transition: color 0.3s ease;
}

.p-category a:hover,
.p-category a:focus {
  color: var(--e-global-color-accent, #ff6600);
}

.p-category .separator {
  margin: 0 4px;
  color: #ddd;
}

.p-title {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
}

.p-title a {
  text-decoration: none;
  color: #222;
  transition: color 0.3s ease;
  display: inline-block;
}

.p-title a:hover,
.p-title a:focus {
  color: var(--e-global-color-accent, #ff6600);
  outline: none;
}

.portfolio-text {
  font-size: 14px;
  line-height: 1.6;
  color: #555;
  margin: 0;
}

/* Button */
.read-btn.link-button {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--e-global-color-primary, #222);
  color: #fff;
  text-decoration: none;
  border-radius: 4px;
  transition: background 0.3s ease, transform 0.2s ease;
  box-sizing: border-box;
}

.read-btn.link-button:hover {
  background: var(--e-global-color-accent, #ff6600);
  transform: translateY(-2px);
}

.read-btn.link-button:focus {
  outline: 2px solid var(--e-global-color-accent, #ff6600);
  outline-offset: 2px;
}

.read-btn.link-button:active {
  transform: translateY(0);
}

.read-btn .f-right {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
}

.read-btn .rt-arrow-right-long {
  transition: transform 0.3s ease;
}

.read-btn:hover .rt-arrow-right-long {
  transform: translateX(4px);
}

/* Empty state */
.elementor-alert {
  padding: 15px 20px;
  border-radius: 4px;
  margin: 20px 0;
}

.elementor-alert-warning {
  background: #fff3cd;
  border-left: 4px solid #ffc107;
  color: #856404;
}

.elementor-alert-info {
  background: #d1ecf1;
  border-left: 4px solid #17a2b8;
  color: #0c5460;
}

/* Loading skeleton (optional enhancement) */
.portfolio-img.loading {
  position: relative;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s ease-in-out infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Print styles */
@media print {
  .portfolio-item {
    break-inside: avoid;
    box-shadow: none;
    border: 1px solid #ddd;
  }

  .portfolio-item:hover {
    transform: none;
  }

  .read-btn.link-button {
    display: none;
  }
}
