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

:root {
  --bg: #FAF5FF;
  --card: #FFFFFF;
  --primary: #9B72CF;
  --secondary: #D8B4FE;
  --text: #3B1F5E;
  --text-light: #7C6A94;
  --border: #EDE4F5;
  --heart: #E879A0;
  --font-display: 'Dancing Script', cursive;
  --font-heading: 'Playfair Display', serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --max-w: 470px;
}

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

.hidden { display: none !important; }

button { cursor: pointer; border: none; background: none; font-family: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--primary); text-decoration: none; }

/* ===========================
   SPLASH / ENTRANCE SCREEN
   =========================== */
.splash {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #EDE4F5 0%, #D8B4FE 40%, #9B72CF 100%);
  transition: opacity .8s ease, visibility .8s ease;
}
.splash.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-particles {
  position: absolute;
  inset: 0;
  overflow: hidden;
}
.splash-particles::before,
.splash-particles::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  animation: float 6s ease-in-out infinite;
}
.splash-particles::before { width: 200px; height: 200px; top: 10%; left: 10%; animation-delay: 0s; }
.splash-particles::after  { width: 150px; height: 150px; bottom: 15%; right: 10%; animation-delay: 3s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); opacity: .3; }
  50%      { transform: translateY(-30px) scale(1.1); opacity: .5; }
}

.splash-content {
  text-align: center;
  animation: fadeInUp 1.2s ease forwards;
}
.splash-title {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 4.5rem);
  color: #fff;
  text-shadow: 0 2px 20px rgba(59, 31, 94, .25);
  line-height: 1.2;
}
.splash-subtitle {
  font-size: 3rem;
  margin: .5rem 0 2rem;
  animation: pulse 2s ease-in-out infinite;
}
.splash-enter {
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: .08em;
  color: var(--text);
  background: rgba(255,255,255,.85);
  padding: .75rem 2.5rem;
  border-radius: 999px;
  backdrop-filter: blur(4px);
  transition: transform .2s, background .2s;
}
.splash-enter:hover { transform: scale(1.05); background: #fff; }

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

/* ===========================
   MAIN APP
   =========================== */
.app {
  max-width: var(--max-w);
  margin: 0 auto;
  padding-bottom: 80px; /* room for music player */
}

/* ===========================
   PROFILE HEADER
   =========================== */
.profile-header {
  padding: 1.25rem 1rem .75rem;
}
.profile-top {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.profile-pic-wrap {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  padding: 3px;
  cursor: pointer;
  animation: storyRingPulse 3s ease-in-out infinite;
}
@keyframes storyRingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(155,114,207,.4); }
  50%      { box-shadow: 0 0 0 4px rgba(155,114,207,.15); }
}
.profile-pic {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg);
}
.profile-stats {
  display: flex;
  flex: 1;
  justify-content: space-around;
  text-align: center;
}
.stat-num {
  display: block;
  font-size: 1.1rem;
  font-weight: 700;
}
.stat-label {
  font-size: .75rem;
  color: var(--text-light);
}
.profile-info {
  margin-top: .75rem;
}
.profile-name {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 600;
}
.profile-handle {
  font-size: .8rem;
  color: var(--text-light);
  margin-bottom: .25rem;
}
.profile-bio {
  font-size: .85rem;
  line-height: 1.45;
  margin-bottom: .75rem;
}
.follow-btn {
  width: 100%;
  padding: .55rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: .85rem;
  color: #fff;
  background: var(--primary);
  transition: background .2s, transform .15s;
}
.follow-btn:hover { background: #8A5FC0; }
.follow-btn:active { transform: scale(.97); }
.follow-btn.following {
  background: var(--border);
  color: var(--text);
}

/* ===========================
   HIGHLIGHTS
   =========================== */
.highlights {
  display: flex;
  gap: .85rem;
  padding: .75rem 1rem;
  overflow-x: auto;
  scrollbar-width: none;
}
.highlights::-webkit-scrollbar { display: none; }

.highlight {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .3rem;
  flex-shrink: 0;
  opacity: .55;
  transition: opacity .2s;
}
.highlight.active, .highlight:hover { opacity: 1; }

.highlight-ring {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 2px solid var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  transition: border-color .2s;
}
.highlight.active .highlight-ring { border-color: var(--primary); }

.highlight-icon { font-size: 1.5rem; }
.highlight-label { font-size: .65rem; font-weight: 500; color: var(--text-light); }

/* ===========================
   VIEW TOGGLE
   =========================== */
.view-toggle {
  display: flex;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.toggle-btn {
  flex: 1;
  padding: .6rem;
  display: flex;
  justify-content: center;
  color: var(--text-light);
  transition: color .2s;
  border-bottom: 2px solid transparent;
}
.toggle-btn.active {
  color: var(--text);
  border-bottom-color: var(--text);
}

/* ===========================
   POSTS GRID
   =========================== */
.posts-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}
.grid-item {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  cursor: pointer;
  background: var(--border);
}
.grid-item img, .grid-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform .3s;
}
.grid-item:hover img, .grid-item:hover video { transform: scale(1.05); }

