/* ==========================================================================
   portfolio-modal.css — Fullscreen Project Overlay Modal
   Design: editorial, minimal, clean — matches design system
   ========================================================================== */

/* ── Overlay backdrop ────────────────────────────────────── */
#project-modal {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.5rem;

  /* Hidden state */
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
}

#project-modal.pm-open {
  opacity: 1;
  visibility: visible;
  pointer-events: all;
}

/* Dimmed backdrop */
.pm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  cursor: pointer;
}

[data-theme="light"] .pm-backdrop {
  background: rgba(15, 23, 42, 0.55);
}

/* ── Modal panel ─────────────────────────────────────────── */
.pm-panel {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 900px;
  height: calc(100vh - 4rem);   /* fixed height — always fills viewport minus padding */
  max-height: 860px;             /* cap on very tall screens */
  background: var(--color-surface-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl, 20px);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* Enter animation */
  transform: scale(0.94) translateY(16px);
  transition: transform 0.28s cubic-bezier(0.16, 1, 0.3, 1),
              opacity 0.28s ease;
}

#project-modal.pm-open .pm-panel {
  transform: scale(1) translateY(0);
}

/* ── Content slot & Inner structure (fixes scrolling) ────── */
.pm-content-slot {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.pm-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

/* ── Header bar ──────────────────────────────────────────── */
.pm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: 1rem;
}

.pm-header-left {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pm-eyebrow {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-primary);
}

.pm-year {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.pm-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pm-close-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all 0.18s ease;
  flex-shrink: 0;
}

.pm-close-btn:hover {
  background: var(--color-surface-soft);
  color: var(--color-text-main);
  border-color: var(--color-text-muted);
}

/* ── Scrollable content area ─────────────────────────────── */
.pm-scroll {
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.pm-scroll::-webkit-scrollbar {
  width: 5px;
}
.pm-scroll::-webkit-scrollbar-track {
  background: transparent;
}
.pm-scroll::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 99px;
}

/* ── Cover image ─────────────────────────────────────────── */
.pm-cover {
  width: 100%;
  height: auto;
  max-height: 480px;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--color-surface-soft);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pm-cover-img {
  width: 100%;
  height: auto;
  max-height: 480px;
  object-fit: contain;
  display: block;
  transition: transform 0.5s ease;
}

.pm-cover:hover .pm-cover-img {
  transform: scale(1.02);
}

.pm-cover--empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  opacity: 0.35;
  height: 140px;   /* smaller placeholder when no image */
}

/* ── Body content ────────────────────────────────────────── */
.pm-body {
  padding: 2rem 2rem 2.5rem;
}

/* Tech tags */
.pm-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 1.25rem;
}

.pm-tag {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-primary);
  background: var(--color-primary-light, rgba(37,99,235,0.07));
  border: 1px solid var(--color-primary-border, rgba(37,99,235,0.18));
  border-radius: var(--radius-full, 9999px);
  padding: 3px 10px;
}

/* Title */
.pm-title {
  font-family: 'Space Grotesk', var(--font-heading);
  font-size: clamp(1.6rem, 3vw, 2.2rem);
  font-weight: 700;
  color: var(--color-text-main);
  line-height: 1.15;
  letter-spacing: -0.025em;
  margin-bottom: 1rem;
}

/* Description */
.pm-desc {
  font-family: var(--font-body);
  font-size: 1rem;
  color: var(--color-text-muted);
  line-height: 1.8;
  margin-bottom: 0;
}

/* Section blocks inside modal preview */
.pm-section-block {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--color-border);
}

.pm-subheading {
  font-family: var(--font-display, var(--font-heading));
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text-main);
  margin-bottom: 0.6rem;
  letter-spacing: -0.01em;
}

.pm-prose {
  font-family: var(--font-body);
  font-size: 0.95rem;
  line-height: 1.85;
  color: var(--color-text-muted);
  white-space: pre-line;
}

