/* Key Projects — profile section (RTL, indigo accent) */

#key-projects .card-body {
  padding: 16px;
}

/* List — 3-column grid like mockup */
.kp-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* List — full-width stacked cards (must override .kp-list grid) */
.kp-list.kp-list--horizontal {
  display: flex;
  flex-direction: column;
  gap: 16px;
  grid-template-columns: none;
}

.kp-list.kp-list--horizontal .kp-card {
  width: 100%;
}

@media (max-width: 900px) {
  .kp-list {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .kp-list {
    grid-template-columns: 1fr;
  }
}

/* Card — enhanced horizontal layout */
.kp-card {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.05);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.kp-card--enhanced {
  background: #fff;
  border-color: #e2e8f0;
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.04),
    0 6px 20px rgba(15, 23, 42, 0.07);
}

.kp-card--enhanced::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.kp-card--enhanced:hover {
  border-color: #cbd5e1;
  box-shadow:
    0 2px 4px rgba(15, 23, 42, 0.05),
    0 14px 36px rgba(15, 23, 42, 0.11);
  transform: translateY(-2px);
}

.kp-card--enhanced .kp-card-layout {
  padding: 18px 20px 18px 16px;
}

.kp-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e8edf4;
}

.kp-card-footer .kp-tech-tags {
  margin-top: 0;
}

.kp-card-footer .kp-links {
  margin-top: 0;
  padding-top: 0;
}

.kp-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: linear-gradient(135deg, #f3f4f6, #e5e7eb);
  position: relative;
}

.kp-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.kp-card-thumb-placeholder {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #ede9fe 0%, #f3f4f6 100%);
}

.kp-card-body {
  padding: 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.kp-card--grid .kp-card-layout {
  display: block;
}

.kp-card--grid .kp-card-info {
  flex: 1;
}

.kp-card--grid .kp-card-visual {
  display: none;
}

.kp-card--enhanced .kp-card-title {
  font-size: 16px;
  font-weight: 800;
  color: #1e293b;
  margin: 0 0 8px;
  line-height: 1.35;
}

.kp-card--enhanced .kp-card-desc {
  font-size: 13px;
  color: #64748b;
  line-height: 1.7;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kp-card--enhanced .kp-tech-chip {
  padding: 4px 11px;
  border: none;
  border-radius: 999px;
  background: #ede9fe;
  color: #6d28d9;
  font-size: 11.5px;
  font-weight: 700;
}

.kp-card--grid .kp-card-desc {
  font-size: 12px;
  color: #718096;
  line-height: 1.55;
  margin: 0 0 10px;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kp-card--grid .kp-tech-tags {
  margin-top: auto;
}

.kp-card--grid .kp-tech-chip {
  font-size: 11px;
  padding: 3px 10px;
  background: #dbeafe;
  color: #2563eb;
  border: none;
  border-radius: 999px;
}

/* Horizontal: info (RTL right) + gallery (RTL left) */
.kp-card-layout {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 20px;
}

.kp-card-info {
  flex: 1 1 55%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}

.kp-card-visual {
  flex: 0 0 42%;
  max-width: 280px;
  min-width: 160px;
  direction: ltr;
}

.kp-card-actions {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 5;
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.kp-card:hover .kp-card-actions,
.kp-card:focus-within .kp-card-actions {
  opacity: 1;
}

.kp-card-action-btn {
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.96);
  color: #6b7280;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
  transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.kp-card-action-btn:hover {
  color: #6366f1;
  border-color: #c7d2fe;
}

.kp-card-action-btn--danger:hover {
  color: #dc2626;
  border-color: #fecaca;
  background: #fef2f2;
}

/* Gallery — count-specific layouts (LTR inside visual column) */
.kp-card-visual .kp-gallery-grid {
  display: grid;
  gap: 6px;
  width: 100%;
  height: 100%;
  min-height: 140px;
}

.kp-gallery-grid--count-1 {
  grid-template-columns: 1fr;
}

.kp-gallery-grid--count-2 {
  grid-template-columns: 1fr 1fr;
}

.kp-gallery-grid--count-3,
.kp-gallery-grid--count-4,
.kp-gallery-grid--count-many {
  grid-template-columns: 1fr 52px;
}

.kp-gallery-main,
.kp-gallery-cell {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
  background: #f3f4f6;
  padding: 0;
  cursor: pointer;
  min-height: 140px;
  transition: box-shadow 0.2s ease;
}

.kp-gallery-grid--count-3 .kp-gallery-main,
.kp-gallery-grid--count-4 .kp-gallery-main,
.kp-gallery-grid--count-many .kp-gallery-main {
  grid-row: 1 / -1;
}

.kp-gallery-main:hover,
.kp-gallery-cell:hover {
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.12);
}

.kp-gallery-zoom {
  position: absolute;
  bottom: 8px;
  left: 8px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.94);
  color: #6366f1;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
  pointer-events: none;
}

.kp-gallery-side {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 0;
}

.kp-gallery-trigger {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  background: #f3f4f6;
  padding: 0;
  cursor: pointer;
  min-height: 0;
}

.kp-gallery-side .kp-gallery-trigger {
  flex: 1;
}

.kp-gallery-main.kp-gallery-trigger,
.kp-gallery-cell.kp-gallery-trigger {
  border-radius: 12px;
  min-height: 140px;
}

.kp-gallery-trigger img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.35s ease;
}

.kp-gallery-main img,
.kp-gallery-cell img {
  position: absolute;
  inset: 0;
}

.kp-gallery-trigger:hover img {
  transform: scale(1.03);
}

.kp-gallery-more-badge {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.55);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}

