/*
 * Native page surfaces.
 *
 * Primary app sections and legacy utility panels all use the same viewport:
 * directly below the fixed header and above the fixed bottom navigation.
 * This deliberately removes dimming backdrops, floating cards and modal
 * geometry from every surface that can be opened by the visitor.
 */

:root {
  --cid-page-top: calc(var(--cid-shell-header-height, 50px) + env(safe-area-inset-top, 0px));
  --cid-page-bottom: calc(var(--cid-shell-footer-height, 56px) + env(safe-area-inset-bottom, 0px));
  --cid-page-bg: var(--cid-dedicated-bg, #f6f8fb);
}

/* Keep the persistent native navigation above every page surface. */
.category-bar {
  z-index: 99999 !important;
}

body.cid-comments-sheet-active .category-bar,
body.cid-keyboard-input-active .category-bar {
  transform: translateX(-50%) !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Utility panels: a class kept for controller compatibility, no overlay. */
.modal-overlay {
  position: fixed !important;
  inset: var(--cid-page-top) 0 var(--cid-page-bottom) 0 !important;
  z-index: 5500 !important;
  display: none !important;
  align-items: stretch !important;
  justify-content: stretch !important;
  padding: 0 !important;
  background: var(--cid-page-bg) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.modal-overlay.open {
  display: block !important;
}

.modal-overlay .modal-window {
  display: flex !important;
  flex-direction: column !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  overflow: hidden !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cid-page-bg) !important;
  box-shadow: none !important;
}

.modal-overlay .modal-header {
  flex: 0 0 auto;
  min-height: 56px;
  padding: 10px 16px !important;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .82);
  border-radius: 0 !important;
}

.modal-overlay .modal-title {
  color: #172033;
  font-weight: 800;
}

.modal-overlay .modal-body {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none !important;
  overflow: auto !important;
  border-radius: 0 !important;
  background: var(--cid-page-bg);
}

.modal-overlay .modal-close {
  display: inline-flex !important;
  width: 44px !important;
  height: 44px !important;
  min-width: 44px !important;
  min-height: 44px !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: #4b5563 !important;
  font-size: 0 !important;
  line-height: 1 !important;
}

.modal-overlay .modal-close::before {
  content: '‹';
  font-size: 30px;
  font-weight: 400;
}

/* Notifications are a first-class route, not a dialog. */
#notificationCenter {
  position: fixed !important;
  inset: var(--cid-page-top) 0 var(--cid-page-bottom) 0 !important;
  z-index: 5200 !important;
  display: none !important;
  overflow: auto !important;
  padding: 0 !important;
  background: var(--cid-page-bg) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

#notificationCenter:not([hidden]) {
  display: block !important;
}

/*
 * Compte is a route surface, not a dialog. Keep the host edge-to-edge and
 * let AccountView's internal cards provide the only intentional grouping.
 */
body[data-cid-dedicated-view="profile"] #profileViewContainer {
  position: fixed !important;
  inset: var(--cid-page-top) 0 var(--cid-page-bottom) 0 !important;
  display: block !important;
  width: 100% !important;
  max-width: none !important;
  height: auto !important;
  max-height: none !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cid-page-bg) !important;
  box-shadow: none !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
}

/* Reserve the route's first paint even while the notification query is
 * hydrating, so an empty list cannot collapse and then push the shell. */
#notificationCenter .notification-dialog {
  min-height: 100%;
}

#notificationCenter .notification-dialog {
  display: flex !important;
  width: 100% !important;
  max-width: none !important;
  min-height: 100% !important;
  max-height: none !important;
  overflow: visible !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cid-page-bg) !important;
  box-shadow: none !important;
  animation: none !important;
}

#notificationCenter .notification-center-header {
  position: sticky;
  top: 0;
  flex: 0 0 auto;
  min-height: 56px;
  padding: 12px 16px !important;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
  background: rgba(255, 255, 255, .82);
}