.grid-video-icon {
  position: absolute;
  top: 8px;
  right: 8px;
  color: #fff;
  filter: drop-shadow(0 1px 3px rgba(0,0,0,.4));
  font-size: 1rem;
}

/* Fade-in on load */
.grid-item { opacity: 0; animation: gridFadeIn .4s ease forwards; }
.grid-item:nth-child(1)  { animation-delay: .05s; }
.grid-item:nth-child(2)  { animation-delay: .10s; }
.grid-item:nth-child(3)  { animation-delay: .15s; }
.grid-item:nth-child(4)  { animation-delay: .20s; }
.grid-item:nth-child(5)  { animation-delay: .25s; }
.grid-item:nth-child(6)  { animation-delay: .30s; }
.grid-item:nth-child(7)  { animation-delay: .35s; }
.grid-item:nth-child(8)  { animation-delay: .40s; }
.grid-item:nth-child(9)  { animation-delay: .45s; }

@keyframes gridFadeIn {
  from { opacity: 0; transform: scale(.92); }
  to   { opacity: 1; transform: scale(1); }
}

/* ===========================
   POSTS FEED
   =========================== */
.posts-feed {
  padding: 0;
}
.feed-post {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity .5s ease, transform .5s ease;
}
.feed-post.visible {
  opacity: 1;
  transform: translateY(0);
}

.feed-post-header {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .7rem 1rem;
}
.feed-post-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--text);
}
.feed-post-user { font-weight: 600; font-size: .85rem; }
.feed-post-location { font-size: .7rem; color: var(--text-light); }

.feed-post-media {
  position: relative;
  width: 100%;
  background: var(--border);
  user-select: none;
  -webkit-user-select: none;
}
.feed-post-media img, .feed-post-media video {
  width: 100%;
  display: block;
}

.feed-post-actions {
  display: flex;
  gap: 1rem;
  padding: .6rem 1rem;
}
.action-btn {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .85rem;
  color: var(--text);
  transition: color .15s, transform .15s;
}
.action-btn:hover { color: var(--primary); }
.action-btn:active { transform: scale(.9); }
.action-btn.liked { color: var(--heart); }
.action-btn svg { width: 22px; height: 22px; }

.feed-post-likes {
  padding: 0 1rem;
  font-size: .85rem;
  font-weight: 600;
}
.feed-post-caption {
  padding: .35rem 1rem .2rem;
  font-size: .85rem;
  line-height: 1.45;
}
.feed-post-caption strong { font-weight: 600; }
.feed-post-tags {
  padding: 0 1rem;
  font-size: .75rem;
  color: var(--primary);
}
.feed-post-date {
  padding: .3rem 1rem .6rem;
  font-size: .65rem;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.feed-post-comments {
  padding: 0 1rem .75rem;
}
.feed-comment {
  font-size: .8rem;
  line-height: 1.4;
  margin-bottom: .25rem;
}
.feed-comment strong { font-weight: 600; }

/* ===========================
   POST MODAL
   =========================== */
.post-modal {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .25s ease;
}
.post-modal.hidden { display: none; }

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 2rem;
  color: #fff;
  z-index: 10;
  line-height: 1;
}
.modal-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 2.5rem;
  color: #fff;
  z-index: 10;
  padding: .5rem;
  opacity: .7;
  transition: opacity .2s;
}
.modal-nav:hover { opacity: 1; }
.modal-prev { left: 8px; }
.modal-next { right: 8px; }