.kp-gallery-empty {
  min-height: 140px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px dashed #d1d5db;
  border-radius: 12px;
  background: #f9fafb;
  color: #9ca3af;
  font-size: 12px;
}

/* Content */
.kp-card-title {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 800;
  color: #1f2937;
  line-height: 1.35;
}

.kp-card-desc {
  margin: 0 0 10px;
  font-size: 13px;
  line-height: 1.65;
  color: #6b7280;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Technology / skill chips on cards */
.kp-tech-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.kp-card-info .kp-tech-tags {
  margin-top: 10px;
}

.kp-tech-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 20px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  line-height: 1.3;
}

.kp-tech-chip--editable {
  padding-left: 8px;
}

.kp-tech-chip-rm {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: #f3f4f6;
  color: #6b7280;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.kp-tech-chip-rm:hover {
  background: #fee2e2;
  color: #dc2626;
}

/* Form: technology picker */
#key-projects .kp-tech-picker .skill-ac-wrap {
  position: relative;
  width: 100%;
  margin-top: 6px;
}

#key-projects .kp-tech-picker .skill-ac-inner {
  position: relative;
  width: 100%;
}

#key-projects .kp-tech-picker .profile-skill-add-input {
  width: 100%;
  box-sizing: border-box;
  min-height: 36px;
  padding: 8px 12px;
  font-size: 13px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-family: inherit;
}

.kp-tech-chips-wrap {
  margin: 6px 0 4px;
}

.kp-tech-chips-wrap:empty {
  display: none;
}

.kp-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 14px 16px;
  margin-top: auto;
  padding-top: 14px;
}

.kp-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: #6366f1;
  text-decoration: none;
  transition: color 0.15s;
}

.kp-link:hover {
  color: #4f46e5;
}

/* Empty + Add */
.kp-empty-wrap {
  text-align: center;
}

.kp-empty-box {
  border: 2px dashed #e5e7eb;
  border-radius: 16px;
  background: #fafafa;
  padding: 36px 24px;
}

.kp-empty-text {
  margin: 0;
  font-size: 13px;
  color: #6b7280;
}

.kp-add-project-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  margin-top: 16px;
  padding: 14px 20px;
  border: 1.5px dashed #d1d5db;
  border-radius: 14px;
  background: #fff;
  color: #4b5563;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.kp-add-project-btn:hover {
  border-color: #a5b4fc;
  background: #f5f3ff;
  color: #6366f1;
}

.kp-add-project-btn--empty {
  margin-top: 0;
  flex-direction: column;
  gap: 10px;
  padding: 32px 20px;
  background: #fafafa;
}

.kp-add-project-btn--empty .kp-add-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px dashed #d1d5db;
  background: #fff;
  color: #9ca3af;
}

.kp-add-project-btn--empty:hover .kp-add-icon {
  border-color: #a5b4fc;
  color: #6366f1;
}

.kp-show-all-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #fff;
  color: #6b7280;
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.kp-show-all-btn:hover {
  border-color: #d1d5db;
  background: #f9fafb;
  color: #1f2937;
}

.kp-show-all-btn svg {
  transition: transform 0.2s ease;
}

.kp-show-all-btn.is-expanded svg {
  transform: rotate(180deg);
}

/* Form — compact */
#key-projects .kp-form--compact {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

#key-projects .kp-form--compact .kp-form-title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 800;
}

#key-projects .kp-form-grid {
  gap: 8px 10px;
}

#key-projects .kp-form-field {
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

#key-projects .kp-form-field .prof-form-input {
  padding: 7px 10px;
  font-size: 13px;
  min-height: 0;
}

