/* Base container */
.bluesky-feed-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 1rem;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Horizontal scroll layout */
.bluesky-feed-container[data-scroll-direction="horizontal"] {
  max-width: 100%;
}

.bluesky-feed-container[data-scroll-direction="horizontal"] .bluesky-feed-scroller {
  display: flex;
  flex-wrap: nowrap;
  align-items: flex-start;
  overflow-x: scroll;
  overflow-y: hidden;
  padding: 1rem;
  gap: 1rem;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.bluesky-feed-container[data-scroll-direction="horizontal"] .bluesky-post {
  flex: 0 0 400px; /* Fixed width for horizontal posts */
  max-height: 550px; /* Control post height */
  overflow-y: auto; /* Allow scrolling within post if content is too long */
  scroll-snap-align: start;
  margin-bottom: 0;
  padding: 1rem;
}

/* Vertical scroll layout */
.bluesky-feed-container[data-scroll-direction="vertical"] .bluesky-feed-scroller {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow-y: scroll;
  overflow-x: hidden;
  padding: 1rem;
  gap: 1rem;
}

.bluesky-feed-scroller::-webkit-scrollbar {
  display: none;
}

.bluesky-feed-container[data-scroll-direction="vertical"] .bluesky-post {
  width: 100%;
  margin-right: 0;
}

/* Navigation buttons positioning */
.bluesky-feed-container[data-scroll-direction="horizontal"] .bluesky-nav-buttons {
  position: sticky;
  bottom: 1rem;
  background: transparent;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.bluesky-feed-container[data-scroll-direction="vertical"] .bluesky-nav-buttons {
  position: static;
  box-shadow: none;
}

/* Feed scroller */
.bluesky-feed-scroller {
  /* Enable hardware acceleration */
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  -webkit-perspective: 1000;
  perspective: 1000;
  will-change: scroll-position;

  /* Ensure smooth scrolling */
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;

  /* Prevent scroll chaining on iOS */
  overscroll-behavior: contain;

  /* Prevent unwanted scroll animations */
  scroll-snap-type: none;
}

/* Scrollbar styling */
.bluesky-feed-scroller::-webkit-scrollbar {
  height: 6px;
}

.bluesky-feed-scroller::-webkit-scrollbar-track {
  background: transparent;
}

.bluesky-feed-scroller::-webkit-scrollbar-thumb {
  background-color: #cbd5e1;
  border-radius: 3px;
}

/* Individual post */
.bluesky-post {
  display: flex;
  flex-direction: column;
  min-height: 200px; /* Ensure consistent height */
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  margin: 8px;
  padding: 0;
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.2s ease;
  position: relative; /* Keep relative positioning */
  width: 300px; /* Set consistent width */
}

.bluesky-post:hover {
  transform: translateY(-2px);
  border-color: rgba(0, 140, 255, 0.3);
  box-shadow: 0 0 20px rgba(0, 140, 255, 0.2);
}

/* Post header */
.bluesky-post-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.bluesky-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #e5e7eb;
  flex-shrink: 0;
}

.bluesky-author-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.bluesky-display-name {
  font-weight: 600;
  color: #1f2937;
  font-size: 1.1rem;
  line-height: 1.2;
}

.bluesky-handle {
  color: #6b7280;
  font-size: 0.95rem;
}

/* Post content */
.bluesky-post-content {
  font-size: 1rem;
  line-height: 1.5;
  color: #1f2937;
  overflow-wrap: break-word;
  word-wrap: break-word;
}

/* Links in post */
.bluesky-link {
  color: #2563eb;
  text-decoration: none;
}

.bluesky-link:hover {
  text-decoration: underline;
}

/* Mentions and hashtags */
.bluesky-mention,
.bluesky-hashtag {
  color: #2563eb;
  text-decoration: none;
}

.bluesky-mention:hover,
.bluesky-hashtag:hover {
  text-decoration: underline;
}

/* Images container */
.bluesky-post-images {
  margin-top: 0.5rem;
  width: 100%;
  max-width: 100%;
  border-radius: 0.75rem;
  overflow: hidden;
}

/* Single image */
.bluesky-post-images:not(.bluesky-post-images-grid) .bluesky-image-wrapper {
  position: relative;
  width: 100%;
  max-height: 500px;
  aspect-ratio: 16/9;
  overflow: hidden;
  border-radius: 0.75rem;
  background-color: #f3f4f6;
}

/* Multiple images grid */
.bluesky-post-images-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  max-height: 600px;
}

.bluesky-post-images-grid .bluesky-image-wrapper {
  position: relative;
  padding-bottom: 100%;
  border-radius: 0.75rem;
  overflow: hidden;
  background-color: #f3f4f6;
}

