/* Shared profile palette for desktop, tablet, and phone browsers. */
body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > .scv-portrait-media > .portrait-slug {
  background: #eff6ff !important;
  border-color: #bfdbfe !important;
  color: #084a9c !important;
}

body.public-profile-page .hero .scv-profile-safety-slot > .scv-profile-safety-badge {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 5px !important;
  border: 1px solid #c7d2fe !important;
  background: #eef2ff !important;
  color: #3730a3 !important;
  box-shadow: none !important;
}

body.public-profile-page .hero .scv-profile-safety-slot .scv-profile-safety-copy {
  display: flex !important;
  flex: 0 1 auto !important;
  min-width: 0 !important;
  align-items: center !important;
  justify-content: center !important;
  text-align: center !important;
  transform: none !important;
}

body.public-profile-page .hero .scv-profile-safety-slot .scv-profile-safety-copy strong {
  color: #3730a3 !important;
  white-space: normal !important;
}

/* Keep the original archived shield/check and padlock artwork. */
body.public-profile-page .hero .scv-profile-safety-slot > .scv-profile-safety-badge > .scv-profile-safety-icon {
  display: inline-flex !important;
  flex: 0 0 22px !important;
  width: 22px !important;
  height: 22px !important;
  align-items: center !important;
  justify-content: center !important;
  border-radius: 7px !important;
  background: #e0e7ff !important;
  color: #3730a3 !important;
}

body.public-profile-page .hero .scv-profile-safety-slot .scv-profile-safety-icon svg {
  width: 14px !important;
  height: 14px !important;
  flex: 0 0 14px;
}

body.public-profile-page .hero .scv-profile-safety-copy > span {
  display: none !important;
}

/* Keep the adult badge's existing wider-screen footprint after hiding its subtitle. */
@media (min-width: 761px) {
  body.public-profile-page .hero .scv-adult-safety-stack .scv-profile-safety-badge {
    min-height: 46px;
  }
}

/* State classes are maintained by the existing authenticated visibility loader. */
body.owner-mode .hero #ownerProfileVisibilityBadge {
  background: #f8fafc !important;
  border-color: #d7e1ec !important;
  color: #475569 !important;
  box-shadow: none !important;
}

body.owner-mode .hero #ownerProfileVisibilityBadge.is-public {
  background: #ecfdf5 !important;
  border-color: #bbf7d0 !important;
  color: #166534 !important;
}

body.owner-mode .hero #ownerProfileVisibilityBadge strong {
  color: inherit !important;
}

