
/* ===============================
   Portfolio PAGE SECTION STYLES
   =============================== */
/* Reset */
*,
*::before,
*::after {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  margin: 0;
  font-family: 'Poppins', sans-serif;
  background: #f5f7fa;
  color: #222831;
  min-height: 100vh;
  line-height: 1.65;
}

/* ========= CONTAINER ========= */
.kf-container {
  max-width: 1100px;
  width: 100%;
  margin: 8rem auto 4rem;
  padding: 2.5rem 2rem 3rem;
  box-sizing: border-box;
  position: relative;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(22px) saturate(180%);
  -webkit-backdrop-filter: blur(22px) saturate(180%);
  border-radius: 32px;
  border: 1px solid rgba(48, 71, 94, 0.06);
  box-shadow:
    0 8px 40px rgba(48, 71, 94, 0.06),
    0 1px 3px rgba(48, 71, 94, 0.03);
  overflow: hidden;
  transition: box-shadow 0.5s ease, border-color 0.5s ease;
}

.kf-container:hover {
  box-shadow:
    0 12px 50px rgba(48, 71, 94, 0.12),
    0 2px 6px rgba(48, 71, 94, 0.06);
  border-color: rgba(48, 71, 94, 0.14);
}

/* Cursor-following glow — positioned by JS */
.kf-container::before {
  content: "";
  position: absolute;
  width: 400px;
  height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(48, 71, 94, 0.07) 0%, transparent 70%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  left: var(--glow-x, 50%);
  top: var(--glow-y, 50%);
  opacity: 0;
  transition: opacity 0.4s ease;
  z-index: 0;
}

.kf-container.kf-glow-active::before {
  opacity: 1;
}

/* Floating decorative dots */
.kf-container::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(48, 71, 94, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  pointer-events: none;
  z-index: 0;
  opacity: 0.6;
}

