/* ===== Mastodon feed widget ===== */
#masto-widget {
  position: absolute;
  /* centered under the flip card */
  top: 100px;
  left: calc(50% - 160px);
  width: 320px;
  max-height: 500px;
  overflow-y: auto;
  z-index: 1;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(28px) saturate(1.4);
  -webkit-backdrop-filter: blur(28px) saturate(1.4);
  cursor: grab;
  border-radius: 16px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  padding: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}

#masto-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  margin-bottom: 8px;
}

#masto-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

#masto-user {
  display: flex;
  flex-direction: column;
}

#masto-display {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
}

#masto-handle {
  font-size: 12px;
  color: #888;
  text-decoration: none;
}
#masto-handle:hover {
  text-decoration: underline;
}

#masto-posts {
  display: flex;
  flex-direction: column;
}

.masto-post {
  padding: 12px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.masto-post:last-child {
  border-bottom: none;
}

.masto-post-time {
  font-size: 11px;
  color: #aaa;
  margin-bottom: 4px;
}

.masto-post-content {
  font-size: 13px;
  line-height: 1.5;
  color: #1a1a1a;
  word-break: break-word;
}

.masto-post-content p {
  margin: 0 0 6px;
}

.masto-post-content p:last-child {
  margin-bottom: 0;
}

.masto-post-content a {
  color: #6364ff;
  text-decoration: none;
}
.masto-post-content a.mention.hashtag,
.masto-post-content a[rel="tag"] {
  color: pink;
}

.masto-media-wrap {
  position: relative;
  margin-top: 8px;
}

.masto-post-media {
  display: flex;
  gap: 4px;
  border-radius: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.masto-post-media::-webkit-scrollbar { display: none; }

.masto-post-media img,
.masto-post-media video {
  flex: 0 0 auto;
  width: 48%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
}

/* a lone video fills the row instead of sitting at half width */
.masto-post-media video:only-child {
  width: 100%;
  max-height: 240px;
  background: #000;
}

.masto-media-arrow {
  display: none;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-size: 20px;
  line-height: 28px;
  text-align: center;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  z-index: 2;
}
.masto-arrow-right {
  right: 4px;
}
.masto-arrow-left {
  left: 4px;
}
.masto-media-arrow:hover {
  background: rgba(0, 0, 0, 0.55);
}

.masto-post-stats {
  display: flex;
  gap: 16px;
  margin-top: 8px;
  font-size: 11px;
  color: #aaa;
}

.masto-loading {
  text-align: center;
  padding: 20px;
  color: #aaa;
  font-size: 13px;
}

/* ---- Lightbox overlay ---- */
#masto-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  justify-content: center;
  align-items: center;
  cursor: pointer;
}
#masto-lightbox.visible {
  display: flex;
}
#masto-lightbox img {
  max-width: 90vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

#masto-load-more {
  display: block;
  width: auto;
  min-width: 50px;
  margin: 7px auto;
  text-align: center;
  padding: 5px 11px;
  color: white;
  background: pink;
  border-radius: 5px;
  font-family: inherit;
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 0.7px;
  transition: background-color 0.2s ease, transform 0.2s ease;
}
#masto-load-more:hover {
  color: white;
  background: #f3aabd;
  transform: translateY(-1px);
}

#masto-load-more.is-loading {
  cursor: wait;
  letter-spacing: 0.5px;
  pointer-events: none;
}

.masto-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: 4px;
  vertical-align: middle;
}

.masto-loading-dots span {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
  animation: masto-loading-bounce 0.9s ease-in-out infinite;
}

.masto-loading-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.masto-loading-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes masto-loading-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .masto-loading-dots span {
    animation: none;
    opacity: 0.7;
  }
}

/* Hide on mobile / portrait */
@media only screen and (max-width: 820px) and (orientation: portrait) {
  #masto-widget { display: none; }
}
