/* ============================================================
   SHARED NAV — X-style sidebar (desktop) + bottom nav (mobile)
   Pages opt in by including shared-nav.css + shared-nav.js and
   placing <div data-shared-nav></div> (left) and optionally
   <div data-shared-rightrail></div> inside a wrapping
   <div class="x-layout"> ... </div>.
   ============================================================ */

:root {
  --xn-fg: #0f1419;
  --xn-muted: #536471;
  --xn-border: #eff3f4;
  --xn-hover: #e7e7e8;
  --xn-accent: #f4c542;
  --xn-bg: #fff;
  --xn-card: #f7f9f9;
  --xn-skeleton-base: #eef0f1;
  --xn-skeleton-hi: #f7f8f8;
}

body.dark {
  --xn-fg: #F5F5F5;
  --xn-muted: #9CA3AF;
  --xn-border: #2C2C2E;
  --xn-hover: #2C2C2E;
  --xn-bg: #121212;
  --xn-card: #1C1C1E;
  --xn-skeleton-base: #2C2C2E;
  --xn-skeleton-hi: #3C3C3E;
}

/* ───────── Skeleton (shared) ───────── */
.skeleton, .skeleton-text, .skeleton-circle, .skeleton-rect {
  display: block;
  background: linear-gradient(90deg,
    var(--xn-skeleton-base) 0%,
    var(--xn-skeleton-hi)  50%,
    var(--xn-skeleton-base) 100%);
  background-size: 200% 100%;
  animation: xnShimmer 1.4s ease-in-out infinite;
  border-radius: 8px;
}
.skeleton-text { height: 12px; border-radius: 6px; margin: 6px 0; }
.skeleton-text.sm { height: 10px; }
.skeleton-text.lg { height: 16px; }
.skeleton-circle { border-radius: 50%; }
.skeleton-rect { border-radius: 12px; }
@keyframes xnShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ───────── Layout ───────── */
.x-layout { display: contents; }
.xn-sidebar .xn-logo,
.xn-sidebar .xn-post-btn { display: none; }
.xn-rightrail { display: none; }

/* MOBILE bottom nav */
.xn-sidebar {
  position: fixed;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 24px);
  max-width: 520px;
  background: var(--xn-bg);
  border: 1px solid var(--xn-border);
  border-radius: 9999px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 4px;
  box-shadow: 0 6px 24px rgba(0,0,0,.08);
  z-index: 60;
}
.xn-sidebar .xn-item {
  position: relative;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px 10px;
  border-radius: 9999px;
  color: var(--xn-muted);
  text-decoration: none;
  font-size: 11px;
  font-weight: 500;
}
.xn-sidebar .xn-item span:not(.xn-badge) { display: none; }
.xn-sidebar .xn-item svg { width: 24px; height: 24px; fill: currentColor; }
.xn-sidebar .xn-item.active { color: var(--xn-fg); }
.xn-sidebar .xn-badge {
  position: absolute;
  top: 4px; right: 6px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  min-width: 16px; height: 16px;
  border-radius: 9999px;
  padding: 0 4px;
  display: flex; align-items: center; justify-content: center;
}

/* Mobile clearance so floating bottom nav doesn't cover content */
@media (max-width: 1024px) {
  body { padding-bottom: 84px; }
}

/* Hide-on-fullscreen helper (vybze-player) */
body.xn-hide-nav .xn-sidebar { display: none !important; }

