/* Conecta Frontend Shell v2.58.4.2 — Community layout recovery and shell boundary
 * stabilization.
 *
 * This layer owns only Portal shell geometry. Domain modules retain their
 * content, data, permissions, routes and feature-level interactions.
 */
body.cc-shell--portal {
  --cc-shell-portal-header-height: 68px;
  --cc-shell-portal-header-z: 320;
  --cc-shell-portal-sticky-top: 0px;
  --cc-shell-community-page-top: 24px;
  --cc-shell-community-flow-gap: 24px;
  --cc-shell-community-footer-gap: 0px;
  /* Faixa neutra após a timeline. Ela pertence ao Community Stage e
   * preserva o afastamento aprovado antes do Footer.
   * Desktop usa a folga histórica de 200px; a variante mobile continua
   * sob o contrato próprio do Portal e não recebe o sticky desktop. */
  --cc-shell-community-footer-clearance: 200px;
  /* A máscara é uma zona de oclusão de largura total: fica abaixo do Header
   * e acima de qualquer coluna/timeline que chegue ao limite nativo do sticky. */
  --cc-shell-community-mask-z: 240;
  --cc-shell-community-content-z: 1;
  --cc-shell-community-sidebar-z: 90;
  --cc-shell-community-header-top: calc(
    var(--cc-shell-portal-sticky-top) + var(--cc-shell-community-page-top)
  );
  --cc-shell-community-timeline-guard-height: calc(
    var(--cc-shell-community-page-top) +
    var(--cc-shell-portal-header-height) +
    var(--cc-shell-community-flow-gap)
  );
}

body.admin-bar.cc-shell--portal {
  --cc-shell-portal-sticky-top: 32px;
}

@media (max-width: 782px) {
  body.admin-bar.cc-shell--portal { --cc-shell-portal-sticky-top: 46px; }
}

/* The canonical renderer has no legacy visual selector. This boundary makes
 * Portal shell geometry independent from generic .conecta-header rules. */
body.cc-shell--portal .cc-portal-header {
  display: grid !important;
  flex: initial !important;
  flex-direction: initial !important;
  flex-wrap: nowrap !important;
  align-items: center !important;
  justify-content: initial !important;
}

/* Portal entry contract: the Header owns the only shared gap before the first
 * content surface. Domain modules keep their internal spacing but do not add a
 * second page-entry margin. Community is excluded because its desktop frame is
 * a dedicated sticky composition below. */
body.cc-shell--portal .conecta-app:not(.conecta-community-view) > .cc-portal-header {
  margin-bottom: var(--cc-shell-content-entry-gap, 24px) !important;
}

body.cc-shell--portal .conecta-app:not(.conecta-community-view) > .cc-portal-header + :not(.cc-portal-footer) {
  margin-top: 0 !important;
}

/* Document directory: the live-search module historically owns 30px of top
 * margin while the Header already owns the Portal rhythm. In the flex app
 * canvas both values add up. The Shell removes only that duplicate entry gap. */
body.cc-shell--portal .conecta-app > .cc-portal-header + .conecta-module-search-shell {
  width: min(var(--cc-shell-page-max), calc(100% - (var(--cc-shell-page-gutter) * 2))) !important;
  max-width: var(--cc-shell-page-max) !important;
  margin: 0 auto 24px !important;
}

body.cc-shell--portal .conecta-app > .cc-portal-header + .conecta-module-search-shell + .conecta-docs-layout {
  margin-top: 0 !important;
}

@media (max-width: 767px) {
  body.cc-shell--portal .conecta-app > .cc-portal-header + .conecta-module-search-shell {
    width: 100% !important;
    margin: 0 auto 18px !important;
  }
}

/* Community desktop: one explicit four-layer contract.
 *
 * Feed layer (z: 1): composer, empty state and post cards remain in document
 * flow.
 * Sidebar rails (z: 90): native sticky columns live inside full-stage Grid
 * rails and the right rail keeps its independent scrolling panel.
 * Full-width guard (z: 240): protects the complete corridor below Header,
 * including the side rails, if native sticky reaches its handoff boundary.
 * Header layer (z: 320): remains the only Portal chrome authority.
 *
 * The Community Stage itself does not create a stacking context. Sticky is
 * bounded structurally by its rails; the guard is visual protection only. */