#key-projects .kp-form-field textarea.prof-form-input {
  min-height: 52px;
  resize: vertical;
}

#key-projects .kp-tech-picker {
  gap: 4px;
}

#key-projects .kp-form-images-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #4b5563;
}

#key-projects .kp-form-images-meta {
  font-weight: 500;
  color: #9ca3af;
  font-size: 11px;
}

#key-projects .kp-form-gallery {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 6px;
}

#key-projects .kp-form-thumb {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  cursor: grab;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

#key-projects .kp-form-thumb:active {
  cursor: grabbing;
}

#key-projects .kp-form-thumb.is-dragging {
  opacity: 0.45;
}

#key-projects .kp-form-thumb.is-drag-over {
  border-color: #6366f1;
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}

#key-projects .kp-form-thumb-num {
  position: absolute;
  top: 4px;
  right: 4px;
  z-index: 2;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(99, 102, 241, 0.92);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

#key-projects .kp-form-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

#key-projects .kp-form-thumb-rm {
  position: absolute;
  top: 4px;
  left: 4px;
  z-index: 3;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

#key-projects .kp-form-upload-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

#key-projects .kp-add-img-btn {
  padding: 5px 12px;
  font-size: 12px;
}

#key-projects .kp-form-actions {
  margin-top: 10px;
  gap: 8px;
}

#key-projects .kp-upload-busy {
  font-size: 11px;
  color: #6b7280;
}

@media (max-width: 640px) {
  .kp-card--enhanced .kp-card-layout {
    padding: 16px;
  }

  .kp-card-layout {
    flex-direction: column-reverse;
    gap: 14px;
  }

  .kp-card-visual {
    flex: none;
    max-width: none;
    width: 100%;
  }

  .kp-card-visual .kp-gallery-grid {
    min-height: 120px;
  }

  .kp-gallery-main,
  .kp-gallery-cell {
    min-height: 120px;
  }

  .kp-card-actions {
    opacity: 1;
  }

  .kp-card-body {
    padding: 16px;
  }

  .kp-card-title {
    font-size: 16px;
  }
}

/* Gallery modal */
#kp-gallery-modal {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

#kp-gallery-modal.kp-modal-visible {
  opacity: 1;
  visibility: visible;
}

#kp-gallery-modal .kp-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

#kp-gallery-modal .kp-modal-panel {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#kp-gallery-modal .kp-modal-image-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  overflow: hidden;
  background: #0f172a;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.35);
}

#kp-gallery-modal .kp-modal-image-wrap.kp-modal-loupe-active {
  cursor: crosshair;
}

#kp-gallery-modal .kp-modal-loupe-btn {
  position: absolute;
  bottom: 14px;
  right: 14px;
  z-index: 3;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

#kp-gallery-modal .kp-modal-loupe-btn:hover,
#kp-gallery-modal .kp-modal-loupe-btn.is-active {
  background: rgba(99, 102, 241, 0.95);
  color: #fff;
  transform: scale(1.04);
}

#kp-gallery-modal .kp-modal-loupe-lens {
  position: fixed;
  z-index: 10060;
  border-radius: 12px;
  border: 3px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  background-repeat: no-repeat;
  background-color: #0f172a;
  pointer-events: none;
}

#kp-gallery-modal .kp-modal-image {
  max-width: 100%;
  max-height: calc(100vh - 160px);
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

#kp-gallery-modal .kp-modal-close,
#kp-gallery-modal .kp-modal-nav {
  position: absolute;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  transition: background 0.15s ease;
}

#kp-gallery-modal .kp-modal-close {
  top: 16px;
  left: 16px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  z-index: 2;
}

#kp-gallery-modal .kp-modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

#kp-gallery-modal .kp-modal-nav {
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  z-index: 2;
}

#kp-gallery-modal .kp-modal-nav:hover {
  background: rgba(255, 255, 255, 0.22);
}

#kp-gallery-modal .kp-modal-nav--prev {
  right: 16px;
}

#kp-gallery-modal .kp-modal-nav--next {
  left: 16px;
}

#kp-gallery-modal .kp-modal-nav:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

#kp-gallery-modal .kp-modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
}

#kp-gallery-modal .kp-modal-thumbs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

#kp-gallery-modal .kp-modal-thumb {
  flex: 0 0 auto;
  width: 56px;
  height: 56px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  opacity: 0.65;
  cursor: pointer;
  padding: 0;
  background: none;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

#kp-gallery-modal .kp-modal-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#kp-gallery-modal .kp-modal-thumb.active,
#kp-gallery-modal .kp-modal-thumb:hover {
  opacity: 1;
  border-color: #fff;
}
