/* ==========================================================
   Portfolio popout galleries (projects + certifications)
   Everything is namespaced with .pg- so it won't clash with
   your existing styles. Tweak the variables to match your theme.
   ========================================================== */

:root {
  --pg-accent: #4f46e5;          /* buttons, active thumbnail, links */
  --pg-accent-hover: #4338ca;
  --pg-bg: #ffffff;              /* popup card background */
  --pg-text: #1e293b;
  --pg-muted: #4b5563;
  --pg-border: #e5e7eb;
  --pg-overlay: rgba(10, 15, 25, 0.78);
  --pg-radius: 14px;
}

body.pg-lock { overflow: hidden; }

.pg-overlay {
  font-family: inherit;
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: var(--pg-overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
}
.pg-overlay.pg-open { opacity: 1; visibility: visible; }

.pg-dialog {
  position: relative;
  width: min(960px, 100%);
  max-height: calc(100vh - 32px);
  display: flex;
  flex-direction: column;
  background: var(--pg-bg);
  color: var(--pg-text);
  border-radius: var(--pg-radius);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transform: translateY(12px) scale(0.98);
  transition: transform 0.2s ease;
}
.pg-overlay.pg-open .pg-dialog { transform: none; }

.pg-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--pg-border);
}
.pg-heading { margin: 0; font-size: 1.1rem; font-weight: 600; }
.pg-counter { color: var(--pg-muted); font-size: 0.9rem; margin-right: 12px; }
.pg-header-right { display: flex; align-items: center; }

.pg-close,
.pg-arrow,
.pg-thumb { font-family: inherit; }

.pg-close {
  width: 36px; height: 36px;
  border: none; border-radius: 50%;
  background: transparent;
  color: var(--pg-text);
  font-size: 1.6rem; line-height: 1;
  cursor: pointer;
}
.pg-close:hover { background: var(--pg-border); }

.pg-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 64px;
}

.pg-slide { transition: opacity 0.18s ease; }
.pg-slide.pg-fading { opacity: 0; }

.pg-media {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(127, 127, 127, 0.08);
  border: 1px solid var(--pg-border);
  border-radius: 10px;
  min-height: 200px;
  max-height: 46vh;
  overflow: hidden;
}
.pg-media img {
  display: block;
  max-width: 100%;
  max-height: 46vh;
  object-fit: contain;
}
.pg-placeholder {
  padding: 40px 20px;
  color: var(--pg-muted);
  font-size: 0.95rem;
  text-align: center;
}

.pg-title { margin: 18px 0 6px; font-size: 1.3rem; font-weight: 600; }
.pg-desc  { margin: 0 0 14px; color: var(--pg-muted); line-height: 1.55; }

.pg-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.pg-btn {
  display: inline-block;
  padding: 9px 16px;
  border-radius: 8px;
  border: 1px solid var(--pg-accent);
  background: var(--pg-accent);
  color: #fff;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}
.pg-btn:hover { background: var(--pg-accent-hover); border-color: var(--pg-accent-hover); }
.pg-btn.pg-secondary { background: transparent; color: var(--pg-accent); }
.pg-btn.pg-secondary:hover { background: rgba(79, 70, 229, 0.1); }

.pg-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px; height: 44px;
  border: 1px solid var(--pg-border);
  border-radius: 50%;
  background: var(--pg-bg);
  color: var(--pg-text);
  font-size: 1.4rem; line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18);
  z-index: 2;
}
.pg-arrow:hover { background: var(--pg-accent); color: #fff; border-color: var(--pg-accent); }
.pg-prev { left: 10px; }
.pg-next { right: 10px; }

.pg-thumbs {
  display: flex;
  gap: 10px;
  padding: 12px 20px;
  border-top: 1px solid var(--pg-border);
  overflow-x: auto;
}
.pg-thumb {
  flex: 0 0 auto;
  width: 84px; height: 56px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  background: rgba(127, 127, 127, 0.12);
  overflow: hidden;
  cursor: pointer;
  opacity: 0.65;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}
.pg-thumb:hover { opacity: 1; }
.pg-thumb[aria-current="true"] { opacity: 1; border-color: var(--pg-accent); }
.pg-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pg-thumb span { font-size: 0.7rem; color: var(--pg-muted); padding: 4px; display: block; }

.pg-close:focus-visible,
.pg-arrow:focus-visible,
.pg-thumb:focus-visible,
.pg-btn:focus-visible { outline: 3px solid var(--pg-accent); outline-offset: 2px; }

@media (max-width: 600px) {
  .pg-stage { padding: 16px 16px 72px; }
  .pg-arrow { top: auto; bottom: 14px; transform: none; }
  .pg-prev { left: 16px; }
  .pg-next { right: 16px; }
  .pg-thumb { width: 68px; height: 46px; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-overlay, .pg-dialog, .pg-slide { transition: none; }
}
