/* ==========================================================
   Requirement 4: Projects (slider)
   ========================================================== */

.projects { overflow: hidden; }

.projects-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
}
.projects-header .section-lead { margin-bottom: 0; }

.slider-controls {
  display: flex;
  gap: 0.6rem;
  flex-shrink: 0;
}
.slider-btn {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1.5px solid var(--text);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease, opacity 0.2s ease;
}
.slider-btn svg { width: 20px; height: 20px; }
.slider-btn:hover:not(:disabled) { background: var(--text); color: var(--light-bg); }
.slider-btn:disabled { opacity: 0.25; cursor: default; }

/* ---------- Track ---------- */
.project-track {
  /* starts aligned with the page content, bleeds off the right edge */
  --edge: max(1.25rem, calc((100% - 1180px) / 2));
  display: flex;
  gap: 1.25rem;
  margin-top: 3rem;
  padding: 0.5rem var(--edge) 1rem;
  scroll-padding-inline: var(--edge);
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scroll-behavior: smooth;
  scrollbar-width: none;
  cursor: grab;
}
.project-track::-webkit-scrollbar { display: none; }
.project-track.is-dragging { cursor: grabbing; scroll-snap-type: none; scroll-behavior: auto; }
.project-track.is-dragging * { pointer-events: none; user-select: none; }
.project-track:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }

/* ---------- Cards ---------- */
.project-card {
  flex: 0 0 clamp(280px, 34vw, 420px);
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  background: var(--light-surface);
  border: 1px solid var(--light-border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.project-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 24px 50px -24px rgba(6, 27, 41, 0.35);
}

.project-media {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--bg);
}
.project-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.6s ease;
}
.project-card:hover .project-media img { transform: scale(1.06); }

.project-status {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(6, 27, 41, 0.75);
  backdrop-filter: blur(6px);
  color: #fff;
}
.project-status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
}
.project-status.is-ongoing::before {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0.7);
  animation: status-pulse 2s infinite;
}

.project-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 1.5rem 1.6rem 1.7rem;
  flex-grow: 1;
}
.project-meta {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--light-muted);
}
.project-meta span + span::before { content: "·"; margin-right: 0.5rem; }

.project-body h3 { font-size: 1.4rem; color: var(--light-text); }
.project-body p {
  margin: 0;
  color: var(--light-muted);
  font-size: 0.97rem;
  flex-grow: 1;
}
.project-card { cursor: pointer; }
.project-link {
  align-self: flex-start;
  margin-top: 0.6rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--light-text);
  background: none;
  border: none;
  border-bottom: 2px solid var(--accent);
  padding: 0 0 2px;
  cursor: pointer;
}
.project-link::after { content: " \2192"; }
.project-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 2px; }

/* ---------- Progress bar ---------- */
.slider-progress {
  height: 3px;
  margin-top: 2rem;
  border-radius: 3px;
  background: var(--light-border);
  overflow: hidden;
}
.slider-progress-bar {
  height: 100%;
  width: 0;
  background: var(--light-text);
  border-radius: 3px;
  transition: width 0.2s ease;
}

@keyframes status-pulse {
  70% { box-shadow: 0 0 0 7px rgba(var(--accent-rgb), 0); }
  100% { box-shadow: 0 0 0 0 rgba(var(--accent-rgb), 0); }
}

/* ---------- Pop-up with more info (built in js/req4-projects.js) ---------- */
.project-modal {
  width: min(760px, calc(100% - 2rem));
  max-height: calc(100dvh - 3rem);
  padding: 0;
  border: none;
  border-radius: var(--radius);
  background: var(--light-surface);
  color: var(--light-text);
  overflow: hidden auto;
  overscroll-behavior: contain;
  box-shadow: 0 40px 90px -30px rgba(1, 34, 51, 0.7);
}
.project-modal[open] { animation: pm-in 0.35s cubic-bezier(0.2, 0.8, 0.2, 1); }
.project-modal::backdrop {
  background: rgba(1, 34, 51, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: pm-fade 0.35s ease;
}
body:has(.project-modal[open]) { overflow: hidden; } /* page stays still behind it */

.pm-inner { position: relative; }

/* stays in the corner while the pop-up scrolls */
.pm-close {
  position: sticky;
  top: 1rem;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: 1rem 1rem calc(-44px - 1rem) auto;
  border: none;
  border-radius: 50%;
  background: rgba(6, 27, 41, 0.75);
  backdrop-filter: blur(6px);
  color: #fff;
  cursor: pointer;
  transition: background 0.2s ease;
}
.pm-close:hover { background: rgba(6, 27, 41, 0.95); }
.pm-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.pm-close svg { width: 20px; height: 20px; }

.pm-media {
  position: relative;
  aspect-ratio: 16 / 8;
  overflow: hidden;
  background: var(--bg);
}
.pm-media img { width: 100%; height: 100%; aspect-ratio: auto; object-fit: cover; }

.pm-body {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 2rem 2.5rem 2.5rem;
}
.pm-body h3 { font-size: clamp(1.7rem, 3.5vw, 2.3rem); font-weight: 800; letter-spacing: -0.02em; }
.pm-lead { margin: 0; font-size: 1.08rem; color: var(--light-muted); }

.pm-sections { display: grid; gap: 0.35rem; margin-top: 0.5rem; }
.pm-sections h4 {
  margin: 1.1rem 0 0;
  font-size: 1rem;
  font-weight: 700;
  color: #1a8a78; /* same readable green as the eyebrows on light bg */
}
.pm-sections p { margin: 0; color: var(--light-text); }

.pm-link { align-self: flex-start; margin-top: 1.5rem; }
.pm-link[hidden] { display: none; }

@keyframes pm-in { from { opacity: 0; transform: translateY(24px) scale(0.96); } }
@keyframes pm-fade { from { opacity: 0; } }

@media (max-width: 680px) {
  .project-modal { width: calc(100% - 1.25rem); max-height: calc(100dvh - 1.25rem); }
  .pm-body { padding: 1.5rem 1.4rem 2rem; }
}

@media (max-width: 680px) {
  .projects-header { flex-direction: column; align-items: flex-start; }
  .slider-controls { display: none; } /* swipe on phones */
  .project-card { flex-basis: 82vw; }
}