#notificationCenter .notification-list {
  flex: 1 1 auto;
  min-height: 0;
  padding: 8px 16px 24px !important;
  background: var(--cid-page-bg);
}

/* Remove the dimming sheet treatment from comments and make it a route pane. */
.cid-comments-sheet-root {
  inset: var(--cid-page-top) 0 var(--cid-page-bottom) 0 !important;
  z-index: 5200 !important;
  height: auto !important;
  max-height: none !important;
  background: var(--cid-page-bg) !important;
}

.cid-comments-sheet-root.is-open .cid-comments-sheet-backdrop,
.cid-comments-sheet-backdrop {
  display: none !important;
  opacity: 0 !important;
}

.cid-comments-sheet {
  top: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  left: 0 !important;
  width: 100% !important;
  max-width: none !important;
  height: 100% !important;
  max-height: none !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  transform: none !important;
  transition: none !important;
}

/* Reply mode is a compact Facebook-style bottom sheet. It must not become a
 * full route surface: the publication stays fixed behind the dimmed modal,
 * and the composer remains constrained to the viewport width. */
.cid-comments-sheet-root.is-write-mode {
  inset: 0 !important;
  z-index: 6200 !important;
  background: rgba(8, 15, 28, .48) !important;
  pointer-events: auto !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-sheet-backdrop {
  display: block !important;
  opacity: 1 !important;
  background: transparent !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-sheet {
  position: absolute !important;
  top: auto !important;
  right: auto !important;
  bottom: max(8px, var(--cid-comments-keyboard-inset, 0px)) !important;
  left: var(--cid-write-composer-left, 8px) !important;
  width: var(--cid-write-composer-width, calc(100% - 16px)) !important;
  max-width: 720px !important;
  height: auto !important;
  min-height: 0 !important;
  max-height: min(360px, calc(100dvh - 24px)) !important;
  margin: 0 auto !important;
  overflow: visible !important;
  border-radius: 18px !important;
  background: #fff !important;
  box-shadow: 0 -12px 38px rgba(17, 24, 39, .24) !important;
  transform: translateY(100%) !important;
  transition: transform 240ms cubic-bezier(.22, .8, .25, 1) !important;
}

.cid-comments-sheet-root.is-write-mode.is-open .cid-comments-sheet {
  transform: translateY(0) !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-composer {
  position: relative !important;
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  overflow: visible !important;
  border-radius: 18px;
}

.cid-comments-sheet-root .cid-comments-composer-input {
  min-height: 40px !important;
  height: 40px !important;
  max-height: 110px !important;
  border-radius: 21px !important;
  font-size: 16px !important;
}

.cid-comments-reply-context[hidden] {
  display: none !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-emoji-picker {
  position: absolute !important;
  right: 12px !important;
  bottom: calc(100% + 8px) !important;
  margin: 0 !important;
  z-index: 2 !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-composer-row {
  display: flex !important;
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  box-sizing: border-box !important;
  overflow: hidden !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-composer-input {
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

.cid-comments-sheet-root.is-write-mode .cid-comments-composer-emoji,
.cid-comments-sheet-root.is-write-mode .cid-comments-composer-submit {
  flex: 0 0 auto !important;
}

.cid-comments-sheet-handle {
  display: none !important;
}

.cid-comments-sheet-close,
.cid-public-profile-close,
.cid-referral-close {
  border-radius: 0 !important;
  background: transparent !important;
  color: #4b5563 !important;
  font-size: 0 !important;
}

.cid-comments-sheet-close::before,
.cid-public-profile-close::before,
.cid-referral-close::before {
  content: '‹';
  font-size: 30px;
  font-weight: 400;
}

/* Public profile dialogs and referral share sheets are also page surfaces. */
.cid-public-profile-dialog {
  position: fixed !important;
  inset: var(--cid-page-top) 0 var(--cid-page-bottom) 0 !important;
  width: 100% !important;
  height: auto !important;
  max-height: none !important;
  margin: 0 !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cid-page-bg) !important;
  box-shadow: none !important;
}

.cid-public-profile-dialog::backdrop {
  background: transparent !important;
}

.cid-public-profile-card {
  min-height: 100%;
  align-content: center;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: var(--cid-page-bg) !important;
}

.cid-referral-dialog {
  position: fixed !important;
  inset: var(--cid-page-top) 0 var(--cid-page-bottom) 0 !important;
  z-index: 5200 !important;
  display: none !important;
  padding: 0 !important;
  background: var(--cid-page-bg) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.cid-referral-dialog.is-open {
  display: block !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.cid-referral-card {
  width: 100% !important;
  min-height: 100% !important;
  overflow: auto !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: var(--cid-page-bg) !important;
  box-shadow: none !important;
  transform: none !important;
}

.cid-referral-card__head {
  padding: 14px 16px !important;
  color: #172033 !important;
  background: rgba(255, 255, 255, .82) !important;
  border-bottom: 1px solid rgba(15, 23, 42, .08);
}

.cid-referral-card__eyebrow {
  color: #1877f2 !important;
}

.cid-referral-card__body {
  padding: 20px 16px 32px !important;
}

/*
 * Mobile comments use a real Facebook-style bottom sheet. Keep the page and
 * publication behind it, while sizing the sheet from the visible viewport
 * when the keyboard is open. These selectors are intentionally scoped to the
 * comments state so other native pages keep their existing full-page layout.
 */
@media (max-width: 720px) {
  body.cid-comments-sheet-active .cid-comments-sheet-root {
    position: fixed !important;
    inset: var(--cid-page-top) 0 0 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: max(
      0px,
      calc(var(--cid-comments-viewport-height, 100dvh) - var(--cid-page-top, 0px))
    ) !important;
    max-height: max(
      0px,
      calc(var(--cid-comments-viewport-height, 100dvh) - var(--cid-page-top, 0px))
    ) !important;
    overflow: hidden !important;
    background: transparent !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-backdrop {
    display: block !important;
    opacity: .42 !important;
    pointer-events: auto !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet {
    position: absolute !important;
    top: auto !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;
    width: 100% !important;
    max-width: 720px !important;
    height: min(
      680px,
      72dvh,
      calc(var(--cid-comments-viewport-height, 100dvh) - var(--cid-page-top, 0px) - 8px)
    ) !important;
    max-height: calc(
      var(--cid-comments-viewport-height, 100dvh) - var(--cid-page-top, 0px) - 8px
    ) !important;
    margin: 0 auto !important;
    overflow: hidden !important;
    border-radius: 20px 20px 0 0 !important;
    transform: translateY(100%) !important;
    transition: transform 280ms cubic-bezier(.22, .8, .25, 1) !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-open .cid-comments-sheet {
    transform: translateY(0) !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer {
    height: auto !important;
    max-height: none !important;
    background: transparent !important;
    box-shadow: none !important;
    border-radius: 0 !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-sheet-handle,
  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-sheet-header,
  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-sheet-list,
  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-sheet-status {
    display: none !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-compact-composer
    .cid-comments-sheet-backdrop {
    opacity: 0 !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-composer {
    width: 100% !important;
    max-width: 100% !important;
    padding: 8px 28px !important;
    border-top: 0 !important;
    background: #fff !important;
    box-shadow: 0 -4px 18px rgba(17, 24, 39, .12) !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-composer-avatar {
    display: none !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet.is-compact-composer
    .cid-comments-composer-submit {
    background: #f0f2f5 !important;
    color: #65676b !important;
    font-size: 32px !important;
    font-weight: 400 !important;
  }

  body.cid-keyboard-input-active .category-bar {
    opacity: 0 !important;
    pointer-events: none !important;
    visibility: hidden !important;
  }

  /*
   * Direct writing is an anchored mini-composer, not the comments route.
   * Its width follows the publication that launched it and its bottom edge
   * follows the visible viewport/keyboard boundary.
   */
  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode {
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    background: rgba(8, 15, 28, .48) !important;
    pointer-events: auto !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-sheet-backdrop {
    display: block !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    background: transparent !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-sheet {
    position: fixed !important;
    top: auto !important;
    right: auto !important;
    bottom: max(
      8px,
      env(safe-area-inset-bottom, 0px),
      var(--cid-comments-keyboard-inset, 0px)
    ) !important;
    left: var(--cid-write-composer-left, 8px) !important;
    width: var(--cid-write-composer-width, calc(100% - 16px)) !important;
    max-width: 720px !important;
    margin: 0 auto !important;
    height: auto !important;
    max-height: min(360px, calc(100dvh - 24px)) !important;
    overflow: visible !important;
    border-radius: 18px !important;
    box-shadow: 0 -12px 38px rgba(17, 24, 39, .24) !important;
    transform: translateY(100%) !important;
    transition: transform 240ms cubic-bezier(.22, .8, .25, 1) !important;
    pointer-events: auto !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode.is-open
    .cid-comments-sheet {
    transform: translateY(0) !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-composer {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    padding: 8px 12px !important;
    border: 0 !important;
    border-top: 1px solid #e4e6eb !important;
    border-radius: 18px !important;
    background: #fff !important;
    box-shadow: none !important;
    position: relative !important;
    overflow: visible !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-composer-row {
    display: flex !important;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow: hidden !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-composer-input {
    flex: 1 1 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: none !important;
    box-sizing: border-box !important;
    overflow-x: hidden !important;
    min-height: 44px !important;
    height: 44px !important;
    font-size: 16px !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-emoji-picker {
    position: absolute !important;
    right: 12px !important;
    bottom: calc(100% + 8px) !important;
    margin: 0 !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-write-mode
    .cid-comments-composer-submit {
    min-width: 78px !important;
    width: auto !important;
    height: 40px !important;
    padding: 0 14px !important;
    border-radius: 20px !important;
    background: #1877f2 !important;
    color: #fff !important;
    font-size: 13px !important;
    font-weight: 900 !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cid-referral-dialog,
  .cid-referral-card,
  .cid-comments-sheet {
    transition: none !important;
  }
}

/*
 * Comment reading is a side surface on desktop. The publication remains
 * visible in the feed, which makes the comment count feel like a contextual
 * action instead of a route change. The existing mobile rules above keep the
 * same content as a bottom sheet where a side drawer would be too narrow.
 */
@media (min-width: 721px) {
  body.cid-comments-sheet-active .cid-comments-sheet-root.is-view-mode {
    inset: 0 !important;
    z-index: 6200 !important;
    background: rgba(8, 15, 28, .28) !important;
    pointer-events: auto !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-view-mode
    .cid-comments-sheet-backdrop {
    display: block !important;
    opacity: 0 !important;
    background: transparent !important;
    transition: opacity 220ms ease !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-view-mode.is-open
    .cid-comments-sheet-backdrop {
    opacity: 1 !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-view-mode
    .cid-comments-sheet {
    top: var(--cid-page-top, 0px) !important;
    right: 0 !important;
    bottom: var(--cid-page-bottom, 0px) !important;
    left: auto !important;
    width: min(440px, calc(100vw - 24px)) !important;
    max-width: 440px !important;
    height: auto !important;
    max-height: none !important;
    border-radius: 20px 0 0 20px !important;
    box-shadow: -12px 0 38px rgba(17, 24, 39, .18) !important;
    transform: translateX(100%) !important;
    transition: transform 280ms cubic-bezier(.22, .8, .25, 1) !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-view-mode.is-open
    .cid-comments-sheet {
    transform: translateX(0) !important;
  }

  body.cid-comments-sheet-active .cid-comments-sheet-root.is-view-mode
    .cid-comments-sheet-list {
    padding-right: 20px !important;
  }
}