/* Image styling */
.bluesky-post-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.bluesky-image-wrapper:hover .bluesky-post-image {
  transform: scale(1.03);
}

/* Loading state */
.bluesky-post-image.lazy {
  opacity: 0;
  transition: opacity 0.3s ease;
}

.bluesky-post-image.loaded {
  opacity: 1;
}

/* Post footer */
.bluesky-post-footer {
  position: absolute;
  top: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85em;
  color: #666;
}

.bluesky-timestamp::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-right: 4px;
  vertical-align: middle;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="%23666" d="M111.8 62.2C170.2 105.9 233 194.7 256 242.4c23-47.6 85.8-136.4 144.2-180.2c42.1-31.6 110.3-56 110.3 21.8c0 15.5-8.9 130.5-14.1 149.2C478.2 298 412 314.6 353.1 304.5c102.9 17.5 129.1 75.5 72.5 133.5c-107.4 110.2-154.3-27.6-166.3-62.9l0 0c-1.7-4.9-2.6-7.8-3.3-7.8s-1.6 3-3.3 7.8l0 0c-12 35.3-59 173.1-166.3 62.9c-56.5-58-30.4-116 72.5-133.5C100 314.6 33.8 298 15.7 233.1C10.4 214.4 1.5 99.4 1.5 83.9c0-77.8 68.2-53.4 110.3-21.8z"/></svg>');
  background-size: contain;
  background-repeat: no-repeat;
}

.bluesky-timestamp {
  font-size: 0.875rem;
  color: #666;
  position: static;
  margin-left: 0;
}

/* Navigation buttons */
.bluesky-nav-buttons {
  display: flex;
  justify-content: space-between;
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  transform: translateY(-50%);
  z-index: 2;
  pointer-events: none; /* Allow clicking through the container */
  padding: 0 10px;
}

.bluesky-nav-button {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  pointer-events: auto; /* Re-enable clicking for buttons */
  padding: 0;
}

.bluesky-nav-button svg {
  width: 20px;
  height: 20px;
  fill: #333;
  transition: fill 0.2s ease;
}

.bluesky-nav-button:hover {
  background: white;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
}

.bluesky-nav-button:hover svg {
  fill: #0066cc;
}

/* Loading spinner */
.bluesky-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 2rem;
}

.bluesky-loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #f3f4f6;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spinner 0.8s linear infinite;
}

.bluesky-feed-footer {
  text-align: center;
  color: #666;
  font-size: 0.9em;
  margin-top: 1rem;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Error state */
.bluesky-feed-error {
  padding: 1rem;
  background-color: #fee2e2;
  border: 1px solid #fecaca;
  border-radius: 0.5rem;
  color: #991b1b;
  margin: 1rem 0;
}

/* Responsive design */
@media (max-width: 768px) {
  .bluesky-feed-container {
    padding: 0.5rem;
  }

  .bluesky-post {
    padding: 1rem;
    min-height: 150px;
  }

  .bluesky-post-images:not(.bluesky-post-images-grid) .bluesky-image-wrapper {
    max-height: 300px;
  }

  .bluesky-post-images-grid {
    max-height: 400px;
  }

  .bluesky-avatar {
    width: 40px;
    height: 40px;
  }

  .bluesky-display-name {
    font-size: 1rem;
  }

  .bluesky-handle {
    font-size: 0.875rem;
  }
}

@media (max-width: 480px) {
  .bluesky-post {
    padding: 0.875rem;
  }

  .bluesky-post-images:not(.bluesky-post-images-grid) .bluesky-image-wrapper {
    max-height: 250px;
  }

  .bluesky-post-images-grid {
    max-height: 300px;
  }

  .bluesky-nav-buttons {
    gap: 0.5rem;
  }

  .bluesky-nav-button {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
  }
}

/* Accessibility improvements */
.bluesky-nav-button:focus,
.bluesky-post:focus-within {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .bluesky-feed-container {
    max-width: 100%;
  }

  .bluesky-nav-buttons,
  .bluesky-loading {
    display: none;
  }

  .bluesky-post {
    break-inside: avoid;
    border: 1px solid #000;
  }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
  .bluesky-post {
    background-color: #1a1a1a;
    border-color: #333;
    color: #e5e5e5;
  }

  .bluesky-display-name {
    color: #e5e5e5;
  }

  .bluesky-handle {
    color: #999;
  }

  .bluesky-post-content {
    color: #e5e5e5;
  }

  .bluesky-timestamp {
    color: #999;
  }

  .bluesky-nav-button:hover:not(:disabled) {
    background-color: #333;
  }

  .bluesky-image-wrapper {
    background-color: #333;
  }

  .bluesky-feed-container[data-scroll-direction="horizontal"] .bluesky-nav-buttons {
    background-color: transparent;
  }
}
