/* Project gallery additions. Load after styles.css, content.css, and pages.css. */
.portfolio {
  background: var(--paper);
  border-top: 1px solid var(--line);
}

.portfolio .section-header {
  margin-bottom: 34px;
}

.portfolio-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.portfolio-filter {
  min-height: 44px;
  padding: 11px 19px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--navy);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  line-height: 1.5;
  text-transform: uppercase;
  transition: background-color .2s, border-color .2s, color .2s;
}

.portfolio-filter:hover {
  border-color: var(--silver-deep);
  background: var(--silver-light);
}

.portfolio-filter[aria-pressed="true"] {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--white);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 5px;
}

.portfolio-status {
  margin: 18px 0 24px;
  color: #566a7e;
  font-size: 12px;
  font-weight: 600;
}

.portfolio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  align-items: stretch;
}

.project-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--white);
}

/* A consistent display bay shows the entire portrait or landscape photo. */
.project-photo-button {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 100%;
  height: 400px;
  min-width: 0;
  padding: 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--navy);
  transition: background-color .2s;
}

.project-photo-button:hover {
  background: var(--navy-mid);
}

.project-photo-button img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: center;
}

.project-card-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
  padding: 28px;
}

.project-category {
  margin: 0 0 12px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .13em;
  line-height: 1.5;
  text-transform: uppercase;
}

.project-card h3 {
  margin: 0 0 16px;
  color: var(--navy);
  font-size: clamp(27px, 2.7vw, 35px);
  line-height: 1.15;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.project-card-copy > p:not(.project-category) {
  margin: 0 0 15px;
  color: #566a7e;
  font-size: 13px;
  line-height: 1.75;
  overflow-wrap: anywhere;
}

.project-card-copy > .project-location {
  font-weight: 700;
}

.project-services {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 6px 0 24px;
  padding: 0;
  list-style: none;
}

.project-services li {
  max-width: 100%;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: var(--paper);
  color: #566a7e;
  font-size: 10px;
  font-weight: 700;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.project-card-bottom {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: auto;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.project-card-bottom > span {
  color: #566a7e;
  font-size: 11px;
}

.project-view {
  min-height: 44px;
  padding: 10px 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--blue);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .05em;
  line-height: 1.5;
  text-align: left;
  text-transform: uppercase;
}

.project-view:hover {
  color: var(--navy);
  text-decoration: underline;
  text-underline-offset: 5px;
}

.portfolio-empty {
  margin: 0;
  padding: 35px 24px;
  border: 1px solid var(--line);
  background: var(--white);
  color: #566a7e;
  text-align: center;
}

/* Preserve native dialog visibility; overflow makes every control reachable. */
.project-dialog {
  width: min(1080px, calc(100% - 48px));
  max-width: none;
  height: auto;
  max-height: 90vh;
  max-height: 90dvh;
  margin: auto;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--silver);
  border-radius: 0;
  background: var(--white);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .3);
}

.project-dialog:not([open]) {
  display: none;
}

.project-dialog::backdrop {
  background: rgba(7, 24, 46, .84);
}

.project-dialog-shell {
  min-width: 0;
}

.project-dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 24px 28px;
  border-bottom: 1px solid var(--line);
}

.project-dialog-header > div {
  min-width: 0;
}

#project-dialog-category {
  margin: 0 0 9px;
  color: var(--blue);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
  line-height: 1.5;
  text-transform: uppercase;
}

#project-dialog-title {
  margin: 0;
  color: var(--navy);
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.15;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.project-dialog button {
  min-height: 44px;
  padding: 10px 15px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--white);
  color: var(--navy);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.5;
  transition: background-color .2s, border-color .2s;
}

.project-dialog button:hover:not(:disabled) {
  border-color: var(--silver-deep);
  background: var(--silver-light);
}

.project-dialog button:disabled {
  cursor: default;
  opacity: .5;
}

#project-dialog-close {
  flex: 0 0 auto;
  white-space: nowrap;
}

.project-dialog-media {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 20px;
  background: var(--navy);
}

/* Auto dimensions with both bounds preserve the original aspect ratio. */
#project-dialog-image {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 60vh;
  max-height: 60dvh;
  margin: 0 auto;
  object-fit: contain;
  object-position: center;
}

.project-dialog-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px 24px;
  padding: 20px 28px;
  border-top: 1px solid var(--line);
}

#project-dialog-caption {
  flex: 1 1 240px;
  min-width: 0;
  margin: 0;
  color: #566a7e;
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.project-dialog-navigation {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

#photo-count {
  margin: 0;
  color: #566a7e;
  font-size: 11px;
  font-weight: 700;
}

.portfolio button:focus-visible,
.project-dialog button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 4px;
}

.project-photo-button:focus-visible {
  outline: 3px solid var(--silver-light);
  outline-offset: -6px;
}

/* Filtering and single-photo navigation must override display declarations. */
.portfolio [hidden],
.project-dialog [hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .portfolio-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 28px;
  }

  .project-photo-button {
    height: 340px;
  }
}

@media (max-width: 620px) {
  .portfolio .section-header {
    margin-bottom: 28px;
  }

  .portfolio-filters {
    gap: 8px;
  }

  .portfolio-filter {
    padding: 10px 14px;
    font-size: 10px;
  }

  .project-photo-button {
    height: 300px;
    padding: 12px;
  }

  .project-card-copy {
    padding: 23px 20px;
  }

  .project-card h3 {
    font-size: 28px;
  }

  .project-dialog {
    width: calc(100% - 24px);
  }

  .project-dialog-header {
    flex-wrap: wrap;
    gap: 14px;
    padding: 18px;
  }

  .project-dialog-header > div {
    flex: 1 1 180px;
  }

  #project-dialog-title {
    font-size: 25px;
  }

  .project-dialog-media {
    padding: 12px;
  }

  #project-dialog-image {
    max-height: 50vh;
    max-height: 50dvh;
  }

  .project-dialog-footer {
    display: block;
    padding: 18px;
  }

  .project-dialog-navigation {
    justify-content: space-between;
    gap: 8px;
    margin-top: 15px;
  }

  .project-dialog button {
    padding: 10px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portfolio *,
  .project-dialog * {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }
}
