.projects-portfolio-section {
  background: linear-gradient(180deg, #000000 0%, #060B16 25%, #0A1222 65%, #111827 100%);
  position: relative;
  padding: 40px clamp(20px, 4vw, 48px) 100px;
  min-height: 70vh;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
}

.portfolio-container {
  max-width: 1360px;
  margin-inline: auto;
  width: 100%;
}

/* Filter & Controls Toolbar */
.portfolio-filter-wrapper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 18px;
  margin-bottom: 44px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.portfolio-filter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.filter-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 20px;
  border-radius: 40px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.filter-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #FFFFFF;
  border-color: rgba(255, 255, 255, 0.28);
  transform: translateY(-1px);
}

.filter-btn.active {
  background: #0F62FE;
  color: #FFFFFF;
  border-color: #0F62FE;
  box-shadow: 0 4px 18px rgba(15, 98, 254, 0.45);
}

.filter-count {
  font-size: 11px;
  font-weight: 700;
  opacity: 0.75;
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 7px;
  border-radius: 12px;
}

.filter-btn.active .filter-count {
  background: rgba(255, 255, 255, 0.25);
  opacity: 1;
}

.portfolio-hint-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 8px 16px;
  border-radius: 30px;
}

.portfolio-hint-badge svg {
  color: #0F62FE;
  flex-shrink: 0;
}

/* Cards Grid */
.portfolio-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

@media (max-width: 1120px) {
  .portfolio-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 740px) {
  .portfolio-filter-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 6px;
  }
  .portfolio-filter-nav::-webkit-scrollbar {
    display: none;
  }
  .filter-btn {
    flex-shrink: 0;
    padding: 8px 16px;
    font-size: 13px;
  }
  .portfolio-cards-grid {
    grid-template-columns: 1fr;
    gap: 16px;
  }
  .card-face {
    padding: 22px 18px;
  }
  .card-title {
    font-size: 19px;
    margin-bottom: 8px;
  }
  .card-section-text {
    font-size: 13.5px;
    line-height: 1.45;
  }
}

/* Card Item (Container with 3D perspective) */
.portfolio-card-item {
  perspective: 1200px;
  min-height: 480px;
  height: 480px;
  transition: opacity 0.35s ease, transform 0.35s ease;
  outline: none;
}

.portfolio-card-item.is-hidden {
  display: none;
}

/* Card Flipper Inner */
.card-flipper {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.2, 0.85, 0.3, 1);
  border-radius: 22px;
  cursor: pointer;
}

.card-flipper:hover {
  transform: translateY(-6px);
}

.card-flipper.is-flipped {
  transform: rotateY(180deg);
}

.card-flipper.is-flipped:hover {
  transform: rotateY(180deg) translateY(-6px);
}

/* Universal Card Faces */
.card-face {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 22px;
  padding: 34px 32px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-sizing: border-box;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 98, 254, 0.25) transparent;
}

.card-face::-webkit-scrollbar {
  width: 5px;
}

.card-face::-webkit-scrollbar-thumb {
  background: rgba(15, 98, 254, 0.25);
  border-radius: 10px;
}

/* FRONT FACE: Clean white card matching reference */
.card-front {
  background: #FFFFFF;
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.28), 0 2px 6px rgba(0, 0, 0, 0.08);
  color: #111827;
  z-index: 2;
}

/* BACK FACE: Matching white card with Cirrus Blue structure & accent border */
.card-back {
  background: #FFFFFF;
  border: 1.5px solid #BFDBFE;
  box-shadow: 0 20px 45px rgba(15, 98, 254, 0.2), 0 4px 12px rgba(0, 0, 0, 0.1);
  color: #111827;
  transform: rotateY(180deg);
  z-index: 1;
}

/* Top Row Layout */
.card-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}

.card-category-tag {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #4B5563;
  background: #F3F4F6;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid #E5E7EB;
}

.card-flip-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #F3F4F6;
  color: #6B7280;
  border: 1px solid #E5E7EB;
  transition: all 0.25s ease;
}

.card-flipper:hover .card-flip-pill {
  background: #0F62FE;
  color: #FFFFFF;
  border-color: #0F62FE;
  transform: rotate(180deg);
}

/* Card Main Body Content */
.card-main-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 23px;
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: #0F172A;
  margin: 0 0 16px 0;
}

.card-section-label {
  font-family: var(--font-body);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0F62FE;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-section-text {
  font-family: var(--font-body);
  font-size: 14.5px;
  line-height: 1.6;
  color: #475569;
  margin: 0;
  font-weight: 400;
}

/* Bottom Action Row */
.card-bottom-row {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid #F1F5F9;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-action-btn {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #64748B;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: color 0.25s ease, gap 0.25s ease;
}

.card-flipper:hover .card-action-btn {
  color: #0F62FE;
  gap: 12px;
}

.card-action-btn svg {
  transition: transform 0.25s ease;
}

.card-flipper:hover .card-action-btn svg {
  transform: translateX(4px);
}

/* Back Face Specifics */
.back-badge {
  background: #EFF6FF;
  color: #0F62FE;
  border: 1px solid #BFDBFE;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 20px;
}

.back-return-btn {
  background: #F1F5F9;
  border: 1px solid #E2E8F0;
  color: #475569;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.back-return-btn:hover {
  background: #0F62FE;
  color: #FFFFFF;
  border-color: #0F62FE;
}

.back-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.015em;
  color: #0F172A;
  margin: 0 0 14px 0;
}

.solution-block {
  margin-bottom: 14px;
}

.solution-block .card-section-label {
  color: #0F62FE;
}

.solution-block .card-section-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: #334155;
}

.bottomline-box {
  background: #F0F7FF;
  border: 1px solid #D0E2FF;
  border-left: 4px solid #0F62FE;
  border-radius: 10px;
  padding: 12px 14px;
}

.bottomline-box .card-section-label {
  color: #0043CE;
  font-size: 10.5px;
  margin-bottom: 4px;
}

.bottomline-box .card-section-text {
  font-size: 13px;
  line-height: 1.5;
  color: #1E293B;
  font-weight: 500;
}

.back-bottom-row {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.return-action-link {
  background: none;
  border: none;
  padding: 0;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0F62FE;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: gap 0.25s ease;
}

.return-action-link:hover {
  gap: 12px;
}

.return-action-link svg {
  transition: transform 0.25s ease;
}

.return-action-link:hover svg {
  transform: translateX(-4px);
}

/* Homepage work teaser */
#work-teaser.projects-portfolio-section {
  min-height: auto;
  padding-top: 100px;
}

#work-teaser .section-head h2 {
  color: #FFFFFF;
}

#work-teaser .work-teaser-cta {
  text-align: center;
  margin-top: 48px;
}

/* Mobile: content-height cards with tap-to-swap (no 3D flip) */
@media (max-width: 740px) {
  .portfolio-card-item {
    height: auto;
    min-height: 0;
    perspective: none;
  }

  .card-flipper {
    height: auto;
    transform-style: flat;
    transition: none;
  }

  .card-flipper:hover,
  .card-flipper.is-flipped,
  .card-flipper.is-flipped:hover {
    transform: none;
  }

  .card-flipper:hover .card-flip-pill {
    transform: none;
  }

  .card-face {
    position: relative;
    inset: auto;
    height: auto;
    overflow-y: visible;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
  }

  .card-back {
    display: none;
    transform: none;
  }

  .card-flipper.is-flipped .card-front {
    display: none;
  }

  .card-flipper.is-flipped .card-back {
    display: flex;
  }

  .card-bottom-row {
    margin-top: 18px;
  }
}