/* Divider */
.pm-divider {
  height: 1px;
  background: var(--color-border);
  margin: 1.75rem 0;
}

/* Meta grid — stacks start date + full tech list */
.pm-meta-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md, 10px);
  overflow: hidden;
  margin-bottom: 0;
}

.pm-meta-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 1.25rem 1.5rem;
  border-right: 1px solid var(--color-border);
}

.pm-meta-item:last-child {
  border-right: none;
}

.pm-meta-label {
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--color-text-muted);
}

.pm-meta-value {
  font-family: var(--font-body);
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-main);
  white-space: nowrap;
}

/* Tech pills inside meta */
.pm-meta-techs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.pm-tech-pill {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--color-text-body, var(--color-text-main));
  background: var(--color-surface-soft);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm, 6px);
  padding: 3px 10px;
}

.pm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.pm-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 10px 20px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid transparent;
  text-decoration: none;
  cursor: pointer;
  transition: all 0.18s ease;
  white-space: nowrap;
}

.pm-btn--primary {
  background: var(--color-text-main);
  color: #fff;
  border-color: var(--color-text-main);
}
.pm-btn--primary:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.pm-btn--ghost {
  background: var(--color-surface-white);
  color: var(--color-text-main);
  border-color: var(--color-border);
}
.pm-btn--ghost:hover {
  border-color: var(--color-text-main);
  background: var(--color-surface-soft);
}

/* ── Loading skeleton inside panel ──────────────────────── */
.pm-skeleton-header {
  height: 56px;
  background: var(--color-surface-soft);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.pm-skeleton-body {
  padding: 0;
}

.pm-skeleton-cover {
  width: 100%;
  height: 220px;
  flex-shrink: 0;
  background: linear-gradient(90deg,
    var(--color-surface-soft) 25%,
    var(--color-surface-white) 50%,
    var(--color-surface-soft) 75%);
  background-size: 200% 100%;
  animation: pm-shimmer 1.4s infinite;
}

.pm-skeleton-content {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
}

.pm-skeleton-line {
  height: 14px;
  border-radius: 4px;
  background: linear-gradient(90deg,
    var(--color-surface-soft) 25%,
    var(--color-border) 50%,
    var(--color-surface-soft) 75%);
  background-size: 200% 100%;
  animation: pm-shimmer 1.4s infinite;
}

.pm-skeleton-line--title {
  height: 28px;
  width: 60%;
  border-radius: 6px;
  margin-bottom: 0.25rem;
}

.pm-skeleton-line--short {
  width: 35%;
}

@keyframes pm-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Project card: clickable trigger ────────────────────── */
.ed-project-row[data-modal-slug] {
  cursor: pointer;
}

/* Keep the "View Case Study" link functional without triggering modal again */
.ed-project-row[data-modal-slug] .ed-case-link {
  position: relative;
  z-index: 2;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 640px) {
  #project-modal {
    padding: 0;
    align-items: flex-end;
  }

  .pm-panel {
    max-width: 100%;
    height: 92vh;
    max-height: 92vh;
    border-radius: var(--radius-xl, 20px) var(--radius-xl, 20px) 0 0;
    border-bottom: none;

    /* Bottom sheet enter from below */
    transform: translateY(100%);
  }

  #project-modal.pm-open .pm-panel {
    transform: translateY(0);
  }

  .pm-cover {
    height: auto;
    max-height: 260px;
  }

  .pm-cover-img {
    height: auto;
    max-height: 260px;
  }

  .pm-body {
    padding: 1.5rem 1.25rem 2rem;
  }

  .pm-meta-grid {
    grid-template-columns: 1fr;
  }

  .pm-meta-item {
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }

  .pm-meta-item:last-child {
    border-bottom: none;
  }

  .pm-actions {
    flex-direction: column;
  }

  .pm-btn {
    justify-content: center;
  }
}

/* ── Reduced motion ──────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  #project-modal,
  .pm-panel {
    transition: opacity 0.01ms, visibility 0.01ms !important;
    transform: none !important;
  }
}
