/* Portfolio components (cards + modal) — centralized styling.
   Keep changes here to update all projects at once. */

.pf-card {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 240px;
  position: relative;
}


/* Bento sizing for portfolio cards (two widths) */
.pf-grid .pf-card.wide { grid-column: span 8; }
.pf-grid .pf-card.narrow { grid-column: span 4; }

/* Make sure the portfolio bento stays compact and consistent */
.pf-grid { align-items: stretch; }

@media (max-width: 820px) {
  .pf-grid .pf-card.wide,
  .pf-grid .pf-card.narrow { grid-column: span 12; }
}

.pf-card .pf-cover {
  position: relative;
  height: 152px;
  overflow: hidden;

  /* Separation from the portfolio container behind the card:
     the cover is inset so you can read the tile boundary even on image areas. */
  margin: 10px 10px 0 10px;
  border-radius: 14px;

  border: 1px solid rgba(0,0,0,0.10);
  box-shadow: 0 10px 22px rgba(0,0,0,0.10);
}

html.dark .pf-card .pf-cover {
  border-color: rgba(255,255,255,0.14);
  box-shadow: 0 10px 22px rgba(0,0,0,0.35);
}

@media (max-width: 520px) {
  .pf-card .pf-cover { margin: 8px 8px 0 8px; border-radius: 12px; }
}


.pf-card .pf-cover img {
  border-radius: inherit;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transform: scale(1.02);
  transition: transform 220ms ease;
}

.pf-card:hover .pf-cover img,
.pf-card:focus-visible .pf-cover img {
  transform: scale(1.06);
}

.pf-card .pf-cover::after {
  border-radius: inherit;
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(0,0,0,0.0) 0%, rgba(0,0,0,0.22) 70%, rgba(0,0,0,0.34) 100%),
    radial-gradient(circle at 20% 0%, rgba(0, 86, 179, 0.24) 0%, rgba(0, 86, 179, 0) 55%);
  pointer-events: none;
}

.pf-card .pf-badge {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: #003366;
  background: rgba(255,255,255,0.82);
  border: 1px solid rgba(0,0,0,0.10);
  backdrop-filter: blur(10px);
}

html.dark .pf-card .pf-badge {
  color: rgba(255,255,255,0.92);
  background: rgba(17, 24, 39, 0.60);
  border-color: rgba(255,255,255,0.14);
}

.pf-card .pf-main {
  padding: 14px 14px 12px 14px;
  display: grid;
  gap: 8px;
  flex: 1;
}

.pf-card .pf-cta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  color: #0056b3;
  font-size: 0.92rem;
  margin-top: 2px;
  user-select: none;
}

html.dark .pf-card .pf-cta {
  color: rgba(165, 205, 255, 0.95);
}

.pf-card .pf-cta .pf-arrow {
  display: inline-block;
  transform: translateX(0);
  transition: transform 160ms ease;
}

.pf-card:hover .pf-cta .pf-arrow,
.pf-card:focus-visible .pf-cta .pf-arrow {
  transform: translateX(3px);
}

/* Optional: subtle “shine” on hover */
.pf-card::before {
  content: "";
  position: absolute;
  inset: -40% -30%;
  background: linear-gradient(120deg, rgba(255,255,255,0.0) 30%, rgba(255,255,255,0.18) 45%, rgba(255,255,255,0.0) 60%);
  transform: translateX(-35%) rotate(8deg);
  opacity: 0;
  transition: opacity 240ms ease, transform 520ms ease;
  pointer-events: none;
}

html.dark .pf-card::before {
  background: linear-gradient(120deg, rgba(0,0,0,0.0) 30%, rgba(255,255,255,0.10) 45%, rgba(0,0,0,0.0) 60%);
}

.pf-card:hover::before,
.pf-card:focus-visible::before {
  opacity: 1;
  transform: translateX(35%) rotate(8deg);
}

/* Modal content layout */
#portfolioModal .modal {
  max-width: 980px;
  /* Keep scroll inside the modal on mobile + prevent scroll chaining */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