/* DESKTOP ≥1025px */
@media (min-width: 1025px) {
  /* IMPORTANT: many legacy pages set `body { max-width: 680px }` for mobile-
     centered layouts. That constraint collapses the 3-col grid down to a
     few pixels on desktop. Reset it whenever shared-nav is loaded. */
  body { background: var(--xn-bg); max-width: none !important; margin: 0 !important; }
  body.xn-has-layout { padding-left: 0 !important; padding-right: 0 !important; }

  .x-layout {
    display: grid;
    grid-template-columns: 275px minmax(0, 600px) 350px;
    justify-content: center;
    max-width: 1290px;
    margin: 0 auto;
    align-items: start;
    width: 100%;
  }


  .xn-sidebar {
    position: fixed;
    top: 0;
    left: max(0px, calc((100vw - 1290px) / 2));
    transform: none;
    width: 275px;
    max-width: 275px;
    height: 100vh;
    background: var(--xn-bg);
    border: none;
    border-right: 1px solid var(--xn-border);
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    padding: 8px 12px 16px;
    z-index: 50;
  }
  /* When inside an .x-layout grid, become sticky instead of fixed so it
     aligns naturally with the grid column. */
  .x-layout .xn-sidebar {
    position: sticky;
    left: auto;
  }
  /* Body padding so fixed sidebar doesn't overlap content on pages that
     are NOT wrapped in .x-layout. */
  body:not(.xn-has-layout) { padding-left: 275px; }
  .xn-sidebar .xn-logo {
    display: flex;
    align-items: center; justify-content: center;
    width: 56px; height: 56px;
    border-radius: 9999px;
    color: var(--xn-fg);
    margin: 4px 0;
    transition: background .15s ease;
  }
  .xn-sidebar .xn-logo:hover { background: var(--xn-hover); }
  .xn-sidebar .xn-logo img { width: 36px; height: 36px; object-fit: contain; }

  .xn-sidebar .xn-item {
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 18px;
    padding: 12px 16px 12px 12px;
    border-radius: 9999px;
    color: var(--xn-fg);
    font-size: 20px;
    font-weight: 400;
    width: max-content;
    max-width: 100%;
  }
  .xn-sidebar .xn-item span:not(.xn-badge) { display: inline; font-size: 20px; line-height: 1; }
  .xn-sidebar .xn-item:hover { background: var(--xn-hover); }
  .xn-sidebar .xn-item.active { font-weight: 700; }
  .xn-sidebar .xn-item svg { width: 26px; height: 26px; }
  .xn-sidebar .xn-badge {
    position: static;
    background: var(--xn-accent);
    margin-left: 4px;
  }
  .xn-sidebar .xn-post-btn {
    display: block;
    margin-top: 16px;
    background: var(--xn-fg);
    color: #fff;
    border: none;
    border-radius: 9999px;
    padding: 14px 24px;
    font-size: 17px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s ease;
  }
  .xn-sidebar .xn-post-btn:hover { background: #272c30; }

  /* Right rail */
  .xn-rightrail {
    display: block;
    position: sticky;
    top: 0;
    width: 350px;
    height: 100vh;
    overflow-y: auto;
    padding: 8px 16px 24px;
    background: var(--xn-bg);
  }
  .xn-rightrail::-webkit-scrollbar { width: 0; }
  .xn-rightrail .xn-card {
    background: var(--xn-card);
    border-radius: 16px;
    padding: 12px 16px;
    margin-bottom: 16px;
  }
  .xn-rightrail .xn-card h3 {
    margin: 0 0 8px;
    font-size: 20px;
    font-weight: 800;
    color: var(--xn-fg);
  }
  .xn-rightrail .xn-trend {
    padding: 10px 0;
    border-bottom: 1px solid var(--xn-border);
  }
  .xn-rightrail .xn-trend:last-child { border-bottom: none; }
  .xn-rightrail .xn-trend .xn-trend-meta { font-size: 13px; color: var(--xn-muted); display:block; }
  .xn-rightrail .xn-trend strong { display:block; font-size: 15px; color: var(--xn-fg); margin: 2px 0; }
  .xn-rightrail .xn-follow {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0;
  }
  .xn-rightrail .xn-follow img { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; }
  .xn-rightrail .xn-follow .xn-follow-info { flex: 1; min-width: 0; }
  .xn-rightrail .xn-follow .xn-follow-info strong { display:block; font-size: 15px; color: var(--xn-fg); }
  .xn-rightrail .xn-follow .xn-follow-info span { display:block; font-size: 13px; color: var(--xn-muted); }
  .xn-rightrail .xn-follow .xn-follow-btn {
    background: var(--xn-fg);
    color: var(--xn-bg); border: none;
    border-radius: 9999px;
    padding: 8px 16px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
  }
  .xn-rightrail .xn-legal { color: var(--xn-muted); font-size: 13px; padding: 8px 4px 24px; line-height: 1.6; }
  .xn-rightrail .xn-legal a { color: var(--xn-muted); text-decoration: none; margin-right: 8px; }
  .xn-rightrail .xn-trend-link { display: block; text-decoration: none; color: inherit; transition: background .15s ease; padding-left: 8px; margin-left: -8px; padding-right: 8px; border-radius: 8px; }
  .xn-rightrail .xn-trend-link:hover { background: rgba(15,20,25,.04); }
  .xn-rightrail .xn-follow .xn-follow-info { text-decoration: none; color: inherit; }
  .xn-rightrail .xn-follow .xn-follow-btn.following { background: var(--xn-bg); color: var(--xn-fg); border: 1px solid var(--xn-border); }
  .xn-rightrail .xn-follow-skel { opacity: .9; }
  .xn-rightrail .xn-show-more { display: block; padding: 12px 0 4px; color: var(--xn-accent); font-size: 14px; text-decoration: none; font-weight: 500; }
  .xn-rightrail .xn-show-more:hover { text-decoration: underline; }

  /* ─────────────────────────────────────────────
     SHARED TOP-NAV — constrained to middle column
     Fixed at top, sized to the 600px main column,
     centered within the 3-column grid.
     ───────────────────────────────────────────── */
  .top-nav {
    display: flex !important;
    position: fixed !important;
    top: 0 !important;
    left: max(275px, calc((100vw - 1290px) / 2 + 275px)) !important;
    right: auto !important;
    transform: none !important;
    width: 600px !important;
    max-width: 600px !important;
    padding: 10px 16px !important;
    background: rgba(255,255,255,0.85);
    backdrop-filter: saturate(180%) blur(12px);
    -webkit-backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--xn-border);
    border-left: 1px solid var(--xn-border);
    border-right: 1px solid var(--xn-border);
    color: var(--xn-fg);
    z-index: 80;
    box-sizing: border-box;
  }
  body.dark .top-nav {
    background: rgba(18,18,18,0.85);
    border-color: var(--xn-border);
  }
  /* Push main content below the fixed top-nav */
  .x-layout > main,
  .x-layout .feed-main,
  .x-layout .vybze-main {
    padding-top: 64px;
  }

  /* Notification icon is already in the left sidebar on desktop —
     hide the duplicate in the top-nav. */
  .top-nav #notificationBtn { display: none !important; }

  /* Public-profile view: hide right rail, expand middle column. */
  body.profile-public .xn-rightrail { display: none !important; }
  body.profile-public .x-layout {
    grid-template-columns: 275px minmax(0, 950px);
  }

  /* Vybze-player desktop: hide left sidebar AND right rail, fullscreen player. */
  body.xn-hide-sidebar .xn-sidebar { display: none !important; }
  body.xn-hide-sidebar .xn-rightrail { display: none !important; }
  body.xn-hide-sidebar:not(.xn-has-layout) { padding-left: 0 !important; }

  /* Profile own view: hide back/settings header on desktop. */
  body.profile-own .profile-top-bar,
  body.profile-public .profile-top-bar { display: none !important; }
}