.modal-body {
  width: 90%;
  max-width: var(--max-w);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border-radius: 12px;
  scrollbar-width: thin;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===========================
   HEART ANIMATION
   =========================== */
.heart-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.heart-burst {
  width: 100px;
  height: 100px;
  animation: heartPop .6s ease forwards;
}
@keyframes heartPop {
  0%   { transform: scale(0); opacity: 1; }
  50%  { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(1); opacity: 0; }
}

/* ===========================
   CONFETTI CANVAS
   =========================== */
.confetti-canvas {
  position: fixed;
  inset: 0;
  z-index: 960;
  pointer-events: none;
}

/* ===========================
   GUESTBOOK
   =========================== */
.guestbook {
  padding: 2rem 1rem;
  text-align: center;
}
.guestbook-title {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  margin-bottom: 1rem;
}
.guestbook-form {
  display: flex;
  flex-direction: column;
  gap: .6rem;
  max-width: 360px;
  margin: 0 auto 1.5rem;
}
.guestbook-form input,
.guestbook-form textarea {
  font-family: var(--font-body);
  font-size: .9rem;
  padding: .7rem .85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.guestbook-form input:focus,
.guestbook-form textarea:focus { border-color: var(--primary); }
.guestbook-form textarea { resize: vertical; min-height: 80px; }

.gb-submit {
  padding: .65rem;
  border-radius: 10px;
  font-weight: 600;
  font-size: .9rem;
  color: #fff;
  background: var(--primary);
  transition: background .2s, transform .15s;
}
.gb-submit:hover { background: #8A5FC0; }
.gb-submit:active { transform: scale(.97); }

.guestbook-messages {
  max-width: 360px;
  margin: 0 auto;
  text-align: left;
}
.gb-msg {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: .75rem 1rem;
  margin-bottom: .6rem;
  animation: fadeInUp .4s ease;
}
.gb-msg-name {
  font-weight: 600;
  font-size: .85rem;
  color: var(--primary);
}
.gb-msg-text {
  font-size: .85rem;
  line-height: 1.4;
  margin-top: .2rem;
}
.gb-msg-time {
  font-size: .65rem;
  color: var(--text-light);
  margin-top: .3rem;
}

/* ===========================
   MUSIC PLAYER
   =========================== */
.music-player {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 800;
}
.music-toggle {
  display: flex;
  align-items: center;
  gap: .4rem;
  background: var(--card);
  border: 1px solid var(--border);
  padding: .5rem .9rem;
  border-radius: 999px;
  box-shadow: 0 2px 12px rgba(155,114,207,.2);
  font-size: .8rem;
  font-weight: 500;
  color: var(--text);
  transition: transform .2s;
}
.music-toggle:hover { transform: scale(1.05); }
.music-icon { font-size: 1rem; }
.music-toggle.playing .music-icon {
  animation: bounce .5s ease infinite alternate;
}
@keyframes bounce {
  from { transform: translateY(0); }
  to   { transform: translateY(-3px); }
}

/* ===========================
   STORY VIEWER
   =========================== */
.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn .25s ease;
}
.story-viewer.hidden { display: none; }

.story-progress {
  position: absolute;
  top: 8px;
  left: 8px;
  right: 8px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.story-progress-bar {
  flex: 1;
  height: 3px;
  background: rgba(255,255,255,.3);
  border-radius: 2px;
  overflow: hidden;
}
.story-progress-bar.viewed {
  background: rgba(255,255,255,.9);
}
.story-progress-bar.active .story-progress-fill {
  animation: storyTimer 5s linear forwards;
}
.story-progress-fill {
  height: 100%;
  background: #fff;
  width: 0;
  border-radius: 2px;
}
@keyframes storyTimer {
  from { width: 0; }
  to   { width: 100%; }
}

.story-close {
  position: absolute;
  top: 20px;
  right: 12px;
  font-size: 2rem;
  color: #fff;
  z-index: 12;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,.5);
}

.story-media {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-media img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.story-text {
  position: absolute;
  bottom: 60px;
  left: 0;
  right: 0;
  text-align: center;
  padding: 0 1.5rem;
  z-index: 10;
}
.story-card-text {
  font-family: var(--font-display);
  font-size: clamp(1.2rem, 5vw, 2rem);
  color: #fff;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
  line-height: 1.3;
}

.story-tap {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  z-index: 11;
  cursor: pointer;
}
.story-tap-left  { left: 0; }
.story-tap-right { right: 0; }

/* ===========================
   CARD TEXT OVERLAY (on grid & feed)
   =========================== */
.grid-item .card-text-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 6px 8px;
  background: linear-gradient(transparent, rgba(0,0,0,.55));
  color: #fff;
  font-family: var(--font-display);
  font-size: .7rem;
  line-height: 1.2;
  pointer-events: none;
}

.feed-card-text {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(transparent, rgba(0,0,0,.5));
  color: #fff;
  font-family: var(--font-display);
  font-size: 1.1rem;
  line-height: 1.3;
  pointer-events: none;
}

/* ===========================
   RESPONSIVE
   =========================== */
@media (min-width: 600px) {
  .profile-pic-wrap { width: 100px; height: 100px; }
  .profile-header { padding: 1.5rem 1.25rem 1rem; }
}