/* Mobile viewport safety: keep header/close visible under iOS browser chrome and notches */
#portfolioModal.modal-backdrop {
  /* Default: keep centered like the rest of the site */
}

@media (max-width: 600px) {
  #portfolioModal.modal-backdrop {
    align-items: flex-start;
    /* Push modal below top browser UI/notch and leave room at the bottom */
    padding: calc(12px + env(safe-area-inset-top)) 10px calc(12px + env(safe-area-inset-bottom));
  }

  /* Use dynamic viewport height when available to avoid iOS vh quirks */
  #portfolioModal .modal {
    width: 100%;
    max-height: calc(100dvh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  }
}

@supports not (height: 100dvh) {
  @media (max-width: 600px) {
    #portfolioModal .modal {
      max-height: calc(100vh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    }
  }
}

/* Sticky header: add safe area padding so it never hides under browser UI */
#portfolioModal .modal-head {
  top: 0;
  padding-top: calc(14px + env(safe-area-inset-top));
}

/* Close button: larger tap target + higher contrast (esp. on mobile) */
#portfolioModal .modal-close {
  width: 44px;
  height: 44px;
  padding: 0;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  line-height: 1;
  border-radius: 999px;
  background: rgba(0, 86, 179, 0.12);
  border-color: rgba(0, 86, 179, 0.35);
  color: #003366;
  box-shadow: 0 10px 22px rgba(0,0,0,0.10);
}

#portfolioModal .modal-close:hover {
  background: rgba(0, 86, 179, 0.18);
}

#portfolioModal .modal-close:active {
  transform: scale(0.98);
}

#portfolioModal .modal-close:focus-visible {
  outline: 2px solid rgba(0, 86, 179, 0.55);
  outline-offset: 3px;
}

html.dark #portfolioModal .modal-close {
  background: rgba(165, 205, 255, 0.14);
  border-color: rgba(165, 205, 255, 0.30);
  color: rgba(255,255,255,0.95);
  box-shadow: 0 10px 22px rgba(0,0,0,0.35);
}


/* Prevent background page scrolling when the portfolio modal is open (JS toggles this class) */
html.pf-no-scroll,
body.pf-no-scroll {
  overflow: hidden !important;
}

#portfolioModal .contact-modal-body {
  padding-top: 14px;
}

.pf-modal-grid {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 860px) {
  .pf-modal-grid {
    grid-template-columns: 1fr;
  }
}

.pf-aside {
  display: grid;
  gap: 12px;
  position: sticky;
  /* Avoid overlapping the sticky modal header (.modal-head). The JS sets --pf-modal-head-h dynamically. */
  top: calc(var(--pf-modal-head-h, 68px) + 12px);
}

@media (max-width: 860px) {
  .pf-aside {
    position: static;
  }
}

.pf-cover-frame {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.70);
}

html.dark .pf-cover-frame {
  border-color: rgba(255,255,255,0.14);
  background: rgba(17, 24, 39, 0.50);
}

.pf-cover-frame img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  display: block;
}

.pf-quick {
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.70);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

html.dark .pf-quick {
  border-color: rgba(255,255,255,0.14);
  background: rgba(17, 24, 39, 0.50);
}

.pf-quick-item {
  display: grid;
  gap: 4px;
}

.pf-quick-label {
  font-size: 0.75rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #003366;
  opacity: 0.90;
}

html.dark .pf-quick-label {
  color: rgba(165, 205, 255, 0.95);
}

.pf-quick-value {
  font-size: 0.95rem;
  line-height: 1.35;
}

.pf-content {
  display: grid;
  gap: 14px;
}

.pf-section {
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.70);
  border-radius: 10px;
  padding: 12px 12px;
}

html.dark .pf-section {
  border-color: rgba(255,255,255,0.14);
  background: rgba(17, 24, 39, 0.50);
}

