/* Profile identity: one square sport icon beside the sport and role rows.
   Identity typography uses 1.2 line-height; two rows plus their gap size the icon.
   Wrapped labels add text rows without enlarging the icon.
   Desktop/tablet icons are 15% larger; mobile retains its original size. */
body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta > #heroRole {
  width: 100% !important;
}

body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline {
  --scv-sport-row-gap: 2px;
  --scv-sport-icon-size: calc((2.4em + var(--scv-sport-row-gap)) * 1.15);
  display: grid !important;
  grid-template-columns: var(--scv-sport-icon-size) minmax(0, 1fr) !important;
  grid-template-rows: auto auto !important;
  grid-auto-flow: row !important;
  align-items: start !important;
  align-content: start !important;
  gap: var(--scv-sport-row-gap) 8px !important;
  width: 100% !important;
  min-width: 0 !important;
  max-width: 100% !important;
  white-space: normal !important;
  overflow: visible !important;
}

body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-sport-line {
  display: contents !important;
}

body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-icon-media {
  grid-column: 1 !important;
  grid-row: 1 / 3 !important;
  align-self: start !important;
  justify-self: start !important;
  display: block !important;
  position: static !important;
  transform: none !important;
  width: var(--scv-sport-icon-size) !important;
  min-width: var(--scv-sport-icon-size) !important;
  max-width: var(--scv-sport-icon-size) !important;
  height: var(--scv-sport-icon-size) !important;
  min-height: var(--scv-sport-icon-size) !important;
  max-height: var(--scv-sport-icon-size) !important;
  margin: 0 !important;
  padding: 2.875px !important;
  border: 0 !important;
  border-radius: 0 !important;
  box-sizing: border-box !important;
  object-fit: contain !important;
  font-size: inherit !important;
  line-height: inherit !important;
}

body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-sport-text,
body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-role-line {
  display: block !important;
  grid-column: 2 !important;
  width: auto !important;
  min-width: 0 !important;
  max-width: 100% !important;
  margin: 0 !important;
  padding: 0 !important;
  white-space: normal !important;
  overflow-wrap: anywhere !important;
  word-break: normal !important;
}

/* Contain the complete PNG without fading or clipping its outer ring. */
body:is(.owner-mode, .public-profile-page) .hero #heroRole img.sport-icon-media {
  -webkit-mask: none !important;
  mask: none !important;
}

body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-sport-text {
  grid-row: 1 !important;
}
body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-role-line {
  grid-row: 2 !important;
}
body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-role-separator {
  display: none !important;
}

/* Set from measured wrapping on phone browsers. The column widths stay stable
   when the role moves below, so the sport cannot switch between layouts. */
body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline.scv-sport-wrap-mobile .sport-icon-media {
  grid-row: 1 !important;
  align-self: center !important;
}
body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline.scv-sport-wrap-mobile .hero-sport-text {
  align-self: center !important;
}
body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline.scv-sport-wrap-mobile .hero-role-line {
  grid-column: 1 / -1 !important;
}

/* Profiles without a supported sport icon keep their text aligned to the name. */
body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline:not(:has(img.sport-icon-media)) {
  grid-template-columns: minmax(0, 1fr) !important;
}

/* Match the sport columns even though country text uses a smaller phone font. */
body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta:has(#heroRole img.sport-icon-media) > #heroNationalityBadge {
  width: 100% !important;
  margin-left: 0 !important;
}
body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta:has(#heroRole img.sport-icon-media) #heroNationalityBadge .hero-nationality-value {
  display: block !important;
  width: 100% !important;
}
body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta:has(#heroRole img.sport-icon-media) #heroNationalityBadge :is(.hero-nationality-value:has(> img, > svg), .flag-inline) {
  display: grid !important;
  grid-template-columns: var(--scv-country-icon-column, 45.2px) minmax(0, 1fr) !important;
  gap: 0 8px !important;
  width: 100% !important;
  align-items: center !important;
}
body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta:has(#heroRole img.sport-icon-media) #heroNationalityBadge :is(.hero-nationality-value, .flag-inline) > :is(img, svg) {
  grid-column: 1 !important;
  justify-self: center !important;
}
body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta:has(#heroRole img.sport-icon-media) #heroNationalityBadge :is(.hero-nationality-value, .flag-inline) > span:not(.flag-inline) {
  grid-column: 2 !important;
  min-width: 0 !important;
  text-align: left !important;
}
body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline:not(:has(img.sport-icon-media)) .sport-icon-media {
  display: none !important;
}
body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline:not(:has(img.sport-icon-media)) :is(.hero-sport-text, .hero-role-line) {
  grid-column: 1 !important;
}

/* Phone identity starts beside the photo and reserves space before its controls. */
@media (max-width: 760px) {
  body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-inline {
    --scv-sport-icon-size: calc(2.4em + var(--scv-sport-row-gap));
  }

  body:is(.owner-mode, .public-profile-page) .hero #heroRole .sport-icon-media {
    padding: 2.5px !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero .hero-identity-primary {
    position: relative !important;
    top: 0 !important;
  }

  /* Visual role adjustment only; its original grid space stays reserved. */
  body:is(.owner-mode, .public-profile-page) .hero #heroRole .hero-role-line {
    position: relative !important;
    top: -2px !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero #heroName {
    padding-bottom: 0 !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero .hero-identity-primary > .subtitle-meta {
    row-gap: 0 !important;
  }

  /* The username joins privacy and Share in the same outer grid row. */
  body:is(.owner-mode, .public-profile-page) .hero .portrait-stack > .scv-portrait-media {
    display: contents !important;
    align-self: start !important;
    margin-top: 0 !important;
  }

  /* Keep the photo edge out of the owner's existing inter-row gutter. */
  body.owner-mode .hero .portrait-stack > .scv-portrait-media > .portrait {
    margin-bottom: calc(0px - var(--scv-owner-row-gap, 0px)) !important;
  }

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

  body:is(.owner-mode, .public-profile-page) .hero .hero-identity-head {
    padding-bottom: 0 !important;
    margin-bottom: 10px !important;
  }

  body.owner-mode .hero .hero-identity-head {
    margin-bottom: calc(10px - var(--scv-owner-row-gap, 0px)) !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero #heroNationalityBadge {
    margin-bottom: 0 !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero .portrait-stack > #shareProfileBtn,
  body:is(.owner-mode, .public-profile-page) .hero .portrait-stack > .scv-profile-safety-slot {
    align-self: start !important;
  }
}

/* Wider profiles keep country on its own row, as on the phone layout. */
@media (min-width: 761px) {
  body:is(.owner-mode, .public-profile-page) .hero .hero-identity-primary > .subtitle-meta {
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
    gap: 7px !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta > #heroRole {
    width: 100% !important;
    margin: 0 !important;
  }

  body:is(.owner-mode, .public-profile-page) .hero .subtitle-meta > #heroNationalityBadge {
    margin: 0 0 0 2.5px !important;
    padding: 0 !important;
  }
}
