/* AnimationStation — immersive web feed.
   Mirrors the mobile HomeScreen/FeedPost: full-viewport snap-scroll posts,
   edge-to-edge media, a bottom-right action rail, creator + caption overlay,
   and slide-in overlays for comments, search, and profiles. Dark-neon theme
   reuses the CSS variables defined in style.css (--bg, --cyan, --purple, …). */

:root {
  --banner-h: 56px;
  --footer-h: 30px;
}

/* Generic hide utility. Without this, elements marked `.hidden` that aren't
   `.overlay` (e.g. the reply hint) stay visible. Overlay/viewer hides are also
   declared right after their base `display:flex` rules below so the hide wins
   on source order in every engine, not only via !important. */
.hidden {
  display: none !important;
}

/* Lock the page to the viewport — the feed area scroll-snaps internally. */
html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
}

/* ---------------- Top banner ---------------- */
.feed-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--banner-h);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem;
  background: rgba(8, 11, 22, 0.82);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.feed-banner .nav-logo {
  font-size: 1.15rem;
  white-space: nowrap;
}
.banner-spacer {
  flex: 1 1 auto;
}
.banner-links {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.banner-link {
  color: var(--text-2);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.4rem 0.6rem;
  border-radius: 9px;
  white-space: nowrap;
}
.banner-link:hover {
  color: var(--text);
  background: var(--glass);
}
.banner-icon-btn {
  position: relative;
  background: var(--glass);
  border: 1px solid var(--border-strong);
  color: var(--text);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.banner-icon-btn:hover {
  border-color: var(--cyan);
}
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}
.banner-cta {
  background: linear-gradient(135deg, var(--cyan), var(--purple));
  color: #05070f;
  font-weight: 700;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  white-space: nowrap;
}
.banner-ghost {
  background: var(--glass);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.9rem;
  cursor: pointer;
  white-space: nowrap;
}
.banner-ghost:hover {
  border-color: var(--cyan);
}
/* Credits/tier pill — always visible (never hidden at small widths), so a
   user's balance is never buried the way it was in the old account-page list.
   The `.low` variant swaps to an amber gradient + a slow pulse to nudge
   towards /buy.html once credits run low. */
.credits-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.32rem 0.7rem;
  border-radius: 999px;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
  white-space: nowrap;
  background: linear-gradient(135deg, rgba(34, 211, 238, 0.22), rgba(168, 85, 247, 0.22));
  border: 1px solid rgba(34, 211, 238, 0.5);
  color: var(--text);
}
.credits-pill-amt {
  color: var(--cyan);
}
.credits-pill-tier {
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  background: var(--glass);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-2);
}
.credits-pill.low {
  background: linear-gradient(135deg, rgba(255, 92, 114, 0.25), rgba(255, 176, 32, 0.25));
  border-color: var(--danger);
  animation: creditsPillPulse 2.2s ease-in-out infinite;
}
.credits-pill.low .credits-pill-amt {
  color: var(--danger);
}
@keyframes creditsPillPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 92, 114, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(255, 92, 114, 0); }
}

/* Avatar badge replacing the old "Hi, {name}" text greeting — a profile photo
   (or initial-letter fallback) that doubles as the link to /account.html.
   Intentionally NOT in .banner-hide-sm: unlike the text greeting it replaces,
   it stays visible at every width. */
.banner-avatar-link {
  display: inline-flex;
  line-height: 0;
}
.banner-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 1.5px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
}
.banner-avatar-link:hover .banner-avatar {
  border-color: var(--cyan);
}

@media (max-width: 640px) {
  .banner-hide-sm {
    display: none !important;
  }
  .credits-pill-tier {
    display: none;
  }
}

/* ---------------- Feed area (snap scroll) ---------------- */
.feed-scroll {
  position: fixed;
  top: var(--banner-h);
  bottom: var(--footer-h);
  left: 0;
  right: 0;
  overflow-y: auto;
  scroll-snap-type: y mandatory;
  -webkit-overflow-scrolling: touch;
  background: #000;
}
.feed-scroll.locked {
  overflow: hidden;
}

.feed-post {
  position: relative;
  width: 100%;
  height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
/* Media: images and videos both letterbox (contain) against the post's black
   background, matching the app's FeedPost. A clip animated from a square or a
   16:9 source does not share the viewport's aspect ratio, and "cover" cropped
   its edges away; "contain" keeps the whole frame. A <video>'s poster is
   painted with the same object-fit, so the still and the clip line up. */
.feed-media {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.post-scrim {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 42%;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.65));
  pointer-events: none;
}

