/* Summit Haven — main styles (glass cards, fixes, desktop layout). */
  /* Guaranteed, dependency-free .hidden rule. Every overlay/modal in
     this app is toggled via the Tailwind "hidden" utility class, but
     that class only exists once cdn.tailwindcss.com finishes loading
     and parsing. If that script is slow or fails, every element
     relying solely on the Tailwind class stays visible and sits in
     normal document flow — stacking dozens of "hidden" modals above
     the real app content and pushing the header thousands of pixels
     down the page. This plain CSS rule (no Tailwind dependency) makes
     display:none apply immediately regardless of CDN load timing. */
  .hidden { display: none !important; }

  /* Same problem, different Tailwind utilities: several overlays/drawers
     in this app (sidebar, bio editor, discard-confirm modal, background
     panel, etc.) don't use the "hidden" class above — they hide by
     default with opacity-0 + pointer-events-none, or slide off-screen
     with -translate-x-full / translate-y-full. Those are ALSO just
     Tailwind-generated classes that don't exist until the CDN script
     loads, so on a slow/blocked connection every one of these elements
     was rendering fully visible in normal document flow (exactly the
     "everything stacked on one page" bug). These plain-CSS fallbacks
     give the same values natively, so overlays stay correctly hidden
     from first paint regardless of CDN timing. JS still toggles the
     Tailwind class names directly (classList.remove/add), so once the
     CDN does load these rules and Tailwind's identical ones simply
     agree with each other — nothing about the toggle logic changes. */
  .opacity-0 { opacity: 0; }
  .pointer-events-none { pointer-events: none; }
  .translate-x-full { transform: translateX(100%); }
  .-translate-x-full { transform: translateX(-100%); }
  .translate-y-full { transform: translateY(100%); }
  .-translate-y-full { transform: translateY(-100%); }

  /* Same fallback logic again: "fixed" + "inset-0" are what actually
     pull every overlay OUT of normal document flow. Without Tailwind,
     a "fixed" element with no native position rule is just a regular
     block — invisible now (thanks to the rules above), but it still
     reserves its full height in the page, leaving a large blank gap
     above the real header. These two rules make fixed/full-viewport
     positioning work natively too, so the layout is correct even on
     a completely failed Tailwind load, not just "nothing's stacked." */
  .fixed { position: fixed; }
  .inset-0 { top: 0; right: 0; bottom: 0; left: 0; }

  /* The whole app is a fixed-width mobile layout — it should never be
     possible to swipe/scroll it sideways. If any element anywhere
     overflows its container even slightly, the browser will otherwise
     let the whole page (and any fixed-position modal along with it)
     be dragged left/right, which is what was happening with the
     Details editor above. Locking horizontal scroll here is a global,
     permanent fix regardless of which element is the culprit. */
  html, body { overflow-x: hidden; max-width: 100%; }

  /* ---------------------------------------------------------
     SUMMIT HAVEN — shared design tokens
     Reference this block on future Summit Haven pages.
     ----------------------------------------------------------
     Background:   the exact uploaded floral lavender photo, applied
                   directly on <body> via background-image (embedded
                   as base64 JPG so the file stays single-file).
                   background-size: cover / position: center /
                   attachment: scroll — scales cleanly on mobile and
                   scrolls naturally with the page content.
     Cards:        bg-white/5 backdrop-blur-lg border border-white/30
                   (glassmorphic — floral background shows through)
     Accent solid: #8B5CF6 (violet-500) / hover #7C3AED
     Accent deep:  #6D28D9 (footer / header bar)
     Text:         #000000 solid black — every heading, label,
                   placeholder, and list item on every card.
                   White text is used ONLY on solid purple
                   buttons/header bar, where black text on
                   purple would be unreadable.
  --------------------------------------------------------- */
  body {
    min-height: 100vh;
    background-color: #E9D8FA; /* fallback beneath the fixed floral layer */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    color: #000000;
    position: relative;
  }
  /* Dedicated fixed background layer — a real fixed-position element
     (not background-attachment: fixed on body) so the floral photo
     stays truly locked in place on iOS Safari, which does not honor
     background-attachment: fixed reliably. */
  #bg-layer {
    background-image: url('public/assets/images/main_background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
  }
  .icon-btn { transition: transform 0.15s ease, background 0.15s ease; }
  .icon-btn:hover { transform: translateY(-1px); }

  /* Safety net for iOS Safari's contenteditable caret-scroll behavior:
     if the browser ever still scrolls the page itself (rather than the
     now-internally-scrolling #book-editor) to keep a text selection
     visible above the keyboard, this keeps it from landing content
     underneath the sticky purple header bar */
  html {
    scroll-padding-top: 72px;
  }

  /* Manuscript Studio — placeholder text for the contenteditable
     #book-editor surface, shown only while genuinely empty so real
     typed content (including formatted bold/italic/underline runs)
     never gets obscured */
  #book-editor:empty:before {
    content: attr(data-placeholder);
    color: rgba(0,0,0,0.4);
    font-weight: 700;
    pointer-events: none;
  }

  /* Manuscript Studio — the default OS text-selection highlight (a
     faint yellow) is hard to see against the editor's frosted-glass
     background, especially on italic/underlined text. Swap it for a
     stronger brand-purple tint with clearly readable text on top. */
  #book-editor::selection,
  #book-editor *::selection {
    background: rgba(124, 58, 237, 0.55) !important;
    color: #1a1025 !important;
  }
  #book-editor::-moz-selection,
  #book-editor *::-moz-selection {
    background: rgba(124, 58, 237, 0.55) !important;
    color: #1a1025 !important;
  }
  .pill-btn { transition: transform 0.15s ease, filter 0.15s ease; }
  .pill-btn:active { transform: scale(0.97); }
  .pill-btn:hover { filter: brightness(1.06); }
  /* Hides the scrollbar on the sidebar drawer while keeping it scrollable */
  .hide-scrollbar { scrollbar-width: none; -ms-overflow-style: none; }
  .hide-scrollbar::-webkit-scrollbar { display: none; }
  /* Tailwind's CDN build doesn't ship a scrollbar-none utility by default */
  .scrollbar-none { scrollbar-width: none; -ms-overflow-style: none; }
  .scrollbar-none::-webkit-scrollbar { display: none; }
  /* Smooth diffuse effect applied to #app-shell while the See More
     popup is open — softens the profile underneath without a dark tint */
  #app-shell { transition: filter 0.25s ease; }
  #app-shell.diffuse-blur { filter: blur(4px); }
  /* High-visibility placeholder for the story customizer's text-tool
     contenteditable layer, so "@Mention someone or type" reads clearly
     over a dimmed photo — contenteditable has no native placeholder
     attribute, so this is the standard :empty:before technique */
  #story-text-editable:empty:before {
    content: attr(data-placeholder);
    color: rgba(255,255,255,0.85);
    pointer-events: none;
  }
  /* Desktop treatment: still the same mobile layout, just given a
     little more breathing room than a pixel-for-pixel phone card —
     modestly wider (about 20% over the 28rem phone width) and text
     bumped up slightly via the root font-size, which scales every
     rem-based Tailwind text size along with it. Below 640px (real
     phones) none of this applies at all — the mobile view is
     untouched. A real, distinct desktop layout is planned for later
     once it's been designed screen by screen like the mobile version
     was — this is deliberately just the mobile design, framed. */
  @media (min-width: 640px) {
    html {
      font-size: 17.5px;
    }
    #app-shell {
      width: 34rem !important;
      max-width: 34rem !important;
      margin-top: 28px;
      margin-bottom: 28px;
      min-height: calc(100vh - 56px);
      border-radius: 28px;
      overflow: hidden;
      box-shadow: 0 30px 70px -12px rgba(76,29,149,0.45), 0 0 0 1px rgba(168,85,247,0.15);
    }
    /* That box-shadow above is a soft drop shadow plus a thin 1px
       purple outline — subtle against the busy default floral
       pattern, but reads as an obvious "glass border" frame sitting
       on top of a plain custom photo/gradient background. Stripped
       here specifically while one's active (see the class toggle in
       applyProfileContentBackground/resetProfileContentBackground),
       so a custom background can go edge-to-edge with nothing
       framing it — every other screen keeps the normal framing. */
    #app-shell.profile-custom-bg-active {
      box-shadow: none !important;
    }
    /* Matches #app-shell's card framing above so this body-level
       overlay (see its own comment for why it lives outside
       #app-shell) still reads as the same phone-card, not a
       differently-styled edge-to-edge panel on desktop. */
    #view-storefront-collection {
      max-width: 34rem !important;
      top: 28px !important;
      bottom: 28px !important;
      border-radius: 28px;
      overflow: hidden;
      box-shadow: 0 30px 70px -12px rgba(76,29,149,0.45), 0 0 0 1px rgba(168,85,247,0.15);
    }
    /* Same fix, same reasoning, for Comment Wall specifically — fixed
       individually and verified, not through the broad generic rule
       that was tried and reverted elsewhere in this file. */
    #profile-comment-wall-panel {
      max-width: 34rem !important;
      top: 28px !important;
      bottom: 28px !important;
      border-radius: 28px;
      overflow: hidden;
      box-shadow: 0 30px 70px -12px rgba(76,29,149,0.45), 0 0 0 1px rgba(168,85,247,0.15);
    }
    /* Same fix, same reasoning, for Group Detail. */
    #groupDetailOverlay {
      max-width: 34rem !important;
      top: 28px !important;
      bottom: 28px !important;
      border-radius: 28px;
      overflow: hidden;
      box-shadow: 0 30px 70px -12px rgba(76,29,149,0.45), 0 0 0 1px rgba(168,85,247,0.15);
    }
    /* Composer's Edit Photos review screen — was trapped inside
       #app-shell (its z-index:82 only mattered locally there), which
       is exactly what let the body-level composer render on top of
       it despite the composer's own lower z-index of 80.
       This does NOT get the narrow Comment-Wall-style card treatment
       — cpOpenReviewScreen() deliberately leaves the composer open
       underneath (it's a "step forward" layered on top, not a
       replacement), so this needs to match the composer's own
       full-width footprint exactly, or the wider composer peeks out
       from behind/beside it. See the stretch-to-fill-middle-column
       group below, which this now belongs to instead. */
    /* New Post composer + Add Text + Post Settings — these already use
       "transform" for their own slide-up-from-bottom open/close
       animation (translateY), so centering them with
       transform:translateX(-50%) like the other overlays above would
       fight that — a single element can only have one transform value
       at a time, and the JS that opens/closes these overwrites it.
       margin-left/right:auto centers a fixed element with left:0;
       right:0 (inherited from the "inset-0" these start with) and a
       max-width instead, with no transform involved at all.
       This is deliberately NOT given the rounded-corner/shadow card
       treatment the other panels above get — these represent a full
       mobile screen taking over, the same way they already do on
       phones, not a floating card. Below the 1240px 3-column
       breakpoint there's no separate "middle column" to fill yet
       (just the one centered app-shell card), so matching that
       card's own width is the correct "fits the screen" behavior
       here too. */
    #yourFeedNewPostOverlay,
    #yfAddTextOverlay,
    #yourFeedPostSettingsOverlay,
    #yourFeedAudienceOverlay,
    #yourFeedMusicOverlay,
    #yourFeedGroupsOverlay,
    #cp-photo-review-screen,
    #gdNewPostOverlay,
    #gd-photo-review-screen {
      max-width: 34rem !important;
      margin-left: auto !important;
      margin-right: auto !important;
    }
    /* Composer Album Picker sheet — now uses the exact same base
       inline-style centering as Comment Wall/Storefront Collection
       (left:50% + transform:translateX(-50%), not Tailwind's left-0/
       right-0 classes), after the margin-auto approach used here
       first turned out not to actually apply — this technique is the
       one already confirmed working elsewhere in this file. */
    #cp-album-picker-sheet {
      max-width: 34rem !important;
    }
    /* A generic rule constraining every "fixed inset-0" element to
       card width was tried here and reverted — 76 elements turned out
       to use at least 3 different internal structures (content
       panels, backdrops with a centered child card, and plain
       dimming layers built with inline styles instead of classes),
       and one clever selector couldn't safely handle all of them at
       once without breaking some of them in ways that were hard to
       predict (About Me's editor silently failing to open was the
       one that got caught). Comment Wall and similar panels are back
       to full-viewport width on desktop for now — cosmetic, and safe.
       Fixing that width issue for real means going through these
       screen by screen with actual verification, not one broad
       selector guessing at all of them. */
  }

  /* ===== 3-column desktop layout: menu (left) | mobile content,
     unchanged (middle) | Messages (right), both rails permanently
     visible. Only kicks in at a genuinely wide breakpoint — anything
     narrower than this keeps the simple centered "phone card" from
     the block above instead, since 3 real columns need more room
     than a tablet-width window actually has. 1240px (not 1024px) on
     purpose: 300px + 300px of fixed rail plus the 544px card above
     needs 1144px minimum just to avoid overflowing — 1240px leaves
     real breathing room instead of sitting right at that edge. Rails
     are 300px — back from a brief 360px that was meant to stop
     "Military & Veterans Hub" wrapping to two lines, reverted because
     it also pushed the breakpoint high enough that the whole 3-column
     layout stopped triggering reliably. The nav label wrapping is a
     known, smaller tradeoff until a better fix (e.g. a slightly
     smaller font just for that one item) is worth revisiting.
     Below 640px (real phones) none of this exists at all; the
     sidebar is still the normal off-canvas hamburger drawer there. ===== */
  /* Tablet-width windows (640px–1239px): the app shows as a centered
     34rem "phone card", but the footer was still stretching edge to
     edge across the whole window. This keeps the footer exactly as
     wide as the card and centered under it. Uses max-width + auto
     margins (not transform), because the footer's scroll-to-hide
     animation already uses transform. Phones (<640px) and the
     3-column desktop layout (1240px+) are untouched. */
  /* Narrow windows / big phones (449px–639px): the app column is
     28rem wide and centered, so the footer matches it instead of
     stretching edge to edge. Real phones (448px and under) are
     unchanged — there the column IS the whole screen. */
  @media (min-width: 449px) and (max-width: 639px) {
    #summit-footer {
      left: 0 !important;
      right: 0 !important;
      max-width: 28rem !important;
      margin-left: auto !important;
      margin-right: auto !important;
      border-radius: 0;
    }
    /* Big Android phones land in this range. The purple header and
       footer bars paint all the way to both screen edges (like on an
       iPhone), while their buttons and the content stay in the
       centered column. The purple "shadow" reaches sideways only;
       the clip-path stops it spilling up or down. */
    #app-shell > header,
    #summit-footer {
      box-shadow: 0 0 0 100vmax #7C3AED;
      clip-path: inset(0 -100vmax);
    }
  }

  @media (min-width: 640px) and (max-width: 1239px) {
    #summit-footer {
      left: 0 !important;
      right: 0 !important;
      max-width: 34rem !important;
      margin-left: auto !important;
      margin-right: auto !important;
      border-radius: 20px 20px 0 0;
    }
  }

  @media (min-width: 1240px) {
    #sidebar {
      position: fixed !important;
      transform: translateX(0) !important;
      top: 0 !important;
      left: 0 !important;
      height: 100vh !important;
      width: 300px !important;
      z-index: 20;
      border-right: 1px solid rgba(168,85,247,0.2);
    }
    /* No dismiss-backdrop needed for a permanently visible sidebar —
       and without this, a stray closeSidebar() call elsewhere could
       still flash the backdrop briefly even though the sidebar itself
       stays put via the !important transform above. */
    #sidebar-overlay {
      display: none !important;
    }
    /* The hamburger toggle has nothing left to toggle */
    #app-shell > header button[aria-label="Menu"] {
      display: none !important;
    }
    /* True centering in the leftover space between the two 300px
       rails, not just a flat 300px margin each side — a fixed-width
       block with fixed margins on both sides doesn't auto-center
       itself, it just sits flush against whichever side is defined
       first, leaving the rest as dead space. This computes the real
       center: (full width minus both rails minus the card) / 2,
       added on top of the left rail's width. */
    #app-shell {
      margin-left: calc(300px + (100vw - 600px - 34rem) / 2) !important;
      margin-right: 0 !important;
    }
    /* The footer was built full-viewport-width (position:fixed;
       left:0; width:100%) since on mobile the viewport IS the app's
       width. Here it's pinned edge-to-edge across the full middle
       column instead (flush against both rails), matching the header
       below — the actual mobile content in between stays its normal
       544px width, centered; only these two bars stretch. */
    #summit-footer {
      left: 300px !important;
      width: calc(100vw - 600px) !important;
    }
    /* Header stretched to match — pulled out of #app-shell's normal
       flow (position:fixed escapes an ancestor's overflow:hidden as
       long as that ancestor has no transform/filter, same trick used
       elsewhere in this file for other overlays), so it can be wider
       than the 544px card it visually sits above. #app-shell's own
       content needs matching top padding since the header no longer
       takes up space in normal flow to push it down automatically. */
    #app-shell > header {
      position: fixed !important;
      top: 0 !important;
      left: 300px !important;
      width: calc(100vw - 600px) !important;
      z-index: 30 !important;
    }
    /* Top padding to compensate for the fixed header no longer
       taking up space in normal flow is handled in JS instead of a
       hardcoded px guess here — see summitSyncHeaderPadding(). A
       fixed number never matched the header's real height (which
       also shifts with the desktop font-size bump above), leaving a
       visible gap between the header and the content below it. */
    #desktop-messages-rail {
      display: flex !important;
      position: fixed;
      top: 0;
      right: 0;
      height: 100vh;
      width: 300px;
      z-index: 20;
      border-left: 1px solid rgba(168,85,247,0.2);
    }
    /* Same fix as #app-shell/#summit-footer above — this overlay
       centers itself in the full viewport by default (left:50% +
       translateX(-50%)), which was correct back when nothing sat
       beside the card, but needs to match the card's actual
       off-center position now that two rails are present. Overriding
       the transform-based centering with a plain calc'd left edge. */
    #view-storefront-collection {
      left: calc(300px + (100vw - 600px - 34rem) / 2) !important;
      transform: none !important;
    }
    /* Same fix, same reasoning, for Comment Wall specifically. */
    #profile-comment-wall-panel {
      left: calc(300px + (100vw - 600px - 34rem) / 2) !important;
      transform: none !important;
    }
    /* Same fix, same reasoning, for Group Detail. */
    #groupDetailOverlay {
      left: calc(300px + (100vw - 600px - 34rem) / 2) !important;
      transform: none !important;
    }
    /* New Post composer + Add Text + Post Settings — different
       treatment from every other panel here: those get centered at
       card-width, but these represent a full mobile screen taking
       over, matching exactly how they already fill the whole
       viewport on phones. Their "whole screen" on desktop is the
       middle column, not the narrower card — so this stretches them
       edge-to-edge between the two rails, the same way the header
       and footer already do, instead of centering them at 34rem.
       cp-photo-review-screen belongs in this group too, not with
       Comment Wall above — it deliberately layers on top of the
       still-open composer rather than replacing it, so it needs to
       match the composer's own full-width footprint or the wider
       composer peeks out from behind it. transform is deliberately
       NOT touched in this shared rule — the other three in this
       group use it via JS for their own slide-up-from-bottom
       animation, and cancelling it here would break that. Its own
       cancellation is a separate rule just below, scoped to only
       cp-photo-review-screen. */
    #yourFeedNewPostOverlay,
    #yfAddTextOverlay,
    #yourFeedPostSettingsOverlay,
    #yourFeedAudienceOverlay,
    #yourFeedMusicOverlay,
    #yourFeedGroupsOverlay,
    #cp-photo-review-screen,
    #gdNewPostOverlay,
    #gd-photo-review-screen {
      left: 300px !important;
      right: auto !important;
      width: calc(100vw - 600px) !important;
      max-width: none !important;
      margin-left: 0 !important;
      margin-right: 0 !important;
    }
    /* cp-photo-review-screen and gd-photo-review-screen's own base
       inline style used left:50% + transform:translateX(-50%) for
       centering (the Comment-Wall-style technique), unlike the other
       three in the group above which never use transform for
       positioning at all — so these two specifically still need their
       transform cancelled. */
    #cp-photo-review-screen,
    #gd-photo-review-screen {
      transform: none !important;
    }
    /* Same rail-aware alignment for the Album Picker sheet as the
       other centered cards above (not stretched like the composer
       itself — "shrink it down" meant narrower, not full-width).
       Cancels the transform-based centering the same way Comment
       Wall/Storefront Collection do, now that this uses that same
       base technique. */
    #cp-album-picker-sheet {
      left: calc(300px + (100vw - 600px - 34rem) / 2) !important;
      transform: none !important;
    }
    /* Change Background drawer — same margin-based centering as the
       composer group above, not the transform-cancel technique,
       since this drawer also uses "transform" via the translate-y-full
       class for its own slide-up animation (see openBackgroundPanel/
       closeBackgroundPanel) — cancelling transform here would break
       that the same way it would for the composer. */
    #backgroundPanelDrawer {
      left: calc(300px + (100vw - 600px - 28rem) / 2) !important;
      right: auto !important;
      margin-left: 0 !important;
      margin-right: 0 !important;
    }
  }

  /* Visiting a Private profile: only the top profile card (name +
     photo) and the lock card show — every other section is hidden.
     Toggled by components/people.js. */
  #view-edit-profile.summit-private-visit > section:not(:first-of-type):not(#profile-private-lock) {
    display: none !important;
  }
  #view-edit-profile.summit-private-visit #storeBtn,
  #view-edit-profile.summit-private-visit #galleryBtn,
  #view-edit-profile.summit-private-visit #profile-badges-list {
    display: none !important;
  }

  /* People Search overlay — same card framing as Comment Wall on
     tablet widths, and the same rail-aware position on the 3-column
     desktop layout (see #profile-comment-wall-panel above). */
  @media (min-width: 640px) {
    #people-search-overlay,
    #follow-lists-overlay,
    #profile-scope-overlay,
    #msg-create-screen {
      max-width: 34rem !important;
      top: 28px !important;
      bottom: 28px !important;
      border-radius: 28px;
      overflow: hidden;
      /* Last shadow = a dim layer over everything behind the pop-up,
         so the header/bottom bar don't peek out around its corners */
      box-shadow: 0 30px 70px -12px rgba(76,29,149,0.45), 0 0 0 1px rgba(168,85,247,0.15), 0 0 0 100vmax rgba(30,10,55,0.55);
    }
  }
  @media (min-width: 1240px) {
    #people-search-overlay,
    #follow-lists-overlay,
    #profile-scope-overlay,
    #msg-create-screen {
      left: calc(300px + (100vw - 600px - 34rem) / 2) !important;
      transform: none !important;
    }
  }

