/* =========================
   IG Stories — Frontend CSS
   ========================= */

/* ---------- Header (shortcode) ---------- */

.igs-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 12px 0;
}

/* Profile picture base */
.igs-profile-picture {
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  position: relative;
  overflow: visible; /* allow ring to show outside */
  display: inline-block;
  cursor: pointer;
}

/* Profile picture with "new story" ring */
.igs-profile-picture.igs-has-new::after {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border-radius: 50%;
  padding: 3px; /* creates inner space for the gradient ring */
  background: conic-gradient(
    from 0deg,
    #ff1450,
    #ff7300,
    #ff1450,
    #ff1450
  );
  -webkit-mask: 
    linear-gradient(#000 0 0) content-box, 
    linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: igs-ring-spin 3s linear infinite;
  pointer-events: none;
  z-index: 3;
}

/* Keep the animation keyframes (same as before) */
@keyframes igs-ring-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}


/* Animation for the ring */
@keyframes igs-ring-spin {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Image inside profile picture */
.igs-profile-picture img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 50%;
}

.igs-profile-placeholder {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #eee, #ddd);
}

/* Metadata (username, stats, bio) */
.igs-profile-meta {
  flex: 1 1 auto;
  min-width: 0; /* important for text-overflow in flex children */
  display: flex;
  flex-direction: column;
}

.igs-topline {
  display: flex;
  align-items: center;
  justify-content: space-between; /* username left, stats right */
  gap: 12px;
  width: 100%;
  box-sizing: border-box;
}

.igs-username {
  font-weight: 700;
  font-size: 1.03rem;
  margin-right: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  min-width: 0;
}

.igs-stats {
  color: #666;
  font-size: 0.95rem;
  display: inline-flex;
  gap: 12px;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.igs-stats .igs-posts,
.igs-stats .igs-followers {
  display: inline-block;
  margin: 0;
}

.igs-stats br {
  display: inline-block; /* keep the line-break as the user requested */
  line-height: 1.25;
  margin-bottom: 4px;
}

.igs-bio {
  margin: 6px 0 0 0;
  color: #333;
  font-size: 0.95rem;
  max-width: 60ch;
  word-break: break-word;
  line-height: 1.35;
}

/* Small screens: stack username + stats vertically for better fit */
@media (max-width: 540px) {
  .igs-topline {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .igs-stats {
    /* allow wrap on small screens and look tidy */
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
}

/* ---------- Overlay / Viewer ---------- */
.igs-overlay {
  position: fixed;
  inset: 0;
  background: rgba(252,185,0,0.8);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  transform: translateZ(0)
}

.igs-viewer {
  position: relative;
  width: 100%;
  max-width: 1100px;
  max-height: 80vh;
  box-sizing: border-box;
  display: flex;
  align-items: stretch;
  justify-content: center;
  background: rgb(0,0,0);
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  overflow: hidden;
}

/* Media container (video / img) */
.igs-media-wrap {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.1);
  overflow: hidden;
  min-height: 320px;
  aspect-ratio: 9 / 16;
  border-radius: 10px;
  transform: translateZ(0)
  
}

/* Make injected video/img fill the container */
.igs-media-wrap video,
.igs-media-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  aspect-ratio: 9 / 16;
  border-radius: inherit;
  
}

/* ---------- Progress bar (top) ---------- */
.igs-progress-wrap {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  height: 6px;
  display: flex;
  gap: 6px;
  z-index: 20000;
  pointer-events: none;
}

.igs-progress-segment {
  flex: 1 1 0;
  background: rgba(255,255,255,0.18);
  border-radius: 4px;
  overflow: hidden;
  height: 100%;
  min-width: 10px;
}

.igs-progress-fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, rgba(255,255,255,1), rgba(255,255,255,0.9));
  transition: width 0s linear;
  transform-origin: left center;
}

/* ---------- Buttons (unmute / exit) ---------- */
.igs-media-wrap .igs-btn-unmute,
.igs-media-wrap .igs-btn-exit {
  position: absolute;
  top: 12px;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  border: none;
  background: rgba(0,0,0,0.4);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 30000;
  -webkit-tap-highlight-color: transparent;
  backdrop-filter: blur(4px);
}

