/* Compass & Dove Social: Collapsible "How does this work" Dropdown (Desktop + Mobile)
 * Self-hosted Cormorant & Figtree only. Light + Dark mode aware.
 * Real content (Community Reels & Stories + Live Adaptive Feed) leads at the very top.
 * Every instructional/onboarding/setup/explainer block lives inside ONE collapsed-by-default
 * <details id="how-it-works"> dropdown directly below Reels & Stories, deep-linkable via
 * #how-it-works and shareable through the ONE shared /assets/m508-block-share.* component.
 */

/* Flex ordering inside section.col-center (display:flex; flex-direction:column):
   1) Real content first: Community Reels & Stories (-20)
   2) One-tap collapsed explainer directly below Reels & above the Feed (-10)
   3) Feed status bar + Pinned Post & Adaptive Feed (0) */
#m508ReelsStoriesRail {
  order: -20 !important;
}

#how-it-works,
#m508HowItWorksWrap {
  order: -10 !important;
  margin: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FAFF 100%);
  border: 1.5px solid #D8E4F2;
  box-shadow: 0 6px 20px rgba(14, 35, 71, 0.08);
  overflow: hidden;
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  scroll-margin-top: 84px;
}

/* Keep Reels strip compact and inviting so Reels + collapsed bar + Pinned Post sit in top viewport */
section.col-center > #m508ReelsStoriesRail.rs-rail-card {
  padding: 10px 12px 11px;
  margin-bottom: 0;
}
section.col-center > #m508ReelsStoriesRail .rs-rail-head {
  margin-bottom: 8px;
}

/* Neutralize legacy mobile-only wrapper so there are never duplicate nested dropdowns */
#m508MobilePostEverywhereWrap {
  display: none !important;
}

/* Native <summary> trigger bar */
#how-it-works > summary.hiw508-bar {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 11px;
  padding: 11px 14px;
  background: linear-gradient(135deg, #0E2347 0%, #17366B 62%, #1D4382 100%);
  color: #FFFFFF;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition: filter 0.16s ease;
}

#how-it-works > summary.hiw508-bar::-webkit-details-marker,
#how-it-works > summary.hiw508-bar::marker {
  display: none;
  content: "";
}

#how-it-works > summary.hiw508-bar:hover {
  filter: brightness(1.04);
}

#how-it-works > summary.hiw508-bar:focus-visible {
  outline: 2.5px solid #F2C96B;
  outline-offset: -3px;
  border-radius: 14px;
}

.hiw508-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.hiw508-icon {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #F6D884 0%, #D4A84B 100%);
  color: #0E2347;
  box-shadow: 0 3px 10px rgba(212, 168, 75, 0.35);
}

.hiw508-titles {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}

.hiw508-title {
  font-family: 'Cormorant', Georgia, serif;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.08;
  color: #FFFDF7;
  letter-spacing: 0.01em;
}

.hiw508-sub {
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(235, 244, 255, 0.88);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hiw508-right {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.hiw508-first-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(246, 216, 132, 0.72);
  background: linear-gradient(135deg, #FCE7A6 0%, #E5B952 100%);
  color: #0E2347;
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  box-shadow: 0 2px 8px rgba(10, 22, 46, 0.25);
}

.hiw508-first-badge[hidden] {
  display: none !important;
}

.hiw508-chev {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  background: rgba(255, 255, 255, 0.12);
  color: #F8DF95;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.16s ease;
}

.hiw508-chev svg {
  transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
}

#how-it-works[open] .hiw508-chev svg {
  transform: rotate(180deg);
}

/* Collapsible body (CLOSED by default via native <details>, opens smoothly in place) */
#m508HowItWorksBody {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: #F6F9FE;
  border-top: 1px solid #DCE7F5;
  overflow: hidden;
  box-sizing: border-box;
}

#how-it-works:not([open]) > #m508HowItWorksBody {
  display: none;
}