.pf-section h4 {
  margin: 0 0 8px 0;
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.pf-bullets {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.pf-bullets li {
  line-height: 1.45;
}

.pf-publications {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
}

.pf-publications a {
  color: #0056b3;
  font-weight: 800;
  text-decoration: none;
}

.pf-publications a:hover {
  text-decoration: underline;
}

html.dark .pf-publications a {
  color: rgba(165, 205, 255, 0.95);
}

/* Gallery */
.pf-gallery {
  border: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.70);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

html.dark .pf-gallery {
  border-color: rgba(255,255,255,0.14);
  background: rgba(17, 24, 39, 0.50);
}

.pf-gallery-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.pf-thumb {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.10);
  cursor: zoom-in;
  background: rgba(255,255,255,0.65);
}

html.dark .pf-thumb {
  border-color: rgba(255,255,255,0.14);
  background: rgba(17, 24, 39, 0.55);
}

.pf-thumb img {
  width: 100%;
  height: 120px;
  object-fit: cover;
  display: block;
  transition: transform 220ms ease;
}

.pf-thumb:hover img {
  transform: scale(1.05);
}


/* Gallery legends */
.pf-thumb-figure {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pf-thumb-figure[role="button"] {
  cursor: zoom-in;
}

.pf-thumb-figure:focus-visible {
  outline: 2px solid rgba(0, 86, 179, 0.55);
  outline-offset: 3px;
  border-radius: 12px;
}

.pf-thumb-caption {
  font-size: 0.78rem;
  line-height: 1.25;
  color: rgba(0,0,0,0.68);
}

html.dark .pf-thumb-caption {
  color: rgba(255,255,255,0.72);
}

/* Lightweight image zoom (lightbox) */
.pf-lightbox {
  position: fixed;
  inset: 0;
  /* Must sit above site modals (.modal-backdrop is z-index: 4000 in the main CSS) */
  z-index: 6000;
  background: rgba(0,0,0,0.72);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.pf-lightbox.open {
  display: flex;
}

.pf-lightbox-inner {
  position: relative;
  max-width: min(1080px, 96vw);
  max-height: 92vh;
  width: 100%;
}

.pf-lightbox-inner img {
  width: 100%;
  height: auto;
  max-height: 92vh;
  object-fit: contain;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(0,0,0,0.15);
}

.pf-lightbox-caption {
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: calc(10px + env(safe-area-inset-bottom));
  padding: 12px 14px;
  border-radius: 12px;
  background: linear-gradient(to top, rgba(0,0,0,0.72), rgba(0,0,0,0.25));
  backdrop-filter: blur(8px);
  color: rgba(255,255,255,0.96);
  font-size: 0.95rem;
  line-height: 1.35;
  pointer-events: none;
}

@media (max-width: 600px) {
  .pf-lightbox-caption {
    left: 8px;
    right: 8px;
    bottom: calc(8px + env(safe-area-inset-bottom));
    padding: 10px 12px;
    font-size: 0.88rem;
  }
}


.pf-lightbox-close {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(17, 24, 39, 0.72);
  color: rgba(255,255,255,0.96);
  cursor: pointer;
  font-size: 18px;
  line-height: 38px;
}


/* Lightbox navigation */
.pf-lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.22);
  background: rgba(17, 24, 39, 0.66);
  color: rgba(255,255,255,0.96);
  cursor: pointer;
  font-size: 26px;
  line-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.pf-lightbox-nav:hover {
  transform: translateY(-50%) scale(1.03);
  background: rgba(17, 24, 39, 0.78);
}

.pf-lightbox-nav:disabled {
  opacity: 0.35;
  cursor: default;
  transform: translateY(-50%);
}

.pf-lightbox-nav.pf-prev { left: -12px; }
.pf-lightbox-nav.pf-next { right: -12px; }

.pf-lightbox-counter {
  position: absolute;
  top: -10px;
  left: 12px;
  padding: 7px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(17, 24, 39, 0.56);
  color: rgba(255,255,255,0.92);
  font-size: 12px;
  letter-spacing: 0.02em;
}

@media (max-width: 680px) {
  .pf-lightbox-nav.pf-prev { left: 6px; }
  .pf-lightbox-nav.pf-next { right: 6px; }
  .pf-lightbox-counter { left: 6px; }
}
