/**
 * Facebook Posts Block Styles
 * Matches WordPress core post card styling
 */

/* Container - Grid layout for cards */
.wp-block-fpb-facebook-posts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  container-type: inline-size;
  gap: var(--wp--preset--spacing--30);
  align-items: start; /* Prevent cards from stretching to match tallest */
}

/* Post Card - Matches wp-block-group styling */
.fpb-post-card {
  display: flex;
  flex-direction: column;
  background-color: var(--wp--preset--color--white, #ffffff);
  border: 2px solid var(--wp--preset--color--dark, currentColor);
  padding: var(--wp--preset--spacing--30, 1.25rem);
  color: var(--wp--preset--color--dark, #000000) !important;
}

/* Post Header - Date and Facebook link */
.fpb-post-card .fpb-post-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25em;
}

/* Post Date - Matches wp-block-post-date */
.fpb-post-card .wp-block-post-date {
  margin-bottom: 0;
}

.fpb-post-card .wp-block-post-date time {
  font-size: var(--wp--preset--font-size--small, 0.875rem);
  color: var(--wp--preset--color--grey, #828282);
  text-transform: uppercase;
}

/* Facebook Link */
.fpb-post-card .fpb-facebook-link {
  display: flex;
  align-items: center;
  color: inherit;
}

.fpb-post-card .fpb-facebook-link:hover {
  opacity: 1;
}

.fpb-post-card .fpb-facebook-link svg {
  width: 24px;
  height: 24px;
}

.fpb-post-card .wp-block-post-title a {
  color: inherit;
  text-decoration: none;
}

.fpb-post-card .wp-block-post-title a:hover {
  text-decoration: underline;
}

.fpb-post-card .wp-block-post-excerpt__excerpt {
  margin: 0 0 1em;
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: var(--fpb-truncate-lines, 3);
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fpb-post-card p.wp-block-post-excerpt__excerpt {
  color: var(--wp--preset--color--dark, #000000) !important;
}

.fpb-post-card .wp-block-post-excerpt__more-text {
  margin: 0;
}

.fpb-post-card .wp-block-post-excerpt__more-link {
  display: inline-block;
  color: inherit;
  text-decoration: underline;
  font-weight: 500;
}

.fpb-post-card .wp-block-post-excerpt__more-link:hover {
  text-decoration: none;
}

/* Post Image */
.fpb-post-card .fpb-post-image {
  line-height: 0;
  position: relative;
}

.fpb-post-card .fpb-post-image img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* Video Thumbnail Styles */
.fpb-post-card .fpb-video-thumbnail {
  position: relative;
  cursor: pointer;
}

.fpb-post-card .fpb-video-link {
  display: block;
  position: relative;
  text-decoration: none;
}

.fpb-post-card .fpb-video-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.1);
  transition: background 0.3s ease;
}

.fpb-post-card .fpb-video-link:hover .fpb-video-overlay {
  background: rgba(0, 0, 0, 0.2);
}

.fpb-post-card .fpb-play-icon {
  width: 64px;
  height: 64px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
  transition: transform 0.3s ease;
}

.fpb-post-card .fpb-video-link:hover .fpb-play-icon {
  transform: scale(1.1);
}

/* Event Badge */
.fpb-post-card .fpb-event-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.4em 0.8em;
  background: var(--wp--preset--color--primary, #1877f2);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 4px;
  margin-bottom: 0.75em;
}

.fpb-post-card .fpb-event-badge svg {
  width: 16px;
  height: 16px;
  stroke: white;
}

/* Shared Event Badge - slightly different styling */
.fpb-post-card .fpb-event-badge.fpb-shared-event {
  background: var(--wp--preset--color--secondary, #42b883);
  position: relative;
}

.fpb-post-card .fpb-event-badge.fpb-shared-event::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 0.25em;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12v8a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-8'/%3E%3Cpolyline points='16 6 12 2 8 6'/%3E%3Cline x1='12' y1='2' x2='12' y2='15'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

/* Event Title */
.fpb-post-card .fpb-event-title {
  margin-bottom: 0.75em;
}

.fpb-post-card .fpb-event-title h3 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.3;
  color: var(--wp--preset--color--dark, #000000);
  font-weight: 700;
}

/* Event Link Button */
.fpb-post-card .fpb-event-link {
  margin-top: 1em;
}

.fpb-post-card .fpb-event-button {
  display: inline-block;
  padding: 0.6em 1.2em;
  background: var(--wp--preset--color--primary, #1877f2);
  color: white !important;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 600;
  font-size: 0.9rem;
  transition: background 0.3s ease, transform 0.2s ease;
}

.fpb-post-card .fpb-event-button:hover {
  background: #166fe5;
  transform: translateY(-1px);
}

/* Video Badge (Optional - for marking video posts) */
.fpb-post-card.has-video::before {
  content: "";
  /* Can add styling if you want a visual indicator on card */
}

.fpb-post-card.has-event {
  /* Optional: special styling for event cards */
}

/* No Posts Message */
.fpb-no-posts {
  padding: var(--wp--preset--spacing--40, 2rem);
  text-align: center;
  background: var(--wp--preset--color--white, #ffffff);
  border: 2px dashed var(--wp--preset--color--dark, currentColor);
  color: inherit;
}

/* Responsive Design */
@media (max-width: 1024px) {
  .wp-block-fpb-facebook-posts {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .wp-block-fpb-facebook-posts {
    grid-template-columns: 1fr;
  }

  .fpb-post-card .fpb-play-icon {
    width: 48px;
    height: 48px;
  }

  .fpb-post-card .fpb-event-title h3 {
    font-size: 1.1rem;
  }

  .fpb-post-card .fpb-event-button {
    width: 100%;
    text-align: center;
  }
}

/* Ensure the block wrapper doesn't constrain the grid */
.wp-block[data-type="fpb/facebook-posts"] {
  max-width: none;
}

.editor-styles-wrapper .fpb-post-card a {
  cursor: default;
  pointer-events: none;
}

/* Alignment Support */
.wp-block-fpb-facebook-posts.alignwide {
  max-width: var(--wp--style--global--wide-size, 1280px);
}

.wp-block-fpb-facebook-posts.alignfull {
  max-width: none;
  padding-left: var(--wp--preset--spacing--30, 20px);
  padding-right: var(--wp--preset--spacing--30, 20px);
}

/* Loading State */
.fpb-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 200px;
}

.fpb-loading::after {
  content: "";
  width: 40px;
  height: 40px;
  border: 4px solid var(--wp--preset--color--dark, currentColor);
  border-top-color: transparent;
  border-radius: 50%;
  animation: fpb-spin 1s linear infinite;
}

@keyframes fpb-spin {
  to {
    transform: rotate(360deg);
  }
}