/* Guide ribbon inside expanded body */
.hiw508-guide-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 13px;
  border-radius: 12px;
  background: #FFFFFF;
  border: 1px solid #DCE6F4;
  font-size: 12.8px;
  color: #2B3B59;
  line-height: 1.45;
}

.hiw508-guide-strip strong {
  color: #0E2347;
}

.hiw508-guide-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: 999px;
  background: #EDF4FF;
  border: 1px solid #C5DAF7;
  color: #12366E;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.hiw508-guide-link:hover {
  background: #DFECFF;
}

/* Clean spacing for relocated widgets inside #m508HowItWorksBody */
#m508HowItWorksBody > #connectBanner,
#m508HowItWorksBody > #connectedBar,
#m508HowItWorksBody > #m508QuickStartSteps,
#m508HowItWorksBody > #m508PushPersistentSlot,
#m508HowItWorksBody > #m508PushOptInHost,
#m508HowItWorksBody > #m508RegulatedSharingRoot,
#m508HowItWorksBody > #studioBridgeCard,
#m508HowItWorksBody > #earning-calculator,
#m508HowItWorksBody > #m508FullGuideCard,
#m508HowItWorksBody > .how-card,
#m508HowItWorksBody > #composerCard {
  margin: 0 !important;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  scroll-margin-top: 78px;
}

/* Two-column pairing for secondary explainer cards on wider desktop */
.hiw508-cards-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.hiw508-cards-grid > * {
  margin: 0 !important;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Ensure shared m508-block-share bar sits cleanly at the bottom of the expanded panel */
#m508HowItWorksBody > .m508-faq-share-bar {
  margin-top: 2px;
  width: 100%;
  box-sizing: border-box;
}

/* Tighten feed-status-bar slightly so Pinned Post sits cleanly in top viewport */
section.col-center > .feed-status-bar {
  padding: 2px 2px;
  margin: 0;
}

/* Mobile responsiveness (<= 640px) */
@media (max-width: 640px) {
  #how-it-works > summary.hiw508-bar {
    padding: 9px 11px;
    gap: 8px;
  }

  .hiw508-icon {
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .hiw508-title {
    font-size: 18.5px;
  }

  .hiw508-sub {
    font-size: 11px;
  }

  .hiw508-first-badge {
    padding: 3px 8px;
    font-size: 10.5px;
  }

  .hiw508-chev {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
  }

  #m508HowItWorksBody {
    padding: 10px;
    gap: 10px;
  }

  .hiw508-cards-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  section.col-center > #m508ReelsStoriesRail.rs-rail-card {
    padding: 8px 10px 9px;
  }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
  .hiw508-chev svg,
  #how-it-works > summary.hiw508-bar {
    transition: none !important;
  }
}


/* M508-COMPOSER-POPUP:start */
/* Sunlit light mode locked for Compass & Dove Social; standalone Pop-Up Composer Modal (Desktop + Mobile) */
#m508ComposerModalOverlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px 14px;
  background: rgba(12, 27, 51, 0.54);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  overflow-y: auto;
}
#m508ComposerModalOverlay.is-open {
  display: flex;
}
#m508ComposerModalDialog {
  position: relative;
  width: 100%;
  max-width: 650px;
  max-height: calc(100vh - 36px);
  overflow-y: auto;
  border-radius: 20px;
  background: linear-gradient(180deg, #FFFFFF 0%, #FAF7F0 100%);
  border: 1.5px solid #D9C38C;
  box-shadow: 0 24px 64px rgba(12, 27, 51, 0.32);
  padding: 0;
}
.m508-cmp-head {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, #0E2347 0%, #17366B 100%);
  color: #FFFDF7;
  border-bottom: 2px solid #D4A84B;
}
.m508-cmp-head-title {
  margin: 0;
  font-family: 'Cormorant', Georgia, serif;
  font-size: 23px;
  font-weight: 700;
  line-height: 1.1;
  color: #FFFDF7;
}
.m508-cmp-head-sub {
  margin: 2px 0 0;
  font-family: 'Figtree', system-ui, sans-serif;
  font-size: 12px;
  color: rgba(246, 232, 194, 0.9);
}
.m508-cmp-close {
  flex: 0 0 36px;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid rgba(246, 216, 132, 0.5);
  background: rgba(255, 255, 255, 0.12);
  color: #FFFDF7;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.m508-cmp-close:hover {
  background: rgba(255, 255, 255, 0.24);
}
#m508ComposerModalBody {
  padding: 14px 16px 18px;
}
#m508ComposerModalBody > #composerCard {
  margin: 0 !important;
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 4px 2px !important;
}
/* Hide raw inline #composerCard until moved into popup modal so feed stays clean at top */
section.col-center > #composerCard {
  display: none;
}
@media (max-width: 640px) {
  #m508ComposerModalOverlay {
    padding: 10px 8px;
    align-items: flex-start;
  }
  #m508ComposerModalDialog {
    max-height: calc(100vh - 20px);
    border-radius: 16px;
    margin-top: 4px;
  }
  #m508ComposerModalBody {
    padding: 10px 10px 16px;
  }
}
/* M508-COMPOSER-POPUP:end */