/* A wide phone is not a tall tablet. Keep these rules tied to short touch viewports. */
@media (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) and (pointer: coarse) {
  body:is(.public-profile-page, .owner-mode) {
    --scv-header-height: 52px !important;
    padding-top: 52px !important;
  }
  body:is(.public-profile-page, .owner-mode) .scv-global-header,
  body:is(.public-profile-page, .owner-mode) .scv-global-nav {
    height: 52px !important;
    min-height: 52px !important;
  }
  body:is(.public-profile-page, .owner-mode) .scv-global-brand,
  body:is(.public-profile-page, .owner-mode) .scv-global-logo-img {
    width: 154px !important;
    min-width: 0 !important;
    max-width: 154px !important;
    height: auto !important;
    max-height: 42px !important;
  }
  body:is(.public-profile-page, .owner-mode) .scv-mobile-header-actions > :is(a, button) {
    width: 44px !important;
    height: 44px !important;
    min-width: 44px !important;
    min-height: 44px !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .hero-grid {
    display: grid !important;
    grid-template-columns: 132px minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    grid-template-areas: none !important;
    align-items: start !important;
    gap: 14px !important;
    min-height: 0 !important;
    padding: 14px !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .portrait-stack {
    display: flex !important;
    flex-direction: column !important;
    grid-area: 1 / 1 !important;
    width: 132px !important;
    min-width: 0 !important;
    max-width: 132px !important;
    gap: 8px !important;
    margin: 0 !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .scv-portrait-media {
    display: block !important;
    width: 132px !important;
    min-width: 0 !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .portrait {
    width: 132px !important;
    height: 132px !important;
    min-height: 0 !important;
    aspect-ratio: 1 !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .portrait-slug {
    min-height: 30px !important;
    padding: 6px !important;
    font-size: 12px !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .hero-content {
    display: flex !important;
    flex-direction: column !important;
    grid-area: 1 / 2 !important;
    width: auto !important;
    min-width: 0 !important;
    min-height: 0 !important;
    gap: 10px !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .hero-identity-head,
  body:is(.public-profile-page, .owner-mode) .hero .hero-identity-primary,
  body:is(.public-profile-page, .owner-mode) .hero .hero-name-row {
    display: block !important;
    position: static !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero #heroName {
    font-size: 25px !important;
    line-height: 1.15 !important;
    max-width: 100% !important;
    white-space: normal !important;
    overflow-wrap: anywhere !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .subtitle-meta {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 4px 12px !important;
    margin-top: 5px !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .hero-divider {
    height: 1px !important;
    min-height: 1px !important;
    margin: 0 !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .meta-grid {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin: 0 !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .meta-item {
    min-width: 0 !important;
    min-height: 0 !important;
    padding: 10px !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero #shareProfileBtn,
  body:is(.public-profile-page, .owner-mode) .hero .scv-profile-safety-slot,
  body:is(.public-profile-page, .owner-mode) .hero .scv-owner-profile-visibility-slot {
    position: static !important;
    width: 100% !important;
    margin: 0 !important;
    padding-top: 0 !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero #shareProfileBtn {
    min-height: 44px !important;
    height: auto !important;
  }
  body:is(.public-profile-page, .owner-mode) .hero .scv-share-profile-status:empty {
    display: none !important;
  }
  body.public-profile-page .scv-public-mobile-actions-anchor > .scv-public-hero-actions > a {
    min-height: 44px !important;
    font-size: 14px !important;
  }
  body:is(.public-profile-page, .owner-mode) #photoGrid {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
    gap: 8px !important;
  }
  body:is(.public-profile-page, .owner-mode) #photoGrid > * {
    max-height: 140px !important;
  }
}

/* Phone profile utility controls: one 30px border-box height in every profile.
   Device bounds preserve tablet layouts, including narrow split-screen views. */
@media (max-device-width: 700px), (max-device-height: 700px) {
  @media (max-width: 700px) and (pointer: coarse),
         (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) and (pointer: coarse) {
    body:is(.public-profile-page, .owner-mode) .hero .hero-grid {
      --scv-mobile-profile-utility-height: 30px;
      --scv-owner-status-height: 30px;
    }

    /* Add space above the shared controls without separating photo and username.
       Both grid contributions grow equally when either text or photo sets the height. */
    body:is(.public-profile-page, .owner-mode) .hero .hero-identity-head {
      padding-bottom: 4px !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero .scv-portrait-media {
      margin-top: 4px !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero #heroName {
      position: relative !important;
      left: 2px !important;
    }

    /* Public contact/signup buttons: 40px on phone browsers in both orientations. */
    body.public-profile-page .scv-public-mobile-actions-anchor > .scv-public-hero-actions {
      grid-auto-rows: 40px !important;
    }

    body.public-profile-page .scv-public-mobile-actions-anchor > .scv-public-hero-actions > a {
      height: 40px !important;
      min-height: 40px !important;
      max-height: 40px !important;
      box-sizing: border-box !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > .scv-portrait-media {
      align-self: end !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > .scv-portrait-media > .portrait-slug,
    body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > #shareProfileBtn,
    body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > .scv-profile-safety-slot,
    body:is(.public-profile-page, .owner-mode) .hero .scv-profile-safety-slot > .scv-profile-safety-badge {
      height: 30px !important;
      min-height: 30px !important;
      max-height: 30px !important;
      box-sizing: border-box !important;
      padding-top: 0 !important;
      padding-bottom: 0 !important;
      align-items: center !important;
      justify-content: center !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > #shareProfileBtn {
      grid-column: 5 !important;
      grid-row: 2 !important;
      align-self: end !important;
      border-radius: 10px !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .portrait-stack > .scv-profile-safety-slot {
      grid-column: 3 !important;
      grid-row: 2 !important;
      display: flex !important;
      align-self: end !important;
      margin: 0 !important;
      padding: 0 !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .scv-profile-safety-slot > .scv-profile-safety-badge {
      display: flex !important;
      width: 100% !important;
      min-width: 0 !important;
      padding-left: 4px !important;
      padding-right: 4px !important;
      gap: 4px !important;
      border-radius: 10px !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .hero-divider {
      display: none !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .meta-grid {
      margin-top: 14px !important;
    }

    /* Move both completion labels without shifting the progress bar or views. */
    body.owner-mode .hero #profileViewsCard .profile-summary-completion-head {
      position: relative;
      top: 3px;
    }

    body.public-profile-page .hero .scv-profile-safety-slot > .scv-profile-safety-badge > .scv-profile-safety-icon {
      flex-basis: 14px !important;
      width: 14px !important;
      height: 14px !important;
      border-radius: 0 !important;
      background: transparent !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .scv-profile-safety-slot .scv-profile-safety-copy {
      display: flex !important;
      flex: 0 1 auto !important;
      min-width: 0 !important;
      align-items: center !important;
      justify-content: center !important;
      text-align: center !important;
      transform: none !important;
    }

    body:is(.public-profile-page, .owner-mode) .hero .scv-profile-safety-slot .scv-profile-safety-copy strong {
      line-height: 14px !important;
      white-space: normal !important;
    }
  }

  @media (orientation: portrait) and (max-width: 640px) and (pointer: coarse) {
    /* Account for the two owner grid gutters around the empty divider track. */
    body.owner-mode .hero .meta-grid {
      margin-top: calc(14px - var(--scv-owner-row-gap, 0px) - var(--scv-owner-row-gap, 0px)) !important;
    }
  }

  /* Keep the utility row together when the phone rotates. */
  @media (orientation: landscape) and (max-height: 500px) and (max-width: 1100px) and (pointer: coarse) {
    body:is(.public-profile-page, .owner-mode) .hero .hero-grid {
      grid-template-columns: 132px 14px minmax(0, 1fr) 8px minmax(0, 1fr) !important;
      grid-template-rows: minmax(132px, auto) 30px auto auto auto auto auto !important;
      gap: 0 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero :is(.portrait-stack, .hero-content) {
      display: contents !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero .scv-portrait-media {
      grid-column: 1 !important;
      grid-row: 1 / 3 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero .hero-identity-head {
      grid-column: 3 / 6 !important;
      grid-row: 1 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero #profileViewsCard {
      grid-column: 1 / 6 !important;
      grid-row: 3 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero .hero-divider {
      grid-column: 1 / 6 !important;
      grid-row: 4 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero .meta-grid {
      grid-column: 1 / 6 !important;
      grid-row: 5 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero #profileControlsCard {
      grid-column: 1 / 6 !important;
      grid-row: 6 !important;
    }
    body:is(.public-profile-page, .owner-mode) .hero #shareProfileStatus {
      grid-column: 3 / 6 !important;
      grid-row: 7 !important;
    }
  }
}