/* Corner accent marks */
.kf-corner-accent {
  position: absolute;
  width: 48px;
  height: 48px;
  pointer-events: none;
  z-index: 1;
  opacity: 0.3;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.kf-corner-accent--tl {
  top: 16px; left: 16px;
  border-top: 2px solid #30475e;
  border-left: 2px solid #30475e;
  border-radius: 8px 0 0 0;
}

.kf-corner-accent--tr {
  top: 16px; right: 16px;
  border-top: 2px solid #30475e;
  border-right: 2px solid #30475e;
  border-radius: 0 8px 0 0;
}

.kf-corner-accent--bl {
  bottom: 16px; left: 16px;
  border-bottom: 2px solid #30475e;
  border-left: 2px solid #30475e;
  border-radius: 0 0 0 8px;
}

.kf-corner-accent--br {
  bottom: 16px; right: 16px;
  border-bottom: 2px solid #30475e;
  border-right: 2px solid #30475e;
  border-radius: 0 0 8px 0;
}

.kf-container:hover .kf-corner-accent {
  opacity: 0.55;
}

.kf-container:hover .kf-corner-accent--tl { transform: translate(-3px, -3px); }
.kf-container:hover .kf-corner-accent--tr { transform: translate(3px, -3px); }
.kf-container:hover .kf-corner-accent--bl { transform: translate(-3px, 3px); }
.kf-container:hover .kf-corner-accent--br { transform: translate(3px, 3px); }

/* ========= HEADER ========= */
.kf-portfolio-header {
  text-align: center;
  margin-bottom: 2.5rem;
  user-select: none;
  position: relative;
  z-index: 1;
}

.kf-portfolio-header p {
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  margin-bottom: 0.4rem;
  background: linear-gradient(90deg, #30475e, #3a506b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-family: 'Poppins', sans-serif;
  position: relative;
  display: inline-block;
}

/* Decorative line behind "Selected Works" */
.kf-portfolio-header p::before,
.kf-portfolio-header p::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 50px;
  height: 1px;
  background: linear-gradient(90deg, transparent, #30475e);
  opacity: 0.4;
}

.kf-portfolio-header p::before {
  right: calc(100% + 12px);
  background: linear-gradient(90deg, transparent, #30475e);
}

.kf-portfolio-header p::after {
  left: calc(100% + 12px);
  background: linear-gradient(90deg, #30475e, transparent);
}

.kf-portfolio-header h2 {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin: 0;
  letter-spacing: 0.06em;
  color: #222831;
  position: relative;
  display: inline-block;
}

/* Animated underline for heading */
.kf-portfolio-header h2::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, #30475e, #3a506b);
  border-radius: 4px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1), left 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

.kf-portfolio-header:hover h2::after {
  width: 100%;
  left: 0;
}

/* ========= FILTERS — Glassmorphism bar ========= */
.kf-portfolio-filters {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 2.5rem;
  user-select: none;
  font-weight: 700;
  font-family: 'Poppins', sans-serif;
  position: relative;
  z-index: 1;
  padding: 12px 20px;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 60px;
  border: 1px solid rgba(48, 71, 94, 0.1);
  box-shadow: 0 4px 20px rgba(48, 71, 94, 0.06);
  flex-wrap: wrap;
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
}

.kf-portfolio-filters:hover {
  box-shadow: 0 6px 28px rgba(48, 71, 94, 0.1);
  border-color: rgba(48, 71, 94, 0.18);
}

.kf-filter-btn {
  position: relative;
  padding: 0.5rem 1.5rem;
  color: #30475e;
  border: 2px solid transparent;
  border-radius: 50px;
  background: transparent;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.8rem;
  transition:
    background-color 0.35s ease,
    color 0.35s ease,
    transform 0.3s ease,
    box-shadow 0.35s ease,
    border-color 0.35s ease;
  outline-offset: 3px;
  font-weight: 700;
  font-family: inherit;
  user-select: none;
  z-index: 1;
  white-space: nowrap;
}

.kf-filter-btn:hover,
.kf-filter-btn:focus-visible {
  background-color: rgba(48, 71, 94, 0.08);
  color: #30475e;
  outline: none;
  transform: scale(1.05);
  z-index: 2;
  border-color: rgba(48, 71, 94, 0.2);
}

.kf-filter-btn.active {
  background-color: #30475e;
  color: #f5f7fa;
  cursor: default;
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(48, 71, 94, 0.35);
  border-color: #30475e;
  z-index: 3;
}

.kf-filter-underline {
  position: absolute;
  height: 3px;
  background: #30475e;
  border-radius: 16px;
  filter: drop-shadow(0 0 6px #30475ecc);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1), width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  pointer-events: none;
  left: 0;
  width: 0;
  z-index: 1;
  will-change: transform, width;
  top: 0;
  display: none; /* Hidden — active pill style replaces it */
}

/* ========= GRID ========= */
.kf-portfolio-grid {
  position: relative;
  user-select: none;
  max-width: 1100px;
  margin: 0 auto;
  min-height: 1200px;
  perspective: 1200px;
  z-index: 1;
}

/* Cursor spotlight on the grid */
.kf-grid-spotlight {
  position: absolute;
  width: 500px;
  height: 500px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(145, 166, 255, 0.06) 0%, transparent 70%);
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 0;
  opacity: 0;
  transition: opacity 0.3s ease;
}

/* ========= CARDS ========= */
.kf-portfolio-card {
  position: absolute;
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(145deg, #1a2332, #253649);
  box-shadow:
    0 10px 30px rgba(0, 0, 0, 0.18),
    0 2px 8px rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  transition:
    transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1),
    box-shadow 0.4s ease,
    border-color 0.35s ease,
    top 0.5s ease,
    left 0.5s ease,
    width 0.5s ease,
    height 0.5s ease;
  user-select: none;
  outline-offset: 6px;
  padding: 0;
  z-index: 1;
  will-change: transform;
  transform-style: preserve-3d;

  /* Entrance animation */
  opacity: 0;
  animation: kf-card-entrance 0.6s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.kf-portfolio-card[data-delay="1"] { animation-delay: 0.08s; }
.kf-portfolio-card[data-delay="2"] { animation-delay: 0.16s; }
.kf-portfolio-card[data-delay="3"] { animation-delay: 0.24s; }
.kf-portfolio-card[data-delay="4"] { animation-delay: 0.32s; }
.kf-portfolio-card[data-delay="5"] { animation-delay: 0.40s; }
.kf-portfolio-card[data-delay="6"] { animation-delay: 0.48s; }

@keyframes kf-card-entrance {
  from {
    opacity: 0;
    transform: translateY(30px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Card inner glow on hover */
.kf-portfolio-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 20px;
  background: radial-gradient(
    ellipse at var(--card-glow-x, 50%) var(--card-glow-y, 50%),
    rgba(145, 166, 255, 0.12) 0%,
    transparent 60%
  );
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: 2;
}

.kf-portfolio-card:hover::before {
  opacity: 1;
}

.kf-portfolio-card:hover,
.kf-portfolio-card:focus-visible {
  border-color: rgba(145, 166, 255, 0.3);
  box-shadow:
    0 24px 50px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(145, 166, 255, 0.1),
    inset 0 0 30px rgba(145, 166, 255, 0.06);
  z-index: 10;
  outline: none;
}

/* ========= IMAGE SLIDER ========= */
.kf-image-slider {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.kf-image-slider img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 20px;
  opacity: 0;
  transition: opacity 1s ease-in-out, transform 6s ease;
  pointer-events: none;
}

/* Subtle Ken Burns */
.kf-image-slider img[style*="opacity: 1"],
.kf-image-slider img.kf-active {
  transform: scale(1.05);
}

/* ========= OVERLAY ========= */
.kf-portfolio-overlay {
  position: relative;
  z-index: 3;
  background: linear-gradient(180deg,
      rgba(15, 23, 35, 0) 0%,
      rgba(15, 23, 35, 0.55) 40%,
      rgba(15, 23, 35, 0.88) 75%,
      rgba(15, 23, 35, 0.95) 100%);
  padding: 3rem 1.5rem 1.8rem;
  border-radius: 0 0 20px 20px;
  color: #f5f7fa;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  min-height: 140px;
  overflow: hidden;
  user-select: none;
  transition: background 0.4s ease, box-shadow 0.4s ease, min-height 0.4s ease;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.kf-portfolio-card:hover .kf-portfolio-overlay,
.kf-portfolio-card:focus-within .kf-portfolio-overlay {
  background: linear-gradient(
    180deg,
    rgba(15, 23, 35, 0.6) 0%,
    rgba(15, 23, 35, 0.92) 60%,
    rgba(15, 23, 35, 0.98) 100%
  );
  backdrop-filter: saturate(180%) blur(8px);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  border-top: 1px solid rgba(145, 166, 255, 0.1);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  min-height: 180px;
}

.kf-portfolio-category {
  font-weight: 700;
  font-size: 0.7rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #91a6ff;
  opacity: 0.9;
  margin-bottom: 0.1rem;
  user-select: none;
  font-family: 'Poppins', sans-serif;
  transition: transform 0.3s ease, letter-spacing 0.3s ease;
}

.kf-portfolio-card:hover .kf-portfolio-category {
  transform: translateX(4px);
  letter-spacing: 0.24em;
}

.kf-portfolio-title {
  font-family: 'Playfair Display', serif;
  font-weight: 900;
  font-size: 1.5rem;
  line-height: 1.2;
  margin: 0;
  color: #e9edf6;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.85);
  max-height: 4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
  transition: transform 0.3s ease;
}

.kf-portfolio-card:hover .kf-portfolio-title {
  transform: translateX(4px);
}

.kf-portfolio-desc-teaser {
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  font-style: italic;
  color: #a3b1e1;
  font-size: 0.85rem;
  line-height: 1.5;
  user-select: text;
  margin-top: 0.4rem;
  transition: max-height 0.5s ease, opacity 0.5s ease, transform 0.4s ease;
  transform: translateY(8px);
}

.kf-portfolio-card:hover .kf-portfolio-desc-teaser,
.kf-portfolio-card:focus-within .kf-portfolio-desc-teaser {
  max-height: 6rem;
  opacity: 1;
  overflow-y: auto;
  transform: translateY(0);
}

/* Scrollbar */
.kf-portfolio-desc-teaser::-webkit-scrollbar { width: 4px; }
.kf-portfolio-desc-teaser::-webkit-scrollbar-thumb {
  background-color: #91a6ff;
  border-radius: 4px;
}

/* ========= BUTTON ========= */
.kf-portfolio-button {
  align-self: flex-start;
  padding: 0.5rem 1.4rem;
  font-weight: 700;
  font-size: 0.8rem;
  background: rgba(245, 247, 250, 0.95);
  border-radius: 40px;
  border: 1.5px solid rgba(48, 71, 94, 0.4);
  color: #30475e;
  cursor: pointer;
  user-select: none;
  overflow: hidden;
  transition:
    background-color 0.3s ease,
    color 0.3s ease,
    transform 0.3s cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 0.3s ease,
    opacity 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-family: 'Poppins', sans-serif;
  text-decoration: none;
  margin-top: 0.5rem;
  box-shadow: 0 2px 8px rgba(48, 71, 94, 0.15);
  position: relative;
  z-index: 4;
  opacity: 0;
  transform: translateY(10px);
}

.kf-portfolio-card:hover .kf-portfolio-button,
.kf-portfolio-card:focus-within .kf-portfolio-button {
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0.18s;
}

.kf-portfolio-button:hover,
.kf-portfolio-button:focus-visible {
  background-color: #30475e;
  color: #f5f7fa;
  border-color: #30475e;
  transform: scale(1.06) translateY(-1px) !important;
  outline: none;
  box-shadow:
    0 6px 20px rgba(48, 71, 94, 0.5),
    0 0 0 3px rgba(48, 71, 94, 0.1);
}

/* Arrow icon animation on button hover */
.kf-portfolio-button::after {
  content: " →";
  display: inline-block;
  transition: transform 0.25s ease;
  transform: translateX(0);
}

.kf-portfolio-button:hover::after {
  transform: translateX(4px);
}

/* ========= PROJECT COUNT BADGE ========= */
.kf-project-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  background: rgba(48, 71, 94, 0.06);
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #30475e;
  margin-top: 0.6rem;
  font-family: 'Poppins', sans-serif;
  transition: background 0.3s ease;
}

.kf-project-count .kf-count-num {
  font-weight: 800;
  font-size: 1rem;
  color: #30475e;
  min-width: 18px;
  text-align: center;
  transition: transform 0.3s ease;
}

/* ========= FLOATING PARTICLES ========= */
.kf-particle {
  position: absolute;
  border-radius: 50%;
  background: rgba(48, 71, 94, 0.06);
  pointer-events: none;
  z-index: 0;
  animation: kf-float linear infinite;
}

@keyframes kf-float {
  0%, 100% { transform: translateY(0) translateX(0) scale(1); opacity: 0.4; }
  25% { transform: translateY(-20px) translateX(10px) scale(1.1); opacity: 0.6; }
  50% { transform: translateY(-10px) translateX(-8px) scale(0.95); opacity: 0.3; }
  75% { transform: translateY(-25px) translateX(5px) scale(1.05); opacity: 0.5; }
}


/* ===============================
   RESPONSIVE BREAKPOINTS
   =============================== */

@media (max-width: 1199px) {
  .kf-container {
    max-width: 960px;
    margin-left: 1.5rem;
    margin-right: 1.5rem;
  }

  .kf-portfolio-grid {
    min-height: 1100px;
  }

  .kf-portfolio-card {
    transition: all 0.4s ease;
    transform-origin: top left;
  }

  .kf-portfolio-card:not(:hover):not(:focus-visible) {
    transform: scale(0.95);
  }
}

@media (max-width: 1023px) {
  .kf-container {
    max-width: 720px;
    border-radius: 24px;
    padding: 2rem 1.5rem;
  }

  .kf-portfolio-filters {
    border-radius: 20px;
    padding: 10px 14px;
  }

  .kf-portfolio-grid {
    position: relative !important;
    min-height: unset !important;
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    grid-auto-rows: 340px;
    gap: 24px;
    height: auto !important;
    margin: 0 auto;
  }

  .kf-portfolio-card {
    position: relative !important;
    top: auto !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    transform: none !important;
    margin: 0;
    border-radius: 16px;
    box-shadow:
      0 10px 24px rgba(0, 0, 0, 0.16),
      0 2px 6px rgba(0, 0, 0, 0.06);
    opacity: 1;
    animation: none;
  }

  .kf-portfolio-button {
    opacity: 1;
    transform: none;
  }

  .kf-corner-accent { display: none; }
  .kf-particle { display: none; }
}

@media (max-width: 767px) {
  .kf-container {
    max-width: 100%;
    padding: 1.5rem 1rem;
    margin: 5rem 0.75rem 3rem;
    border-radius: 20px;
  }

  .kf-portfolio-filters {
    gap: 6px;
    padding: 8px 10px;
    border-radius: 16px;
  }

  .kf-filter-btn {
    padding: 0.4rem 1rem;
    font-size: 0.7rem;
  }

  .kf-portfolio-header p::before,
  .kf-portfolio-header p::after { display: none; }

  .kf-portfolio-grid {
    grid-template-columns: 1fr !important;
    grid-auto-rows: auto;
    gap: 20px;
  }

  .kf-portfolio-card {
    width: 100% !important;
    max-width: 100%;
    height: auto !important;
    margin: 0;
    border-radius: 14px;
    min-height: 280px;
  }

  .kf-portfolio-title {
    font-size: 1.25rem;
  }
}
