/* =============================================
   SQUARE — Feed
============================================= */

/* ---- Stories Strip ---- */
.stories-strip {
  padding: var(--s-4) var(--s-4) var(--s-3);
  overflow-x: auto; overflow-y: hidden;
  scrollbar-width: none; -ms-overflow-style: none;
  display: flex; gap: var(--s-4);
  border-bottom: 1px solid var(--border);
}
.stories-strip::-webkit-scrollbar { display: none; }

.story-item {
  display: flex; flex-direction: column; align-items: center;
  gap: 6px; flex-shrink: 0; cursor: pointer;
  -webkit-user-select: none; user-select: none;
}

.story-item .avatar-ring { width: 68px; height: 68px; padding: 5px; }
.story-item .avatar-ring .avatar { width: 58px; height: 58px; border: 4px solid var(--bg); }

/* Add story */
.story-item.story-add .story-avatar-wrap { position: relative; }
.story-item.story-add .add-icon {
  position: absolute; bottom: -2px; right: -2px;
  width: 22px; height: 22px;
  background: var(--primary); border-radius: var(--r-full);
  border: 2.5px solid var(--bg);
  display: flex; align-items: center; justify-content: center;
}
.story-item.story-add .add-icon { font-size: 15px; font-weight: 800; color: #fff; line-height: 1; }

.story-item .story-name {
  font-size: 11px; font-weight: 500; color: var(--text-2);
  max-width: 62px; text-align: center;
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis;
}
.story-item.viewed .avatar-ring { background: var(--surface-3); }

/* Story pulse animation (unviewed) */
@keyframes storyPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}
.story-item:not(.viewed):not(.story-add) .avatar-ring {
  animation: storyPulse 2.5s ease infinite;
}
.story-item:hover .avatar-ring { animation: none; transform: scale(1.05); transition: transform 0.2s; }

/* ---- Filter Tabs ---- */
.feed-filter {
  display: flex; gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}
.feed-filter::-webkit-scrollbar { display: none; }
.filter-tab {
  flex-shrink: 0; font-size: 13px; font-weight: 600;
  padding: 6px 16px; border-radius: var(--r-full);
  color: var(--text-2); border: 1.5px solid var(--border);
  transition: all var(--t-fast) var(--ease); cursor: pointer;
  font-family: var(--font-body);
}
.filter-tab.active {
  background: var(--primary); border-color: var(--primary); color: #fff;
  box-shadow: var(--shadow-primary);
}
.filter-tab:not(.active):hover { background: var(--surface-2); color: var(--text); }

/* ---- Feed Posts ---- */
.feed-posts { padding: var(--s-2) 0; }

/* ---- Post Card ---- */
.post-card {
  margin-bottom: var(--s-3);
  background: var(--surface);
  border-radius: 0;
  border-bottom: 1px solid var(--border);
  transition: background var(--t-base) var(--ease);
}

@media (min-width: 900px) {
  .post-card {
    border-radius: var(--r-xl);
    border: 1px solid var(--border);
    margin: 0 var(--s-4) var(--s-4);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
  }
  .post-card:hover { box-shadow: var(--shadow-md); }
  .feed-posts { padding: var(--s-4) 0; }
}

/* Post Header */
.post-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--s-3) var(--s-4);
}
.post-header-left {
  display: flex; align-items: center; gap: var(--s-3); cursor: pointer;
}
.post-user-info .username {
  font-size: 14px; font-weight: 700; color: var(--text);
  display: flex; align-items: center; gap: 4px;
}
.post-user-info .username img.isax {
  width: 15px; height: 15px;
}
.post-user-info .post-meta {
  font-size: 12px; color: var(--text-3);
  display: flex; align-items: center; gap: 4px; margin-top: 1px;
}
.post-user-info .post-meta .hashtag-badge {
  font-size: 11px; font-weight: 700; color: var(--secondary);
  background: var(--secondary-glow); padding: 2px 8px; border-radius: var(--r-full);
}
.post-more-btn {
  width: 36px; height: 36px; display: flex; align-items: center; justify-content: center;
  color: var(--text-3); border-radius: var(--r-full);
  transition: background var(--t-fast) var(--ease);
}
.post-more-btn:hover { background: var(--surface-2); color: var(--text); }
.post-more-btn img.isax { width: 20px; height: 20px; }