.ai-badge {
  position: absolute;
  left: 14px;
  top: 14px;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  z-index: 3;
}

.mute-btn {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.25);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  z-index: 3;
}
.play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 2;
}
.play-overlay svg,
.play-overlay span {
  font-size: 4.5rem;
  color: rgba(255, 255, 255, 0.9);
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.6));
}

/* Creator + caption (bottom-left) */
.post-creator {
  position: absolute;
  left: 16px;
  right: 84px;
  bottom: 18px;
  z-index: 4;
  color: #fff;
}
.creator-row {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  margin-bottom: 0.4rem;
}
.creator-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.6);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  flex: 0 0 auto;
}
.creator-name {
  font-weight: 700;
  font-size: 0.98rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
.post-caption {
  font-size: 0.9rem;
  line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.post-caption.prompt {
  font-style: italic;
  color: rgba(255, 255, 255, 0.85);
  -webkit-line-clamp: 2;
}

/* Action rail (bottom-right) */
.post-rail {
  position: absolute;
  right: 12px;
  bottom: 20px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.1rem;
}
.rail-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0;
}
.rail-btn .rail-icon {
  font-size: 1.9rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
  display: inline-flex;
}
.rail-btn .rail-icon svg {
  display: block;
}
.rail-btn .rail-count {
  font-size: 0.72rem;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.rail-btn.liked .rail-icon {
  color: var(--danger);
}
.rail-btn.saved .rail-icon {
  color: var(--cyan);
}

/* Feed status states */
.feed-status {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  color: var(--text-2);
  text-align: center;
  padding: 2rem;
}
.spinner {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 3px solid var(--border-strong);
  border-top-color: var(--cyan);
  animation: spin 1s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.feed-end {
  height: 100%;
  scroll-snap-align: start;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  color: var(--text-2);
  text-align: center;
  padding: 2rem;
}
.feed-end .empty-glow {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(
    circle at 40% 35%,
    rgba(34, 211, 238, 0.5),
    rgba(168, 85, 247, 0.35) 60%,
    transparent 72%
  );
}

/* ---------------- Slim footer ---------------- */
.feed-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--footer-h);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  background: rgba(8, 11, 22, 0.9);
  border-top: 1px solid var(--border);
  font-size: 0.75rem;
  color: var(--text-3);
}
.feed-footer a {
  color: var(--text-2);
  text-decoration: none;
}
.feed-footer a:hover {
  color: var(--cyan);
}
.feed-footer .sep {
  opacity: 0.5;
}

/* ---------------- Overlays (comments sheet, search, profile) ---------------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 6, 14, 0.6);
  backdrop-filter: blur(3px);
  display: flex;
}
.overlay.hidden {
  display: none;
}

/* Comments bottom sheet */
.sheet {
  margin-top: auto;
  width: 100%;
  max-height: 72vh;
  background: var(--surface);
  border-top-left-radius: 18px;
  border-top-right-radius: 18px;
  border-top: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  animation: sheet-up 0.22s ease;
}
@keyframes sheet-up {
  from {
    transform: translateY(30px);
    opacity: 0.6;
  }
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sheet-head h3 {
  margin: 0;
  font-size: 1rem;
}
.sheet-close {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}
.sheet-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 1rem;
}
.sheet-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--border);
  align-items: flex-end;
}
.sheet-input textarea {
  flex: 1 1 auto;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  padding: 0.55rem 0.9rem;
}
.sheet-input textarea:focus {
  outline: none;
  border-color: var(--cyan);
}
.sheet-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--cyan);
  color: var(--bg);
  font-size: 1.2rem;
  cursor: pointer;
  flex: 0 0 auto;
}
.sheet-send:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Comment row */
.comment {
  display: flex;
  gap: 0.6rem;
  padding: 0.6rem 0;
}
.comment.reply {
  margin-left: 2.2rem;
}
.comment-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: var(--text);
  flex: 0 0 auto;
}
.comment-main {
  flex: 1 1 auto;
  min-width: 0;
}
.comment-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
}
.comment-time {
  color: var(--text-3);
  font-size: 0.78rem;
  margin-left: 0.4rem;
}
.comment-body {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.4;
  margin: 0.15rem 0;
  word-break: break-word;
}
.comment-actions {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  font-size: 0.78rem;
  color: var(--text-3);
}
.comment-actions button {
  background: none;
  border: none;
  color: var(--text-3);
  cursor: pointer;
  font-size: 0.78rem;
  padding: 0;
}
.comment-actions button:hover {
  color: var(--text);
}
.comment-like.liked {
  color: var(--danger);
}
.comment-empty {
  text-align: center;
  color: var(--text-3);
  padding: 2rem 1rem;
}

