/* Post Directory Grid & Form Styles */
.post-directory * {
  box-sizing: border-box;
}
.post-directory {
  width: 100%;
  box-sizing: border-box;
}

/* Form Styles */
.pd-search-form {
  margin-bottom: 4rem;
  width: 90%;
  max-width: var(--wp--style--global--content-size);
  margin-inline: auto;
}

.pd-search-header {
  margin-bottom: 1.25rem;
}

.pd-search-headline {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.pd-search-intro {
  font-size: 0.95rem;
  line-height: 1.4;
}

.pd-search-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  align-items: flex-start;
  justify-content: end;
}

.pd-filter-group {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
  flex-basis: calc(50% - 0.5rem);
}

.pd-filter-group label {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--wp--preset--color--brown);
}

.pd-filter-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.pd-reset-link {
  font-size: 0.9rem;
  color: var(--wp--preset--color--brown, #4a3828);
  text-decoration: underline;
}

/* Grid Layout */
.pd-grid {
  display: grid;
  grid-template-columns: repeat(1, 1fr);
  gap: 2rem;
  width: 90%;
  max-width: var(--wp--style--global--content-size);
  margin-inline: auto;
}

.pd-card {
  position: relative;
  background-color: #fff;
  border-radius: 1.667rem;
  padding: 1.389rem 1.556rem;
  box-shadow: 0 1px 4px 0px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.pd-grid .pd-card:hover {
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.pd-card-cover-link {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  border-radius: inherit;
}

.pd-card-content {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.pd-card-content > *:not(:first-child) {
  margin-top: 0.889rem !important;
  margin-block-start: 0.889rem !important;
  margin-bottom: 0 !important;
}

.pd-card-content p:has(svg) {
  color: var(--wp--preset--color--darkgreen);
}

.pd-card-title + .pd-card-address {
  margin-top: 0.444rem !important;
  margin-block-start: 0.444rem !important;
}

.pd-card-image img {
  width: 100%;
  height: auto;
  max-height: 200px;
  border-radius: 0.9rem;
  object-fit: contain;
  margin-bottom: 0.889rem;
  border: 1px solid #f1f1f1;
  padding: 0.5rem;
}

.pd-card-title {
  margin: 0;
  font-family: var(--wp--preset--font-family--open-sans);
  color: var(--wp--preset--color--black);
  font-size: 1rem;
  font-weight: 700;
}

.pd-card-title a {
  color: inherit;
  text-decoration: none;
}

.pd-card-title a:hover {
  text-decoration: underline;
}

.pd-card-link {
  margin-top: auto;
}

.pd-card-more-link {
  display: inline-block;
  font-size: var(--wp--preset--font-size--small, 0.95rem);
  font-weight: 600;
  color: var(--wp--preset--color--darkgreen, #306d1f);
  text-decoration: underline;
  transition: color 0.2s ease;
}

.pd-card-more-link:hover {
  color: var(--wp--preset--color--brown, #8c4b27);
  text-decoration: underline;
}
.pd-card-phone,
.pd-card-email,
.pd-card-instagram,
.pd-card-website {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 0.611rem;
  margin-top: 0.889rem !important;
  margin-block-start: 0.889rem !important;
  margin-bottom: 0 !important;
}

.pd-card-phone,
.pd-card-phone a,
.pd-card-email a,
.pd-card-instagram a,
.pd-card-website a {
  font-size: var(--wp--preset--font-size--small);
  color: var(--wp--preset--color--darkgreen);
}

/* Pagination Styles */
.pd-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 3.5rem;
}

.pd-page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: 50vw;
  border: 1px solid #d9d9d9;
  color: var(--wp--preset--color--darkgreen);
  text-decoration: none;
  font-size: var(--wp--preset--font-size--small);
  background-color: #fff;
  transition: all 0.2s ease;
}

.pd-page-link:hover {
  border-color: var(--wp--preset--color--darkgreen);
  background-color: var(--wp--preset--color--cream, #f9f6f0);
}

.pd-page-link.is-active {
  background-color: var(--wp--preset--color--darkgreen);
  color: #fff;
  border-color: var(--wp--preset--color--darkgreen);
  font-weight: 700;
}

/* Map & Marker Styles */
.pd-map-wrapper {
  position: relative;
  margin-bottom: 3rem;
  width: 100%;
  aspect-ratio: 16 / 9;
  max-height: 60vh;
  border-radius: 1.5rem;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: none;
}

.pd-map-wrapper.is-dragging {
  cursor: grabbing;
}

.pd-map-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
  transition: transform 0.08s ease-out;
  will-change: transform;
}

.pd-map-container.is-animating {
  transition: transform 0.25s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

.pd-map-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

/* Map Zoom Controls (+ / - / reset) */
.pd-map-controls {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.pd-map-control-btn {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background-color: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--wp--preset--color--darkgreen, #306d1f);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  transition: all 0.2s ease;
  user-select: none;
  padding: 0;
}

.pd-map-control-btn:hover {
  background-color: var(--wp--preset--color--darkgreen, #306d1f);
  color: #ffffff;
  border-color: var(--wp--preset--color--darkgreen, #306d1f);
}

.pd-map-markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pd-map-marker {
  position: absolute;
  display: block;
  width: 24px;
  height: 32px;
  transform: translate3d(-50%, -100%, 0);
  transform-origin: 50% 100%;
  cursor: pointer;
  z-index: 5;
  pointer-events: auto;
  transition: transform 0.15s ease-out;
  backface-visibility: hidden;
  -webkit-font-smoothing: subpixel-antialiased;
  will-change: transform;
}

.pd-map-marker:hover {
  z-index: 10;
}

.pd-marker-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.25));
  pointer-events: none;
}

.pd-marker-path {
  fill: var(--wp--preset--color--darkgreen, #306d1f);
  transition: fill 0.2s ease;
}

.pd-map-marker:hover .pd-marker-path {
  fill: var(--wp--preset--color--brown, #4a3828);
}

/* Cluster & Spiderfying styles */
.pd-map-cluster {
  position: absolute;
  width: 36px;
  height: 36px;
  transform: translate3d(-50%, -50%, 0);
  transform-origin: 50% 50%;
  background-color: var(--wp--preset--color--darkgreen, #306d1f);
  color: #ffffff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 14px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  z-index: 10;
  pointer-events: auto;
  transition:
    transform 0.15s ease-out,
    background-color 0.2s ease;
  backface-visibility: hidden;
  -webkit-font-smoothing: subpixel-antialiased;
  will-change: transform;
}

.pd-map-cluster:hover {
  background-color: var(--wp--preset--color--brown, #4a3828);
  z-index: 15;
}

.pd-map-marker.is-spiderfied {
  z-index: 8;
  filter: drop-shadow(0 2px 5px rgba(0, 0, 0, 0.2));
}

.pd-spider-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

.pd-card.is-active-card {
  outline: 2px solid var(--wp--preset--color--darkgreen);
  box-shadow: 0 8px 25px rgba(48, 109, 31, 0.15);
}

/* Map-enabled full width layout (Mobile first default) */
.post-directory .pd-map-layout {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: auto;
  max-height: none;
  margin-bottom: 3rem;
}

.post-directory .pd-map-layout .pd-map-wrapper {
  position: relative;
  width: 100%;
  height: 400px;
  max-height: 40vh;
  margin-bottom: 1.5rem;
  border-radius: 1.5rem;
}

.post-directory .pd-map-layout .pd-map-overlay {
  position: relative;
  top: auto;
  left: auto;
  transform: none;
  bottom: auto;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: auto;
  gap: 1.5rem;
  width: 90%;
  margin-inline: auto;
}

.post-directory .pd-map-layout .pd-map-overlay .pd-map-search {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 2rem;
  height: 100%;
  pointer-events: auto;
}

/* Left side Search Form in Map Layout */
.post-directory .pd-map-layout .pd-search-form {
  pointer-events: auto;
  width: 100%;
  max-width: 100%;
  margin-bottom: 0;
  margin-inline: unset;
}

.post-directory .pd-map-layout .pd-search-filters {
  flex-direction: column;
  gap: 1rem;
}

.post-directory .pd-map-layout .pd-filter-group {
  width: 100%;
}

/* Right side Card Panel in Map Layout */
.post-directory .pd-map-layout .pd-map-card-panel {
  pointer-events: auto;
  width: 100%;
  max-width: 100%;
  position: relative;
  background: #ffffff;
  color: var(--wp--preset--color--black, #000000);
  border-radius: 1.25rem;
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.18);
  padding: 0.889rem 1rem;
  display: none; /* hidden until marker click */
  animation: pdSlideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  max-height: none;
  min-height: calc(36px + 0.889rem);
}

.pd-no-results {
  color: var(--wp--preset--color--black, #000000);
  margin: 0;
}

.pd-map-card-panel .pd-no-results {
  padding-right: 2.5rem;
}

.post-directory .pd-map-layout .pd-map-card-panel.is-open {
  display: block;
}

.post-directory .pd-map-layout .pd-map-card-panel.is-closing {
  display: block;
  animation: pdSlideOutRight 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.pd-map-card-panel .pd-grid {
  display: block !important;
  margin-inline: unset;
  width: 100%;
}

.pd-map-card-panel .pd-grid article {
  max-width: 100%;
}

.pd-map-card-panel .pd-pagination {
  display: none !important;
}

.pd-map-card-panel .pd-card {
  display: none;
  width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
}

.pd-map-card-panel .pd-card.is-active-card {
  display: flex !important;
  flex-direction: column;
  align-items: stretch;
  gap: 0.75rem;
}

.pd-map-card-panel .pd-card-image {
  flex: none;
  width: 100%;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.pd-map-card-panel .pd-card-image a {
  display: block;
  width: 100%;
  height: 100%;
}

.pd-map-card-panel .pd-card-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 0.889rem;
  max-height: 120px;
  margin-bottom: 0;
}

.pd-map-card-panel .pd-card-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin: 0;
  padding-right: 2.5rem;
}

.pd-map-card-panel .pd-card-title {
  font-size: 1.05rem;
  line-height: 1.35;
}

.pd-map-card-panel .pd-card-address {
  font-size: 0.667rem;
  color: #71717a;
}

.pd-map-card-panel .pd-card-content > .pd-card-link {
  margin-top: 0.75rem !important;
  margin-block-start: 0.75rem !important;
}

/* Close button on Map Card Panel */
.pd-card-close-btn {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--wp--preset--color--cream, #f4f0e8);
  border: none;
  font-size: 1.25rem;
  line-height: 1;
  color: var(--wp--preset--color--darkgreen);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  transition: all 0.2s ease;
}

.pd-reset-button {
  display: inline-flex;
  border: 0;
  color: var(--wp--preset--color--grayish-green);
  background-color: transparent;
  font-size: var(--wp--preset--font-size--small, 0.95rem);
  cursor: pointer;
}

.pd-reset-button:hover {
  text-decoration: underline;
}

.post-directory .pd-map-layout .pd-reset-button {
  width: 100%;
}

@keyframes pdSlideInRight {
  from {
    opacity: 0;
    transform: translateX(25px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes pdSlideOutRight {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(25px);
  }
}

@media only screen and (min-width: 600px) {
  .pd-map-card-panel .pd-card.is-active-card {
    gap: 0.889rem;
  }

  .pd-map-card-panel .pd-card-image {
    flex: 0 0 98px;
    width: 98px;
  }

  .pd-map-card-panel .pd-card-image img {
    max-height: 98px;
    width: auto;
  }
}

.post-directory.has-map .pd-map-layout .pd-map-wrapper {
  margin-bottom: 0;
}

.post-directory.has-map .pd-map-layout .pd-map-card-panel {
  margin-top: 1.5rem;
}

@media only screen and (min-width: 990px) {
  .post-directory .pd-map-layout {
    position: relative;
    height: 800px;
    max-height: 60vh;
  }

  .post-directory .pd-map-layout .pd-map-wrapper {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    max-height: 60vh;
    margin-bottom: 0;
    border-radius: 0;
  }

  .post-directory .pd-map-layout .pd-map-overlay {
    position: absolute;
    top: 2.5rem;
    bottom: 2.5rem;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 1400px;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
    pointer-events: none;
    gap: 1.5rem;
    z-index: 9;
  }

  .post-directory .pd-map-layout .pd-search-form {
    width: 320px;
    pointer-events: auto;
  }

  .post-directory .pd-map-layout .pd-map-card-panel {
    width: 440px;
    max-width: calc(100% - 2rem);
    max-height: 100%;
    margin-left: auto;
    margin-top: 0;
    pointer-events: auto;
  }

  .pd-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 3rem;
  }

  .pd-map-card-panel .pd-grid article {
    max-width: calc(100% - 2rem);
  }
}