/* Media */
.post-media {
  position: relative; width: 100%; overflow: hidden; background: var(--surface-2);
}
.post-media img, .post-media video {
  width: 100%; aspect-ratio: 4/5; object-fit: cover; display: block;
  transition: transform 0.5s var(--ease);
}
@media (min-width: 900px) {
  .post-media img, .post-media video { aspect-ratio: 16/10; }
}
.post-media:active img { transform: scale(1.02); }

/* Double-tap heart */
.heart-burst {
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0);
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none; z-index: 10;
}
.heart-burst img.isax {
  width: 90px; height: 90px;
  filter: invert(1) drop-shadow(0 4px 20px rgba(0,0,0,0.4));
}

/* Video badge */
.video-badge {
  position: absolute; top: var(--s-3); right: var(--s-3);
  background: rgba(0,0,0,0.45); backdrop-filter: blur(8px);
  border-radius: var(--r-full); padding: 4px 10px;
  display: flex; align-items: center; gap: 5px;
  color: #fff; font-size: 12px; font-weight: 600;
}
.video-badge img.isax { width: 14px; height: 14px; filter: invert(1); }

/* Play overlay */
.play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.1);
  transition: opacity var(--t-fast) var(--ease);
}
.play-overlay .play-btn {
  width: 60px; height: 60px;
  background: rgba(255,255,255,0.22); backdrop-filter: blur(10px);
  border-radius: var(--r-full); display: flex; align-items: center; justify-content: center;
  border: 2px solid rgba(255,255,255,0.5);
  transition: transform var(--t-base) var(--ease-spring);
}
.play-overlay .play-btn img.isax { width: 28px; height: 28px; filter: invert(1); }
.post-media.playing .play-overlay { opacity: 0; pointer-events: none; }

/* Text post */
.post-text-card {
  width: 100%; min-height: 200px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--s-8) var(--s-6); text-align: center; position: relative; overflow: hidden;
}
.post-text-card .text-content {
  font-family: var(--font-display); font-size: 17px; font-weight: 700;
  color: #fff; line-height: 1.55; text-shadow: 0 2px 12px rgba(0,0,0,0.3);
  max-width: 320px; position: relative; z-index: 1;
}

/* Post Actions */
.post-actions {
  display: flex; align-items: center;
  padding: var(--s-1) var(--s-4) 0; gap: var(--s-1);
}
.action-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 8px; border-radius: var(--r-md);
  color: var(--text-2); font-size: 13px; font-weight: 600;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease),
              transform var(--t-base) var(--ease-spring);
  cursor: pointer;
}
.action-btn img.isax { width: 22px; height: 22px; transition: transform var(--t-base) var(--ease-spring); opacity: 0.65; }
.action-btn:hover { background: var(--surface-2); }
.action-btn:hover img.isax { opacity: 0.9; }
.action-btn:active { transform: scale(0.9); }

/* Liked/saved active state — filter approximating primary (#FF385C) and accent (#FF9500) */
.action-btn.like-btn.liked { color: var(--primary); }
.action-btn.like-btn.liked img.isax {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(32%) sepia(80%) saturate(2000%) hue-rotate(320deg) brightness(105%);
}
.action-btn.save-btn.saved { color: var(--accent); }
.action-btn.save-btn.saved img.isax {
  opacity: 1;
  filter: brightness(0) saturate(100%) invert(60%) sepia(90%) saturate(1000%) hue-rotate(5deg) brightness(105%);
}

.post-actions .spacer { flex: 1; }

