/* =============================================================
   Section: Project Detail Modal + Photo Carousel
   ----------------------------------------------------------------
   Fullscreen overlay launched from .work-card clicks (homepage
   "Recent Work" and the Projects page grid). Renders project info
   alongside a swipeable photo carousel without leaving the page.

   On WP migration: the same DOM is mounted by project-modal.js in
   the theme. Cards keep their permalinks for SEO/no-JS fallback;
   the JS calls preventDefault() and opens the modal instead.
   ============================================================= */

/* ---- Root overlay ---- */
.project-modal {
  position: fixed;
  inset: 0;
  z-index: var(--z-overlay);
  display: none;
  align-items: stretch;
  justify-content: center;
  background: rgba(11, 11, 12, 0.78);
  -webkit-backdrop-filter: blur(8px);
          backdrop-filter: blur(8px);
  opacity: 0;
  transition: opacity var(--dur-base) var(--ease-out);
}

.project-modal.is-open {
  display: flex;
  opacity: 1;
}

/* Lock body scroll while modal is open. Class toggled by JS. */
body.project-modal-open {
  overflow: hidden;
}

/* ---- Dialog panel ---- */
.project-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 1480px;
  margin: auto;
  background: var(--ink-2);
  color: var(--bone);
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
  max-height: 100svh;
  overflow: hidden;
  transform: translateY(24px);
  transition: transform var(--dur-base) var(--ease-out);
  /* Torn-dirt edge mask along the bottom so the modal echoes the
     work-card silhouette without re-using the same SVG twice. */
  -webkit-mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 14px), transparent 100%);
          mask-image: linear-gradient(180deg, #000 0, #000 calc(100% - 14px), transparent 100%);
}

.project-modal.is-open .project-modal__dialog {
  transform: translateY(0);
}

@media (min-width: 980px) {
  .project-modal__dialog {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-rows: 1fr;
    max-height: 92svh;
    margin: 4svh auto;
    border: 1px solid var(--rule-dark);
    box-shadow: var(--shadow-card);
  }
}

/* ---- Close button ---- */
.project-modal__close {
  position: absolute;
  top: var(--s-4);
  right: var(--s-4);
  z-index: 5;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(11, 11, 12, 0.6);
  color: var(--bone);
  border: 1px solid var(--rule-dark);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.project-modal__close:hover {
  background: var(--safety);
  color: var(--ink);
  border-color: var(--safety);
}

.project-modal__close:focus-visible {
  outline: 2px solid var(--safety);
  outline-offset: 2px;
}

/* ---- Download (Save as PDF) button ----
   Sits immediately left of the close button. Same metric/affordance
   as .project-modal__close so the two read as a small toolbar; uses
   the FA download glyph instead of an &times;. */
.project-modal__download {
  position: absolute;
  top: var(--s-4);
  right: calc(var(--s-4) + 56px);
  z-index: 5;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(11, 11, 12, 0.6);
  color: var(--bone);
  border: 1px solid var(--rule-dark);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.project-modal__download:hover {
  background: var(--safety);
  color: var(--ink);
  border-color: var(--safety);
}

.project-modal__download:focus-visible {
  outline: 2px solid var(--safety);
  outline-offset: 2px;
}

.project-modal__download[disabled],
.project-modal__download.is-loading {
  cursor: progress;
  opacity: 0.6;
}

.project-modal__download.is-loading i {
  animation: project-modal-pulse 0.9s ease-in-out infinite;
}

@keyframes project-modal-pulse {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(2px); }
}

/* ============================================================
   Carousel
   ============================================================ */
.project-modal__carousel {
  position: relative;
  background: var(--ink);
  overflow: hidden;
  min-height: 240px;
  aspect-ratio: 16 / 10;
}

@media (min-width: 980px) {
  .project-modal__carousel {
    aspect-ratio: auto;
    min-height: 0;
    height: 100%;
  }
}

.project-modal__track {
  position: absolute;
  inset: 0;
  display: flex;
  width: 100%;
  height: 100%;
  transition: transform var(--dur-base) var(--ease-out);
  touch-action: pan-y;
  cursor: grab;
}

.project-modal__track.is-dragging {
  cursor: grabbing;
  transition: none;
}

.project-modal__slide {
  flex: 0 0 100%;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink);
  user-select: none;
  -webkit-user-drag: none;
}

.project-modal__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none; /* let the track receive pointer events */
  filter: contrast(1.05);
}

/* Empty state (no photos): friendly placeholder so the carousel
   area never collapses to zero height. */
.project-modal__slide--empty {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted-dark);
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.02) 0 12px,
      rgba(255, 255, 255, 0) 12px 24px
    ),
    var(--ink);
}

