/* User profile page styles */

/* User Profile */
.user-profile {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 120px 24px 80px;
}

.profile-header {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--gray-200);
  margin-bottom: 40px;
}

.profile-avatar {
  flex-shrink: 0;
}

.profile-avatar img {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  object-fit: cover;
}

.avatar-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 16px;
  background: var(--blue);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 48px;
  font-weight: 600;
}

.profile-info h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 4px;
}

.profile-username {
  font-size: 18px;
  color: var(--gray-500);
  margin-bottom: 12px;
  overflow-wrap: anywhere;
}

.profile-bio {
  font-size: 16px;
  color: var(--gray-600);
  max-width: 500px;
}

.profile-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

.posts-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.post-card {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px;
}

.post-content {
  font-size: 16px;
  line-height: 1.6;
  margin-bottom: 12px;
}

.post-date {
  font-size: 14px;
  color: var(--gray-500);
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  background: var(--gray-50);
  border-radius: 12px;
}

.empty-state p {
  color: var(--gray-500);
  font-size: 16px;
}

.profile-info h1 {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 4px;
  overflow-wrap: anywhere;
  min-width: 0;
}

.profile-badges {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}

/* The Premium badge is gold artwork; give it a touch more room and a soft
   glow so it reads as the thing it is next to the flat icons. */
.badge-icon.badge-icon-premium { width: 28px; height: 28px; }
.badge-icon-premium {
  object-fit: contain;
  filter: drop-shadow(0 3px 9px rgba(201, 148, 47, 0.35));
}

/* Badge Tooltip - Electron style */
.badge-tooltip {
  position: relative;
  display: inline-flex;
  cursor: default;
}

.badge-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 12px;
  background: #35353c;
  color: #ffffff;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  border-radius: 6px;
  border: 1px solid #3e3f46;
  opacity: 0;
  pointer-events: none;
  box-shadow: 0px 4px 20px 8px rgb(0 0 0 / 34%);
  z-index: 10001;
  text-align: center;
  line-height: 1.4;
}

/* Tooltip arrow */
.badge-tooltip::before {
  content: '';
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #35353c;
  opacity: 0;
  pointer-events: none;
  z-index: 10002;
}

.badge-tooltip:hover::after,
.badge-tooltip:hover::before,
.badge-tooltip:focus-visible::after,
.badge-tooltip:focus-visible::before {
  opacity: 1;
}

/* Profile Layout */
.profile-layout {
  position: relative;
}

.profile-main {
  width: 100%;
}

/* Badge Legend - Collapsible Popup */
.badge-legend {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 10;
}

.badge-legend-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.badge-legend-toggle::-webkit-details-marker {
  display: none;
}

.badge-legend-toggle::after {
  content: '▼';
  font-size: 8px;
  transition: transform 0.2s ease;
}

.badge-legend[open] .badge-legend-toggle::after {
  transform: rotate(180deg);
}

.badge-legend-toggle:hover {
  background: var(--bg-tertiary);
}

.badge-legend-content {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 240px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.badge-legend-item {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge-legend-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.badge-legend-info {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.badge-legend-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}

.badge-legend-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.3;
}

/* Hide badge legend on mobile */
@media (max-width: 768px) {
  .badge-legend {
    display: none;
  }
}

/* Premium Profile Styling */
.premium-name {
  background: linear-gradient(135deg, #d4af37 0%, #f4e4a6 25%, #d4af37 50%, #c5a028 75%, #d4af37 100%);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  0% { background-position: 0% center; }
  100% { background-position: 200% center; }
}

.premium-profile .profile-avatar img,
.premium-profile .avatar-placeholder {
  border: 3px solid #d4af37;
  box-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.premium-profile .profile-header {
  position: relative;
}

.premium-profile .profile-header::before {
  content: "";
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.05) 0%, transparent 50%);
  border-radius: 24px;
  z-index: -1;
}

.profile-joined {
  font-size: 14px;
  color: var(--gray-400);
  margin-top: 8px;
}

.stories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 24px;
}

.story-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  overflow: hidden;
  transition: var(--transition);
}

.story-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.story-image {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--gray-100);
}

.story-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.story-nsfw-badge {
  position: absolute;
  top: 12px;
  right: 12px;
  background: var(--red);
  color: var(--white);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 6px;
}

.story-text {
  padding: 16px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}

.story-meta {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.story-date {
  font-size: 13px;
  color: var(--gray-400);
}

.story-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.story-tag {
  font-size: 11px;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 4px 8px;
  border-radius: 6px;
}

.error-state {
  text-align: center;
  padding: 80px 24px;
}

.error-state h1 {
  font-size: 32px;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--gray-700);
}

.error-state p {
  font-size: 16px;
  color: var(--gray-500);
}

/* Lightbox */
.lightbox-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.lightbox-overlay.active {
  opacity: 1;
  pointer-events: auto;
}


.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 48px;
  height: 48px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  color: var(--white);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  z-index: 2001;
}

.lightbox-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lightbox-content {
  max-width: 90vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.lightbox-image {
  max-width: 100%;
  max-height: calc(90vh - 80px);
  object-fit: contain;
  border-radius: 12px;
}

.lightbox-profile-image {
  max-width: 400px;
  border-radius: 20px;
}

.lightbox-info {
  margin-top: 16px;
  text-align: center;
}

.lightbox-date {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.7);
}

.lightbox-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.lightbox-tags .story-tag {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.8);
}

/* Story card clickable */
.story-card {
  cursor: pointer;
}

.story-card:focus {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

/* ---- Responsive ---- */
@media (max-width: 520px) {
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .profile-info h1 {
    justify-content: center;
  }

  .profile-avatar img,
  .avatar-placeholder {
    width: 88px;
    height: 88px;
  }

  .avatar-placeholder {
    font-size: 36px;
  }
}

@media (max-width: 400px) {
  .stories-grid {
    grid-template-columns: 1fr;
  }
}