/* Post Footer */
.post-footer { padding: var(--s-2) var(--s-4) var(--s-4); }
.post-caption { font-size: 14px; line-height: 1.6; color: var(--text); margin-bottom: var(--s-2); }
.post-caption .caption-user { font-weight: 700; margin-right: 6px; }
.post-caption .read-more { color: var(--text-3); cursor: pointer; font-weight: 500; }

.post-hashtags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.hashtag-pill {
  font-size: 12px; font-weight: 700; color: var(--secondary);
  background: var(--secondary-glow); padding: 3px 10px; border-radius: var(--r-full);
  cursor: pointer; text-decoration: none; display: inline-block;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.hashtag-pill:hover { background: var(--secondary); color: #fff; }
a.hashtag-badge { text-decoration: none; }

.post-view-comments {
  margin-top: 8px; font-size: 13px; color: var(--text-3); cursor: pointer; font-weight: 500;
}
.post-view-comments span { color: var(--text-2); font-weight: 600; }

/* =============================================
   MOBILE POST CARDS — Overlay layout (212/215)
   Only applies on mobile, desktop unchanged
============================================= */
@media (max-width: 899px) {
  .post-card {
    border-radius: var(--r-xl);
    margin: 0 var(--s-3) var(--s-4);
    overflow: hidden;
    border: none;
    border-bottom: none;
    box-shadow: 0 4px 24px rgba(0,0,0,0.10);
    position: relative;
    background: var(--surface);
  }

  /* post-media-wrap is the relative stacking context */
  .post-media-wrap { position: relative; }

  /* Header — taken out of flow, overlaid on image top */
  .post-header {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0,0,0,0.58) 0%, transparent 100%);
    padding: var(--s-3) var(--s-4) calc(var(--s-4) * 2.5);
    border-bottom: none;
  }
  .post-header .username { color: #fff; text-shadow: 0 1px 4px rgba(0,0,0,0.35); }
  .post-header .post-meta { color: rgba(255,255,255,0.72); }
  .post-header .hashtag-badge { background: rgba(255,255,255,0.18); color: #fff; }
  .post-header .post-more-btn img.isax { filter: invert(1); opacity: 0.9; }
  .post-header .avatar-ring .avatar { border-color: rgba(255,255,255,0.85); }

  /* Portrait aspect ratio for mobile */
  .post-media img, .post-media video { aspect-ratio: 4/5; }

  /* Actions — vertical stack, bottom-right of image */
  .post-actions {
    position: absolute;
    right: var(--s-3);
    bottom: var(--s-3);
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 0;
    z-index: 10;
  }
  .post-actions .spacer { display: none; }
  .post-actions .save-btn { order: -1; } /* bookmark floats to top */

  .action-btn {
    flex-direction: column;
    gap: 2px;
    padding: 8px 6px;
    background: rgba(0,0,0,0.28);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    width: 44px;
    min-height: 50px;
    justify-content: center;
  }
  .action-btn:hover { background: rgba(0,0,0,0.44); }
  .action-btn img.isax { filter: invert(1); opacity: 0.95; width: 22px; height: 22px; }

  /* Active states on overlay */
  .action-btn.like-btn.liked img.isax {
    filter: brightness(0) saturate(100%) invert(32%) sepia(80%) saturate(2000%) hue-rotate(320deg) brightness(105%);
  }
  .action-btn.save-btn.saved img.isax {
    filter: brightness(0) saturate(100%) invert(60%) sepia(90%) saturate(1000%) hue-rotate(5deg) brightness(105%);
  }

  /* Caption below image */
  .post-footer { padding: var(--s-3) var(--s-4) var(--s-3); }
  .feed-posts { padding: var(--s-2) 0; }
}

/* Desktop feed header bar */
@media (min-width: 900px) {
  .feed-top-bar {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--s-5) var(--s-6) var(--s-3);
    border-bottom: 1px solid var(--border);
  }
  .feed-top-bar h2 {
    font-family: var(--font-display); font-size: 20px; font-weight: 800; color: var(--text);
  }
}