/* ============================================================
   CREATE POST MODAL (X-style, dark, blur backdrop)
   Pages opt in by giving the overlay .xp-overlay and modal .xp-modal.
   ============================================================ */
.xp-overlay {
  position: fixed; inset: 0;
  background: rgba(91,112,131,.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: none;
  z-index: 998;
  animation: xpFadeIn .15s ease;
}
.xp-overlay.active { display: block; }
@keyframes xpFadeIn { from { opacity:0 } to { opacity:1 } }

.xp-modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%) scale(.98);
  width: min(600px, calc(100% - 24px));
  max-height: 90vh;
  background: var(--xn-bg);
  color: var(--xn-fg);
  border-radius: 16px;
  border: 1px solid var(--xn-border);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
  font-family: inherit;
}
.xp-modal.open {
  display: flex;
  animation: xpPop .18s ease forwards;
}
@keyframes xpPop {
  to { transform: translate(-50%, -50%) scale(1); }
}
@media (max-width: 640px) {
  .xp-modal {
    top: 0; left: 0; transform: none;
    width: 100%; height: 100dvh; max-height: 100dvh;
    border-radius: 0; border: none;
  }
  .xp-modal.open { animation: none; }
}

.xp-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
}
.xp-close {
  background: transparent; border: none; color: var(--xn-fg);
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s ease;
}
.xp-close:hover { background: var(--xn-hover); }
.xp-drafts {
  background: transparent; border: none;
  color: #f4c542; font-weight: 700; font-size: 15px;
  padding: 6px 12px; border-radius: 9999px; cursor: pointer;
}
.xp-drafts:hover { background: rgba(244,197,66,.12); }