/* ---- Arrows ---- */
.project-modal__arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  appearance: none;
  -webkit-appearance: none;
  background: rgba(11, 11, 12, 0.55);
  color: var(--bone);
  border: 1px solid var(--rule-dark);
  font-family: var(--font-mono);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}

.project-modal__arrow:hover {
  background: var(--safety);
  color: var(--ink);
  border-color: var(--safety);
}

.project-modal__arrow:focus-visible {
  outline: 2px solid var(--safety);
  outline-offset: 2px;
}

.project-modal__arrow[disabled] {
  opacity: 0;
  pointer-events: none;
}

.project-modal__arrow--prev { left: var(--s-3); }
.project-modal__arrow--next { right: var(--s-3); }

/* ---- Counter (3 / 12) ---- */
.project-modal__counter {
  position: absolute;
  top: var(--s-4);
  left: var(--s-4);
  z-index: 3;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(11, 11, 12, 0.6);
  border: 1px solid var(--rule-dark);
  padding: 6px 10px;
}

/* ---- Dot nav ---- */
.project-modal__dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: var(--s-4);
  z-index: 3;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  pointer-events: none; /* container ignores; buttons re-enable */
}

.project-modal__dot {
  pointer-events: auto;
  appearance: none;
  -webkit-appearance: none;
  width: 8px;
  height: 8px;
  border-radius: var(--r-pill);
  background: rgba(244, 241, 234, 0.45);
  border: 0;
  padding: 0;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
}

.project-modal__dot:hover { background: var(--bone); }

.project-modal__dot.is-active {
  background: var(--safety);
  transform: scale(1.4);
}

.project-modal__dot:focus-visible {
  outline: 2px solid var(--safety);
  outline-offset: 3px;
}

/* ============================================================
   Info panel
   ============================================================ */
.project-modal__info {
  padding: var(--s-6) var(--s-5) var(--s-7);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: var(--s-4);
  background: var(--ink-2);
  position: relative;
}

@media (min-width: 980px) {
  .project-modal__info {
    padding: var(--s-7) var(--s-7) var(--s-8);
  }
}

.project-modal__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding-top: 25px;
}

.project-modal__sector {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--bone);
  background: rgba(11, 11, 12, 0.55);
  border: 1px solid var(--rule-dark);
  padding: 6px 12px;
}

.project-modal__job-number {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--safety);
}

.project-modal__title {
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 3.5vw, 3rem);
  line-height: 1.05;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  margin: 0;
}

.project-modal__sub {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted-dark);
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-3);
  margin: 0;
}

.project-modal__sub strong {
  color: var(--bone);
  font-weight: 500;
}

.project-modal__rule {
  height: 1px;
  background: var(--rule-dark);
  border: 0;
  margin: var(--s-2) 0;
}

/* Definition list of meta */
.project-modal__meta {
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  gap: var(--s-2) var(--s-5);
  margin: 0;
  font-size: 0.94rem;
}

.project-modal__meta dt {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--muted-dark);
  align-self: center;
}

.project-modal__meta dd {
  margin: 0;
  font-family: var(--font-body);
  color: var(--bone);
  line-height: 1.4;
}