/* M508-ROYALTY-ASSURANCE:start */
#composerCard select#postCatalog {
  padding-right: 28px !important;
  text-overflow: ellipsis;
}
.m508-royalty-assurance {
  margin-top: 10px;
  padding: 10px 13px;
  border-radius: 12px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-family: 'Figtree', system-ui, -apple-system, sans-serif;
  font-size: 12.6px;
  line-height: 1.45;
  border: 1.5px solid #B7DFC8;
  background: linear-gradient(135deg, #F2FBF6 0%, #FAFDFB 100%);
  color: #134E2E;
  box-shadow: 0 2px 8px rgba(19, 78, 46, 0.06);
}
.m508-royalty-assurance.is-guest {
  border-color: #E8D29B;
  background: linear-gradient(135deg, #FFFBF0 0%, #FFFDF8 100%);
  color: #4A360D;
}
.m508-ra-dot {
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  border-radius: 999px;
  background: #16804B;
  color: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 0 3px rgba(22, 128, 75, 0.16);
}
.m508-royalty-assurance.is-guest .m508-ra-dot {
  background: #C8942A;
  box-shadow: 0 0 0 3px rgba(200, 148, 42, 0.18);
}
.m508-ra-body {
  flex: 1 1 auto;
  min-width: 0;
}
.m508-ra-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-weight: 800;
  font-size: 12.8px;
  color: #0E3F24;
  margin-bottom: 2px;
}
.m508-royalty-assurance.is-guest .m508-ra-title {
  color: #0E2347;
}
.m508-ra-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: #D8F3E4;
  color: #0E5632;
}
.m508-royalty-assurance.is-guest .m508-ra-pill {
  background: #F6E2AD;
  color: #0E2347;
}
.m508-ra-sub {
  margin: 0;
  font-size: 12px;
  color: #24573B;
}
.m508-royalty-assurance.is-guest .m508-ra-sub {
  color: #54411B;
}
.m508-ra-link {
  color: #0E2347;
  font-weight: 800;
  text-decoration: underline;
  margin-left: 4px;
  white-space: nowrap;
}
.m508-ra-activate-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, #FBE08C 0%, #EAB435 100%);
  border: 1px solid #C99625;
  color: #0E2347 !important;
  font-weight: 800;
  font-size: 12.2px;
  text-decoration: none !important;
  box-shadow: 0 3px 10px rgba(178, 128, 22, 0.22);
}
.m508-ra-activate-btn:hover {
  filter: brightness(1.04);
}
@media (max-width: 640px) {
  .m508-royalty-assurance {
    padding: 9px 11px;
    font-size: 12px;
  }
  .m508-ra-title {
    font-size: 12.2px;
  }
}
/* M508-ROYALTY-ASSURANCE:end */