@media (min-width: 1181px) {
  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin {
    --conecta-community-adminbar: var(--cc-shell-portal-sticky-top) !important;
    --conecta-community-page-top: var(--cc-shell-community-page-top) !important;
    --conecta-community-header-height: var(--cc-shell-portal-header-height) !important;
    --conecta-community-sticky-gap: var(--cc-shell-community-flow-gap) !important;
    --conecta-community-sidebar-top: calc(
      var(--cc-shell-community-header-top) +
      var(--cc-shell-portal-header-height) +
      var(--cc-shell-community-flow-gap)
    ) !important;
    padding-top: var(--cc-shell-community-page-top) !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin::before {
    content: "" !important;
    position: fixed !important;
    top: var(--cc-shell-portal-sticky-top) !important;
    left: 0 !important;
    right: 0 !important;
    height: var(--cc-shell-community-timeline-guard-height) !important;
    display: block !important;
    z-index: var(--cc-shell-community-mask-z) !important;
    pointer-events: none !important;
    background: var(--conecta-bg, #F6F7F3) !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin::after {
    content: none !important;
    display: none !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin > .cc-portal-header {
    position: sticky !important;
    top: var(--cc-shell-community-header-top) !important;
    z-index: var(--cc-shell-portal-header-z) !important;
    width: min(var(--cc-shell-page-max), calc(100% - (var(--cc-shell-page-gutter) * 2))) !important;
    max-width: var(--cc-shell-page-max) !important;
    min-height: var(--cc-shell-portal-header-height) !important;
    margin: 0 auto !important;
    isolation: isolate !important;
    background: var(--conecta-card-bg, #fff) !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin > .cc-portal-header + .conecta-community-shell {
    width: min(var(--cc-shell-page-max), calc(100% - (var(--cc-shell-page-gutter) * 2))) !important;
    max-width: var(--cc-shell-page-max) !important;
    margin: var(--cc-shell-community-flow-gap) auto var(--cc-shell-community-footer-gap) !important;
    position: relative !important;
    z-index: auto !important;
    isolation: auto !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin .conecta-community-feed {
    position: relative !important;
    z-index: var(--cc-shell-community-content-z) !important;
    isolation: auto !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin .conecta-community-left,
  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin .conecta-community-right,
  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin .conecta-community-sidebar {
    z-index: var(--cc-shell-community-sidebar-z) !important;
    isolation: auto !important;
  }

  body.cc-shell--portal .conecta-community-view.conecta-community-linkedin .conecta-community-shell ~ .cc-portal-footer {
    margin-top: 0 !important;
  }
}

/* Reader mode intentionally removes fixed Portal chrome behavior. */
body.conecta-reading.cc-shell--portal .conecta-community-view.conecta-community-linkedin::before,
body.conecta-reading.cc-shell--portal .conecta-community-view.conecta-community-linkedin::after,
body.cc-shell--portal.conecta-a11y-reading .conecta-community-view.conecta-community-linkedin::before,
body.cc-shell--portal.conecta-a11y-reading .conecta-community-view.conecta-community-linkedin::after {
  content: none !important;
  display: none !important;
}

/* The Portal footer expands only from the application frame, never from the
 * viewport. This keeps its width stable in desktop and Safari mobile. */
body.cc-shell--portal .conecta-app > .cc-portal-footer,
body.cc-shell--portal .conecta-profile-edit-view > .cc-portal-footer,
body.cc-shell--portal .conecta-profile-public-view > .cc-portal-footer,
body.cc-shell--portal .conecta-profile-directory-view > .cc-portal-footer {
  width: calc(100% + (var(--cc-shell-frame-padding, 24px) * 2)) !important;
  max-width: none !important;
  margin-left: calc(var(--cc-shell-frame-padding, 24px) * -1) !important;
  margin-right: calc(var(--cc-shell-frame-padding, 24px) * -1) !important;
}

@media (max-width: 767px) {
  body.cc-shell--portal .conecta-app > .cc-portal-footer,
  body.cc-shell--portal .conecta-profile-edit-view > .cc-portal-footer,
  body.cc-shell--portal .conecta-profile-public-view > .cc-portal-footer,
  body.cc-shell--portal .conecta-profile-directory-view > .cc-portal-footer {
    width: calc(100% + (var(--cc-shell-page-gutter) * 2)) !important;
    margin-left: calc(var(--cc-shell-page-gutter) * -1) !important;
    margin-right: calc(var(--cc-shell-page-gutter) * -1) !important;
  }
}
