/* ===== CSS Variables ===== */
:root {
  --bg-primary: #000000;
  --bg-secondary: #121212;
  --bg-tertiary: #1a1a1a;
  --bg-elevated: #262626;
  --text-primary: #ffffff;
  --text-secondary: #a8a8a8;
  --text-tertiary: #737373;
  --border-color: #262626;
  --accent-color: #0095f6;
  --accent-hover: #1877f2;
  --gradient-start: #f09433;
  --gradient-middle: #e6683c;
  --gradient-end: #dc2743;
  --gradient-purple: #bc1888;
  --story-ring: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #bc1888, #8134af, #5851db);
  --header-height: 60px;
  --post-aspect-ratio: 16 / 9;
  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s ease;
  --shadow-elevated: 0 4px 12px rgba(0, 0, 0, 0.5);
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img {
  display: block;
  max-width: 100%;
}

/* ===== App Container ===== */
.app-container {
  display: flex;
  justify-content: center;
  min-height: 100vh;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  max-width: 935px;
  padding: 30px 20px;
  margin: 0 auto;
}

/* ===== Profile Header ===== */
.profile-header {
  display: flex;
  gap: 80px;
  padding: 20px 0 40px;
  margin-bottom: 24px;
}

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

/* Profile Picture with Story Ring */
.profile-picture-container {
  position: relative;
  width: 150px;
  height: 150px;
  cursor: pointer;
}

.story-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: var(--story-ring);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.story-ring.active {
  opacity: 1;
}

.story-ring.large {
  inset: -5px;
}

.story-ring::before {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--bg-primary);
}

.profile-picture-container img {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 3px solid var(--bg-primary);
  z-index: 1;
}

.profile-picture-container:hover .story-ring {
  opacity: 1;
}

/* Profile Info */
.profile-info {
  flex: 1;
  padding-top: 10px;
}

.profile-top {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 20px;
}

.username {
  font-size: 1.4rem;
  font-weight: 400;
}

.follow-btn {
  padding: 8px 24px;
  background-color: var(--accent-color);
  color: white;
  font-weight: 600;
  font-size: 0.9rem;
  border-radius: 8px;
  transition: background-color var(--transition-fast);
}

.follow-btn:hover {
  background-color: var(--accent-hover);
}

.options-btn {
  padding: 8px;
  color: var(--text-primary);
}

.options-btn svg {
  width: 24px;
  height: 24px;
}

/* Profile Stats */
.profile-stats {
  display: flex;
  gap: 40px;
  margin-bottom: 20px;
}

.stat {
  display: flex;
  gap: 6px;
}

.stat-number {
  font-weight: 600;
}

.stat-label {
  color: var(--text-primary);
}

/* Profile Bio */
.profile-bio {
  max-width: 400px;
}

.full-name {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.profession {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.bio-text {
  font-size: 0.95rem;
  /* white-space: pre-line; */
  color: var(--text-primary);
}

.bio-text p {
  margin-bottom: 8px;
}

.bio-link {
  color: var(--accent-color);
  font-weight: 500;
}

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

/* ===== Story Highlights ===== */
.highlights-section {
  padding: 20px 0;
  margin-bottom: 20px;
}

.highlights-container {
  display: flex;
  gap: 24px;
  overflow-x: auto;
  padding: 10px 0;
  scrollbar-width: none;
}

.highlights-container::-webkit-scrollbar {
  display: none;
}

.highlight-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  flex-shrink: 0;
}

.highlight-circle {
  position: relative;
  width: 77px;
  height: 77px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  padding: 3px;
  border: 1px solid var(--border-color);
  transition: transform var(--transition-fast);
}

.highlight-item:hover .highlight-circle {
  transform: scale(1.05);
}

.highlight-circle img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.highlight-title {
  font-size: 0.75rem;
  color: var(--text-primary);
  max-width: 80px;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Category Tabs ===== */
.category-tabs {
  display: flex;
  justify-content: center;
  gap: 60px;
  border-top: 1px solid var(--border-color);
  padding-top: 12px;
  margin-bottom: 24px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 12px 0;
  color: var(--text-tertiary);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-top: 1px solid transparent;
  margin-top: -13px;
  transition: all var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-secondary);
}

.tab-btn.active {
  color: var(--text-primary);
  border-top-color: var(--text-primary);
}

.tab-btn svg {
  width: 12px;
  height: 12px;
}

/* ===== Posts Grid (Widescreen Format) ===== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
}

.post-item {
  position: relative;
  aspect-ratio: var(--post-aspect-ratio);
  background-color: var(--bg-tertiary);
  overflow: hidden;
  cursor: pointer;
}

.post-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--transition-normal), opacity var(--transition-normal);
}

.post-item:hover img {
  transform: scale(1.03);
  opacity: 0.7;
}

.post-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.post-item:hover .post-overlay {
  opacity: 1;
}

.post-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  color: white;
  font-weight: 600;
  font-size: 1rem;
}

.post-stat svg {
  width: 20px;
  height: 20px;
  fill: white;
}

/* Video indicator */
.video-indicator {
  position: absolute;
  top: 12px;
  right: 12px;
  color: white;
  z-index: 2;
}

.video-indicator svg {
  width: 24px;
  height: 24px;
  fill: white;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

/* Featured badge */
.featured-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  background: var(--story-ring);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 2;
}

/* ===== Loading Indicator ===== */
.loading-indicator {
  display: none;
  justify-content: center;
  padding: 40px;
}

.loading-indicator.active {
  display: flex;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--text-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* ===== Post Modal ===== */
.post-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.post-modal.active {
  display: flex;
}

.post-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  cursor: pointer;
}

.post-modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  border-radius: 4px;
  overflow: hidden;
  max-width: 900px;
  max-height: 90vh;
  width: 100%;
  box-shadow: var(--shadow-elevated);
}