.igs-media-wrap .igs-btn-exit {
  right: 12px;
}

.igs-media-wrap .igs-btn-unmute {
  right: 68px; /* leave space from exit button */
}

/* Make buttons slightly larger on mobile */
@media (max-width: 480px) {
  .igs-media-wrap .igs-btn-unmute,
  .igs-media-wrap .igs-btn-exit {
    width: 52px;
    height: 52px;
    font-size: 20px;
    border-radius: 10px;
    top: 14px;
    right: 12px;
  }
  .igs-media-wrap .igs-btn-unmute { right: 74px; }
}

/* ---------- Fullscreen adjustments ----------
.igs-viewer:-webkit-full-screen,
.igs-viewer:-moz-full-screen,
.igs-viewer:-ms-fullscreen,
.igs-viewer:fullscreen {
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  padding: 0;
}

.igs-viewer:fullscreen .igs-progress-wrap,
.igs-viewer:-webkit-full-screen .igs-progress-wrap {
  top: 18px;
  left: 18px;
  right: 18px;
  height: 6px;
}

.igs-viewer:fullscreen .igs-media-wrap .igs-btn-unmute,
.igs-viewer:fullscreen .igs-media-wrap .igs-btn-exit,
.igs-viewer:-webkit-full-screen .igs-media-wrap .igs-btn-unmute,
.igs-viewer:-webkit-full-screen .igs-media-wrap .igs-btn-exit {
  top: 18px;
  right: 18px;
}
---------- end fullscreen adjustments ---------- */

/* ---------- Misc UI helpers ---------- */
.igs-overlay * {
  box-sizing: border-box;
}

.igs-info-wrap {
  width: 320px;
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  color: #222;
}

.igs-close {
  float: right;
  border: none;
  background: transparent;
  font-size: 18px;
  cursor: pointer;
}

.igs-caption {
  margin-top: 18px;
  font-size: 14px;
  color: #333;
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  .igs-viewer {
    flex-direction: column;
    max-width: 96%;
    height: 100vh;
  }
  .igs-info-wrap {
    width: 100%;
    height: auto;
    max-height: 30vh;
    overflow: auto;
    border-radius: 0 0 8px 8px;
  }
  .igs-media-wrap {
    /* height: 70vh; */
    border-radius: 8px 8px 0 0;
  }
  .igs-progress-wrap {
    top: 8px;
    left: 8px;
    right: 8px;
    height: 5px;
    gap: 4px;
  }
}

/* ---------- Accessibility focus outlines ---------- */
.igs-media-wrap .igs-btn-unmute:focus,
.igs-media-wrap .igs-btn-exit:focus {
  outline: 2px solid rgba(255,255,255,0.9);
  outline-offset: 2px;
}

/* ---------- Tiny polish ---------- */
.igs-media-wrap {
  transition: transform 160ms ease;
}

.profile-pic-wrapper {
  position: relative;
  display: inline-block;
  border-radius: 50%;
  padding: 4px; /* thickness of the ring */
  background: conic-gradient(
    from 0deg,
    #ff0057,
    #ff7b00,
    #ffdd00,
    #00ff85,
    #0099ff,
    #b400ff,
    #ff0057
  );
  animation: rotateRing 2.5s linear infinite;
}

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

.profile-pic {
  display: block;
  border-radius: 50%;
  border: 3px solid #fff; /* inner white border for contrast */
  width: 80px;
  height: 80px;
}

@media (min-width: 768px) {
  .igs-viewer {
    width: 100%;
    max-height: 90vh;
    max-width: calc(90vh * 9 / 16); /* keeps 9:16 aspect ratio */
    aspect-ratio: 9 / 16;
    margin: 0 auto; /* center horizontally */
    border-radius: 10px; /* same as mobile */
  }

  .igs-media-wrap {
    aspect-ratio: 9 / 16;
    max-height: 90vh;
    max-width: calc(90vh * 9 / 16);
    border-radius: 10px;
  }

  .igs-media-wrap video,
  .igs-media-wrap img {
    object-fit: cover; /* keeps video/image filling the container */
    aspect-ratio: 9 / 16;
    max-height: 90vh;
    max-width: calc(90vh * 9 / 16);
  }
}