.xp-body {
  flex: 1;
  overflow-y: auto;
  padding: 4px 16px 12px;
}
.xp-row { display: flex; gap: 12px; }
.xp-avatar {
  width: 40px; height: 40px; border-radius: 50%; object-fit: cover;
  flex-shrink: 0;
}
.xp-row-main { flex: 1; min-width: 0; }

.xp-audience {
  display: inline-flex; align-items: center; gap: 4px;
  background: transparent; border: 1px solid #f4c542;
  color: #f4c542; font-weight: 700; font-size: 14px;
  padding: 2px 12px; border-radius: 9999px; cursor: pointer;
  margin: 4px 0 6px;
}
.xp-input {
  width: 100%; min-height: 120px;
  background: transparent; border: none; outline: none; resize: none;
  color: var(--xn-fg); font-size: 20px; line-height: 1.4;
  font-family: inherit; padding: 8px 0;
}
.xp-input::placeholder { color: var(--xn-muted); transition: opacity .25s ease; }
.xp-input.xp-fading::placeholder { opacity: 0; }

.xp-reply-scope {
  display: inline-flex; align-items: center; gap: 6px;
  background: transparent; border: none;
  color: #f4c542; font-weight: 700; font-size: 14px;
  padding: 8px 0 12px; cursor: pointer;
  border-bottom: 1px solid var(--xn-border);
  width: 100%; justify-content: flex-start;
}

.xp-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--xn-border);
}
.xp-tools { display: flex; align-items: center; gap: 2px; }
.xp-tool-btn {
  background: transparent; border: none;
  color: #f4c542; width: 36px; height: 36px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .15s ease;
}
.xp-tool-btn:hover { background: rgba(244,197,66,.12); }

.xp-submit-wrap { display: flex; align-items: center; gap: 12px; }
.xp-counter { position: relative; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; }
.xp-counter-ring { display: block; }
.xp-counter-num {
  position: absolute; font-size: 11px; color: var(--xn-muted);
}
.xp-counter.warn #postCounterArc { stroke: #ffd400; }
.xp-counter.danger #postCounterArc { stroke: #f4212e; }
.xp-counter.danger .xp-counter-num { color: #f4212e; }

.xp-post-btn {
  background: #f4c542 !important;
  color: #0f1419 !important;
  font-weight: 700;
  border: none;
  border-radius: 9999px;
  padding: 8px 16px;
  cursor: pointer;
  min-width: 76px;
  font-size: 15px;
}
.xp-post-btn:disabled { opacity: .5; cursor: not-allowed; }

/* Media preview in the X-style modal */
.xp-modal .media-preview-container { margin-top: 12px; }
.xp-modal .media-preview-container img,
.xp-modal .media-preview-container video {
  border-radius: 14px;
  max-width: 100%;
}
.xp-modal .remove-media-btn {
  background: rgba(15,20,25,.75); color: #fff;
  border: none; border-radius: 9999px;
  padding: 6px 14px; font-size: 13px;
  font-weight: 700; cursor: pointer;
  margin-bottom: 8px;
}

/* Hide the floating bottom-nav on selected pages, but keep desktop sidebar visible. */
@media (max-width: 1024px) {
  body.xn-hide-bottom-nav .xn-sidebar { display: none !important; }
  body.xn-hide-bottom-nav { padding-bottom: 0 !important; }
}