/* ---------------------------------------------------------
   SUMMIT HAVEN — keep the purple header stuck to the top
   "overflow: hidden" on body (and on the desktop phone-card)
   quietly turns them into their own scroll boxes, which stops
   the sticky header from sticking. "clip" still blocks sideways
   scrolling and still rounds the card corners, without that
   side effect. (Older browsers just keep "hidden".)
   --------------------------------------------------------- */
html, body { overflow-x: clip; }
@supports not (overflow-x: clip) {
  /* Very old browsers: let only the page itself block sideways
     scrolling, so the header can still stick. */
  body { overflow-x: visible; }
}
@media (min-width: 640px) and (max-width: 1239px) {
  #app-shell { overflow: clip; }
}

/* ---------------------------------------------------------
   SUMMIT HAVEN — profile buttons open full pages (profile-pages.js)
   The purple Albums/Vids/Reels/post screen now lives inside the
   page under the header instead of floating over it.
   --------------------------------------------------------- */
#app-content > #profile-scope-overlay {
  position: static !important;
  top: auto !important; bottom: auto !important; left: auto !important;
  transform: none !important;
  width: auto !important; max-width: none !important;
  background: transparent !important;
  backdrop-filter: none !important; -webkit-backdrop-filter: none !important;
  border-radius: 0 !important; overflow: visible !important;
  box-shadow: none !important; z-index: auto !important;
}
#app-content > #profile-scope-overlay > div:first-child {
  border-radius: 9999px; margin-bottom: 16px; padding: 12px 16px;
}
#app-content > #profile-scope-overlay #profile-scope-body {
  flex: none; overflow: visible; padding: 0 0 24px;
}

/* Profile card: when not editing, the Store/Gallery buttons are narrower so
   the followers/badges column has more room. (The name now has its own
   full-width line under the photo — #profile-name-row in index.html.) */
#profile-col3.profile-viewing { width: 96px; }
