/* ==============================================================
   🌌 COSMIC SCROLL — TikTok-style "For You" stream
   Used by js/cosmic-scroll.js on the home page and the feed.
   ============================================================== */

.cs-root {
  --cs-h: min(88vh, 860px);
  position: relative;
  width: 100%;
  max-width: 560px;
  margin: 0 auto 2.5rem;
  border-radius: 28px;
  overflow: hidden;
  background: #000103;
  border: 1px solid rgba(0, 255, 240, 0.22);
  box-shadow: 0 0 40px rgba(0, 255, 240, 0.12), 0 0 80px rgba(255, 0, 255, 0.08);
}
@supports (height: 100dvh) { .cs-root { --cs-h: min(88dvh, 860px); } }

.cs-scroller {
  height: var(--cs-h);
  overflow-y: auto;
  overscroll-behavior: contain;
  scroll-snap-type: y mandatory;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.cs-scroller::-webkit-scrollbar { display: none; }
.cs-scroller:focus-visible { outline: 3px solid #00fff0; outline-offset: -3px; }

/* ─── FULL SCREEN — true swipe-up mode ─── */
.cs-root.cs-full {
  position: fixed;
  inset: 0;
  z-index: 5000;
  max-width: none;
  margin: 0;
  border-radius: 0;
  border: 0;
  --cs-h: 100vh;
}
@supports (height: 100dvh) { .cs-root.cs-full { --cs-h: 100dvh; } }
html.cs-lock, html.cs-lock body { overflow: hidden; }

/* ─── CARDS ─── */
.cs-card {
  position: relative;
  height: var(--cs-h);
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  color: #eafffd;
  background:
    radial-gradient(circle at 20% 15%, rgba(0, 255, 240, 0.16), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(255, 0, 255, 0.14), transparent 50%),
    linear-gradient(160deg, var(--cs-a, #1a0b3d), var(--cs-b, #0d1b2a) 70%, #000103);
}
.cs-card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.55;
  background-image:
    radial-gradient(1px 1px at 12% 20%, #fff, transparent),
    radial-gradient(1px 1px at 70% 12%, #b9faff, transparent),
    radial-gradient(1.5px 1.5px at 40% 60%, #ffb3ff, transparent),
    radial-gradient(1px 1px at 88% 44%, #fff, transparent),
    radial-gradient(1px 1px at 25% 85%, #b9faff, transparent),
    radial-gradient(1.5px 1.5px at 60% 90%, #fff, transparent);
  animation: cs-drift 30s linear infinite;
}
@keyframes cs-drift { to { transform: translateY(-40px); } }

.cs-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 1.25rem 5rem 1.5rem 1.25rem;
}
.cs-card.is-active .cs-text,
.cs-card.is-active .cs-center { animation: cs-rise 0.5s ease both; }
@keyframes cs-rise { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }

.cs-text h3 { margin: 0.25rem 0 0.5rem; font-size: clamp(1.15rem, 4.5vw, 1.5rem); color: #fff; line-height: 1.25; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.6); }
.cs-body { margin: 0 0 0.75rem; color: #d8fbff; font-size: 1.02rem; line-height: 1.55; white-space: pre-line; max-height: 40vh; overflow: auto; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7); }
.cs-kicker { margin: 0; color: #00fff0; font-weight: 800; font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.cs-author { display: inline-flex; align-items: center; gap: 0.5rem; min-height: 44px; color: #fff; font-weight: 700; text-decoration: none; }
.cs-author:hover { color: #ff66ff; }
.cs-avatar { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, #00fff0, #ff00ff); color: #000103; font-weight: 900; font-size: 0.9rem; }

.cs-center { margin: auto 0; text-align: center; padding-left: 3.75rem; }
.cs-big {
  margin: 0 0 0.75rem;
  font-size: clamp(1.7rem, 7vw, 2.6rem);
  font-weight: 900;
  line-height: 1.15;
  background: linear-gradient(90deg, #00fff0, #ff66ff, #ffd700);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.cs-big.sm { font-size: clamp(1.25rem, 5vw, 1.7rem); color: #fff; background: none; -webkit-text-fill-color: currentColor; }
.cs-sub { margin: 0 auto; color: #d8fbff; font-size: 1.1rem; max-width: 26rem; }
.cs-row { display: flex; flex-wrap: wrap; gap: 0.75rem; justify-content: center; margin-top: 1.25rem; }
.cs-cta {
  display: inline-flex; align-items: center; justify-content: center; min-height: 48px; margin-top: 1rem;
  padding: 0.6rem 1.4rem; border-radius: 999px; font-weight: 800; text-decoration: none;
  background: linear-gradient(135deg, #00fff0, #ff00ff); color: #000103;
  box-shadow: 0 0 20px rgba(0, 255, 240, 0.35);
}
.cs-cta:hover, .cs-cta:focus { color: #000103; transform: translateY(-2px); }
.cs-cta.ghost { background: transparent; color: #00fff0; border: 1.5px solid #00fff0; box-shadow: none; }

/* Media fills the upper part of the card */
.cs-video, .cs-media-img {
  position: absolute; inset: 0 0 auto 0; width: 100%; height: 58%;
  border: 0; padding: 0; margin: 0; object-fit: cover; background: #000;
  -webkit-mask-image: linear-gradient(#000 70%, transparent);
  mask-image: linear-gradient(#000 70%, transparent);
}
button.cs-video { cursor: pointer; display: block; }
button.cs-video img { width: 100%; height: 100%; object-fit: cover; display: block; }
iframe.cs-video { -webkit-mask-image: none; mask-image: none; height: 56%; }
.cs-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  font-size: 1.8rem; color: #000103; background: rgba(0, 255, 240, 0.92);
  box-shadow: 0 0 30px rgba(0, 255, 240, 0.6), 0 0 60px rgba(255, 0, 255, 0.35);
}
button.cs-video:focus-visible { outline: 3px solid #ffd700; outline-offset: -3px; }

/* ─── ACTION RAIL ─── */
.cs-rail {
  position: absolute; right: 0.6rem; bottom: 1.5rem; z-index: 2;
  display: flex; flex-direction: column; gap: 0.7rem; align-items: center;
}
.cs-act {
  width: 54px; height: 54px; min-height: 54px; border-radius: 50%; padding: 0;
  display: grid; place-items: center; align-content: center; gap: 0;
  font-size: 1.45rem; line-height: 1; color: #fff; text-decoration: none; cursor: pointer;
  background: rgba(0, 1, 3, 0.45); border: 1px solid rgba(0, 255, 240, 0.3);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  transition: transform 0.15s ease, border-color 0.2s ease;
}
.cs-act small { font-size: 0.72rem; font-weight: 800; color: #eafffd; }
.cs-act:hover, .cs-act:focus-visible { border-color: #ff00ff; transform: scale(1.08); color: #fff; }
.cs-act:active { transform: scale(0.92); }
.cs-act[aria-pressed="true"] { border-color: #ff66ff; box-shadow: 0 0 16px rgba(255, 0, 255, 0.45); }

.cs-burst {
  position: absolute; z-index: 3; pointer-events: none; font-size: 5rem;
  transform: translate(-50%, -50%) scale(0.4); animation: cs-pop 0.9s ease-out forwards;
  filter: drop-shadow(0 0 20px rgba(255, 0, 255, 0.8));
}
@keyframes cs-pop {
  30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
  100% { transform: translate(-50%, -120%) scale(1); opacity: 0; }
}

/* ─── BREATHING ORB ─── */
.cs-breath {
  width: 150px; height: 150px; margin: 0 auto 1.5rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #b9faff, #00fff0 35%, #ff00ff 100%);
  box-shadow: 0 0 60px rgba(0, 255, 240, 0.5), 0 0 120px rgba(255, 0, 255, 0.3);
  animation: cs-breathe 10s ease-in-out infinite;
}
@keyframes cs-breathe { 0%, 100% { transform: scale(0.6); } 50% { transform: scale(1); } }

/* ─── CONTROLS ─── */
.cs-controls { position: absolute; top: 0.75rem; right: 0.75rem; z-index: 4; display: flex; gap: 0.4rem; }
.cs-ctl {
  width: 44px; height: 44px; min-height: 44px; padding: 0; border-radius: 50%; cursor: pointer;
  font-size: 1rem; color: #eafffd; background: rgba(0, 1, 3, 0.55);
  border: 1px solid rgba(0, 255, 240, 0.3);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.cs-ctl:hover, .cs-ctl:focus-visible { border-color: #00fff0; color: #00fff0; }

.cs-heading { text-align: center; margin: 2rem 0 1rem; }
.cs-heading p { margin: 0.25rem auto 0; color: #b9faff; }

.cs-view-toggle { display: flex; justify-content: center; gap: 0.5rem; margin: 0 0 1.25rem; }
.cs-view-toggle button {
  min-height: 44px; padding: 0.5rem 1.1rem; border-radius: 999px; cursor: pointer; font-weight: 800;
  color: #b9faff; background: rgba(0, 255, 240, 0.05); border: 1px solid rgba(0, 255, 240, 0.25);
}
.cs-view-toggle button[aria-pressed="true"] { color: #000103; background: linear-gradient(135deg, #00fff0, #ff00ff); border-color: transparent; }

@media (max-width: 600px) {
  .cs-root:not(.cs-full) { border-radius: 20px; margin-left: -0.25rem; margin-right: -0.25rem; width: calc(100% + 0.5rem); }
}

@media (prefers-reduced-motion: reduce) {
  .cs-card::before, .cs-breath, .cs-card.is-active .cs-text, .cs-card.is-active .cs-center { animation: none !important; }
  .cs-breath { transform: scale(0.85); }
}