.modal-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  padding: 8px;
  z-index: 10;
  cursor: pointer;
  transition: background 0.2s;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.7);
}

.modal-close-btn svg {
  width: 20px;
  height: 20px;
  display: block;
}

.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: white;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  padding: 12px;
  z-index: 10;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
}

.modal-nav:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: translateY(-50%) scale(1.1);
}

.modal-nav svg {
  width: 24px;
  height: 24px;
  display: block;
}

.modal-prev {
  left: 20px;
}

.modal-next {
  right: 20px;
}

.modal-image-container {
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.modal-image-container img {
  width: 100%;
  max-height: 60vh;
  object-fit: contain;
}

.modal-embed-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
}

.modal-embed-container iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
}

.modal-info {
  width: 100%;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-color);
}

.modal-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
}

.modal-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-user img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
}

.modal-username {
  font-weight: 600;
  font-size: 0.9rem;
  display: block;
}

.modal-location {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.modal-caption {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
}

.modal-caption h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 12px;
}

.modal-caption p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.modal-comments {
  border-top: 1px solid var(--border-color);
  padding: 16px;
}

.modal-comments-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.modal-comments-header h4 {
  font-size: 0.95rem;
  font-weight: 600;
}

.modal-comments-header span {
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.modal-comments-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 220px;
  overflow-y: auto;
}

.modal-comment {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.modal-comment-username {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

.modal-comment-text,
.modal-comments-empty {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.modal-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
}

.modal-stats {
  color: var(--text-primary);
  font-size: 0.9rem;
}

.likes-count {
  display: flex;
  align-items: center;
  gap: 6px;
}

.likes-count svg {
  width: 18px;
  height: 18px;
  color: #ed4956;
}

.modal-tags {
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  font-size: 0.8rem;
  color: var(--accent-color);
}

/* ===== Responsive Design ===== */
@media (max-width: 1200px) {
  .profile-header {
    gap: 40px;
  }
}

@media (max-width: 935px) {
  .main-content {
    padding: 20px 16px;
  }
  
  .profile-header {
    gap: 28px;
  }
  
  .profile-picture-container {
    width: 120px;
    height: 120px;
  }
}

@media (max-width: 735px) {
  .main-content {
    padding: 16px;
  }
  
  .profile-header {
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 16px;
    padding-bottom: 24px;
  }
  
  .profile-picture-container {
    width: 86px;
    height: 86px;
  }
  
  .profile-info {
    padding: 0;
    width: 100%;
  }
  
  .profile-top {
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
  }
  
  .profile-stats {
    justify-content: center;
    padding: 12px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    margin: 12px 0;
  }
  
  .profile-bio {
    max-width: 100%;
  }
  
  .category-tabs {
    gap: 0;
    justify-content: space-around;
    text-transform: uppercase;
  }
  
  .tab-btn span {
    display: none;
  }
  
  .tab-btn svg {
    width: 24px;
    height: 24px;
  }
  
  .posts-grid {
    grid-template-columns: 1fr;
    gap: 2px;
  }
  
  .post-modal-content {
    flex-direction: column;
    max-height: 100vh;
  }
  
  .modal-image-container {
    max-width: 100%;
    max-height: 50vh;
  }
  
  .modal-info {
    width: 100%;
  }
}

/* ===== Animations ===== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from { 
    opacity: 0;
    transform: translateY(20px);
  }
  to { 
    opacity: 1;
    transform: translateY(0);
  }
}

/* Filter Animation - Exit */
@keyframes filterOut {
  0% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.5;
    transform: scale(0.9);
  }
  100% {
    opacity: 0;
    transform: scale(0.8) translateY(-20px);
  }
}

/* Filter Animation - Enter */
@keyframes filterIn {
  0% {
    opacity: 0;
    transform: scale(0.8) translateY(30px);
  }
  60% {
    opacity: 1;
    transform: scale(1.02) translateY(-5px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.post-item {
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.post-item.filtered-out {
  display: none;
}

/* ===== Scrollbar Styles ===== */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}