.project-modal__disciplines {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.project-modal__discipline {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  letter-spacing: var(--tracking-eyebrow);
  text-transform: uppercase;
  color: var(--bone);
  border: 1px solid var(--rule-dark);
  padding: 4px 10px;
}

.project-modal__description {
  font-family: var(--font-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--bone);
  margin: 0;
}

.project-modal__description p { margin: 0 0 var(--s-3); }
.project-modal__description p:last-child { margin-bottom: 0; }

.project-modal__cta {
  margin-top: auto;
  padding-top: var(--s-5);
}

/* Reduced motion: instant transitions */
@media (prefers-reduced-motion: reduce) {
  .project-modal,
  .project-modal__dialog,
  .project-modal__track {
    transition: none;
  }
  .project-modal__download.is-loading i {
    animation: none;
  }
}

/* ============================================================
   PDF Export — white spec sheet
   ----------------------------------------------------------------
   The PDF renderer (assets/js/pdf-renderer.js) reuses the live
   modal's HTML builders (ACI.projectModalInfoHtml / SlidesHtml)
   so labels like "PAST PERFORMANCE" and "Scope of Work" stay in
   sync — change them in project-modal.js and the PDF picks it
   up automatically.

   The wrapper .project-modal-pdf-spec re-skins the .project-modal__*
   classes the builders produce for white-paper print: dark text,
   light borders, a compact 2-column gallery at the bottom of the
   page so everything fits on a single sheet.
   ============================================================ */

.project-modal-pdf-doc {
  background: #ffffff;
  color: #0b0b0c;
  font-family: var(--font-body, "Inter", system-ui, sans-serif);
  display: flex;
  flex-direction: column;
}

.project-modal-pdf-spec {
  background: #ffffff;
  color: #0b0b0c;
  padding: 32px 36px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.project-modal-pdf-spec--break {
  page-break-before: always;
  break-before: page;
}

/* ---- Info column re-skin (overrides the dark modal styling) ---- */
.project-modal-pdf-spec .project-modal__info {
  max-height: none;
  overflow: visible;
  padding: 0;
  background: transparent;
  color: #0b0b0c;
  display: block;
  gap: 0;
}

.project-modal-pdf-spec .project-modal__top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.project-modal-pdf-spec .project-modal__sector {
  background: #f4f1ea;
  border: 1px solid #d4cfc2;
  color: #0b0b0c;
  padding: 5px 10px;
  font-size: 11px;
}

.project-modal-pdf-spec .project-modal__job-number {
  color: #c75d1f;
  font-size: 11px;
}

.project-modal-pdf-spec .project-modal__title {
  color: #0b0b0c;
  font-size: 36px;
  margin: 0 0 8px;
}

.project-modal-pdf-spec .project-modal__sub {
  color: #5a5a5a;
  font-size: 11px;
  gap: 14px;
  margin: 0 0 14px;
}

.project-modal-pdf-spec .project-modal__sub strong {
  color: #0b0b0c;
}

.project-modal-pdf-spec .project-modal__rule {
  background: #d4cfc2;
  margin: 12px 0 18px;
}

.project-modal-pdf-spec .project-modal__meta {
  grid-template-columns: 120px 1fr;
  gap: 8px 24px;
  margin: 0 0 18px;
  font-size: 13px;
}

.project-modal-pdf-spec .project-modal__meta dt {
  color: #6b6b6b;
  font-size: 10px;
}

.project-modal-pdf-spec .project-modal__meta dd {
  color: #0b0b0c;
}

.project-modal-pdf-spec .project-modal__discipline {
  color: #0b0b0c;
  border-color: #d4cfc2;
  font-size: 10px;
}

.project-modal-pdf-spec .project-modal__description {
  color: #0b0b0c;
  font-size: 13px;
  line-height: 1.55;
  margin: 0;
}

.project-modal-pdf-spec .project-modal__description p {
  margin: 0 0 10px;
}

.project-modal-pdf-spec .project-modal__description p:last-child {
  margin-bottom: 0;
}

/* Awards block re-skin — works alongside awards.css's .project-modal__awards rules. */
.project-modal-pdf-spec .project-modal__awards {
  margin-top: 18px;
  padding-top: 14px;
  border-top: 1px solid #d4cfc2;
  background: transparent;
  color: #0b0b0c;
}

.project-modal-pdf-spec .project-modal__awards-title {
  color: #0b0b0c;
  font-size: 11px;
}

.project-modal-pdf-spec .project-modal__award {
  color: #0b0b0c;
  font-size: 12px;
}

.project-modal-pdf-spec .project-modal__award-name,
.project-modal-pdf-spec .project-modal__award-name a {
  color: #0b0b0c;
}

.project-modal-pdf-spec .project-modal__award-year,
.project-modal-pdf-spec .project-modal__award-cats {
  color: #6b6b6b;
}

.project-modal-pdf-spec .project-modal__award-desc {
  color: #4a4a4a;
}

/* ---- Gallery: compact grid at the bottom of the spec sheet ---- */
.project-modal-pdf-spec__gallery {
  margin-top: 4px;
  page-break-inside: avoid;
  break-inside: avoid;
}

.project-modal-pdf-spec__gallery--empty {
  display: none;
}

/* The slides arrive inside a .project-modal__track wrapper (so the
   shared builder output is unchanged); we override the carousel's
   absolute-positioned flex layout into a CSS grid for print. */
.project-modal-pdf-spec__gallery .project-modal__track {
  position: static;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  height: auto;
  transform: none !important;
  transition: none !important;
  cursor: default;
  touch-action: auto;
}

.project-modal-pdf-spec__gallery--single .project-modal__track {
  grid-template-columns: 1fr;
}

.project-modal-pdf-spec__gallery .project-modal__slide {
  position: static;
  flex: initial;
  width: 100%;
  height: auto;
  aspect-ratio: 4 / 3;
  background: #f4f1ea;
  border: 1px solid #d4cfc2;
  display: block;
  page-break-inside: avoid;
  break-inside: avoid;
}

.project-modal-pdf-spec__gallery .project-modal__slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  filter: none;
}

.project-modal-pdf-spec__gallery .project-modal__slide--empty {
  aspect-ratio: auto;
  padding: 18px;
  text-align: center;
  color: #6b6b6b;
  background: #f4f1ea;
}