/* Search + profile panels (slide from right) */
.panel {
  margin-left: auto;
  width: min(480px, 100%);
  height: 100%;
  background: var(--bg);
  border-left: 1px solid var(--border-strong);
  display: flex;
  flex-direction: column;
  animation: panel-in 0.22s ease;
}
@keyframes panel-in {
  from {
    transform: translateX(24px);
    opacity: 0.6;
  }
}
.panel-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 {
  margin: 0;
  font-size: 1.05rem;
  flex: 1 1 auto;
}
.panel-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.75rem 1rem 2rem;
}
.search-input {
  flex: 1 1 auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  padding: 0.5rem 0.9rem;
}
.search-input:focus {
  outline: none;
  border-color: var(--cyan);
}

/* User row (search results + generic) */
.user-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
}
.user-row .u-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
  flex: 0 0 auto;
  cursor: pointer;
}
.user-row .u-main {
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}
.user-row .u-name {
  font-weight: 600;
  color: var(--text);
}
.user-row .u-handle {
  color: var(--text-3);
  font-size: 0.85rem;
}
.user-row .u-bio {
  color: var(--text-2);
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.follow-btn {
  flex: 0 0 auto;
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  background: var(--cyan);
  color: var(--bg);
}
.follow-btn.following {
  background: var(--glass);
  border-color: var(--border-strong);
  color: var(--text);
}
.follow-btn:disabled {
  opacity: 0.6;
  cursor: default;
}

/* Notifications panel */
.notif-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.notif-row.unread {
  background: rgba(34, 211, 238, 0.06);
}
.notif-main {
  flex: 1 1 auto;
  min-width: 0;
}
.notif-text {
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.35;
}
.notif-time {
  color: var(--text-3);
  font-size: 0.78rem;
  margin-top: 2px;
}
.notif-thumb {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  object-fit: cover;
  flex: 0 0 auto;
  background: var(--surface-2);
}

/* Deep-linking from a notification into a specific comment (mirrors mobile's
   auto-scroll + highlight in CommentsScreen). */
.comment-highlight {
  animation: commentHighlight 2s ease;
}
@keyframes commentHighlight {
  0%, 40% { background: rgba(34, 211, 238, 0.18); }
  100% { background: transparent; }
}

/* Profile panel */
.profile-hero {
  text-align: center;
  padding: 0.5rem 0 1rem;
}
.profile-avatar {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  margin: 0 auto 0.6rem;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text);
}
.profile-name {
  font-size: 1.25rem;
  font-weight: 700;
  margin: 0;
}
.profile-handle {
  color: var(--text-3);
  margin: 0.1rem 0 0.5rem;
}
.profile-bio {
  color: var(--text-2);
  font-size: 0.92rem;
  max-width: 340px;
  margin: 0 auto 0.75rem;
}
.profile-stats {
  display: flex;
  justify-content: center;
  gap: 1.4rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.9rem;
}
.stat {
  text-align: center;
}
.stat b {
  display: block;
  font-size: 1.1rem;
  color: var(--text);
}
.stat span {
  font-size: 0.78rem;
  color: var(--text-3);
}
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
  margin-top: 0.5rem;
}
.grid-item {
  position: relative;
  aspect-ratio: 1;
  background: var(--surface);
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
}
.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.grid-item .g-play {
  position: absolute;
  right: 6px;
  top: 6px;
  color: #fff;
  font-size: 0.9rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.6));
}

/* Simple menu popover (⋯ actions) */
.action-menu {
  position: fixed;
  z-index: 50;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  overflow: hidden;
}
.action-menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  padding: 0.7rem 1rem;
  cursor: pointer;
}
.action-menu button:hover {
  background: var(--glass);
}
.action-menu button.danger {
  color: var(--danger);
}

/* Full-screen media viewer (profile grid taps) */
.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 6, 14, 0.94);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}
.viewer.hidden {
  display: none !important;
}
.viewer img,
.viewer video {
  max-width: 94vw;
  max-height: 88vh;
  border-radius: 12px;
}
.viewer-close {
  position: fixed;
  top: 16px;
  right: 20px;
  background: none;
  border: none;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
}

/* Toast (lightweight feedback) */
.toast {
  position: fixed;
  bottom: calc(var(--footer-h) + 14px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow-md);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.toast.show {
  opacity: 1;
}
